Bewerken

Delen via


MmMapIoSpaceEx function (wdm.h)

The MmMapIoSpaceEx routine maps the given physical address range to non-paged system space using the specified page protection.

Syntax

PVOID MmMapIoSpaceEx(
  [in] PHYSICAL_ADDRESS PhysicalAddress,
  [in] SIZE_T           NumberOfBytes,
  [in] ULONG            Protect
);

Parameters

[in] PhysicalAddress

Specifies the starting 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] Protect

Flag bits that specify the protection to use for the mapped range. The caller must set one of the following flag bits in the Protect parameter.

Flag bit Meaning
PAGE_READONLY The mapped range can only be read, not written.
PAGE_READWRITE The mapped range can be read or written.
PAGE_EXECUTE The mapped range can be executed, but not read or written.
PAGE_EXECUTE_READ The mapped range can be executed or read, but not written.
PAGE_EXECUTE_READWRITE The mapped range can be executed, read, or written.
 

In addition, the caller can set one (but not both) of the following optional flag bits in the Protect parameter.

Flag bit Meaning
PAGE_NOCACHE Specifies non-cached memory.
PAGE_WRITECOMBINE Specifies write-combined memory (the memory should not be cached by the processor, but writes to the memory can be combined by the processor).

Return value

MmMapIoSpaceEx returns the base virtual address that maps the base physical address for the range. If space for mapping the range is insufficient, it returns NULL.

Remarks

A driver must call this routine during device start-up if it receives translated resources of type CmResourceTypeMemory in a CM_PARTIAL_RESOURCE_DESCRIPTOR structure. MmMapIoSpaceEx maps the physical address returned in the resource list to a virtual address through which the driver can access device registers.

For example, drivers of PIO devices that allocate long-term I/O buffers can call this routine to make such buffers accessible or to make device memory accessible.

For more information about using this routine, see Mapping Bus-Relative Addresses to Virtual Addresses.

Requirements

Requirement Value
Minimum supported client Available starting with Windows 10.
Target Platform Universal
Header wdm.h (include Wdm.h, Ntddk.h, Ntifs.h)
Library NtosKrnl.lib
DLL NtosKrnl.exe
IRQL <=DISPATCH_LEVEL

See also

MmAllocateContiguousMemory

MmAllocateNonCachedMemory

MmMapLockedPages

MmUnmapIoSpace