[FREELDR]: Part 3 of my local changes merging:

- Remove the DiskVtbl functions (machxbox.c) of the XBOX and share them instead with those of the PC, since they are basically the same.
  They just however differ by which 'DiskGetPartitionEntry' function they use. To cope with this, 'DiskGetPartitionEntry' becomes a pointer
  to either the default function 'DiskGetMbrPartitionEntry' (which indeed assumes a MBR-layout, see partition.c), or the special function
  'XboxDiskGetPartitionEntry' in the case of partitionless XBOX disks.
  Note that, by the way, partition.c should in the future support GPT-layout disks as well...
- The boot devices pre-initialization code can also be shared as well, thus getting rid of 'XboxInitializeBootDevices', because we note that
  this is exactly what the (old) XBOX version of 'DetectBiosDisks' did at its beginning.
- But then, we can also share 'DetectBiosDisks' XBOX code with its PC version, and also *fix* the PC code version as well!
  'DetectSystem' and 'DetectBiosDisks' are therefore merged *as they should be*. Thanks to the boot devices pre-initialization code that has
  run before the hardware detection, 'DetectBiosDisks' can just use the cached information.
- Now we correctly initialize the PC root HW system configuration key: we first create it, then, after the bios disks (floppies + HDDs) are enumerated
  we set the BIOS INT13h disk data to the system key's configuration data.

svn path=/trunk/; revision=73618
This commit is contained in:
Hermès Bélusca-Maïto 2017-01-29 02:35:28 +00:00
parent 17990b28a2
commit 9a649094dc
10 changed files with 111 additions and 413 deletions

View file

