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

📄 ui.lst

📁 Philips LPC2138 Demo Application with Keil C
💻 LST
📖 第 1 页 / 共 3 页
字号:
ARM COMPILER V2.42,  ui                                                                    27/03/06  10:45:52  PAGE 1   


ARM COMPILER V2.42, COMPILATION OF MODULE ui
OBJECT MODULE PLACED IN .\obj\ui.obj
COMPILER INVOKED BY: C:\Keil\ARM\BIN\CA.exe src\ui.c THUMB DEBUG PRINT(.\LST\UI.LST) TABS(4) OBJECT(.\obj\ui.obj) 

stmt  level    source

    1          /*****************************************************************************\
    2          *              efs - General purpose Embedded Filesystem library              *
    3          *          --------------------- -----------------------------------          *
    4          *                                                                             *
    5          * Filename : ui.c                                                             *
    6          * Description : This file contains functions which will be presented to the   *
    7          *               user of this library.                                         *
    8          *                                                                             *
    9          * This library is free software; you can redistribute it and/or               *
   10          * modify it under the terms of the GNU Lesser General Public                  *
   11          * License as published by the Free Software Foundation; either                *
   12          * version 2.1 of the License, or (at your option) any later version.          *
   13          *                                                                             *
   14          * This library is distributed in the hope that it will be useful,             *
   15          * but WITHOUT ANY WARRANTY; without even the implied warranty of              *
   16          * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU           *
   17          * Lesser General Public License for more details.                             *
   18          *                                                                             *
   19          *                                                    (c)2005 Michael De Nil   *
   20          *                                                    (c)2005 Lennart Yseboodt *
   21          \*****************************************************************************/
   22          
   23          /*****************************************************************************/
   24          #include "ui.h"
   25          /*****************************************************************************/
   26          
   27          /*****************************************************************************
   28           * short listfiles(char *dir)
   29           *
   30           * Deschription: This function returns the number of files / directories
   31           * inside the given directory.
   32           *
   33           * Return value: number of files/directories in the given directory or -1
   34           * if directory does not exist.
   35          \*****************************************************************************/
   36          
   37          short listFiles(FileSystem *fs, char *dirname)
   38          {
   39   1          unsigned long startCluster;
   40   1          unsigned char fileEntryCount;
   41   1          unsigned short counter=0;
   42   1          unsigned long offset=0;
   43   1          FileRecord fileEntry;
   44   1          FileLocation loc;
   45   1          unsigned char buf[512];
   46   1          File dir;
   47   1          unsigned short i;
   48   1          
   49   1          /* Find out if we are searching in the root dir or in */
   50   1          if(dirname[0]=='/' && dirname[1]=='\0')
   51   1          {
   52   2              if( (fs->type == FAT12) || (fs->type == FAT16) )
   53   2              {
   54   3                  for(i=0;i<=(fs->volumeId.RootEntryCount/16);i++)
   55   3                  {
   56   4                      loc.Sector=fs->FirstSectorRootDir + i;
   57   4                      part_readBuf(fs->part,loc.Sector,buf);
   58   4                      /* I STOPPED HERE*/
   59   4                      /* FIXME */
ARM COMPILER V2.42,  ui                                                                    27/03/06  10:45:52  PAGE 2   

   60   4                  }
   61   3              }
   62   2          }
   63   1          else /* Normal directory */
   64   1          {
   65   2              /* Check if path given is a directory */
   66   2              if(fs_findFile(fs,dirname,&loc,0)!=2)
   67   2              {
   68   3                  FUNC_OUT((TXT("")));
   69   3                  return(-1);
   70   3              }
   71   2          
   72   2              /* Find out what the startcluster of the directory is */
   73   2              part_readBuf(fs->part,loc.Sector, buf);
   74   2              fileEntry = *(((FileRecord*)buf) + loc.Offset);
   75   2              startCluster = (((unsigned long)fileEntry.FirstClusterHigh)<<16) 
   76   2                  + fileEntry.FirstClusterLow;
   77   2      
   78   2              /* Init of dir */
   79   2              dir.fs=fs;
   80   2              dir.Cache.LogicCluster=-1;
   81   2              dir.Cache.FirstCluster=startCluster;
   82   2              dir.DirEntry.Attribute=ATTR_DIRECTORY;
   83   2          
   84   2              while((file_fread(&dir,offset,512,buf)))
   85   2              {
   86   3                  DBG((TXT("Read 512 bytes from dir with offset %li.\n"),offset));
   87   3                  for(fileEntryCount=0;fileEntryCount<16;fileEntryCount++)
   88   3                  {
   89   4                      fileEntry = *(((FileRecord*)buf) + fileEntryCount);
   90   4                      if( !( (fileEntry.Attribute & 0x0F) == 0x0F ) )
   91   4                      {
   92   5                          if
   93   5                          (
   94   5                           (fileEntry.FileName[0]>='A' && fileEntry.FileName[0]<='Z')
   95   5                           ||
   96   5                           (fileEntry.FileName[0]>='0' && fileEntry.FileName[0]<='9')
   97   5                          )
   98   5                          {
   99   6                              DBG((TXT("Filename: %s\n"),fileEntry.FileName));
  100   6                              counter++;
  101   6                          }
  102   5                      }
  103   4                  }
  104   3                  offset+=512;
  105   3              }
  106   2          }
  107   1          
  108   1          FUNC_OUT((TXT("")));
  109   1          return(counter);
  110   1          
  111   1          return(-1);
  112   1      }
  113          /*****************************************************************************/
  114          
  115          /* ****************************************************************************  
  116           * esint16 rmfile(FileSystem *fs,euint8* filename)
  117           * Description: This function takes a filename as argument and deletes it,
  118           * by freeing it's clusterchain, and deleting it's entry from the directory.
  119           * Return value: 0 on success, -1 on errors, like file not found.
  120          */
  121          esint16 rmfile(FileSystem *fs,euint8* filename)
  122          {
  123   1          FileLocation loc;
  124   1          ClusterChain cache;
  125   1          euint8* buf;
ARM COMPILER V2.42,  ui                                                                    27/03/06  10:45:52  PAGE 3   

  126   1          euint32 firstCluster=0;
  127   1          
  128   1          if((fs_findFile(fs,(eint8*)filename,&loc,0))==1){
  129   2              buf=part_getSect(fs->part,loc.Sector,IOM_MODE_READWRITE);
  130   2              firstCluster = ex_getb16(buf,loc.Offset*32+20);
  131   2              firstCluster <<= 16;
  132   2              firstCluster += ex_getb16(buf,loc.Offset*32+26);
  133   2              /* Bugfix:
  134   2               * By clearing the entire structure, you mark end of directory.
  135   2               * If this is not the case, files that are further away cannot
  136   2              * be opened anymore by implementations that follow the spec. */
  137   2              /*memClr(buf+(loc.Offset*32),32);*/
  138   2              *(buf+(loc.Offset*32)+0) = 0xE5; /* Mark file deleted */
  139   2              part_relSect(fs->part,buf);
  140   2              cache.DiscCluster = cache.LastCluster = cache.Linear = cache.LogicCluster = 0;
  141   2              cache.FirstCluster = firstCluster;
  142   2              fat_unlinkClusterChain(fs,&cache);
  143   2              return(0);
  144   2          }
  145   1          return(-1);
  146   1      }
  147          
  148          /*****************************************************************************/
  149          esint8 mkdir(FileSystem *fs,eint8* dirname)
  150          {
  151   1          FileLocation loc;
  152   1          FileRecord direntry;
  153   1          euint32 nc,parentdir;
  154   1          euint8* buf;
  155   1          eint8 ffname[11];
  156   1          
  157   1          if( fs_findFile(fs,dirname,&loc,&parentdir) ){
  158   2              return(-1);
  159   2          }
  160   1          if(parentdir==0)return(-2);
  161   1          
  162   1          if(!fs_findFreeFile(fs,dirname,&loc,0))return(-3);
  163   1          
  164   1          /* You may never search for a free cluster, and the call
  165   1           * functions that may cause changes to the FAT table, that
  166   1           * is why getNextFreeCluster has to be called AFTER calling
  167   1           * fs_findFreeFile, which may have to expand a directory in
  168   1           * order to store the new filerecord !! 
  169   1           */
  170   1          
  171   1          nc = fs_getNextFreeCluster(fs,fs_giveFreeClusterHint(fs));
  172   1          if(nc==0)return(0);
  173   1          
  174   1          fs_clearCluster(fs,nc);
  175   1          
  176   1          buf = part_getSect(fs->part,loc.Sector,IOM_MODE_READWRITE);
  177   1      
  178   1          dir_getFatFileName(dirname,ffname);
  179   1          memClr(&direntry,sizeof(direntry));
  180   1          memCpy(ffname,&direntry,11);
  181   1          direntry.FileSize = 0;
  182   1          direntry.FirstClusterHigh=nc>>16;
  183   1          direntry.FirstClusterLow=nc&0xFFFF;
  184   1          direntry.Attribute = ATTR_DIRECTORY;
  185   1          memCpy(&direntry,buf+(32*loc.Offset),32);
  186   1              
  187   1          part_relSect(fs->part,buf);
  188   1          
  189   1          buf = part_getSect(fs->part,fs_clusterToSector(fs,nc),IOM_MODE_READWRITE);
  190   1          
  191   1          memClr(&direntry,sizeof(direntry));
ARM COMPILER V2.42,  ui                                                                    27/03/06  10:45:52  PAGE 4   

  192   1          memCpy(".          ",&direntry,11);
  193   1          direntry.Attribute = ATTR_DIRECTORY;
  194   1          direntry.FileSize = 0;
  195   1          direntry.FirstClusterHigh=nc>>16;
  196   1          direntry.FirstClusterLow=nc&0xFFFF;
  197   1          memCpy(&direntry,buf,32);
  198   1          
  199   1          if(fs->type == FAT32 && parentdir == fs->volumeId.RootCluster){
  200   2              parentdir = 0;
  201   2          }
  202   1          if(fs->type != FAT32 && parentdir<=1){
  203   2              parentdir = 0;
  204   2          } 
  205   1          
  206   1          memClr(&direntry,sizeof(direntry));
  207   1          memCpy("..         ",&direntry,11);
  208   1          direntry.Attribute = ATTR_DIRECTORY;
  209   1          direntry.FileSize = 0;
  210   1          direntry.FirstClusterHigh=parentdir>>16;
  211   1          direntry.FirstClusterLow=parentdir&0xFFFF;
  212   1          memCpy(&direntry,buf+32,32);
  213   1      
  214   1          part_relSect(fs->part,buf);
  215   1          
  216   1          fat_setNextClusterAddress(fs,nc,fat_giveEocMarker(fs));
  217   1      
  218   1          return(0);
  219   1      }
