Author: sginsberg
Date: Mon Nov 9 23:59:49 2009
New Revision: 44061
URL:
http://svn.reactos.org/svn/reactos?rev=44061&view=rev
Log:
- Implement the generic bus handler support and initialization.
- Add missing hack flags for ACPI hacks.
- Add the hack flags to the registry.
Modified:
trunk/reactos/boot/bootdata/hivesys_i386.inf
trunk/reactos/hal/halx86/generic/bus/bushndlr.c
trunk/reactos/hal/halx86/generic/bus/halbus.c
trunk/reactos/hal/halx86/generic/halinit.c
trunk/reactos/hal/halx86/include/bus.h
trunk/reactos/hal/halx86/include/halp.h
trunk/reactos/include/ndk/haltypes.h
Modified: trunk/reactos/boot/bootdata/hivesys_i386.inf
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/bootdata/hivesys_i386…
==============================================================================
--- trunk/reactos/boot/bootdata/hivesys_i386.inf [iso-8859-1] (original)
+++ trunk/reactos/boot/bootdata/hivesys_i386.inf [iso-8859-1] Mon Nov 9 23:59:49 2009
@@ -44,6 +44,24 @@
; 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
Modified: trunk/reactos/hal/halx86/generic/bus/bushndlr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/generic/bus/bus…
==============================================================================
--- trunk/reactos/hal/halx86/generic/bus/bushndlr.c [iso-8859-1] (original)
+++ trunk/reactos/hal/halx86/generic/bus/bushndlr.c [iso-8859-1] Mon Nov 9 23:59:49 2009
@@ -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(a)reactos.org)
*/
+
+/* INCLUDES *******************************************************************/
+
+#include <hal.h>
+#define NDEBUG
+#include <debug.h>
+
+/* 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;
+}
Modified: trunk/reactos/hal/halx86/generic/bus/halbus.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/generic/bus/hal…
==============================================================================
--- trunk/reactos/hal/halx86/generic/bus/halbus.c [iso-8859-1] (original)
+++ trunk/reactos/hal/halx86/generic/bus/halbus.c [iso-8859-1] Mon Nov 9 23:59:49 2009
@@ -115,16 +115,6 @@
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 **********************************************************/
/*
Modified: trunk/reactos/hal/halx86/generic/halinit.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/generic/halinit…
==============================================================================
--- trunk/reactos/hal/halx86/generic/halinit.c [iso-8859-1] (original)
+++ trunk/reactos/hal/halx86/generic/halinit.c [iso-8859-1] Mon Nov 9 23:59:49 2009
@@ -139,8 +139,8 @@
}
else if (BootPhase == 1)
{
- /* Initialize the default HAL stubs for bus handling functions */
- HalpInitNonBusHandler();
+ /* Initialize bus handlers */
+ HalpInitBusHandler();
/* Enable IRQ 0 */
HalpEnableInterruptHandler(IDT_DEVICE,
Modified: trunk/reactos/hal/halx86/include/bus.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/include/bus.h?r…
==============================================================================
--- trunk/reactos/hal/halx86/include/bus.h [iso-8859-1] (original)
+++ trunk/reactos/hal/halx86/include/bus.h [iso-8859-1] Mon Nov 9 23:59:49 2009
@@ -157,6 +157,19 @@
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 @@
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;
Modified: trunk/reactos/hal/halx86/include/halp.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/include/halp.h?…
==============================================================================
--- trunk/reactos/hal/halx86/include/halp.h [iso-8859-1] (original)
+++ trunk/reactos/hal/halx86/include/halp.h [iso-8859-1] Mon Nov 9 23:59:49 2009
@@ -61,9 +61,6 @@
/* adapter.c */
PADAPTER_OBJECT NTAPI HalpAllocateAdapterEx(ULONG NumberOfMapRegisters,BOOLEAN IsMaster,
BOOLEAN Dma32BitAddresses);
-/* bus.c */
-VOID NTAPI HalpInitNonBusHandler (VOID);
-
/* sysinfo.c */
VOID
NTAPI
Modified: trunk/reactos/include/ndk/haltypes.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/ndk/haltypes.h?rev…
==============================================================================
--- trunk/reactos/include/ndk/haltypes.h [iso-8859-1] (original)
+++ trunk/reactos/include/ndk/haltypes.h [iso-8859-1] Mon Nov 9 23:59:49 2009
@@ -249,8 +249,10 @@
//
// 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