[FREELDR:ARCH] Fix minor bugs; condense XboxDiskInit() a bit (#8732)

- `AtaInit()` returns the number of detected ATA devices. Therefore,
  when iterating over them, go from index 0 to the count _minus_ 1,
  in `Pc98InitializeBootDevices()` and in `XboxDiskInit()`.

- Initialize `DiskDrive->Type` to `DRIVE_TYPE_HDD` for detected SCSI
  hard-disk drives in `pc98disk.c!InitScsiDrive()`.

- Rearrange `XboxDiskInit()` and reduce its indentation level.
This commit is contained in:
Hermès Bélusca-Maïto
2026-03-13 22:21:37 +01:00
parent 62d71ebbd3
commit d2cbec0b5f
2 changed files with 16 additions and 18 deletions

View File

@@ -397,6 +397,7 @@ InitScsiDrive(
DiskDrive->Geometry.Heads = RegsOut.b.dh;
DiskDrive->Geometry.SectorsPerTrack = RegsOut.b.dl;
DiskDrive->Geometry.BytesPerSector = RegsOut.w.bx;
DiskDrive->Type = DRIVE_TYPE_HDD;
}
/* Other devices */
else if (ScsiParameters != 0)
@@ -675,7 +676,7 @@ Pc98InitializeBootDevices(VOID)
* that cannot boot from a CD-ROM and has LBA limitations.
*/
AtaInit(&IdeDetectedCount);
for (i = 0; i <= IdeDetectedCount; i++)
for (i = 0; i < IdeDetectedCount; i++)
{
DiskDrive = &Pc98DiskDrive[BiosHardDriveDriveNumber];
if (InitIdeDrive(DiskDrive, i))

View File

@@ -42,31 +42,28 @@ static
VOID
XboxDiskInit(VOID)
{
UCHAR DetectedCount;
UCHAR UnitNumber;
PDEVICE_UNIT DeviceUnit = NULL;
UCHAR DetectedCount, UnitNumber;
ASSERT(!AtaInitialized);
AtaInitialized = TRUE;
/* Find first HDD and CD */
AtaInit(&DetectedCount);
for (UnitNumber = 0; UnitNumber <= DetectedCount; UnitNumber++)
for (UnitNumber = 0; UnitNumber < DetectedCount; UnitNumber++)
{
DeviceUnit = AtaGetDevice(UnitNumber);
if (DeviceUnit)
PDEVICE_UNIT DeviceUnit = AtaGetDevice(UnitNumber);
if (!DeviceUnit)
continue;
if (DeviceUnit->Flags & ATA_DEVICE_ATAPI)
{
if (DeviceUnit->Flags & ATA_DEVICE_ATAPI)
{
if (!CdDrive)
CdDrive = DeviceUnit;
}
else
{
if (!HardDrive)
HardDrive = DeviceUnit;
}
if (!CdDrive)
CdDrive = DeviceUnit;
}
else
{
if (!HardDrive)
HardDrive = DeviceUnit;
}
}
}