@ -37,12 +37,11 @@ DBG_DEFAULT_CHANNEL(HWDETECT);
static unsigned int delay_count = 1;
extern UCHAR PcBiosDiskCount;
PCHAR
GetHarddiskIdentifier(
UCHAR DriveNumber);
/* This function is slightly different in its PC and XBOX versions */
GET_HARDDISK_CONFIG_DATA GetHarddiskConfigurationData = NULL;
BOOLEAN
InitializeBiosDisks(VOID);
PCHAR
GetHarddiskIdentifier(UCHAR DriveNumber);
/* FUNCTIONS *****************************************************************/
@ -351,19 +350,29 @@ DetectBiosFloppyController(PCONFIGURATION_COMPONENT_DATA BusKey)
return ControllerKey;
}
PCONFIGURATION_COMPONENT_DATA
DetectSystem(VOID)
VOID
DetectBiosDisks(PCONFIGURATION_COMPONENT_DATA SystemKey,
PCONFIGURATION_COMPONENT_DATA BusKey)
{
PCONFIGURATION_COMPONENT_DATA SystemKey;
PCONFIGURATION_COMPONENT_DATA ControllerKey, DiskKey;
PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
PCM_INT13_DRIVE_PARAMETER Int13Drives;
GEOMETRY Geometry;
UCHAR DiskCount;
UCHAR DiskCount, DriveNumber;
USHORT i;
ULONG Size;
/* The pre-enumeration of the BIOS disks was already done in InitializeBootDevices() */
DiskCount = PcBiosDiskCount;
/* Use the floppy disk controller as our controller */
ControllerKey = DetectBiosFloppyController(BusKey);
if (!ControllerKey)
{
ERR("Failed to detect BIOS disk controller\n");
return;
}
/* Allocate resource descriptor */
Size = sizeof(CM_PARTIAL_RESOURCE_LIST) +
sizeof(CM_INT13_DRIVE_PARAMETER) * DiskCount;
@ -371,7 +380,7 @@ DetectSystem(VOID)
if (PartialResourceList == NULL)
{
ERR("Failed to allocate resource descriptor\n");
return NULL;
return;
}
/* Initialize resource descriptor */
@ -389,16 +398,18 @@ DetectSystem(VOID)
Int13Drives = (PVOID)(((ULONG_PTR)PartialResourceList) + sizeof(CM_PARTIAL_RESOURCE_LIST));
for (i = 0; i < DiskCount; i++)
{
if (MachDiskGetDriveGeometry(0x80 + i, &Geometry))
DriveNumber = 0x80 + i;
if (MachDiskGetDriveGeometry(DriveNumber, &Geometry))
{
Int13Drives[i].DriveSelect = 0x80 + i;
Int13Drives[i].DriveSelect = DriveNumber;
Int13Drives[i].MaxCylinders = Geometry.Cylinders - 1;
Int13Drives[i].SectorsPerTrack = (USHORT)Geometry.Sectors;
Int13Drives[i].MaxHeads = (USHORT)Geometry.Heads - 1;
Int13Drives[i].NumberDrives = DiskCount;
TRACE("Disk %x: %u Cylinders %u Heads %u Sectors %u Bytes\n",
0x80 + i,
DriveNumber,
Geometry.Cylinders - 1,
Geometry.Heads - 1,
Geometry.Sectors,
@ -406,47 +417,15 @@ DetectSystem(VOID)
}
}
FldrCreateComponentKey(NULL,
SystemClass,
MaximumType,
0x0,
0x0,
0xFFFFFFFF,
NULL,
PartialResourceList,
Size,
&SystemKey);
return SystemKey;
}
extern PCM_PARTIAL_RESOURCE_LIST
PcGetHarddiskConfigurationData(UCHAR DriveNumber, ULONG* pSize);
#define GetHarddiskConfigurationData PcGetHarddiskConfigurationData
// static
VOID
DetectBiosDisks(PCONFIGURATION_COMPONENT_DATA BusKey)
{
PCONFIGURATION_COMPONENT_DATA ControllerKey, DiskKey;
ULONG i;
/* Use the floppy disk controller as our controller */
ControllerKey = DetectBiosFloppyController(BusKey);
if (!ControllerKey)
{
ERR("Failed to detect BIOS disk controller\n");
return;
}
/* Update the 'System' key's configuration data with BIOS INT13h information */
FldrSetConfigurationData(SystemKey, PartialResourceList, Size);
/* Create and fill subkey for each harddisk */
for (i = 0; i < PcBiosDiskCount; i++)
for (i = 0; i < DiskCount; i++)
{
PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
ULONG Size;
PCHAR Identifier;
UCHAR DriveNumber = 0x80 + (UCHAR)i;
DriveNumber = 0x80 + i;
/* Get disk values */
PartialResourceList = GetHarddiskConfigurationData(DriveNumber, &Size);

View file

@ -26,6 +26,10 @@
DBG_DEFAULT_CHANNEL(HWDETECT);
/*
* This is the common code for harddisk for both the PC and the XBOX.
*/
typedef struct tagDISKCONTEXT
{
UCHAR DriveNumber;
@ -49,8 +53,7 @@ SIZE_T DiskReadBufferSize;
/* FUNCTIONS *****************************************************************/
// static
ARC_STATUS
static ARC_STATUS
DiskClose(ULONG FileId)
{
DISKCONTEXT* Context = FsGetDeviceSpecific(FileId);
@ -59,8 +62,7 @@ DiskClose(ULONG FileId)
return ESUCCESS;
}
// static
ARC_STATUS
static ARC_STATUS
DiskGetFileInformation(ULONG FileId, FILEINFORMATION* Information)
{
DISKCONTEXT* Context = FsGetDeviceSpecific(FileId);
@ -131,8 +133,7 @@ DiskOpen(CHAR* Path, OPENMODE OpenMode, ULONG* FileId)
return ESUCCESS;
}
// static
ARC_STATUS
static ARC_STATUS
DiskRead(ULONG FileId, VOID* Buffer, ULONG N, ULONG* Count)
{
DISKCONTEXT* Context = FsGetDeviceSpecific(FileId);
@ -177,8 +178,7 @@ DiskRead(ULONG FileId, VOID* Buffer, ULONG N, ULONG* Count)
return (!ret) ? EIO : ESUCCESS;
}
// static
ARC_STATUS
static ARC_STATUS
DiskSeek(ULONG FileId, LARGE_INTEGER* Position, SEEKMODE SeekMode)
{
DISKCONTEXT* Context = FsGetDeviceSpecific(FileId);
@ -203,15 +203,13 @@ static const DEVVTBL DiskVtbl =
PCHAR
GetHarddiskIdentifier(
UCHAR DriveNumber)
GetHarddiskIdentifier(UCHAR DriveNumber)
{
return PcDiskIdentifier[DriveNumber - 0x80];
}
VOID
GetHarddiskInformation(
UCHAR DriveNumber)
static VOID
GetHarddiskInformation(UCHAR DriveNumber)
{
PMASTER_BOOT_RECORD Mbr;
PULONG Buffer;
@ -330,6 +328,7 @@ PcInitializeBootDevices(VOID)
break;
}
/* Cache the BIOS hard disk information for later use */
GetHarddiskInformation(DriveNumber);
/* Check if we have seen the boot drive */

View file

@ -78,9 +78,9 @@ DBG_DEFAULT_CHANNEL(HWDETECT);
#define CONTROLLER_TIMEOUT 250
// NOTE: Similar to xboxhw.c!XboxGetHarddiskConfigurationData(),
// NOTE: Similar to machxbox.c!XboxGetHarddiskConfigurationData(),
// but with extended geometry support.
// static
static
PCM_PARTIAL_RESOURCE_LIST
PcGetHarddiskConfigurationData(UCHAR DriveNumber, ULONG* pSize)
{
@ -811,7 +811,7 @@ DetectParallelPorts(PCONFIGURATION_COMPONENT_DATA BusKey)
TRACE("DetectParallelPorts() done\n");
}
//static
// static
BOOLEAN
DetectKeyboardDevice(VOID)
{
@ -1252,9 +1252,6 @@ DetectDisplayController(PCONFIGURATION_COMPONENT_DATA BusKey)
}
}
extern VOID
DetectBiosDisks(PCONFIGURATION_COMPONENT_DATA BusKey);
static
VOID
DetectIsaBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
@ -1295,7 +1292,7 @@ DetectIsaBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
(*BusNumber)++;
/* Detect ISA/BIOS devices */
DetectBiosDisks(BusKey);
DetectBiosDisks(SystemKey, BusKey);
DetectSerialPorts(BusKey);
DetectParallelPorts(BusKey);
DetectKeyboardController(BusKey);
@ -1305,9 +1302,6 @@ DetectIsaBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
/* FIXME: Detect more ISA devices */
}
extern PCONFIGURATION_COMPONENT_DATA
DetectSystem(VOID);
PCONFIGURATION_COMPONENT_DATA
PcHwDetect(VOID)
{
@ -1317,7 +1311,10 @@ PcHwDetect(VOID)
TRACE("DetectHardware()\n");
/* Create the 'System' key */
SystemKey = DetectSystem();
FldrCreateSystemKey(&SystemKey);
// TODO: Discover and set the machine type as the Component->Identifier
GetHarddiskConfigurationData = PcGetHarddiskConfigurationData;
/* Detect buses */
DetectPciBios(SystemKey, &BusNumber);
@ -1326,6 +1323,9 @@ PcHwDetect(VOID)
DetectIsaBios(SystemKey, &BusNumber); // TODO: Detect first EISA or MCA, before ISA
DetectAcpiBios(SystemKey, &BusNumber);
// TODO: Collect the ROM blocks from 0xC0000 to 0xF0000 and append their
// CM_ROM_BLOCK data into the 'System' key's configuration data.
TRACE("DetectHardware() Done\n");
return SystemKey;
}
@ -1387,6 +1387,8 @@ PcMachInit(const char *CmdLine)
MachVtbl.InitializeBootDevices = PcInitializeBootDevices;
MachVtbl.HwDetect = PcHwDetect;
MachVtbl.HwIdle = PcHwIdle;
// DiskGetPartitionEntry = DiskGetMbrPartitionEntry; // Default
}
VOID

View file

@ -24,23 +24,7 @@
DBG_DEFAULT_CHANNEL(HWDETECT);
static CHAR Hex[] = "0123456789ABCDEF";
extern ULONG reactos_disk_count;
extern ARC_DISK_SIGNATURE_EX reactos_arc_disk_info[];
typedef struct tagDISKCONTEXT
{
UCHAR DriveNumber;
ULONG SectorSize;
ULONGLONG SectorOffset;
ULONGLONG SectorCount;
ULONGLONG SectorNumber;
} DISKCONTEXT;
// NOTE: Similar to hardware.c!PcGetHarddiskConfigurationData(),
// NOTE: Similar to machpc.c!PcGetHarddiskConfigurationData(),
// but without extended geometry support.
static
PCM_PARTIAL_RESOURCE_LIST
@ -111,302 +95,6 @@ XboxGetHarddiskConfigurationData(UCHAR DriveNumber, ULONG* pSize)
return PartialResourceList;
}
#define GetHarddiskConfigurationData XboxGetHarddiskConfigurationData
extern ARC_STATUS
DiskClose(ULONG FileId);
extern ARC_STATUS
DiskGetFileInformation(ULONG FileId, FILEINFORMATION* Information);
static
ARC_STATUS
DiskOpen(CHAR* Path, OPENMODE OpenMode, ULONG* FileId)
{
DISKCONTEXT* Context;
ULONG DrivePartition, SectorSize;
UCHAR DriveNumber;
ULONGLONG SectorOffset = 0;
ULONGLONG SectorCount = 0;
PARTITION_TABLE_ENTRY PartitionTableEntry;
CHAR FileName[1];
if (!DissectArcPath(Path, FileName, &DriveNumber, &DrivePartition))
return EINVAL;
if (DrivePartition == 0xff)
{
/* This is a CD-ROM device */
SectorSize = 2048;
}
else
{
/* This is either a floppy disk device (DrivePartition == 0) or
* a hard disk device (DrivePartition != 0 && DrivePartition != 0xFF) but
* it doesn't matter which one because they both have 512 bytes per sector */
SectorSize = 512;
}
if (DrivePartition != 0xff && DrivePartition != 0)
{
if (!XboxDiskGetPartitionEntry(DriveNumber, DrivePartition, &PartitionTableEntry))
return EINVAL;
SectorOffset = PartitionTableEntry.SectorCountBeforePartition;
SectorCount = PartitionTableEntry.PartitionSectorCount;
}
else
{
SectorCount = 0; /* FIXME */
}
Context = FrLdrTempAlloc(sizeof(DISKCONTEXT), TAG_HW_DISK_CONTEXT);
if (!Context)
return ENOMEM;
Context->DriveNumber = DriveNumber;
Context->SectorSize = SectorSize;
Context->SectorOffset = SectorOffset;
Context->SectorCount = SectorCount;
Context->SectorNumber = 0;
FsSetDeviceSpecific(*FileId, Context);
return ESUCCESS;
}
extern ARC_STATUS
DiskRead(ULONG FileId, VOID* Buffer, ULONG N, ULONG* Count);
extern ARC_STATUS
DiskSeek(ULONG FileId, LARGE_INTEGER* Position, SEEKMODE SeekMode);
static const DEVVTBL DiskVtbl =
{
DiskClose,
DiskGetFileInformation,
DiskOpen,
DiskRead,
DiskSeek,
};
static
VOID
GetHarddiskIdentifier(PCHAR Identifier,
UCHAR DriveNumber)
{
PMASTER_BOOT_RECORD Mbr;
PULONG Buffer;
ULONG i;
ULONG Checksum;
ULONG Signature;
CHAR ArcName[MAX_PATH];
PARTITION_TABLE_ENTRY PartitionTableEntry;
/* Read the MBR */
if (!MachDiskReadLogicalSectors(DriveNumber, 0ULL, 1, DiskReadBuffer))
{
ERR("Reading MBR failed\n");
return;
}
Buffer = (ULONG*)DiskReadBuffer;
Mbr = (PMASTER_BOOT_RECORD)DiskReadBuffer;
Signature = Mbr->Signature;
TRACE("Signature: %x\n", Signature);
/* Calculate the MBR checksum */
Checksum = 0;
for (i = 0; i < 512 / sizeof(ULONG); i++)
{
Checksum += Buffer[i];
}
Checksum = ~Checksum + 1;
TRACE("Checksum: %x\n", Checksum);
/* Fill out the ARC disk block */
reactos_arc_disk_info[reactos_disk_count].DiskSignature.Signature = Signature;
reactos_arc_disk_info[reactos_disk_count].DiskSignature.CheckSum = Checksum;
sprintf(ArcName, "multi(0)disk(0)rdisk(%lu)", reactos_disk_count);
strcpy(reactos_arc_disk_info[reactos_disk_count].ArcName, ArcName);
reactos_arc_disk_info[reactos_disk_count].DiskSignature.ArcName =
reactos_arc_disk_info[reactos_disk_count].ArcName;
reactos_disk_count++;
sprintf(ArcName, "multi(0)disk(0)rdisk(%u)partition(0)", DriveNumber - 0x80);
FsRegisterDevice(ArcName, &DiskVtbl);
/* Add partitions */
i = 1;
DiskReportError(FALSE);
while (XboxDiskGetPartitionEntry(DriveNumber, i, &PartitionTableEntry))
{
if (PartitionTableEntry.SystemIndicator != PARTITION_ENTRY_UNUSED)
{
sprintf(ArcName, "multi(0)disk(0)rdisk(%u)partition(%lu)", DriveNumber - 0x80, i);
FsRegisterDevice(ArcName, &DiskVtbl);
}
i++;
}
DiskReportError(TRUE);
/* Convert checksum and signature to identifier string */
Identifier[0] = Hex[(Checksum >> 28) & 0x0F];
Identifier[1] = Hex[(Checksum >> 24) & 0x0F];
Identifier[2] = Hex[(Checksum >> 20) & 0x0F];
Identifier[3] = Hex[(Checksum >> 16) & 0x0F];
Identifier[4] = Hex[(Checksum >> 12) & 0x0F];
Identifier[5] = Hex[(Checksum >> 8) & 0x0F];
Identifier[6] = Hex[(Checksum >> 4) & 0x0F];
Identifier[7] = Hex[Checksum & 0x0F];
Identifier[8] = '-';
Identifier[9] = Hex[(Signature >> 28) & 0x0F];
Identifier[10] = Hex[(Signature >> 24) & 0x0F];
Identifier[11] = Hex[(Signature >> 20) & 0x0F];
Identifier[12] = Hex[(Signature >> 16) & 0x0F];
Identifier[13] = Hex[(Signature >> 12) & 0x0F];
Identifier[14] = Hex[(Signature >> 8) & 0x0F];
Identifier[15] = Hex[(Signature >> 4) & 0x0F];
Identifier[16] = Hex[Signature & 0x0F];
Identifier[17] = '-';
Identifier[18] = 'A';
Identifier[19] = 0;
TRACE("Identifier: %s\n", Identifier);
}
static
VOID
DetectBiosDisks(PCONFIGURATION_COMPONENT_DATA SystemKey,
PCONFIGURATION_COMPONENT_DATA BusKey)
{
PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
PCM_INT13_DRIVE_PARAMETER Int13Drives;
GEOMETRY Geometry;
PCONFIGURATION_COMPONENT_DATA DiskKey, ControllerKey;
UCHAR DiskCount;
ULONG i;
ULONG Size;
BOOLEAN Changed;
/* Count the number of visible drives */
DiskReportError(FALSE);
DiskCount = 0;
/* There are some really broken BIOSes out there. There are even BIOSes
* that happily report success when you ask them to read from non-existent
* harddisks. So, we set the buffer to known contents first, then try to
* read. If the BIOS reports success but the buffer contents haven't
* changed then we fail anyway */
memset(DiskReadBuffer, 0xcd, DiskReadBufferSize);
while (MachDiskReadLogicalSectors(0x80 + DiskCount, 0ULL, 1, DiskReadBuffer))
{
Changed = FALSE;
for (i = 0; ! Changed && i < DiskReadBufferSize; i++)
{
Changed = ((PUCHAR)DiskReadBuffer)[i] != 0xcd;
}
if (! Changed)
{
TRACE("BIOS reports success for disk %d but data didn't change\n",
(int)DiskCount);
break;
}
DiskCount++;
memset(DiskReadBuffer, 0xcd, DiskReadBufferSize);
}
DiskReportError(TRUE);
TRACE("BIOS reports %d harddisk%s\n",
(int)DiskCount, (DiskCount == 1) ? "" : "s");
//DetectBiosFloppyController(BusKey);
/* Allocate resource descriptor */
Size = sizeof(CM_PARTIAL_RESOURCE_LIST) +
sizeof(CM_INT13_DRIVE_PARAMETER) * DiskCount;
PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
if (PartialResourceList == NULL)
{
ERR("Failed to allocate resource descriptor\n");
return;
}
/* Initialize resource descriptor */
memset(PartialResourceList, 0, Size);
PartialResourceList->Version = 1;
PartialResourceList->Revision = 1;
PartialResourceList->Count = 1;
PartialResourceList->PartialDescriptors[0].Type = CmResourceTypeDeviceSpecific;
PartialResourceList->PartialDescriptors[0].ShareDisposition = 0;
PartialResourceList->PartialDescriptors[0].Flags = 0;
PartialResourceList->PartialDescriptors[0].u.DeviceSpecificData.DataSize =
sizeof(CM_INT13_DRIVE_PARAMETER) * DiskCount;
/* Get harddisk Int13 geometry data */
Int13Drives = (PVOID)(((ULONG_PTR)PartialResourceList) + sizeof(CM_PARTIAL_RESOURCE_LIST));
for (i = 0; i < DiskCount; i++)
{
if (MachDiskGetDriveGeometry(0x80 + i, &Geometry))
{
Int13Drives[i].DriveSelect = 0x80 + i;
Int13Drives[i].MaxCylinders = Geometry.Cylinders - 1;
Int13Drives[i].SectorsPerTrack = (USHORT)Geometry.Sectors;
Int13Drives[i].MaxHeads = (USHORT)Geometry.Heads - 1;
Int13Drives[i].NumberDrives = DiskCount;
TRACE(
"Disk %x: %u Cylinders %u Heads %u Sectors %u Bytes\n",
0x80 + i,
Geometry.Cylinders - 1,
Geometry.Heads - 1,
Geometry.Sectors,
Geometry.BytesPerSector);
}
}
FldrCreateComponentKey(BusKey,
ControllerClass,
DiskController,
Output | Input,
0,
0xFFFFFFFF,
NULL,
PartialResourceList,
Size,
&ControllerKey);
TRACE("Created key: DiskController\\0\n");
/* Create and fill subkey for each harddisk */
for (i = 0; i < DiskCount; i++)
{
CHAR Identifier[20];
/* Get disk values */
PartialResourceList = GetHarddiskConfigurationData(0x80 + i, &Size);
GetHarddiskIdentifier(Identifier, 0x80 + i);
/* Create disk key */
FldrCreateComponentKey(ControllerKey,
PeripheralClass,
DiskPeripheral,
Output | Input,
0,
0xFFFFFFFF,
Identifier,
PartialResourceList,
Size,
&DiskKey);
}
}
BOOLEAN
XboxInitializeBootDevices(VOID)
{
// Emulate old behavior
return XboxHwDetect() != NULL;
}
static
VOID
DetectIsaBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
@ -463,6 +151,8 @@ XboxHwDetect(VOID)
/* Create the 'System' key */
FldrCreateSystemKey(&SystemKey);
GetHarddiskConfigurationData = XboxGetHarddiskConfigurationData;
/* TODO: Build actual xbox's hardware configuration tree */
DetectIsaBios(SystemKey, &BusNumber);
@ -515,6 +205,8 @@ XboxMachInit(const char *CmdLine)
MachVtbl.HwDetect = XboxHwDetect;
MachVtbl.HwIdle = XboxHwIdle;
DiskGetPartitionEntry = XboxDiskGetPartitionEntry;
/* Set LEDs to orange after init */
XboxSetLED("oooo");
}

