/**++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  @function: Delete a message queue

  @function name: SDLIB_DeleteMessageQueue
  @prototype: void SDLIB_DeleteMessageQueue(PSDMESSAGE_QUEUE pQueue)
  @category: Support_Reference
  
  @input: pQueue - message queue to delete
  
  @notes: This function flushes the message queue and frees all memory allocated for
          messages.
  
  @see also: SDLIB_CreateMessageQueue
  
  @example: Deleting a message queue:
       if (pMsgQueue != NULL) {
            SDLIB_DeleteMessageQueue(pMsgQueue);
       }
  
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
void _DeleteMessageQueue(PSDMESSAGE_QUEUE pQueue)
{
    PSDMESSAGE_BLOCK pMsg;
    SDIO_STATUS     status;
    CT_DECLARE_IRQ_SYNC_CONTEXT();
    
    status = CriticalSectionAcquireSyncIrq(&pQueue->MessageCritSection);
    
        /* cleanup free list */
    while (1) {
        pMsg = GetFreeMessageBlock(pQueue);
        if (pMsg != NULL) {
            KernelFree(pMsg); 
        } else {
            break;   
        }
    }  
        /* cleanup any in the queue */
    while (1) {
        pMsg = GetQueuedMessage(pQueue);
        if (pMsg != NULL) {
            KernelFree(pMsg); 
        } else {
            break;   
        }
    }
    
    status = CriticalSectionReleaseSyncIrq(&pQueue->MessageCritSection);  
    CriticalSectionDelete(&pQueue->MessageCritSection);  
    KernelFree(pQueue);
    
}
Example #2
0
/*----------------------------------------------------------------------
            Parameters:

           Description:
----------------------------------------------------------------------*/
void
KernelImageFree(KIMAGE *kimage)
{
  int  row, col ;

  for (row = 0 ; row < kimage->rows ; row++)
  {
    for (col = 0 ; col < kimage->cols ; col++)
    {
      KernelFree(KIMAGEpix(kimage, row, col)) ;
    }
  }
  free(kimage) ;
}
Example #3
0
static void hifCleanupDevice(HIF_DEVICE *device)
{
    int count;
    
    CriticalSectionDelete(&device->lock);
    
    for (count = 0; count < BUS_REQUEST_MAX_NUM_TOTAL; count++) {
        if (device->busrequestblob[count].request != NULL){
            SDDeviceFreeRequest(device->handle,device->busrequestblob[count].request);
            device->busrequestblob[count].request = NULL;
        }
    }
    
    KernelFree(device);
}
Example #4
0
int InvokeSessionCommand(user SESSION_CONTEXT *session_context,
                        user TEE_Param params[4],
                        user uint32_t param_type,
                        int32_t command)
{
    TZ_CMD_DATA *tz_cmd_data = NULL;
    int ret = -1;
    tz_cmd_data = (TZ_CMD_DATA *)KernelMalloc(sizeof(TZ_CMD_DATA));
    Client_MemFill(tz_cmd_data, 0, sizeof(TZ_CMD_DATA));

    // params[0]
    tz_cmd_data->params[0].memref.buffer = KernelMalloc(params[0].memref.size);
    MemMove(tz_cmd_data->params[0].memref.buffer, params[0].memref.buffer, 
            params[0].memref.size);
    tz_cmd_data->params[0].memref.size = params[0].memref.size;
    // param_type
    tz_cmd_data->param_type = param_type;
    // operation_type
    tz_cmd_data->operation_type = TEE_OPERATION_INVOKE_COMMAND;
    // session_context
    MemMove(&tz_cmd_data->session_context, session_context, sizeof(SESSION_CONTEXT));
    // command id
    tz_cmd_data->command_id = command;
    // meta_data
    tz_cmd_data->meta_data[0].usr_addr = params[0].memref.buffer;
    tz_cmd_data->meta_data[0].size = params[0].memref.size;
    ret = CallTZFunction(tz_cmd_data);
    // write back
    MemMove(params[0].memref.buffer, tz_cmd_data->params[0].memref.buffer,
            params[0].memref.size);
    // free memory
    KernelFree(tz_cmd_data);


    return ret;
}
Example #5
0
int OpenSession(user TEE_Param params[4],
                kernel out SESSION_CONTEXT *session_context,
                user uint32_t param_type)
{
    int ret = -1;
    TZ_CMD_DATA *tz_cmd_data = NULL;

    if (param_type != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT,
                                      TEE_PARAM_TYPE_NONE,
                                      TEE_PARAM_TYPE_NONE,
                                      TEE_PARAM_TYPE_NONE)) {
        return TEEC_ERROR_BAD_PARAMETERS;
    }
    tz_cmd_data = (TZ_CMD_DATA *)KernelMalloc(sizeof(TZ_CMD_DATA));
    // params[0] dest_uuid
    MemMove(&tz_cmd_data->params[0], &params[0], sizeof(TEE_Param));
    // params[1] client_uuid
    tz_cmd_data->params[1].memref.buffer = KernelMalloc(sizeof(TEE_UUID));
    tz_cmd_data->params[1].memref.size = sizeof(TEE_UUID);
    MemMove(tz_cmd_data->params[1].memref.buffer, &client_uuid, sizeof(TEE_UUID));
    // params[2] client login type
    tz_cmd_data->params[2].value.a = TEE_LOGIN_PUBLIC;
    tz_cmd_data->operation_type = TEE_OPERATION_OPEN_SESSION;

    param_type = TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT,
                                 TEE_PARAM_TYPE_MEMREF_INPUT,
                                 TEE_PARAM_TYPE_VALUE_INPUT,
                                 TEE_PARAM_TYPE_NONE);
    tz_cmd_data->param_type = param_type;
    tz_cmd_data->meta_data[0].usr_addr = params[0].memref.buffer;
    tz_cmd_data->meta_data[0].size = params[0].memref.size;
    ret = CallTZFunction(tz_cmd_data);
    MemMove(session_context, &tz_cmd_data->session_context, sizeof(SESSION_CONTEXT));
    KernelFree(tz_cmd_data);
    return ret;
}