src/ssx/occhw/occhw_async_gpe.c
/// Create (initialize) the GpeRequest base class
///
/// \param request An uninitialized or otherwise idle GpeRequest.
///
/// \param queue An initialized GpeQueue.
///
/// \param func_id The IPC function ID of the GPE command.
///
/// \param cmd_data A pointer to command-specific input and output data.
///
/// \param timeout If not specified as SSX_WAIT_FOREVER, then this request
/// will be governed by a private watchdog timer that will cancel a queued job
/// or kill a running job if the hardware operation does not complete before
/// it times out.
///
/// \param callback The callback to execute when the GPE command completes,
/// or NULL (0) to indicate no callback.
///
/// \param arg The parameter to the callback routine; ignored if the \a
/// callback is NULL.
///
/// \param options Options to control request priority and callback context.
///
/// This routine has no way to know if the GpeRequest structure is currently
/// in use, so this API should only be called on uninitialized or otherwise
/// idle GpeRequest structures.
///
/// \retval 0 Success
///
/// \retval -ASYNC_INVALID_OBJECT_GPE_REQUEST The \a request was NULL (0)
/// or the \a queue was NULL (0) or not a GpeQueue.
///
/// \retval IPC_RC_INVALID_FUNC_ID The func_id has an invalid target id
/// for the specified GPE queue.
///
/// See async_request_create() for other errors that may be returned by this
/// call.
Create (initialize) the GpeRequest base class
\param request An uninitialized or otherwise idle GpeRequest.

\param queue An initialized GpeQueue.

\param func_id The IPC function ID of the GPE command.

\param cmd_data A pointer to command-specific input and output data.

\param timeout If not specified as SSX_WAIT_FOREVER, then this request
will be governed by a private watchdog timer that will cancel a queued job
or kill a running job if the hardware operation does not complete before
it times out.

\param callback The callback to execute when the GPE command completes,
or NULL (0) to indicate no callback.

\param arg The parameter to the callback routine; ignored if the \a
callback is NULL.

\param options Options to control request priority and callback context.

This routine has no way to know if the GpeRequest structure is currently
in use, so this API should only be called on uninitialized or otherwise
idle GpeRequest structures.

\retval 0 Success

\retval -ASYNC_INVALID_OBJECT_GPE_REQUEST The \a request was NULL (0)
or the \a queue was NULL (0) or not a GpeQueue.

\retval IPC_RC_INVALID_FUNC_ID The func_id has an invalid target id
for the specified GPE queue.

See async_request_create() for other errors that may be returned by this
call.
Create ( initialize ) the GpeRequest base class \ param request An uninitialized or otherwise idle GpeRequest . \ param queue An initialized GpeQueue . \ param func_id The IPC function ID of the GPE command . \ param cmd_data A pointer to command - specific input and output data . \ param timeout If not specified as SSX_WAIT_FOREVER then this request will be governed by a private watchdog timer that will cancel a queued job or kill a running job if the hardware operation does not complete before it times out . \ param callback The callback to execute when the GPE command completes or NULL ( 0 ) to indicate no callback . \ param arg The parameter to the callback routine ; ignored if the \ a callback is NULL . \ param options Options to control request priority and callback context . This routine has no way to know if the GpeRequest structure is currently in use so this API should only be called on uninitialized or otherwise idle GpeRequest structures . \ retval 0 Success \ retval - ASYNC_INVALID_OBJECT_GPE_REQUEST The \ a request was NULL ( 0 ) or the \ a queue was NULL ( 0 ) or not a GpeQueue . \ retval IPC_RC_INVALID_FUNC_ID The func_id has an invalid target id for the specified GPE queue . See async_request_create () for other errors that may be returned by this call .
int
gpe_request_create(GpeRequest* request,
                   GpeQueue* queue,
                   ipc_func_enum_t func_id,
                   void* cmd_data,
                   SsxInterval timeout,
                   AsyncRequestCallback callback,
                   void* arg,
                   int options)
{
    AsyncQueue*  async_queue = (AsyncQueue*)queue;
    uint32_t    targeted_func_id;
    int         rc;
    if (SSX_ERROR_CHECK_API)
    {
        SSX_ERROR_IF(!(async_queue->engine & ASYNC_ENGINE_GPE),
                     ASYNC_INVALID_OBJECT_GPE_REQUEST);
    }
    rc = async_request_create(&(request->request),
                              async_queue,
                              gpe_run_method,
                              gpe_error_method,
                              timeout,
                              callback,
                              arg,
                              options);
    if(!rc)
    {
        if(IPC_FUNCID_IS_MT(func_id))
        {
            targeted_func_id = IPC_SET_MT_TARGET(func_id, queue->ipc_target_id);
        }
        else
        {
            targeted_func_id = func_id;
        }
        if (IPC_GET_TARGET_ID(targeted_func_id) != queue->ipc_target_id)
        {
            rc = IPC_RC_INVALID_FUNC_ID;
        }
        else
        {
            request->cmd_data = cmd_data;
            request->targeted_func_id = targeted_func_id;
        }
    }
    return rc;
}
int gpe_request_create ( GpeRequest * request , GpeQueue * queue , ipc_func_enum_t func_id , void * cmd_data , SsxInterval timeout , AsyncRequestCallback callback , void * arg , int options ) { AsyncQueue * async_queue = ( AsyncQueue * ) queue ; uint32_t targeted_func_id ; int rc ; if ( SSX_ERROR_CHECK_API ) { SSX_ERROR_IF ( ! ( async_queue -> engine & ASYNC_ENGINE_GPE ) , ASYNC_INVALID_OBJECT_GPE_REQUEST ) ; } rc = async_request_create ( & ( request -> request ) , async_queue , gpe_run_method , gpe_error_method , timeout , callback , arg , options ) ; if ( ! rc ) { if ( IPC_FUNCID_IS_MT ( func_id ) ) { targeted_func_id = IPC_SET_MT_TARGET ( func_id , queue -> ipc_target_id ) ; } else { targeted_func_id = func_id ; } if ( IPC_GET_TARGET_ID ( targeted_func_id ) != queue -> ipc_target_id ) { rc = IPC_RC_INVALID_FUNC_ID ; } else { request -> cmd_data = cmd_data ; request -> targeted_func_id = targeted_func_id ; } } return rc ; }
Create (initialize) the GpeRequest base class
\param request An uninitialized or otherwise idle GpeRequest.
Create ( initialize ) the GpeRequest base class \ param request An uninitialized or otherwise idle GpeRequest .
//initialize the base async request //If this is a multi-target function ID we need to set the target id. //This macro will set the target to an invalid target id if this //function id is not a multi-target function ID and this condition //will be caught when we check that the target id for the request //matches the target id for the queue. //single target function IDs already have a target //check that target id of the command matches the target id //of the queue. //initialize data that will be used when sending the command