Support managing floppy parameter table
This commit is contained in:
parent
f10fa026cf
commit
0a2a0e4659
@ -24,6 +24,10 @@ print_banner: mov si, banner
|
|||||||
cmp al, 0x0D
|
cmp al, 0x0D
|
||||||
jnz .loop
|
jnz .loop
|
||||||
|
|
||||||
|
push dx
|
||||||
|
call dinit
|
||||||
|
pop dx
|
||||||
|
|
||||||
cmp dl, 0x80
|
cmp dl, 0x80
|
||||||
jc .k
|
jc .k
|
||||||
sub dl, (0x80-2)
|
sub dl, (0x80-2)
|
||||||
|
@ -28,6 +28,45 @@ bpb: resb BPBSIZ4
|
|||||||
|
|
||||||
section .text
|
section .text
|
||||||
|
|
||||||
|
; initial setup for disk i/o
|
||||||
|
dinit: ; copy previously set DPT to our data area
|
||||||
|
lds si, [4*0x1E]
|
||||||
|
mov di, dpt
|
||||||
|
mov cx, 11
|
||||||
|
rep movsb
|
||||||
|
; restore DS
|
||||||
|
xor ax, ax
|
||||||
|
mov ds, ax
|
||||||
|
; set vector
|
||||||
|
mov word [4*0x1E], dpt
|
||||||
|
mov word [4*0x1E+2], ds
|
||||||
|
ret
|
||||||
|
|
||||||
|
; restore DPT to default values if possible
|
||||||
|
; IN dl bios drive number
|
||||||
|
rstdpt: mov ah, 8
|
||||||
|
int 0x13
|
||||||
|
jc .ret
|
||||||
|
mov ax, es
|
||||||
|
or ax, di
|
||||||
|
test ax, ax
|
||||||
|
jz .ret
|
||||||
|
; DS:SI = ES:DI
|
||||||
|
mov ax, es
|
||||||
|
mov ds, ax
|
||||||
|
mov si, di
|
||||||
|
; ES:DI = dpt
|
||||||
|
xor ax, ax
|
||||||
|
mov es, ax
|
||||||
|
mov di, dpt
|
||||||
|
; do the copy
|
||||||
|
mov cx, 11
|
||||||
|
rep movsb
|
||||||
|
.ret: ; restore DS to 0
|
||||||
|
xor ax, ax
|
||||||
|
mov ds, ax
|
||||||
|
ret
|
||||||
|
|
||||||
; log in drive
|
; log in drive
|
||||||
; currently only supports 18 sectors 2 heads floppies
|
; currently only supports 18 sectors 2 heads floppies
|
||||||
; IN dl drive number
|
; IN dl drive number
|
||||||
@ -46,6 +85,8 @@ logdrv: ; dont do anything if drive already selected
|
|||||||
mov [dsknum], dl
|
mov [dsknum], dl
|
||||||
; save info for bios
|
; save info for bios
|
||||||
mov [biosnum], dl
|
mov [biosnum], dl
|
||||||
|
; reset dpt to defaults
|
||||||
|
call rstdpt
|
||||||
; 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
|
||||||
@ -54,10 +95,14 @@ logdrv: ; dont do anything if drive already selected
|
|||||||
xor dx, dx
|
xor dx, dx
|
||||||
call mapabs
|
call mapabs
|
||||||
; copy bios parameter block
|
; copy bios parameter block
|
||||||
lea si, [dskbuf+BPBOFF]
|
; TODO: guess from first byte of FAT if BPB invalid
|
||||||
|
mov si, dskbuf+BPBOFF
|
||||||
mov di, bpb
|
mov di, bpb
|
||||||
mov cx, BPBSIZ4
|
mov cx, BPBSIZ4
|
||||||
rep movsb
|
rep movsb
|
||||||
|
; copy SPT to DPT
|
||||||
|
mov al, [bpb+BPBSPT]
|
||||||
|
mov [dpt+4], al
|
||||||
; make sure partition offset is forced zero
|
; make sure partition offset is forced zero
|
||||||
xor ax, ax
|
xor ax, ax
|
||||||
mov [bpb+BPBHS], ax
|
mov [bpb+BPBHS], ax
|
||||||
@ -68,7 +113,7 @@ calchs: ; put sectors per cylinder into bx
|
|||||||
mov ax, [bpb+BPBSPT]
|
mov ax, [bpb+BPBSPT]
|
||||||
mul word [bpb+BPBNOS]
|
mul word [bpb+BPBNOS]
|
||||||
mov bx, ax
|
mov bx, ax
|
||||||
; but linear sector num into dx:ax
|
; put linear sector num into dx:ax
|
||||||
mov ax, [dskseek]
|
mov ax, [dskseek]
|
||||||
mov dx, [dskseek+2]
|
mov dx, [dskseek+2]
|
||||||
; dx:ax = linear count, bx = sectors / cylinder
|
; dx:ax = linear count, bx = sectors / cylinder
|
||||||
|
Loading…
Reference in New Issue
Block a user