📄 ls.lst
字号:
ARM COMPILER V2.42, ls 27/03/06 10:45:51 PAGE 1
ARM COMPILER V2.42, COMPILATION OF MODULE ls
OBJECT MODULE PLACED IN .\obj\ls.obj
COMPILER INVOKED BY: C:\Keil\ARM\BIN\CA.exe src\ls.c THUMB DEBUG PRINT(.\LST\LS.LST) TABS(4) OBJECT(.\obj\ls.obj)
stmt level source
1 /*****************************************************************************\
2 * efs - General purpose Embedded Filesystem library *
3 * --------------------- ----------------------------------- *
4 * *
5 * Filename : ls.c *
6 * Description : This file contains functions to list the files in a directory *
7 * *
8 * This library is free software; you can redistribute it and/or *
9 * modify it under the terms of the GNU Lesser General Public *
10 * License as published by the Free Software Foundation; either *
11 * version 2.1 of the License, or (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16 * Lesser General Public License for more details. *
17 * *
18 * (c)2005 Michael De Nil *
19 * (c)2005 Lennart Yseboodt *
20 \*****************************************************************************/
21
22 /*****************************************************************************/
23 #include "ls.h"
24 /*****************************************************************************/
25
26 esint8 ls_openDir(DirList *dlist,FileSystem *fs,eint8* dirname)
27 {
28 1 FileLocation loc;
29 1 euint32 fc;
30 1
31 1 dlist->fs=fs;
32 1
33 1 if(fs_findFile(dlist->fs,dirname,&loc,&fc)!=2)
34 1 {
35 2 return(-1);
36 2 }
37 1
38 1 fs_initClusterChain(dlist->fs,&(dlist->Cache),fc);
39 1 memClr(&(dlist->currentEntry),sizeof(dlist->currentEntry));
40 1 dlist->rEntry=0;
41 1 dlist->cEntry=0xFFFF;
42 1
43 1 return(0);
44 1 }
45 /*****************************************************************************/
46
47 esint8 ls_getDirEntry(DirList *dlist)
48 {
49 1 if(dlist->Cache.FirstCluster == 1){
50 2 return(ls_getRootAreaEntry(dlist));
51 2 }else if(dlist->Cache.FirstCluster){
52 2 return(ls_getRealDirEntry(dlist));
53 2 }
54 1 return(-1);
55 1 }
56 /*****************************************************************************/
57
58 esint8 ls_getNext(DirList *dlist)
59 {
ARM COMPILER V2.42, ls 27/03/06 10:45:51 PAGE 2
60 1 do{
61 2 if(ls_getDirEntry(dlist))return(-1);
62 2 dlist->rEntry++;
63 2 }while(!ls_isValidFileEntry(&(dlist->currentEntry)));
64 1 dlist->cEntry++;
65 1 return(0);
66 1 }
67 /*****************************************************************************/
68
69 esint8 ls_getRealDirEntry(DirList *dlist)
70 {
71 1 euint8* buf;
72 1
73 1 if(dlist->Cache.FirstCluster<=1)return(-1);
74 1
75 1 if(fat_LogicToDiscCluster(dlist->fs,
76 1 &(dlist->Cache),
77 1 (dlist->rEntry)/(16 * dlist->fs->volumeId.SectorsPerCluster))){
78 2 return(-1);
79 2 }
80 1
81 1 buf = part_getSect(dlist->fs->part,
82 1 fs_clusterToSector(dlist->fs,dlist->Cache.DiscCluster) + (dlist->rEntry/16)%dlist->fs->volumeId.S
-ectorsPerCluster,
83 1 IOM_MODE_READONLY);
84 1
85 1 /*memCpy(buf+(dlist->rEntry%16)*32,&(dlist->currentEntry),32);*/
86 1 ls_fileEntryToDirListEntry(dlist,buf,32*(dlist->rEntry%16));
87 1
88 1 part_relSect(dlist->fs->part,buf);
89 1
90 1 return(0);
91 1 }
92 /*****************************************************************************/
93
94 esint8 ls_getRootAreaEntry(DirList *dlist)
95 {
96 1 euint8 *buf=0;
97 1
98 1 if((dlist->fs->type != FAT12) && (dlist->fs->type != FAT16))return(-1);
99 1 if(dlist->rEntry>=dlist->fs->volumeId.RootEntryCount)return(-1);
100 1
101 1 buf = part_getSect(dlist->fs->part,
102 1 dlist->fs->FirstSectorRootDir+dlist->rEntry/16,
103 1 IOM_MODE_READONLY);
104 1 /*memCpy(buf+32*(dlist->rEntry%16),&(dlist->currentEntry),32);*/
105 1 ls_fileEntryToDirListEntry(dlist,buf,32*(dlist->rEntry%16));
106 1 part_relSect(dlist->fs->part,buf);
107 1 return(0);
108 1 }
109 /*****************************************************************************/
110
111 esint8 ls_isValidFileEntry(ListDirEntry *entry)
112 {
113 1 if(entry->FileName[0] == 0 || entry->FileName[0] == 0xE5 || entry->FileName[0] == '.')return(0);
114 1 if((entry->Attribute&0x0F)==0x0F)return(0);
115 1 return(1);
116 1 }
117 /*****************************************************************************/
118
119 void ls_fileEntryToDirListEntry(DirList *dlist, euint8* buf, euint16 offset)
120 {
121 1 if(offset>480 || offset%32)return;
122 1
123 1 buf+=offset;
124 1 memCpy(buf+OFFSET_DE_FILENAME,dlist->currentEntry.FileName,LIST_MAXLENFILENAME);
ARM COMPILER V2.42, ls 27/03/06 10:45:51 PAGE 3
125 1 dlist->currentEntry.Attribute = *(buf+OFFSET_DE_ATTRIBUTE);
126 1 dlist->currentEntry.FileSize = ex_getb32(buf,OFFSET_DE_FILESIZE);
127 1 }
128 /*****************************************************************************/
129
ARM COMPILER V2.42, ls 27/03/06 10:45:51 PAGE 4
ASSEMBLY LISTING OF GENERATED OBJECT CODE
*** EXTERNALS:
EXTERN CODE16 (memCpy?T)
EXTERN CODE16 (memClr?T)
EXTERN CODE16 (ex_getb32?T)
EXTERN CODE16 (part_getSect?T)
EXTERN CODE16 (part_relSect?T)
EXTERN CODE16 (fs_clusterToSector?T)
EXTERN CODE16 (fs_findFile?T)
EXTERN CODE16 (fs_initClusterChain?T)
EXTERN CODE16 (fat_LogicToDiscCluster?T)
EXTERN CODE16 (?C?SDIV?T)
*** PUBLICS:
PUBLIC ls_openDir?T
PUBLIC ls_getNext?T
PUBLIC ls_getDirEntry?T
PUBLIC ls_getRealDirEntry?T
PUBLIC ls_getRootAreaEntry?T
PUBLIC ls_isValidFileEntry?T
PUBLIC ls_fileEntryToDirListEntry?T
*** CODE SEGMENT '?PR?ls_openDir?T?ls':
26: esint8 ls_openDir(DirList *dlist,FileSystem *fs,eint8* dirname)
00000000 B510 PUSH {R4,LR}
00000002 ---- Variable 'dirname' assigned to Register 'R2' ----
00000002 1C0B MOV R3,R1 ; fs
00000004 ---- Variable 'fs' assigned to Register 'R3' ----
00000004 1C04 MOV R4,R0 ; dlist
00000006 ---- Variable 'dlist' assigned to Register 'R4' ----
00000006 B083 SUB R13,#0xC
27: {
00000008 ; SCOPE-START
31: dlist->fs=fs;
00000008 1C19 MOV R1,R3 ; fs
0000000A 1C20 MOV R0,R4 ; dlist
0000000C 6001 STR R1,[R0,#0x0] ; dlist
33: if(fs_findFile(dlist->fs,dirname,&loc,&fc)!=2)
0000000E 1C20 MOV R0,R4 ; dlist
00000010 6800 LDR R0,[R0,#0x0] ; dlist
00000012 1C11 MOV R1,R2 ; dirname
00000014 AA00 ADD R2,R13,#0x0
00000016 AB02 ADD R3,R13,#0x8
00000018 F7FF BL fs_findFile?T ; T=0x0001 (1)
0000001A FFF2 BL fs_findFile?T ; T=0x0001 (2)
0000001C 0600 LSL R0,R0,#0x18 ; fs_findFile?T
0000001E 1600 ASR R0,R0,#0x18
00000020 2802 CMP R0,#0x2
00000022 D001 BEQ L_1 ; T=0x00000028
35: return(-1);
00000024 4800 LDR R0,=0xFFFFFFFF
00000026 E012 B L_2 ; T=0x0000004E
36: }
00000028 L_1:
38: fs_initClusterChain(dlist->fs,&(dlist->Cache),fc);
00000028 1C20 MOV R0,R4 ; dlist
0000002A 6800 LDR R0,[R0,#0x0] ; dlist
0000002C 1C21 MOV R1,R4 ; dlist
0000002E 311C ADD R1,#0x1C
00000030 9A02 LDR R2,[R13,#0x8] ; fc
00000032 F7FF BL fs_initClusterChain?T ; T=0x0001 (1)
00000034 FFE5 BL fs_initClusterChain?T ; T=0x0001 (2)
39: memClr(&(dlist->currentEntry),sizeof(dlist->currentEntry));
00000036 1C20 MOV R0,R4 ; dlist
ARM COMPILER V2.42, ls 27/03/06 10:45:51 PAGE 5
00000038 3008 ADD R0,#0x8
0000003A 2114 MOV R1,#0x14
0000003C F7FF BL memClr?T ; T=0x0001 (1)
0000003E FFE0 BL memClr?T ; T=0x0001 (2)
40: dlist->rEntry=0;
00000040 2100 MOV R1,#0x0
00000042 1C20 MOV R0,R4 ; dlist
00000044 80C1 STRH R1,[R0,#0x6]
41: dlist->cEntry=0xFFFF;
00000046 4800 LDRH R1,=0xFFFF
00000048 1C20 MOV R0,R4 ; dlist
0000004A 8081 STRH R1,[R0,#0x4]
43: return(0);
0000004C 2000 MOV R0,#0x0
0000004E ; SCOPE-END
44: }
0000004E L_2:
0000004E B003 ADD R13,#0xC
00000050 BC10 POP {R4}
00000052 BC08 POP {R3}
00000054 4718 BX R3
00000056 ENDP ; 'ls_openDir?T'
*** CODE SEGMENT '?PR?ls_getDirEntry?T?ls':
47: esint8 ls_getDirEntry(DirList *dlist)
00000000 B530 PUSH {R4-R5,LR}
00000002 1C04 MOV R4,R0 ; dlist
00000004 ---- Variable 'dlist' assigned to Register 'R4' ----
49: if(dlist->Cache.FirstCluster == 1){
00000004 1C20 MOV R0,R4 ; dlist
00000006 6A85 LDR R5,[R0,#0x28]
00000008 2D01 CMP R5,#0x1
0000000A D105 BNE L_3 ; T=0x00000018
50: return(ls_getRootAreaEntry(dlist));
0000000C 1C20 MOV R0,R4 ; dlist
0000000E F7FF BL ls_getRootAreaEntry?T ; T=0x0001 (1)
00000010 FFF7 BL ls_getRootAreaEntry?T ; T=0x0001 (2)
00000012 0600 LSL R0,R0,#0x18 ; ls_getRootAreaEntry?T
00000014 1600 ASR R0,R0,#0x18
00000016 E008 B L_4 ; T=0x0000002A
51: }else if(dlist->Cache.FirstCluster){
00000018 L_3:
00000018 2D00 CMP R5,#0x0
0000001A D005 BEQ L_5 ; T=0x00000028
52: return(ls_getRealDirEntry(dlist));
0000001C 1C20 MOV R0,R4 ; dlist
0000001E F7FF BL ls_getRealDirEntry?T ; T=0x0001 (1)
00000020 FFEF BL ls_getRealDirEntry?T ; T=0x0001 (2)
00000022 0600 LSL R0,R0,#0x18 ; ls_getRealDirEntry?T
00000024 1600 ASR R0,R0,#0x18
00000026 E000 B L_4 ; T=0x0000002A
53: }
00000028 L_5:
54: return(-1);
00000028 4800 LDR R0,=0xFFFFFFFF
55: }
0000002A L_4:
0000002A BC30 POP {R4-R5}
0000002C BC08 POP {R3}
0000002E 4718 BX R3
00000030 ENDP ; 'ls_getDirEntry?T'
*** CODE SEGMENT '?PR?ls_getNext?T?ls':
58: esint8 ls_getNext(DirList *dlist)
00000000 B510 PUSH {R4,LR}
00000002 1C04 MOV R4,R0 ; dlist
00000004 ---- Variable 'dlist' assigned to Register 'R4' ----
60: do{
ARM COMPILER V2.42, ls 27/03/06 10:45:51 PAGE 6
00000004 L_7:
61: if(ls_getDirEntry(dlist))return(-1);
00000004 1C20 MOV R0,R4 ; dlist
00000006 F7FF BL ls_getDirEntry?T ; T=0x0001 (1)
00000008 FFFB BL ls_getDirEntry?T ; T=0x0001 (2)
0000000A 2800 CMP R0,#0x0 ; ls_getDirEntry?T
0000000C D001 BEQ L_11 ; T=0x00000012
0000000E 4800 LDR R0,=0xFFFFFFFF
00000010 E012 B L_12 ; T=0x00000038
00000012 L_11:
62: dlist->rEntry++;
00000012 1C20 MOV R0,R4 ; dlist
00000014 3006 ADD R0,#0x6
00000016 8801 LDRH R1,[R0,#0x0]
00000018 3101 ADD R1,#0x1
0000001A 8001 STRH R1,[R0,#0x0]
63: }while(!ls_isValidFileEntry(&(dlist->currentEntry)));
0000001C 1C20 MOV R0,R4 ; dlist
0000001E 3008 ADD R0,#0x8
00000020 F7FF BL ls_isValidFileEntry?T ; T=0x0001 (1)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -