From c08beef1cf6cce3e69696f6f1b32f8e04fc6d448 Mon Sep 17 00:00:00 2001 From: Stanislav Motylkov Date: Fri, 16 Aug 2019 20:14:10 +0300 Subject: [PATCH] [FREELDR] Add PCI BIOS emulation and PCI bus enumeration for Xbox (#1830) CORE-16216 CORE-16308 --- boot/freeldr/freeldr/arch/i386/hwpci.c | 6 ++++-- boot/freeldr/freeldr/arch/i386/machpc.c | 1 + boot/freeldr/freeldr/arch/i386/machxbox.c | 14 ++++++++++++++ boot/freeldr/freeldr/include/arch/pc/hardware.h | 6 ++++++ boot/freeldr/freeldr/include/arch/pc/machpc.h | 1 + 5 files changed, 26 insertions(+), 2 deletions(-) diff --git a/boot/freeldr/freeldr/arch/i386/hwpci.c b/boot/freeldr/freeldr/arch/i386/hwpci.c index 8e6062da061..c5aa14a1333 100644 --- a/boot/freeldr/freeldr/arch/i386/hwpci.c +++ b/boot/freeldr/freeldr/arch/i386/hwpci.c @@ -24,6 +24,8 @@ DBG_DEFAULT_CHANNEL(HWDETECT); +FIND_PCI_BIOS FindPciBios = NULL; + static PPCI_IRQ_ROUTING_TABLE GetPciIrqRoutingTable(VOID) @@ -75,8 +77,8 @@ GetPciIrqRoutingTable(VOID) } -static BOOLEAN -FindPciBios(PPCI_REGISTRY_INFO BusData) +BOOLEAN +PcFindPciBios(PPCI_REGISTRY_INFO BusData) { REGS RegsIn; REGS RegsOut; diff --git a/boot/freeldr/freeldr/arch/i386/machpc.c b/boot/freeldr/freeldr/arch/i386/machpc.c index 0d17add29c6..ede5441dfae 100644 --- a/boot/freeldr/freeldr/arch/i386/machpc.c +++ b/boot/freeldr/freeldr/arch/i386/machpc.c @@ -1353,6 +1353,7 @@ PcHwDetect(VOID) // TODO: Discover and set the machine type as the Component->Identifier GetHarddiskConfigurationData = PcGetHarddiskConfigurationData; + FindPciBios = PcFindPciBios; /* Detect buses */ DetectPciBios(SystemKey, &BusNumber); diff --git a/boot/freeldr/freeldr/arch/i386/machxbox.c b/boot/freeldr/freeldr/arch/i386/machxbox.c index 139f5719251..4b96228f1cf 100644 --- a/boot/freeldr/freeldr/arch/i386/machxbox.c +++ b/boot/freeldr/freeldr/arch/i386/machxbox.c @@ -23,6 +23,18 @@ DBG_DEFAULT_CHANNEL(HWDETECT); +BOOLEAN +XboxFindPciBios(PPCI_REGISTRY_INFO BusData) +{ + /* We emulate PCI BIOS here, there are 2 known working PCI buses on an original Xbox */ + + BusData->NoBuses = 2; + BusData->MajorRevision = 1; + BusData->MinorRevision = 0; + BusData->HardwareMechanism = 1; + return TRUE; +} + VOID XboxGetExtendedBIOSData(PULONG ExtendedBIOSDataArea, PULONG ExtendedBIOSDataSize) { @@ -175,8 +187,10 @@ XboxHwDetect(VOID) FldrCreateSystemKey(&SystemKey); GetHarddiskConfigurationData = XboxGetHarddiskConfigurationData; + FindPciBios = XboxFindPciBios; /* TODO: Build actual xbox's hardware configuration tree */ + DetectPciBios(SystemKey, &BusNumber); DetectIsaBios(SystemKey, &BusNumber); TRACE("DetectHardware() Done\n"); diff --git a/boot/freeldr/freeldr/include/arch/pc/hardware.h b/boot/freeldr/freeldr/include/arch/pc/hardware.h index 76a9bb5feda..bc6aad11971 100644 --- a/boot/freeldr/freeldr/include/arch/pc/hardware.h +++ b/boot/freeldr/freeldr/include/arch/pc/hardware.h @@ -38,6 +38,12 @@ PCM_PARTIAL_RESOURCE_LIST extern GET_HARDDISK_CONFIG_DATA GetHarddiskConfigurationData; +typedef +BOOLEAN +(*FIND_PCI_BIOS)(PPCI_REGISTRY_INFO BusData); + +extern FIND_PCI_BIOS FindPciBios; + VOID DetectBiosDisks(PCONFIGURATION_COMPONENT_DATA SystemKey, PCONFIGURATION_COMPONENT_DATA BusKey); diff --git a/boot/freeldr/freeldr/include/arch/pc/machpc.h b/boot/freeldr/freeldr/include/arch/pc/machpc.h index fb8284fe763..e07eab29a9c 100644 --- a/boot/freeldr/freeldr/include/arch/pc/machpc.h +++ b/boot/freeldr/freeldr/include/arch/pc/machpc.h @@ -49,6 +49,7 @@ VOID PcVideoPrepareForReactOS(VOID); VOID PcPrepareForReactOS(VOID); PFREELDR_MEMORY_DESCRIPTOR PcMemGetMemoryMap(ULONG *MemoryMapSize); +BOOLEAN PcFindPciBios(PPCI_REGISTRY_INFO BusData); BOOLEAN DiskResetController(UCHAR DriveNumber); BOOLEAN DiskGetExtendedDriveParameters(UCHAR DriveNumber, PVOID Buffer, USHORT BufferSize); -- 2.17.1