DEVICE.LST
上传用户:jcsy2001
上传日期:2013-11-29
资源大小:201k
文件大小:7k
开发平台:

C/C++

  1. C51 COMPILER V8.02   DEVICE                                                                04/29/2007 12:48:54 PAGE 1   
  2. C51 COMPILER V8.02, COMPILATION OF MODULE DEVICE
  3. OBJECT MODULE PLACED IN DEVICE.OBJ
  4. COMPILER INVOKED BY: D:KeilC51BINC51.EXE DEVICE.C BROWSE DEBUG OBJECTEXTEND
  5. line level    source
  6.    1          #include "common.h"
  7.    2          #include "DEVICE.H"
  8.    3          #include "HAL.H"
  9.    4          #include "HPI.H"
  10.    5          #include "HPI32.H"
  11.    6          
  12.    7          //////////////////////////////////
  13.    8          extern unsigned char xdata DBUF[BUFFER_LENGTH];
  14.    9          extern SYS_INFO_BLOCK xdata DeviceInfo;
  15.   10          extern FILE_INFO xdata ThisFile;
  16.   11          extern unsigned int xdata DirStartCluster;
  17.   12          extern unsigned long xdata DirStartCluster32;
  18.   13          
  19.   14          unsigned char xdata DBUF[BUFFER_LENGTH];
  20.   15                  
  21.   16          ///////////////////////////////////////////////////////////////////////////
  22.   17          unsigned char InitFileSystem(void)
  23.   18          {
  24.   19   1              unsigned int ReservedSectorsNum;
  25.   20   1      
  26.   21   1              ////////////////////////////////////////////////////
  27.   22   1              DeviceInfo.BPB_BytesPerSec=512; //暂假设为512
  28.   23   1              
  29.   24   1      
  30.   25   1              ////////////////////////////////////////////////////
  31.   26   1              if(!SdReadSector(0x0,1,DBUF))
  32.   27   1                      return FALSE;
  33.   28   1          if(DBUF[510] != 0x55 || DBUF[511] != 0xaa) return FALSE;
  34.   29   1      
  35.   30   1              //////////////////////////////////
  36.   31   1              if(DBUF[0]==0xeb||DBUF[0]==0xe9)
  37.   32   1                      {
  38.   33   2                      DeviceInfo.StartSector=0;
  39.   34   2                      }
  40.   35   1              else
  41.   36   1                      {
  42.   37   2                       if(DBUF[446] != 0x80 && DBUF[446] != 0)  return FALSE;
  43.   38   2                       DeviceInfo.StartSector=LSwapINT32(DBUF[454],DBUF[455],DBUF[456],DBUF[457]);
  44.   39   2                      }
  45.   40   1              ///////////////////////////////////////////////////////
  46.   41   1              if(!SdReadSector(DeviceInfo.StartSector,1,DBUF))
  47.   42   1                      return FALSE;
  48.   43   1              
  49.   44   1              if(DBUF[510] != 0x55 || DBUF[511] != 0xaa) return FALSE;
  50.   45   1      
  51.   46   1              DeviceInfo.BPB_BytesPerSec=LSwapINT16(DBUF[11],DBUF[12]);
  52.   47   1              DeviceInfo.BPB_SecPerClus=DBUF[13];
  53.   48   1              ReservedSectorsNum=LSwapINT16(DBUF[14],DBUF[15]);
  54.   49   1              DeviceInfo.BPB_NumFATs=DBUF[16];
  55.   50   1      
  56.   51   1              if(DBUF[82]=='F'&&DBUF[83]=='A'&&DBUF[84]=='T'&&DBUF[85]=='3'&&DBUF[86]=='2')
  57.   52   1              {
  58.   53   2                      DeviceInfo.BPB_RootEntCnt=LSwapINT16(DBUF[17],DBUF[18]);
  59.   54   2                      DeviceInfo.BPB_RootEntCnt=(DeviceInfo.BPB_RootEntCnt)*32/DeviceInfo.BPB_BytesPerSec;
  60.   55   2                      DeviceInfo.BPB_TotSec32=LSwapINT32(DBUF[32],DBUF[33],DBUF[34],DBUF[35]);
  61. C51 COMPILER V8.02   DEVICE                                                                04/29/2007 12:48:54 PAGE 2   
  62.   56   2                      DeviceInfo.BPB_FATSz32=LSwapINT32(DBUF[36],DBUF[37],DBUF[38],DBUF[39]);
  63.   57   2                      DeviceInfo.RootStartCluster=LSwapINT32(DBUF[44],DBUF[45],DBUF[46],DBUF[47]);
  64.   58   2                      DeviceInfo.FatStartSector=DeviceInfo.StartSector+ReservedSectorsNum;
  65.   59   2                      DeviceInfo.FirstDataSector=DeviceInfo.FatStartSector+DeviceInfo.BPB_NumFATs*DeviceInfo.BPB_FATSz32;
  66.   60   2                      //DeviceInfo.TotCluster=(DeviceInfo.BPB_TotSec32-DeviceInfo.FirstDataSector+1)/DeviceInfo.BPB_SecPerClus
  67.              -+1;
  68.   61   2                      DeviceInfo.TotCluster=(DeviceInfo.BPB_TotSec32-ReservedSectorsNum-DeviceInfo.BPB_NumFATs*DeviceInfo.BPB_
  69.              -FATSz32-DeviceInfo.BPB_RootEntCnt)/DeviceInfo.BPB_SecPerClus;
  70.   62   2                      DirStartCluster32=DeviceInfo.RootStartCluster;
  71.   63   2                      DeviceInfo.FAT=1;       //FAT16=0,FAT32=1;
  72.   64   2                      
  73.   65   2              }
  74.   66   1              else
  75.   67   1              {               
  76.   68   2                      DeviceInfo.BPB_RootEntCnt=LSwapINT16(DBUF[17],DBUF[18]);
  77.   69   2                      DeviceInfo.BPB_RootEntCnt=(DeviceInfo.BPB_RootEntCnt)*32/DeviceInfo.BPB_BytesPerSec;    
  78.   70   2                      DeviceInfo.BPB_TotSec16=LSwapINT16(DBUF[19],DBUF[20]);  
  79.   71   2                      if(DeviceInfo.BPB_TotSec16==0)
  80.   72   2                        DeviceInfo.BPB_TotSec16=LSwapINT32(DBUF[32],DBUF[33],DBUF[34],DBUF[35]);
  81.   73   2                      DeviceInfo.BPB_FATSz16=LSwapINT16(DBUF[22],DBUF[23]);                   
  82.   74   2                      DeviceInfo.FatStartSector=DeviceInfo.StartSector+ReservedSectorsNum;
  83.   75   2                      DeviceInfo.RootStartSector=DeviceInfo.StartSector+DeviceInfo.BPB_NumFATs*DeviceInfo.BPB_FATSz16+Reserved
  84.              -SectorsNum;        
  85.   76   2                      DeviceInfo.FirstDataSector=DeviceInfo.FatStartSector+DeviceInfo.BPB_NumFATs*DeviceInfo.BPB_FATSz16+Devic
  86.              -eInfo.BPB_RootEntCnt;
  87.   77   2                      DeviceInfo.TotCluster=(DeviceInfo.BPB_TotSec16-DeviceInfo.BPB_RootEntCnt-DeviceInfo.BPB_NumFATs*DeviceIn
  88.              -fo.BPB_FATSz16-1)/DeviceInfo.BPB_SecPerClus;
  89.   78   2              if(DeviceInfo.TotCluster<4085) return FALSE;    //FAT12 不被支持
  90.   79   2                      DeviceInfo.FAT=0;
  91.   80   2              }               
  92.   81   1              ///////////////////////////////////////////////////////
  93.   82   1              ThisFile.bFileOpen=0;   
  94.   83   1              ///////////////////////////////////////////////////////
  95.   84   1              return TRUE;
  96.   85   1      }
  97.   86          
  98.   87          unsigned char SdReadSector(unsigned long sector,unsigned char len,unsigned char *pBuffer)
  99.   88          {
  100.   89   1              while(len--)
  101.   90   1               {
  102.   91   2                if(SdReadBlock(pBuffer,sector<<9)==0) 
  103.   92   2                   return 0;
  104.   93   2            pBuffer+=512;
  105.   94   2               }
  106.   95   1        return 1;
  107.   96   1      }
  108.   97          
  109.   98          unsigned char SdWriteSector(unsigned long sector,unsigned char len,unsigned char *pBuffer)
  110.   99          {
  111.  100   1              while(len--)
  112.  101   1               {
  113.  102   2                if(SdWriteBlock(pBuffer,sector<<9)==0) return 0;
  114.  103   2            pBuffer+=512;
  115.  104   2               }
  116.  105   1       return 1;  
  117.  106   1      }
  118. MODULE INFORMATION:   STATIC OVERLAYABLE
  119.    CODE SIZE        =   1439    ----
  120.    CONSTANT SIZE    =   ----    ----
  121.    XDATA SIZE       =   8192    ----
  122. C51 COMPILER V8.02   DEVICE                                                                04/29/2007 12:48:54 PAGE 3   
  123.    PDATA SIZE       =   ----    ----
  124.    DATA SIZE        =   ----      18
  125.    IDATA SIZE       =   ----    ----
  126.    BIT SIZE         =   ----    ----
  127. END OF MODULE INFORMATION.
  128. C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)