Create the AHCI branch for Aman's work
[reactos.git] / sdk / include / xdk / halfuncs.h
1 /* Hardware Abstraction Layer Functions */
2
3 #if (NTDDI_VERSION >= NTDDI_WIN2K)
4
5 #if defined(USE_DMA_MACROS) && !defined(_NTHAL_) && (defined(_NTDDK_) || defined(_NTDRIVER_)) || defined(_WDM_INCLUDED_)
6
7 $if (_WDMDDK_)
8 __drv_preferredFunction("AllocateCommonBuffer","Obsolete")
9 FORCEINLINE
10 PVOID
11 NTAPI
12 HalAllocateCommonBuffer(
13 _In_ PDMA_ADAPTER DmaAdapter,
14 _In_ ULONG Length,
15 _Out_ PPHYSICAL_ADDRESS LogicalAddress,
16 _In_ BOOLEAN CacheEnabled)
17 {
18 PALLOCATE_COMMON_BUFFER allocateCommonBuffer;
19 PVOID commonBuffer;
20
21 allocateCommonBuffer = *(DmaAdapter)->DmaOperations->AllocateCommonBuffer;
22 ASSERT( allocateCommonBuffer != NULL );
23 commonBuffer = allocateCommonBuffer( DmaAdapter, Length, LogicalAddress, CacheEnabled );
24 return commonBuffer;
25 }
26
27 __drv_preferredFunction("FreeCommonBuffer","Obsolete")
28 FORCEINLINE
29 VOID
30 NTAPI
31 HalFreeCommonBuffer(
32 _In_ PDMA_ADAPTER DmaAdapter,
33 _In_ ULONG Length,
34 _In_ PHYSICAL_ADDRESS LogicalAddress,
35 _In_ PVOID VirtualAddress,
36 _In_ BOOLEAN CacheEnabled)
37 {
38 PFREE_COMMON_BUFFER freeCommonBuffer;
39
40 freeCommonBuffer = *(DmaAdapter)->DmaOperations->FreeCommonBuffer;
41 ASSERT( freeCommonBuffer != NULL );
42 freeCommonBuffer( DmaAdapter, Length, LogicalAddress, VirtualAddress, CacheEnabled );
43 }
44
45 __drv_preferredFunction("ReadDmaCounter","Obsolete")
46 FORCEINLINE
47 ULONG
48 NTAPI
49 HalReadDmaCounter(
50 _In_ PDMA_ADAPTER DmaAdapter)
51 {
52 PREAD_DMA_COUNTER readDmaCounter;
53 ULONG counter;
54
55 readDmaCounter = *(DmaAdapter)->DmaOperations->ReadDmaCounter;
56 ASSERT( readDmaCounter != NULL );
57 counter = readDmaCounter( DmaAdapter );
58 return counter;
59 }
60
61 FORCEINLINE
62 ULONG
63 HalGetDmaAlignment(
64 _In_ PDMA_ADAPTER DmaAdapter)
65 {
66 PGET_DMA_ALIGNMENT getDmaAlignment;
67 ULONG alignment;
68
69 getDmaAlignment = *(DmaAdapter)->DmaOperations->GetDmaAlignment;
70 ASSERT( getDmaAlignment != NULL );
71 alignment = getDmaAlignment( DmaAdapter );
72 return alignment;
73 }
74
75 $endif (_WDMDDK_)
76 $if (_NTDDK_)
77 /* Nothing here */
78
79 #else /* USE_DMA_MACROS ... */
80
81 //DECLSPEC_DEPRECATED_DDK
82 NTHALAPI
83 VOID
84 NTAPI
85 IoFreeAdapterChannel(
86 _In_ PADAPTER_OBJECT AdapterObject);
87
88 //DECLSPEC_DEPRECATED_DDK
89 NTHALAPI
90 BOOLEAN
91 NTAPI
92 IoFlushAdapterBuffers(
93 _In_ PADAPTER_OBJECT AdapterObject,
94 _In_ PMDL Mdl,
95 _In_ PVOID MapRegisterBase,
96 _In_ PVOID CurrentVa,
97 _In_ ULONG Length,
98 _In_ BOOLEAN WriteToDevice);
99
100 //DECLSPEC_DEPRECATED_DDK
101 NTHALAPI
102 VOID
103 NTAPI
104 IoFreeMapRegisters(
105 _In_ PADAPTER_OBJECT AdapterObject,
106 _In_ PVOID MapRegisterBase,
107 _In_ ULONG NumberOfMapRegisters);
108
109 //DECLSPEC_DEPRECATED_DDK
110 NTHALAPI
111 PVOID
112 NTAPI
113 HalAllocateCommonBuffer(
114 _In_ PADAPTER_OBJECT AdapterObject,
115 _In_ ULONG Length,
116 _Out_ PPHYSICAL_ADDRESS LogicalAddress,
117 _In_ BOOLEAN CacheEnabled);
118
119 //DECLSPEC_DEPRECATED_DDK
120 NTHALAPI
121 VOID
122 NTAPI
123 HalFreeCommonBuffer(
124 _In_ PADAPTER_OBJECT AdapterObject,
125 _In_ ULONG Length,
126 _In_ PHYSICAL_ADDRESS LogicalAddress,
127 _In_ PVOID VirtualAddress,
128 _In_ BOOLEAN CacheEnabled);
129
130 //DECLSPEC_DEPRECATED_DDK
131 NTHALAPI
132 ULONG
133 NTAPI
134 HalReadDmaCounter(
135 _In_ PADAPTER_OBJECT AdapterObject);
136
137 NTHALAPI
138 NTSTATUS
139 NTAPI
140 HalAllocateAdapterChannel(
141 _In_ PADAPTER_OBJECT AdapterObject,
142 _In_ PWAIT_CONTEXT_BLOCK Wcb,
143 _In_ ULONG NumberOfMapRegisters,
144 _In_ PDRIVER_CONTROL ExecutionRoutine);
145
146 $endif (_NTDDK_)
147 #endif /* USE_DMA_MACROS ... */
148
149 $if (_NTDDK_)
150 #if !defined(NO_LEGACY_DRIVERS)
151 NTHALAPI
152 NTSTATUS
153 NTAPI
154 HalAssignSlotResources(
155 _In_ PUNICODE_STRING RegistryPath,
156 _In_opt_ PUNICODE_STRING DriverClassName,
157 _In_ PDRIVER_OBJECT DriverObject,
158 _In_ PDEVICE_OBJECT DeviceObject,
159 _In_ INTERFACE_TYPE BusType,
160 _In_ ULONG BusNumber,
161 _In_ ULONG SlotNumber,
162 _Inout_ PCM_RESOURCE_LIST *AllocatedResources);
163
164 _IRQL_requires_max_(PASSIVE_LEVEL)
165 NTHALAPI
166 ULONG
167 NTAPI
168 HalGetInterruptVector(
169 _In_ INTERFACE_TYPE InterfaceType,
170 _In_ ULONG BusNumber,
171 _In_ ULONG BusInterruptLevel,
172 _In_ ULONG BusInterruptVector,
173 _Out_ PKIRQL Irql,
174 _Out_ PKAFFINITY Affinity);
175
176 NTHALAPI
177 ULONG
178 NTAPI
179 HalSetBusData(
180 _In_ BUS_DATA_TYPE BusDataType,
181 _In_ ULONG BusNumber,
182 _In_ ULONG SlotNumber,
183 _In_reads_bytes_(Length) PVOID Buffer,
184 _In_ ULONG Length);
185
186 NTHALAPI
187 ULONG
188 NTAPI
189 HalGetBusData(
190 _In_ BUS_DATA_TYPE BusDataType,
191 _In_ ULONG BusNumber,
192 _In_ ULONG SlotNumber,
193 _Out_writes_bytes_(Length) PVOID Buffer,
194 _In_ ULONG Length);
195
196 NTHALAPI
197 BOOLEAN
198 NTAPI
199 HalMakeBeep(
200 _In_ ULONG Frequency);
201 #endif /* !defined(NO_LEGACY_DRIVERS) */
202
203 _IRQL_requires_max_(PASSIVE_LEVEL)
204 NTHALAPI
205 PADAPTER_OBJECT
206 NTAPI
207 HalGetAdapter(
208 _In_ PDEVICE_DESCRIPTION DeviceDescription,
209 _Out_ PULONG NumberOfMapRegisters);
210
211 VOID
212 NTAPI
213 HalPutDmaAdapter(
214 _In_ PADAPTER_OBJECT DmaAdapter);
215
216 NTHALAPI
217 VOID
218 NTAPI
219 HalAcquireDisplayOwnership(
220 _In_ PHAL_RESET_DISPLAY_PARAMETERS ResetDisplayParameters);
221
222 NTHALAPI
223 ULONG
224 NTAPI
225 HalGetBusDataByOffset(
226 _In_ BUS_DATA_TYPE BusDataType,
227 _In_ ULONG BusNumber,
228 _In_ ULONG SlotNumber,
229 _Out_writes_bytes_(Length) PVOID Buffer,
230 _In_ ULONG Offset,
231 _In_ ULONG Length);
232
233 NTHALAPI
234 ULONG
235 NTAPI
236 HalSetBusDataByOffset(
237 _In_ BUS_DATA_TYPE BusDataType,
238 _In_ ULONG BusNumber,
239 _In_ ULONG SlotNumber,
240 _In_reads_bytes_(Length) PVOID Buffer,
241 _In_ ULONG Offset,
242 _In_ ULONG Length);
243
244 NTHALAPI
245 BOOLEAN
246 NTAPI
247 HalTranslateBusAddress(
248 _In_ INTERFACE_TYPE InterfaceType,
249 _In_ ULONG BusNumber,
250 _In_ PHYSICAL_ADDRESS BusAddress,
251 _Inout_ PULONG AddressSpace,
252 _Out_ PPHYSICAL_ADDRESS TranslatedAddress);
253
254 NTHALAPI
255 PVOID
256 NTAPI
257 HalAllocateCrashDumpRegisters(
258 _In_ PADAPTER_OBJECT AdapterObject,
259 _Inout_ PULONG NumberOfMapRegisters);
260
261 NTSTATUS
262 NTAPI
263 HalGetScatterGatherList(
264 _In_ PADAPTER_OBJECT DmaAdapter,
265 _In_ PDEVICE_OBJECT DeviceObject,
266 _In_ PMDL Mdl,
267 _In_ PVOID CurrentVa,
268 _In_ ULONG Length,
269 _In_ PDRIVER_LIST_CONTROL ExecutionRoutine,
270 _In_ PVOID Context,
271 _In_ BOOLEAN WriteToDevice);
272
273 VOID
274 NTAPI
275 HalPutScatterGatherList(
276 _In_ PADAPTER_OBJECT DmaAdapter,
277 _In_ PSCATTER_GATHER_LIST ScatterGather,
278 _In_ BOOLEAN WriteToDevice);
279
280 $endif (_NTDDK_)
281 #endif /* (NTDDI_VERSION >= NTDDI_WIN2K) */
282
283 $if (_NTDDK_)
284 #if (NTDDI_VERSION >= NTDDI_WINXP)
285 _IRQL_requires_max_(PASSIVE_LEVEL)
286 NTKERNELAPI
287 VOID
288 FASTCALL
289 HalExamineMBR(
290 _In_ PDEVICE_OBJECT DeviceObject,
291 _In_ ULONG SectorSize,
292 _In_ ULONG MBRTypeIdentifier,
293 _Out_ PVOID *Buffer);
294 #endif /* (NTDDI_VERSION >= NTDDI_WINXP) */
295
296 #if (NTDDI_VERSION >= NTDDI_WIN7)
297
298 NTSTATUS
299 NTAPI
300 HalAllocateHardwareCounters(
301 _In_reads_(GroupCount) PGROUP_AFFINITY GroupAffinty,
302 _In_ ULONG GroupCount,
303 _In_ PPHYSICAL_COUNTER_RESOURCE_LIST ResourceList,
304 _Out_ PHANDLE CounterSetHandle);
305
306 NTSTATUS
307 NTAPI
308 HalFreeHardwareCounters(
309 _In_ HANDLE CounterSetHandle);
310
311 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
312
313 #if defined(_IA64_)
314 #if (NTDDI_VERSION >= NTDDI_WIN2K)
315 NTHALAPI
316 ULONG
317 NTAPI
318 HalGetDmaAlignmentRequirement(VOID);
319 #endif
320 #endif /* defined(_IA64_) */
321
322 #if defined(_M_IX86) || defined(_M_AMD64)
323 #define HalGetDmaAlignmentRequirement() 1L
324 #endif
325
326 #if (NTDDI_VERSION >= NTDDI_WIN7)
327
328 typedef struct _WHEA_ERROR_SOURCE_DESCRIPTOR *PWHEA_ERROR_SOURCE_DESCRIPTOR;
329 typedef struct _WHEA_ERROR_RECORD *PWHEA_ERROR_RECORD;
330
331 NTHALAPI
332 VOID
333 NTAPI
334 HalBugCheckSystem(
335 _In_ PWHEA_ERROR_SOURCE_DESCRIPTOR ErrorSource,
336 _In_ PWHEA_ERROR_RECORD ErrorRecord);
337
338 #else
339
340 typedef struct _WHEA_ERROR_RECORD *PWHEA_ERROR_RECORD;
341
342 NTHALAPI
343 VOID
344 NTAPI
345 HalBugCheckSystem(
346 _In_ PWHEA_ERROR_RECORD ErrorRecord);
347
348 #endif /* (NTDDI_VERSION >= NTDDI_WIN7) */
349
350 $endif (_NTDDK_)