summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorMiika Pekkarinen <miipekk@ihme.org>2006-01-31 10:08:53 +0000
committerMiika Pekkarinen <miipekk@ihme.org>2006-01-31 10:08:53 +0000
commitde281db7e7dee08301b22ad79a7752588691b66f (patch)
tree23d8cb89722611621b6e3851fce240272ddc1073 /firmware
parent1446b210eb928607eb257c63d2c100fc15650d17 (diff)
downloadrockbox-de281db7e7dee08301b22ad79a7752588691b66f.tar.gz
rockbox-de281db7e7dee08301b22ad79a7752588691b66f.zip
Now dircache should work on players requiring long aligned memory
accesses. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8502 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/common/dircache.c32
-rw-r--r--firmware/export/config.h6
-rw-r--r--firmware/include/dircache.h3
3 files changed, 36 insertions, 5 deletions
diff --git a/firmware/common/dircache.c b/firmware/common/dircache.c
index 9e96404dd6..fbd7fab188 100644
--- a/firmware/common/dircache.c
+++ b/firmware/common/dircache.c
@@ -55,6 +55,7 @@ static bool dircache_initialized = false;
55static bool thread_enabled = false; 55static bool thread_enabled = false;
56static unsigned long allocated_size = DIRCACHE_LIMIT; 56static unsigned long allocated_size = DIRCACHE_LIMIT;
57static unsigned long dircache_size = 0; 57static unsigned long dircache_size = 0;
58static unsigned long entry_count = 0;
58static unsigned long reserve_used = 0; 59static unsigned long reserve_used = 0;
59static unsigned int cache_build_ticks = 0; 60static unsigned int cache_build_ticks = 0;
60static char dircache_cur_path[MAX_PATH]; 61static char dircache_cur_path[MAX_PATH];
@@ -79,12 +80,22 @@ static struct dircache_entry* allocate_entry(void)
79 } 80 }
80 81
81 next_entry = (struct dircache_entry *)((char *)dircache_root+dircache_size); 82 next_entry = (struct dircache_entry *)((char *)dircache_root+dircache_size);
82 dircache_size += sizeof(struct dircache_entry); 83#ifdef ROCKBOX_STRICT_ALIGN
84 /* Make sure the entry is long aligned. */
85 if ((long)next_entry & 0x03)
86 {
87 next_entry = (struct dircache_entry *)(((long)next_entry & ~0x03) + 0x04);
88 dircache_size += 4 - ((long)next_entry & 0x03);
89 }
90#endif
83 next_entry->name_len = 0; 91 next_entry->name_len = 0;
84 next_entry->d_name = NULL; 92 next_entry->d_name = NULL;
85 next_entry->up = NULL; 93 next_entry->up = NULL;
86 next_entry->down = NULL; 94 next_entry->down = NULL;
87 next_entry->next = NULL; 95 next_entry->next = NULL;
96
97 dircache_size += sizeof(struct dircache_entry);
98 entry_count++;
88 99
89 return next_entry; 100 return next_entry;
90} 101}
@@ -306,16 +317,17 @@ int dircache_load(const char *path)
306 if (fd < 0) 317 if (fd < 0)
307 return -2; 318 return -2;
308 319
320 dircache_root = (struct dircache_entry *)(((long)audiobuf & ~0x03) + 0x04);
309 bytes_read = read(fd, &maindata, sizeof(struct dircache_maindata)); 321 bytes_read = read(fd, &maindata, sizeof(struct dircache_maindata));
310 if (bytes_read != sizeof(struct dircache_maindata) 322 if (bytes_read != sizeof(struct dircache_maindata)
311 || (long)maindata.root_entry != (long)audiobuf 323 || (long)maindata.root_entry != (long)dircache_root
312 || maindata.size <= 0) 324 || maindata.size <= 0)
313 { 325 {
314 close(fd); 326 close(fd);
315 return -3; 327 return -3;
316 } 328 }
317 329
318 dircache_root = (struct dircache_entry *)audiobuf; 330 entry_count = maindata.entry_count;
319 bytes_read = read(fd, dircache_root, MIN(DIRCACHE_LIMIT, maindata.size)); 331 bytes_read = read(fd, dircache_root, MIN(DIRCACHE_LIMIT, maindata.size));
320 close(fd); 332 close(fd);
321 333
@@ -359,6 +371,7 @@ int dircache_save(const char *path)
359 maindata.magic = DIRCACHE_MAGIC; 371 maindata.magic = DIRCACHE_MAGIC;
360 maindata.size = dircache_size; 372 maindata.size = dircache_size;
361 maindata.root_entry = dircache_root; 373 maindata.root_entry = dircache_root;
374 maindata.entry_count = entry_count;
362 375
363 /* Save the info structure */ 376 /* Save the info structure */
364 bytes_written = write(fd, &maindata, sizeof(struct dircache_maindata)); 377 bytes_written = write(fd, &maindata, sizeof(struct dircache_maindata));
@@ -491,7 +504,7 @@ int dircache_build(int last_size)
491 } 504 }
492 else 505 else
493 { 506 {
494 dircache_root = (struct dircache_entry *)audiobuf; 507 dircache_root = (struct dircache_entry *)(((long)audiobuf & ~0x03) + 0x04);
495 dircache_size = 0; 508 dircache_size = 0;
496 } 509 }
497 510
@@ -541,6 +554,14 @@ bool dircache_is_enabled(void)
541} 554}
542 555
543/** 556/**
557 * Returns the current number of entries (directories and files) in the cache.
558 */
559int dircache_get_entry_count(void)
560{
561 return entry_count;
562}
563
564/**
544 * Returns the allocated space for dircache (without reserve space). 565 * Returns the allocated space for dircache (without reserve space).
545 */ 566 */
546int dircache_get_cache_size(void) 567int dircache_get_cache_size(void)
@@ -896,7 +917,7 @@ struct dircache_entry* readdir_cached(DIRCACHED* dir)
896 regentry = readdir(dir->regulardir); 917 regentry = readdir(dir->regulardir);
897 if (regentry == NULL) 918 if (regentry == NULL)
898 return NULL; 919 return NULL;
899 920
900 strncpy(dir->secondary_entry.d_name, regentry->d_name, MAX_PATH-1); 921 strncpy(dir->secondary_entry.d_name, regentry->d_name, MAX_PATH-1);
901 dir->secondary_entry.size = regentry->size; 922 dir->secondary_entry.size = regentry->size;
902 dir->secondary_entry.startcluster = regentry->startcluster; 923 dir->secondary_entry.startcluster = regentry->startcluster;
@@ -928,6 +949,7 @@ struct dircache_entry* readdir_cached(DIRCACHED* dir)
928 dir->secondary_entry.wrttime = ce->wrttime; 949 dir->secondary_entry.wrttime = ce->wrttime;
929 dir->secondary_entry.wrtdate = ce->wrtdate; 950 dir->secondary_entry.wrtdate = ce->wrtdate;
930 dir->secondary_entry.next = NULL; 951 dir->secondary_entry.next = NULL;
952 dir->internal_entry = ce;
931 953
932 //logf("-> %s", ce->name); 954 //logf("-> %s", ce->name);
933 return &dir->secondary_entry; 955 return &dir->secondary_entry;
diff --git a/firmware/export/config.h b/firmware/export/config.h
index 8df596665f..8ce7ee61a3 100644
--- a/firmware/export/config.h
+++ b/firmware/export/config.h
@@ -160,6 +160,12 @@
160#define HAVE_DIRCACHE 1 160#define HAVE_DIRCACHE 1
161#endif 161#endif
162 162
163/* Determine if accesses should be strictly long aligned. */
164#if (CONFIG_CPU == SH7034) || (CONFIG_CPU == PNX0101) \
165 || (CONFIG_CPU == PP5002) || (CONFIG_CPU == PP5020)
166#define ROCKBOX_STRICT_ALIGN 1
167#endif
168
163/* define for all cpus from coldfire family */ 169/* define for all cpus from coldfire family */
164#if (CONFIG_CPU == MCF5249) || (CONFIG_CPU == MCF5250) 170#if (CONFIG_CPU == MCF5249) || (CONFIG_CPU == MCF5250)
165#define CPU_COLDFIRE 171#define CPU_COLDFIRE
diff --git a/firmware/include/dircache.h b/firmware/include/dircache.h
index 512fcb1833..6e75e1bfeb 100644
--- a/firmware/include/dircache.h
+++ b/firmware/include/dircache.h
@@ -41,6 +41,7 @@ struct travel_data {
41struct dircache_maindata { 41struct dircache_maindata {
42 long magic; 42 long magic;
43 long size; 43 long size;
44 long entry_count;
44 struct dircache_entry *root_entry; 45 struct dircache_entry *root_entry;
45}; 46};
46 47
@@ -61,6 +62,7 @@ struct dircache_entry {
61typedef struct { 62typedef struct {
62 bool busy; 63 bool busy;
63 struct dircache_entry *entry; 64 struct dircache_entry *entry;
65 struct dircache_entry *internal_entry;
64 struct dircache_entry secondary_entry; 66 struct dircache_entry secondary_entry;
65 DIR *regulardir; 67 DIR *regulardir;
66} DIRCACHED; 68} DIRCACHED;
@@ -70,6 +72,7 @@ int dircache_load(const char *path);
70int dircache_save(const char *path); 72int dircache_save(const char *path);
71int dircache_build(int last_size); 73int dircache_build(int last_size);
72bool dircache_is_enabled(void); 74bool dircache_is_enabled(void);
75int dircache_get_entry_count(void);
73int dircache_get_cache_size(void); 76int dircache_get_cache_size(void);
74int dircache_get_reserve_used(void); 77int dircache_get_reserve_used(void);
75int dircache_get_build_ticks(void); 78int dircache_get_build_ticks(void);