summaryrefslogtreecommitdiff
path: root/firmware/drivers
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2003-01-29 12:33:23 +0000
committerBjörn Stenberg <bjorn@haxx.se>2003-01-29 12:33:23 +0000
commit38bc30b0d62eadb904c320f7c0f5f2086b170ccc (patch)
tree19ecc261e1e5cf4b164931f857cf4b60c789a338 /firmware/drivers
parentff4da18d1a42342917a62f6e0a904b2884c98ae1 (diff)
downloadrockbox-38bc30b0d62eadb904c320f7c0f5f2086b170ccc.tar.gz
rockbox-38bc30b0d62eadb904c320f7c0f5f2086b170ccc.zip
The dir code is now reentrant.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3184 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers')
-rw-r--r--firmware/drivers/fat.c16
-rw-r--r--firmware/drivers/fat.h1
2 files changed, 7 insertions, 10 deletions
diff --git a/firmware/drivers/fat.c b/firmware/drivers/fat.c
index 9274a9c339..ef013ac481 100644
--- a/firmware/drivers/fat.c
+++ b/firmware/drivers/fat.c
@@ -253,10 +253,6 @@ struct fat_cache_entry
253static char fat_cache_sectors[FAT_CACHE_SIZE][SECTOR_SIZE]; 253static char fat_cache_sectors[FAT_CACHE_SIZE][SECTOR_SIZE];
254static struct fat_cache_entry fat_cache[FAT_CACHE_SIZE]; 254static struct fat_cache_entry fat_cache[FAT_CACHE_SIZE];
255 255
256/* sectors cache for longname use */
257static unsigned char lastsector[SECTOR_SIZE];
258static unsigned char lastsector2[SECTOR_SIZE];
259
260static int sec2cluster(unsigned int sec) 256static int sec2cluster(unsigned int sec)
261{ 257{
262 if ( sec < fat_bpb.firstdatasector ) 258 if ( sec < fat_bpb.firstdatasector )
@@ -1695,7 +1691,7 @@ int fat_getnext(struct fat_dir *dir, struct fat_direntry *entry)
1695 int longarray[20]; 1691 int longarray[20];
1696 int longs=0; 1692 int longs=0;
1697 int sectoridx=0; 1693 int sectoridx=0;
1698 static unsigned char cached_buf[SECTOR_SIZE]; 1694 unsigned char* cached_buf = dir->sectorcache[0];
1699 1695
1700 dir->entrycount = 0; 1696 dir->entrycount = 0;
1701 1697
@@ -1766,13 +1762,13 @@ int fat_getnext(struct fat_dir *dir, struct fat_direntry *entry)
1766 if ( sectoridx >= SECTOR_SIZE*2 ) { 1762 if ( sectoridx >= SECTOR_SIZE*2 ) {
1767 if ( ( index >= SECTOR_SIZE ) && 1763 if ( ( index >= SECTOR_SIZE ) &&
1768 ( index < SECTOR_SIZE*2 )) 1764 ( index < SECTOR_SIZE*2 ))
1769 ptr = lastsector; 1765 ptr = dir->sectorcache[1];
1770 else 1766 else
1771 ptr = lastsector2; 1767 ptr = dir->sectorcache[2];
1772 } 1768 }
1773 else { 1769 else {
1774 if ( index < SECTOR_SIZE ) 1770 if ( index < SECTOR_SIZE )
1775 ptr = lastsector; 1771 ptr = dir->sectorcache[1];
1776 } 1772 }
1777 1773
1778 index &= SECTOR_SIZE-1; 1774 index &= SECTOR_SIZE-1;
@@ -1799,9 +1795,9 @@ int fat_getnext(struct fat_dir *dir, struct fat_direntry *entry)
1799 1795
1800 /* save this sector, for longname use */ 1796 /* save this sector, for longname use */
1801 if ( sectoridx ) 1797 if ( sectoridx )
1802 memcpy( lastsector2, cached_buf, SECTOR_SIZE ); 1798 memcpy( dir->sectorcache[2], dir->sectorcache[0], SECTOR_SIZE );
1803 else 1799 else
1804 memcpy( lastsector, cached_buf, SECTOR_SIZE ); 1800 memcpy( dir->sectorcache[1], dir->sectorcache[0], SECTOR_SIZE );
1805 sectoridx += SECTOR_SIZE; 1801 sectoridx += SECTOR_SIZE;
1806 1802
1807 } 1803 }
diff --git a/firmware/drivers/fat.h b/firmware/drivers/fat.h
index 6a3e5cf967..ec71fceb05 100644
--- a/firmware/drivers/fat.h
+++ b/firmware/drivers/fat.h
@@ -64,6 +64,7 @@ struct fat_dir
64 unsigned int entrycount; 64 unsigned int entrycount;
65 int sector; 65 int sector;
66 struct fat_file file; 66 struct fat_file file;
67 unsigned char sectorcache[3][SECTOR_SIZE];
67}; 68};
68 69
69 70