/*++ Copyright (c) Microsoft Corporation. All rights reserved. Module Name: WdfCommonBuffer.h Environment: user mode NOTE: This header is generated by stubwork. To modify contents, add or remove or tags in the corresponding .x and .y template files. --*/ #pragma once #ifndef WDF_EXTERN_C #ifdef __cplusplus #define WDF_EXTERN_C extern "C" #define WDF_EXTERN_C_START extern "C" { #define WDF_EXTERN_C_END } #else #define WDF_EXTERN_C #define WDF_EXTERN_C_START #define WDF_EXTERN_C_END #endif #endif WDF_EXTERN_C_START typedef struct _WDF_COMMON_BUFFER_CONFIG { // // Size of this structure in bytes // ULONG Size; // // Alignment requirement of the buffer address // ULONG AlignmentRequirement; // // Minimum logical address for the allocated common buffer. // 0 to indicate that there is no minimum requirement. // PHYSICAL_ADDRESS MinimumAddress; // // Maximum logical address for the allocated common buffer. // 0 to indicate that there is no maximum requirement. // PHYSICAL_ADDRESS MaximumAddress; // // Cache type of the common buffer. // Use MmMaximumCacheType to indicate the default platform behavior. // MEMORY_CACHING_TYPE CacheType; } WDF_COMMON_BUFFER_CONFIG, *PWDF_COMMON_BUFFER_CONFIG; VOID FORCEINLINE WDF_COMMON_BUFFER_CONFIG_INIT( _Out_ PWDF_COMMON_BUFFER_CONFIG Config, _In_ ULONG AlignmentRequirement ) { RtlZeroMemory(Config, sizeof(WDF_COMMON_BUFFER_CONFIG)); Config->Size = WDF_STRUCTURE_SIZE(WDF_COMMON_BUFFER_CONFIG); Config->AlignmentRequirement = AlignmentRequirement; Config->MinimumAddress.QuadPart = 0; Config->MaximumAddress.QuadPart = 0; Config->CacheType = MmMaximumCacheType; } // // WDF Function: WdfCommonBufferCreate // typedef _Must_inspect_result_ _IRQL_requires_max_(PASSIVE_LEVEL) WDFAPI NTSTATUS (NTAPI *PFN_WDFCOMMONBUFFERCREATE)( _In_ PWDF_DRIVER_GLOBALS DriverGlobals, _In_ WDFDMAENABLER DmaEnabler, _In_ _When_(Length == 0, __drv_reportError(Length cannot be zero)) size_t Length, _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes, _Out_ WDFCOMMONBUFFER* CommonBuffer ); _Must_inspect_result_ _IRQL_requires_max_(PASSIVE_LEVEL) FORCEINLINE NTSTATUS WdfCommonBufferCreate( _In_ WDFDMAENABLER DmaEnabler, _In_ _When_(Length == 0, __drv_reportError(Length cannot be zero)) size_t Length, _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes, _Out_ WDFCOMMONBUFFER* CommonBuffer ) { #if defined(WDF_EVERYTHING_ALWAYS_AVAILABLE) return ((PFN_WDFCOMMONBUFFERCREATE) WdfFunctions[WdfCommonBufferCreateTableIndex])(WdfDriverGlobals, DmaEnabler, Length, Attributes, CommonBuffer); #else if (WDF_IS_FUNCTION_AVAILABLE(WdfCommonBufferCreate)) { return ((PFN_WDFCOMMONBUFFERCREATE) WdfFunctions[WdfCommonBufferCreateTableIndex])(WdfDriverGlobals, DmaEnabler, Length, Attributes, CommonBuffer); } else { return ((PFN_WDFDRIVERERRORREPORTAPIMISSING) WdfFunctions[WdfDriverErrorReportApiMissingTableIndex])(WdfDriverGlobals, WdfGetDriver(), NULL, WdfCommonBufferCreateTableIndex, TRUE); } #endif } // // WDF Function: WdfCommonBufferCreateWithConfig // typedef _Must_inspect_result_ _IRQL_requires_max_(PASSIVE_LEVEL) WDFAPI NTSTATUS (NTAPI *PFN_WDFCOMMONBUFFERCREATEWITHCONFIG)( _In_ PWDF_DRIVER_GLOBALS DriverGlobals, _In_ WDFDMAENABLER DmaEnabler, _In_ _When_(Length == 0, __drv_reportError(Length cannot be zero)) size_t Length, _In_ PWDF_COMMON_BUFFER_CONFIG Config, _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes, _Out_ WDFCOMMONBUFFER* CommonBuffer ); _Must_inspect_result_ _IRQL_requires_max_(PASSIVE_LEVEL) FORCEINLINE NTSTATUS WdfCommonBufferCreateWithConfig( _In_ WDFDMAENABLER DmaEnabler, _In_ _When_(Length == 0, __drv_reportError(Length cannot be zero)) size_t Length, _In_ PWDF_COMMON_BUFFER_CONFIG Config, _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes, _Out_ WDFCOMMONBUFFER* CommonBuffer ) { #if defined(WDF_EVERYTHING_ALWAYS_AVAILABLE) return ((PFN_WDFCOMMONBUFFERCREATEWITHCONFIG) WdfFunctions[WdfCommonBufferCreateWithConfigTableIndex])(WdfDriverGlobals, DmaEnabler, Length, Config, Attributes, CommonBuffer); #else if (WDF_IS_FUNCTION_AVAILABLE(WdfCommonBufferCreateWithConfig)) { return ((PFN_WDFCOMMONBUFFERCREATEWITHCONFIG) WdfFunctions[WdfCommonBufferCreateWithConfigTableIndex])(WdfDriverGlobals, DmaEnabler, Length, Config, Attributes, CommonBuffer); } else { return ((PFN_WDFDRIVERERRORREPORTAPIMISSING) WdfFunctions[WdfDriverErrorReportApiMissingTableIndex])(WdfDriverGlobals, WdfGetDriver(), NULL, WdfCommonBufferCreateWithConfigTableIndex, TRUE); } #endif } // // WDF Function: WdfCommonBufferGetAlignedVirtualAddress // typedef _IRQL_requires_max_(DISPATCH_LEVEL) WDFAPI PVOID (NTAPI *PFN_WDFCOMMONBUFFERGETALIGNEDVIRTUALADDRESS)( _In_ PWDF_DRIVER_GLOBALS DriverGlobals, _In_ WDFCOMMONBUFFER CommonBuffer ); _IRQL_requires_max_(DISPATCH_LEVEL) FORCEINLINE PVOID WdfCommonBufferGetAlignedVirtualAddress( _In_ WDFCOMMONBUFFER CommonBuffer ) { #if defined(WDF_EVERYTHING_ALWAYS_AVAILABLE) return ((PFN_WDFCOMMONBUFFERGETALIGNEDVIRTUALADDRESS) WdfFunctions[WdfCommonBufferGetAlignedVirtualAddressTableIndex])(WdfDriverGlobals, CommonBuffer); #else if (WDF_IS_FUNCTION_AVAILABLE(WdfCommonBufferGetAlignedVirtualAddress)) { return ((PFN_WDFCOMMONBUFFERGETALIGNEDVIRTUALADDRESS) WdfFunctions[WdfCommonBufferGetAlignedVirtualAddressTableIndex])(WdfDriverGlobals, CommonBuffer); } else { ((PFN_WDFDRIVERERRORREPORTAPIMISSING) WdfFunctions[WdfDriverErrorReportApiMissingTableIndex])(WdfDriverGlobals, WdfGetDriver(), NULL, WdfCommonBufferGetAlignedVirtualAddressTableIndex, FALSE); return (PVOID)0; } #endif } // // WDF Function: WdfCommonBufferGetAlignedLogicalAddress // typedef _IRQL_requires_max_(DISPATCH_LEVEL) WDFAPI PHYSICAL_ADDRESS (NTAPI *PFN_WDFCOMMONBUFFERGETALIGNEDLOGICALADDRESS)( _In_ PWDF_DRIVER_GLOBALS DriverGlobals, _In_ WDFCOMMONBUFFER CommonBuffer ); _IRQL_requires_max_(DISPATCH_LEVEL) FORCEINLINE PHYSICAL_ADDRESS WdfCommonBufferGetAlignedLogicalAddress( _In_ WDFCOMMONBUFFER CommonBuffer ) { #if defined(WDF_EVERYTHING_ALWAYS_AVAILABLE) return ((PFN_WDFCOMMONBUFFERGETALIGNEDLOGICALADDRESS) WdfFunctions[WdfCommonBufferGetAlignedLogicalAddressTableIndex])(WdfDriverGlobals, CommonBuffer); #else if (WDF_IS_FUNCTION_AVAILABLE(WdfCommonBufferGetAlignedLogicalAddress)) { return ((PFN_WDFCOMMONBUFFERGETALIGNEDLOGICALADDRESS) WdfFunctions[WdfCommonBufferGetAlignedLogicalAddressTableIndex])(WdfDriverGlobals, CommonBuffer); } else { ((PFN_WDFDRIVERERRORREPORTAPIMISSING) WdfFunctions[WdfDriverErrorReportApiMissingTableIndex])(WdfDriverGlobals, WdfGetDriver(), NULL, WdfCommonBufferGetAlignedLogicalAddressTableIndex, FALSE); PHYSICAL_ADDRESS addr; addr.QuadPart = 0; return addr; } #endif } // // WDF Function: WdfCommonBufferGetLength // typedef _IRQL_requires_max_(DISPATCH_LEVEL) WDFAPI size_t (NTAPI *PFN_WDFCOMMONBUFFERGETLENGTH)( _In_ PWDF_DRIVER_GLOBALS DriverGlobals, _In_ WDFCOMMONBUFFER CommonBuffer ); _IRQL_requires_max_(DISPATCH_LEVEL) FORCEINLINE size_t WdfCommonBufferGetLength( _In_ WDFCOMMONBUFFER CommonBuffer ) { #if defined(WDF_EVERYTHING_ALWAYS_AVAILABLE) return ((PFN_WDFCOMMONBUFFERGETLENGTH) WdfFunctions[WdfCommonBufferGetLengthTableIndex])(WdfDriverGlobals, CommonBuffer); #else if (WDF_IS_FUNCTION_AVAILABLE(WdfCommonBufferGetLength)) { return ((PFN_WDFCOMMONBUFFERGETLENGTH) WdfFunctions[WdfCommonBufferGetLengthTableIndex])(WdfDriverGlobals, CommonBuffer); } else { ((PFN_WDFDRIVERERRORREPORTAPIMISSING) WdfFunctions[WdfDriverErrorReportApiMissingTableIndex])(WdfDriverGlobals, WdfGetDriver(), NULL, WdfCommonBufferGetLengthTableIndex, FALSE); return (size_t)0; } #endif } WDF_EXTERN_C_END