Author: fireball Date: Sun Jan 27 17:13:20 2008 New Revision: 32028
URL: http://svn.reactos.org/svn/reactos?rev=32028&view=rev Log: - Add cache enable switch to fat.c. Comment out #define CACHE_ENABLED if you don't want freeldr to cache peripheral devices access.
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 Jan 27 17:13:20 2008 @@ -21,6 +21,8 @@
#define NDEBUG #include <debug.h> + +#define CACHE_ENABLED
ULONG BytesPerSector; /* Number of bytes per sector */ ULONG SectorsPerCluster; /* Number of sectors per cluster */ @@ -334,6 +336,7 @@ } MmHeapFree(FatVolumeBootSector);
+#ifdef CACHE_ENABLED // // Initialize the disk cache for this drive // @@ -354,6 +357,20 @@ return FALSE; } } +#else + { + GEOMETRY DriveGeometry; + ULONG BlockSize; + + // Initialize drive by getting its geometry + if (!MachDiskGetDriveGeometry(DriveNumber, &DriveGeometry)) + { + return FALSE; + } + + BlockSize = MachDiskGetCacheableBlockCount(DriveNumber); + } +#endif
return TRUE; } @@ -1405,7 +1422,21 @@
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 }
const FS_VTBL FatVtbl = {