From b75c10c9d8c7405ba2f89724b485154d5201c404 Mon Sep 17 00:00:00 2001 From: Michal Idziorek Date: Fri, 5 Sep 2014 02:36:33 +0200 Subject: working on bootloaders (lba) --- boot0/disk_load_16.asm | 44 ++++++++++++++++++++++++++++++++++++-------- boot0/mbr.asm | 28 ++++++++++++++++++++++++---- 2 files changed, 60 insertions(+), 12 deletions(-) (limited to 'boot0') diff --git a/boot0/disk_load_16.asm b/boot0/disk_load_16.asm index 55ad4aa..6762469 100644 --- a/boot0/disk_load_16.asm +++ b/boot0/disk_load_16.asm @@ -9,15 +9,15 @@ [bits 16] STR_LBA: - db "\nLBA Support Detected (no support yet)",0 + db "LBA Support Detected",0 -STR_CHS +STR_CHS: db "CHS Support Detected",0 -STR_ERROR +STR_ERROR: db "Disk Read Error",0 -STR_DONE +STR_DONE: db "Stage 2 Loaded",0 disk_load_16: @@ -31,14 +31,23 @@ disk_load_16: 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 + + mov dl,[BOOT_DRIVE] + xor ah,ah + mov ah,0x42 + + mov bx,0 + mov ds,bx + lea si,[lba_adr] + + int 0x13 + jnc disk_load_finish + jmp disk_load_error disk_load_chs: @@ -63,6 +72,12 @@ disk_load_chs: jnc disk_load_finish +disk_load_error: + + call print_nextline + mov bx, STR_ERROR + call print_string + call print_nextline jmp $ disk_load_finish: @@ -75,4 +90,17 @@ disk_load_finish: popa ret - + + +;; here we hold the lba addr +lba_adr: + + dw 0x10 ; size of packet ( 16 byte) + dw 16 ; number of sectors to read + + ; target is 0x7e00 + dw 0x7e00 ; target addr. offset + dw 0x0000 ; target addr. sector + + dd 1 ; first sector to read + dd 0 diff --git a/boot0/mbr.asm b/boot0/mbr.asm index d24bbfe..9f5a51d 100644 --- a/boot0/mbr.asm +++ b/boot0/mbr.asm @@ -11,11 +11,14 @@ jmp stage1 STR_1: - db "Starting Fool Loader Stage 1. v0.1",0 + 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 @@ -24,23 +27,40 @@ BOOT_DRIVE: stage1: + ;remember BOOT_DRIVE (as was set by BIOS) + mov [BOOT_DRIVE],dl + ;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 + call print_clear + call print_nextline + + ;pr message mov bx, STR_1 call print_string call print_nextline + ;show bootdrive + mov bx, STR_BOOT + call print_string + + mov al,[BOOT_DRIVE] + call print_hex_byte + call print_nextline + + call disk_load_16 ; loads stage 2 + ;entering stage2 message mov bx, STR_2 call print_string call print_nextline + + call print_nextline + mov dl,[BOOT_DRIVE] jmp 0x7e00 ; jump to next sector where we put stage 2 ;fill partition table (4x16byte) with zeroes. -- cgit v1.2.3