From 3b395720437954b8aea8466d2fb4e9c695aa3882 Mon Sep 17 00:00:00 2001 From: Nero <41307858+nero@users.noreply.github.com> Date: Sat, 22 Aug 2020 23:36:25 +0000 Subject: [PATCH] kernel: fall back to defaults if int 13h/ah=8 spews bogus data --- kernel/drive.asm | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/kernel/drive.asm b/kernel/drive.asm index d7beb84..72742e0 100644 --- a/kernel/drive.asm +++ b/kernel/drive.asm @@ -18,7 +18,8 @@ drive_table: resb (drives * drive_size) section .text -drives_init: int 0x11 +drives_init: ; CX = number of floppy drives in the system + int 0x11 mov cl, 6 shr ax, cl inc ax @@ -31,16 +32,20 @@ drives_init: int 0x11 .loop: push cx push dx mov [bx+drive.biosnum], dl - ; defaults if 13h,AH=8 fails (XT 360kb) - les di, [0x1e * 4] - mov cx, 0x2709 ; 40 cylinders, 9 sectors - mov dh, 1 ; 2 heads - ; ask bios - push bx + ; query bios for floppy format mov ah, 8 + push bx int 0x13 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 ds pop es