TZ_RESULT UREE_GetSecurememinfo (UREE_SESSION_HANDLE session, UREE_SECUREMEM_INFO *info) { MTEEC_PARAM p[4]; TZ_RESULT ret; if ((info == NULL)) { return TZ_RESULT_ERROR_BAD_PARAMETERS; } ret = UREE_TeeServiceCall(session, TZCMD_DBG_SECUREMEM_INFO, TZ_ParamTypes2(TZPT_VALUE_OUTPUT, TZPT_VALUE_OUTPUT), p); if (ret != TZ_RESULT_SUCCESS) { printf("[uree] UREE_GetSecurememinfo Error: %d\n", ret); return ret; } info->used_byte = p[0].value.a; info->max_free_cont_mem_sz = p[0].value.b; info->total_byte = p[1].value.a; info->max_foot_print = p[1].value.b; return TZ_RESULT_SUCCESS; }
static inline TZ_RESULT _handleOpFunc_1 (uint32_t cmd, UREE_SESSION_HANDLE session, uint32_t mem_handle, uint32_t *count, char *dbg) { MTEEC_PARAM p[4]; TZ_RESULT ret; if ((mem_handle == 0) || (count == NULL)) { return TZ_RESULT_ERROR_BAD_PARAMETERS; } p[0].value.a = (uint32_t) mem_handle; ret = UREE_TeeServiceCall(session, cmd, TZ_ParamTypes2( TZPT_VALUE_INPUT, TZPT_VALUE_OUTPUT), p); if (ret < 0) { #ifdef DBG_UREE_MEM printf("[uree] %s Error: %d\n", dbg, ret); #endif *count = 0; return ret; } *count = p[1].value.a; return TZ_RESULT_SUCCESS; }
TZ_RESULT UREE_WriteSecurechunkmem (UREE_SESSION_HANDLE session, uint32_t offset, uint32_t size, void *buffer) { MTEEC_PARAM p[4]; TZ_RESULT ret; if ((session == 0) || (size == 0)) { return TZ_RESULT_ERROR_BAD_PARAMETERS; } p[0].value.a = offset; p[1].value.a = size; p[2].mem.buffer = buffer; p[2].mem.size = size; // fix me!!!! ret = UREE_TeeServiceCall(session, TZCMD_MEM_SECURECM_WRITE, TZ_ParamTypes3(TZPT_VALUE_INPUT, TZPT_VALUE_INPUT, TZPT_MEM_INPUT), p); if (ret != TZ_RESULT_SUCCESS) { #ifdef DBG_UREE_MEM printf("[uree] UREE_WriteSecurechunkmem Error: %d\n", ret); #endif return ret; } return TZ_RESULT_SUCCESS; }
// notiec: handle type is the same static inline TZ_RESULT _allocFunc (uint32_t cmd, UREE_SESSION_HANDLE session, uint32_t *mem_handle, uint32_t alignment, uint32_t size, char *dbg) { MTEEC_PARAM p[4]; TZ_RESULT ret; if ((mem_handle == NULL) || (size == 0)) { return TZ_RESULT_ERROR_BAD_PARAMETERS; } p[0].value.a = alignment; p[1].value.a = size; ret = UREE_TeeServiceCall(session, cmd, TZ_ParamTypes3( TZPT_VALUE_INPUT, TZPT_VALUE_INPUT, TZPT_VALUE_OUTPUT), p); if (ret != TZ_RESULT_SUCCESS) { #ifdef DBG_UREE_MEM printf("[uree] %s Error: %d\n", dbg, ret); #endif return ret; } *mem_handle = (UREE_SECUREMEM_HANDLE) p[2].value.a; return TZ_RESULT_SUCCESS; }
TZ_RESULT UREE_AppendSecurechunkmem (UREE_SESSION_HANDLE session) { MTEEC_PARAM p[4]; TZ_RESULT ret; if (session == 0) { return TZ_RESULT_ERROR_BAD_PARAMETERS; } ret = UREE_TeeServiceCall(session, TZCMD_MEM_SECURECM_APPEND, 0, p); if (ret != TZ_RESULT_SUCCESS) { #ifdef DBG_UREE_MEM printf("[uree] UREE_ReleaseSecurechunkmem Error: %d\n", ret); #endif return ret; } return TZ_RESULT_SUCCESS; }
TZ_RESULT UREE_ReleaseSecurechunkmem (UREE_SESSION_HANDLE session, uint32_t size, uint32_t *released_size) { MTEEC_PARAM p[4]; TZ_RESULT ret; if (session == 0) { return TZ_RESULT_ERROR_BAD_PARAMETERS; } p[0].value.a = size; ret = UREE_TeeServiceCall(session, TZCMD_MEM_SECURECM_RELEASE, TZ_ParamTypes2(TZPT_VALUE_INPUT, TZPT_VALUE_OUTPUT), p); if (ret != TZ_RESULT_SUCCESS) { #ifdef DBG_UREE_MEM printf("[uree] UREE_ReleaseSecurechunkmem Error: %d\n", ret); #endif return ret; } *released_size = p[1].value.a; return TZ_RESULT_SUCCESS; }