📄 ff.txt
字号:
000262 0000 DCW 0x0000
|L3.612|
DCD FatFs
|L3.616|
DCD 0x41615252
|L3.620|
DCD 0x61417272
|L3.624|
DCD Fsid
AREA ||i.clust2sect||, CODE, READONLY, ALIGN=1
clust2sect PROC
;;;693
;;;694 DWORD clust2sect ( /* !=0: Sector number, 0: Failed - invalid cluster# */
000000 4602 MOV r2,r0
;;;695 FATFS *fs, /* File system object */
;;;696 DWORD clst /* Cluster# to be converted */
;;;697 )
;;;698 {
;;;699 clst -= 2;
000002 1e89 SUBS r1,r1,#2
;;;700 if (clst >= (fs->n_fatent - 2)) return 0; /* Invalid cluster# */
000004 6990 LDR r0,[r2,#0x18]
000006 1e80 SUBS r0,r0,#2
000008 4288 CMP r0,r1
00000a d801 BHI |L4.16|
00000c 2000 MOVS r0,#0
|L4.14|
;;;701 return clst * fs->csize + fs->database;
;;;702 }
00000e 4770 BX lr
|L4.16|
000010 7893 LDRB r3,[r2,#2] ;701
000012 6a90 LDR r0,[r2,#0x28] ;701
000014 fb010003 MLA r0,r1,r3,r0 ;701
000018 e7f9 B |L4.14|
;;;703
ENDP
AREA ||i.create_chain||, CODE, READONLY, ALIGN=1
create_chain PROC
;;;635 static
;;;636 DWORD create_chain ( /* 0:No free cluster, 1:Internal error, 0xFFFFFFFF:Disk error, >=2:New cluster# */
000000 e92d41f0 PUSH {r4-r8,lr}
;;;637 FATFS *fs, /* File system object */
;;;638 DWORD clst /* Cluster# to stretch. 0 means create a new chain. */
;;;639 )
;;;640 {
000004 4604 MOV r4,r0
000006 4688 MOV r8,r1
;;;641 DWORD cs, ncl, scl;
;;;642
;;;643
;;;644 if (clst == 0) { /* Create a new chain */
000008 f1b80f00 CMP r8,#0
00000c d106 BNE |L5.28|
;;;645 scl = fs->last_clust; /* Get suggested start point */
00000e 68e7 LDR r7,[r4,#0xc]
;;;646 if (!scl || scl >= fs->n_fatent) scl = 1;
000010 b117 CBZ r7,|L5.24|
000012 69a0 LDR r0,[r4,#0x18]
000014 42b8 CMP r0,r7
000016 d811 BHI |L5.60|
|L5.24|
000018 2701 MOVS r7,#1
00001a e00f B |L5.60|
|L5.28|
;;;647 }
;;;648 else { /* Stretch the current chain */
;;;649 cs = get_fat(fs, clst); /* Check the cluster status */
00001c 4641 MOV r1,r8
00001e 4620 MOV r0,r4
000020 f7fffffe BL get_fat
000024 4606 MOV r6,r0
;;;650 if (cs < 2) return 1; /* It is an invalid cluster */
000026 2e02 CMP r6,#2
000028 d202 BCS |L5.48|
00002a 2001 MOVS r0,#1
|L5.44|
;;;651 if (cs < fs->n_fatent) return cs; /* It is already followed by next cluster */
;;;652 scl = clst;
;;;653 }
;;;654
;;;655 ncl = scl; /* Start cluster */
;;;656 for (;;) {
;;;657 ncl++; /* Next cluster */
;;;658 if (ncl >= fs->n_fatent) { /* Wrap around */
;;;659 ncl = 2;
;;;660 if (ncl > scl) return 0; /* No free cluster */
;;;661 }
;;;662 cs = get_fat(fs, ncl); /* Get the cluster status */
;;;663 if (cs == 0) break; /* Found a free cluster */
;;;664 if (cs == 0xFFFFFFFF || cs == 1)/* An error occurred */
;;;665 return cs;
;;;666 if (ncl == scl) return 0; /* No free cluster */
;;;667 }
;;;668
;;;669 if (put_fat(fs, ncl, 0x0FFFFFFF)) /* Mark the new cluster "last link" */
;;;670 return 0xFFFFFFFF;
;;;671 if (clst != 0) { /* Link it to the previous one if needed */
;;;672 if (put_fat(fs, clst, ncl))
;;;673 return 0xFFFFFFFF;
;;;674 }
;;;675
;;;676 fs->last_clust = ncl; /* Update FSINFO */
;;;677 if (fs->free_clust != 0xFFFFFFFF) {
;;;678 fs->free_clust--;
;;;679 fs->fsi_flag = 1;
;;;680 }
;;;681
;;;682 return ncl; /* Return new cluster number */
;;;683 }
00002c e8bd81f0 POP {r4-r8,pc}
|L5.48|
000030 69a0 LDR r0,[r4,#0x18] ;651
000032 42b0 CMP r0,r6 ;651
000034 d901 BLS |L5.58|
000036 4630 MOV r0,r6 ;651
000038 e7f8 B |L5.44|
|L5.58|
00003a 4647 MOV r7,r8 ;652
|L5.60|
00003c 463d MOV r5,r7 ;655
00003e bf00 NOP ;656
|L5.64|
000040 1c6d ADDS r5,r5,#1 ;657
000042 69a0 LDR r0,[r4,#0x18] ;658
000044 42a8 CMP r0,r5 ;658
000046 d804 BHI |L5.82|
000048 2502 MOVS r5,#2 ;659
00004a 42bd CMP r5,r7 ;660
00004c d901 BLS |L5.82|
00004e 2000 MOVS r0,#0 ;660
000050 e7ec B |L5.44|
|L5.82|
000052 4629 MOV r1,r5 ;662
000054 4620 MOV r0,r4 ;662
000056 f7fffffe BL get_fat
00005a 4606 MOV r6,r0 ;662
00005c b906 CBNZ r6,|L5.96|
00005e e009 B |L5.116|
|L5.96|
000060 1c70 ADDS r0,r6,#1 ;664
000062 d001 BEQ |L5.104|
000064 2e01 CMP r6,#1 ;664
000066 d101 BNE |L5.108|
|L5.104|
000068 4630 MOV r0,r6 ;665
00006a e7df B |L5.44|
|L5.108|
00006c 42bd CMP r5,r7 ;666
00006e d1e7 BNE |L5.64|
000070 2000 MOVS r0,#0 ;666
000072 e7db B |L5.44|
|L5.116|
000074 bf00 NOP ;663
000076 f06f4270 MVN r2,#0xf0000000 ;669
00007a 4629 MOV r1,r5 ;669
00007c 4620 MOV r0,r4 ;669
00007e f7fffffe BL put_fat
000082 b110 CBZ r0,|L5.138|
000084 f04f30ff MOV r0,#0xffffffff ;670
000088 e7d0 B |L5.44|
|L5.138|
00008a f1b80f00 CMP r8,#0 ;671
00008e d008 BEQ |L5.162|
000090 462a MOV r2,r5 ;672
000092 4641 MOV r1,r8 ;672
000094 4620 MOV r0,r4 ;672
000096 f7fffffe BL put_fat
00009a b110 CBZ r0,|L5.162|
00009c f04f30ff MOV r0,#0xffffffff ;673
0000a0 e7c4 B |L5.44|
|L5.162|
0000a2 60e5 STR r5,[r4,#0xc] ;676
0000a4 6920 LDR r0,[r4,#0x10] ;677
0000a6 1c40 ADDS r0,r0,#1 ;677
0000a8 d004 BEQ |L5.180|
0000aa 6920 LDR r0,[r4,#0x10] ;678
0000ac 1e40 SUBS r0,r0,#1 ;678
0000ae 6120 STR r0,[r4,#0x10] ;678
0000b0 2001 MOVS r0,#1 ;679
0000b2 7160 STRB r0,[r4,#5] ;679
|L5.180|
0000b4 4628 MOV r0,r5 ;682
0000b6 e7b9 B |L5.44|
;;;684 #endif /* !_FS_READONLY */
ENDP
AREA ||i.create_name||, CODE, READONLY, ALIGN=2
create_name PROC
;;;1267 static
;;;1268 FRESULT create_name (
000000 e92d5ff3 PUSH {r0,r1,r4-r12,lr}
;;;1269 DIR *dj, /* Pointer to the directory object */
;;;1270 const TCHAR **path /* Pointer to pointer to the segment in the path string */
;;;1271 )
;;;1272 {
;;;1273 #ifdef _EXCVT
;;;1274 static const BYTE excvt[] = _EXCVT; /* Upper conversion table for extended chars */
;;;1275 #endif
;;;1276
;;;1277 #if _USE_LFN /* LFN configuration */
;;;1278 BYTE b, cf;
;;;1279 WCHAR w, *lfn;
;;;1280 int i, ni, si, di;
;;;1281 const TCHAR *p;
;;;1282
;;;1283 /* Create LFN in Unicode */
;;;1284 si = di = 0;
;;;1285 p = *path;
;;;1286 lfn = dj->lfn;
;;;1287 for (;;) {
;;;1288 w = p[si++]; /* Get a character */
;;;1289 if (w < ' ' || w == '/' || w == '\\') break; /* Break on end of segment */
;;;1290 if (di >= _MAX_LFN) /* Reject too long name */
;;;1291 return FR_INVALID_NAME;
;;;1292 #if !_LFN_UNICODE
;;;1293 w &= 0xFF;
;;;1294 if (IsDBCS1(w)) { /* If it is a DBC 1st byte */
;;;1295 b = p[si++]; /* Get 2nd byte */
;;;1296 if (!IsDBCS2(b)) /* Reject invalid code for DBC */
;;;1297 return FR_INVALID_NAME;
;;;1298 w = (w << 8) + b;
;;;1299 }
;;;1300 w = ff_convert(w, 1); /* Convert OEM to Unicode */
;;;1301 if (!w) return FR_INVALID_NAME; /* Reject invalid code */
;;;1302 #endif
;;;1303 if (w < 0x80 && chk_chr("\"*:<>\?|\x7F", w)) /* Reject illegal chars for LFN */
;;;1304 return FR_INVALID_NAME;
;;;1305 lfn[di++] = w; /* Store the Unicode char */
;;;1306 }
;;;1307 *path = &p[si]; /* Return pointer to the next segment */
;;;1308 cf = (w < ' ') ? NS_LAST : 0; /* Set last segment flag if end of path */
;;;1309 #if _FS_RPATH
;;;1310 if ((di == 1 && lfn[di - 1] == '.') || /* Is this a dot entry? */
;;;1311 (di == 2 && lfn[di - 1] == '.' && lfn[di - 2] == '.')) {
;;;1312 lfn[di] = 0;
;;;1313 for (i = 0; i < 11; i++)
;;;1314 dj->fn[i] = (i < di) ? '.' : ' ';
;;;1315 dj->fn[i] = cf | NS_DOT; /* This is a dot entry */
;;;1316 return FR_OK;
;;;1317 }
;;;1318 #endif
;;;1319 while (di) { /* Strip trailing spaces and dots */
;;;1320 w = lfn[di - 1];
;;;1321 if (w != ' ' && w != '.') break;
;;;1322 di--;
;;;1323 }
;;;1324 if (!di) return FR_INVALID_NAME; /* Reject nul string */
;;;1325
;;;1326 lfn[di] = 0; /* LFN is created */
;;;1327
;;;1328 /* Create SFN in directory form */
;;;1329 mem_set(dj->fn, ' ', 11);
;;;1330 for (si = 0; lfn[si] == ' ' || lfn[si] == '.'; si++) ; /* Strip leading spaces and dots */
;;;1331 if (si) cf |= NS_LOSS | NS_LFN;
;;;1332 while (di && lfn[di - 1] != '.') di--; /* Find extension (di<=si: no extension) */
;;;1333
;;;1334 b = i = 0; ni = 8;
;;;1335 for (;;) {
;;;1336 w = lfn[si++]; /* Get an LFN char */
;;;1337 if (!w) break; /* Break on end of the LFN */
;;;1338 if (w == ' ' || (w == '.' && si != di)) { /* Remove spaces and dots */
;;;1339 cf |= NS_LOSS | NS_LFN; continue;
;;;1340 }
;;;1341
;;;1342 if (i >= ni || si == di) { /* Extension or end of SFN */
;;;1343 if (ni == 11) { /* Long extension */
;;;1344 cf |= NS_LOSS | NS_LFN; break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -