Finish up the remaining TODOs in bootsect.asm
This commit is contained in:
parent
8d67cdf201
commit
de098cb9f3
61
bootsect.asm
61
bootsect.asm
|
@ -121,8 +121,15 @@ search_root:
|
|||
je .end
|
||||
|
||||
test byte [si + 11], 0x08 + 0x10
|
||||
jz .isfile
|
||||
jnz .skipentry
|
||||
|
||||
; Make sure the file has non-zero size
|
||||
cmp word [si + 28], 0
|
||||
jne .isfile
|
||||
cmp word [si + 30], 0
|
||||
jne .isfile
|
||||
|
||||
.skipentry:
|
||||
add si, 32
|
||||
jmp .entry
|
||||
|
||||
|
@ -154,18 +161,12 @@ search_root:
|
|||
.end:
|
||||
|
||||
notfound:
|
||||
; TODO: Better error messages
|
||||
mov ax, 0x0e00 + '?'
|
||||
int 0x10
|
||||
|
||||
hang:
|
||||
hlt
|
||||
jmp hang
|
||||
mov si, notfound_msg
|
||||
jmp fatal_error
|
||||
|
||||
found:
|
||||
; SI points to 11 bytes after the start of the entry, so adjust all
|
||||
; offsets
|
||||
; TODO: Handle zero-length files
|
||||
mov ax, [si - 11 + 26] ; First cluster
|
||||
push ax
|
||||
|
||||
|
@ -248,8 +249,13 @@ loadsectors:
|
|||
push ax
|
||||
push cx
|
||||
push dx
|
||||
push di
|
||||
|
||||
.loop:
|
||||
mov di, 3 ; Retry thrice
|
||||
|
||||
.retry:
|
||||
|
||||
push ax
|
||||
push cx
|
||||
|
||||
|
@ -286,9 +292,9 @@ loadsectors:
|
|||
mov al, 1
|
||||
mov dl, [drivenumber]
|
||||
int 0x13
|
||||
|
||||
; TODO: Handle reset & retry
|
||||
jnc .noerror
|
||||
.noerror:
|
||||
jc .error
|
||||
|
||||
pop cx
|
||||
pop ax
|
||||
|
@ -298,15 +304,46 @@ loadsectors:
|
|||
|
||||
loop .loop
|
||||
|
||||
pop di
|
||||
pop dx
|
||||
pop cx
|
||||
pop ax
|
||||
ret
|
||||
|
||||
%include "hexprint.inc"
|
||||
.error:
|
||||
; Do we still have retries remaining?
|
||||
mov si, diskerror_msg
|
||||
test di, di
|
||||
jz fatal_error ; No, fail
|
||||
dec di
|
||||
|
||||
; Yes, reset disk
|
||||
xor ah, ah
|
||||
int 0x13
|
||||
|
||||
; Execute the loop again
|
||||
pop cx
|
||||
pop ax
|
||||
jmp .retry
|
||||
|
||||
fatal_error:
|
||||
lodsb
|
||||
test al, al
|
||||
jz hang
|
||||
mov ah, 0xe
|
||||
int 0x10
|
||||
jmp fatal_error
|
||||
|
||||
hang:
|
||||
hlt
|
||||
jmp hang
|
||||
|
||||
|
||||
kernel_name: db "KERNEL BIN"
|
||||
|
||||
notfound_msg: db "Kernel not found", 0
|
||||
diskerror_msg: db "Disk error", 0
|
||||
|
||||
times 510-($-$$) db 0
|
||||
db 0x55, 0xaa
|
||||
_end:
|
||||
|
|
Loading…
Reference in New Issue