Reactos
at master 350 lines 7.4 kB view raw
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") 9FORCEINLINE 10PVOID 11NTAPI 12HalAllocateCommonBuffer( 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") 28FORCEINLINE 29VOID 30NTAPI 31HalFreeCommonBuffer( 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") 46FORCEINLINE 47ULONG 48NTAPI 49HalReadDmaCounter( 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 61FORCEINLINE 62ULONG 63HalGetDmaAlignment( 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 82NTHALAPI 83VOID 84NTAPI 85IoFreeAdapterChannel( 86 _In_ PADAPTER_OBJECT AdapterObject); 87 88//DECLSPEC_DEPRECATED_DDK 89NTHALAPI 90BOOLEAN 91NTAPI 92IoFlushAdapterBuffers( 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 101NTHALAPI 102VOID 103NTAPI 104IoFreeMapRegisters( 105 _In_ PADAPTER_OBJECT AdapterObject, 106 _In_ PVOID MapRegisterBase, 107 _In_ ULONG NumberOfMapRegisters); 108 109//DECLSPEC_DEPRECATED_DDK 110NTHALAPI 111PVOID 112NTAPI 113HalAllocateCommonBuffer( 114 _In_ PADAPTER_OBJECT AdapterObject, 115 _In_ ULONG Length, 116 _Out_ PPHYSICAL_ADDRESS LogicalAddress, 117 _In_ BOOLEAN CacheEnabled); 118 119//DECLSPEC_DEPRECATED_DDK 120NTHALAPI 121VOID 122NTAPI 123HalFreeCommonBuffer( 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 131NTHALAPI 132ULONG 133NTAPI 134HalReadDmaCounter( 135 _In_ PADAPTER_OBJECT AdapterObject); 136 137NTHALAPI 138NTSTATUS 139NTAPI 140HalAllocateAdapterChannel( 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) 151NTHALAPI 152NTSTATUS 153NTAPI 154HalAssignSlotResources( 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) 165NTHALAPI 166ULONG 167NTAPI 168HalGetInterruptVector( 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 176NTHALAPI 177ULONG 178NTAPI 179HalSetBusData( 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 186NTHALAPI 187ULONG 188NTAPI 189HalGetBusData( 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 196NTHALAPI 197BOOLEAN 198NTAPI 199HalMakeBeep( 200 _In_ ULONG Frequency); 201#endif /* !defined(NO_LEGACY_DRIVERS) */ 202 203_IRQL_requires_max_(PASSIVE_LEVEL) 204NTHALAPI 205PADAPTER_OBJECT 206NTAPI 207HalGetAdapter( 208 _In_ PDEVICE_DESCRIPTION DeviceDescription, 209 _Out_ PULONG NumberOfMapRegisters); 210 211VOID 212NTAPI 213HalPutDmaAdapter( 214 _In_ PADAPTER_OBJECT DmaAdapter); 215 216NTHALAPI 217VOID 218NTAPI 219HalAcquireDisplayOwnership( 220 _In_ PHAL_RESET_DISPLAY_PARAMETERS ResetDisplayParameters); 221 222NTHALAPI 223ULONG 224NTAPI 225HalGetBusDataByOffset( 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 233NTHALAPI 234ULONG 235NTAPI 236HalSetBusDataByOffset( 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 244NTHALAPI 245BOOLEAN 246NTAPI 247HalTranslateBusAddress( 248 _In_ INTERFACE_TYPE InterfaceType, 249 _In_ ULONG BusNumber, 250 _In_ PHYSICAL_ADDRESS BusAddress, 251 _Inout_ PULONG AddressSpace, 252 _Out_ PPHYSICAL_ADDRESS TranslatedAddress); 253 254NTHALAPI 255PVOID 256NTAPI 257HalAllocateCrashDumpRegisters( 258 _In_ PADAPTER_OBJECT AdapterObject, 259 _Inout_ PULONG NumberOfMapRegisters); 260 261NTSTATUS 262NTAPI 263HalGetScatterGatherList( 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 273VOID 274NTAPI 275HalPutScatterGatherList( 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) 286NTKERNELAPI 287VOID 288FASTCALL 289HalExamineMBR( 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 298NTSTATUS 299NTAPI 300HalAllocateHardwareCounters( 301 _In_reads_(GroupCount) PGROUP_AFFINITY GroupAffinty, 302 _In_ ULONG GroupCount, 303 _In_ PPHYSICAL_COUNTER_RESOURCE_LIST ResourceList, 304 _Out_ PHANDLE CounterSetHandle); 305 306NTSTATUS 307NTAPI 308HalFreeHardwareCounters( 309 _In_ HANDLE CounterSetHandle); 310 311#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ 312 313#if defined(_IA64_) 314#if (NTDDI_VERSION >= NTDDI_WIN2K) 315NTHALAPI 316ULONG 317NTAPI 318HalGetDmaAlignmentRequirement(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 328typedef struct _WHEA_ERROR_SOURCE_DESCRIPTOR *PWHEA_ERROR_SOURCE_DESCRIPTOR; 329typedef struct _WHEA_ERROR_RECORD *PWHEA_ERROR_RECORD; 330 331NTHALAPI 332VOID 333NTAPI 334HalBugCheckSystem( 335 _In_ PWHEA_ERROR_SOURCE_DESCRIPTOR ErrorSource, 336 _In_ PWHEA_ERROR_RECORD ErrorRecord); 337 338#else 339 340typedef struct _WHEA_ERROR_RECORD *PWHEA_ERROR_RECORD; 341 342NTHALAPI 343VOID 344NTAPI 345HalBugCheckSystem( 346 _In_ PWHEA_ERROR_RECORD ErrorRecord); 347 348#endif /* (NTDDI_VERSION >= NTDDI_WIN7) */ 349 350$endif (_NTDDK_)