From 631d55b60c234129f3c9d5f23b5cee9f60ebcf64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Sat, 26 Dec 2015 20:43:50 +0000 Subject: [PATCH] [BOOTSECTORS]: Sync the .asm files with their .S counterparts (make easier for diff'ing). svn path=/trunk/; revision=70431 --- reactos/boot/freeldr/bootsect/fat.S | 2 +- reactos/boot/freeldr/bootsect/fat.asm | 24 +++++++++++------------ reactos/boot/freeldr/bootsect/fat32.S | 2 +- reactos/boot/freeldr/bootsect/fat32.asm | 14 ++++++------- reactos/boot/freeldr/bootsect/isoboot.asm | 18 +++++++++-------- reactos/boot/freeldr/bootsect/isobtrt.asm | 20 ++++++++++--------- 6 files changed, 41 insertions(+), 39 deletions(-) diff --git a/reactos/boot/freeldr/bootsect/fat.S b/reactos/boot/freeldr/bootsect/fat.S index c589a20b86c..19049a0ca71 100644 --- a/reactos/boot/freeldr/bootsect/fat.S +++ b/reactos/boot/freeldr/bootsect/fat.S @@ -29,7 +29,7 @@ // of the PutChars function in the boot sector. // // When it locates freeldr.sys on the disk it will -// load the first sector of the file to 0000:8000 +// load the first sector of the file to 0000:F800 // With the help of this sector we should be able // to load the entire file off the disk, no matter // how fragmented it is. diff --git a/reactos/boot/freeldr/bootsect/fat.asm b/reactos/boot/freeldr/bootsect/fat.asm index 4cb4da64a02..33af1f53f30 100644 --- a/reactos/boot/freeldr/bootsect/fat.asm +++ b/reactos/boot/freeldr/bootsect/fat.asm @@ -29,7 +29,7 @@ ; of the PutChars function in the boot sector. ; ; When it locates freeldr.sys on the disk it will -; load the first sector of the file to 0000:8000 +; load the first sector of the file to 0000:F800 ; With the help of this sector we should be able ; to load the entire file off the disk, no matter ; how fragmented it is. @@ -187,12 +187,12 @@ SearchRootDirSector: FoundFreeLoader: ; We found freeldr.sys on the disk ; so we need to load the first 512 - ; bytes of it to 0000:8000 + ; bytes of it to 0000:F800 ; ES:DI has dir entry (ES:DI == 07E0:XXXX) mov ax,WORD [es:di+1ah] ; Get start cluster push ax ; Save start cluster - push WORD 800h ; Put 800h on the stack and load it - pop es ; Into ES so that we load the cluster at 0000:8000 + push WORD 0F80h ; FREELDR_BASE / 16 ; Put load segment on the stack and load it + pop es ; Into ES so that we load the cluster at 0000:F800 call ReadCluster ; Read the cluster pop ax ; Restore start cluster of FreeLoader @@ -204,16 +204,14 @@ FoundFreeLoader: ; Now AX has start cluster of FreeLoader and we ; have loaded the helper code in the first 512 bytes - ; of FreeLoader to 0000:8000. Now transfer control + ; of FreeLoader to 0000:F800. Now transfer control ; to the helper code. Skip the first three bytes ; because they contain a jump instruction to skip ; over the helper code in the FreeLoader image. - ;jmp 0000:9003h - push 0 ; push segment (0x0000) - mov bx, [0x8000 + 0xA8] ; load the RVA of the EntryPoint into eax - add bx, 0x8003 ; RVA -> VA and skip 3 bytes (jump to fathelper code) - push bx ; push offset - retf ; Transfer control to FreeLoader + ;ljmp16 0, FREELDR_BASE + 3 + db 0EAh + dw 0F803h + dw 0 @@ -225,8 +223,8 @@ ErrBoot: call PutChars ; Display it Reboot: - mov si,msgAnyKey ; Press any key message - call PutChars ; Display it + ; mov si,msgAnyKey ; Press any key message + ; call PutChars ; Display it xor ax,ax int 16h ; Wait for a keypress int 19h ; Reboot diff --git a/reactos/boot/freeldr/bootsect/fat32.S b/reactos/boot/freeldr/bootsect/fat32.S index 7fb91e21ccc..0002b7d65c3 100644 --- a/reactos/boot/freeldr/bootsect/fat32.S +++ b/reactos/boot/freeldr/bootsect/fat32.S @@ -400,7 +400,7 @@ LoadFile: cmp eax, HEX(0ffffff8) // Check to see if this is the last cluster in the chain jae LoadFileDone // If so continue, if not then read the next one push eax - xor bx, bx // Load ROSLDR starting at 0000:8000h + xor bx, bx // Load ROSLDR starting at 0000:F800h push es call ReadCluster pop es diff --git a/reactos/boot/freeldr/bootsect/fat32.asm b/reactos/boot/freeldr/bootsect/fat32.asm index 3f3ba02ac78..157dd8589b5 100644 --- a/reactos/boot/freeldr/bootsect/fat32.asm +++ b/reactos/boot/freeldr/bootsect/fat32.asm @@ -361,14 +361,14 @@ CheckEndCluster: jmp PrintFileSystemError ; If so exit with error InitializeLoadSegment: - mov bx,800h + mov bx,0F80h ; FREELDR_BASE / 16 mov es,bx LoadFile: cmp eax,0ffffff8h ; Check to see if this is the last cluster in the chain jae LoadFileDone ; If so continue, if not then read the next one push eax - xor bx,bx ; Load ROSLDR starting at 0000:8000h + xor bx,bx ; Load ROSLDR starting at 0000:F800h push es call ReadCluster pop es @@ -391,11 +391,11 @@ LoadFileDone: mov dl,[BYTE bp+BootDrive] ; Load boot drive into DL mov dh,[BootPartition] ; Load boot partition into DH - push 0 ; push segment (0x0000) - mov eax, [0x8000 + 0xA8] ; load the RVA of the EntryPoint into eax - add eax, 0x8000 ; RVA -> VA - push ax ; push offset - retf ; Transfer control to FreeLoader + ; Transfer execution to the bootloader + ;ljmp16 0, FREELDR_BASE + db 0EAh + dw 0F800h + dw 0 ; Returns the FAT entry for a given cluster number ; On entry EAX has cluster number diff --git a/reactos/boot/freeldr/bootsect/isoboot.asm b/reactos/boot/freeldr/bootsect/isoboot.asm index 28bf414557c..3258c22bec3 100644 --- a/reactos/boot/freeldr/bootsect/isoboot.asm +++ b/reactos/boot/freeldr/bootsect/isoboot.asm @@ -360,7 +360,10 @@ get_fs_structures: call crlf %endif - mov bx, 0x8000 ; bx = load address +; use high segment, as some bios can fail, when offset is too big + mov bx, 0x0F80 ; FREELDR_BASE / 16 ; es = load segment + mov es, bx + xor ebx, ebx ; bx = load offset mov si, di ; restore file pointer mov cx, 0xFFFF ; load the whole file call getfssec ; get the whole file @@ -373,13 +376,12 @@ get_fs_structures: mov dl, [DriveNo] ; dl = boot drive mov dh, 0 ; dh = boot partition - push 0 ; push segment (0x0000) - mov eax, [0x8000 + 0xA8] ; load the RVA of the EntryPoint into eax - add eax, 0x8000 ; RVA -> VA - push ax ; push offset - retf ; Transfer control to ROSLDR - + ; Transfer execution to the bootloader + ;ljmp16 0, FREELDR_BASE + db 0xEA + dw 0xF800 + dw 0 ; ; searchdir: @@ -944,7 +946,7 @@ findfail_msg: db 'Failed to find file!', 0 startldr_msg: db 'Starting SETUPLDR.SYS', 0 %endif -nosecsize_msg: db 'No sector size, assume 0800', CR, LF, 0 +; nosecsize_msg: db 'No sector size, assume 0800', CR, LF, 0 spec_err_msg: db 'Load spec failed, trying wing ...', CR, LF, 0 maybe_msg: db 'Found smth at drive = ', 0 alright_msg: db 'might be ok, continuing...', CR, LF, 0 diff --git a/reactos/boot/freeldr/bootsect/isobtrt.asm b/reactos/boot/freeldr/bootsect/isobtrt.asm index 31b96780607..45c0ea77c7f 100644 --- a/reactos/boot/freeldr/bootsect/isobtrt.asm +++ b/reactos/boot/freeldr/bootsect/isobtrt.asm @@ -332,7 +332,10 @@ get_fs_structures: call crlf %endif - mov bx, 0x8000 ; bx = load address +; use high segment, as some bios can fail, when offset is too big + mov bx, 0x0F80 ; FREELDR_BASE / 16 ; es = load segment + mov es, bx + xor ebx, ebx ; bx = load offset mov si, di ; restore file pointer mov cx, 0xFFFF ; load the whole file call getfssec ; get the whole file @@ -345,13 +348,12 @@ get_fs_structures: mov dl, [DriveNo] ; dl = boot drive mov dh, 0 ; dh = boot partition - push 0 ; push segment (0x0000) - mov eax, [0x8000 + 0xA8] ; load the RVA of the EntryPoint into eax - add eax, 0x8000 ; RVA -> VA - push ax ; push offset - retf ; Transfer control to ROSLDR - + ; Transfer execution to the bootloader + ;ljmp16 0, FREELDR_BASE + db 0xEA + dw 0xF800 + dw 0 ; ; searchdir: @@ -892,7 +894,7 @@ getchar: isolinux_banner db CR, LF, 'Loading IsoBoot...', CR, LF, 0 -copyright_str db ' Copyright (C) 1994-2002 H. Peter Anvin', CR, LF, 0 +copyright_str db ' (C) 1994-2002 H. Peter Anvin', CR, LF, 0 presskey_msg db 'Press any key to boot from CD', 0 dot_msg db '.',0 @@ -910,7 +912,7 @@ findfail_msg: db 'Failed to find file!', 0 startldr_msg: db 'Starting SETUPLDR.SYS', 0 %endif -nosecsize_msg: db 'Failed to get sector size, assuming 0800', CR, LF, 0 +; nosecsize_msg: db 'Failed to get sector size, assuming 0800', CR, LF, 0 spec_err_msg: db 'Loading spec packet failed, trying to wing it...', CR, LF, 0 maybe_msg: db 'Found something at drive = ', 0 alright_msg: db 'Looks like it might be right, continuing...', CR, LF, 0