Fix for buffer conflict between fat code and cache code - by Mike Lerwill

svn path=/trunk/; revision=2654
This commit is contained in:
Brian Palmer 2002-02-26 23:17:22 +00:00
parent e6b4f4973d
commit ad979612af
4 changed files with 29 additions and 21 deletions

View file

@ -39,8 +39,11 @@
#define NR_TASKS 128 /* Space reserved in the GDT for TSS descriptors */
#define STACK16ADDR 0x7000 /* The 16-bit stack top will be at 0000:7000 */
#define STACK32ADDR 0xA0000 /* The 32-bit stack top will be at 9000:FFFF, or 0x9FFFF */
#define STACK32ADDR 0x80000 /* The 32-bit stack top will be at 7000:FFFF, or 0x7FFFF */
#define MAXLOWMEMADDR 0x78000 /* The highest usuable low memory address for our memory allocator */
#define FILESYSBUFFER 0x80000 /* Buffer to store file system data (e.g. cluster buffer for FAT) */
#define DISKREADBUFFER 0x90000 /* Buffer to store data read in from the disk via the BIOS */
/* Makes "x" a global variable or label */

View file

@ -57,7 +57,7 @@ VOID BootMain(VOID)
DebugInit();
#endif
InitMemoryManager( (PVOID) 0x20000 /* BaseAddress */, 0x70000 /* Length */);
InitMemoryManager( (PVOID) 0x20000 /* BaseAddress */, 0x58000 /* Length */);
if (!ParseIniFile())
{

View file

@ -40,7 +40,6 @@ ULONG RootDirSectors; // Number of sectors of the root directory (fat32)
ULONG FatType = 0; // FAT12, FAT16, or FAT32
ULONG FatDriveNumber = 0;
BOOL FatOpenVolume(ULONG DriveNumber, ULONG VolumeStartSector)
{
@ -77,6 +76,7 @@ BOOL FatOpenVolume(ULONG DriveNumber, ULONG VolumeStartSector)
// Now try to read the boot sector
// If this fails then abort
if (!DiskReadLogicalSectors(DriveNumber, VolumeStartSector, 1, FatVolumeBootSector))
{
return FALSE;
@ -247,7 +247,12 @@ ULONG FatDetermineFatType(PFAT_BOOTSECTOR FatBootSector)
SectorsPerFat = FatBootSector->SectorsPerFat ? FatBootSector->SectorsPerFat : Fat32BootSector->SectorsPerFatBig;
TotalSectors = FatBootSector->TotalSectors ? FatBootSector->TotalSectors : FatBootSector->TotalSectorsBig;
DataSectorCount = TotalSectors - (FatBootSector->ReservedSectors + (FatBootSector->NumberOfFats * SectorsPerFat) + RootDirSectors);
CountOfClusters = DataSectorCount / FatBootSector->SectorsPerCluster;
//mjl
if (FatBootSector->SectorsPerCluster == 0)
CountOfClusters = 0;
else
CountOfClusters = DataSectorCount / FatBootSector->SectorsPerCluster;
if (CountOfClusters < 4085)
{
@ -771,20 +776,20 @@ BOOL FatGetFatEntry(UINT32 Cluster, PUINT32 ClusterPointer)
if (ThisFatEntOffset == (FatVolumeBootSector->BytesPerSector - 1))
{
if (!FatReadVolumeSectors(FatDriveNumber, ThisFatSecNum, 2, (PVOID)DISKREADBUFFER))
if (!FatReadVolumeSectors(FatDriveNumber, ThisFatSecNum, 2, (PVOID)FILESYSBUFFER))
{
return FALSE;
}
}
else
{
if (!FatReadVolumeSectors(FatDriveNumber, ThisFatSecNum, 1, (PVOID)DISKREADBUFFER))
if (!FatReadVolumeSectors(FatDriveNumber, ThisFatSecNum, 1, (PVOID)FILESYSBUFFER))
{
return FALSE;
}
}
fat = *((WORD *) (DISKREADBUFFER + ThisFatEntOffset));
fat = *((WORD *) ((PVOID)FILESYSBUFFER + ThisFatEntOffset));
if (Cluster & 0x0001)
fat = fat >> 4; /* Cluster number is ODD */
else
@ -798,12 +803,12 @@ BOOL FatGetFatEntry(UINT32 Cluster, PUINT32 ClusterPointer)
ThisFatSecNum = FatVolumeBootSector->ReservedSectors + (FatOffset / FatVolumeBootSector->BytesPerSector);
ThisFatEntOffset = (FatOffset % FatVolumeBootSector->BytesPerSector);
if (!FatReadVolumeSectors(FatDriveNumber, ThisFatSecNum, 1, (PVOID)DISKREADBUFFER))
if (!FatReadVolumeSectors(FatDriveNumber, ThisFatSecNum, 1, (PVOID)FILESYSBUFFER))
{
return FALSE;
}
fat = *((WORD *) (DISKREADBUFFER + ThisFatEntOffset));
fat = *((WORD *) ((PVOID)FILESYSBUFFER + ThisFatEntOffset));
break;
@ -814,13 +819,13 @@ BOOL FatGetFatEntry(UINT32 Cluster, PUINT32 ClusterPointer)
ThisFatSecNum += FatVolumeBootSector->ReservedSectors + (FatOffset / FatVolumeBootSector->BytesPerSector);
ThisFatEntOffset = (FatOffset % FatVolumeBootSector->BytesPerSector);
if (!FatReadVolumeSectors(FatDriveNumber, ThisFatSecNum, 1, (PVOID)DISKREADBUFFER))
if (!FatReadVolumeSectors(FatDriveNumber, ThisFatSecNum, 1, (PVOID)FILESYSBUFFER))
{
return FALSE;
}
// Get the fat entry
fat = (*((DWORD *) (DISKREADBUFFER + ThisFatEntOffset))) & 0x0FFFFFFF;
fat = (*((DWORD *) ((PVOID)FILESYSBUFFER + ThisFatEntOffset))) & 0x0FFFFFFF;
break;
@ -968,12 +973,12 @@ BOOL FatReadCluster(ULONG ClusterNumber, PVOID Buffer)
DbgPrint((DPRINT_FILESYSTEM, "FatReadCluster() ClusterNumber = %d Buffer = 0x%x ClusterStartSector = %d\n", ClusterNumber, Buffer, ClusterStartSector));
if (!FatReadVolumeSectors(FatDriveNumber, ClusterStartSector, FatVolumeBootSector->SectorsPerCluster, (PVOID)DISKREADBUFFER))
if (!FatReadVolumeSectors(FatDriveNumber, ClusterStartSector, FatVolumeBootSector->SectorsPerCluster, (PVOID)FILESYSBUFFER))
{
return FALSE;
}
memcpy(Buffer, (PVOID)DISKREADBUFFER, FatVolumeBootSector->SectorsPerCluster * FatVolumeBootSector->BytesPerSector);
memcpy(Buffer, (PVOID)FILESYSBUFFER, FatVolumeBootSector->SectorsPerCluster * FatVolumeBootSector->BytesPerSector);
return TRUE;
}
@ -1000,12 +1005,12 @@ BOOL FatReadClusterChain(ULONG StartClusterNumber, ULONG NumberOfClusters, PVOID
//
// Read cluster into memory
//
if (!FatReadVolumeSectors(FatDriveNumber, ClusterStartSector, FatVolumeBootSector->SectorsPerCluster, (PVOID)DISKREADBUFFER))
if (!FatReadVolumeSectors(FatDriveNumber, ClusterStartSector, FatVolumeBootSector->SectorsPerCluster, (PVOID)FILESYSBUFFER))
{
return FALSE;
}
memcpy(Buffer, (PVOID)DISKREADBUFFER, FatVolumeBootSector->SectorsPerCluster * FatVolumeBootSector->BytesPerSector);
memcpy(Buffer, (PVOID)FILESYSBUFFER, FatVolumeBootSector->SectorsPerCluster * FatVolumeBootSector->BytesPerSector);
//
// Decrement count of clusters left to read
@ -1051,12 +1056,12 @@ BOOL FatReadPartialCluster(ULONG ClusterNumber, ULONG StartingOffset, ULONG Leng
ClusterStartSector = ((ClusterNumber - 2) * FatVolumeBootSector->SectorsPerCluster) + DataSectorStart;
if (!FatReadVolumeSectors(FatDriveNumber, ClusterStartSector, FatVolumeBootSector->SectorsPerCluster, (PVOID)DISKREADBUFFER))
if (!FatReadVolumeSectors(FatDriveNumber, ClusterStartSector, FatVolumeBootSector->SectorsPerCluster, (PVOID)FILESYSBUFFER))
{
return FALSE;
}
memcpy(Buffer, (PVOID)(DISKREADBUFFER + StartingOffset), Length);
memcpy(Buffer, ((PVOID)FILESYSBUFFER + StartingOffset), Length);
return TRUE;
}

View file

@ -25,10 +25,10 @@ New memory layout:
0000:1000 - 0000:6FFF: Real mode stack area
0000:7000 - 0000:7FFF: Unused
0000:8000 - xxxx:xxxx: FreeLoader program & data area
xxxx:xxxx - 8000:FFFF: Random memory allocation heap
9000:0000 - 9000:7FFF: Disk read buffer for BIOS Int 13h
9000:8000 - 9000:8FFF: Screen save buffer passed in from boot sector
9000:9000 - 9000:FFFF: Protected mode stack area
xxxx:xxxx - 7000:7FFF: Random memory allocation heap
7000:8000 - 7000:FFFF: Protected mode stack area
8000:0000 - 8000:FFFF: File system read buffer
9000:0000 - 9000:FFFF: Disk read buffer for BIOS Int 13h
A000:0000 - FFFF:FFFF: reserved