mirror of https://github.com/FDOS/kernel.git
boot: enable loading from file systems with 256 sectors per cluster
This should be Enhanced DR-DOS compatible. oemboot.asm contains an optimisation to save 2 bytes, by using mov instead of a lea with bp evaluating to a constant value. This was needed to fit the addition for 256 spc support. It is otherwise unrelated. The LBA detection patch offsets in SYS have also been updated to match the changed boot.asm offsets.
This commit is contained in:
parent
28cd58688a
commit
2efe4ab9f4
|
@ -363,7 +363,9 @@ load_next: dec ax ; cluster numbers start with 2
|
||||||
dec ax
|
dec ax
|
||||||
|
|
||||||
mov di, word [bsSecPerClust]
|
mov di, word [bsSecPerClust]
|
||||||
and di, 0xff ; DI = sectors per cluster
|
dec di ; minus one if 256 spc
|
||||||
|
and di, 0xff ; DI = sectors per cluster - 1
|
||||||
|
inc di ; = spc
|
||||||
mul di
|
mul di
|
||||||
add ax, [data_start]
|
add ax, [data_start]
|
||||||
adc dx, [data_start+2] ; DX:AX = first sector to read
|
adc dx, [data_start+2] ; DX:AX = first sector to read
|
||||||
|
@ -422,9 +424,9 @@ read_next:
|
||||||
|
|
||||||
; NOTE: sys must be updated if location changes!!!
|
; NOTE: sys must be updated if location changes!!!
|
||||||
%ifdef ISFAT12
|
%ifdef ISFAT12
|
||||||
%define LBA_TEST_OFFSET 179h
|
%define LBA_TEST_OFFSET 17Bh
|
||||||
%elifdef ISFAT16
|
%elifdef ISFAT16
|
||||||
%define LBA_TEST_OFFSET 176h
|
%define LBA_TEST_OFFSET 178h
|
||||||
%else
|
%else
|
||||||
%define LBA_TEST_OFFSET 0
|
%define LBA_TEST_OFFSET 0
|
||||||
; Just a placeholder, so the proper error message
|
; Just a placeholder, so the proper error message
|
||||||
|
|
|
@ -294,7 +294,9 @@ c3:
|
||||||
sub ax, 2
|
sub ax, 2
|
||||||
sbb cx, byte 0 ; CX:AX == cluster - 2
|
sbb cx, byte 0 ; CX:AX == cluster - 2
|
||||||
mov bl, [bsSecPerClust]
|
mov bl, [bsSecPerClust]
|
||||||
sub bh, bh
|
dec bx ; bl = spc - 1, 0FFh if 256 spc
|
||||||
|
sub bh, bh ; bx = spc - 1
|
||||||
|
inc bx ; bx = spc
|
||||||
xchg cx, ax ; AX:CX == cluster - 2
|
xchg cx, ax ; AX:CX == cluster - 2
|
||||||
mul bx ; first handle high word
|
mul bx ; first handle high word
|
||||||
; DX must be 0 here
|
; DX must be 0 here
|
||||||
|
|
|
@ -313,6 +313,8 @@ convert_cluster:
|
||||||
dec eax
|
dec eax
|
||||||
|
|
||||||
movzx edx, byte [bsSecPerClust]
|
movzx edx, byte [bsSecPerClust]
|
||||||
|
dec dl ; spc - 1
|
||||||
|
inc dx ; spc
|
||||||
push edx
|
push edx
|
||||||
mul edx
|
mul edx
|
||||||
pop edx
|
pop edx
|
||||||
|
|
|
@ -143,7 +143,7 @@ segment .text
|
||||||
|
|
||||||
%define FATBUF bp-0x7500 ; offset of temporary buffer for FAT
|
%define FATBUF bp-0x7500 ; offset of temporary buffer for FAT
|
||||||
; chain 0:FATBUF = 0:0700 = LOADSEG:0
|
; chain 0:FATBUF = 0:0700 = LOADSEG:0
|
||||||
%define ROOTDIR bp-0x7700 ; offset to buffer for root directory
|
%define ROOTDIR 0x7C00-0x7700 ; offset to buffer for root directory
|
||||||
; entry of kernel 0:ROOTDIR
|
; entry of kernel 0:ROOTDIR
|
||||||
%define CLUSTLIST bp+0x0300 ; zero terminated list of clusters
|
%define CLUSTLIST bp+0x0300 ; zero terminated list of clusters
|
||||||
; that the kernel occupies
|
; that the kernel occupies
|
||||||
|
@ -332,11 +332,11 @@ real_start:
|
||||||
pop di ; mov di, word [RootDirSecs]
|
pop di ; mov di, word [RootDirSecs]
|
||||||
pop ax ; mov ax, word [root_dir_start]
|
pop ax ; mov ax, word [root_dir_start]
|
||||||
pop dx ; mov dx, word [root_dir_start+2]
|
pop dx ; mov dx, word [root_dir_start+2]
|
||||||
lea bx, [ROOTDIR] ; es:bx = 0:0500
|
mov bx, ROOTDIR ; es:bx = 0:0500
|
||||||
push es ; save pointer to ROOTDIR
|
push es ; save pointer to ROOTDIR
|
||||||
call readDisk
|
call readDisk
|
||||||
pop es ; restore pointer to ROOTDIR
|
pop es ; restore pointer to ROOTDIR
|
||||||
lea si, [ROOTDIR] ; ds:si = 0:0500
|
mov si, ROOTDIR ; ds:si = 0:0500
|
||||||
|
|
||||||
|
|
||||||
; Search for kernel file name, and find start cluster.
|
; Search for kernel file name, and find start cluster.
|
||||||
|
@ -361,7 +361,7 @@ ffDone:
|
||||||
%ifdef SETROOTDIR
|
%ifdef SETROOTDIR
|
||||||
; copy over this portion of root dir to 0x0:500 for PC-DOS
|
; copy over this portion of root dir to 0x0:500 for PC-DOS
|
||||||
; (this may allow IBMBIO.COM to start in any directory entry)
|
; (this may allow IBMBIO.COM to start in any directory entry)
|
||||||
lea di, [ROOTDIR] ; es:di = 0:0500
|
mov di, ROOTDIR ; es:di = 0:0500
|
||||||
mov cx, 32 ; limit to this 1 entry (rest don't matter)
|
mov cx, 32 ; limit to this 1 entry (rest don't matter)
|
||||||
rep movsw
|
rep movsw
|
||||||
%endif
|
%endif
|
||||||
|
@ -493,7 +493,9 @@ load_next: dec ax ; cluster numbers start with 2
|
||||||
dec ax
|
dec ax
|
||||||
|
|
||||||
mov di, word [bsSecPerClust]
|
mov di, word [bsSecPerClust]
|
||||||
and di, 0xff ; DI = sectors per cluster
|
dec di ; minus one if 256 spc
|
||||||
|
and di, 0xff ; DI = sectors per cluster - 1
|
||||||
|
inc di ; = spc
|
||||||
mul di
|
mul di
|
||||||
add ax, [data_start]
|
add ax, [data_start]
|
||||||
adc dx, [data_start+2] ; DX:AX = first sector to read
|
adc dx, [data_start+2] ; DX:AX = first sector to read
|
||||||
|
|
|
@ -1567,7 +1567,7 @@ void put_boot(SYSOptions *opts)
|
||||||
/* !!! if boot sector changes then update these locations !!! */
|
/* !!! if boot sector changes then update these locations !!! */
|
||||||
{
|
{
|
||||||
unsigned offset;
|
unsigned offset;
|
||||||
offset = (fs == FAT16) ? 0x176 : 0x179;
|
offset = (fs == FAT16) ? 0x178 : 0x17B;
|
||||||
|
|
||||||
if ( (newboot[offset]==0x84) && (newboot[offset+1]==0xD2) ) /* test dl,dl */
|
if ( (newboot[offset]==0x84) && (newboot[offset+1]==0xD2) ) /* test dl,dl */
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue