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
34 HalpMapPhysicalMemory64(IN PHYSICAL_ADDRESS PhysicalAddress
,
38 // Use kernel memory manager I/O map facilities
40 return MmMapIoSpace(PhysicalAddress
,
41 NumberPage
<< PAGE_SHIFT
,
47 HalpUnmapVirtualAddress(IN PVOID VirtualAddress
,
51 // Use kernel memory manager I/O map facilities
53 MmUnmapIoSpace(VirtualAddress
, NumberPages
<< PAGE_SHIFT
);
63 ULONG_PTR PageDirectory
;
68 Flags
= __readeflags();
72 // Get page table directory base
74 PageDirectory
= __readcr3();
77 // Check for CPUID support
79 if (KeGetCurrentPrcb()->CpuID
)
82 // Check for global bit in CPU features
85 if (CpuInfo
[3] & 0x2000)
88 // Get current CR4 value
95 __writecr4(Cr4
& ~CR4_PGE
);
98 // Flush TLB and re-enable global bit
100 __writecr3(PageDirectory
);
104 // Restore interrupts
106 __writeeflags(Flags
);
112 // Legacy: just flush TLB
114 __writecr3(PageDirectory
);
115 __writeeflags(Flags
);
118 /* FUNCTIONS *****************************************************************/
125 HalHandleNMI(IN PVOID NmiInfo
)
128 SYSTEM_CONTROL_PORT_B_REGISTER SystemControl
;
133 if (HalpNMIInProgress
++) while (TRUE
);
136 // Read the system control register B
138 SystemControl
.Bits
= __inbyte(SYSTEM_CONTROL_PORT_B
);
141 // Switch to boot vieo
143 if (InbvIsBootDriverInstalled())
148 InbvAcquireDisplayOwnership();
154 InbvSolidColorFill(0, 0, 639, 479, 1);
155 InbvSetScrollRegion(0, 0, 639, 479);
160 InbvSetTextColor(15);
161 InbvInstallDisplayStringFilter(NULL
);
162 InbvEnableDisplayString(TRUE
);
166 // Display NMI failure string
168 InbvDisplayString("\n*** Hardware Malfunction\n\n");
169 InbvDisplayString("Call your hardware vendor for support\n\n");
172 // Check for parity error
174 if (SystemControl
.ParityCheck
)
179 InbvDisplayString("NMI: Parity Check / Memory Parity Error\n");
183 // Check for I/O failure
185 if (SystemControl
.ChannelCheck
)
190 InbvDisplayString("NMI: Channel Check / IOCHK\n");
194 // Check for EISA systems
196 if (HalpBusType
== MACHINE_TYPE_EISA
)
199 // FIXME: Not supported
207 InbvDisplayString("\n*** The system has halted ***\n");
211 // Enter the debugger if possible
213 //if (!(KdDebuggerNotPresent) && (KdDebuggerEnabled)) KeEnterKernelDebugger();
226 HalSystemVectorDispatchEntry(IN ULONG Vector
,
227 OUT PKINTERRUPT_ROUTINE
**FlatDispatch
,
228 OUT PKINTERRUPT_ROUTINE
*NoConnection
)
231 // Not implemented on x86
241 KeFlushWriteBuffer(VOID
)
244 // Not implemented on x86