Add attempt for drive table to kernel

This commit is contained in:
Nero 2019-09-19 20:02:16 +00:00
parent 7d7b4a89e6
commit d23bba5bdd
2 changed files with 59 additions and 7 deletions

50
kernel/drive.asm Normal file
View File

@ -0,0 +1,50 @@
%define drive_struct_len 0x0C
drive_table:
dw 0
.count:
dw 4
; Drive table
; 00 BYTE DL number
; 01 BYTE file system type
; 02 BYTE CHS heads (ignored if LBA)
; 03 BYTE CHS sectors per track (ignored if LBA)
; 04 DWORD total number of sectors
; 08 DWORD partition offset
; DI is incremented for the space taken
; IN ES:DI
drive_setup:
xor cx, cx
mov [drive_table], di
mov al, drive_struct_len
mov ah, BYTE [drive_table.count]
mul ah
xchg cx, ax
; this increments DI and also fills table with zeros
rep stosb
ret
; Load a drive table entry
; IN DL drive number
; OUT DS:SI ptr to table item
drive_load:
; bail out if number too high
cmp dl, [cs:drive_table.count]
jnc .err
push cs
pop ds
mov si, [drive_table]
push ax
mov al, drive_struct_len
mul dl
add si, ax
pop ax
ret
.err:
stc
ret

View File

@ -31,28 +31,30 @@ isr_error:
isr_return:
iret
%include "drive.asm"
init:
mov ax, cs
mov ds, ax
mov es, ax
mov di, kernel_end
call drive_setup
mov dx, isr_dos_main
mov ax, 0x2521
pushf
push cs
call isr_dos_main
mov cx, WORD [0x80]
xor ch, ch
mov si, 0x81
.loop:
lodsb
call putc
loop .loop
mov dl, 0x37
mov ah, 0x02
int 0x21
cli
.halt:
hlt
jmp .halt
kernel_end: