From 66f54f639c76f061266a903a831ff9d9faf2cb1e Mon Sep 17 00:00:00 2001 From: Ain <41307858+nero@users.noreply.github.com> Date: Mon, 14 Oct 2019 17:59:48 +0000 Subject: [PATCH] WIP on fcb io --- kernel/drive.asm | 36 +++++++++++------------------------- kernel/exec.asm | 6 +----- kernel/fcb.asm | 15 +++++++++------ kernel/main.asm | 5 ----- 4 files changed, 21 insertions(+), 41 deletions(-) diff --git a/kernel/drive.asm b/kernel/drive.asm index 04599ac..2e1280a 100644 --- a/kernel/drive.asm +++ b/kernel/drive.asm @@ -46,8 +46,18 @@ drive_read: dec dl mov ax, 0x0201 mov bx, diskbuf + ; try read int 0x13 -.giveup: + jnc .end + ; reset disk + mov ah, 0x00 + int 0x13 + ; loop with si + dec si + test si, si + jnz .try + stc +.end: pop si pop bx pop dx @@ -57,27 +67,3 @@ drive_read: .fast: ; fast lane for boot sector inc cl jmp .try -.fail: - ; reset disk - mov ah, 0x00 - int 0x13 - ; loop with si - dec si - test si, si - jnz .try - stc - jmp .giveup - -; Seek to fcb_off given in a ptr -; IN BX ptr to FCB -drive_seek: - push ax - push cx - mov cl, [bx+fcb_ss] - add cl, 7 - mov ax, 1 - sal ax, cl - int3 - pop cx - pop ax - ret diff --git a/kernel/exec.asm b/kernel/exec.asm index 6c8f963..9ab3744 100644 --- a/kernel/exec.asm +++ b/kernel/exec.asm @@ -7,11 +7,7 @@ exec: mov bx, sp call fcb_parse - call fcb_open_blockdev - mov cx, 5 -.loop: - call fcb_getc - loop .loop + call fcb_open_rootdir add sp, 0x20 pop bx diff --git a/kernel/fcb.asm b/kernel/fcb.asm index a5a174c..b945d0a 100644 --- a/kernel/fcb.asm +++ b/kernel/fcb.asm @@ -1,3 +1,5 @@ +; diskbuf needs to be defined + ; User-accessible part of FCB (12 bytes) %define fcb_drv 0 ; 1 byte, 1=A: 2=B: 3=C: %define fcb_fn 1 ; 8 bytes @@ -19,16 +21,18 @@ %define fcb_end 32 -fcb_open_blockdev: +fcb_open_rootdir: mov dl, 0x01 mov [bx], dl dec dl - ; Init non-user FCB data with zero + ; Setup default data + ; Default 2 heads, 9 sectors + mov word [bx+fcb_spt], 0x0209 xor ax, ax - xor dx, dx - lea di, [bx+fcb_spt] - mov cx, (fcb_end - fcb_spt) + lea di, [bx+fcb_ss] + ; Sector & Cluster size 128 bytes + mov cx, (fcb_end - fcb_ss) rep stosb ; load first sector @@ -72,7 +76,6 @@ fcb_get_sector_mask: fcb_getc: push bx - call drive_seek call fcb_get_sector_mask not ax and ax, [bx+fcb_off] diff --git a/kernel/main.asm b/kernel/main.asm index 76be6db..72efe25 100644 --- a/kernel/main.asm +++ b/kernel/main.asm @@ -8,11 +8,6 @@ cpu 8086 %define stack (diskbuf) -; Metadata for current disk sector -%define diskptr 0x50 -%define disknum 0x54 -%define diskflg 0x55 - %define default_drive BYTE [0x4] org self