diff --git a/reactos/boot/bootdata/hivesys_i386.inf b/reactos/boot/bootdata/hivesys_i386.inf index 2bbe9ff3358..977ea93d55b 100644 --- a/reactos/boot/bootdata/hivesys_i386.inf +++ b/reactos/boot/bootdata/hivesys_i386.inf @@ -45,6 +45,24 @@ HKLM,"SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName","ComputerName" ; Device classes key HKLM,"SYSTEM\CurrentControlSet\Control\DeviceClasses",,0x00000012 +; HAL Chipset Hacks +HKLM,"SYSTEM\CurrentControlSet\Control\HAL","10390530",0x00010001,0x1 +HKLM,"SYSTEM\CurrentControlSet\Control\HAL","10390620",0x00010001,0x1 +HKLM,"SYSTEM\CurrentControlSet\Control\HAL","10B90533",0x00010001,0x1 +HKLM,"SYSTEM\CurrentControlSet\Control\HAL","10B91533",0x00010001,0x1 +HKLM,"SYSTEM\CurrentControlSet\Control\HAL","11060596",0x00010001,0x1 +HKLM,"SYSTEM\CurrentControlSet\Control\HAL","11060686",0x00010001,0x5 +HKLM,"SYSTEM\CurrentControlSet\Control\HAL","1166004F",0x00010001,0x1 +HKLM,"SYSTEM\CurrentControlSet\Control\HAL","11660050",0x00010001,0x1 +HKLM,"SYSTEM\CurrentControlSet\Control\HAL","11660200",0x00010001,0x1 +HKLM,"SYSTEM\CurrentControlSet\Control\HAL","80862410",0x00010001,0x8 +HKLM,"SYSTEM\CurrentControlSet\Control\HAL","80862420",0x00010001,0x8 +HKLM,"SYSTEM\CurrentControlSet\Control\HAL","80862440",0x00010001,0x8 +HKLM,"SYSTEM\CurrentControlSet\Control\HAL","8086244C",0x00010001,0x8 +HKLM,"SYSTEM\CurrentControlSet\Control\HAL","80862480",0x00010001,0x8 +HKLM,"SYSTEM\CurrentControlSet\Control\HAL","8086248C",0x00010001,0x8 +HKLM,"SYSTEM\CurrentControlSet\Control\HAL","80867110",0x00010001,0x1 + ; Hardware profile settings HKLM,"SYSTEM\CurrentControlSet\Control\IDConfigDB",,0x00000012 HKLM,"SYSTEM\CurrentControlSet\Control\IDConfigDB","CurrentConfig",0x00010001,0x00000000 diff --git a/reactos/hal/halx86/generic/bus/bushndlr.c b/reactos/hal/halx86/generic/bus/bushndlr.c index 1df180e9052..3b5472be668 100644 --- a/reactos/hal/halx86/generic/bus/bushndlr.c +++ b/reactos/hal/halx86/generic/bus/bushndlr.c @@ -2,6 +2,185 @@ * PROJECT: ReactOS HAL * LICENSE: GPL - See COPYING in the top level directory * FILE: hal/halx86/generic/bus/bushndlr.c - * PURPOSE: + * PURPOSE: Generic HAL Bus Handler Support * PROGRAMMERS: Stefan Ginsberg (stefan.ginsberg@reactos.org) */ + +/* INCLUDES *******************************************************************/ + +#include +#define NDEBUG +#include + +/* GLOBALS ********************************************************************/ + +KSPIN_LOCK HalpBusDatabaseSpinLock; +KEVENT HalpBusDatabaseEvent; +LIST_ENTRY HalpAllBusHandlers; +PARRAY HalpBusTable; +PARRAY HalpConfigTable; + +/* PRIVATE FUNCTIONS **********************************************************/ + +PARRAY +NTAPI +HalpAllocateArray(IN ULONG ArraySize) +{ + PARRAY Array; + ULONG Size; + + /* Compute array size */ + if (ArraySize == -1) ArraySize = 0; + Size = ArraySize * sizeof(PARRAY) + sizeof(ARRAY); + + /* Allocate the array */ + Array = ExAllocatePoolWithTag(NonPagedPool, + Size, + 'BusH'); + if (!Array) KeBugCheckEx(HAL_MEMORY_ALLOCATION, Size, 0, (ULONG_PTR)__FILE__, __LINE__); + + /* Initialize it */ + Array->ArraySize = ArraySize; + RtlZeroMemory(Array->Element, sizeof(PVOID) * (ArraySize + 1)); + return Array; +} + +VOID +NTAPI +HalpGrowArray(IN PARRAY *CurrentArray, + IN PARRAY *NewArray) +{ + PVOID Tmp; + + /* Check if the current array doesn't exist yet, or if it's smaller than the new one */ + if (!(*CurrentArray) || ((*NewArray)->ArraySize > (*CurrentArray)->ArraySize)) + { + /* Does it exist (and can it fit?) */ + if (*CurrentArray) + { + /* Copy the current array into the new one */ + RtlCopyMemory(&(*NewArray)->Element, + &(*CurrentArray)->Element, + sizeof(PVOID) * ((*CurrentArray)->ArraySize + 1)); + } + + /* Swap the pointers (XOR swap would be more l33t) */ + Tmp = *CurrentArray; + *CurrentArray = *NewArray; + *NewArray = Tmp; + } +} + +PBUS_HANDLER +FASTCALL +HalpLookupHandler(IN PARRAY Array, + IN ULONG Type, + IN ULONG Number, + IN BOOLEAN AddReference) +{ + PHAL_BUS_HANDLER Bus; + PBUS_HANDLER Handler = NULL; + + /* Make sure the entry exists */ + if (Array->ArraySize >= Type) + { + /* Retrieve it */ + Array = Array->Element[Type]; + + /* Make sure the entry array exists */ + if ((Array) && (Array->ArraySize >= Number)) + { + /* Retrieve the bus and its handler */ + Bus = Array->Element[Number]; + Handler = &Bus->Handler; + + /* Reference the handler if needed */ + if (AddReference) Bus->ReferenceCount++; + } + } + + /* Return the handler */ + return Handler; +} + +VOID +FASTCALL +HaliReferenceBusHandler(IN PBUS_HANDLER Handler) +{ + PHAL_BUS_HANDLER Bus; + + /* Find and reference the bus handler */ + Bus = CONTAINING_RECORD(Handler, HAL_BUS_HANDLER, Handler); + Bus->ReferenceCount++; +} + +VOID +FASTCALL +HaliDereferenceBusHandler(IN PBUS_HANDLER Handler) +{ + PHAL_BUS_HANDLER Bus; + + /* Find and dereference the bus handler */ + Bus = CONTAINING_RECORD(Handler, HAL_BUS_HANDLER, Handler); + Bus->ReferenceCount--; + ASSERT(Bus->ReferenceCount != 0); +} + +PBUS_HANDLER +FASTCALL +HaliHandlerForBus(IN INTERFACE_TYPE InterfaceType, + IN ULONG BusNumber) +{ + /* Lookup the interface in the bus table */ + return HalpLookupHandler(HalpBusTable, InterfaceType, BusNumber, FALSE); +} + +PBUS_HANDLER +FASTCALL +HaliHandlerForConfigSpace(IN BUS_DATA_TYPE ConfigType, + IN ULONG BusNumber) +{ + /* Lookup the configuration in the configuration table */ + return HalpLookupHandler(HalpConfigTable, ConfigType, BusNumber, FALSE); +} + +PBUS_HANDLER +FASTCALL +HaliReferenceHandlerForBus(IN INTERFACE_TYPE InterfaceType, + IN ULONG BusNumber) +{ + /* Lookup the interface in the bus table, and reference the handler */ + return HalpLookupHandler(HalpBusTable, InterfaceType, BusNumber, TRUE); +} + +PBUS_HANDLER +FASTCALL +HaliReferenceHandlerForConfigSpace(IN BUS_DATA_TYPE ConfigType, + IN ULONG BusNumber) +{ + /* Lookup the configuration in the configuration table and add a reference */ + return HalpLookupHandler(HalpConfigTable, ConfigType, BusNumber, TRUE); +} + +VOID +NTAPI +HalpInitBusHandler(VOID) +{ + /* Setup the bus lock */ + KeInitializeSpinLock(&HalpBusDatabaseSpinLock); + + /* Setup the bus event */ + KeInitializeEvent(&HalpBusDatabaseEvent, SynchronizationEvent, TRUE); + + /* Setup the bus configuration and bus table */ + HalpBusTable = HalpAllocateArray(0); + HalpConfigTable = HalpAllocateArray(0); + + /* Setup the bus list */ + InitializeListHead(&HalpAllBusHandlers); + + /* These should be written by the PCI driver later, but we give defaults */ + HalPciTranslateBusAddress = HalpTranslateBusAddress; + HalPciAssignSlotResources = HalpAssignSlotResources; + HalFindBusAddressTranslation = HalpFindBusAddressTranslation; +} diff --git a/reactos/hal/halx86/generic/bus/halbus.c b/reactos/hal/halx86/generic/bus/halbus.c index 392c69f7c1f..8421b774b63 100644 --- a/reactos/hal/halx86/generic/bus/halbus.c +++ b/reactos/hal/halx86/generic/bus/halbus.c @@ -115,16 +115,6 @@ HalpFindBusAddressTranslation(IN PHYSICAL_ADDRESS BusAddress, return TRUE; } -VOID -NTAPI -HalpInitNonBusHandler(VOID) -{ - /* These should be written by the PCI driver later, but we give defaults */ - HalPciTranslateBusAddress = HalpTranslateBusAddress; - HalPciAssignSlotResources = HalpAssignSlotResources; - HalFindBusAddressTranslation = HalpFindBusAddressTranslation; -} - /* PUBLIC FUNCTIONS **********************************************************/ /* diff --git a/reactos/hal/halx86/generic/halinit.c b/reactos/hal/halx86/generic/halinit.c index 1bfd080b9b4..27077d678c3 100644 --- a/reactos/hal/halx86/generic/halinit.c +++ b/reactos/hal/halx86/generic/halinit.c @@ -139,8 +139,8 @@ HalInitSystem(IN ULONG BootPhase, } else if (BootPhase == 1) { - /* Initialize the default HAL stubs for bus handling functions */ - HalpInitNonBusHandler(); + /* Initialize bus handlers */ + HalpInitBusHandler(); /* Enable IRQ 0 */ HalpEnableInterruptHandler(IDT_DEVICE, diff --git a/reactos/hal/halx86/include/bus.h b/reactos/hal/halx86/include/bus.h index 607c0ef0523..295bc5d3a6e 100644 --- a/reactos/hal/halx86/include/bus.h +++ b/reactos/hal/halx86/include/bus.h @@ -157,6 +157,19 @@ typedef struct _PCI_REGISTRY_INFO_INTERNAL PCI_CARD_DESCRIPTOR CardList[ANYSIZE_ARRAY]; } PCI_REGISTRY_INFO_INTERNAL, *PPCI_REGISTRY_INFO_INTERNAL; +typedef struct _ARRAY +{ + ULONG ArraySize; + PVOID Element[ANYSIZE_ARRAY]; +} ARRAY, *PARRAY; + +typedef struct _HAL_BUS_HANDLER +{ + LIST_ENTRY AllHandlers; + ULONG ReferenceCount; + BUS_HANDLER Handler; +} HAL_BUS_HANDLER, *PHAL_BUS_HANDLER; + /* FUNCTIONS *****************************************************************/ VOID @@ -306,6 +319,45 @@ HalpInitializePciStubs( VOID ); +VOID +NTAPI +HalpInitBusHandler( + VOID +); + +BOOLEAN +NTAPI +HalpTranslateBusAddress( + IN INTERFACE_TYPE InterfaceType, + IN ULONG BusNumber, + IN PHYSICAL_ADDRESS BusAddress, + IN OUT PULONG AddressSpace, + OUT PPHYSICAL_ADDRESS TranslatedAddress +); + +NTSTATUS +NTAPI +HalpAssignSlotResources( + IN PUNICODE_STRING RegistryPath, + IN PUNICODE_STRING DriverClassName, + IN PDRIVER_OBJECT DriverObject, + IN PDEVICE_OBJECT DeviceObject, + IN INTERFACE_TYPE BusType, + IN ULONG BusNumber, + IN ULONG SlotNumber, + IN OUT PCM_RESOURCE_LIST *AllocatedResources +); + +BOOLEAN +NTAPI +HalpFindBusAddressTranslation( + IN PHYSICAL_ADDRESS BusAddress, + IN OUT PULONG AddressSpace, + OUT PPHYSICAL_ADDRESS TranslatedAddress, + IN OUT PULONG_PTR Context, + IN BOOLEAN NextBus +); + extern ULONG HalpBusType; extern BOOLEAN HalpPCIConfigInitialized; extern BUS_HANDLER HalpFakePciBusHandler; diff --git a/reactos/hal/halx86/include/halp.h b/reactos/hal/halx86/include/halp.h index bd5f61e6830..198842a648c 100644 --- a/reactos/hal/halx86/include/halp.h +++ b/reactos/hal/halx86/include/halp.h @@ -61,9 +61,6 @@ typedef struct _HalAddressUsage /* adapter.c */ PADAPTER_OBJECT NTAPI HalpAllocateAdapterEx(ULONG NumberOfMapRegisters,BOOLEAN IsMaster, BOOLEAN Dma32BitAddresses); -/* bus.c */ -VOID NTAPI HalpInitNonBusHandler (VOID); - /* sysinfo.c */ VOID NTAPI diff --git a/reactos/include/ndk/haltypes.h b/reactos/include/ndk/haltypes.h index 4687378a263..f7d5e57082a 100644 --- a/reactos/include/ndk/haltypes.h +++ b/reactos/include/ndk/haltypes.h @@ -249,8 +249,10 @@ typedef struct _BUS_HANDLER // // HAL Chip Hacks // -#define HAL_PCI_CHIP_HACK_DISABLE_HIBERNATE 0x02 -#define HAL_PCI_CHIP_HACK_USB_SMI_DISABLE 0x08 +#define HAL_PCI_CHIP_HACK_BROKEN_ACPI_TIMER 0x01 +#define HAL_PCI_CHIP_HACK_DISABLE_HIBERNATE 0x02 +#define HAL_PCI_CHIP_HACK_DISABLE_ACPI_IRQ_ROUTING 0x04 +#define HAL_PCI_CHIP_HACK_USB_SMI_DISABLE 0x08 // // Kernel Exports