📄 ff.txt
字号:
; generated by ARM C/C++ Compiler, 4.1 [Build 561]
; commandline ArmCC [--split_sections --debug -c --asm --interleave -o.\Flash\Obj\ff.o --depend=.\Flash\Obj\ff.d --cpu=Cortex-M3 --apcs=interwork -O0 --diag_suppress=870 -I..\..\Libraries\CMSIS\CM3\CoreSupport -I..\..\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x -I..\..\Libraries\STM32F10x_StdPeriph_Driver\inc -I..\..\User\bsp -I..\..\User\fatfs -I..\..\User -IC:\Keil\ARM\INC -IC:\Keil\ARM\INC\ST\STM32F10x -D__MICROLIB -DSTM32F10X_HD -DUSE_STDPERIPH_DRIVER ..\..\User\fatfs\ff.c]
THUMB
AREA ||i.check_fs||, CODE, READONLY, ALIGN=2
check_fs PROC
;;;1626 static
;;;1627 BYTE check_fs ( /* 0:The FAT BR, 1:Valid BR but not an FAT, 2:Not a BR, 3:Disk error */
000000 b570 PUSH {r4-r6,lr}
;;;1628 FATFS *fs, /* File system object */
;;;1629 DWORD sect /* Sector# (lba) to check if it is an FAT boot record or not */
;;;1630 )
;;;1631 {
000002 4604 MOV r4,r0
000004 460d MOV r5,r1
;;;1632 if (disk_read(fs->drv, fs->win, sect, 1) != RES_OK) /* Load boot record */
000006 7860 LDRB r0,[r4,#1]
000008 2301 MOVS r3,#1
00000a 462a MOV r2,r5
00000c f1040130 ADD r1,r4,#0x30
000010 f7fffffe BL disk_read
000014 b108 CBZ r0,|L1.26|
;;;1633 return 3;
000016 2003 MOVS r0,#3
|L1.24|
;;;1634 if (LD_WORD(&fs->win[BS_55AA]) != 0xAA55) /* Check record signature (always placed at offset 510 even if the sector size is >512) */
;;;1635 return 2;
;;;1636
;;;1637 if ((LD_DWORD(&fs->win[BS_FilSysType]) & 0xFFFFFF) == 0x544146) /* Check "FAT" string */
;;;1638 return 0;
;;;1639 if ((LD_DWORD(&fs->win[BS_FilSysType32]) & 0xFFFFFF) == 0x544146)
;;;1640 return 0;
;;;1641
;;;1642 return 1;
;;;1643 }
000018 bd70 POP {r4-r6,pc}
|L1.26|
00001a f8b4022e LDRH r0,[r4,#0x22e] ;1634
00001e f5a0412a SUB r1,r0,#0xaa00 ;1634
000022 3955 SUBS r1,r1,#0x55 ;1634
000024 d001 BEQ |L1.42|
000026 2002 MOVS r0,#2 ;1635
000028 e7f6 B |L1.24|
|L1.42|
00002a f8d40066 LDR r0,[r4,#0x66] ;1637
00002e f020407f BIC r0,r0,#0xff000000 ;1637
000032 4908 LDR r1,|L1.84|
000034 4288 CMP r0,r1 ;1637
000036 d101 BNE |L1.60|
000038 2000 MOVS r0,#0 ;1638
00003a e7ed B |L1.24|
|L1.60|
00003c f8d40082 LDR r0,[r4,#0x82] ;1639
000040 f020407f BIC r0,r0,#0xff000000 ;1639
000044 4903 LDR r1,|L1.84|
000046 4288 CMP r0,r1 ;1639
000048 d101 BNE |L1.78|
00004a 2000 MOVS r0,#0 ;1640
00004c e7e4 B |L1.24|
|L1.78|
00004e 2001 MOVS r0,#1 ;1642
000050 e7e2 B |L1.24|
;;;1644
ENDP
000052 0000 DCW 0x0000
|L1.84|
DCD 0x00544146
AREA ||i.chk_chr||, CODE, READONLY, ALIGN=1
chk_chr PROC
;;;267 static
;;;268 int chk_chr (const char* str, int chr) {
000000 4602 MOV r2,r0
;;;269 while (*str && *str != chr) str++;
000002 e000 B |L2.6|
|L2.4|
000004 1c52 ADDS r2,r2,#1
|L2.6|
000006 7810 LDRB r0,[r2,#0]
000008 b110 CBZ r0,|L2.16|
00000a 7810 LDRB r0,[r2,#0]
00000c 4288 CMP r0,r1
00000e d1f9 BNE |L2.4|
|L2.16|
;;;270 return *str;
000010 7810 LDRB r0,[r2,#0]
;;;271 }
000012 4770 BX lr
;;;272
ENDP
AREA ||i.chk_mounted||, CODE, READONLY, ALIGN=2
chk_mounted PROC
;;;1652 static
;;;1653 FRESULT chk_mounted ( /* FR_OK(0): successful, !=0: any error occurred */
000000 e92d4ff7 PUSH {r0-r2,r4-r11,lr}
;;;1654 const TCHAR **path, /* Pointer to pointer to the path name (drive number) */
;;;1655 FATFS **rfs, /* Pointer to pointer to the found file system object */
;;;1656 BYTE chk_wp /* !=0: Check media write protection for write access */
;;;1657 )
;;;1658 {
000004 b086 SUB sp,sp,#0x18
;;;1659 BYTE fmt, b, *tbl;
;;;1660 UINT vol;
;;;1661 DSTATUS stat;
;;;1662 DWORD bsect, fasize, tsect, sysect, nclst, szbfat;
;;;1663 WORD nrsv;
;;;1664 const TCHAR *p = *path;
000006 9806 LDR r0,[sp,#0x18]
000008 6800 LDR r0,[r0,#0]
00000a 9000 STR r0,[sp,#0]
;;;1665 FATFS *fs;
;;;1666
;;;1667 /* Get logical drive number from the path name */
;;;1668 vol = p[0] - '0'; /* Is there a drive number? */
00000c 9800 LDR r0,[sp,#0]
00000e 7800 LDRB r0,[r0,#0]
000010 3830 SUBS r0,r0,#0x30
000012 9004 STR r0,[sp,#0x10]
;;;1669 if (vol <= 9 && p[1] == ':') { /* Found a drive number, get and strip it */
000014 9804 LDR r0,[sp,#0x10]
000016 2809 CMP r0,#9
000018 d80a BHI |L3.48|
00001a 9800 LDR r0,[sp,#0]
00001c 7840 LDRB r0,[r0,#1]
00001e 283a CMP r0,#0x3a
000020 d106 BNE |L3.48|
;;;1670 p += 2; *path = p; /* Return pointer to the path name */
000022 9800 LDR r0,[sp,#0]
000024 1c80 ADDS r0,r0,#2
000026 9000 STR r0,[sp,#0]
000028 9906 LDR r1,[sp,#0x18]
00002a 9800 LDR r0,[sp,#0]
00002c 6008 STR r0,[r1,#0]
00002e e001 B |L3.52|
|L3.48|
;;;1671 } else { /* No drive number is given */
;;;1672 #if _FS_RPATH
;;;1673 vol = Drive; /* Use current drive */
;;;1674 #else
;;;1675 vol = 0; /* Use drive 0 */
000030 2000 MOVS r0,#0
000032 9004 STR r0,[sp,#0x10]
|L3.52|
;;;1676 #endif
;;;1677 }
;;;1678
;;;1679 /* Check if the logical drive is valid or not */
;;;1680 if (vol >= _DRIVES) /* Is the drive number valid? */
000034 9804 LDR r0,[sp,#0x10]
000036 b118 CBZ r0,|L3.64|
;;;1681 return FR_INVALID_DRIVE;
000038 200b MOVS r0,#0xb
|L3.58|
;;;1682 *rfs = fs = FatFs[vol]; /* Return pointer to the corresponding file system object */
;;;1683 if (!fs) return FR_NOT_ENABLED; /* Is the file system object available? */
;;;1684
;;;1685 ENTER_FF(fs); /* Lock file system */
;;;1686
;;;1687 if (fs->fs_type) { /* If the logical drive has been mounted */
;;;1688 stat = disk_status(fs->drv);
;;;1689 if (!(stat & STA_NOINIT)) { /* and the physical drive is kept initialized (has not been changed), */
;;;1690 #if !_FS_READONLY
;;;1691 if (chk_wp && (stat & STA_PROTECT)) /* Check write protection if needed */
;;;1692 return FR_WRITE_PROTECTED;
;;;1693 #endif
;;;1694 return FR_OK; /* The file system object is valid */
;;;1695 }
;;;1696 }
;;;1697
;;;1698 /* The logical drive must be mounted. Following code attempts to mount the volume (initialize the file system object) */
;;;1699
;;;1700 fs->fs_type = 0; /* Clear the file system object */
;;;1701 fs->drv = (BYTE)LD2PD(vol); /* Bind the logical drive and a physical drive */
;;;1702 stat = disk_initialize(fs->drv); /* Initialize low level disk I/O layer */
;;;1703 if (stat & STA_NOINIT) /* Check if the drive is ready */
;;;1704 return FR_NOT_READY;
;;;1705 #if _MAX_SS != 512 /* Get disk sector size if needed */
;;;1706 if (disk_ioctl(fs->drv, GET_SECTOR_SIZE, &SS(fs)) != RES_OK || SS(fs) > _MAX_SS)
;;;1707 return FR_NO_FILESYSTEM;
;;;1708 #endif
;;;1709 #if !_FS_READONLY
;;;1710 if (chk_wp && (stat & STA_PROTECT)) /* Check disk write protection if needed */
;;;1711 return FR_WRITE_PROTECTED;
;;;1712 #endif
;;;1713 /* Search FAT partition on the drive (Supports only generic partitionings, FDISK and SFD) */
;;;1714 fmt = check_fs(fs, bsect = 0); /* Check sector 0 if it is a VBR */
;;;1715 if (fmt == 1) { /* Not an FAT-VBR, the disk may be partitioned */
;;;1716 /* Check the partition listed in top of the partition table */
;;;1717 tbl = &fs->win[MBR_Table + LD2PT(vol) * 16]; /* Partition table */
;;;1718 if (tbl[4]) { /* Is the partition existing? */
;;;1719 bsect = LD_DWORD(&tbl[8]); /* Partition offset in LBA */
;;;1720 fmt = check_fs(fs, bsect); /* Check the partition */
;;;1721 }
;;;1722 }
;;;1723 if (fmt == 3) return FR_DISK_ERR;
;;;1724 if (fmt) return FR_NO_FILESYSTEM; /* No FAT volume is found */
;;;1725
;;;1726 /* Following code initializes the file system object */
;;;1727
;;;1728 if (LD_WORD(fs->win+BPB_BytsPerSec) != SS(fs)) /* (BPB_BytsPerSec must be equal to the physical sector size) */
;;;1729 return FR_NO_FILESYSTEM;
;;;1730
;;;1731 fasize = LD_WORD(fs->win+BPB_FATSz16); /* Number of sectors per FAT */
;;;1732 if (!fasize) fasize = LD_DWORD(fs->win+BPB_FATSz32);
;;;1733 fs->fsize = fasize;
;;;1734
;;;1735 fs->n_fats = b = fs->win[BPB_NumFATs]; /* Number of FAT copies */
;;;1736 if (b != 1 && b != 2) return FR_NO_FILESYSTEM; /* (Must be 1 or 2) */
;;;1737 fasize *= b; /* Number of sectors for FAT area */
;;;1738
;;;1739 fs->csize = b = fs->win[BPB_SecPerClus]; /* Number of sectors per cluster */
;;;1740 if (!b || (b & (b - 1))) return FR_NO_FILESYSTEM; /* (Must be 1,2,4...128) */
;;;1741
;;;1742 fs->n_rootdir = LD_WORD(fs->win+BPB_RootEntCnt); /* Number of root directory entries */
;;;1743 if (fs->n_rootdir % (SS(fs) / 32)) return FR_NO_FILESYSTEM; /* (BPB_RootEntCnt must be sector aligned) */
;;;1744
;;;1745 tsect = LD_WORD(fs->win+BPB_TotSec16); /* Number of sectors on the volume */
;;;1746 if (!tsect) tsect = LD_DWORD(fs->win+BPB_TotSec32);
;;;1747
;;;1748 nrsv = LD_WORD(fs->win+BPB_RsvdSecCnt); /* Number of reserved sectors */
;;;1749 if (!nrsv) return FR_NO_FILESYSTEM; /* (BPB_RsvdSecCnt must not be 0) */
;;;1750
;;;1751 /* Determine the FAT sub type */
;;;1752 sysect = nrsv + fasize + fs->n_rootdir / (SS(fs) / 32); /* RSV+FAT+DIR */
;;;1753 if (tsect < sysect) return FR_NO_FILESYSTEM; /* (Invalid volume size) */
;;;1754 nclst = (tsect - sysect) / fs->csize; /* Number of clusters */
;;;1755 if (!nclst) return FR_NO_FILESYSTEM; /* (Invalid volume size) */
;;;1756 fmt = FS_FAT12;
;;;1757 if (nclst >= MIN_FAT16) fmt = FS_FAT16;
;;;1758 if (nclst >= MIN_FAT32) fmt = FS_FAT32;
;;;1759
;;;1760 /* Boundaries and Limits */
;;;1761 fs->n_fatent = nclst + 2; /* Number of FAT entries */
;;;1762 fs->database = bsect + sysect; /* Data start sector */
;;;1763 fs->fatbase = bsect + nrsv; /* FAT start sector */
;;;1764 if (fmt == FS_FAT32) {
;;;1765 if (fs->n_rootdir) return FR_NO_FILESYSTEM; /* (BPB_RootEntCnt must be 0) */
;;;1766 fs->dirbase = LD_DWORD(fs->win+BPB_RootClus); /* Root directory start cluster */
;;;1767 szbfat = fs->n_fatent * 4; /* (Required FAT size) */
;;;1768 } else {
;;;1769 if (!fs->n_rootdir) return FR_NO_FILESYSTEM; /* (BPB_RootEntCnt must not be 0) */
;;;1770 fs->dirbase = fs->fatbase + fasize; /* Root directory start sector */
;;;1771 szbfat = (fmt == FS_FAT16) ? /* (Required FAT size) */
;;;1772 fs->n_fatent * 2 : fs->n_fatent * 3 / 2 + (fs->n_fatent & 1);
;;;1773 }
;;;1774 if (fs->fsize < (szbfat + (SS(fs) - 1)) / SS(fs)) /* (FAT size must not be less than FAT sectors */
;;;1775 return FR_NO_FILESYSTEM;
;;;1776
;;;1777 #if !_FS_READONLY
;;;1778 /* Initialize cluster allocation information */
;;;1779 fs->free_clust = 0xFFFFFFFF;
;;;1780 fs->last_clust = 0;
;;;1781
;;;1782 /* Get fsinfo if available */
;;;1783 if (fmt == FS_FAT32) {
;;;1784 fs->fsi_flag = 0;
;;;1785 fs->fsi_sector = bsect + LD_WORD(fs->win+BPB_FSInfo);
;;;1786 if (disk_read(fs->drv, fs->win, fs->fsi_sector, 1) == RES_OK &&
;;;1787 LD_WORD(fs->win+BS_55AA) == 0xAA55 &&
;;;1788 LD_DWORD(fs->win+FSI_LeadSig) == 0x41615252 &&
;;;1789 LD_DWORD(fs->win+FSI_StrucSig) == 0x61417272) {
;;;1790 fs->last_clust = LD_DWORD(fs->win+FSI_Nxt_Free);
;;;1791 fs->free_clust = LD_DWORD(fs->win+FSI_Free_Count);
;;;1792 }
;;;1793 }
;;;1794 #endif
;;;1795 fs->fs_type = fmt; /* FAT sub-type */
;;;1796 fs->id = ++Fsid; /* File system mount ID */
;;;1797 fs->winsect = 0; /* Invalidate sector cache */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -