2 * PROJECT: ReactOS Hardware Abstraction Layer (HAL)
3 * LICENSE: BSD - See COPYING.ARM in the top level directory
4 * FILE: halx86/generic/misc.c
5 * PURPOSE: NMI, I/O Mapping and x86 Subs
6 * PROGRAMMERS: ReactOS Portable Systems Group
9 /* INCLUDES *******************************************************************/
15 /* GLOBALS *******************************************************************/
17 BOOLEAN HalpNMIInProgress
;
19 /* PRIVATE FUNCTIONS **********************************************************/
24 HalpOpenRegistryKey(IN PHANDLE KeyHandle
,
26 IN PUNICODE_STRING KeyName
,
27 IN ACCESS_MASK DesiredAccess
,
32 OBJECT_ATTRIBUTES ObjectAttributes
;
34 /* Setup the attributes we received */
35 InitializeObjectAttributes(&ObjectAttributes
,
45 Status
= ZwCreateKey(KeyHandle
,
56 Status
= ZwOpenKey(KeyHandle
, DesiredAccess
, &ObjectAttributes
);
66 HalpCheckPowerButton(VOID
)
69 // Nothing to do on non-ACPI
80 ULONG_PTR PageDirectory
;
85 Flags
= __readeflags();
89 // Get page table directory base
91 PageDirectory
= __readcr3();
94 // Check for CPUID support
96 if (KeGetCurrentPrcb()->CpuID
)
99 // Check for global bit in CPU features
102 if (CpuInfo
[3] & 0x2000)
105 // Get current CR4 value
110 // Disable global bit
112 __writecr4(Cr4
& ~CR4_PGE
);
115 // Flush TLB and re-enable global bit
117 __writecr3(PageDirectory
);
121 // Restore interrupts
123 __writeeflags(Flags
);
129 // Legacy: just flush TLB
131 __writecr3(PageDirectory
);
132 __writeeflags(Flags
);
135 /* FUNCTIONS *****************************************************************/
142 HalHandleNMI(IN PVOID NmiInfo
)
145 SYSTEM_CONTROL_PORT_B_REGISTER SystemControl
;
150 if (HalpNMIInProgress
++) while (TRUE
);
153 // Read the system control register B
155 SystemControl
.Bits
= __inbyte(SYSTEM_CONTROL_PORT_B
);
158 // Switch to boot vieo
160 if (InbvIsBootDriverInstalled())
165 InbvAcquireDisplayOwnership();
171 InbvSolidColorFill(0, 0, 639, 479, 1);
172 InbvSetScrollRegion(0, 0, 639, 479);
177 InbvSetTextColor(15);
178 InbvInstallDisplayStringFilter(NULL
);
179 InbvEnableDisplayString(TRUE
);
183 // Display NMI failure string
185 InbvDisplayString("\n*** Hardware Malfunction\n\n");
186 InbvDisplayString("Call your hardware vendor for support\n\n");
189 // Check for parity error
191 if (SystemControl
.ParityCheck
)
196 InbvDisplayString("NMI: Parity Check / Memory Parity Error\n");
200 // Check for I/O failure
202 if (SystemControl
.ChannelCheck
)
207 InbvDisplayString("NMI: Channel Check / IOCHK\n");
211 // Check for EISA systems
213 if (HalpBusType
== MACHINE_TYPE_EISA
)
216 // FIXME: Not supported
224 InbvDisplayString("\n*** The system has halted ***\n");
228 // Enter the debugger if possible
230 //if (!(KdDebuggerNotPresent) && (KdDebuggerEnabled)) KeEnterKernelDebugger();
243 HalSystemVectorDispatchEntry(IN ULONG Vector
,
244 OUT PKINTERRUPT_ROUTINE
**FlatDispatch
,
245 OUT PKINTERRUPT_ROUTINE
*NoConnection
)
248 // Not implemented on x86
258 KeFlushWriteBuffer(VOID
)
261 // Not implemented on x86
267 /* x86 fastcall wrappers */
275 KeRaiseIrql(KIRQL NewIrql
,
278 /* Call the fastcall function */
279 *OldIrql
= KfRaiseIrql(NewIrql
);
288 KeLowerIrql(KIRQL NewIrql
)
290 /* Call the fastcall function */
291 KfLowerIrql(NewIrql
);
294 #undef KeAcquireSpinLock
300 KeAcquireSpinLock(PKSPIN_LOCK SpinLock
,
303 /* Call the fastcall function */
304 *OldIrql
= KfAcquireSpinLock(SpinLock
);
307 #undef KeReleaseSpinLock
313 KeReleaseSpinLock(PKSPIN_LOCK SpinLock
,
316 /* Call the fastcall function */
317 KfReleaseSpinLock(SpinLock
, NewIrql
);