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 **********************************************************/
23 HalpCheckPowerButton(VOID
)
26 // Nothing to do on non-ACPI
37 ULONG_PTR PageDirectory
;
42 Flags
= __readeflags();
46 // Get page table directory base
48 PageDirectory
= __readcr3();
51 // Check for CPUID support
53 if (KeGetCurrentPrcb()->CpuID
)
56 // Check for global bit in CPU features
59 if (CpuInfo
[3] & 0x2000)
62 // Get current CR4 value
69 __writecr4(Cr4
& ~CR4_PGE
);
72 // Flush TLB and re-enable global bit
74 __writecr3(PageDirectory
);
86 // Legacy: just flush TLB
88 __writecr3(PageDirectory
);
92 /* FUNCTIONS *****************************************************************/
99 HalHandleNMI(IN PVOID NmiInfo
)
102 SYSTEM_CONTROL_PORT_B_REGISTER SystemControl
;
107 if (HalpNMIInProgress
++) while (TRUE
);
110 // Read the system control register B
112 SystemControl
.Bits
= __inbyte(SYSTEM_CONTROL_PORT_B
);
115 // Switch to boot vieo
117 if (InbvIsBootDriverInstalled())
122 InbvAcquireDisplayOwnership();
128 InbvSolidColorFill(0, 0, 639, 479, 1);
129 InbvSetScrollRegion(0, 0, 639, 479);
134 InbvSetTextColor(15);
135 InbvInstallDisplayStringFilter(NULL
);
136 InbvEnableDisplayString(TRUE
);
140 // Display NMI failure string
142 InbvDisplayString("\n*** Hardware Malfunction\n\n");
143 InbvDisplayString("Call your hardware vendor for support\n\n");
146 // Check for parity error
148 if (SystemControl
.ParityCheck
)
153 InbvDisplayString("NMI: Parity Check / Memory Parity Error\n");
157 // Check for I/O failure
159 if (SystemControl
.ChannelCheck
)
164 InbvDisplayString("NMI: Channel Check / IOCHK\n");
168 // Check for EISA systems
170 if (HalpBusType
== MACHINE_TYPE_EISA
)
173 // FIXME: Not supported
181 InbvDisplayString("\n*** The system has halted ***\n");
185 // Enter the debugger if possible
187 //if (!(KdDebuggerNotPresent) && (KdDebuggerEnabled)) KeEnterKernelDebugger();
200 HalSystemVectorDispatchEntry(IN ULONG Vector
,
201 OUT PKINTERRUPT_ROUTINE
**FlatDispatch
,
202 OUT PKINTERRUPT_ROUTINE
*NoConnection
)
205 // Not implemented on x86
215 KeFlushWriteBuffer(VOID
)
218 // Not implemented on x86
224 /* x86 fastcall wrappers */
232 KeRaiseIrql(KIRQL NewIrql
,
235 /* Call the fastcall function */
236 *OldIrql
= KfRaiseIrql(NewIrql
);
245 KeLowerIrql(KIRQL NewIrql
)
247 /* Call the fastcall function */
248 KfLowerIrql(NewIrql
);
251 #undef KeAcquireSpinLock
257 KeAcquireSpinLock(PKSPIN_LOCK SpinLock
,
260 /* Call the fastcall function */
261 *OldIrql
= KfAcquireSpinLock(SpinLock
);
264 #undef KeReleaseSpinLock
270 KeReleaseSpinLock(PKSPIN_LOCK SpinLock
,
273 /* Call the fastcall function */
274 KfReleaseSpinLock(SpinLock
, NewIrql
);