3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: hal/halx86/generic/misc.c
5 * PURPOSE: Miscellanous Routines
6 * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
7 * Eric Kohl (ekohl@abo.rhein-zeitung.de)
8 * Timo Kreuzer (timo.kreuzer@reactos.org)
11 /* INCLUDES ******************************************************************/
17 LARGE_INTEGER HalpPerformanceFrequency
;
19 /* PRIVATE FUNCTIONS *********************************************************/
23 HalpCheckPowerButton(VOID
)
25 /* Nothing to do on non-ACPI */
31 HalpMapPhysicalMemory64(IN PHYSICAL_ADDRESS PhysicalAddress
,
34 /* Use kernel memory manager I/O map facilities */
35 return MmMapIoSpace(PhysicalAddress
,
36 NumberPage
<< PAGE_SHIFT
,
42 HalpUnmapVirtualAddress(IN PVOID VirtualAddress
,
45 /* Use kernel memory manager I/O map facilities */
46 MmUnmapIoSpace(VirtualAddress
, NumberPages
<< PAGE_SHIFT
);
51 HalpInitIdtEntry(PKIDTENTRY64 Idt
, PVOID Address
)
53 Idt
->OffsetLow
= (ULONG_PTR
)Address
& 0xffff;
54 Idt
->OffsetMiddle
= ((ULONG_PTR
)Address
>> 16) & 0xffff;
55 Idt
->OffsetHigh
= (ULONG_PTR
)Address
>> 32;
56 Idt
->Selector
= KGDT_64_R0_CODE
;
67 HalpSetInterruptGate(ULONG Index
, PVOID Address
)
71 /* Disable interupts */
72 Flags
= __readeflags();
75 /* Initialize the entry */
76 HalpInitIdtEntry(&KeGetPcr()->IdtBase
[Index
], Address
);
78 /* Enable interrupts if they were enabled previously */
83 /* FUNCTIONS *****************************************************************/
90 HalHandleNMI(IN PVOID NmiInfo
)
94 /* Get the NMI Flag */
95 ucStatus
= READ_PORT_UCHAR((PUCHAR
)0x61);
97 /* Display NMI failure string */
98 HalDisplayString ("\n*** Hardware Malfunction\n\n");
99 HalDisplayString ("Call your hardware vendor for support\n\n");
101 /* Check for parity error */
104 /* Display message */
105 HalDisplayString ("NMI: Parity Check / Memory Parity Error\n");
108 /* Check for I/O failure */
111 /* Display message */
112 HalDisplayString ("NMI: Channel Check / IOCHK\n");
115 /* Halt the system */
116 HalDisplayString("\n*** The system has halted ***\n");
117 //KeEnterKernelDebugger();
125 HalSystemVectorDispatchEntry(IN ULONG Vector
,
126 OUT PKINTERRUPT_ROUTINE
**FlatDispatch
,
127 OUT PKINTERRUPT_ROUTINE
*NoConnection
)
129 /* Not implemented on x86 */
135 HalBugCheckSystem (PVOID ErrorRecord
)
146 KeFlushWriteBuffer(VOID
)
148 /* Not implemented on x86 */
154 KeQueryPerformanceCounter(
155 OUT PLARGE_INTEGER PerformanceFrequency OPTIONAL
)
157 LARGE_INTEGER Result
;
159 ASSERT(HalpPerformanceFrequency
.QuadPart
!= 0);
161 /* Does the caller want the frequency? */
162 if (PerformanceFrequency
)
165 *PerformanceFrequency
= HalpPerformanceFrequency
;
168 Result
.QuadPart
= __rdtsc();