From 468df3b26a47b957e05f99cf210e1581ffb07eb2 Mon Sep 17 00:00:00 2001 From: Hisping Lin Date: Fri, 3 Nov 2017 11:51:52 +0800 Subject: [PATCH] lib: optee_client: add read vboot key flag func Change-Id: Id0405cc2b695f00b5d7586d01bd0b66279b24430 Signed-off-by: Hisping Lin --- include/optee_include/OpteeClientInterface.h | 1 + lib/optee_clientApi/OpteeClientInterface.c | 58 ++++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/include/optee_include/OpteeClientInterface.h b/include/optee_include/OpteeClientInterface.h index c1aa6c4d10..5f3089d367 100644 --- a/include/optee_include/OpteeClientInterface.h +++ b/include/optee_include/OpteeClientInterface.h @@ -24,6 +24,7 @@ uint32_t trusty_write_attribute_hash(uint32_t *buf, uint32_t length); uint32_t trusty_notify_optee_uboot_end(void); uint32_t trusty_read_vbootkey_hash(uint32_t *buf, uint32_t length); uint32_t trusty_write_vbootkey_hash(uint32_t *buf, uint32_t length); +uint32_t trusty_read_vbootkey_enable_flag(uint8_t *flag); uint32_t trusty_read_permanent_attributes_flag(uint8_t *attributes); uint32_t trusty_write_permanent_attributes_flag(uint8_t attributes); diff --git a/lib/optee_clientApi/OpteeClientInterface.c b/lib/optee_clientApi/OpteeClientInterface.c index 6a57e3b7d6..9f309d0a44 100644 --- a/lib/optee_clientApi/OpteeClientInterface.c +++ b/lib/optee_clientApi/OpteeClientInterface.c @@ -1027,6 +1027,64 @@ uint32_t trusty_write_vbootkey_hash(uint32_t *buf, uint32_t length) return TeecResult; } +uint32_t trusty_read_vbootkey_enable_flag(uint8_t *flag) +{ + TEEC_Result TeecResult; + TEEC_Context TeecContext; + TEEC_Session TeecSession; + uint32_t ErrorOrigin; + uint32_t bootflag; + + TEEC_UUID tempuuid = { 0x2d26d8a8, 0x5134, 0x4dd8, \ + { 0xb3, 0x2f, 0xb3, 0x4b, 0xce, 0xeb, 0xc4, 0x71 } }; + TEEC_UUID *TeecUuid = &tempuuid; + TEEC_Operation TeecOperation = {0}; + + OpteeClientApiLibInitialize(); + + TeecResult = TEEC_InitializeContext(NULL, &TeecContext); + + TeecResult = TEEC_OpenSession(&TeecContext, + &TeecSession, + TeecUuid, + TEEC_LOGIN_PUBLIC, + NULL, + NULL, + &ErrorOrigin); + + TEEC_SharedMemory SharedMem0 = {0}; + + SharedMem0.size = 1 * sizeof(uint32_t); + SharedMem0.flags = 0; + + TeecResult = TEEC_AllocateSharedMemory(&TeecContext, &SharedMem0); + + TeecOperation.params[0].tmpref.buffer = SharedMem0.buffer; + TeecOperation.params[0].tmpref.size = SharedMem0.size; + + TeecOperation.paramTypes = TEEC_PARAM_TYPES(TEEC_MEMREF_TEMP_OUTPUT, + TEEC_NONE, + TEEC_NONE, + TEEC_NONE); + + TeecResult = TEEC_InvokeCommand(&TeecSession, + 5, + &TeecOperation, + &ErrorOrigin); + + if (TeecResult == TEEC_SUCCESS) { + memcpy(&bootflag, SharedMem0.buffer, SharedMem0.size); + if (bootflag == 0x000000FF) + *flag = 1; + } + + TEEC_ReleaseSharedMemory(&SharedMem0); + TEEC_CloseSession(&TeecSession); + TEEC_FinalizeContext(&TeecContext); + + return TeecResult; +} + uint32_t trusty_read_permanent_attributes_flag(uint8_t *attributes) { TEEC_Result TeecResult;