/*TEEK_init do prepare for start SecureOs*/ static s32 TEEK_init(TEEC_Session *session, TEEC_Context *context) { TEEC_Result result; TEEC_UUID svc_uuid = TEE_SERVICE_SECBOOT; /*TEEK_InitializeContext try to initialize the tee context*/ result = TEEK_InitializeContext(NULL,context); if(result != TEEC_SUCCESS) { result = SEC_ERROR; return result; } /*TEEK_OpenSession try to open a tee session*/ result = TEEK_OpenSession(context,session,&svc_uuid,TEEC_LOGIN_PUBLIC,NULL,NULL,NULL); if (result != TEEC_SUCCESS) { result = SEC_ERROR; TEEK_FinalizeContext(context); } return result; }
/****************************************************************************** Function: TEEK_init Description: TEEK初始化 Input: session context Output: none Return: 0: OK 其他: ERROR码 ******************************************************************************/ static int TEEK_init(TEEC_Session *session, TEEC_Context *context) { TEEC_Result result; TEEC_UUID svc_uuid = TEE_SERVICE_SECBOOT; TEEC_Operation operation = {0}; u8 package_name[] = "sec_boot"; u32 root_id = 0; result = TEEK_InitializeContext(NULL, context); if(result != TEEC_SUCCESS) { sec_print_err("TEEK_InitializeContext failed,result = 0x%x!\n",result); return BSP_ERROR; } operation.started = 1; operation.cancel_flag = 0; operation.paramTypes = TEEC_PARAM_TYPES( TEEC_NONE, TEEC_NONE, TEEC_MEMREF_TEMP_INPUT, TEEC_MEMREF_TEMP_INPUT); operation.params[2].tmpref.buffer = (void *)(&root_id); operation.params[2].tmpref.size = sizeof(root_id); operation.params[3].tmpref.buffer = (void *)(package_name); operation.params[3].tmpref.size = strlen(package_name) + 1; result = TEEK_OpenSession( context, session, &svc_uuid, TEEC_LOGIN_IDENTIFY, NULL, &operation, NULL); if (result != TEEC_SUCCESS) { sec_print_err("TEEK_OpenSession failed,result = 0x%x!\n",result); TEEK_FinalizeContext(context); return BSP_ERROR; } return BSP_OK; }
/****************************************************************************** Function: TEEK_init Description: TEEK初始化 Input: session context Output: none Return: 0: OK 其他: ERROR码 ******************************************************************************/ static s32 TEEK_init(TEEC_Session *session, TEEC_Context *context) { TEEC_Result result; TEEC_UUID svc_uuid = TEE_SERVICE_SECBOOT; mutex_lock(&trans_lock); result = TEEK_InitializeContext( NULL, context); if(result != TEEC_SUCCESS) { sec_print_err("TEEK_InitializeContext failed!\n"); result = SEC_ERROR; goto error1; } result = TEEK_OpenSession( context, session, &svc_uuid, TEEC_LOGIN_PUBLIC, NULL, NULL, NULL); if (result != TEEC_SUCCESS) { sec_print_err("TEEK_OpenSession failed!\n"); result = SEC_ERROR; TEEK_FinalizeContext(context); } error1: mutex_unlock(&trans_lock); return result; }