From 273b6dd69f6c59f78d7b0786ebc504ec76702b39 Mon Sep 17 00:00:00 2001 From: Brian Palmer Date: Tue, 15 Apr 2003 22:48:06 +0000 Subject: [PATCH] Fixed the EXT2/3 boot sector code so that it only uses the boot drive in the boot sector if it exists (i.e. not 0xff) Otherwise it uses the boot drive passed in the DL register. Updated the EXT2/3 installer to reflect the changes in the boot sector code for EXT2/3. svn path=/trunk/; revision=4540 --- freeldr/bootsect/ext2.asm | 20 ++++++++++++++------ freeldr/install/linux/finstext2.c | 4 ++-- freeldr/install/linux/finstext2.h | 8 +++++++- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/freeldr/bootsect/ext2.asm b/freeldr/bootsect/ext2.asm index 45ed471e7be..51c7a4d0dc2 100644 --- a/freeldr/bootsect/ext2.asm +++ b/freeldr/bootsect/ext2.asm @@ -1,6 +1,6 @@ ; EXT2.ASM ; EXT2 Boot Sector -; Copyright (c) 2002 Brian Palmer +; Copyright (c) 2002, 2003 Brian Palmer ; [bp-0x04] Here we will store the number of sectors per track ; [bp-0x08] Here we will store the number of heads @@ -62,8 +62,14 @@ main: mov sp,7b00h ; Setup a stack + cmp BYTE [BYTE bp+BootDrive],BYTE 0xff ; If they have specified a boot drive then use it + jne GetDriveParameters + + mov [BYTE bp+BootDrive],dl ; Save the boot drive + + GetDriveParameters: - mov ax,0800h + mov ah,08h mov dl,[BYTE bp+BootDrive] ; Get boot drive in dl int 13h ; Request drive parameters from the bios jnc CalcDriveSize ; If the call succeeded then calculate the drive size @@ -334,7 +340,9 @@ Done: msgDiskError db 'Disk error',0 -msgAnyKey db 'Press any key to restart',0 +; Sorry, need the space... +;msgAnyKey db 'Press any key to restart',0 +msgAnyKey db 'Press any key',0 times 509-($-$$) db 0 ; Pad to 509 bytes @@ -628,19 +636,19 @@ Ext2ReadDirectBlocksLoop: ; And reboots PrintFileNotFound: mov si,msgFreeLdr ; FreeLdr not found message - jmp short DisplayAndRebootIt + jmp short DisplayItAndReboot ; Displays a file size is 0 error ; And reboots PrintFileSizeError: mov si,msgFileSize ; Error message - jmp short DisplayAndRebootIt + jmp short DisplayItAndReboot ; Displays a file is not a regular file error ; And reboots PrintRegFileError: mov si,msgRegFile ; Error message -DisplayAndRebootIt: +DisplayItAndReboot: call PutChars ; Display it jmp Reboot diff --git a/freeldr/install/linux/finstext2.c b/freeldr/install/linux/finstext2.c index 891439f4870..2b4d39b8541 100644 --- a/freeldr/install/linux/finstext2.c +++ b/freeldr/install/linux/finstext2.c @@ -111,8 +111,8 @@ int main(int argc, char *argv[]) printf("Cylinders: %d\n", Ext2DriveGeometry.cylinders); printf("Start: %d\n", Ext2DriveGeometry.start); - Ext2BootCode->BootDrive = 0x80; - Ext2BootCode->BootPartition = 0x05; + Ext2BootCode->BootDrive = 0xff; + Ext2BootCode->BootPartition = 0x00; //Ext2BootCode->SectorsPerTrack = Ext2DriveGeometry.sectors; //Ext2BootCode->NumberOfHeads = Ext2DriveGeometry.heads; Ext2BootCode->Ext2VolumeStartSector = Ext2DriveGeometry.start; diff --git a/freeldr/install/linux/finstext2.h b/freeldr/install/linux/finstext2.h index e6b6bf9f966..763ff6a38cf 100644 --- a/freeldr/install/linux/finstext2.h +++ b/freeldr/install/linux/finstext2.h @@ -8,7 +8,7 @@ typedef struct { unsigned char JmpBoot[3]; unsigned char BootDrive; - unsigned char BootPartition; + //unsigned char BootPartition; //unsigned char SectorsPerTrack; //unsigned short NumberOfHeads; //unsigned long Reserved1; @@ -22,6 +22,12 @@ typedef struct unsigned long Ext2FirstDataBlock; // First data block (1 for 1024-byte blocks, 0 for bigger sizes) unsigned long Ext2InodesPerGroup; // Number of inodes per group unsigned long Ext2InodesPerBlock; // Number of inodes per block + + unsigned char BootCodeAndData[459]; + + unsigned char BootPartition; + unsigned short BootSignature; + } PACKED EXT2_BOOTCODE, *PEXT2_BOOTCODE;