FDOS/kernel

SYS: When OEM compatibility boot sector enabled and in use, /FORCE:LBA and /FORCE:CHS are silently ignored

ecm-pushbx opened this issue · 1 comments

This is the part that applies the patches to the standard boot sector loader:

kernel/sys/sys.c

Lines 1562 to 1601 in 302b002

if (opts->kernel.stdbs)
{
/* copy over appropriate boot sector, FAT12 or FAT16 */
memcpy(newboot, (fs == FAT16) ? fat16com : fat12com, SEC_SIZE);
/* !!! if boot sector changes then update these locations !!! */
{
unsigned offset;
offset = (fs == FAT16) ? 0x176 : 0x179;
if ( (newboot[offset]==0x84) && (newboot[offset+1]==0xD2) ) /* test dl,dl */
{
/* if always use LBA then NOP out conditional jmp over LBA logic if A: */
if (opts->force==LBA)
{
offset+=2; /* jz */
newboot[offset] = 0x90; /* NOP */ ++offset;
newboot[offset] = 0x90; /* NOP */
}
else if (opts->force==CHS) /* if force CHS then always skip LBA logic */
{
newboot[offset] = 0x30; /* XOR */
}
}
else
{
printf("%s : fat boot sector does not match expected layout\n", pgm);
exit(1);
}
}
}
else
{
#ifdef WITHOEMCOMPATBS
printf("Using OEM (PC/MS-DOS) compatible boot sector.\n");
memcpy(newboot, (fs == FAT16) ? oemfat16 : oemfat12, SEC_SIZE);
#else
printf("Internal Error: no OEM compatible boot sector!\n");
#endif
}

For the OEM compatibility boot sector loader, no patches are applied. And that is true even though the LBA detection is very similar for the OEM loader, and could be patched similarly:

%ifdef TRYLBAREAD

Like my INSTSECT the SYS program could detect the unit handling and LBA detection sequences automatically, without need for the hardcoded offset value.