Read disk geometry and DPT from BIOS
This commit is contained in:
parent
c06c6ac918
commit
6bdb1da2ed
@ -9,12 +9,14 @@ dskseek: resd 1
|
||||
dskbuf: resb 512
|
||||
|
||||
dpt: resb DPTSIZE
|
||||
bpb: resb BPBSIZ4
|
||||
|
||||
section .text
|
||||
|
||||
ret: ret
|
||||
|
||||
; Convert drive number into DL for int 13h
|
||||
; A=0, B=1, C=0x80
|
||||
; IN dl dos drive number
|
||||
; OUT dl bios drive number
|
||||
getdl: cmp dl, 2
|
||||
@ -22,6 +24,22 @@ getdl: cmp dl, 2
|
||||
mov dl, 0x80
|
||||
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
|
||||
; IN dl drive number
|
||||
dsksel: cmp dl, byte [dsknum]
|
||||
@ -30,15 +48,31 @@ dsksel: cmp dl, byte [dsknum]
|
||||
call dskrst
|
||||
|
||||
call getdl
|
||||
mov ah, 8
|
||||
les di, [0x1E*4]
|
||||
int 0x13
|
||||
push dx
|
||||
call qrychs
|
||||
|
||||
; copy dpt
|
||||
mov bx, di
|
||||
; store CHS data in BPB
|
||||
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 bx, di
|
||||
mov cx, DPTSIZE
|
||||
call lod
|
||||
mov ax, [bpb+BPBSPT]
|
||||
mov [dpt+DPTSPT], al
|
||||
pop dx
|
||||
.nodpt:
|
||||
|
||||
|
||||
ret
|
||||
|
||||
|
@ -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
|
||||
; IN ES:BX far pointer to data
|
||||
; CX number of bytes to copy
|
||||
; 0:DX destination buffer
|
||||
; only CX is trashed
|
||||
|
||||
lod: push si
|
||||
push di
|
||||
push es
|
||||
lod: push es
|
||||
|
||||
; ES:DI := DS:DX
|
||||
mov ax, ds
|
||||
@ -25,8 +32,6 @@ lod: push si
|
||||
mov ds, cx
|
||||
|
||||
pop es
|
||||
pop di
|
||||
pop si
|
||||
ret
|
||||
|
||||
; far pointer store
|
||||
@ -35,18 +40,8 @@ lod: push si
|
||||
; 0:DX source buffer
|
||||
; only CX is trashed
|
||||
|
||||
sto: push si
|
||||
push di
|
||||
|
||||
mov si, dx
|
||||
sto: mov si, dx
|
||||
mov di, bx
|
||||
|
||||
; do the copy
|
||||
pushf
|
||||
cld
|
||||
rep movsb
|
||||
popf
|
||||
|
||||
pop di
|
||||
pop si
|
||||
ret
|
||||
|
Loading…
Reference in New Issue
Block a user