Enable LBA booting for FAT16 and workaround for floppies where DL is not

passed.


git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@397 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
Bart Oldeman 2002-08-02 22:27:58 +00:00
parent 11be0d22e4
commit cbad615e0b
2 changed files with 86 additions and 12 deletions

View File

@ -178,15 +178,21 @@ Entry: jmp short real_start
; ENTRY ; ENTRY
;----------------------------------------------------------------------- ;-----------------------------------------------------------------------
real_start: cli real_start: cli
cld cld
xor ax, ax xor ax, ax
mov ss, ax ; initialize stack mov ss, ax ; initialize stack
mov ds, ax mov ds, ax
mov bp, 0x7c00 mov bp, 0x7c00
lea sp, [bp-0x20] lea sp, [bp-0x20]
sti sti
int 0x13 ; reset drive cmp byte [drive], 0xff ; BIOS bug ??
jne dont_use_dl
mov [drive], dl ; BIOS passes drive number in DL
; a reset should not be needed here
dont_use_dl:
; int 0x13 ; reset drive
; int 0x12 ; get memory available in AX ; int 0x12 ; get memory available in AX
; mov ax, 0x01e0 ; mov ax, 0x01e0
; mov cl, 6 ; move boot sector to higher memory ; mov cl, 6 ; move boot sector to higher memory
@ -203,10 +209,9 @@ real_start: cli
cont: mov ds, ax cont: mov ds, ax
mov ss, ax mov ss, ax
mov [drive], dl ; BIOS passes drive number in DL
call print call print
db "Loading FreeDOS ",0 db "FreeDOS",0
%ifdef CALCPARAMS %ifdef CALCPARAMS
GETDRIVEPARMS GETDRIVEPARMS
@ -337,7 +342,8 @@ finished: ; Mark end of FAT chain with 0, so we have a single
pop ds pop ds
call print call print
db " KERNEL",0 db " Kernel",0 ; "KERNEL"
; loadFile: Loads the file into memory, one cluster at a time. ; loadFile: Loads the file into memory, one cluster at a time.
@ -403,6 +409,64 @@ readDisk: push si
read_next: push dx read_next: push dx
push ax push ax
;******************** LBA_READ *******************************
; check for LBA support
push bx
mov ah,041h ;
mov bx,055aah ;
mov dl, [drive]
int 0x13
jc read_normal_BIOS
sub bx,0aa55h
jne read_normal_BIOS
shr cx,1 ; CX must have 1 bit set
jnc read_normal_BIOS
; OK, drive seems to support LBA addressing
lea si,[LBA_DISK_PARAMETER_BLOCK]
; setup LBA disk block
mov [si+12],bx
mov [si+14],bx
pop bx
pop ax
pop dx
push dx
push ax
mov [si+ 8],ax
mov [si+10],dx
mov [si+4],bx
mov [si+6],es
mov ah,042h
jmp short do_int13_read
LBA_DISK_PARAMETER_BLOCK:
db 10h ; constant size of block
db 0
dw 1 ; 1 sector read
; and overflow into code !!!
read_normal_BIOS:
pop bx
pop ax
pop dx
push dx
push ax
;******************** END OF LBA_READ ************************
; ;
; translate sector number to BIOS parameters ; translate sector number to BIOS parameters
; ;
@ -480,14 +544,18 @@ ax_min_2: push ax
pop ax pop ax
%else %else
mov ax, 0x0201 mov ax, 0x0201
do_int13_read:
mov dl, [drive] mov dl, [drive]
int 0x13 int 0x13
%endif %endif
read_finished:
jnc read_ok ; jump if no error jnc read_ok ; jump if no error
xor ah, ah ; else, reset floppy xor ah, ah ; else, reset floppy
int 0x13 int 0x13
pop ax pop ax
pop dx ; and... pop dx ; and...
read_next_chained:
jmp short read_next ; read the same sector again jmp short read_next ; read the same sector again
read_ok: read_ok:
@ -512,10 +580,10 @@ no_incr_es: pop ax
sub di,si ; if there is anything left to read, sub di,si ; if there is anything left to read,
jg read_next ; continue jg read_next ; continue
%else %else
add ax, 1 add ax, byte 1
adc dx, byte 0 ; DX:AX = next sector to read adc dx, byte 0 ; DX:AX = next sector to read
dec di ; if there is anything left to read, dec di ; if there is anything left to read,
jnz read_next ; continue jnz read_next_chained ; continue
%endif %endif
clc clc

View File

@ -622,6 +622,9 @@ VOID put_boot(COUNT drive, BYTE * bsFile, BOOL both)
temp = bs32->sysFatSecMask + 1; temp = bs32->sysFatSecMask + 1;
for (bs32->sysFatSecShift = 0; temp != 1; for (bs32->sysFatSecShift = 0; temp != 1;
bs32->sysFatSecShift++, temp >>= 1) ; bs32->sysFatSecShift++, temp >>= 1) ;
/* use fixed drive for A:, B: and DL otherwise */
bs32->bsDriveNumber = drive < 2 ? 0 : 0xff;
} }
#ifdef DEBUG #ifdef DEBUG
if (fs == 32) if (fs == 32)
@ -656,6 +659,9 @@ VOID put_boot(COUNT drive, BYTE * bsFile, BOOL both)
/* sector data starts on */ /* sector data starts on */
temp = temp + bs->sysRootDirSecs; temp = temp + bs->sysRootDirSecs;
bs->sysDataStart = temp; bs->sysDataStart = temp;
/* use fixed BIOS drive 0 for A:, B: and DL otherwise */
bs32->bsDriveNumber = drive < 2 ? 0 : 0xff;
} }
#ifdef DEBUG #ifdef DEBUG