lib: optee_client: add judgment of return value

Change-Id: If616f89ffb2c3ea30afb7bced56a1ca28b1232b2
Signed-off-by: Hisping Lin <hisping.lin@rock-chips.com>
This commit is contained in:
Hisping Lin 2019-03-04 10:35:12 +08:00 committed by Jianhong Chen
parent d08ece9d97
commit f4e1db9544
10 changed files with 354 additions and 105 deletions

View File

@ -30,9 +30,13 @@ int test_secure_storage_default(void)
}
debug("%s start\n", __func__);
OpteeClientApiLibInitialize();
TeecResult = OpteeClientApiLibInitialize();
if (TeecResult != TEEC_SUCCESS)
return -1;
TeecResult = TEEC_InitializeContext(NULL, &TeecContext);
if (TeecResult != TEEC_SUCCESS)
return -1;
TeecOperation.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT,
TEEC_NONE,
@ -164,9 +168,13 @@ int test_secure_storage_security_partition(void)
}
debug("%s start\n", __func__);
OpteeClientApiLibInitialize();
TeecResult = OpteeClientApiLibInitialize();
if (TeecResult != TEEC_SUCCESS)
return -1;
TeecResult = TEEC_InitializeContext(NULL, &TeecContext);
if (TeecResult != TEEC_SUCCESS)
return -1;
TeecOperation.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT,
TEEC_NONE,

View File

@ -14,7 +14,7 @@
#define ATTEST_UUID_SIZE (ATAP_HEX_UUID_LEN+1)
#define ATTEST_CA_OUT_SIZE 256
void test_optee(void);
uint32_t test_optee(void);
uint32_t trusty_read_rollback_index(uint32_t slot, uint64_t *value);
uint32_t trusty_write_rollback_index(uint32_t slot, uint64_t value);
uint32_t trusty_read_permanent_attributes(uint8_t *attributes, uint32_t size);

View File

@ -9,7 +9,7 @@
#include <linux/types.h>
void OpteeClientMemInit(void);
int OpteeClientMemInit(void);
void *OpteeClientMemAlloc(uint32_t length);

View File

@ -70,6 +70,6 @@ int tee_supp_rk_fs_init(void);
int tee_supp_rk_fs_process(size_t num_params,
struct tee_ioctl_param *params);
void OpteeClientRkFsInit(void);
int OpteeClientRkFsInit(void);
#endif

View File

@ -33,6 +33,6 @@ int tee_supp_rk_fs_init(void);
int tee_supp_rk_fs_process(void *cmd, uint32_t cmd_size);
void OpteeClientRkFsInit(void);
int OpteeClientRkFsInit(void);
#endif

View File

@ -17,11 +17,18 @@ TEEC_Result OpteeClientApiLibInitialize(void)
{
TEEC_Result status = TEEC_SUCCESS;
OpteeClientMemInit();
OpteeClientRkFsInit();
status = OpteeClientMemInit();
if (status != TEEC_SUCCESS) {
printf("OpteeClientMemInit fail!");
return status;
}
status = OpteeClientRkFsInit();
if (status != TEEC_SUCCESS) {
printf("OpteeClientRkFsInit fail!");
return status;
}
return TEEC_SUCCESS;
}
/*

File diff suppressed because it is too large Load Diff

View File

@ -14,7 +14,7 @@
void *my_mem_start;
uint32_t my_count;
uint8_t *my_flag;
uint8_t *my_flag = NULL;
typedef struct {
void *addrBlock;
uint32_t sizeBlock;
@ -22,14 +22,25 @@ typedef struct {
} ALLOC_FLAG;
ALLOC_FLAG alloc_flags[50];
void my_malloc_init(void *start, uint32_t size)
int my_malloc_init(void *start, uint32_t size)
{
if (start == NULL || size == 0) {
printf("malloc init fail!");
return -1;
}
memset(start, 0, size);
my_mem_start = start;
my_count = size/4096;
if (my_flag == NULL) {
my_flag = malloc(size/4096);
if (my_flag == NULL) {
printf("malloc fail!");
return -1;
}
}
memset(my_flag, 0, size/4096);
memset(alloc_flags, 0, 50 * sizeof(ALLOC_FLAG));
return 0;
}
void write_usedblock(void *addr, uint32_t size)
@ -75,7 +86,8 @@ void *my_malloc(uint32_t size)
uint32_t i, j, k, num;
num = (size - 1) / 4096 + 1;
if (my_count < num)
return 0;
for (i = 0; i < my_count - num; i++) {
if (*(my_flag + i) == 0) {
for (j = 0; j < num; j++) {
@ -127,7 +139,7 @@ void my_free(void *ptr)
* Initlialize the memory component, for example providing the
* containing drivers handle.
*/
void OpteeClientMemInit(void)
int OpteeClientMemInit(void)
{
ARM_SMC_ARGS ArmSmcArgs = {0};
@ -143,7 +155,7 @@ void OpteeClientMemInit(void)
debug("get share memory, arg0=0x%x arg1=0x%x arg2=0x%x arg3=0x%x\n",
ArmSmcArgs.Arg0, ArmSmcArgs.Arg1, ArmSmcArgs.Arg2, ArmSmcArgs.Arg3);
my_malloc_init((void *)(size_t)ArmSmcArgs.Arg1, ArmSmcArgs.Arg2);
return my_malloc_init((void *)(size_t)ArmSmcArgs.Arg1, ArmSmcArgs.Arg2);
}
/*

View File

@ -1233,10 +1233,10 @@ int tee_supp_rk_fs_init(void)
return TEEC_SUCCESS;
}
void OpteeClientRkFsInit(void)
int OpteeClientRkFsInit(void)
{
debug(" OpteeClientRkFsInit\n");
tee_supp_rk_fs_init();
return tee_supp_rk_fs_init();
}
bool tee_supp_param_is_value(struct tee_ioctl_param *param)
{

View File

@ -1277,10 +1277,10 @@ int tee_supp_rk_fs_init(void)
return 0;
}
void OpteeClientRkFsInit(void)
int OpteeClientRkFsInit(void)
{
debug(" OpteeClientRkFsInit\n");
tee_supp_rk_fs_init();
return tee_supp_rk_fs_init();
}
static int rkss_step = 0;