FreeBSD/sys/dev/isci/isci_io_request.c
/**
 * @brief This callback method asks the user to provide the physical
 *        address for the supplied virtual address when building an
 *        io request object.
 *
 * @param[in] controller This parameter is the core controller object
 *            handle.
 * @param[in] io_request This parameter is the io request object handle
 *            for which the physical address is being requested.
 * @param[in] virtual_address This parameter is the virtual address which
 *            is to be returned as a physical address.
 * @param[out] physical_address The physical address for the supplied virtual
 *             address.
 *
 * @return None.
 */
@brief This callback method asks the user to provide the physical
address for the supplied virtual address when building an
io request object.

@param[in] controller This parameter is the core controller object
handle.
@param[in] io_request This parameter is the io request object handle
for which the physical address is being requested.
@param[in] virtual_address This parameter is the virtual address which
is to be returned as a physical address.
@param[out] physical_address The physical address for the supplied virtual
address.

@return None.
@brief This callback method asks the user to provide the physical address for the supplied virtual address when building an io request object . @param [ in ] controller This parameter is the core controller object handle . @param [ in ] io_request This parameter is the io request object handle for which the physical address is being requested . @param [ in ] virtual_address This parameter is the virtual address which is to be returned as a physical address . @param [ out ] physical_address The physical address for the supplied virtual address . @return None .
void
scic_cb_io_request_get_physical_address(SCI_CONTROLLER_HANDLE_T	controller,
    SCI_IO_REQUEST_HANDLE_T io_request, void *virtual_address,
    SCI_PHYSICAL_ADDRESS *physical_address)
{
	SCI_IO_REQUEST_HANDLE_T scif_request =
	    sci_object_get_association(io_request);
	struct ISCI_REQUEST *isci_request =
	    sci_object_get_association(scif_request);
	if(isci_request != NULL) {
		*physical_address = isci_request->physical_address +
		    (uintptr_t)virtual_address -
		    (uintptr_t)isci_request;
	} else {
		SCI_CONTROLLER_HANDLE_T scif_controller =
		    (SCI_CONTROLLER_HANDLE_T) sci_object_get_association(controller);
		struct ISCI_CONTROLLER *isci_controller =
		    (struct ISCI_CONTROLLER *)sci_object_get_association(scif_controller);
		U64 virt_addr_offset = (uintptr_t)virtual_address -
		    (U64)isci_controller->uncached_controller_memory.virtual_address;
		*physical_address =
		    isci_controller->uncached_controller_memory.physical_address
		    + virt_addr_offset;
	}
}
void scic_cb_io_request_get_physical_address ( SCI_CONTROLLER_HANDLE_T controller , SCI_IO_REQUEST_HANDLE_T io_request , void * virtual_address , SCI_PHYSICAL_ADDRESS * physical_address ) { SCI_IO_REQUEST_HANDLE_T scif_request = sci_object_get_association ( io_request ) ; struct ISCI_REQUEST * isci_request = sci_object_get_association ( scif_request ) ; if ( isci_request != NULL ) { * physical_address = isci_request -> physical_address + ( uintptr_t ) virtual_address - ( uintptr_t ) isci_request ; } else { SCI_CONTROLLER_HANDLE_T scif_controller = ( SCI_CONTROLLER_HANDLE_T ) sci_object_get_association ( controller ) ; struct ISCI_CONTROLLER * isci_controller = ( struct ISCI_CONTROLLER * ) sci_object_get_association ( scif_controller ) ; U64 virt_addr_offset = ( uintptr_t ) virtual_address - ( U64 ) isci_controller -> uncached_controller_memory . virtual_address ; * physical_address = isci_controller -> uncached_controller_memory . physical_address + virt_addr_offset ; } }
@brief This callback method asks the user to provide the physical
        address for the supplied virtual address when building an
        io request object.
@brief This callback method asks the user to provide the physical address for the supplied virtual address when building an io request object .
/* isci_request is not NULL, meaning this is a request initiated
		 *  by CAM or the isci layer (i.e. device reset for I/O
		 *  timeout).  Therefore we can calculate the physical address
		 *  based on the address we stored in the struct ISCI_REQUEST
		 *  object.
		 */ /* isci_request is NULL, meaning this is a request generated
		 *  internally by SCIL (i.e. for SMP requests or NCQ error
		 *  recovery).  Therefore we calculate the physical address
		 *  based on the controller's uncached controller memory buffer,
		 *  since we know that this is what SCIL uses for internal
		 *  framework requests.
		 */