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:
C. Masloch 2023-01-04 22:09:46 +01:00 committed by Kenneth J Davis
parent 28cd58688a
commit 2efe4ab9f4
5 changed files with 18 additions and 10 deletions

View File

@ -363,7 +363,9 @@ load_next: dec ax ; cluster numbers start with 2
dec ax
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
add ax, [data_start]
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!!!
%ifdef ISFAT12
%define LBA_TEST_OFFSET 179h
%define LBA_TEST_OFFSET 17Bh
%elifdef ISFAT16
%define LBA_TEST_OFFSET 176h
%define LBA_TEST_OFFSET 178h
%else
%define LBA_TEST_OFFSET 0
; Just a placeholder, so the proper error message

View File

@ -294,7 +294,9 @@ c3:
sub ax, 2
sbb cx, byte 0 ; CX:AX == cluster - 2
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
mul bx ; first handle high word
; DX must be 0 here

View File

@ -313,6 +313,8 @@ convert_cluster:
dec eax
movzx edx, byte [bsSecPerClust]
dec dl ; spc - 1
inc dx ; spc
push edx
mul edx
pop edx

View File

@ -143,7 +143,7 @@ segment .text
%define FATBUF bp-0x7500 ; offset of temporary buffer for FAT
; 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
%define CLUSTLIST bp+0x0300 ; zero terminated list of clusters
; that the kernel occupies
@ -332,11 +332,11 @@ real_start:
pop di ; mov di, word [RootDirSecs]
pop ax ; mov ax, word [root_dir_start]
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
call readDisk
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.
@ -361,7 +361,7 @@ ffDone:
%ifdef SETROOTDIR
; copy over this portion of root dir to 0x0:500 for PC-DOS
; (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)
rep movsw
%endif
@ -493,7 +493,9 @@ load_next: dec ax ; cluster numbers start with 2
dec ax
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
add ax, [data_start]
adc dx, [data_start+2] ; DX:AX = first sector to read

View File

@ -1567,7 +1567,7 @@ void put_boot(SYSOptions *opts)
/* !!! if boot sector changes then update these locations !!! */
{
unsigned offset;
offset = (fs == FAT16) ? 0x176 : 0x179;
offset = (fs == FAT16) ? 0x178 : 0x17B;
if ( (newboot[offset]==0x84) && (newboot[offset+1]==0xD2) ) /* test dl,dl */
{