Author: fireball Date: Sun Feb 3 21:51:48 2008 New Revision: 32107
URL: http://svn.reactos.org/svn/reactos?rev=32107&view=rev Log: - Make caching enable/disable a runtime switch instead of a compile time one.
Modified: trunk/reactos/boot/freeldr/freeldr/fs/fat.c
Modified: trunk/reactos/boot/freeldr/freeldr/fs/fat.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/fs/fat... ============================================================================== --- trunk/reactos/boot/freeldr/freeldr/fs/fat.c (original) +++ trunk/reactos/boot/freeldr/freeldr/fs/fat.c Sun Feb 3 21:51:48 2008 @@ -22,7 +22,7 @@ #define NDEBUG #include <debug.h>
-#define CACHE_ENABLED +BOOLEAN gCacheEnabled = TRUE;
ULONG BytesPerSector; /* Number of bytes per sector */ ULONG SectorsPerCluster; /* Number of sectors per cluster */ @@ -336,28 +336,30 @@ } MmHeapFree(FatVolumeBootSector);
-#ifdef CACHE_ENABLED - // - // Initialize the disk cache for this drive - // - if (!CacheInitializeDrive(DriveNumber)) - { - return FALSE; - } - - // - // Force the FAT sectors into the cache - // as long as it is FAT12 or FAT16. FAT32 can - // have a multi-megabyte FAT so we don't want that. - // - if (FatType != FAT32 && FatType != FATX32) - { - if (!CacheForceDiskSectorsIntoCache(DriveNumber, ActiveFatSectorStart, SectorsPerFat)) + if (gCacheEnabled) + { + // + // Initialize the disk cache for this drive + // + if (!CacheInitializeDrive(DriveNumber)) { return FALSE; } - } -#else + + // + // Force the FAT sectors into the cache + // as long as it is FAT12 or FAT16. FAT32 can + // have a multi-megabyte FAT so we don't want that. + // + if (FatType != FAT32 && FatType != FATX32) + { + if (!CacheForceDiskSectorsIntoCache(DriveNumber, ActiveFatSectorStart, SectorsPerFat)) + { + return FALSE; + } + } + } + else { GEOMETRY DriveGeometry; ULONG BlockSize; @@ -370,7 +372,6 @@
BlockSize = MachDiskGetCacheableBlockCount(DriveNumber); } -#endif
return TRUE; } @@ -1422,21 +1423,24 @@
BOOLEAN FatReadVolumeSectors(ULONG DriveNumber, ULONG SectorNumber, ULONG SectorCount, PVOID Buffer) { -#ifdef CACHE_ENABLED - return CacheReadDiskSectors(DriveNumber, SectorNumber + FatVolumeStartSector, SectorCount, Buffer); -#else - // Now try to read in the block - if (!MachDiskReadLogicalSectors(DriveNumber, SectorNumber + FatVolumeStartSector, SectorCount, (PVOID)DISKREADBUFFER)) - { - return FALSE; - } - - // Copy data to the caller - RtlCopyMemory(Buffer, (PVOID)DISKREADBUFFER, SectorCount * BytesPerSector); - - // Return success - return TRUE; -#endif + if (gCacheEnabled) + { + return CacheReadDiskSectors(DriveNumber, SectorNumber + FatVolumeStartSector, SectorCount, Buffer); + } + else + { + // Now try to read in the block + if (!MachDiskReadLogicalSectors(DriveNumber, SectorNumber + FatVolumeStartSector, SectorCount, (PVOID)DISKREADBUFFER)) + { + return FALSE; + } + + // Copy data to the caller + RtlCopyMemory(Buffer, (PVOID)DISKREADBUFFER, SectorCount * BytesPerSector); + + // Return success + return TRUE; + } }
const FS_VTBL FatVtbl = {