Author: sir_richard Date: Thu Apr 1 21:42:07 2010 New Revision: 46647
URL: http://svn.reactos.org/svn/reactos?rev=46647&view=rev Log: [HAL]: Split HalReportResouceUsage into per-platform function, since PC/AT HAL and ACPI HAL have different requirements. As a bonus, the ACPI HAL now identifies itself as ACPI Compatible, instead of using the "PC Compatible" moniker. [HAL]: Implement HalpGetNMICrashFlag so you can do NMI crashes now. [HAL]: Implement basic HalpRegistryPciDebuggingDeviceInfo for the day someone implements the Kd routines. [HAL]: HalpInitializePciBus needs to be different between "Bus Handler HALs" (non-ACPI/embedded) and "Non-Bus Handler HALs" (ACPI/x64). On ACPI, all we do is setup the raw PCI Stubs and NMI crashing. PC/AT will need more involved code.
Modified: trunk/reactos/hal/halx86/generic/acpi/halacpi.c trunk/reactos/hal/halx86/generic/bus/pcibus.c trunk/reactos/hal/halx86/generic/legacy/halpcat.c trunk/reactos/hal/halx86/generic/usage.c trunk/reactos/hal/halx86/include/bus.h trunk/reactos/hal/halx86/include/halp.h
Modified: trunk/reactos/hal/halx86/generic/acpi/halacpi.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/generic/acpi/hal... ============================================================================== --- trunk/reactos/hal/halx86/generic/acpi/halacpi.c [iso-8859-1] (original) +++ trunk/reactos/hal/halx86/generic/acpi/halacpi.c [iso-8859-1] Thu Apr 1 21:42:07 2010 @@ -861,4 +861,64 @@ return STATUS_SUCCESS; }
+VOID +NTAPI +HalpInitializePciBus(VOID) +{ + /* Setup the PCI stub support */ + HalpInitializePciStubs(); + + /* Set the NMI crash flag */ + HalpGetNMICrashFlag(); +} + +/* + * @implemented + */ +VOID +NTAPI +HalReportResourceUsage(VOID) +{ + INTERFACE_TYPE InterfaceType; + UNICODE_STRING HalString; + + /* FIXME: Initialize DMA 64-bit support */ + + /* FIXME: Initialize MCA bus */ + + /* Initialize PCI bus. */ + HalpInitializePciBus(); + + /* What kind of bus is this? */ + switch (HalpBusType) + { + /* ISA Machine */ + case MACHINE_TYPE_ISA: + InterfaceType = Isa; + break; + + /* EISA Machine */ + case MACHINE_TYPE_EISA: + InterfaceType = Eisa; + break; + + /* MCA Machine */ + case MACHINE_TYPE_MCA: + InterfaceType = MicroChannel; + break; + + /* Unknown */ + default: + InterfaceType = Internal; + break; + } + + /* Build HAL usage */ + RtlInitUnicodeString(&HalString, L"ACPI Compatible Eisa/Isa HAL"); + HalpReportResourceUsage(&HalString, InterfaceType); + + /* Setup PCI debugging and Hibernation */ + HalpRegisterPciDebuggingDeviceInfo(); +} + /* EOF */
Modified: trunk/reactos/hal/halx86/generic/bus/pcibus.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/generic/bus/pcib... ============================================================================== --- trunk/reactos/hal/halx86/generic/bus/pcibus.c [iso-8859-1] (original) +++ trunk/reactos/hal/halx86/generic/bus/pcibus.c [iso-8859-1] Thu Apr 1 21:42:07 2010 @@ -13,6 +13,8 @@ #include <debug.h>
/* GLOBALS *******************************************************************/ + +PCI_TYPE1_CFG_CYCLE_BITS HalpPciDebuggingDevice[2] = {{{{0}}}};
BOOLEAN HalpPCIConfigInitialized; ULONG HalpMinPciBus, HalpMaxPciBus; @@ -519,6 +521,34 @@ { DPRINT1("Unimplemented!\n"); return STATUS_NOT_IMPLEMENTED; +} + +VOID +NTAPI +HalpRegisterPciDebuggingDeviceInfo(VOID) +{ + BOOLEAN Found = FALSE; + ULONG i; + PAGED_CODE(); + + /* Loop PCI debugging devices */ + for (i = 0; i < 2; i++) + { + /* Reserved bit is set if we found one */ + if (HalpPciDebuggingDevice[i].u.bits.Reserved1) + { + Found = TRUE; + break; + } + } + + /* Bail out if there aren't any */ + if (!Found) return; + + /* FIXME: TODO */ + DPRINT1("You have implemented the KD routines for searching PCI debugger" + "devices, but you have forgotten to implement this routine\n"); + while (TRUE); }
static ULONG NTAPI @@ -1026,9 +1056,3 @@ HalpPCIConfigInitialized = TRUE; }
-VOID -NTAPI -HalpInitializePciBus(VOID) -{ - /* FIXME: Initialize NMI Crash Flag */ -}
Modified: trunk/reactos/hal/halx86/generic/legacy/halpcat.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/generic/legacy/h... ============================================================================== --- trunk/reactos/hal/halx86/generic/legacy/halpcat.c [iso-8859-1] (original) +++ trunk/reactos/hal/halx86/generic/legacy/halpcat.c [iso-8859-1] Thu Apr 1 21:42:07 2010 @@ -24,4 +24,67 @@ return STATUS_NO_SUCH_DEVICE; }
+VOID +NTAPI +HalpInitializePciBus(VOID) +{ + /* FIXME: Should do legacy PCI bus detection */ + + /* FIXME: Should detect chipset hacks */ + + /* FIXME: Should detect broken PCI hardware and apply hacks */ + + /* FIXME: Should build resource ranges */ +} + +/* + * @implemented + */ +VOID +NTAPI +HalReportResourceUsage(VOID) +{ + INTERFACE_TYPE InterfaceType; + UNICODE_STRING HalString; + + /* FIXME: Initialize MCA bus */ + + /* Initialize PCI bus. */ + HalpInitializePciBus(); + + /* Initialize the stubs */ + HalpInitializePciStubs(); + + /* What kind of bus is this? */ + switch (HalpBusType) + { + /* ISA Machine */ + case MACHINE_TYPE_ISA: + InterfaceType = Isa; + break; + + /* EISA Machine */ + case MACHINE_TYPE_EISA: + InterfaceType = Eisa; + break; + + /* MCA Machine */ + case MACHINE_TYPE_MCA: + InterfaceType = MicroChannel; + break; + + /* Unknown */ + default: + InterfaceType = Internal; + break; + } + + /* Build HAL usage */ + RtlInitUnicodeString(&HalString, L"PC Compatible Eisa/Isa HAL"); + HalpReportResourceUsage(&HalString, InterfaceType); + + /* Setup PCI debugging and Hibernation */ + HalpRegisterPciDebuggingDeviceInfo(); +} + /* EOF */
Modified: trunk/reactos/hal/halx86/generic/usage.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/generic/usage.c?... ============================================================================== --- trunk/reactos/hal/halx86/generic/usage.c [iso-8859-1] (original) +++ trunk/reactos/hal/halx86/generic/usage.c [iso-8859-1] Thu Apr 1 21:42:07 2010 @@ -14,6 +14,7 @@
/* GLOBALS ********************************************************************/
+BOOLEAN HalpNMIDumpFlag; PUCHAR KdComPortInUse; PADDRESS_USAGE HalpAddressUsageList; IDTUsageFlags HalpIDTUsageFlags[MAXIMUM_IDTVECTOR]; @@ -88,55 +89,56 @@ /* Enable the interrupt */ HalEnableSystemInterrupt(SystemVector, Irql, Mode); } + +VOID +NTAPI +HalpGetNMICrashFlag(VOID) +{ + UNICODE_STRING ValueName; + UNICODE_STRING KeyName = RTL_CONSTANT_STRING(L"\Registry\Machine\System\CurrentControlSet\Control\CrashControl"); + OBJECT_ATTRIBUTES ObjectAttributes; + ULONG ResultLength; + HANDLE Handle; + NTSTATUS Status; + KEY_VALUE_PARTIAL_INFORMATION KeyValueInformation; + + /* Set default */ + HalpNMIDumpFlag = 0; + + /* Initialize attributes */ + InitializeObjectAttributes(&ObjectAttributes, + &KeyName, + OBJ_CASE_INSENSITIVE, + NULL, + NULL); + + /* Open crash key */ + Status = ZwOpenKey(&Handle, KEY_READ, &ObjectAttributes); + if (NT_SUCCESS(Status)) + { + /* Query key value */ + RtlInitUnicodeString(&ValueName, L"NMICrashDump"); + Status = ZwQueryValueKey(Handle, + &ValueName, + KeyValuePartialInformation, + &KeyValueInformation, + sizeof(KeyValueInformation), + &ResultLength); + if (NT_SUCCESS(Status)) + { + /* Check for valid data */ + if (ResultLength == sizeof(KEY_VALUE_PARTIAL_INFORMATION)) + { + /* Read the flag */ + HalpNMIDumpFlag = KeyValueInformation.Data[0]; + } + } + + /* We're done */ + ZwClose(Handle); + } +} #endif
-/* - * @unimplemented - */ -VOID -NTAPI -HalReportResourceUsage(VOID) -{ - INTERFACE_TYPE InterfaceType; - UNICODE_STRING HalString; +/* EOF */
- /* FIXME: Initialize DMA 64-bit support */ - - /* FIXME: Initialize MCA bus */ - - /* Initialize PCI bus. */ - HalpInitializePciBus(); - - /* Initialize the stubs */ - HalpInitializePciStubs(); - - /* What kind of bus is this? */ - switch (HalpBusType) - { - /* ISA Machine */ - case MACHINE_TYPE_ISA: - InterfaceType = Isa; - break; - - /* EISA Machine */ - case MACHINE_TYPE_EISA: - InterfaceType = Eisa; - break; - - /* MCA Machine */ - case MACHINE_TYPE_MCA: - InterfaceType = MicroChannel; - break; - - /* Unknown */ - default: - InterfaceType = Internal; - break; - } - - /* Build HAL usage */ - RtlInitUnicodeString(&HalString, L"PC Compatible Eisa/Isa HAL"); - HalpReportResourceUsage(&HalString, InterfaceType); - - /* FIXME: Setup PCI debugging and Hibernation */ -}
Modified: trunk/reactos/hal/halx86/include/bus.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/hal/halx86/include/bus.h?re... ============================================================================== --- trunk/reactos/hal/halx86/include/bus.h [iso-8859-1] (original) +++ trunk/reactos/hal/halx86/include/bus.h [iso-8859-1] Thu Apr 1 21:42:07 2010 @@ -158,6 +158,38 @@ PCI_CARD_DESCRIPTOR CardList[ANYSIZE_ARRAY]; } PCI_REGISTRY_INFO_INTERNAL, *PPCI_REGISTRY_INFO_INTERNAL;
+typedef struct _PCI_TYPE0_CFG_CYCLE_BITS +{ + union + { + struct + { + ULONG Reserved1:2; + ULONG RegisterNumber:6; + ULONG FunctionNumber:3; + ULONG Reserved2:21; + } bits; + ULONG AsULONG; + } u; +} PCI_TYPE0_CFG_CYCLE_BITS, *PPCI_TYPE0_CFG_CYCLE_BITS; + +typedef struct _PCI_TYPE1_CFG_CYCLE_BITS +{ + union + { + struct + { + ULONG Reserved1:2; + ULONG RegisterNumber:6; + ULONG FunctionNumber:3; + ULONG DeviceNumber:5; + ULONG BusNumber:8; + ULONG Reserved2:8; + } bits; + ULONG AsULONG; + } u; +} PCI_TYPE1_CFG_CYCLE_BITS, *PPCI_TYPE1_CFG_CYCLE_BITS; + typedef struct _ARRAY { ULONG ArraySize; @@ -359,6 +391,12 @@ IN BOOLEAN NextBus );
+VOID +NTAPI +HalpRegisterPciDebuggingDeviceInfo( + VOID +); + 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?r... ============================================================================== --- trunk/reactos/hal/halx86/include/halp.h [iso-8859-1] (original) +++ trunk/reactos/hal/halx86/include/halp.h [iso-8859-1] Thu Apr 1 21:42:07 2010 @@ -708,6 +708,19 @@ );
VOID +NTAPI +HalpGetNMICrashFlag( + VOID +); + +VOID +NTAPI +HalpReportResourceUsage( + IN PUNICODE_STRING HalName, + IN INTERFACE_TYPE InterfaceType +); + +VOID FASTCALL KeUpdateSystemTime( IN PKTRAP_FRAME TrapFrame,