ARM COMPILER V2.42,  ui                                                                    27/03/06  10:45:52  PAGE 5   

ASSEMBLY LISTING OF GENERATED OBJECT CODE



*** EXTERNALS:
 EXTERN CODE16 (lpc2000_debug_printf?T)
 EXTERN CODE16 (memCpy?T)
 EXTERN CODE16 (memClr?T)
 EXTERN CODE16 (ex_getb16?T)
 EXTERN CODE16 (part_readBuf?T)
 EXTERN CODE16 (part_getSect?T)
 EXTERN CODE16 (part_relSect?T)
 EXTERN CODE16 (fs_clusterToSector?T)
 EXTERN CODE16 (fs_getNextFreeCluster?T)
 EXTERN CODE16 (fs_giveFreeClusterHint?T)
 EXTERN CODE16 (fs_findFreeFile?T)
 EXTERN CODE16 (fs_findFile?T)
 EXTERN CODE16 (fs_clearCluster?T)
 EXTERN CODE16 (dir_getFatFileName?T)
 EXTERN CODE16 (file_fread?T)
 EXTERN CODE16 (fat_setNextClusterAddress?T)
 EXTERN CODE16 (fat_giveEocMarker?T)
 EXTERN CODE16 (fat_unlinkClusterChain?T)
 EXTERN CODE16 (?C?SDIV?T)



