Author: tkreuzer
Date: Tue Sep 11 11:45:47 2012
New Revision: 57274
URL:
http://svn.reactos.org/svn/reactos?rev=57274&view=rev
Log:
[FREELDR]
- Remove the FILESYSBUFFER from the memory layout, grow the DISKREADBUFFER to 64 KB
- Make use of the full disk buffer when reading sectors, speeds up hdd boot process by
about a factor of 2, patch by Carlo Bramini
- See CORE-6071
Modified:
trunk/reactos/boot/freeldr/freeldr/arch/i386/hwdisk.c
trunk/reactos/boot/freeldr/freeldr/arch/i386/pcmem.c
trunk/reactos/boot/freeldr/freeldr/include/arch/pc/x86common.h
Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/hwdisk.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/i386/hwdisk.c [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/arch/i386/hwdisk.c [iso-8859-1] Tue Sep 11 11:45:47
2012
@@ -113,32 +113,47 @@
static LONG DiskRead(ULONG FileId, VOID* Buffer, ULONG N, ULONG* Count)
{
DISKCONTEXT* Context = FsGetDeviceSpecific(FileId);
- UCHAR* Ptr = (UCHAR*)Buffer;
- ULONG i, Length;
- BOOLEAN ret;
-
- *Count = 0;
- i = 0;
- while (N > 0)
- {
- Length = N;
- if (Length > Context->SectorSize)
- Length = Context->SectorSize;
+ UCHAR * Ptr = (UCHAR*)Buffer;
+ ULONG Length, TotalSectors, MaxSectors, ReadSectors;
+ BOOLEAN ret;
+ ULONGLONG SectorOffset;
+
+ TotalSectors = (N + Context->SectorSize - 1) / Context->SectorSize;
+ MaxSectors = DISKREADBUFFER_SIZE / Context->SectorSize;
+ SectorOffset = Context->SectorNumber + Context->SectorOffset;
+
+ ret = 0;
+
+ while (TotalSectors)
+ {
+ ReadSectors = TotalSectors;
+ if (ReadSectors > MaxSectors)
+ ReadSectors = MaxSectors;
+
ret = MachDiskReadLogicalSectors(
Context->DriveNumber,
- Context->SectorNumber + Context->SectorOffset + i,
- 1,
+ SectorOffset,
+ ReadSectors,
(PVOID)DISKREADBUFFER);
if (!ret)
- return EIO;
+ break;
+
+ Length = ReadSectors * Context->SectorSize;
+ if (Length > N)
+ Length = N;
+
RtlCopyMemory(Ptr, (PVOID)DISKREADBUFFER, Length);
+
Ptr += Length;
- *Count += Length;
- N -= Length;
- i++;
- }
-
- return ESUCCESS;
+ N -= Length;
+
+ SectorOffset += ReadSectors;
+ TotalSectors -= ReadSectors;
+ }
+
+ *Count = Ptr - (UCHAR *)Buffer;
+
+ return (!ret) ? EIO : ESUCCESS;
}
static LONG DiskSeek(ULONG FileId, LARGE_INTEGER* Position, SEEKMODE SeekMode)
Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/pcmem.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/i386/pcmem.c [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/arch/i386/pcmem.c [iso-8859-1] Tue Sep 11 11:45:47
2012
@@ -29,15 +29,13 @@
#define MAX_BIOS_DESCRIPTORS 32
#define FREELDR_BASE_PAGE (FREELDR_BASE / PAGE_SIZE)
-#define FILEBUF_BASE_PAGE (FILESYSBUFFER / PAGE_SIZE)
#define DISKBUF_BASE_PAGE (DISKREADBUFFER / PAGE_SIZE)
-#define STACK_BASE_PAGE (DISKBUF_BASE_PAGE + 1)
+#define STACK_BASE_PAGE (STACKLOWLIMIT / PAGE_SIZE)
#define STACK_END_PAGE (STACK32ADDR / PAGE_SIZE)
#define BIOSBUF_BASE_PAGE (BIOSCALLBUFFER / PAGE_SIZE)
-#define FREELDR_PAGE_COUNT (FILEBUF_BASE_PAGE - FREELDR_BASE_PAGE)
-#define FILEBUF_PAGE_COUNT (DISKBUF_BASE_PAGE - FILEBUF_BASE_PAGE)
-#define DISKBUF_PAGE_COUNT (1)
+#define FREELDR_PAGE_COUNT (DISKBUF_BASE_PAGE - FREELDR_BASE_PAGE)
+#define DISKBUF_PAGE_COUNT (STACK_BASE_PAGE - DISKBUF_BASE_PAGE)
#define STACK_PAGE_COUNT (STACK_END_PAGE - STACK_BASE_PAGE)
#define BIOSBUF_PAGE_COUNT (1)
@@ -49,7 +47,6 @@
{ LoaderFirmwarePermanent, 0x00, 1 }, // realmode int vectors
{ LoaderFirmwareTemporary, 0x01, FREELDR_BASE_PAGE - 1 }, // freeldr stack
+ cmdline
{ LoaderLoadedProgram, FREELDR_BASE_PAGE, FREELDR_PAGE_COUNT }, // freeldr image
- { LoaderFirmwareTemporary, FILEBUF_BASE_PAGE, FILEBUF_PAGE_COUNT }, // File system read
buffer. FILESYSBUFFER
{ LoaderFirmwareTemporary, DISKBUF_BASE_PAGE, DISKBUF_PAGE_COUNT }, // Disk read buffer
for int 13h. DISKREADBUFFER
{ LoaderOsloaderStack, STACK_BASE_PAGE, STACK_PAGE_COUNT }, // prot mode stack.
{ LoaderFirmwareTemporary, BIOSBUF_BASE_PAGE, BIOSBUF_PAGE_COUNT }, // BIOSCALLBUFFER
Modified: trunk/reactos/boot/freeldr/freeldr/include/arch/pc/x86common.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/inclu…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/include/arch/pc/x86common.h [iso-8859-1]
(original)
+++ trunk/reactos/boot/freeldr/freeldr/include/arch/pc/x86common.h [iso-8859-1] Tue Sep 11
11:45:47 2012
@@ -13,12 +13,12 @@
#define BSS_START HEX(6F00)
#define FREELDR_BASE HEX(F800)
#define FREELDR_PE_BASE HEX(10000)
-#define FILESYSBUFFER HEX(80000) /* Buffer to store file system data (e.g. cluster
buffer for FAT) */
-#define DISKREADBUFFER HEX(90000) /* Buffer to store data read in from the disk via
the BIOS */
+#define DISKREADBUFFER HEX(80000) /* Buffer to store data read in from the disk via
the BIOS */
+#define STACKLOWLIMIT HEX(90000)
#define STACK32ADDR HEX(98000) /* The 32-bit stack top will be at 9000:8000, or
0xA8000 */
#define STACK64ADDR HEX(98000) /* The 64-bit stack top will be at 98000 */
#define BIOSCALLBUFFER HEX(98000) /* Buffer to store temporary data for any Int386()
call */
-#define DISKREADBUFFER_SIZE 512
+#define DISKREADBUFFER_SIZE HEX(10000)
#define BIOSCALLBUFSEGMENT (BIOSCALLBUFFER/16) /* Buffer to store temporary data for any
Int386() call */
#define BIOSCALLBUFOFFSET HEX(0000) /* Buffer to store temporary data for any Int386()
call */