X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=kern%2Fsrc%2Fboot.asm;h=25486e63f4fbdd8a386d8508cbaf4a4b623aafe0;hb=refs%2Fheads%2Fmaster;hp=96506de177878426b08c7da880baebfe4cde1719;hpb=426ed1c5006c82261fee2eea3feafe3282b2b862;p=eightysix diff --git a/kern/src/boot.asm b/kern/src/boot.asm index 96506de..25486e6 100644 --- a/kern/src/boot.asm +++ b/kern/src/boot.asm @@ -3,18 +3,19 @@ bits 16 section .bootsect -extern _stage2_start_seg -extern _stage2_size +extern _bootsect_start +extern _kern_start_seg +extern _kern_size -boot_driveno equ 7b00h -num_read_tries equ 7b06h ; 2 bytes -sect_pending equ 7b08h ; 2 bytes -sect_per_track equ 7b0ah ; 2 bytes -cur_head equ 7b0ch ; 2 bytes - current head -start_sect equ 7b0eh ; 2 bytes - start sector in track -destptr equ 7b10h ; 2 bytes - destination pointer -num_heads equ 7b12h ; 2 bytes - number of heads -cur_cyl equ 7b14h ; 2 bytes - current cylinder +boot_driveno equ 0500h +num_read_tries equ 0506h ; 2 bytes +sect_pending equ 0508h ; 2 bytes +sect_per_track equ 050ah ; 2 bytes +cur_head equ 050ch ; 2 bytes - current head +start_sect equ 050eh ; 2 bytes - start sector in track +destptr equ 0510h ; 2 bytes - destination pointer +num_heads equ 0512h ; 2 bytes - number of heads +cur_cyl equ 0514h ; 2 bytes - current cylinder %macro floppy_motor_off 0 pushf @@ -57,7 +58,7 @@ bios_param_block: db 0 ; 25h: winnt flags db 28h ; 26h: signature(?) dd 0 ; 27h: volume serial number - db "80 SIX BOOT"; 2bh: volume label, 11 bytes + db "86BOOT "; 2bh: volume label, 11 bytes db "FAT12 " ; 36h: filesystem id, 8 bytes start: @@ -65,13 +66,18 @@ start: xor ax, ax mov ds, ax mov es, ax + mov ss, ax + mov [boot_driveno], dl ; save boot drive number + + ; relocate boot sector to 600h + mov si, 0x7c00 + mov di, _bootsect_start + mov cx, 256 + rep movsw + jmp 00:.setcs .setcs: - ; put the stack high - mov ax, 0x7f00 - mov ss, ax - xor sp, sp - mov [boot_driveno], dl + mov sp, _bootsect_start ; temp stack below our relocated address ; query sectors per track mov ah, 8 ; get drive parameters call, dl already has the drive @@ -92,13 +98,13 @@ start: .querydone: ; load the rest of the code high - mov ax, _stage2_size + mov ax, _kern_size add ax, 511 mov cl, 9 shr ax, cl inc ax mov [sect_pending], ax - mov ax, _stage2_start_seg + mov ax, _kern_start_seg mov es, ax ; destination segment mov word [destptr], 0 mov word [start_sect], 1 ; start from sector 1 to skip boot sector @@ -173,7 +179,7 @@ start: jnz .rdloop ; loaded sucessfully, load segment registers and jump -.done: mov ax, _stage2_start_seg +.done: mov ax, _kern_start_seg mov ds, ax mov es, ax push ax @@ -248,7 +254,7 @@ print_hex_digit: str_rdtrack2 db " from ",0 str_rdtrack3 db "/",0 -str_load_fail db "Failed to load 2nd stage!",0 +str_load_fail db "Failed to load kernel!",0 str_newline db 13,10,0 times 510-($-$$) db 0