From dc6035fe9d84fa6b0518f3324e5d083bf23b7b52 Mon Sep 17 00:00:00 2001 From: Nero <41307858+nero@users.noreply.github.com> Date: Sat, 24 Oct 2020 22:50:23 +0000 Subject: [PATCH] Protypical implementation of DPT copying --- boot/kernel.asm | 2 ++ inc/dpt.asm | 18 +++++------------ kernel/drive.asm | 29 +++++++++++++++++++-------- kernel/far.asm | 52 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 80 insertions(+), 21 deletions(-) create mode 100644 kernel/far.asm diff --git a/boot/kernel.asm b/boot/kernel.asm index adcb7d2..74f359d 100644 --- a/boot/kernel.asm +++ b/boot/kernel.asm @@ -4,6 +4,7 @@ %include "inc/bpb.asm" %include "inc/mbr.asm" %include "inc/fcb.asm" +%include "inc/dpt.asm" ; kernel stack size in words %define stacksize 512 @@ -36,6 +37,7 @@ print_banner: mov si, banner hlt: hlt jmp hlt +%include "kernel/far.asm" %include "kernel/fcb.asm" %include "kernel/drive.asm" diff --git a/inc/dpt.asm b/inc/dpt.asm index 6a1f1ef..9586925 100644 --- a/inc/dpt.asm +++ b/inc/dpt.asm @@ -1,13 +1,5 @@ -struc dpt -.steprate resb 1 -.dmahdld resb 1 -.motoroff resb 1 -.sectorsize resb 1 -.lastsector resb 1 -.gaplen resb 1 -.dtl resb 1 -.gapfmt resb 1 -.fillchar resb 1 -.hdsettle resb 1 -.motoron resb 1 -endstruc +DPTMTT equ 2 +DPTSS equ 3 +DPTSPT equ 4 + +DPTSIZE equ 11 diff --git a/kernel/drive.asm b/kernel/drive.asm index 32cd58b..f609dd6 100644 --- a/kernel/drive.asm +++ b/kernel/drive.asm @@ -8,24 +8,37 @@ dskseek: resd 1 ; disk buffer for I/O operations dskbuf: resb 512 +dpt: resb DPTSIZE + section .text ret: ret + ; Convert drive number into DL for int 13h + ; IN dl dos drive number + ; OUT dl bios drive number +getdl: cmp dl, 2 + jc ret + mov dl, 0x80 + ret + ; select drive ; IN dl drive number -dsksel: cmp dl, 1 - jnc ret - mov al, dl - and al, 0x02 - ror dl, 1 - ror dl, 1 - cmp dl, byte [dsknum] +dsksel: cmp dl, byte [dsknum] je ret call dskrst - int 3 + call getdl + mov ah, 8 + les di, [0x1E*4] + int 0x13 + + ; copy dpt + mov bx, di + mov dx, dpt + mov cx, DPTSIZE + call lod ret diff --git a/kernel/far.asm b/kernel/far.asm new file mode 100644 index 0000000..59e5b7c --- /dev/null +++ b/kernel/far.asm @@ -0,0 +1,52 @@ +; 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 + + ; ES:DI := DS:DX + mov ax, ds + mov es, ax + mov di, dx + ; DS:SI := 0:BX + xor ax, ax + mov ds, ax + mov si, bx + ; copy + pushf + cld + rep movsb + popf + ; reset DS to kernel data + mov ds, cx + + pop es + pop di + pop si + ret + +; far pointer store +; IN ES:BX far ptr +; CX number of bytes +; 0:DX source buffer +; only CX is trashed + +sto: push si + push di + + mov si, dx + mov di, bx + + ; do the copy + pushf + cld + rep movsb + popf + + pop di + pop si + ret