ca6af7129f695a88f22e6f69e3e8be16769968c6
[reactos.git] / reactos / hal / halx86 / generic / misc.c
1 /*
2 * PROJECT: ReactOS HAL
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 */
9
10 /* INCLUDES ******************************************************************/
11
12 #include <hal.h>
13 #define NDEBUG
14 #include <debug.h>
15
16 /* PRIVATE FUNCTIONS *********************************************************/
17
18 VOID
19 NTAPI
20 HalpCheckPowerButton(VOID)
21 {
22 /* Nothing to do on non-ACPI */
23 return;
24 }
25
26 PVOID
27 NTAPI
28 HalpMapPhysicalMemory64(IN PHYSICAL_ADDRESS PhysicalAddress,
29 IN ULONG NumberPage)
30 {
31 /* Use kernel memory manager I/O map facilities */
32 return MmMapIoSpace(PhysicalAddress,
33 NumberPage << PAGE_SHIFT,
34 MmNonCached);
35 }
36
37 VOID
38 NTAPI
39 HalpUnmapVirtualAddress(IN PVOID VirtualAddress,
40 IN ULONG NumberPages)
41 {
42 /* Use kernel memory manager I/O map facilities */
43 MmUnmapIoSpace(VirtualAddress, NumberPages << PAGE_SHIFT);
44 }
45
46 VOID
47 NTAPI
48 HalpSetInterruptGate(ULONG Index, PVOID address)
49 {
50 KIDTENTRY *idt;
51 KIDT_ACCESS Access;
52
53 /* Set the IDT Access Bits */
54 Access.Reserved = 0;
55 Access.Present = 1;
56 Access.Dpl = 0; /* Kernel-Mode */
57 Access.SystemSegmentFlag = 0;
58 Access.SegmentType = I386_INTERRUPT_GATE;
59
60 idt = (KIDTENTRY*)((ULONG)KeGetPcr()->IDT + index * sizeof(KIDTENTRY));
61 idt->Offset = (USHORT)((ULONG_PTR)address & 0xffff);
62 idt->Selector = KGDT_R0_CODE;
63 idt->Access = Access.Value;
64 idt->ExtendedOffset = (USHORT)((ULONG_PTR)address >> 16);
65 }
66
67 /* FUNCTIONS *****************************************************************/
68
69 /*
70 * @implemented
71 */
72 VOID
73 NTAPI
74 HalHandleNMI(IN PVOID NmiInfo)
75 {
76 UCHAR ucStatus;
77
78 /* Get the NMI Flag */
79 ucStatus = READ_PORT_UCHAR((PUCHAR)0x61);
80
81 /* Display NMI failure string */
82 HalDisplayString ("\n*** Hardware Malfunction\n\n");
83 HalDisplayString ("Call your hardware vendor for support\n\n");
84
85 /* Check for parity error */
86 if (ucStatus & 0x80)
87 {
88 /* Display message */
89 HalDisplayString ("NMI: Parity Check / Memory Parity Error\n");
90 }
91
92 /* Check for I/O failure */
93 if (ucStatus & 0x40)
94 {
95 /* Display message */
96 HalDisplayString ("NMI: Channel Check / IOCHK\n");
97 }
98
99 /* Halt the system */
100 HalDisplayString("\n*** The system has halted ***\n");
101 //KeEnterKernelDebugger();
102 }
103
104 /*
105 * @implemented
106 */
107 UCHAR
108 FASTCALL
109 HalSystemVectorDispatchEntry(IN ULONG Vector,
110 OUT PKINTERRUPT_ROUTINE **FlatDispatch,
111 OUT PKINTERRUPT_ROUTINE *NoConnection)
112 {
113 /* Not implemented on x86 */
114 return 0;
115 }
116
117 /*
118 * @implemented
119 */
120 VOID
121 NTAPI
122 KeFlushWriteBuffer(VOID)
123 {
124 /* Not implemented on x86 */
125 return;
126 }
127