⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ffs.c

📁 ADAM2 sources (modified by Oleg)
💻 C
📖 第 1 页 / 共 3 页
字号:
/*------------------------------------------------------------------------------*//*                                                                             	*//*   Copyright (C) 1999-2003 by Texas Instruments, Inc.  All rights reserved.  	*//*   Copyright (C) 2001-2003 Telogy Networks.	    						   	*//*                                                                              *//*     IMPORTANT - READ CAREFULLY BEFORE PROCEEDING TO USE SOFTWARE.           	*//*                                                                             	*//*  This document is displayed for you to read prior to using the software     	*//*  and documentation.  By using the software and documentation, or opening    	*//*  the sealed packet containing the software, or proceeding to download the   	*//*  software from a Bulletin Board System(BBS) or a WEB Server, you agree to   	*//*  abide by the following Texas Instruments License Agreement. If you choose  	*//*  not to agree with these provisions, promptly discontinue use of the        	*//*  software and documentation and return the material to the place you        	*//*  obtained it.                                                               	*//*                                                                             	*//*                               *** NOTE ***                                  	*//*                                                                             	*//*  The licensed materials contain MIPS Technologies, Inc. confidential        	*//*  information which is protected by the appropriate MIPS Technologies, Inc.  	*//*  license agreement.  It is your responsibility to comply with these         	*//*  licenses.                                                                  	*//*                                                                             	*//*                   Texas Instruments License Agreement                       	*//*                                                                             	*//*  1. License - Texas Instruments (hereinafter "TI"), grants you a license    	*//*  to use the software program and documentation in this package ("Licensed   	*//*  Materials") for Texas Instruments broadband products.                      	*//*                                                                             	*//*  2. Restrictions - You may not reverse-assemble or reverse-compile the      	*//*  Licensed Materials provided in object code or executable format.  You may  	*//*  not sublicense, transfer, assign, rent, or lease the Licensed Materials    	*//*  or this Agreement without written permission from TI.                      	*//*                                                                             	*//*  3. Copyright - The Licensed Materials are copyrighted. Accordingly, you    	*//*  may either make one copy of the Licensed Materials for backup and/or       	*//*  archival purposes or copy the Licensed Materials to another medium and     	*//*  keep the original Licensed Materials for backup and/or archival purposes.  	*//*                                                                             	*//*  4. Runtime and Applications Software - You may create modified or          	*//*  derivative programs of software identified as Runtime Libraries or         	*//*  Applications Software, which, in source code form, remain subject to this  	*//*  Agreement, but object code versions of such derivative programs are not    	*//*  subject to this Agreement.                                                 	*//*                                                                             	*//*  5. Warranty - TI warrants the media to be free from defects in material    	*//*  and workmanship and that the software will substantially conform to the    	*//*  related documentation for a period of ninety (90) days after the date of   	*//*  your purchase. TI does not warrant that the Licensed Materials will be     	*//*  free from error or will meet your specific requirements.                   	*//*                                                                             	*//*  6. Remedies - If you find defects in the media or that the software does   	*//*  not conform to the enclosed documentation, you may return the Licensed     	*//*  Materials along with the purchase receipt, postage prepaid, to the         	*//*  following address within the warranty period and receive a refund.         	*//*                                                                             	*//*  TEXAS INSTRUMENTS                                                          	*//*  Application Specific Products, MS 8650                                     	*//*  c/o ADAM2 Application Manager                                              	*//*  12500 TI Boulevard                                                         	*//*  Dallas, TX 75243  - U.S.A.                                                 	*//*                                                                             	*//*  7. Limitations - TI makes no warranty or condition, either expressed or    	*//*  implied, including, but not limited to, any implied warranties of          	*//*  merchantability and fitness for a particular purpose, regarding the        	*//*  licensed materials.                                                        	*//*                                                                             	*//*  Neither TI nor any applicable licensor will be liable for any indirect,    	*//*  incidental or consequential damages, including but not limited to loss of  	*//*  profits.                                                                   	*//*                                                                             	*//*  8. Term - The license is effective until terminated.   You may terminate   	*//*  it at any other time by destroying the program together with all copies,   	*//*  modifications and merged portions in any form. It also will terminate if   	*//*  you fail to comply with any term or condition of this Agreement.           	*//*                                                                             	*//*  9. Export Control - The re-export of United States origin software and     	*//*  documentation is subject to the U.S. Export Administration Regulations or  	*//*  your equivalent local regulations. Compliance with such regulations is     	*//*  your responsibility.                                                       	*//*                                                                             	*//*                         *** IMPORTANT NOTICE ***                            	*//*                                                                             	*//*  Texas Instruments (TI) reserves the right to make changes to or to         	*//*  discontinue any semiconductor product or service identified in this        	*//*  publication without notice. TI advises its customers to obtain the latest  	*//*  version of the relevant information to verify, before placing orders,      	*//*  that the information being relied upon is current.                         	*//*                                                                             	*//*  TI warrants performance of its semiconductor products and related          	*//*  software to current specifications in accordance with TI's standard        	*//*  warranty. Testing and other quality control techniques are utilized to     	*//*  the extent TI deems necessary to support this warranty. Unless mandated    	*//*  by government requirements, specific testing of all parameters of each     	*//*  device is not necessarily performed.                                       	*//*                                                                             	*//*  Please be aware that Texas Instruments products are not intended for use   	*//*  in life-support appliances, devices, or systems. Use of a TI product in    	*//*  such applications without the written approval of the appropriate TI       	*//*  officer is prohibited. Certain applications using semiconductor devices    	*//*  may involve potential risks of injury, property damage, or loss of life.   	*//*  In order to minimize these risks, adequate design and operating            	*//*  safeguards should be provided by the customer to minimize inherent or      	*//*  procedural hazards. Inclusion of TI products in such applications is       	*//*  understood to be fully at the risk of the customer using TI devices or     	*//*  systems.                                                                   	*//*                                                                             	*//*  TI assumes no liability for TI applications assistance, customer product   	*//*  design, software performance, or infringement of patents or services       	*//*  described herein. Nor does TI warrant or represent that license, either    	*//*  expressed or implied, is granted under any patent right, copyright, mask   	*//*  work right, or other intellectual property right of TI covering or         	*//*  relating to any combination, machine, or process in which such             	*//*  semiconductor products or services might be or are used.                   	*//*                                                                             	*//*  All company and/or product names are trademarks and/or registered          	*//*  trademarks of their respective manaufacturers.                             	*//*------------------------------------------------------------------------------*/#include "_stdio.h"#include "fcb.h"#include "ffs.h"#include "ffs_util.h"#include "flashop.h"#include "hw.h" #include "support.h" /* Flash File System guidlines                                               *//* The flash file system can only open read write and close a file that      *//*  the rights apply. That is even root has no authority to read a not       *//*  owned file.                                                              *//*                                                                           *//* FindFirst finds the first file in the global file system that meets the   *//*  rights. Only root can see all file entries, but cannot read/write them.  *//*                                                                           *//* INodes are FFS dependent that is the system can have many FFS and inode   *//*  is maintained for each.                                                  *//*                                                                           */ffs_tMountPoint ffs_sFlashFileSystemsMounts[NUM_OF_SLOTS+1] = {{0,0}, {0,0}};int ffs_iNumOfFlashMounts = 0;          int _ffs_hw_isslotenabled(int slot)  {  return(FALSE);  }void ffs_RepairFlashFileSystems(int slot)  {  }void ffs_InitFlashFIleSystem(void)  {  int i;  bit32u bootblocksize;  sys_printf("\nFlash File System ");      bootblocksize=FWBGetBlockSize(CS0_BASE);  if (bootblocksize<MIN_BOOT_BLOCK_SIZE)     bootblocksize=MIN_BOOT_BLOCK_SIZE;  ffs_iNumOfFlashMounts=0;  ffs_AddFileSystem(0,(void *)(CS0_BASE+bootblocksize));  for(i=1;i<=NUM_OF_SLOTS;i++)    {    }     sys_printf("initialized.\n");  }int ffs_AddFileSystem(int slot,void *ffs)  {  int i;  if (slot)    {    if (!_ffs_hw_isslotenabled(slot))      {      return(FFS_ERRS_SLOT_NOT_ENABLED);      }    }  if (!strncmp((char *)ffs,"FFS",3)==0)    {    return(FFS_ERRS_NOT_A_VALID_FFS);    }  if ((((char *)ffs)[3])>FFS_VERSION)    {    return(FFS_ERRS_VERSION_NOT_SUPPORTED);    }  for(i=0;i<ffs_iNumOfFlashMounts;i++)    {    if (ffs_sFlashFileSystemsMounts[i].slot==slot)      return(FFS_ERRS_FFS_ALREADY_MOUNTED);    }  ffs_sFlashFileSystemsMounts[ffs_iNumOfFlashMounts].ffs_ptr=ffs;  ffs_sFlashFileSystemsMounts[ffs_iNumOfFlashMounts].slot=slot;  ffs_iNumOfFlashMounts++;  ffs_RepairFlashFileSystems(slot);  return(FFS_ERRS_NO_ERROR);  }int ffs_RemoveSlotMount(int slot)  {  void *tmp_ffs_ptr;  int i,tmp_slot;    for(i=0;i<ffs_iNumOfFlashMounts;i++)    {    if (ffs_sFlashFileSystemsMounts[i].slot==slot)      {      ffs_iNumOfFlashMounts--;      tmp_ffs_ptr=ffs_sFlashFileSystemsMounts[ffs_iNumOfFlashMounts].ffs_ptr;      tmp_slot=ffs_sFlashFileSystemsMounts[ffs_iNumOfFlashMounts].slot;      ffs_sFlashFileSystemsMounts[ffs_iNumOfFlashMounts].ffs_ptr=ffs_sFlashFileSystemsMounts[i].ffs_ptr;      ffs_sFlashFileSystemsMounts[ffs_iNumOfFlashMounts].slot=ffs_sFlashFileSystemsMounts[i].slot;      ffs_sFlashFileSystemsMounts[i].ffs_ptr=tmp_ffs_ptr;      ffs_sFlashFileSystemsMounts[i].slot=tmp_slot;      return(FFS_ERRS_NO_ERROR);      }    }  return(FFS_ERRS_NO_SUCH_FFS);  }int ffs_AddNewSlotMount(int slot)  {  return(ffs_AddFileSystem(slot,(void *)(((slot-1)<<15)+SLOT_BASE)));  }ffs_tEntry *_ffs_DumpFlashFileSystemEntry(ffs_tEntry *ffse,int show_deleted)  {  int i,iFileFlags,iFileNameLength;  bit32 iFileLength;  char *cp;    iFileFlags=_ffs_GetBit16Value(ffse->flags);  iFileLength=_ffs_GetBit24Value(ffse->flen);  iFileNameLength=ffse->fnlen&0x0ff;  if ((iFileFlags&FFS_F_DELETE)||(show_deleted))    {    sys_printf("%c",(iFileFlags&FFS_F_DELETE)?' ':'b');    sys_printf("%c",(iFileFlags&FFS_F_BLOCK_ALIGN)?'B':' ');    sys_printf("%c",(iFileFlags&FFS_F_AUTO_EXECUTE)?'a':' ');    sys_printf("%c",(iFileFlags&FFS_F_EXT_FIFLE_SYSTEM)?'e':' ');    sys_printf("%c",(iFileFlags&FFS_F_VOLUME_ID)?'v':' ');    sys_printf("%c",(iFileFlags&FFS_F_LINK)?'l':' ');    sys_printf("%c",(iFileFlags&FFS_F_DIRECTORY)?'d':' ');    sys_printf("%c",(iFileFlags&FFS_F_USER_READ)?'r':' ');    sys_printf("%c",(iFileFlags&FFS_F_USER_WRITE)?'w':' ');    sys_printf("%c",(iFileFlags&FFS_F_USER_EXECUTE)?'x':' ');    sys_printf("%c",(iFileFlags&FFS_F_GROUP_READ)?'r':' ');    sys_printf("%c",(iFileFlags&FFS_F_GROUP_WRITE)?'w':' ');    sys_printf("%c",(iFileFlags&FFS_F_GROUP_EXECUTE)?'x':' ');    sys_printf("%c",(iFileFlags&FFS_F_WORLD_READ)?'r':' ');    sys_printf("%c",(iFileFlags&FFS_F_WORLD_WRITE)?'w':' ');    sys_printf("%c",(iFileFlags&FFS_F_WORLD_EXECUTE)?'x':' ');    sys_printf(" %d:%d ",ffse->uid,ffse->gid);    sys_printf("a:%3d i:%d ",ffse->aeo,_ffs_GetBit16Value(ffse->inode));    _ffs_DecodeAndPrintMdate(_ffs_GetBit16Value(ffse->mdate));    sys_printf(" ");    _ffs_DecodeAndPrintMtime(_ffs_GetBit16Value(ffse->mtime));    sys_printf(" %7d",iFileLength);    cp=ffse->data;    sys_printf(" ");    for(i=0;i<iFileNameLength;i++)      sys_printf("%c",*cp++);    sys_printf("\n");    }  return((ffs_tEntry *)(((char *)ffse)+(sizeof(ffs_tEntry)-1)+iFileLength+iFileNameLength));  }bit16u _ffs_GetBit16Value(char *cbit16)  {  int tmp;  tmp=(int)*cbit16++;  tmp&=0x0ff;  tmp|=(((int) *cbit16)<<8)&0x0ff00;  return(tmp);  }   void _ffs_PutBit16Value(char *cbit16, bit16u val)  {     *cbit16++=(bit8) val;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -