[CMAKE]
[reactos.git] / hal / halx86 / generic / misc.c
index 1a0f4f8..2ddd185 100644 (file)
 
 BOOLEAN HalpNMIInProgress;
 
+UCHAR HalpSerialLen;
+CHAR HalpSerialNumber[31];
+
 /* PRIVATE FUNCTIONS **********************************************************/
 
+#ifndef _MINIHAL_
 VOID
 NTAPI
-HalpCheckPowerButton(VOID)
+INIT_FUNCTION
+HalpReportSerialNumber(VOID)
 {
-    //
-    // Nothing to do on non-ACPI
-    //
-    return;
+    NTSTATUS Status;
+    UNICODE_STRING KeyString;
+    HANDLE Handle;
+
+    /* Make sure there is a serial number */
+    if (!HalpSerialLen) return;
+
+    /* Open the system key */
+    RtlInitUnicodeString(&KeyString, L"\\Registry\\Machine\\Hardware\\Description\\System");
+    Status = HalpOpenRegistryKey(&Handle, 0, &KeyString, KEY_ALL_ACCESS, FALSE);
+    if (NT_SUCCESS(Status))
+    {
+        /* Add the serial number */
+        RtlInitUnicodeString(&KeyString, L"Serial Number");
+        ZwSetValueKey(Handle,
+                      &KeyString,
+                      0,
+                      REG_BINARY,
+                      HalpSerialNumber,
+                      HalpSerialLen);
+                      
+        /* Close the handle */
+        ZwClose(Handle);
+    }
 }
 
-PVOID
+NTSTATUS
 NTAPI
-HalpMapPhysicalMemory64(IN PHYSICAL_ADDRESS PhysicalAddress,
-                        IN ULONG NumberPage)
+INIT_FUNCTION
+HalpMarkAcpiHal(VOID)
 {
-    //
-    // Use kernel memory manager I/O map facilities
-    //
-    return MmMapIoSpace(PhysicalAddress,
-                        NumberPage << PAGE_SHIFT,
-                        MmNonCached);
+    NTSTATUS Status;
+    UNICODE_STRING KeyString;
+    HANDLE KeyHandle;
+    HANDLE Handle;
+    
+    /* Open the control set key */
+    RtlInitUnicodeString(&KeyString,
+                         L"\\REGISTRY\\MACHINE\\SYSTEM\\CURRENTCONTROLSET");
+    Status = HalpOpenRegistryKey(&Handle, 0, &KeyString, KEY_ALL_ACCESS, FALSE);
+    if (NT_SUCCESS(Status))
+    {
+        /* Open the PNP key */
+        RtlInitUnicodeString(&KeyString, L"Control\\Pnp");
+        Status = HalpOpenRegistryKey(&KeyHandle,
+                                     Handle,
+                                     &KeyString,
+                                     KEY_ALL_ACCESS,
+                                     TRUE);
+        /* Close root key */
+        ZwClose(Handle);
+        
+        /* Check if PNP BIOS key exists */
+        if (NT_SUCCESS(Status))
+        {
+            /* Set the disable value to false -- we need the mapper */
+            RtlInitUnicodeString(&KeyString, L"DisableFirmwareMapper");
+            Status = ZwSetValueKey(KeyHandle,
+                                   &KeyString,
+                                   0,
+                                   REG_DWORD,
+                                   &HalDisableFirmwareMapper,
+                                   sizeof(HalDisableFirmwareMapper));
+            
+            /* Close subkey */
+            ZwClose(KeyHandle);
+        }
+    }
+    
+    /* Return status */
+    return Status;
 }
 
+NTSTATUS 
+NTAPI
+HalpOpenRegistryKey(IN PHANDLE KeyHandle,
+                    IN HANDLE RootKey,
+                    IN PUNICODE_STRING KeyName,
+                    IN ACCESS_MASK DesiredAccess, 
+                    IN BOOLEAN Create)
+{
+    NTSTATUS Status;
+    ULONG Disposition;
+    OBJECT_ATTRIBUTES ObjectAttributes;
+    
+    /* Setup the attributes we received */
+    InitializeObjectAttributes(&ObjectAttributes,
+                               KeyName,
+                               OBJ_CASE_INSENSITIVE,
+                               RootKey,
+                               NULL);
+
+    /* What to do? */
+    if ( Create )
+    {
+        /* Create the key */
+        Status = ZwCreateKey(KeyHandle,
+                             DesiredAccess,
+                             &ObjectAttributes,
+                             0,
+                             NULL,
+                             REG_OPTION_VOLATILE,
+                             &Disposition);
+    }
+    else
+    {
+        /* Open the key */
+        Status = ZwOpenKey(KeyHandle, DesiredAccess, &ObjectAttributes);
+    }
+        
+    /* We're done */
+    return Status;
+}
+#endif
+
 VOID
 NTAPI
-HalpUnmapVirtualAddress(IN PVOID VirtualAddress,
-                        IN ULONG NumberPages)
+HalpCheckPowerButton(VOID)
 {
     //
-    // Use kernel memory manager I/O map facilities
+    // Nothing to do on non-ACPI
     //
-    MmUnmapIoSpace(VirtualAddress, NumberPages << PAGE_SHIFT);
+    return;
 }
 
 VOID
@@ -122,6 +222,7 @@ VOID
 NTAPI
 HalHandleNMI(IN PVOID NmiInfo)
 {
+#ifndef _MINIHAL_
     SYSTEM_CONTROL_PORT_B_REGISTER SystemControl;
 
     //
@@ -203,11 +304,13 @@ HalHandleNMI(IN PVOID NmiInfo)
     //
     InbvDisplayString("\n*** The system has halted ***\n");
 
+
     //
     // Enter the debugger if possible
     //
+    KiBugCheckData[0] = (ULONG_PTR)KeServiceDescriptorTable; /* NMI Corruption? */
     //if (!(KdDebuggerNotPresent) && (KdDebuggerEnabled)) KeEnterKernelDebugger();
-
+#endif
     //
     // Freeze the system
     //
@@ -241,3 +344,60 @@ KeFlushWriteBuffer(VOID)
     //
     return;
 }
+
+#ifdef _M_IX86
+/* x86 fastcall wrappers */
+
+#undef KeRaiseIrql
+/*
+ * @implemented
+ */
+VOID
+NTAPI
+KeRaiseIrql(KIRQL NewIrql,
+            PKIRQL OldIrql)
+{
+    /* Call the fastcall function */
+    *OldIrql = KfRaiseIrql(NewIrql);
+}
+
+#undef KeLowerIrql
+/*
+ * @implemented
+ */
+VOID
+NTAPI
+KeLowerIrql(KIRQL NewIrql)
+{
+    /* Call the fastcall function */
+    KfLowerIrql(NewIrql);
+}
+
+#undef KeAcquireSpinLock
+/*
+ * @implemented
+ */
+VOID
+NTAPI
+KeAcquireSpinLock(PKSPIN_LOCK SpinLock,
+                  PKIRQL OldIrql)
+{
+    /* Call the fastcall function */
+    *OldIrql = KfAcquireSpinLock(SpinLock);
+}
+
+#undef KeReleaseSpinLock
+/*
+ * @implemented
+ */
+VOID
+NTAPI
+KeReleaseSpinLock(PKSPIN_LOCK SpinLock,
+                  KIRQL NewIrql)
+{
+    /* Call the fastcall function */
+    KfReleaseSpinLock(SpinLock, NewIrql);
+}
+
+#endif
+