diff options
Diffstat (limited to 'boot0')
| -rw-r--r-- | boot0/disk_load_16.asm | 78 | ||||
| -rw-r--r-- | boot0/mbr.asm | 54 |
2 files changed, 132 insertions, 0 deletions
diff --git a/boot0/disk_load_16.asm b/boot0/disk_load_16.asm new file mode 100644 index 0000000..55ad4aa --- /dev/null +++ b/boot0/disk_load_16.asm @@ -0,0 +1,78 @@ +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;; Miguel's FoolOS Helper Functions ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; +;disk_load_16 +; + + +[bits 16] + +STR_LBA: + db "\nLBA Support Detected (no support yet)",0 + +STR_CHS + db "CHS Support Detected",0 + +STR_ERROR + db "Disk Read Error",0 + +STR_DONE + db "Stage 2 Loaded",0 + +disk_load_16: + + pusha + + ; check if LBA is supported + mov ah,0x41 + mov bx,0x55aa + int 0x13 + jnc disk_load_lba + jmp disk_load_chs + + +disk_load_lba: + + mov bx, STR_LBA + call print_string + call print_nextline + jmp $ + jmp disk_load_finish + +disk_load_chs: + + mov bx, STR_CHS + call print_string + call print_nextline + + mov bx,0 ;target es:bx + mov es,bx + mov bx,0x7e00 + + mov al,50 ;number of sectors to read + mov ah,0x02 ;BIOS read sector func + + mov cl,2 ; sector + mov ch,0 ; cylinder + + mov dl,[BOOT_DRIVE] + mov dh,0 ;head + + int 0x13 ;bios interrupt + + jnc disk_load_finish + + jmp $ + +disk_load_finish: + + call print_nextline + mov bx, STR_DONE + call print_string + call print_nextline + + + popa + ret + diff --git a/boot0/mbr.asm b/boot0/mbr.asm new file mode 100644 index 0000000..d24bbfe --- /dev/null +++ b/boot0/mbr.asm @@ -0,0 +1,54 @@ +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; +; stage 1 +; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +[bits 16] + +[org 0x7c00] + +jmp stage1 + +STR_1: + db "Starting Fool Loader Stage 1. v0.1",0 + +STR_2: + db "Starting Stage 2",0 + +BOOT_DRIVE: + db 0xff ; remember the bootdrive here + +%include "boot/print_string_16.asm" +%include "boot0/disk_load_16.asm" + +stage1: + + ;first of allsetup the stack (Right under mbr) + ;guaranteed ~30KB space + mov bp,0x07bff + mov sp,bp + + ;remember BOOT_DRIVE (as was set by BIOS) + mov [BOOT_DRIVE],dl + + mov bx, STR_1 + call print_string + call print_nextline + + call disk_load_16 ; loads stage 2 + + mov bx, STR_2 + call print_string + call print_nextline + 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 + |
