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
33 HalpMapPhysicalMemory64(IN PHYSICAL_ADDRESS PhysicalAddress
,
37 // Use kernel memory manager I/O map facilities
39 return MmMapIoSpace(PhysicalAddress
,
40 NumberPage
<< PAGE_SHIFT
,
46 HalpUnmapVirtualAddress(IN PVOID VirtualAddress
,
50 // Use kernel memory manager I/O map facilities
52 MmUnmapIoSpace(VirtualAddress
, NumberPages
<< PAGE_SHIFT
);
61 ULONG_PTR PageDirectory
;
66 Flags
= __readeflags();
70 // Get page table directory base
72 PageDirectory
= __readcr3();
75 // Check for CPUID support
77 if (KeGetCurrentPrcb()->CpuID
)
80 // Check for global bit in CPU features
83 if (CpuInfo
[3] & 0x2000)
86 // Get current CR4 value
93 __writecr4(Cr4
& ~CR4_PGE
);
96 // Flush TLB and re-enable global bit
98 __writecr3(PageDirectory
);
102 // Restore interrupts
104 __writeeflags(Flags
);
110 // Legacy: just flush TLB
112 __writecr3(PageDirectory
);
113 __writeeflags(Flags
);
116 /* FUNCTIONS *****************************************************************/
123 HalHandleNMI(IN PVOID NmiInfo
)
125 SYSTEM_CONTROL_PORT_B_REGISTER SystemControl
;
130 if (HalpNMIInProgress
++) while (TRUE
);
133 // Read the system control register B
135 SystemControl
.Bits
= __inbyte(SYSTEM_CONTROL_PORT_B
);
138 // Switch to boot vieo
140 if (InbvIsBootDriverInstalled())
145 InbvAcquireDisplayOwnership();
151 InbvSolidColorFill(0, 0, 639, 479, 1);
152 InbvSetScrollRegion(0, 0, 639, 479);
157 InbvSetTextColor(15);
158 InbvInstallDisplayStringFilter(NULL
);
159 InbvEnableDisplayString(TRUE
);
163 // Display NMI failure string
165 InbvDisplayString("\n*** Hardware Malfunction\n\n");
166 InbvDisplayString("Call your hardware vendor for support\n\n");
169 // Check for parity error
171 if (SystemControl
.ParityCheck
)
176 InbvDisplayString("NMI: Parity Check / Memory Parity Error\n");
180 // Check for I/O failure
182 if (SystemControl
.ChannelCheck
)
187 InbvDisplayString("NMI: Channel Check / IOCHK\n");
191 // Check for EISA systems
193 if (HalpBusType
== MACHINE_TYPE_EISA
)
196 // FIXME: Not supported
204 InbvDisplayString("\n*** The system has halted ***\n");
207 // Enter the debugger if possible
209 //if (!(KdDebuggerNotPresent) && (KdDebuggerEnabled)) KeEnterKernelDebugger();
222 HalSystemVectorDispatchEntry(IN ULONG Vector
,
223 OUT PKINTERRUPT_ROUTINE
**FlatDispatch
,
224 OUT PKINTERRUPT_ROUTINE
*NoConnection
)
227 // Not implemented on x86
237 KeFlushWriteBuffer(VOID
)
240 // Not implemented on x86