xref: /reactos/sdk/include/ndk/haltypes.h (revision 019f21ee)
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 *Resources
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_ PUNICODE_STRING DriverClassName,
117     _In_ PDRIVER_OBJECT DriverObject,
118     _In_ 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     _Out_ 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 #define HAL_PRIVATE_DISPATCH_VERSION        2
159 typedef struct _HAL_PRIVATE_DISPATCH
160 {
161     ULONG Version;
162     pHalHandlerForBus HalHandlerForBus;
163     pHalHandlerForConfigSpace HalHandlerForConfigSpace;
164     pHalLocateHiberRanges HalLocateHiberRanges;
165     pHalRegisterBusHandler HalRegisterBusHandler;
166     pHalSetWakeEnable HalSetWakeEnable;
167     pHalSetWakeAlarm HalSetWakeAlarm;
168     pHalTranslateBusAddress HalPciTranslateBusAddress;
169     pHalAssignSlotResources HalPciAssignSlotResources;
170     pHalHaltSystem HalHaltSystem;
171     pHalFindBusAddressTranslation HalFindBusAddressTranslation;
172     pHalResetDisplay HalResetDisplay;
173     pHalAllocateMapRegisters HalAllocateMapRegisters;
174     pKdSetupPciDeviceForDebugging KdSetupPciDeviceForDebugging;
175     pKdReleasePciDeviceForDebugging KdReleasePciDeviceforDebugging;
176     pKdGetAcpiTablePhase0 KdGetAcpiTablePhase0;
177     pKdCheckPowerButton KdCheckPowerButton;
178     pHalVectorToIDTEntry HalVectorToIDTEntry;
179     pKdMapPhysicalMemory64 KdMapPhysicalMemory64;
180     pKdUnmapVirtualAddress KdUnmapVirtualAddress;
181 #if (NTDDI_VERSION >= NTDDI_LONGHORN)
182     pKdGetPciDataByOffset KdGetPciDataByOffset;
183     pKdSetPciDataByOffset KdSetPciDataByOffset;
184     PVOID HalGetInterruptVectorOverride;
185     PVOID HalGetVectorInputOverride;
186 #endif
187 } HAL_PRIVATE_DISPATCH, *PHAL_PRIVATE_DISPATCH;
188 
189 //
190 // HAL Supported Range
191 //
192 #define HAL_SUPPORTED_RANGE_VERSION 1
193 typedef struct _SUPPORTED_RANGE
194 {
195     struct _SUPPORTED_RANGE *Next;
196     ULONG SystemAddressSpace;
197     LONGLONG SystemBase;
198     LONGLONG Base;
199     LONGLONG Limit;
200 } SUPPORTED_RANGE, *PSUPPORTED_RANGE;
201 
202 typedef struct _SUPPORTED_RANGES
203 {
204     USHORT Version;
205     BOOLEAN Sorted;
206     UCHAR Reserved;
207     ULONG NoIO;
208     SUPPORTED_RANGE IO;
209     ULONG NoMemory;
210     SUPPORTED_RANGE Memory;
211     ULONG NoPrefetchMemory;
212     SUPPORTED_RANGE PrefetchMemory;
213     ULONG NoDma;
214     SUPPORTED_RANGE Dma;
215 } SUPPORTED_RANGES, *PSUPPORTED_RANGES;
216 
217 //
218 // HAL Bus Handler
219 //
220 #define HAL_BUS_HANDLER_VERSION 1
221 typedef struct _BUS_HANDLER
222 {
223     ULONG Version;
224     INTERFACE_TYPE InterfaceType;
225     BUS_DATA_TYPE ConfigurationType;
226     ULONG BusNumber;
227     PDEVICE_OBJECT DeviceObject;
228     struct _BUS_HANDLER *ParentHandler;
229     PVOID BusData;
230     ULONG DeviceControlExtensionSize;
231     PSUPPORTED_RANGES BusAddresses;
232     ULONG Reserved[4];
233     PGETSETBUSDATA GetBusData;
234     PGETSETBUSDATA SetBusData;
235     PADJUSTRESOURCELIST AdjustResourceList;
236     PASSIGNSLOTRESOURCES AssignSlotResources;
237     PGETINTERRUPTVECTOR GetInterruptVector;
238     PTRANSLATEBUSADDRESS TranslateBusAddress;
239     PVOID Spare1;
240     PVOID Spare2;
241     PVOID Spare3;
242     PVOID Spare4;
243     PVOID Spare5;
244     PVOID Spare6;
245     PVOID Spare7;
246     PVOID Spare8;
247 } BUS_HANDLER;
248 
249 //
250 // HAL Chip Hacks
251 //
252 #define HAL_PCI_CHIP_HACK_BROKEN_ACPI_TIMER        0x01
253 #define HAL_PCI_CHIP_HACK_DISABLE_HIBERNATE        0x02
254 #define HAL_PCI_CHIP_HACK_DISABLE_ACPI_IRQ_ROUTING 0x04
255 #define HAL_PCI_CHIP_HACK_USB_SMI_DISABLE          0x08
256 
257 //
258 // Kernel Exports
259 //
260 #if (defined(_NTDRIVER_) || defined(_NTHAL_)) && !defined(_BLDR_)
261 extern NTSYSAPI PHAL_PRIVATE_DISPATCH HalPrivateDispatchTable;
262 #define HALPRIVATEDISPATCH ((PHAL_PRIVATE_DISPATCH)&HalPrivateDispatchTable)
263 #else
264 extern NTSYSAPI HAL_PRIVATE_DISPATCH HalPrivateDispatchTable;
265 #define HALPRIVATEDISPATCH (&HalPrivateDispatchTable)
266 #endif
267 
268 //
269 // HAL Exports
270 //
271 extern PUCHAR NTHALAPI KdComPortInUse;
272 
273 //
274 // HAL Constants
275 //
276 #define HAL_IRQ_TRANSLATOR_VERSION 0x0
277 
278 //
279 // BIOS call structure
280 //
281 #ifdef _M_AMD64
282 
283 typedef struct _X86_BIOS_REGISTERS
284 {
285     ULONG Eax;
286     ULONG Ecx;
287     ULONG Edx;
288     ULONG Ebx;
289     ULONG Ebp;
290     ULONG Esi;
291     ULONG Edi;
292     USHORT SegDs;
293     USHORT SegEs;
294 } X86_BIOS_REGISTERS, *PX86_BIOS_REGISTERS;
295 
296 #endif // _M_AMD64
297 
298 #endif
299 #endif
300 
301 
302 
303