From 9c62b2152a4e7d3bf22c903ee76a06163c7088d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= Date: Sun, 18 Oct 2009 18:24:35 +0000 Subject: [PATCH] [freeldr/i386] Read up to 128 sectors at once svn path=/trunk/; revision=43565 --- reactos/boot/freeldr/freeldr/arch/i386/hardware.c | 11 ++++++----- reactos/boot/freeldr/freeldr/arch/i386/xboxhw.c | 11 ++++++----- reactos/boot/freeldr/freeldr/include/arch.h | 1 + 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/reactos/boot/freeldr/freeldr/arch/i386/hardware.c b/reactos/boot/freeldr/freeldr/arch/i386/hardware.c index 007ed197320..6022e782b74 100644 --- a/reactos/boot/freeldr/freeldr/arch/i386/hardware.c +++ b/reactos/boot/freeldr/freeldr/arch/i386/hardware.c @@ -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; diff --git a/reactos/boot/freeldr/freeldr/arch/i386/xboxhw.c b/reactos/boot/freeldr/freeldr/arch/i386/xboxhw.c index 58a6542104b..96b91f4aa96 100644 --- a/reactos/boot/freeldr/freeldr/arch/i386/xboxhw.c +++ b/reactos/boot/freeldr/freeldr/arch/i386/xboxhw.c @@ -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; diff --git a/reactos/boot/freeldr/freeldr/include/arch.h b/reactos/boot/freeldr/freeldr/include/arch.h index 9a4f3575c7f..a10055856ef 100644 --- a/reactos/boot/freeldr/freeldr/include/arch.h +++ b/reactos/boot/freeldr/freeldr/include/arch.h @@ -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