VideoPortMapBankedMemory

VP_STATUS VideoPortMapBankedMemory(

    PVOID HwDeviceExtension,
   PHYSICAL_ADDRESS PhysicalAddress,
   PULONG Length,
   PULONG InIoSpace,
   PVOID *VirtualAddress,
   ULONG BankLength,
   UCHAR  ReadWriteBank,
   PBANKED_SECTION_ROUTINE BankRoutine,
   PVOID  Context
  );

VideoPortMapBankedMemory remaps a bus-relative physical range of video memory into the corresponding display driver’s virtual address space in response to a VRP with the IoControlCode member set to IOCTL_VIDEO_SHARE_VIDEO_MEMORY and possibly to IOCTL_VIDEO_MAP_VIDEO_MEMORY.

Parameters

HwDeviceExtension

Points to the miniport driver’s device extension.

PhysicalAddress

Specifies the bus-relative base address of the range to be mapped.

Length

Points to a variable specifying the total number of bytes of device memory to be mapped (regardless of bank size). VideoPortMapBankedMemory returns the actual size of the memory mapped, which can be rounded to a system-determined alignment boundary, in this parameter. However, the miniport and display drivers cannot access memory outside the range delimited by the input value at Length.

InIoSpace

Points to a variable indicating whether the range is in I/O space or memory space. TRUE indicates I/O space.

VirtualAddress

Points to a variable that specifies a process handle, which usually should be set to zero. Such a handle can also be a value passed in a VRP by the corresponding display driver. Zero specifies that the port driver should map the logical memory range at any location in the address space of the current process. On return from a successful call, VideoPortMapBankedMemory resets the variable to the base virtual address to which it has mapped the given PhysicalAddress.

BankLength

Specifies the size of a Bank, in bytes. 

ReadWriteBank

If set to TRUE the Bank is Read\Write; if set to FALSE there are two independent Read and Write Banks.

BankRoutine

Points to a driver-supplied HwVidBankedMemoryCallback function to be called by the Memory Manager when a new bank is accessed by the display driver.

Context

Points to a miniport driver-supplied context that is passed back to the driver when the BankRoutine is called.

Return Value

VideoPortMapBankedMemory returns NO_ERROR if the given logical range was successfully mapped to a user-space virtual range. Otherwise, it can return ERROR_INVALID_PARAMETER.

Comments

VideoPortMapBankedMemory runs in kernel mode within the same context as the user-mode thread that initiated the call.

VideoPortMapBankedMemory is called by miniport drivers to efficiently manage x86 type devices that are limited to mapping a frame buffer in banks. When this routine returns to the caller, the frame buffer managed by the miniport driver is mapped as a linear frame buffer into the address space of the requesting process (see VirtualAddress parameter). When an access is made to an address in that mapped space, the Memory Manager calls the miniport driver to update the Bank Index Register to point to a new bank that contains the currently referenced address.  The Bank Index Register is maintained by the miniport driver in BankRoutine. The correct Bank Index is calculated by the Memory Manager transparently to a display driver and passed to the miniport driver in the callback to BankRoutine.

Callers of VideoPortMapBankedMemory are running at IRQL = PASSIVE_LEVEL.

See Also

HwVidBankedMemoryCallback, IOCTL_VIDEO_MAP_VIDEO_MEMORY, IOCTL_VIDEO_SHARE_VIDEO_MEMORY, IOCTL_VIDEO_UNSHARE_VIDEO_MEMORY, VIDEO_REQUEST_PACKET, VideoPortMapMemory, VideoPortUnmapMemory