kernel: fall back to defaults if int 13h/ah=8 spews bogus data

This commit is contained in:
Nero 2020-08-22 23:36:25 +00:00
parent ff3a59c71e
commit 3b39572043

View File

@ -18,7 +18,8 @@ drive_table: resb (drives * drive_size)
section .text section .text
drives_init: int 0x11 drives_init: ; CX = number of floppy drives in the system
int 0x11
mov cl, 6 mov cl, 6
shr ax, cl shr ax, cl
inc ax inc ax
@ -31,16 +32,20 @@ drives_init: int 0x11
.loop: push cx .loop: push cx
push dx push dx
mov [bx+drive.biosnum], dl mov [bx+drive.biosnum], dl
; defaults if 13h,AH=8 fails (XT 360kb) ; query bios for floppy format
les di, [0x1e * 4]
mov cx, 0x2709 ; 40 cylinders, 9 sectors
mov dh, 1 ; 2 heads
; ask bios
push bx
mov ah, 8 mov ah, 8
push bx
int 0x13 int 0x13
pop bx pop bx
; copy dpt ; set up defaults if invalid data or fail
jc .defs
test cx, cx
jnz .load
.defs: ; use defaults: 360k, 40 cyl, 9 sects
les di, [0x1e * 4]
mov cx, 0x270
mov dh, 1
.load: ; copy dpt
push es push es
push ds push ds
pop es pop es