rdos/kernel/drvtab.asm

52 lines
784 B
NASM

; Drive table
; Header:
; byte number of drives
; Item (type BIOS CHS):
; byte type (1)
; byte drive number
; word number of cylinders
; byte number of heads
; word number of sectors per cylinder
; 3 bytes padding
; Item (type BIOS LBA):
; byte type (2)
; byte drive number
; dword offset
; dword size
; Create a drive table at ES:DI
drvtab_create:
mov ax, 0x2B
call intr_register
mov al, 8 ; 8 drives per default
mov ah, 10 ; 10 bytes per drive
stosb
mul ah
xor cx, cx
xchg cx, ax
rep stosb
ret
; Get drive table item
; IN DL drive number (A=0, B=1, ...)
; OUT DS:SI ptr to drive struct
drvtab_load:
push ax
mov ax, 0x2B
call intr_load
cmp dl, [ds:si]
jnb .err
mov al, 10
mul dl
inc ax
add si, ax
pop ax
ret
.err:
pop ax
stc
ret