From e89b232b5f4be59c5ad6480299d30f45754f199d Mon Sep 17 00:00:00 2001 From: tantricity Date: Sat, 30 May 2009 16:22:09 +0000 Subject: [PATCH] remove unused code, r18 args fix --- source/cache.c | 33 ++------------------------------- source/libfat.c | 38 +++++++++++++++++++------------------- 2 files changed, 21 insertions(+), 50 deletions(-) diff --git a/source/cache.c b/source/cache.c index 9fcf24f..9445c20 100644 --- a/source/cache.c +++ b/source/cache.c @@ -108,35 +108,6 @@ static u32 accessTime(){ return accessCounter; } -static void FlushAndInvalidateCachePage(CACHE* cache,unsigned int page) { - if(cache->cacheEntries[page].dirty == true) { - // Write the page back to disc - _FAT_disc_writeSectors (cache->disc, cache->cacheEntries[page].sector, cache->cacheEntries[page].count, cache->cacheEntries[page].cache); - } - //Invalidate - cache->cacheEntries[page].sector = CACHE_FREE; - cache->cacheEntries[page].last_access = 0; - cache->cacheEntries[page].count = 0; - cache->cacheEntries[page].dirty = false; - -} - -void InvalidateCachePagesSharingSectors(CACHE* cache, sec_t sector, sec_t numSectors, unsigned int valid_page) { - return; - unsigned int i; - if(cache==NULL)return; - CACHE_ENTRY* cacheEntries = cache->cacheEntries; - unsigned int numberOfPages = cache->numberOfPages; - - for (i = 0; i < numberOfPages ; i++) { - if(i==valid_page) continue; - if ( ( cacheEntries[i].sector > sector+numSectors ) || - ( cacheEntries[i].sector+cacheEntries[i].count < sector ) ) continue; - - FlushAndInvalidateCachePage(cache,i); - } -} - /* Retrieve a sector's page from the cache. If it is not found in the cache, load it into the cache and return the page it was loaded to. @@ -173,7 +144,7 @@ static unsigned int _FAT_cache_getSector (CACHE* cache, sec_t sector, void* buff } cacheEntries[oldUsed].dirty = false; } - InvalidateCachePagesSharingSectors(cache,sector,sectorsPerPage,oldUsed); + // Load the new sector into the cache if (!_FAT_disc_readSectors (cache->disc, sector, sectorsPerPage, cacheEntries[oldUsed].cache)) { return false; @@ -234,7 +205,7 @@ bool _FAT_cache_getSectors (CACHE* cache, sec_t sector, sec_t numSectors, void* cacheEntries[oldUsed].sector = sector; cacheEntries[oldUsed].count = cache->sectorsPerPage; - InvalidateCachePagesSharingSectors(cache,cacheEntries[oldUsed].sector,cacheEntries[oldUsed].count,oldUsed); + if (!_FAT_disc_readSectors (cache->disc, sector, cacheEntries[oldUsed].count, cacheEntries[oldUsed].cache)) { return false; } diff --git a/source/libfat.c b/source/libfat.c index cb71414..109234f 100644 --- a/source/libfat.c +++ b/source/libfat.c @@ -1,9 +1,9 @@ /* libfat.c Simple functionality for startup, mounting and unmounting of FAT-based devices. - + Copyright (c) 2006 Michael "Chishm" Chisholm - + Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -68,7 +68,7 @@ bool fatMount (const char* name, const DISC_INTERFACE* interface, sec_t startSec PARTITION* partition; devoptab_t* devops; char* nameCopy; - + if(!interface->startup()) return false; @@ -92,15 +92,15 @@ bool fatMount (const char* name, const DISC_INTERFACE* interface, sec_t startSec interface->shutdown(); return false; } - + // Add an entry for this device to the devoptab table memcpy (devops, &dotab_fat, sizeof(dotab_fat)); strcpy (nameCopy, name); devops->name = nameCopy; devops->deviceData = partition; - + AddDevice (devops); - + return true; } @@ -112,21 +112,21 @@ void fatUnmount (const char* name) { devoptab_t *devops; PARTITION* partition; const DISC_INTERFACE *disc; - + devops = (devoptab_t*)GetDeviceOpTab (name); if (!devops) { return; } - + // Perform a quick check to make sure we're dealing with a libfat controlled device if (devops->open_r != dotab_fat.open_r) { return; } - + if (RemoveDevice (name) == -1) { return; } - + partition = (PARTITION*)devops->deviceData; disc = partition->disc; _FAT_partition_destructor (partition); @@ -139,8 +139,8 @@ bool fatInit (uint32_t cacheSize, bool setAsDefaultDevice) { int defaultDevice = -1; const DISC_INTERFACE *disc; - for (i = 0; - _FAT_disc_interfaces[i].name != NULL && _FAT_disc_interfaces[i].getInterface != NULL; + for (i = 0; + _FAT_disc_interfaces[i].name != NULL && _FAT_disc_interfaces[i].getInterface != NULL; i++) { disc = _FAT_disc_interfaces[i].getInterface(); @@ -151,26 +151,26 @@ bool fatInit (uint32_t cacheSize, bool setAsDefaultDevice) { } } } - + if (defaultDevice < 0) { // None of our devices mounted return false; } - + if (setAsDefaultDevice) { char filePath[MAXPATHLEN * 2]; strcpy (filePath, _FAT_disc_interfaces[defaultDevice].name); strcat (filePath, ":/"); #ifdef ARGV_MAGIC - if ( __system_argv->argvMagic == ARGV_MAGIC && __system_argv->argc >= 1 ) { + if ( __system_argv->argvMagic == ARGV_MAGIC && __system_argv->argc >= 1 && strrchr( __system_argv->argv[0], '/' )!=NULL ) { // Check the app's path against each of our mounted devices, to see // if we can support it. If so, change to that path. - for (i = 0; - _FAT_disc_interfaces[i].name != NULL && _FAT_disc_interfaces[i].getInterface != NULL; + for (i = 0; + _FAT_disc_interfaces[i].name != NULL && _FAT_disc_interfaces[i].getInterface != NULL; i++) { - if ( !strncasecmp( __system_argv->argv[0], _FAT_disc_interfaces[i].name, - strlen(_FAT_disc_interfaces[i].name))) + if ( !strncasecmp( __system_argv->argv[0], _FAT_disc_interfaces[i].name, + strlen(_FAT_disc_interfaces[i].name))) { char *lastSlash; strcpy(filePath, __system_argv->argv[0]);