Skip to content

Commit de96d00

Browse files
committed
additional comments about LBA detection
1 parent cab3234 commit de96d00

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

kernel/initdisk.c

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ void DosDefinePartition(struct DriveParamS *driveParam,
567567
/* Turn off LBA if not forced and the partition is within 1023 cyls and of the right type */
568568
/* the FileSystem type was internally converted to LBA_xxxx if a non-LBA partition
569569
above cylinder 1023 was found */
570-
if (!InitKernelConfig.ForceLBA && !ExtLBAForce && !IsLBAPartition(pEntry->FileSystem))
570+
if (!(InitKernelConfig.ForceLBA || IsLBAPartition(pEntry->FileSystem) || ExtLBAForce))
571571
pddt->ddt_descflags &= ~DF_LBA;
572572
pddt->ddt_ncyl = driveParam->chs.Cylinder;
573573

@@ -642,24 +642,27 @@ STATIC int LBA_Get_Drive_Parameters(int drive, struct DriveParamS *driveParam, i
642642
memset(driveParam, 0, sizeof *driveParam);
643643
drive |= 0x80;
644644

645-
/* for tests - disable LBA support,
646-
even if exists */
645+
/* use CHS if LBA support is not enabled by kernel configuration */
647646
if (!InitKernelConfig.GlobalEnableLBAsupport)
648647
{
648+
if (firstPass && (InitKernelConfig.Verbose >= 1)) printf("LBA support disabled.\n");
649649
goto StandardBios;
650650
}
651651
/* check for LBA support */
652652
regs.b.x = 0x55aa;
653653
regs.a.b.h = 0x41;
654654
regs.d.b.l = drive;
655+
regs.flags = FLG_CARRY; /* ensure carry is set to force error if unsupported */
655656

656657
init_call_intr(0x13, &regs);
657658

658-
if ((regs.flags & 0x01) || regs.b.x != 0xaa55 || (regs.c.x & 0x01) == 0)
659+
if ((regs.flags & FLG_CARRY) || regs.b.x != 0xaa55 || !(regs.c.x & 0x01))
659660
{
660661
/* error conditions:
661-
carry set or BX != 0xaa55 => no EDD spec compatible BIOS
662-
CX bit 1 clear => fixed disc access subset not supported */
662+
carry set or BX != 0xaa55 => no EDD spec compatible BIOS (LBA extensions not supported)
663+
CX bit 1 is set if BIOS supports fixed disk subset (Disk Address Packet [DAP] subset),
664+
or clear if fixed disk access subset not supported by LBA extensions
665+
*/
663666
goto StandardBios;
664667
}
665668

@@ -678,7 +681,7 @@ STATIC int LBA_Get_Drive_Parameters(int drive, struct DriveParamS *driveParam, i
678681
regs.d.b.l = drive;
679682
init_call_intr(0x13, &regs);
680683

681-
if (regs.flags & 0x01)
684+
if (regs.flags & FLG_CARRY)
682685
{
683686
/* carry flag set indicates failed LBA disk parameter query */
684687
goto StandardBios;
@@ -916,6 +919,7 @@ BOOL ScanForPrimaryPartitions(struct DriveParamS * driveParam, int scan_type,
916919
if (chs.Cylinder > 1023 || end.Cylinder > 1023)
917920
{
918921

922+
/* if partition exceeds bounds of CHS addressing but LBA is not supported then skip partition */
919923
if (!(driveParam->descflags & DF_LBA))
920924
{
921925
printf
@@ -929,8 +933,11 @@ BOOL ScanForPrimaryPartitions(struct DriveParamS * driveParam, int scan_type,
929933
continue;
930934
}
931935

932-
if (!InitKernelConfig.ForceLBA && !ExtLBAForce
933-
&& !IsLBAPartition(pEntry->FileSystem))
936+
/* if partition exceeds bounds of CHS addressing and we can use LBA
937+
but partition type indicates to use CHS then print warning
938+
and force internal filesystem indicator to enable LBA
939+
*/
940+
if (!(InitKernelConfig.ForceLBA || IsLBAPartition(pEntry->FileSystem) || ExtLBAForce))
934941
{
935942
printf
936943
("WARNING: Partition ID does not suggest LBA - part %s FS %02x.\n"

0 commit comments

Comments
 (0)