Read disk geometry and DPT from BIOS

This commit is contained in:
Nero 2020-10-30 09:29:22 +00:00
parent c06c6ac918
commit 6bdb1da2ed
2 changed files with 51 additions and 22 deletions

View File

@ -9,12 +9,14 @@ dskseek: resd 1
dskbuf: resb 512 dskbuf: resb 512
dpt: resb DPTSIZE dpt: resb DPTSIZE
bpb: resb BPBSIZ4
section .text section .text
ret: ret ret: ret
; Convert drive number into DL for int 13h ; Convert drive number into DL for int 13h
; A=0, B=1, C=0x80
; IN dl dos drive number ; IN dl dos drive number
; OUT dl bios drive number ; OUT dl bios drive number
getdl: cmp dl, 2 getdl: cmp dl, 2
@ -22,6 +24,22 @@ getdl: cmp dl, 2
mov dl, 0x80 mov dl, 0x80
ret ret
; Ask BIOS for drive parameters
; IN dl dos drive number
; OUT CX,DH chs data
; ES:DI DPT if floppy
qrychs: mov ah, 8
les di, [0x1E*4]
int 0x13
jc .defs
test cl, cl
jz .defs
ret
.defs: mov cx, 0x2709 ; max track = 39, max sec = 9
mov dh, 1 ; 2 heads
ret
; select drive ; select drive
; IN dl drive number ; IN dl drive number
dsksel: cmp dl, byte [dsknum] dsksel: cmp dl, byte [dsknum]
@ -30,15 +48,31 @@ dsksel: cmp dl, byte [dsknum]
call dskrst call dskrst
call getdl call getdl
mov ah, 8 push dx
les di, [0x1E*4] call qrychs
int 0x13
; copy dpt ; store CHS data in BPB
mov bx, di xor ax, ax
mov al, cl
mov [bpb+BPBSPT], ax
mov al, dh
inc ax
mov [bpb+BPBNOS], ax
; get dpt from bios if not hdd
pop dx
test dl, 0x80
jnz .nodpt
push dx
mov dx, dpt mov dx, dpt
mov bx, di
mov cx, DPTSIZE mov cx, DPTSIZE
call lod call lod
mov ax, [bpb+BPBSPT]
mov [dpt+DPTSPT], al
pop dx
.nodpt:
ret ret

View File

@ -1,12 +1,19 @@
; Utilities to help with far pointers
; exchange DS:SI with ES:DI
xchgs: push ds
push es
pop ds
pop es
xchg si, di
ret
; far pointer load ; far pointer load
; IN ES:BX far pointer to data ; IN ES:BX far pointer to data
; CX number of bytes to copy ; CX number of bytes to copy
; 0:DX destination buffer ; 0:DX destination buffer
; only CX is trashed
lod: push si lod: push es
push di
push es
; ES:DI := DS:DX ; ES:DI := DS:DX
mov ax, ds mov ax, ds
@ -25,8 +32,6 @@ lod: push si
mov ds, cx mov ds, cx
pop es pop es
pop di
pop si
ret ret
; far pointer store ; far pointer store
@ -35,18 +40,8 @@ lod: push si
; 0:DX source buffer ; 0:DX source buffer
; only CX is trashed ; only CX is trashed
sto: push si sto: mov si, dx
push di
mov si, dx
mov di, bx mov di, bx
; do the copy
pushf
cld cld
rep movsb rep movsb
popf
pop di
pop si
ret ret