Make logging in drive a no-op if drive already logged in

This commit is contained in:
Nero 2020-12-17 00:41:53 +00:00
parent bd3b27362d
commit de04b5ca01
2 changed files with 16 additions and 19 deletions

View File

@ -29,10 +29,7 @@ print_banner: mov si, banner
sub dl, (0x80-2) sub dl, (0x80-2)
.k: mov [defdrv], dl .k: mov [defdrv], dl
call dskrst call logdrv.force
mov dl, [defdrv]
call logdrv
xor ax, ax xor ax, ax
xor dx, dx xor dx, dx

View File

@ -28,38 +28,38 @@ bpb: resb BPBSIZ4
section .text section .text
dskrst: call flush
mov ax, 0xFFFF
mov [dsknum], al
mov [dskseek], ax
mov [dskseek+2], 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
logdrv: push dx logdrv: ; dont do anything if drive already selected
call dskrst cmp dl, [dsknum]
je .ret
; clear out current contents
.force: push dx
call flush
mov ax, 0xFFFF
mov [dskseek], ax
mov [dskseek+2], ax
mov byte [dskflag], 0
pop dx pop dx
; set current drive number
mov [dsknum], dl
; save info for bios
mov [biosnum], dl mov [biosnum], dl
; load boot sector
xor ax, ax xor ax, ax
xor dx, dx xor dx, dx
call mapabs call mapabs
; copy bios parameter block ; copy bios parameter block
lea si, [dskbuf+BPBOFF] lea si, [dskbuf+BPBOFF]
mov di, bpb mov di, bpb
mov cx, BPBSIZ4 mov cx, BPBSIZ4
rep movsb rep movsb
; 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
mov [bpb+BPBHS+2], ax mov [bpb+BPBHS+2], ax
.ret: ret
ret
calchs: mov bx, (18*2) calchs: mov bx, (18*2)
; dx:ax = linear count, bx = sectors / cylinder ; dx:ax = linear count, bx = sectors / cylinder