diff --git a/bootloader/boot.asm b/bootloader/boot.asm index 389dee964450fc77f3c0de68f60c4107678a3b12..ae7b8223b38a1bed2534c145648b81733db77227 100644 --- a/bootloader/boot.asm +++ b/bootloader/boot.asm @@ -2,8 +2,31 @@ [org 0x7c00] mov [_boot_drive_id], dl + ; Load the kernel image from boot disk, disk offset 512B to 64KB. + KERN_ADDR equ 0x7e00 + mov ah, 0x02 + mov dl, [_boot_drive_id] + mov ch, 0 + mov dh, 0 + mov cl, 2 ; from the second one, + mov al, 127 ; read 127 sectors in total. + mov bx, KERN_ADDR + int 0x13 ; Set carry on error, and set AL to sectors that actual read. + + jc disk_io_error + mov dl, 0x7f + cmp dl, al + jne disk_io_error + ; kernel successfully loaded now! + mov bx, _motd_kern_ok + call println_bios + jmp _init_prot_mode +%include "./str.16.inc" + + + gdt_begin: gdt_entry_0: @@ -63,25 +86,6 @@ _prot_begin: call println_vga - ; Load the kernel image from boot disk, disk offset 512B to 64KB. - KERN_ADDR equ 0x7e00 - mov ah, 0x02 - mov ch, 0 - mov dh, 0 - mov cl, 2 ; from the second one, - mov al, 127 ; read 127 sectors in total. - mov bx, KERN_ADDR - int 0x13 ; Set carry on error, and set AL to sectors that actual read. - jmp _stall - - jc disk_io_error - mov dl, 0x7f - cmp dl, al - jne disk_io_error - ; kernel successfully loaded now! - mov ebx, _motd_kern_ok - call println_vga - _stall: jmp $