diff options
| author | Miika Pekkarinen <miipekk@ihme.org> | 2006-08-05 20:19:10 +0000 |
|---|---|---|
| committer | Miika Pekkarinen <miipekk@ihme.org> | 2006-08-05 20:19:10 +0000 |
| commit | 954b73265404075ec4d379ddea14e626113a8677 (patch) | |
| tree | 5c6ff0056ebd118aadb896856e7679a41c595cba /firmware/common | |
| parent | 85ba65d2a3fa3d10799efadbe3a33f026bf354df (diff) | |
| download | rockbox-954b73265404075ec4d379ddea14e626113a8677.zip rockbox-954b73265404075ec4d379ddea14e626113a8677.tar.gz rockbox-954b73265404075ec4d379ddea14e626113a8677.tar.bz2 rockbox-954b73265404075ec4d379ddea14e626113a8677.tar.xz | |
Initial support and use for EEPROM memory on H120 & H140 players when
Rockbox firmware has been flashed over original firmware (not yet
possible to do). Dircache & tagcache serialization for fast bootup
without the need to scan disk when Rockbox is in flash.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10464 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/common')
| -rw-r--r-- | firmware/common/crc32.c | 4 | ||||
| -rw-r--r-- | firmware/common/dircache.c | 32 |
2 files changed, 26 insertions, 10 deletions
diff --git a/firmware/common/crc32.c b/firmware/common/crc32.c index 18ee6ac..21fefac 100644 --- a/firmware/common/crc32.c +++ b/firmware/common/crc32.c @@ -21,8 +21,10 @@ /* Tool function to calculate a CRC32 across some buffer */ /* third argument is either 0xFFFFFFFF to start or value from last piece */ -unsigned crc_32(unsigned char* buf, unsigned len, unsigned crc32) +unsigned crc_32(const void *src, unsigned len, unsigned crc32) { + const unsigned char *buf = (const unsigned char *)src; + /* CCITT standard polynomial 0x04C11DB7 */ static const unsigned crc32_lookup[16] = { /* lookup table for 4 bits at a time is affordable */ diff --git a/firmware/common/dircache.c b/firmware/common/dircache.c index 6167aa3..d2c77a2 100644 --- a/firmware/common/dircache.c +++ b/firmware/common/dircache.c @@ -402,7 +402,7 @@ static struct dircache_entry* dircache_get_entry(const char *path, return cache_entry; } -#if 0 +#if 1 /** * Function to load the internal cache structure from disk to initialize * the dircache really fast and little disk access. @@ -423,32 +423,41 @@ int dircache_load(const char *path) if (fd < 0) return -2; - dircache_root = (struct dircache_entry *)(((long)audiobuf & ~0x03) + 0x04); bytes_read = read(fd, &maindata, sizeof(struct dircache_maindata)); if (bytes_read != sizeof(struct dircache_maindata) - || (long)maindata.root_entry != (long)dircache_root || maindata.size <= 0) { + logf("Dircache file header error"); close(fd); return -3; } + dircache_root = buffer_alloc(0); + if ((long)maindata.root_entry != (long)dircache_root) + { + logf("Position missmatch"); + close(fd); + return -4; + } + + dircache_root = buffer_alloc(maindata.size + DIRCACHE_RESERVE); entry_count = maindata.entry_count; bytes_read = read(fd, dircache_root, MIN(DIRCACHE_LIMIT, maindata.size)); close(fd); if (bytes_read != maindata.size) + { + logf("Dircache read failed"); return -6; + } /* Cache successfully loaded. */ dircache_size = maindata.size; + allocated_size = dircache_size + DIRCACHE_RESERVE; + reserve_used = 0; logf("Done, %d KiB used", dircache_size / 1024); dircache_initialized = true; memset(fd_bindings, 0, sizeof(fd_bindings)); - - /* We have to long align the audiobuf to keep the buffer access fast. */ - audiobuf += (long)((dircache_size & ~0x03) + 0x04); - audiobuf += DIRCACHE_RESERVE; return 0; } @@ -472,7 +481,7 @@ int dircache_save(const char *path) return -1; logf("Saving directory cache"); - fd = open(path, O_WRONLY | O_CREAT); + fd = open(path, O_WRONLY | O_CREAT | O_TRUNC); maindata.magic = DIRCACHE_MAGIC; maindata.size = dircache_size; @@ -484,6 +493,7 @@ int dircache_save(const char *path) if (bytes_written != sizeof(struct dircache_maindata)) { close(fd); + logf("dircache: write failed #1"); return -2; } @@ -491,8 +501,11 @@ int dircache_save(const char *path) bytes_written = write(fd, dircache_root, dircache_size); close(fd); if (bytes_written != dircache_size) + { + logf("dircache: write failed #2"); return -3; - + } + return 0; } #endif /* #if 0 */ @@ -616,6 +629,7 @@ int dircache_build(int last_size) return -3; logf("Building directory cache"); + /* Background build, dircache has been previously allocated */ if (dircache_size > 0) { thread_enabled = true; |