[HAL]: Split HalReportResouceUsage into per-platform function, since PC/AT HAL and...
[reactos.git] / reactos / hal / halx86 / generic / usage.c
1 /*
2 * PROJECT: ReactOS HAL
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: hal/halx86/generic/usage.c
5 * PURPOSE: HAL Resource Report Routines
6 * PROGRAMMERS: Stefan Ginsberg (stefan.ginsberg@reactos.org)
7 */
8
9 /* INCLUDES *******************************************************************/
10
11 #include <hal.h>
12 #define NDEBUG
13 #include <debug.h>
14
15 /* GLOBALS ********************************************************************/
16
17 BOOLEAN HalpNMIDumpFlag;
18 PUCHAR KdComPortInUse;
19 PADDRESS_USAGE HalpAddressUsageList;
20 IDTUsageFlags HalpIDTUsageFlags[MAXIMUM_IDTVECTOR];
21 IDTUsage HalpIDTUsage[MAXIMUM_IDTVECTOR];
22
23 ADDRESS_USAGE HalpDefaultIoSpace =
24 {
25 NULL, CmResourceTypePort, IDT_INTERNAL,
26 {
27 {0x2000, 0xC000}, /* PIC?? */
28 {0xC000, 0x1000}, /* DMA 2 */
29 {0x8000, 0x1000}, /* DMA 1 */
30 {0x2000, 0x200}, /* PIC 1 */
31 {0xA000, 0x200}, /* PIC 2 */
32 {0x4000, 0x400}, /* PIT 1 */
33 {0x4800, 0x400}, /* PIT 2 */
34 {0x9200, 0x100}, /* ????? */
35 {0x7000, 0x200}, /* CMOS */
36 {0xF000, 0x1000}, /* ????? */
37 {0xCF800, 0x800}, /* PCI 0 */
38 {0,0},
39 }
40 };
41
42 /* FUNCTIONS ******************************************************************/
43
44 VOID
45 NTAPI
46 HalpReportResourceUsage(IN PUNICODE_STRING HalName,
47 IN INTERFACE_TYPE InterfaceType)
48 {
49 DbgPrint("%wZ has been initialized\n", HalName);
50 }
51
52 VOID
53 NTAPI
54 HalpRegisterVector(IN UCHAR Flags,
55 IN ULONG BusVector,
56 IN ULONG SystemVector,
57 IN KIRQL Irql)
58 {
59 /* Save the vector flags */
60 HalpIDTUsageFlags[SystemVector].Flags = Flags;
61
62 /* Save the vector data */
63 HalpIDTUsage[SystemVector].Irql = Irql;
64 HalpIDTUsage[SystemVector].BusReleativeVector = BusVector;
65 }
66
67 #ifndef _MINIHAL_
68 VOID
69 NTAPI
70 HalpEnableInterruptHandler(IN UCHAR Flags,
71 IN ULONG BusVector,
72 IN ULONG SystemVector,
73 IN KIRQL Irql,
74 IN PVOID Handler,
75 IN KINTERRUPT_MODE Mode)
76 {
77 UCHAR Entry;
78
79 /* Convert the vector into the IDT entry */
80 Entry = HalVectorToIDTEntry(SystemVector);
81
82 /* Register the vector */
83 HalpRegisterVector(Flags, BusVector, SystemVector, Irql);
84
85 /* Connect the interrupt */
86 ((PKIPCR)KeGetPcr())->IDT[Entry].ExtendedOffset = (USHORT)(((ULONG_PTR)Handler >> 16) & 0xFFFF);
87 ((PKIPCR)KeGetPcr())->IDT[Entry].Offset = (USHORT)((ULONG_PTR)Handler);
88
89 /* Enable the interrupt */
90 HalEnableSystemInterrupt(SystemVector, Irql, Mode);
91 }
92
93 VOID
94 NTAPI
95 HalpGetNMICrashFlag(VOID)
96 {
97 UNICODE_STRING ValueName;
98 UNICODE_STRING KeyName = RTL_CONSTANT_STRING(L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\CrashControl");
99 OBJECT_ATTRIBUTES ObjectAttributes;
100 ULONG ResultLength;
101 HANDLE Handle;
102 NTSTATUS Status;
103 KEY_VALUE_PARTIAL_INFORMATION KeyValueInformation;
104
105 /* Set default */
106 HalpNMIDumpFlag = 0;
107
108 /* Initialize attributes */
109 InitializeObjectAttributes(&ObjectAttributes,
110 &KeyName,
111 OBJ_CASE_INSENSITIVE,
112 NULL,
113 NULL);
114
115 /* Open crash key */
116 Status = ZwOpenKey(&Handle, KEY_READ, &ObjectAttributes);
117 if (NT_SUCCESS(Status))
118 {
119 /* Query key value */
120 RtlInitUnicodeString(&ValueName, L"NMICrashDump");
121 Status = ZwQueryValueKey(Handle,
122 &ValueName,
123 KeyValuePartialInformation,
124 &KeyValueInformation,
125 sizeof(KeyValueInformation),
126 &ResultLength);
127 if (NT_SUCCESS(Status))
128 {
129 /* Check for valid data */
130 if (ResultLength == sizeof(KEY_VALUE_PARTIAL_INFORMATION))
131 {
132 /* Read the flag */
133 HalpNMIDumpFlag = KeyValueInformation.Data[0];
134 }
135 }
136
137 /* We're done */
138 ZwClose(Handle);
139 }
140 }
141 #endif
142
143 /* EOF */
144