ScsiPortGetPhysicalAddress

SCSI_PHYSICAL_ADDRESS
ScsiPortGetPhysicalAddress(

IN PVOID HwDeviceExtension,
IN PSCSI_REQUEST_BLOCK Srb,/* optional */
IN PVOID VirtualAddress,
OUT ULONG *Length
);

ScsiPortGetPhysicalAddress converts a given virtual address range to a physical address range for a DMA operation.

Parameters

HwDeviceExtension

Points to the miniport driver's per-HBA storage area.

Srb

Points to the SCSI request block if the VirtualAddress to be converted comes from that SRB's DataBuffer member or, possibly, from the SenseInfoBuffer. Otherwise, this parameter must be NULL.

VirtualAddress

Points to the base virtual address to be converted. If this virtual address falls within the range for an SRB-supplied DataBuffer, the caller also must provide the Srb pointer.

Length

Returns the number of bytes mapped, starting at the returned physical address.

Return Value

ScsiPortGetPhysicalAddress returns the corresponding physical address for a given VirtualAddress. If the given address cannot be converted, it returns NULL.

Comments

Miniport drivers of busmaster HBAs call ScsiPortGetPhysicalAddress to get mapped physical address ranges to be used during DMA operations. For example, ScsiPortGetPhysicalAddress can be used to build a scatter/gather list for data transfers that span pages. Note that the Length returned can be greater than the size of the DataBuffer in a given SRB.

If a nonNULL Srb is passed, the VirtualAddress either must be within the range of the DataBuffer of the SRB or must be a pointer from the SenseInfoBuffer. Otherwise, the given VirtualAddress must be in the miniport's uncached extension, the SrbExtension, or the SenseInfoBuffer.

A miniport driver can call ScsiPortGetPhysicalAddress to translate an extension address only if that miniport's DriverEntry routine set NeedPhysicalAddresses to TRUE in the HW_INITIALIZATION_DATA when it called ScsiPortInitialize.

Due to constraints on some buses, such as ISA, the address returned by this routine is not guaranteed to match the address returned by an analogous outside routine (such as MmGetPhysicalAddress). A miniport driver should call only ScsiPortXxx routines to be portable.

See Also

HW_INITIALIZATION_DATA, DriverEntry, ScsiPortGetUncachedExtension, ScsiPortGetVirtualAddress, SCSI_REQUEST_BLOCK