View file

@ -175,7 +175,6 @@ static struct
(WRITE_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_DEV_CNTRL), (Data)))
/* IDE_DRIVE_IDENTIFY */
typedef struct _IDE_DRIVE_IDENTIFY
{
USHORT ConfigBits; /*00*/
@ -494,8 +493,8 @@ XboxDiskGetPartitionEntry(UCHAR DriveNumber, ULONG PartitionNumber, PPARTITION_T
}
}
/* No magic Xbox partitions. Maybe there's a MBR */
return DiskGetPartitionEntry(DriveNumber, PartitionNumber, PartitionTableEntry);
/* No magic Xbox partitions, maybe there's a MBR */
return DiskGetMbrPartitionEntry(DriveNumber, PartitionNumber, PartitionTableEntry);
}
BOOLEAN

View file

@ -17,19 +17,29 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/*
* TODO: This is here where we should add support for GPT partitions
* as well as partitionless disks!
*/
#ifndef _M_ARM
#include <freeldr.h>
#define NDEBUG
#include <debug.h>
DBG_DEFAULT_CHANNEL(DISK);
/* This function serves to retrieve a partition entry for devices that handle partitions differently */
DISK_GET_PARTITION_ENTRY DiskGetPartitionEntry = DiskGetMbrPartitionEntry;
BOOLEAN DiskGetActivePartitionEntry(UCHAR DriveNumber,
PPARTITION_TABLE_ENTRY PartitionTableEntry,
ULONG *ActivePartition)
PPARTITION_TABLE_ENTRY PartitionTableEntry,
ULONG *ActivePartition)
{
ULONG BootablePartitionCount = 0;
ULONG CurrentPartitionNumber;
ULONG Index;
ULONG BootablePartitionCount = 0;
ULONG CurrentPartitionNumber;
ULONG Index;
MASTER_BOOT_RECORD MasterBootRecord;
PPARTITION_TABLE_ENTRY ThisPartitionTableEntry;
@ -81,15 +91,15 @@ BOOLEAN DiskGetActivePartitionEntry(UCHAR DriveNumber,
return TRUE;
}
BOOLEAN DiskGetPartitionEntry(UCHAR DriveNumber, ULONG PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry)
BOOLEAN DiskGetMbrPartitionEntry(UCHAR DriveNumber, ULONG PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry)
{
MASTER_BOOT_RECORD MasterBootRecord;
PARTITION_TABLE_ENTRY ExtendedPartitionTableEntry;
ULONG ExtendedPartitionNumber;
ULONG ExtendedPartitionOffset;
ULONG Index;
ULONG CurrentPartitionNumber;
PPARTITION_TABLE_ENTRY ThisPartitionTableEntry;
MASTER_BOOT_RECORD MasterBootRecord;
PARTITION_TABLE_ENTRY ExtendedPartitionTableEntry;
ULONG ExtendedPartitionNumber;
ULONG ExtendedPartitionOffset;
ULONG Index;
ULONG CurrentPartitionNumber;
PPARTITION_TABLE_ENTRY ThisPartitionTableEntry;
// Read master boot record
if (!DiskReadBootRecord(DriveNumber, 0, &MasterBootRecord))
@ -101,7 +111,7 @@ BOOLEAN DiskGetPartitionEntry(UCHAR DriveNumber, ULONG PartitionNumber, PPARTITI
for (Index=0; Index<4; Index++)
{
ThisPartitionTableEntry = &MasterBootRecord.PartitionTable[Index];
if (ThisPartitionTableEntry->SystemIndicator != PARTITION_ENTRY_UNUSED &&
ThisPartitionTableEntry->SystemIndicator != PARTITION_EXTENDED &&
ThisPartitionTableEntry->SystemIndicator != PARTITION_XINT13_EXTENDED)
@ -166,7 +176,7 @@ BOOLEAN DiskGetPartitionEntry(UCHAR DriveNumber, ULONG PartitionNumber, PPARTITI
BOOLEAN DiskGetFirstPartitionEntry(PMASTER_BOOT_RECORD MasterBootRecord, PPARTITION_TABLE_ENTRY PartitionTableEntry)
{
ULONG Index;
ULONG Index;
for (Index=0; Index<4; Index++)
{
@ -187,7 +197,7 @@ BOOLEAN DiskGetFirstPartitionEntry(PMASTER_BOOT_RECORD MasterBootRecord, PPARTIT
BOOLEAN DiskGetFirstExtendedPartitionEntry(PMASTER_BOOT_RECORD MasterBootRecord, PPARTITION_TABLE_ENTRY PartitionTableEntry)
{
ULONG Index;
ULONG Index;
for (Index=0; Index<4; Index++)
{

View file

@ -57,7 +57,6 @@ ULONG XboxDiskGetCacheableBlockCount(UCHAR DriveNumber);
TIMEINFO* XboxGetTime(VOID);
BOOLEAN XboxInitializeBootDevices(VOID);
PCONFIGURATION_COMPONENT_DATA XboxHwDetect(VOID);
VOID XboxHwIdle(VOID);

View file

@ -23,17 +23,25 @@
#define CONFIG_CMD(bus, dev_fn, where) \
(0x80000000 | (((ULONG)(bus)) << 16) | (((dev_fn) & 0x1F) << 11) | (((dev_fn) & 0xE0) << 3) | ((where) & ~3))
#define TAG_HW_RESOURCE_LIST 'lRwH'
#define TAG_HW_DISK_CONTEXT 'cDwH'
#define TAG_HW_RESOURCE_LIST 'lRwH'
#define TAG_HW_DISK_CONTEXT 'cDwH'
/* PROTOTYPES ***************************************************************/
/* hardware.c */
VOID StallExecutionProcessor(ULONG Microseconds);
VOID HalpCalibrateStallExecution(VOID);
typedef
PCM_PARTIAL_RESOURCE_LIST
(*GET_HARDDISK_CONFIG_DATA)(UCHAR DriveNumber, ULONG* pSize);
extern GET_HARDDISK_CONFIG_DATA GetHarddiskConfigurationData;
VOID
DetectBiosDisks(PCONFIGURATION_COMPONENT_DATA SystemKey,
PCONFIGURATION_COMPONENT_DATA BusKey);
/* hwacpi.c */
VOID DetectAcpiBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber);

View file

@ -54,7 +54,6 @@ BOOLEAN DiskGetExtendedDriveParameters(UCHAR DriveNumber, PVOID Buffer, USHORT B
BOOLEAN PcDiskGetBootPath(OUT PCHAR BootPath, IN ULONG Size);
BOOLEAN PcDiskReadLogicalSectors(UCHAR DriveNumber, ULONGLONG SectorNumber, ULONG SectorCount, PVOID Buffer);
BOOLEAN PcDiskGetPartitionEntry(UCHAR DriveNumber, ULONG PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry);
BOOLEAN PcDiskGetDriveGeometry(UCHAR DriveNumber, PGEOMETRY DriveGeometry);
ULONG PcDiskGetCacheableBlockCount(UCHAR DriveNumber);

View file

@ -138,8 +138,19 @@ BOOLEAN DiskGetBootPath(OUT PCHAR BootPath, IN ULONG Size);
// Fixed Disk Partition Management Functions
//
///////////////////////////////////////////////////////////////////////////////////////
/* Signature of DiskGetPartitionEntry(...) */
typedef
BOOLEAN
(*DISK_GET_PARTITION_ENTRY)(UCHAR DriveNumber,
ULONG PartitionNumber,
PPARTITION_TABLE_ENTRY PartitionTableEntry);
/* This function serves to retrieve a partition entry for devices that handle partitions differently */
extern DISK_GET_PARTITION_ENTRY DiskGetPartitionEntry;
BOOLEAN DiskGetActivePartitionEntry(UCHAR DriveNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry, ULONG *ActivePartition);
BOOLEAN DiskGetPartitionEntry(UCHAR DriveNumber, ULONG PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry);
BOOLEAN DiskGetMbrPartitionEntry(UCHAR DriveNumber, ULONG PartitionNumber, PPARTITION_TABLE_ENTRY PartitionTableEntry);
BOOLEAN DiskGetFirstPartitionEntry(PMASTER_BOOT_RECORD MasterBootRecord, PPARTITION_TABLE_ENTRY PartitionTableEntry);
BOOLEAN DiskGetFirstExtendedPartitionEntry(PMASTER_BOOT_RECORD MasterBootRecord, PPARTITION_TABLE_ENTRY PartitionTableEntry);
BOOLEAN DiskReadBootRecord(UCHAR DriveNumber, ULONGLONG LogicalSectorNumber, PMASTER_BOOT_RECORD BootRecord);