vbr: bail out on disk read error

This commit is contained in:
Nero 2019-03-29 22:32:50 +00:00
parent f70242dfa2
commit cb3c977286

View File

@ -58,14 +58,12 @@ _startup:
mov ss, ax
xor sp, sp
call print_inline
db "VBR: Using", 0
mov [fdc.drv], dl ; backup drive number
.adjust_chs:
chs_bios:
mov ah, 0x08
int 0x13 ; required, QEMU detects 360kB as 1200kB with CHS 80 2 15
jc .noadjust ; skip if function does not exist
jc chs_print ; skip if function does not exist
inc dh
mov [fdc.nos], dh
mov ax, cx
@ -79,12 +77,11 @@ _startup:
mul word [fdc.nos] ; number of tracks = number of cylinders * heads
mul word [fdc.spt] ; number of sectors = number of tracks * sectors per track
mov [fdc.ts], ax
jmp chs_print
chs_print:
call print_inline
db " BIOS", 0
.noadjust:
call print_inline
db " CHS ", 0
db "CHS ", 0
mov ax, [fdc.ts]
div word [fdc.nos]
@ -112,12 +109,13 @@ _startup:
call loadrootdir
call dump
.end:
hlt
jmp .end
; Load root directory into memory
; in es data segment
; in es data segment
loadrootdir:
push bx
push cx
@ -142,16 +140,6 @@ loadrootdir:
pop bx
ret
; Load a cluster from cluster offset
; in ax cluster number
; es:bx buffer
loadcl:
mov ax, [fdc.sf]
mul byte [fdc.fn]
add ax, [fdc.rsc]
call print16
ret
; Load a single block into memory
; in ax sector number
; es:bx buffer
@ -173,12 +161,24 @@ loadblk:
mov dl, [fdc.drv] ; driver number
mov ax, 0x0201 ; ah=0x02 al=0x01
int 0x13
jc .error
pop dx
pop cx
pop ax
inc ax
add bx, 0x0200
ret
.error:
xor al, al
xchg al, ah
call print_inline
db "disk error ", 0
call print_number
call print_inline
db 0x0A, 0x0D, 0
.hlt:
hlt
jmp .hlt
print_number:
mov cx, 0x000A
@ -198,6 +198,7 @@ print_number:
print_inline:
pop si
push ax
push bx
.loop:
lodsb
@ -210,6 +211,7 @@ print_inline:
jmp .loop
.end:
pop bx
pop ax
push si
ret