[freeldr/i386] Read up to 128 sectors at once

svn path=/trunk/; revision=43565
This commit is contained in:
Hervé Poussineau 2009-10-18 18:24:35 +00:00
parent 125296305f
commit 9c62b2152a
3 changed files with 13 additions and 10 deletions

View file

@ -467,7 +467,7 @@ static LONG DiskRead(ULONG FileId, VOID* Buffer, ULONG N, ULONG* Count)
{
DISKCONTEXT* Context = FsGetDeviceSpecific(FileId);
UCHAR* Ptr = (UCHAR*)Buffer;
ULONG i, Length;
ULONG i, Length, Sectors;
BOOLEAN ret;
*Count = 0;
@ -475,12 +475,13 @@ static LONG DiskRead(ULONG FileId, VOID* Buffer, ULONG N, ULONG* Count)
while (N > 0)
{
Length = N;
if (Length > Context->SectorSize)
Length = Context->SectorSize;
if (Length > DISKREADBUFFER_SIZE)
Length = DISKREADBUFFER_SIZE;
Sectors = (Length + Context->SectorSize - 1) / Context->SectorSize;
ret = MachDiskReadLogicalSectors(
Context->DriveNumber,
Context->SectorNumber + Context->SectorOffset + i,
1,
Sectors,
(PVOID)DISKREADBUFFER);
if (!ret)
return EIO;
@ -488,7 +489,7 @@ static LONG DiskRead(ULONG FileId, VOID* Buffer, ULONG N, ULONG* Count)
Ptr += Length;
*Count += Length;
N -= Length;
i++;
i += Sectors;
}
return ESUCCESS;

View file

@ -168,7 +168,7 @@ static LONG DiskRead(ULONG FileId, VOID* Buffer, ULONG N, ULONG* Count)
{
DISKCONTEXT* Context = FsGetDeviceSpecific(FileId);
UCHAR* Ptr = (UCHAR*)Buffer;
ULONG i, Length;
ULONG i, Length, Sectors;
BOOLEAN ret;
*Count = 0;
@ -176,12 +176,13 @@ static LONG DiskRead(ULONG FileId, VOID* Buffer, ULONG N, ULONG* Count)
while (N > 0)
{
Length = N;
if (Length > Context->SectorSize)
Length = Context->SectorSize;
if (Length > DISKREADBUFFER_SIZE)
Length = DISKREADBUFFER_SIZE;
Sectors = (Length + Context->SectorSize - 1) / Context->SectorSize;
ret = MachDiskReadLogicalSectors(
Context->DriveNumber,
Context->SectorNumber + Context->SectorOffset + i,
1,
Sectors,
(PVOID)DISKREADBUFFER);
if (!ret)
return EIO;
@ -189,7 +190,7 @@ static LONG DiskRead(ULONG FileId, VOID* Buffer, ULONG N, ULONG* Count)
Ptr += Length;
*Count += Length;
N -= Length;
i++;
i += Sectors;
}
return ESUCCESS;

View file

@ -46,6 +46,7 @@
#define BIOSCALLBUFOFFSET 0x0000 /* Buffer to store temporary data for any Int386() call */
#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 */
#define DISKREADBUFFER_SIZE 0x10000
#elif defined(_M_PPC) || defined(_M_MIPS) || defined(_M_ARM)
#define DISKREADBUFFER 0x80000000
#define FILESYSBUFFER 0x80000000