d_map_query Kernel Service

Purpose

Queries the amount of direct memory access (DMA) space or DMA windows available on the partition end point. To use full 64-bit DMA all device drivers must call the d_map_query kernel service before attempting to initialize a new DMA window or before attempting to allocate DMA space within an existing DMA window by using the d_map_init_ext kernel service. Device drivers that do not use full 64-bit DMA should not call this service.

Syntax

#include <sys/types.h>
#include <sys/dma.h>
#include <sys/kerrno.h>
kerrno_t d_map_query(bid, slot, flags, cmd, dq_info)
uint64_t  bid;
uint64_t  slot;
uint64_t  flags;
uint64_t  cmd;
void *    dq_info;

Parameter

Item Description
bid Specifies the bus identifier.
slot Specifies the slot on the parent bus. This is the same as the connwhere property in the CuDv object class for the device.
flags Specifies flags for the d_map_query kernel service. For future support, this parameter must be set to 0.
cmd Specifies the type of query that the d_map_query kernel service will execute.
dq_info Specifies the dq_ddw_resources_t or dq_dma_available_t structure based on which cmd parameter was defined.

Description

The d_map_query kernel service allows the device driver to determine the amount of DMA space available within the DMA window or the amount of DMA windows available for a particular partition end point.

The d_map_query kernel service Dynamic DMA Windows Query (DDW_QUERY) option is supported only on partition end points that support the dynamic DMA windows (DDW_QUERY) option. The d_map_query kernel service can also be used to determine the dynamic DMA windows capability of a particular partition endpoint. When a slot is initialized on a reboot or power-on operation of the partition or on a DR isolate operation that encompasses the partition endpoint, a default DMA window is always allocated for less than 4 GB. After the first call to the d_map_query kernel service with the DDW_QUERY option, the default DMA window is removed. This leaves no usable DMA window on the partition endpoint until the d_map_init_ext kernel service is called to initialize a new DMA window.

Note: The DDW_QUERY option should only be used by device drivers that fully support the 64-bit DMA.

The caller of the d_map_query kernel service must pass the desired command to the cmd parameter and have the appropriate dq_info parameter initialized.

The options available for the cmd parameter are defined in the <sys/dma.h> header file, and are described as follows:

DDW_QUERY
Returns the number of additional DMA windows available for a partition endpoint. The dq_ddw_resources_t structure must be passed to the dq_info parameter for this command. The dqdr_version field in the structure should be assigned as DQDR_VERSION.
DMA_QUERY
Returns the maximum amount of contiguous pages available for a given page size in all existing DMA windows. The dq_dma_available_t structure must be passed to the dq_info parameter for this command. The dqda_version field in the structure should be assigned as DQDA_VERSION and the corresponding I/O page size for the query must be specified. The supported I/O page size for the DMA operation can be obtained from the d_map_query kernel service by running the DDW_QUERY command.

The dq_ddw_resources_t and dq_dma_available_t structures are defined in the <sys/dma.h> as follows:

typedef struct dq_ddw_resources
	{   /* input by caller */
       uint64_t dqdr_version;
       /* returned to caller */
		 uint64_t dqdr_supported_page_sizes; 
		 uint64_t dqdr_windows_avail; 
       /* Amount of dynamic DMA windows available.
		  * If DDW_QUERY, is not available 
		  * 0 will be returned.
       */ 
        uint64_t dqdr_max_pages; /* Largest number of contiguous pages available.*/
    		uint64_t dqdr_rsvd1; 	        /* reserved for future use */
    		uint64_t dqdr_rsvd2;           /* reserved for future use */
    		uint64_t dqdr_rsvd3;           /* reserved for future use */
    		uint64_t dqdr_rsvd4;           /* reserved for future use */
	} dq_ddw_resources_t;
	/* 
 	* The dq_dma_available structure is to be used in d_map_querywith the 
 	* DMA_QUERY cmd specified
 	*/
	typedef struct dq_dma_available
	{
      /*input by caller */
      uint64_t dqda_version;
      uint64_t dqda_io_page_size; 
      /* Page size in bytes, should only be equal to the supported pagesize */
      /* returned to caller for DMA_Query*/
      uint64_t dqda_pages_available;
		uint64_t dqda_rsvd1;        /* reserved for future use */
		uint64_t dqda_rsvd2;        /* reserved for future use */
		uint64_t dqda_rsvd3;        /* reserved for future use */	
		uint64_t dqda_rsvd4;        /* reserved for future use */
	} dq_dma_available_t;

Execution Environment

The d_map_query kernel service can be called from the process environment only.

Return Values

Item Description
0 Success
Kerrno Error occurred