diff --git a/reactos/hal/halx86/directory.rbuild b/reactos/hal/halx86/directory.rbuild index a1faa7436ad..a56d8e83e52 100644 --- a/reactos/hal/halx86/directory.rbuild +++ b/reactos/hal/halx86/directory.rbuild @@ -4,13 +4,66 @@ - - - - - - - - - + + + + + include + include + + + hal_generic + hal_generic_up + hal_generic_pc + ntoskrnl + + halinit_up.c + halup.rc + + + + + + include + include + + + + hal_generic + hal_generic_pc + ntoskrnl + + apic.c + halinit_mp.c + ioapic.c + ipi_mp.c + mpconfig.c + mps.S + mpsboot.asm + mpsirql.c + processor_mp.c + spinlock.c + halmp.rc + + + + + include + include + + + + hal_generic + hal_generic_up + ntoskrnl + + pci.c + + + halinit_xbox.c + part_xbox.c + halxbox.rc + halxbox.h + + diff --git a/reactos/hal/halx86/generic/bus.c b/reactos/hal/halx86/generic/bus.c index 1bcdb5de362..a35adbe315a 100644 --- a/reactos/hal/halx86/generic/bus.c +++ b/reactos/hal/halx86/generic/bus.c @@ -56,14 +56,14 @@ HalpAssignSlotResources(IN PUNICODE_STRING RegistryPath, BusHandler.BusNumber = BusNumber; /* Call the PCI function */ - return BusHandler.AssignSlotResources(&BusHandler, - &BusHandler, - RegistryPath, - DriverClassName, - DriverObject, - DeviceObject, - SlotNumber, - AllocatedResources); + return HalpAssignPCISlotResources(&BusHandler, + &BusHandler, + RegistryPath, + DriverClassName, + DriverObject, + DeviceObject, + SlotNumber, + AllocatedResources); } BOOLEAN @@ -233,12 +233,12 @@ HalGetBusDataByOffset(IN BUS_DATA_TYPE BusDataType, BusHandler.BusNumber = BusNumber; /* Call PCI function */ - return BusHandler.GetBusData(&BusHandler, - &BusHandler, - *(PPCI_SLOT_NUMBER)&SlotNumber, - Buffer, - Offset, - Length); + return HalpGetPCIData(&BusHandler, + &BusHandler, + *(PPCI_SLOT_NUMBER)&SlotNumber, + Buffer, + Offset, + Length); } /* Invalid bus */ @@ -312,12 +312,12 @@ HalSetBusDataByOffset(IN BUS_DATA_TYPE BusDataType, BusHandler.BusNumber = BusNumber; /* Call PCI function */ - return BusHandler.SetBusData(&BusHandler, - &BusHandler, - *(PPCI_SLOT_NUMBER)&SlotNumber, - Buffer, - Offset, - Length); + return HalpSetPCIData(&BusHandler, + &BusHandler, + *(PPCI_SLOT_NUMBER)&SlotNumber, + Buffer, + Offset, + Length); } /* Invalid bus */ diff --git a/reactos/hal/halx86/generic/generic.rbuild b/reactos/hal/halx86/generic/generic.rbuild index a1bc76e8b19..bf35d302b2d 100644 --- a/reactos/hal/halx86/generic/generic.rbuild +++ b/reactos/hal/halx86/generic/generic.rbuild @@ -12,8 +12,8 @@ dma.c drive.c display.c + halinit.c misc.c - pci.c portio.c profil.c reboot.c @@ -28,8 +28,14 @@ irq.S - halinit.c processor.c spinlock.c + + ../include + include + + + pci.c + diff --git a/reactos/hal/halx86/generic/halinit.c b/reactos/hal/halx86/generic/halinit.c index 6608e60f4b1..21b142a0f28 100644 --- a/reactos/hal/halx86/generic/halinit.c +++ b/reactos/hal/halx86/generic/halinit.c @@ -14,7 +14,6 @@ /* GLOBALS *******************************************************************/ -HALP_HOOKS HalpHooks; BOOLEAN HalpPciLockSettings; /* PRIVATE FUNCTIONS *********************************************************/ diff --git a/reactos/hal/halx86/generic/pci.c b/reactos/hal/halx86/generic/pci.c index b65a86a6abc..11fc3cf6049 100644 --- a/reactos/hal/halx86/generic/pci.c +++ b/reactos/hal/halx86/generic/pci.c @@ -346,6 +346,26 @@ HalpGetPCIData(IN PBUS_HANDLER BusHandler, PPCI_COMMON_CONFIG PciConfig = (PPCI_COMMON_CONFIG)PciBuffer; ULONG Len = 0; +#ifdef SARCH_XBOX + /* Trying to get PCI config data from devices 0:0:1 and 0:0:2 will completely + * hang the Xbox. Also, the device number doesn't seem to be decoded for the + * video card, so it appears to be present on 1:0:0 - 1:31:0. + * We hack around these problems by indicating "device not present" for devices + * 0:0:1, 0:0:2, 1:1:0, 1:2:0, 1:3:0, ...., 1:31:0 */ + if ((0 == BusHandler->BusNumber && 0 == Slot.u.bits.DeviceNumber && + (1 == Slot.u.bits.FunctionNumber || 2 == Slot.u.bits.FunctionNumber)) || + (1 == BusHandler->BusNumber && 0 != Slot.u.bits.DeviceNumber)) + { + DPRINT("Blacklisted PCI slot\n"); + if (0 == Offset && 2 <= Length) + { + *(PUSHORT)Buffer = PCI_INVALID_VENDORID; + return 2; + } + return 0; + } +#endif + /* Normalize the length */ if (Length > sizeof(PCI_COMMON_CONFIG)) Length = sizeof(PCI_COMMON_CONFIG); @@ -417,6 +437,21 @@ HalpSetPCIData(IN PBUS_HANDLER BusHandler, PPCI_COMMON_CONFIG PciConfig = (PPCI_COMMON_CONFIG)PciBuffer; ULONG Len = 0; +#ifdef SARCH_XBOX + /* Trying to get PCI config data from devices 0:0:1 and 0:0:2 will completely + * hang the Xbox. Also, the device number doesn't seem to be decoded for the + * video card, so it appears to be present on 1:0:0 - 1:31:0. + * We hack around these problems by indicating "device not present" for devices + * 0:0:1, 0:0:2, 1:1:0, 1:2:0, 1:3:0, ...., 1:31:0 */ + if ((0 == BusHandler->BusNumber && 0 == Slot.u.bits.DeviceNumber && + (1 == Slot.u.bits.FunctionNumber || 2 == Slot.u.bits.FunctionNumber)) || + (1 == BusHandler->BusNumber && 0 != Slot.u.bits.DeviceNumber)) + { + DPRINT1("Trying to set data on blacklisted PCI slot\n"); + return 0; + } +#endif + /* Normalize the length */ if (Length > sizeof(PCI_COMMON_CONFIG)) Length = sizeof(PCI_COMMON_CONFIG); @@ -893,9 +928,6 @@ VOID NTAPI HalpInitializePciBus(VOID) { - /* Initialize the hooks */ - if (HalpHooks.InitPciBus) HalpHooks.InitPciBus(&HalpFakePciBusHandler); - /* Initialize the stubs */ HalpInitializePciStubs(); diff --git a/reactos/hal/halx86/include/halp.h b/reactos/hal/halx86/include/halp.h index 04e4db19b6c..704969816d5 100644 --- a/reactos/hal/halx86/include/halp.h +++ b/reactos/hal/halx86/include/halp.h @@ -115,12 +115,6 @@ HaliSetSystemInformation( IN OUT PVOID Buffer ); -typedef struct tagHALP_HOOKS -{ - void (*InitPciBus)(PBUS_HANDLER BusHandler); -} HALP_HOOKS, *PHALP_HOOKS; - -extern HALP_HOOKS HalpHooks; extern KSPIN_LOCK HalpSystemHardwareLock; #endif /* __INTERNAL_HAL_HAL_H */ diff --git a/reactos/hal/halx86/mp/halinit.c b/reactos/hal/halx86/mp/halinit.c deleted file mode 100644 index bbe2156ee47..00000000000 --- a/reactos/hal/halx86/mp/halinit.c +++ /dev/null @@ -1,153 +0,0 @@ -/* - * PROJECT: ReactOS HAL - * LICENSE: GPL - See COPYING in the top level directory - * FILE: hal/halx86/generic/halinit.c - * PURPOSE: HAL Entrypoint and Initialization - * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org) - */ - -/* INCLUDES ******************************************************************/ - -#include -#define NDEBUG -#include - -/* GLOBALS *******************************************************************/ - -HALP_HOOKS HalpHooks; -BOOLEAN HalpPciLockSettings; - -/* PRIVATE FUNCTIONS *********************************************************/ - -VOID -NTAPI -HalpGetParameters(IN PLOADER_PARAMETER_BLOCK LoaderBlock) -{ - PCHAR CommandLine; - - /* Make sure we have a loader block and command line */ - if ((LoaderBlock) && (LoaderBlock->LoadOptions)) - { - /* Read the command line */ - CommandLine = LoaderBlock->LoadOptions; - - /* Check if PCI is locked */ - if (strstr(CommandLine, "PCILOCK")) HalpPciLockSettings = TRUE; - - /* Check for initial breakpoint */ - if (strstr(CommandLine, "BREAK")) DbgBreakPoint(); - } -} - -/* FUNCTIONS *****************************************************************/ - -/* - * @implemented - */ -BOOLEAN -NTAPI -HalInitSystem(IN ULONG BootPhase, - IN PLOADER_PARAMETER_BLOCK LoaderBlock) -{ - PKPRCB Prcb = KeGetCurrentPrcb(); - - /* Check the boot phase */ - if (!BootPhase) - { - /* Phase 0... save bus type */ - HalpBusType = LoaderBlock->u.I386.MachineType & 0xFF; - - /* Get command-line parameters */ - HalpGetParameters(LoaderBlock); - - /* Checked HAL requires checked kernel */ -#if DBG - if (!(Prcb->BuildType & PRCB_BUILD_DEBUG)) - { - /* No match, bugcheck */ - KeBugCheckEx(MISMATCHED_HAL, 2, Prcb->BuildType, 1, 0); - } -#else - /* Release build requires release HAL */ - if (Prcb->BuildType & PRCB_BUILD_DEBUG) - { - /* No match, bugcheck */ - KeBugCheckEx(MISMATCHED_HAL, 2, Prcb->BuildType, 0, 0); - } -#endif - -#ifdef CONFIG_SMP - /* SMP HAL requires SMP kernel */ - if (Prcb->BuildType & PRCB_BUILD_UNIPROCESSOR) - { - /* No match, bugcheck */ - KeBugCheckEx(MISMATCHED_HAL, 2, Prcb->BuildType, 0, 0); - } -#endif - - /* Validate the PRCB */ - if (Prcb->MajorVersion != PRCB_MAJOR_VERSION) - { - /* Validation failed, bugcheck */ - KeBugCheckEx(MISMATCHED_HAL, 1, Prcb->MajorVersion, 1, 0); - } - - /* Initialize the PICs */ - //HalpInitPICs(); - - /* Force initial PIC state */ - KfRaiseIrql(KeGetCurrentIrql()); - - /* Initialize the clock */ - HalpInitializeClock(); - - /* Setup busy waiting */ - //HalpCalibrateStallExecution(); - - /* Fill out the dispatch tables */ - HalQuerySystemInformation = HaliQuerySystemInformation; - HalSetSystemInformation = HaliSetSystemInformation; - HalInitPnpDriver = NULL; // FIXME: TODO - HalGetDmaAdapter = HalpGetDmaAdapter; - HalGetInterruptTranslator = NULL; // FIXME: TODO - - /* Initialize the hardware lock (CMOS) */ - KeInitializeSpinLock(&HalpSystemHardwareLock); - } - else if (BootPhase == 1) - { - /* Initialize the default HAL stubs for bus handling functions */ - HalpInitNonBusHandler(); - - /* Enable the clock interrupt */ - ((PKIPCR)KeGetPcr())->IDT[0x30].ExtendedOffset = - (USHORT)(((ULONG_PTR)HalpClockInterrupt >> 16) & 0xFFFF); - ((PKIPCR)KeGetPcr())->IDT[0x30].Offset = - (ULONG_PTR)HalpClockInterrupt; - HalEnableSystemInterrupt(0x30, CLOCK2_LEVEL, Latched); - - /* Initialize DMA. NT does this in Phase 0 */ - HalpInitDma(); - } - - /* All done, return */ - return TRUE; -} - -/* - * @unimplemented - */ -VOID -NTAPI -HalReportResourceUsage(VOID) -{ - /* Initialize PCI bus. */ - HalpInitializePciBus(); - - /* FIXME: This is done in ReactOS MP HAL only*/ - //HaliReconfigurePciInterrupts(); - - /* FIXME: Report HAL Usage to kernel */ -} - -/* EOF */ diff --git a/reactos/hal/halx86/mp/halinit_mp.c b/reactos/hal/halx86/mp/halinit_mp.c index 9756923bb7b..f22d932225b 100644 --- a/reactos/hal/halx86/mp/halinit_mp.c +++ b/reactos/hal/halx86/mp/halinit_mp.c @@ -21,6 +21,12 @@ extern BOOLEAN HaliFindSmpConfig(VOID); ULONG_PTR KernelBase; /***************************************************************************/ + +VOID NTAPI HalpInitPICs(VOID) +{ + UNIMPLEMENTED; +} + VOID HalpInitPhase0(PLOADER_PARAMETER_BLOCK LoaderBlock) diff --git a/reactos/hal/halx86/mp/halmp.rbuild b/reactos/hal/halx86/mp/halmp.rbuild deleted file mode 100644 index cdf2ceeae02..00000000000 --- a/reactos/hal/halx86/mp/halmp.rbuild +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - ../include - include - - - - hal_generic - ntoskrnl - apic.c - halinit.c - halinit_mp.c - ioapic.c - ipi_mp.c - mpconfig.c - mps.S - mpsboot.asm - mpsirql.c - processor_mp.c - spinlock.c - halmp.rc - diff --git a/reactos/hal/halx86/up/halup.rbuild b/reactos/hal/halx86/up/halup.rbuild deleted file mode 100644 index 74d64dad439..00000000000 --- a/reactos/hal/halx86/up/halup.rbuild +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - ../include - include - - - -enable-stdcall-fixup - hal_generic - hal_generic_up - ntoskrnl - halinit_up.c - halup.rc - diff --git a/reactos/hal/halx86/xbox/halinit_xbox.c b/reactos/hal/halx86/xbox/halinit_xbox.c index 6c7dfe9ed6c..28e3342c755 100644 --- a/reactos/hal/halx86/xbox/halinit_xbox.c +++ b/reactos/hal/halx86/xbox/halinit_xbox.c @@ -11,7 +11,7 @@ /* INCLUDES *****************************************************************/ -#include +#include "halxbox.h" #define NDEBUG #include @@ -21,8 +21,6 @@ VOID HalpInitPhase0(PLOADER_PARAMETER_BLOCK LoaderBlock) { - HalpHooks.InitPciBus = HalpXboxInitPciBus; - HalpXboxInitPartIo(); } diff --git a/reactos/hal/halx86/xbox/halxbox.rbuild b/reactos/hal/halx86/xbox/halxbox.rbuild deleted file mode 100644 index 6008b9d8ad7..00000000000 --- a/reactos/hal/halx86/xbox/halxbox.rbuild +++ /dev/null @@ -1,19 +0,0 @@ - - - - - ../include - . - include - - - - hal_generic - hal_generic_up - ntoskrnl - halinit_xbox.c - part_xbox.c - pci_xbox.c - halxbox.rc - halxbox.h - diff --git a/reactos/hal/halx86/xbox/part_xbox.c b/reactos/hal/halx86/xbox/part_xbox.c index 4ae66dad29b..c23ef09d671 100644 --- a/reactos/hal/halx86/xbox/part_xbox.c +++ b/reactos/hal/halx86/xbox/part_xbox.c @@ -11,7 +11,7 @@ /* INCLUDES *****************************************************************/ -#include +#include "halxbox.h" #define NDEBUG #include diff --git a/reactos/hal/halx86/xbox/pci_xbox.c b/reactos/hal/halx86/xbox/pci_xbox.c deleted file mode 100644 index 3f1c59c6d8b..00000000000 --- a/reactos/hal/halx86/xbox/pci_xbox.c +++ /dev/null @@ -1,100 +0,0 @@ -/* - * COPYRIGHT: See COPYING in the top level directory - * PROJECT: ReactOS kernel - * FILE: hal/halx86/xbox/pci_xbox.c - * PURPOSE: Xbox specific handling of PCI cards - * PROGRAMMER: Ge van Geldorp (gvg@reactos.com) - * UPDATE HISTORY: - * 2004/12/04: Created - * - * Trying to get PCI config data from devices 0:0:1 and 0:0:2 will completely - * hang the Xbox. Also, the device number doesn't seem to be decoded for the - * video card, so it appears to be present on 1:0:0 - 1:31:0. - * We hack around these problems by indicating "device not present" for devices - * 0:0:1, 0:0:2, 1:1:0, 1:2:0, 1:3:0, ...., 1:31:0 - */ - -/* INCLUDES *****************************************************************/ - -#include - -#define NDEBUG -#include - -/* VARIABLES ***************************************************************/ - -static pGetSetBusData GenericGetPciData; -static pGetSetBusData GenericSetPciData; - -/* FUNCTIONS ***************************************************************/ - -static ULONG NTAPI -HalpXboxGetPciData(IN PBUS_HANDLER BusHandler, - IN PBUS_HANDLER RootHandler, - IN PCI_SLOT_NUMBER SlotNumber, - OUT PUCHAR Buffer, - IN ULONG Offset, - IN ULONG Length) -{ - ULONG BusNumber = BusHandler->BusNumber; - - DPRINT("HalpXboxGetPciData() called.\n"); - DPRINT(" BusNumber %lu\n", BusNumber); - DPRINT(" SlotNumber %lu\n", SlotNumber); - DPRINT(" Offset 0x%lx\n", Offset); - DPRINT(" Length 0x%lx\n", Length); - - if ((0 == BusNumber && 0 == SlotNumber.u.bits.DeviceNumber && - (1 == SlotNumber.u.bits.FunctionNumber || 2 == SlotNumber.u.bits.FunctionNumber)) || - (1 == BusNumber && 0 != SlotNumber.u.bits.DeviceNumber)) - { - DPRINT("Blacklisted PCI slot\n"); - if (0 == Offset && 2 <= Length) - { - *(PUSHORT)Buffer = PCI_INVALID_VENDORID; - return 2; - } - return 0; - } - - return GenericGetPciData(BusHandler, RootHandler, SlotNumber, Buffer, Offset, Length); -} - -static ULONG NTAPI -HalpXboxSetPciData(IN PBUS_HANDLER BusHandler, - IN PBUS_HANDLER RootHandler, - IN PCI_SLOT_NUMBER SlotNumber, - IN PUCHAR Buffer, - IN ULONG Offset, - IN ULONG Length) -{ - ULONG BusNumber = BusHandler->BusNumber; - - DPRINT("HalpXboxSetPciData() called.\n"); - DPRINT(" BusNumber %lu\n", BusNumber); - DPRINT(" SlotNumber %lu\n", SlotNumber); - DPRINT(" Offset 0x%lx\n", Offset); - DPRINT(" Length 0x%lx\n", Length); - - if ((0 == BusNumber && 0 == SlotNumber.u.bits.DeviceNumber && - (1 == SlotNumber.u.bits.FunctionNumber || 2 == SlotNumber.u.bits.FunctionNumber)) || - (1 == BusNumber && 0 != SlotNumber.u.bits.DeviceNumber)) - { - DPRINT1("Trying to set data on blacklisted PCI slot\n"); - return 0; - } - - return GenericSetPciData(BusHandler, RootHandler, SlotNumber, Buffer, Offset, Length); -} - -VOID -HalpXboxInitPciBus(PBUS_HANDLER BusHandler) -{ - /* Use our own handlers to prevent a freeze */ - GenericGetPciData = BusHandler->GetBusData; - BusHandler->GetBusData = HalpXboxGetPciData; - GenericSetPciData = BusHandler->SetBusData; - BusHandler->SetBusData = HalpXboxSetPciData; -} - -/* EOF */