*** PUBLICS:
 PUBLIC         listFiles?T
 PUBLIC         rmfile?T
 PUBLIC         mkdir?T



*** DATA SEGMENT '?CON?ui':
 00000000          ??S_4:
 00000000            DB          '..         ',0x00
 0000000C          ??S_3:
 0000000C            DB          '.          ',0x00
 00000018          ??S_2:
 00000018            DB          'Filename: %s',0x0A,0x00
 00000026          ??S_1:
 00000026            DB          'Read 512 bytes from dir with offset %l'
 0000004C            DB          'i.',0x0A,0x00

*** CODE SEGMENT '?PR?listFiles?T?ui':
   37: short listFiles(FileSystem *fs, char *dirname)
 00000000  B5F0      PUSH        {R4-R7,LR}
 00000002  1C0E      MOV         R6,R1 ; dirname
 00000004  ---- Variable 'dirname' assigned to Register 'R6' ----
 00000004  1C05      MOV         R5,R0 ; fs
 00000006  ---- Variable 'fs' assigned to Register 'R5' ----
 00000006  4800      LDR         R0,=0xFFFFFD84
 00000008  4485      ADD         R13,R13,R0
   38: {
 0000000A            ; SCOPE-START
   41:     unsigned short counter=0;
 0000000A  2100      MOV         R1,#0x0
 0000000C  A800      ADD         R0,R13,#0x0
 0000000E  8001      STRH        R1,[R0,#0x0] ; counter
   42:     unsigned long offset=0;
 00000010  2400      MOV         R4,#0x0
 00000012  ---- Variable 'offset' assigned to Register 'R4' ----
   50:     if(dirname[0]=='/' && dirname[1]=='\0')
 00000012  1C30      MOV         R0,R6 ; dirname
 00000014  7800      LDRB        R0,[R0,#0x0] ; dirname
 00000016  282F      CMP         R0,#0x2F
 00000018  D129      BNE         L_1  ; T=0x0000006E
 0000001A  1C30      MOV         R0,R6 ; dirname
 0000001C  7840      LDRB        R0,[R0,#0x1]
 0000001E  2800      CMP         R0,#0x0
 00000020  D125      BNE         L_1  ; T=0x0000006E
ARM COMPILER V2.42,  ui                                                                    27/03/06  10:45:52  PAGE 6   

   52:         if( (fs->type == FAT12) || (fs->type == FAT16) )
 00000022  1C28      MOV         R0,R5 ; fs
 00000024  303C      ADD         R0,#0x3C
 00000026  7800      LDRB        R0,[R0,#0x0]

⌨️ 快捷键说明

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