Ejemplo n.º 1
0
/******************************************************************************
Function:	    load_done
Description:	全部镜像发送完毕开始校验
Input:		    
            cmd_id      - 传送给安全OS的cmd_id

Output:		    none
Return:		    0: OK  其他: ERROR码
******************************************************************************/
static s32 load_done(TEEC_Session *session, SECBOOT_CMD_ID cmd_id)		  		  
{
	TEEC_Result result;
	TEEC_Operation operation;
	u32 origin;

	mutex_lock(&trans_lock);
	
	operation.started = 1;
	operation.cancel_flag = 0;
	operation.paramTypes = TEEC_PARAM_TYPES(
						TEEC_NONE,
						TEEC_NONE,
						TEEC_NONE,
						TEEC_NONE);

	result = TEEK_InvokeCommand(
				session,
				cmd_id,
				&operation,
				&origin);
	if (result != TEEC_SUCCESS) {
		sec_print_err("invoke failed!\n");
		result = SEC_ERROR;
	}

	mutex_unlock(&trans_lock);

	return result;
}
/******************************************************************************
Function:        TEEK_cmd_session
Description:     传入命令到安全OS
Input:
        cmd_id      - 传送给安全OS的cmd_id
        func_cmd    - 调用函数命令字
        param       - 函数入参

Output:          none
Return:          0: OK  其他: ERROR码
******************************************************************************/
static int TEEK_cmd_session(TEEC_Session   *session,
                            SECBOOT_CMD_ID cmd_id,
                            FUNC_CMD_ID    func_cmd,
                            const unsigned int param)
{
    TEEC_Result result;
    TEEC_Operation operation;
    unsigned int   origin;

    operation.started = 1;
    operation.cancel_flag = 0;
    operation.paramTypes = TEEC_PARAM_TYPES(
                           TEEC_VALUE_INPUT,
                           TEEC_NONE,
                           TEEC_NONE,
                           TEEC_NONE);
    operation.params[0].value.a = (unsigned int)func_cmd;
    operation.params[0].value.b = param;

    result = TEEK_InvokeCommand(
                           session,
                           cmd_id,
                           &operation,
                           &origin);
    if (result != TEEC_SUCCESS) {
        sec_print_err("invoke failed!result = 0x%x!\n",result);
        result = BSP_ERROR;
    }

    return BSP_OK;
}
/*Do the SecureOs locally for modem only*/
static s32 TEEK_start_modem()
{
    s32 ret_os = SEC_ERROR;
    TEEC_Session session;
    TEEC_Context context;
    u32 origin;
    TEEC_Operation operation;
    TEEC_Result result;

    /*TEEK_init do prepare for start SecureOs*/
    ret_os = TEEK_init(&session, &context);

    if(SEC_ERROR == ret_os)
    {
       printk(KERN_ERR "%s:TEEK_InitializeContext failed!\n",__FUNCTION__);
       return ret_os;
    }
    memset(&operation, 0, sizeof(TEEC_Operation));
    operation.started = 1;
    operation.cancel_flag = 0;
    /*Configure the local checking parameters*/
    operation.paramTypes = TEEC_PARAM_TYPES(
                                                 TEEC_VALUE_INPUT,
                                                 TEEC_NONE,
                                                 TEEC_NONE,
                                                 TEEC_NONE);

    operation.params[0].value.a = MODEM;
    operation.params[1].value.a = NULL;
    operation.params[2].value.a = NULL;
    
    /*TEEK_InvokeCommand do the local checking for modem*/
    result = TEEK_InvokeCommand(
               &session,
               SECBOOT_CMD_ID_VERIFY_DATA_TYPE_LOCAL,
               &operation,
               &origin);

    /*When finish TEEK_CloseSession try to close the tee session*/
    TEEK_CloseSession(&session);
    /*When finish TEEK_FinalizeContext try to close the tee context*/
    TEEK_FinalizeContext(&context);

    return result;
}
Ejemplo n.º 4
0
/******************************************************************************
Function:	    bsp_trans_to_os
Description:	从指定偏移开始传送指定大小的镜像
Input:		    
            cmd_id      - 传送给安全OS的cmd_id
            *buf		- 输入参数,存放要传送到安全os中的值
		    size		- 输入参数,要写入的镜像的bytes大小
		    offset		- 镜像需要写入的偏移地址

Output:		    none
Return:		    0: OK  其他: ERROR码
******************************************************************************/
static s32 bsp_trans_to_os(TEEC_Session *session,
		  SECBOOT_CMD_ID cmd_id,
		  void * buf,
		  const unsigned int offset,
		  const unsigned int size)
{
	TEEC_Result result;
	TEEC_Operation operation;
	u32 origin;

	mutex_lock(&trans_lock);
	
	operation.started = 1;
	operation.cancel_flag = 0;
	operation.paramTypes = TEEC_PARAM_TYPES(
						TEEC_VALUE_INPUT,
						TEEC_MEMREF_TEMP_INPUT,
						TEEC_VALUE_INPUT,
						TEEC_NONE);
	operation.params[0].value.a = trans_data.image_addr;
	operation.params[0].value.b = offset;
	operation.params[1].tmpref.buffer = (void *)g_vrl_P;
	operation.params[1].tmpref.size = SECBOOT_VRL_SIZE;
	operation.params[2].value.a = (u32)virt_to_phys(buf);
    operation.params[2].value.b = size;

	result = TEEK_InvokeCommand(
				session,
				cmd_id,
				&operation,
				&origin);
	if (result != TEEC_SUCCESS) {
		sec_print_err("invoke failed!\n");
		result = SEC_ERROR;
	}

	mutex_unlock(&trans_lock);

	return result;
}