WdfDeviceMapIoSpace function (wdfdevice.h)

[Applies to UMDF only]

The WdfDeviceMapIoSpace function maps the given physical address range to system address space and returns a pseudo base address.

Syntax

NTSTATUS WdfDeviceMapIoSpace(
  [in]  WDFDEVICE           Device,
  [in]  PHYSICAL_ADDRESS    PhysicalAddress,
  [in]  SIZE_T              NumberOfBytes,
  [in]  MEMORY_CACHING_TYPE CacheType,
  [out] PVOID               *PseudoBaseAddress
);

Parameters

[in] Device

A handle to a framework device object.

[in] PhysicalAddress

Specifies the starting 64-bit physical address of the I/O range to be mapped.

[in] NumberOfBytes

Specifies a value greater than zero, indicating the number of bytes to be mapped.

[in] CacheType

Specifies a MEMORY_CACHING_TYPE value, which indicates the cache attribute to use to map the physical address range. The MEMORY_CACHING_TYPE enumeration type is defined in Wdfdevice.h.

[out] PseudoBaseAddress

The address of a location that receives a pointer to the pseudo base address.

Return value

If the operation succeeds, the function returns STATUS_SUCCESS.

The function might return other NTSTATUS values.

Remarks

This function is the UMDF version 2 equivalent of IWDFDevice3::MapIoSpace.

A driver must call this function during device start-up if it receives translated resources of type CmResourceTypeMemory in a CM_PARTIAL_RESOURCE_DESCRIPTOR structure. WdfDeviceMapIoSpace maps the physical address returned in the resource list to a framework-managed address referred to as the pseudo base address.

The driver can then use the pseudo base address to access device registers with WDF_READ_REGISTER_Xxx and WDF_WRITE_REGISTER_Xxx functions.

A driver that calls WdfDeviceMapIoSpace must set the UmdfDirectHardwareAccess INF directive to AllowDirectHardwareAccess.

If the driver sets the UmdfRegisterAccessMode INF directive to RegisterAccessUsingUserModeMapping, calling WdfDeviceMapIoSpace also maps the given physical address range to a user-mode base address range that the driver can subsequently access by calling WdfDeviceGetHardwareRegisterMappedAddress.

For more information about INF directives that UMDF drivers can use, see Specifying WDF Directives in INF Files.

For more information about parsing hardware resources starting in UMDF version 2, see Handling Hardware Resources in a UMDF Driver.

The PHYSICAL_ADDRESS type is defined in Wudfwdm.h, as follows:

typedef LARGE_INTEGER PHYSICAL_ADDRESS;

For an example that shows how a driver finds and maps memory-mapped register resources, see Reading and Writing to Device Registers.

Requirements

Requirement Value
Minimum supported client Windows 8.1
Target Platform Universal
Minimum UMDF version 2.0
Header wdfdevice.h (include Wdf.h)
Library WUDFx02000.lib
DLL WUDFx02000.dll
IRQL PASSIVE_LEVEL

See also

IWDFDevice3::MapIoSpace

WdfDeviceUnmapIoSpace