Author: hbelusca
Date: Sun Jan 29 02:35:28 2017
New Revision: 73618
URL:
http://svn.reactos.org/svn/reactos?rev=73618&view=rev
Log:
[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.
Modified:
trunk/reactos/boot/freeldr/freeldr/arch/i386/hardware.c
trunk/reactos/boot/freeldr/freeldr/arch/i386/hwdisk.c
trunk/reactos/boot/freeldr/freeldr/arch/i386/machpc.c
trunk/reactos/boot/freeldr/freeldr/arch/i386/machxbox.c
trunk/reactos/boot/freeldr/freeldr/arch/i386/xboxdisk.c
trunk/reactos/boot/freeldr/freeldr/disk/partition.c
trunk/reactos/boot/freeldr/freeldr/include/arch/i386/machxbox.h
trunk/reactos/boot/freeldr/freeldr/include/arch/pc/hardware.h
trunk/reactos/boot/freeldr/freeldr/include/arch/pc/machpc.h
trunk/reactos/boot/freeldr/freeldr/include/disk.h
Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/hardware.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/i386/hardware.c [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/arch/i386/hardware.c [iso-8859-1] Sun Jan 29
02:35:28 2017
@@ -37,12 +37,11 @@
static unsigned int delay_count = 1;
extern UCHAR PcBiosDiskCount;
+/* This function is slightly different in its PC and XBOX versions */
+GET_HARDDISK_CONFIG_DATA GetHarddiskConfigurationData = NULL;
+
PCHAR
-GetHarddiskIdentifier(
- UCHAR DriveNumber);
-
-BOOLEAN
-InitializeBiosDisks(VOID);
+GetHarddiskIdentifier(UCHAR DriveNumber);
/* FUNCTIONS *****************************************************************/
@@ -351,18 +350,28 @@
return ControllerKey;
}
-PCONFIGURATION_COMPONENT_DATA
-DetectSystem(VOID)
-{
- PCONFIGURATION_COMPONENT_DATA SystemKey;
+VOID
+DetectBiosDisks(PCONFIGURATION_COMPONENT_DATA SystemKey,
+ PCONFIGURATION_COMPONENT_DATA BusKey)
+{
+ 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) +
@@ -371,7 +380,7 @@
if (PartialResourceList == NULL)
{
ERR("Failed to allocate resource descriptor\n");
- return NULL;
+ return;
}
/* Initialize resource descriptor */
@@ -389,16 +398,18 @@
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 @@
}
}
- 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++)
- {
- PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
- ULONG Size;
+ for (i = 0; i < DiskCount; i++)
+ {
PCHAR Identifier;
- UCHAR DriveNumber = 0x80 + (UCHAR)i;
+
+ DriveNumber = 0x80 + i;
/* Get disk values */
PartialResourceList = GetHarddiskConfigurationData(DriveNumber, &Size);
Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/hwdisk.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/i386/hwdisk.c [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/arch/i386/hwdisk.c [iso-8859-1] Sun Jan 29 02:35:28
2017
@@ -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 @@
/* FUNCTIONS *****************************************************************/
-// static
-ARC_STATUS
+static ARC_STATUS
DiskClose(ULONG FileId)
{
DISKCONTEXT* Context = FsGetDeviceSpecific(FileId);
@@ -59,8 +62,7 @@
return ESUCCESS;
}
-// static
-ARC_STATUS
+static ARC_STATUS
DiskGetFileInformation(ULONG FileId, FILEINFORMATION* Information)
{
DISKCONTEXT* Context = FsGetDeviceSpecific(FileId);
@@ -131,8 +133,7 @@
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 @@
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 @@
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 @@
break;
}
+ /* Cache the BIOS hard disk information for later use */
GetHarddiskInformation(DriveNumber);
/* Check if we have seen the boot drive */
Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/machpc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/i386/machpc.c [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/arch/i386/machpc.c [iso-8859-1] Sun Jan 29 02:35:28
2017
@@ -78,9 +78,9 @@
#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 @@
TRACE("DetectParallelPorts() done\n");
}
-//static
+// static
BOOLEAN
DetectKeyboardDevice(VOID)
{
@@ -1252,9 +1252,6 @@
}
}
-extern VOID
-DetectBiosDisks(PCONFIGURATION_COMPONENT_DATA BusKey);
-
static
VOID
DetectIsaBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
@@ -1295,7 +1292,7 @@
(*BusNumber)++;
/* Detect ISA/BIOS devices */
- DetectBiosDisks(BusKey);
+ DetectBiosDisks(SystemKey, BusKey);
DetectSerialPorts(BusKey);
DetectParallelPorts(BusKey);
DetectKeyboardController(BusKey);
@@ -1305,9 +1302,6 @@
/* FIXME: Detect more ISA devices */
}
-extern PCONFIGURATION_COMPONENT_DATA
-DetectSystem(VOID);
-
PCONFIGURATION_COMPONENT_DATA
PcHwDetect(VOID)
{
@@ -1317,7 +1311,10 @@
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);
@@ -1325,6 +1322,9 @@
DetectPnpBios(SystemKey, &BusNumber);
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 @@
MachVtbl.InitializeBootDevices = PcInitializeBootDevices;
MachVtbl.HwDetect = PcHwDetect;
MachVtbl.HwIdle = PcHwIdle;
+
+ // DiskGetPartitionEntry = DiskGetMbrPartitionEntry; // Default
}
VOID
Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/machxbox.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/i386/machxbox.c [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/arch/i386/machxbox.c [iso-8859-1] Sun Jan 29
02:35:28 2017
@@ -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
@@ -110,302 +94,6 @@
*pSize = Size;
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
@@ -462,6 +150,8 @@
/* Create the 'System' key */
FldrCreateSystemKey(&SystemKey);
+
+ GetHarddiskConfigurationData = XboxGetHarddiskConfigurationData;
/* TODO: Build actual xbox's hardware configuration tree */
DetectIsaBios(SystemKey, &BusNumber);
@@ -515,6 +205,8 @@
MachVtbl.HwDetect = XboxHwDetect;
MachVtbl.HwIdle = XboxHwIdle;
+ DiskGetPartitionEntry = XboxDiskGetPartitionEntry;
+
/* Set LEDs to orange after init */
XboxSetLED("oooo");
}
Modified: trunk/reactos/boot/freeldr/freeldr/arch/i386/xboxdisk.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/arch/…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/arch/i386/xboxdisk.c [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/arch/i386/xboxdisk.c [iso-8859-1] Sun Jan 29
02:35:28 2017
@@ -175,7 +175,6 @@
(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 @@
}
}
- /* 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
Modified: trunk/reactos/boot/freeldr/freeldr/disk/partition.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/disk/…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/disk/partition.c [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/disk/partition.c [iso-8859-1] Sun Jan 29 02:35:28
2017
@@ -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)
-{
- ULONG BootablePartitionCount = 0;
- ULONG CurrentPartitionNumber;
- ULONG Index;
+ PPARTITION_TABLE_ENTRY PartitionTableEntry,
+ ULONG *ActivePartition)
+{
+ ULONG BootablePartitionCount = 0;
+ ULONG CurrentPartitionNumber;
+ ULONG Index;
MASTER_BOOT_RECORD MasterBootRecord;
PPARTITION_TABLE_ENTRY ThisPartitionTableEntry;
@@ -81,15 +91,15 @@
return TRUE;
}
-BOOLEAN DiskGetPartitionEntry(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;
+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;
// Read master boot record
if (!DiskReadBootRecord(DriveNumber, 0, &MasterBootRecord))
@@ -101,7 +111,7 @@
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 DiskGetFirstPartitionEntry(PMASTER_BOOT_RECORD MasterBootRecord,
PPARTITION_TABLE_ENTRY PartitionTableEntry)
{
- ULONG Index;
+ ULONG Index;
for (Index=0; Index<4; Index++)
{
@@ -187,7 +197,7 @@
BOOLEAN DiskGetFirstExtendedPartitionEntry(PMASTER_BOOT_RECORD MasterBootRecord,
PPARTITION_TABLE_ENTRY PartitionTableEntry)
{
- ULONG Index;
+ ULONG Index;
for (Index=0; Index<4; Index++)
{
Modified: trunk/reactos/boot/freeldr/freeldr/include/arch/i386/machxbox.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/inclu…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/include/arch/i386/machxbox.h [iso-8859-1]
(original)
+++ trunk/reactos/boot/freeldr/freeldr/include/arch/i386/machxbox.h [iso-8859-1] Sun Jan
29 02:35:28 2017
@@ -57,7 +57,6 @@
TIMEINFO* XboxGetTime(VOID);
-BOOLEAN XboxInitializeBootDevices(VOID);
PCONFIGURATION_COMPONENT_DATA XboxHwDetect(VOID);
VOID XboxHwIdle(VOID);
Modified: trunk/reactos/boot/freeldr/freeldr/include/arch/pc/hardware.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/inclu…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/include/arch/pc/hardware.h [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/include/arch/pc/hardware.h [iso-8859-1] Sun Jan 29
02:35:28 2017
@@ -23,16 +23,24 @@
#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);
-VOID StallExecutionProcessor(ULONG Microseconds);
+typedef
+PCM_PARTIAL_RESOURCE_LIST
+(*GET_HARDDISK_CONFIG_DATA)(UCHAR DriveNumber, ULONG* pSize);
-VOID HalpCalibrateStallExecution(VOID);
+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);
Modified: trunk/reactos/boot/freeldr/freeldr/include/arch/pc/machpc.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/inclu…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/include/arch/pc/machpc.h [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/include/arch/pc/machpc.h [iso-8859-1] Sun Jan 29
02:35:28 2017
@@ -54,7 +54,6 @@
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);
Modified: trunk/reactos/boot/freeldr/freeldr/include/disk.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/inclu…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/include/disk.h [iso-8859-1] (original)
+++ trunk/reactos/boot/freeldr/freeldr/include/disk.h [iso-8859-1] Sun Jan 29 02:35:28
2017
@@ -138,8 +138,19 @@
// 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);