📄 fat.cod
字号:
; Listing generated by Microsoft (R) Optimizing Compiler Version 12.20.9615
TTL d:\wince420\platform\ep931x\eboot\.\fat.c
CODE32
00000 AREA |.drectve|, DRECTVE
DCB "-defaultlib:coredll.lib "
DCB "-defaultlib:corelibc.lib "
00000 AREA |.data|, DATA
COMMON |g_fileinfo|, 0x11
COMMON |g_fatparms|, 0x18
00000 AREA |.rdata|, DATA, READONLY
|EdbgVendorIds| DCW 0x0
DCW 0x0
DCD 0x4033
DCB 0x1
DCB "AD", 0x0
DCW 0x1050
DCW 0x940
DCD 0x4005
DCB 0x1
DCB "LS", 0x0
DCW 0x1050
DCW 0x940
DCD 0x2078
DCB 0x1
DCB "LS", 0x0
DCW 0x10ec
DCW 0x8029
DCD 0xc0f0
DCB 0x1
DCB "KS", 0x0
DCW 0x10ec
DCW 0x8129
DCD 0x0
DCB 0x4
DCB "RT", 0x0
DCW 0x10ec
DCW 0x8139
DCD 0x900b
DCB 0x4
DCB "RT", 0x0
DCW 0x10ec
DCW 0x8139
DCD 0xd0c9
DCB 0x4
DCB "RT", 0x0
DCW 0x10ec
DCW 0x8139
DCD 0xe04c
DCB 0x4
DCB "RT", 0x0
DCW 0x1186
DCW 0x1300
DCD 0x50ba
DCB 0x4
DCB "DL", 0x0
DCW 0x100b
DCW 0x20
DCD 0xa0cc
DCB 0x5
DCB "NG", 0x0
DCW 0x10b7
DCW 0x9050
DCD 0x6008
DCB 0x6
DCB "3C", 0x0
DCW 0x10b7
DCW 0x9200
DCD 0x476
DCB 0x6
DCB "3C", 0x0
EXPORT |init_fat|
; File d:\wince420\platform\ep931x\eboot\fat.c
00000 AREA |.text| { |init_fat| }, CODE, ARM, SELECTION=1 ; comdat noduplicate
00000 AREA |.pdata$$init_fat|, PDATA, SELECTION=5, ASSOC=|.text| { |init_fat| } ; comdat associative
|$T36684| DCD |init_fat|
DCD 0x40000200
; Function compile flags: /Ogsy
00000 AREA |.text| { |init_fat| }, CODE, ARM, SELECTION=1 ; comdat noduplicate
00000 |init_fat| PROC
; 83 : {
00000 |$M36682|
; 84 : #if 0
; 85 : UCHAR bsect[SECTOR_SIZE];
; 86 : PPARTTE pptbl = NULL;
; 87 : PBSECTHDR psecthdr = NULL;
; 88 : UCHAR i = 0;
; 89 :
; 90 : // Locate and verify single active partition in MBR.
; 91 : memset (&bsect[0], 0, SECTOR_SIZE);
; 92 : if (read_sector(0, &bsect[0]))
; 93 : {
; 94 : RETAILMSG(1, (TEXT("ERROR: Couldn't read MBR.\r\n")));
; 95 : return(-1);
; 96 : }
; 97 :
; 98 : // TODO - look for more than one occurrance of active partition.
; 99 : // Walk partition table looking for active partition
; 100 : pptbl = (PPARTTE)((UCHAR *)&bsect[0] + SECTOR_SIZE - PARTSIG_SIZE - PARTTBL_SIZE);
; 101 : for(i=0 ; i < MAX_PARTITIONS && pptbl->actvflg != PARTACTV_FLAG; i++)
; 102 : ++pptbl;
; 103 :
; 104 : if (i == MAX_PARTITIONS)
; 105 : {
; 106 : RETAILMSG(1, (TEXT("ERROR: Didn't find an active partition.\r\n")));
; 107 : return(-1);
; 108 : }
; 109 :
; 110 : // Save FAT info for active boot partition
; 111 : g_fatparms.apartlba = pptbl->slba;
; 112 : g_fatparms.apartlen = pptbl->size;
; 113 :
; 114 : DEBUGMSG(ZONE_INFO, (TEXT("Active boot partition found (LBA=0x%x Length=0x%x).\r\n"), g_fatparms.apartlba, g_fatparms.apartlen));
; 115 :
; 116 : // Compute and store root directory LBA - to do this, get the boot sector
; 117 : // from the active partition, look at the disk parameter block contents
; 118 : // to determine number of reserved and hidden sectors, then compute.
; 119 : memset (&bsect[0], 0, SECTOR_SIZE);
; 120 : if (read_sector(g_fatparms.apartlba, &bsect[0]))
; 121 : {
; 122 : RETAILMSG(1, (TEXT("ERROR: Couldn't load active boot sector.\r\n")));
; 123 : return(-1);
; 124 : }
; 125 :
; 126 : psecthdr = (PBSECTHDR)&bsect[0];
; 127 : g_fatparms.rootdirlba = g_fatparms.apartlba + (psecthdr->numfats * psecthdr->sectspfat) + psecthdr->numrsvdsects;
; 128 : g_fatparms.fatlba = g_fatparms.apartlba + psecthdr->numrsvdsects;
; 129 :
; 130 : DEBUGMSG(ZONE_INFO, (TEXT("Root dir location (LBA=0x%x)\r\n"), g_fatparms.rootdirlba));
; 131 : DEBUGMSG(ZONE_INFO, (TEXT(" - Number of FATs = 0x%x\r\n"), psecthdr->numfats));
; 132 : DEBUGMSG(ZONE_INFO, (TEXT(" - Number of Sectors Per FATs = 0x%x\r\n"), psecthdr->sectspfat));
; 133 : DEBUGMSG(ZONE_INFO, (TEXT(" - Number of Hidden Sectors = 0x%x\r\n"), psecthdr->numhdnsects));
; 134 : DEBUGMSG(ZONE_INFO, (TEXT(" - Number of Reserved Sectors = 0x%x\r\n"), psecthdr->numrsvdsects));
; 135 :
; 136 :
; 137 : // Save data start LBA
; 138 : g_fatparms.cluststlba = g_fatparms.rootdirlba + ((sizeof(DIRENTRY) * psecthdr->numrootentry) / psecthdr->bytespsect);
; 139 : if ((sizeof(DIRENTRY) * psecthdr->numrootentry) % psecthdr->bytespsect)
; 140 : ++g_fatparms.cluststlba;
; 141 :
; 142 : // Save number of sectors per cluster
; 143 : g_fatparms.sectspclust = psecthdr->sectspclust;
; 144 : g_fatparms.numrootentry = psecthdr->numrootentry;
; 145 : #endif // 0
; 146 :
; 147 : return(0);
00000 e3a00000 mov r0, #0
; 148 : }
00004 e12fff1e bx lr
00008 |$M36683|
ENDP ; |init_fat|
EXPORT |clust_to_lba|
00000 AREA |.text| { |clust_to_lba| }, CODE, ARM, SELECTION=1 ; comdat noduplicate
00000 AREA |.pdata$$clust_to_lba|, PDATA, SELECTION=5, ASSOC=|.text| { |clust_to_lba| } ; comdat associative
|$T36691| DCD |clust_to_lba|
DCD 0x40000200
; Function compile flags: /Ogsy
00000 AREA |.text| { |clust_to_lba| }, CODE, ARM, SELECTION=1 ; comdat noduplicate
00000 |clust_to_lba| PROC
; 152 : {
00000 |$M36689|
; 153 : //return(g_fatparms.cluststlba + (clust - 2) * g_fatparms.sectspclust);
; 154 : return 0;
00000 e3a00000 mov r0, #0
; 155 : }
00004 e12fff1e bx lr
00008 |$M36690|
ENDP ; |clust_to_lba|
EXPORT |file_read|
00000 AREA |.text| { |file_read| }, CODE, ARM, SELECTION=1 ; comdat noduplicate
00000 AREA |.pdata$$file_read|, PDATA, SELECTION=5, ASSOC=|.text| { |file_read| } ; comdat associative
|$T36698| DCD |file_read|
DCD 0x40000200
; Function compile flags: /Ogsy
00000 AREA |.text| { |file_read| }, CODE, ARM, SELECTION=1 ; comdat noduplicate
00000 |file_read| PROC
; 159 : {
00000 |$M36696|
; 160 : #if 0
; 161 : UCHAR *ptmp = pbuf;
; 162 : ULONG bytestoread = len;
; 163 : ULONG sectstoread = 0;
; 164 :
; 165 : // TODO - handle EOF mid-cluster.
; 166 : while (bytestoread)
; 167 : {
; 168 : if (g_fileinfo.bytesreminsect == 0) // Buffer isn't filled...
; 169 : {
; 170 : // EOF?
; 171 : if (g_fileinfo.curclust >= 0xfff8 && g_fileinfo.curclust <= 0xffff)
; 172 : return(FAT_EOF);
; 173 :
; 174 : memset(&g_bsect[0], 0, SECTOR_SIZE);
; 175 : if (read_sector(g_fileinfo.cursect, &g_bsect[0]))
; 176 : {
; 177 : RETAILMSG(1, (TEXT("ERROR: Couldn't read data sector.\r\n")));
; 178 : return(-1);
; 179 : }
; 180 :
; 181 : // jump to next cluster if we've read all the sectors in the current
; 182 : g_fileinfo.sectreminclust--;
; 183 : g_fileinfo.cursect++;
; 184 : if (g_fileinfo.sectreminclust == 0)
; 185 : {
; 186 : ++g_fileinfo.clusttlbofst;
; 187 : g_fileinfo.sectreminclust = g_fatparms.sectspclust;
; 188 : g_fileinfo.curclust = *((USHORT *)CLUST_LIST_START + g_fileinfo.clusttlbofst);
; 189 : g_fileinfo.cursect = clust_to_lba(g_fileinfo.curclust);
; 190 : }
; 191 :
; 192 : g_fileinfo.bytesreminsect = SECTOR_SIZE;
; 193 : g_fileinfo.byteofst = 0;
; 194 : }
; 195 :
; 196 : // If data in read buffer has all the data the caller needs...
; 197 : if (bytestoread <= g_fileinfo.bytesreminsect)
; 198 : {
; 199 : memcpy(ptmp, (UCHAR *)&g_bsect[g_fileinfo.byteofst], bytestoread);
; 200 : g_fileinfo.bytesreminsect -= (USHORT)bytestoread;
; 201 : g_fileinfo.byteofst += (USHORT)bytestoread;
; 202 : return(0);
; 203 : }
; 204 :
; 205 : // Caller wants more data than is in the global buffer - first
; 206 : // deplete the global buffer contents
; 207 : memcpy(ptmp, (UCHAR *)&g_bsect[g_fileinfo.byteofst], g_fileinfo.bytesreminsect);
; 208 : bytestoread -= g_fileinfo.bytesreminsect;
; 209 : ptmp += g_fileinfo.bytesreminsect;
; 210 : g_fileinfo.bytesreminsect = 0;
; 211 :
; 212 : // If remaining bytes are less than a sector in size - don't need to
; 213 : // optimize for multi-sector reads - do a partial sector read
; 214 : if ((bytestoread / SECTOR_SIZE) == 0)
; 215 : continue;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -