xref: /reactos/sdk/include/ndk/haltypes.h (revision 9cfd8dd9)
1 /*++ NDK Version: 0098
2 
3 Copyright (c) Alex Ionescu.  All rights reserved.
4 
5 Header Name:
6 
7     haltypes.h
8 
9 Abstract:
10 
11     Type definitions for the HAL.
12 
13 Author:
14 
15     Alex Ionescu (alexi@tinykrnl.org) - Updated - 27-Feb-2006
16 
17 --*/
18 
19 #ifndef _HALTYPES_H
20 #define _HALTYPES_H
21 
22 //
23 // Dependencies
24 //
25 #include <umtypes.h>
26 
27 #ifndef NTOS_MODE_USER
28 
29 //
30 // HalShutdownSystem Types
31 //
32 typedef enum _FIRMWARE_REENTRY
33 {
34     HalHaltRoutine,
35     HalPowerDownRoutine,
36     HalRestartRoutine,
37     HalRebootRoutine,
38     HalInteractiveModeRoutine,
39     HalMaximumRoutine
40 } FIRMWARE_REENTRY, *PFIRMWARE_REENTRY;
41 
42 //
43 // HAL Private function Types
44 //
45 typedef
46 PBUS_HANDLER
47 (FASTCALL *pHalHandlerForConfigSpace)(
48     _In_ BUS_DATA_TYPE ConfigSpace,
49     _In_ ULONG BusNumber
50 );
51 
52 typedef
53 NTSTATUS
54 (NTAPI *PINSTALL_BUS_HANDLER)(
55     _In_ PBUS_HANDLER Bus
56 );
57 
58 typedef
59 NTSTATUS
60 (NTAPI *pHalRegisterBusHandler)(
61     _In_ INTERFACE_TYPE InterfaceType,
62     _In_ BUS_DATA_TYPE ConfigSpace,
63     _In_ ULONG BusNumber,
64     _In_ INTERFACE_TYPE ParentInterfaceType,
65     _In_ ULONG ParentBusNumber,
66     _In_ ULONG ContextSize,
67     _In_ PINSTALL_BUS_HANDLER InstallCallback,
68     _Out_ PBUS_HANDLER *BusHandler
69 );
70 
71 typedef
72 VOID
73 (NTAPI *pHalSetWakeEnable)(
74     _In_ BOOLEAN Enable
75 );
76 
77 typedef
78 VOID
79 (NTAPI *pHalSetWakeAlarm)(
80     _In_ ULONGLONG AlartTime,
81     _In_ PTIME_FIELDS TimeFields
82 );
83 
84 typedef
85 VOID
86 (NTAPI *pHalLocateHiberRanges)(
87     _In_ PVOID MemoryMap
88 );
89 
90 typedef
91 NTSTATUS
92 (NTAPI *pHalAllocateMapRegisters)(
93     _In_ PADAPTER_OBJECT AdapterObject,
94     _In_ ULONG Unknown,
95     _In_ ULONG Unknown2,
96     PMAP_REGISTER_ENTRY Registers
97 );
98 
99 //
100 // HAL Bus Handler Callback Types
101 //
102 typedef
103 NTSTATUS
104 (NTAPI *PADJUSTRESOURCELIST)(
105     _In_ PBUS_HANDLER BusHandler,
106     _In_ PBUS_HANDLER RootHandler,
107     _Inout_ PIO_RESOURCE_REQUIREMENTS_LIST* pResourceList
108 );
109 
110 typedef
111 NTSTATUS
112 (NTAPI *PASSIGNSLOTRESOURCES)(
113     _In_ PBUS_HANDLER BusHandler,
114     _In_ PBUS_HANDLER RootHandler,
115     _In_ PUNICODE_STRING RegistryPath,
116     _In_opt_ PUNICODE_STRING DriverClassName,
117     _In_ PDRIVER_OBJECT DriverObject,
118     _In_opt_ PDEVICE_OBJECT DeviceObject,
119     _In_ ULONG SlotNumber,
120     _Inout_ PCM_RESOURCE_LIST* AllocatedResources
121 );
122 
123 typedef
124 ULONG
125 (NTAPI *PGETSETBUSDATA)(
126     _In_ PBUS_HANDLER BusHandler,
127     _In_ PBUS_HANDLER RootHandler,
128     _In_ ULONG SlotNumber,
129     _In_ PVOID Buffer,
130     _In_ ULONG Offset,
131     _In_ ULONG Length
132 );
133 
134 typedef
135 ULONG
136 (NTAPI *PGETINTERRUPTVECTOR)(
137     _In_ PBUS_HANDLER BusHandler,
138     _In_ PBUS_HANDLER RootHandler,
139     _In_ ULONG BusInterruptLevel,
140     _In_ ULONG BusInterruptVector,
141     _Out_ PKIRQL Irql,
142     _Out_ PKAFFINITY Affinity
143 );
144 
145 typedef
146 BOOLEAN
147 (NTAPI *PTRANSLATEBUSADDRESS)(
148     _In_ PBUS_HANDLER BusHandler,
149     _In_ PBUS_HANDLER RootHandler,
150     _In_ PHYSICAL_ADDRESS BusAddress,
151     _Inout_ PULONG AddressSpace,
152     _Out_ PPHYSICAL_ADDRESS TranslatedAddress
153 );
154 
155 //
156 // HAL Private dispatch Table
157 //
158 // See Version table at:
159 // https://www.geoffchappell.com/studies/windows/km/ntoskrnl/inc/ntos/hal/hal_private_dispatch.htm
160 //
161 #if (NTDDI_VERSION < NTDDI_WINXP)
162 #define HAL_PRIVATE_DISPATCH_VERSION        1
163 #elif (NTDDI_VERSION < NTDDI_LONGHORN)
164 #define HAL_PRIVATE_DISPATCH_VERSION        2
165 #elif (NTDDI_VERSION >= NTDDI_LONGHORN)
166 #define HAL_PRIVATE_DISPATCH_VERSION        5
167 #else
168 /* Not yet defined */
169 #endif
170 typedef struct _HAL_PRIVATE_DISPATCH
171 {
172     ULONG Version;
173     pHalHandlerForBus HalHandlerForBus;
174     pHalHandlerForConfigSpace HalHandlerForConfigSpace;
175     pHalLocateHiberRanges HalLocateHiberRanges;
176     pHalRegisterBusHandler HalRegisterBusHandler;
177     pHalSetWakeEnable HalSetWakeEnable;
178     pHalSetWakeAlarm HalSetWakeAlarm;
179     pHalTranslateBusAddress HalPciTranslateBusAddress;
180     pHalAssignSlotResources HalPciAssignSlotResources;
181     pHalHaltSystem HalHaltSystem;
182     pHalFindBusAddressTranslation HalFindBusAddressTranslation;
183     pHalResetDisplay HalResetDisplay;
184     pHalAllocateMapRegisters HalAllocateMapRegisters;
185     pKdSetupPciDeviceForDebugging KdSetupPciDeviceForDebugging;
186     pKdReleasePciDeviceForDebugging KdReleasePciDeviceforDebugging;
187     pKdGetAcpiTablePhase0 KdGetAcpiTablePhase0;
188     pKdCheckPowerButton KdCheckPowerButton;
189     pHalVectorToIDTEntry HalVectorToIDTEntry;
190     pKdMapPhysicalMemory64 KdMapPhysicalMemory64;
191     pKdUnmapVirtualAddress KdUnmapVirtualAddress;
192 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
193     pKdGetPciDataByOffset KdGetPciDataByOffset;
194     pKdSetPciDataByOffset KdSetPciDataByOffset;
195     PVOID HalGetInterruptVectorOverride;
196     PVOID HalGetVectorInputOverride;
197 #endif
198 } HAL_PRIVATE_DISPATCH, *PHAL_PRIVATE_DISPATCH;
199 
200 //
201 // HAL Supported Range
202 //
203 #define HAL_SUPPORTED_RANGE_VERSION 1
204 typedef struct _SUPPORTED_RANGE
205 {
206     struct _SUPPORTED_RANGE *Next;
207     ULONG SystemAddressSpace;
208     LONGLONG SystemBase;
209     LONGLONG Base;
210     LONGLONG Limit;
211 } SUPPORTED_RANGE, *PSUPPORTED_RANGE;
212 
213 typedef struct _SUPPORTED_RANGES
214 {
215     USHORT Version;
216     BOOLEAN Sorted;
217     UCHAR Reserved;
218     ULONG NoIO;
219     SUPPORTED_RANGE IO;
220     ULONG NoMemory;
221     SUPPORTED_RANGE Memory;
222     ULONG NoPrefetchMemory;
223     SUPPORTED_RANGE PrefetchMemory;
224     ULONG NoDma;
225     SUPPORTED_RANGE Dma;
226 } SUPPORTED_RANGES, *PSUPPORTED_RANGES;
227 
228 //
229 // HAL Bus Handler
230 //
231 #define HAL_BUS_HANDLER_VERSION 1
232 typedef struct _BUS_HANDLER
233 {
234     ULONG Version;
235     INTERFACE_TYPE InterfaceType;
236     BUS_DATA_TYPE ConfigurationType;
237     ULONG BusNumber;
238     PDEVICE_OBJECT DeviceObject;
239     struct _BUS_HANDLER *ParentHandler;
240     PVOID BusData;
241     ULONG DeviceControlExtensionSize;
242     PSUPPORTED_RANGES BusAddresses;
243     ULONG Reserved[4];
244     PGETSETBUSDATA GetBusData;
245     PGETSETBUSDATA SetBusData;
246     PADJUSTRESOURCELIST AdjustResourceList;
247     PASSIGNSLOTRESOURCES AssignSlotResources;
248     PGETINTERRUPTVECTOR GetInterruptVector;
249     PTRANSLATEBUSADDRESS TranslateBusAddress;
250     PVOID Spare1;
251     PVOID Spare2;
252     PVOID Spare3;
253     PVOID Spare4;
254     PVOID Spare5;
255     PVOID Spare6;
256     PVOID Spare7;
257     PVOID Spare8;
258 } BUS_HANDLER;
259 
260 //
261 // HAL Chip Hacks
262 //
263 #define HAL_PCI_CHIP_HACK_BROKEN_ACPI_TIMER        0x01
264 #define HAL_PCI_CHIP_HACK_DISABLE_HIBERNATE        0x02
265 #define HAL_PCI_CHIP_HACK_DISABLE_ACPI_IRQ_ROUTING 0x04
266 #define HAL_PCI_CHIP_HACK_USB_SMI_DISABLE          0x08
267 
268 //
269 // Kernel Exports
270 //
271 #if !defined(_NTSYSTEM_) && (defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_))
272 extern NTSYSAPI PHAL_PRIVATE_DISPATCH HalPrivateDispatchTable;
273 #define HALPRIVATEDISPATCH ((PHAL_PRIVATE_DISPATCH)&HalPrivateDispatchTable)
274 #else
275 extern NTSYSAPI HAL_PRIVATE_DISPATCH HalPrivateDispatchTable;
276 #define HALPRIVATEDISPATCH (&HalPrivateDispatchTable)
277 #endif
278 
279 //
280 // HAL Exports
281 //
282 extern NTHALAPI PUCHAR KdComPortInUse;
283 
284 //
285 // HAL Constants
286 //
287 #define HAL_IRQ_TRANSLATOR_VERSION 0x0
288 
289 //
290 // BIOS call structure
291 //
292 typedef struct _X86_BIOS_REGISTERS
293 {
294     ULONG Eax;
295     ULONG Ecx;
296     ULONG Edx;
297     ULONG Ebx;
298     ULONG Ebp;
299     ULONG Esi;
300     ULONG Edi;
301     USHORT SegDs;
302     USHORT SegEs;
303 } X86_BIOS_REGISTERS, *PX86_BIOS_REGISTERS;
304 
305 #endif
306 #endif
307 
308 
309 
310