[HAL]: Split HalReportResouceUsage into per-platform function, since PC/AT HAL and...
authorSir Richard <sir_richard@svn.reactos.org>
Thu, 1 Apr 2010 19:42:07 +0000 (19:42 +0000)
committerSir Richard <sir_richard@svn.reactos.org>
Thu, 1 Apr 2010 19:42:07 +0000 (19:42 +0000)
[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.

svn path=/trunk/; revision=46647

reactos/hal/halx86/generic/acpi/halacpi.c
reactos/hal/halx86/generic/bus/pcibus.c
reactos/hal/halx86/generic/legacy/halpcat.c
reactos/hal/halx86/generic/usage.c
reactos/hal/halx86/include/bus.h
reactos/hal/halx86/include/halp.h

index f9fe873..8a4a445 100644 (file)
@@ -861,4 +861,64 @@ HalpSetupAcpiPhase0(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
     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 */
index 50f1add..2440cd4 100644 (file)
@@ -14,6 +14,8 @@
 
 /* GLOBALS *******************************************************************/
 
+PCI_TYPE1_CFG_CYCLE_BITS HalpPciDebuggingDevice[2] = {{{{0}}}};
+
 BOOLEAN HalpPCIConfigInitialized;
 ULONG HalpMinPciBus, HalpMaxPciBus;
 KSPIN_LOCK HalpPCIConfigLock;
@@ -521,6 +523,34 @@ HalpReleasePciDeviceForDebugging(IN OUT PDEBUG_DEVICE_DESCRIPTOR PciDevice)
     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
 PciSize(ULONG Base, ULONG Mask)
 {
@@ -1026,9 +1056,3 @@ HalpInitializePciStubs(VOID)
     HalpPCIConfigInitialized = TRUE;
 }
 
-VOID
-NTAPI
-HalpInitializePciBus(VOID)
-{
-    /* FIXME: Initialize NMI Crash Flag */
-}
index bbabb9c..db04395 100644 (file)
@@ -24,4 +24,67 @@ HalpSetupAcpiPhase0(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
     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 */
index d35a3e3..aa500fa 100644 (file)
@@ -14,6 +14,7 @@
 
 /* GLOBALS ********************************************************************/
 
+BOOLEAN HalpNMIDumpFlag;
 PUCHAR KdComPortInUse;
 PADDRESS_USAGE HalpAddressUsageList;
 IDTUsageFlags HalpIDTUsageFlags[MAXIMUM_IDTVECTOR];
@@ -88,55 +89,56 @@ HalpEnableInterruptHandler(IN UCHAR Flags,
     /* Enable the interrupt */
     HalEnableSystemInterrupt(SystemVector, Irql, Mode);
 }
-#endif
 
-/*
- * @unimplemented
- */
 VOID
 NTAPI
-HalReportResourceUsage(VOID)
+HalpGetNMICrashFlag(VOID)
 {
-    INTERFACE_TYPE InterfaceType;
-    UNICODE_STRING HalString;
-
-    /* FIXME: Initialize DMA 64-bit support */
-
-    /* FIXME: Initialize MCA bus */
-
-    /* Initialize PCI bus. */
-    HalpInitializePciBus();
+    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);
     
-    /* Initialize the stubs */
-    HalpInitializePciStubs();
-
-    /* What kind of bus is this? */
-    switch (HalpBusType)
+    /* Open crash key */
+    Status = ZwOpenKey(&Handle, KEY_READ, &ObjectAttributes);
+    if (NT_SUCCESS(Status))
     {
-        /* 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;
+        /* 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
 
-    /* Build HAL usage */
-    RtlInitUnicodeString(&HalString, L"PC Compatible Eisa/Isa HAL");
-    HalpReportResourceUsage(&HalString, InterfaceType);
+/* EOF */
 
-    /* FIXME: Setup PCI debugging and Hibernation */
-}
index 3e07190..0384022 100644 (file)
@@ -158,6 +158,38 @@ typedef struct _PCI_REGISTRY_INFO_INTERNAL
     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 @@ HalpFindBusAddressTranslation(
     IN BOOLEAN NextBus
 );
 
+VOID
+NTAPI
+HalpRegisterPciDebuggingDeviceInfo(
+    VOID
+);
+
 extern ULONG HalpBusType;
 extern BOOLEAN HalpPCIConfigInitialized;
 extern BUS_HANDLER HalpFakePciBusHandler;
index 44b81a0..3bf4a80 100644 (file)
@@ -707,6 +707,19 @@ HalpOpenRegistryKey(
     IN BOOLEAN Create
 );
 
+VOID
+NTAPI
+HalpGetNMICrashFlag(
+    VOID
+);
+
+VOID
+NTAPI
+HalpReportResourceUsage(
+    IN PUNICODE_STRING HalName,
+    IN INTERFACE_TYPE InterfaceType
+);
+
 VOID
 FASTCALL
 KeUpdateSystemTime(