Add support for hard disks
This commit is contained in:
parent
b8b56e1f45
commit
c75b323d31
@ -29,17 +29,21 @@ init: cli
|
|||||||
sub dl, (0x80-2)
|
sub dl, (0x80-2)
|
||||||
.k: mov [defdrv], dl
|
.k: mov [defdrv], dl
|
||||||
|
|
||||||
call logdrv.force
|
call logdrv
|
||||||
|
|
||||||
xor ax, ax
|
xor ax, ax
|
||||||
xor dx, dx
|
xor dx, dx
|
||||||
call maprd
|
call maprd
|
||||||
|
|
||||||
inc word [dskbuf+0x82]
|
inc word [dskbuf+0x82]
|
||||||
|
push word [dskbuf+0x82]
|
||||||
|
|
||||||
call dirty
|
call dirty
|
||||||
call flush
|
call flush
|
||||||
|
|
||||||
|
call printf
|
||||||
|
db "Current run: ",2,0x0A,0x0D,0
|
||||||
|
|
||||||
hlt: hlt
|
hlt: hlt
|
||||||
jmp hlt
|
jmp hlt
|
||||||
|
|
||||||
|
@ -65,15 +65,33 @@ int13: ; debug output
|
|||||||
stc
|
stc
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; restore DPT to default values if possible
|
; get drive parameters
|
||||||
; IN dl bios drive number
|
; read BIOS int13h/AH=8 values
|
||||||
rstdpt: mov ah, 8
|
; DPT data gets copied over our dpt
|
||||||
|
; CHS data gets inserted into our bpb
|
||||||
|
getprm: mov ah, 8
|
||||||
|
mov dl, [biosnum]
|
||||||
call int13
|
call int13
|
||||||
jc .ret
|
; bail out if error
|
||||||
mov ax, es
|
jc .nodpt
|
||||||
|
; get and store sector number
|
||||||
|
and cx, 0x3F
|
||||||
|
mov word [bpb+BPBSPT], cx
|
||||||
|
; get and store number of heads
|
||||||
|
xchg dl, dh
|
||||||
|
and dx, 0xFF
|
||||||
|
inc dx
|
||||||
|
mov [bpb+BPBNOS], dx
|
||||||
|
; print geometry
|
||||||
|
push dx
|
||||||
|
push cx
|
||||||
|
call printf
|
||||||
|
db "getprm: ",2," sectors, ",2," heads",0x0A,0x0D,0
|
||||||
|
; test if DPT ptr is non-zero
|
||||||
|
.nochs: mov ax, es
|
||||||
or ax, di
|
or ax, di
|
||||||
test ax, ax
|
test ax, ax
|
||||||
jz .ret
|
jz .nodpt
|
||||||
; DS:SI = ES:DI
|
; DS:SI = ES:DI
|
||||||
mov ax, es
|
mov ax, es
|
||||||
mov ds, ax
|
mov ds, ax
|
||||||
@ -85,9 +103,10 @@ rstdpt: mov ah, 8
|
|||||||
; do the copy
|
; do the copy
|
||||||
mov cx, 11
|
mov cx, 11
|
||||||
rep movsb
|
rep movsb
|
||||||
.ret: ; restore DS to 0
|
.nodpt: ; restore segment registers
|
||||||
xor ax, ax
|
xor ax, ax
|
||||||
mov ds, ax
|
mov ds, ax
|
||||||
|
mov es, ax
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; log in drive
|
; log in drive
|
||||||
@ -95,7 +114,7 @@ rstdpt: mov ah, 8
|
|||||||
; IN dl drive number
|
; IN dl drive number
|
||||||
logdrv: ; dont do anything if drive already selected
|
logdrv: ; dont do anything if drive already selected
|
||||||
cmp dl, [dsknum]
|
cmp dl, [dsknum]
|
||||||
je .ret
|
je logfdd.ret
|
||||||
; clear out current contents
|
; clear out current contents
|
||||||
push dx
|
push dx
|
||||||
call flush
|
call flush
|
||||||
@ -106,10 +125,14 @@ logdrv: ; dont do anything if drive already selected
|
|||||||
pop dx
|
pop dx
|
||||||
; set current drive number
|
; set current drive number
|
||||||
mov [dsknum], dl
|
mov [dsknum], dl
|
||||||
; save info for bios
|
; fork off if hdd
|
||||||
|
cmp dl, 2
|
||||||
|
jnc loghdd
|
||||||
|
|
||||||
|
logfdd: ; save info for bios
|
||||||
mov [biosnum], dl
|
mov [biosnum], dl
|
||||||
; reset dpt to defaults
|
; reset dpt to defaults
|
||||||
call rstdpt
|
call getprm
|
||||||
; set default geometry (1.44 MB floppy)
|
; set default geometry (1.44 MB floppy)
|
||||||
mov word [bpb+BPBNOS], 2
|
mov word [bpb+BPBNOS], 2
|
||||||
mov word [bpb+BPBSPT], 18
|
mov word [bpb+BPBSPT], 18
|
||||||
@ -132,6 +155,50 @@ logdrv: ; dont do anything if drive already selected
|
|||||||
mov [bpb+BPBHS+2], ax
|
mov [bpb+BPBHS+2], ax
|
||||||
.ret: ret
|
.ret: ret
|
||||||
|
|
||||||
|
loghdd: sub dl, 2
|
||||||
|
cmp dl, 4
|
||||||
|
jnc logerr
|
||||||
|
push dx
|
||||||
|
mov byte [biosnum], 0x80
|
||||||
|
; get chs data (needed or we cant load vbr)
|
||||||
|
call getprm
|
||||||
|
; read mbr
|
||||||
|
xor ax, ax
|
||||||
|
xor dx, dx
|
||||||
|
call mapabs
|
||||||
|
; get partition number
|
||||||
|
pop bx
|
||||||
|
xor bh, bh
|
||||||
|
mov cl, 4
|
||||||
|
sal bx, cl
|
||||||
|
; bail out if no partition
|
||||||
|
cmp byte [dskbuf+0x1be+bx+4], 0
|
||||||
|
je logerr
|
||||||
|
; load partition offset
|
||||||
|
mov ax, [dskbuf+0x1be+bx+8]
|
||||||
|
mov dx, [dskbuf+0x1be+bx+8+2]
|
||||||
|
; save to to stack
|
||||||
|
push dx
|
||||||
|
push ax
|
||||||
|
; load vbr
|
||||||
|
call mapabs
|
||||||
|
; copy bpb
|
||||||
|
mov si, dskbuf+BPBOFF
|
||||||
|
mov di, bpb
|
||||||
|
mov cx, BPBSIZ4
|
||||||
|
rep movsb
|
||||||
|
; fix CHS data
|
||||||
|
call getprm
|
||||||
|
; fix partition offset
|
||||||
|
pop ax
|
||||||
|
pop dx
|
||||||
|
mov [bpb+BPBHS], ax
|
||||||
|
mov [bpb+BPBHS+2], dx
|
||||||
|
ret
|
||||||
|
|
||||||
|
logerr: stc
|
||||||
|
ret
|
||||||
|
|
||||||
mapclu: ; counting from begin of cluster area
|
mapclu: ; counting from begin of cluster area
|
||||||
mov bx, [bpb+BPBRDE]
|
mov bx, [bpb+BPBRDE]
|
||||||
mov cl, 4
|
mov cl, 4
|
||||||
|
Loading…
Reference in New Issue
Block a user