diff options
Diffstat (limited to 'boot0')
| -rw-r--r-- | boot0/disk_load_16.asm | 6 | ||||
| -rw-r--r-- | boot0/mbr.asm | 96 |
2 files changed, 65 insertions, 37 deletions
diff --git a/boot0/disk_load_16.asm b/boot0/disk_load_16.asm index c536c56..0d605db 100644 --- a/boot0/disk_load_16.asm +++ b/boot0/disk_load_16.asm @@ -1,18 +1,14 @@ -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;;;;; Miguel's FoolOS Helper Functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ;disk_load_16 ; - [bits 16] STR_LBA: db "LBA Support Detected",0 STR_CHS: - db "CHS is BROKEN SORRY!!",0 + db "CHS is probably BROKEN SORRY!!",0 STR_ERROR: db "Disk Read Error",0 diff --git a/boot0/mbr.asm b/boot0/mbr.asm index 9f5a51d..1673c0c 100644 --- a/boot0/mbr.asm +++ b/boot0/mbr.asm @@ -1,49 +1,69 @@ -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; -; stage 1 +; FOOL-OS Master Boot Record ; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; +; This is the Master Boot Record for x86 +; +; We are limited to 512 bytes (one sector) +; minus 64 bytes for the partition table +; minus 2 bytes formagic number (0xaa55) +; +; all we do here is : +; +; 1. Put the Stack at 0x07bff (it is counting down) +; 2. Remeber Boot Drive at [BOOT_DRIVE] +; 3. Print PR message and Boot Drive number +; 4. Load Second Stage Bootloader from Boot Drive at next sector +; 5. Show Info Message after successfull loading +; 6. Jump to 2nd Stage Boot Loader +; +; Refer to a memory map as needed: +; http://wiki.osdev.org/Memory_Map_(x86) +; Everything here is 16bit [bits 16] +; Per definition this will be loaded by the BIOS at 0x7c00 [org 0x7c00] +; skip constants and includes jmp stage1 -STR_1: - db "Fool Loader Stage 1. v0.1",0 - -STR_2: - db "Starting Stage 2",0 - -STR_BOOT: - db "boot drive: ",0 +; string constants (null terminated) +STR_1: db "Fool Loader Stage 1. v0.1",0 +STR_2: db "Starting Stage 2",0 +STR_BOOT: db "Boot drive: ",0 -BOOT_DRIVE: - db 0xff ; remember the bootdrive here +; some space (one byte) to remember the Boot Drive +BOOT_DRIVE: db 0xff +; include print and disk load routines %include "boot/print_string_16.asm" %include "boot0/disk_load_16.asm" +; Here we start! stage1: - ;remember BOOT_DRIVE (as was set by BIOS) - mov [BOOT_DRIVE],dl - - ;first of allsetup the stack (Right under mbr) - ;guaranteed ~30KB space + ; first of all, setup the stack (right under our MBR) + ; ~30KB space guaranteed mov bp,0x07bff mov sp,bp + ; remember BOOT_DRIVE (as was set by BIOS in dl) + mov [BOOT_DRIVE],dl + + ; clear screen and print PR message call print_clear call print_nextline - - ;pr message + mov bx, STR_1 call print_string call print_nextline - ;show bootdrive + + ; print bootdrive number mov bx, STR_BOOT call print_string @@ -52,23 +72,35 @@ stage1: call print_nextline - call disk_load_16 ; loads stage 2 + ; Actually Load the Second Stage Bootloader! + call disk_load_16 + - ;entering stage2 message + ; show info message that 2nd Stage was loaded mov bx, STR_2 call print_string call print_nextline - call print_nextline + + + ; save Boot Drive in dl for second stage mov dl,[BOOT_DRIVE] - jmp 0x7e00 ; jump to next sector where we put stage 2 -;fill partition table (4x16byte) with zeroes. -;(otherwise my Acer Aspire will not boot) -times 64 db 0x0 -;so we get identified as MBR -times 510-($-$$) db 0x0 -;dw 0x0 -dw 0xaa55 + ; jump to the next sector where we loaded the 2nd stage + jmp 0x7e00 + + + ; nothing essential under this line + ; we need this to follow some mbr standards + + ; fill at least 4x16byte with zeroes. (partition table) + ; (otherwise my Acer Aspire will not boot) + times 64 db 0x0 + + ; fill rest with zeroes + times 510-($-$$) db 0x0 + + ; magic number so we get identified as MBR + dw 0xaa55 |
