Add drive table initialisation
This commit is contained in:
parent
e6e75082e3
commit
a0adadeaf4
51
kernel/drvtab.asm
Normal file
51
kernel/drvtab.asm
Normal file
@ -0,0 +1,51 @@
|
||||
; 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
|
@ -65,8 +65,8 @@ putc:
|
||||
announce:
|
||||
push ds
|
||||
push cs
|
||||
mov ax, cs
|
||||
mov ds, ax
|
||||
push cs
|
||||
pop ds
|
||||
mov ax, str_product
|
||||
push ax
|
||||
call printf
|
||||
@ -85,15 +85,21 @@ start:
|
||||
|
||||
call announce
|
||||
|
||||
call drvtab_create
|
||||
|
||||
int3
|
||||
|
||||
cli
|
||||
.halt:
|
||||
hlt
|
||||
jmp .halt
|
||||
|
||||
%include "intr.asm"
|
||||
%include "drvtab.asm"
|
||||
|
||||
%include "printf.inc"
|
||||
%include "print.asm"
|
||||
|
||||
%include "intr.asm"
|
||||
%include "debug.asm"
|
||||
|
||||
times 512 nop
|
||||
|
Loading…
Reference in New Issue
Block a user