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:
parent
d08ece9d97
commit
f4e1db9544
12
cmd/optee.c
12
cmd/optee.c
|
|
@ -30,9 +30,13 @@ int test_secure_storage_default(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
debug("%s start\n", __func__);
|
debug("%s start\n", __func__);
|
||||||
OpteeClientApiLibInitialize();
|
TeecResult = OpteeClientApiLibInitialize();
|
||||||
|
if (TeecResult != TEEC_SUCCESS)
|
||||||
|
return -1;
|
||||||
|
|
||||||
TeecResult = TEEC_InitializeContext(NULL, &TeecContext);
|
TeecResult = TEEC_InitializeContext(NULL, &TeecContext);
|
||||||
|
if (TeecResult != TEEC_SUCCESS)
|
||||||
|
return -1;
|
||||||
|
|
||||||
TeecOperation.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT,
|
TeecOperation.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT,
|
||||||
TEEC_NONE,
|
TEEC_NONE,
|
||||||
|
|
@ -164,9 +168,13 @@ int test_secure_storage_security_partition(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
debug("%s start\n", __func__);
|
debug("%s start\n", __func__);
|
||||||
OpteeClientApiLibInitialize();
|
TeecResult = OpteeClientApiLibInitialize();
|
||||||
|
if (TeecResult != TEEC_SUCCESS)
|
||||||
|
return -1;
|
||||||
|
|
||||||
TeecResult = TEEC_InitializeContext(NULL, &TeecContext);
|
TeecResult = TEEC_InitializeContext(NULL, &TeecContext);
|
||||||
|
if (TeecResult != TEEC_SUCCESS)
|
||||||
|
return -1;
|
||||||
|
|
||||||
TeecOperation.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT,
|
TeecOperation.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT,
|
||||||
TEEC_NONE,
|
TEEC_NONE,
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
#define ATTEST_UUID_SIZE (ATAP_HEX_UUID_LEN+1)
|
#define ATTEST_UUID_SIZE (ATAP_HEX_UUID_LEN+1)
|
||||||
#define ATTEST_CA_OUT_SIZE 256
|
#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_read_rollback_index(uint32_t slot, uint64_t *value);
|
||||||
uint32_t trusty_write_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);
|
uint32_t trusty_read_permanent_attributes(uint8_t *attributes, uint32_t size);
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
#include <linux/types.h>
|
#include <linux/types.h>
|
||||||
|
|
||||||
void OpteeClientMemInit(void);
|
int OpteeClientMemInit(void);
|
||||||
|
|
||||||
void *OpteeClientMemAlloc(uint32_t length);
|
void *OpteeClientMemAlloc(uint32_t length);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,6 @@ int tee_supp_rk_fs_init(void);
|
||||||
|
|
||||||
int tee_supp_rk_fs_process(size_t num_params,
|
int tee_supp_rk_fs_process(size_t num_params,
|
||||||
struct tee_ioctl_param *params);
|
struct tee_ioctl_param *params);
|
||||||
void OpteeClientRkFsInit(void);
|
int OpteeClientRkFsInit(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,6 @@ int tee_supp_rk_fs_init(void);
|
||||||
|
|
||||||
int tee_supp_rk_fs_process(void *cmd, uint32_t cmd_size);
|
int tee_supp_rk_fs_process(void *cmd, uint32_t cmd_size);
|
||||||
|
|
||||||
void OpteeClientRkFsInit(void);
|
int OpteeClientRkFsInit(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -17,11 +17,18 @@ TEEC_Result OpteeClientApiLibInitialize(void)
|
||||||
{
|
{
|
||||||
TEEC_Result status = TEEC_SUCCESS;
|
TEEC_Result status = TEEC_SUCCESS;
|
||||||
|
|
||||||
OpteeClientMemInit();
|
status = OpteeClientMemInit();
|
||||||
|
if (status != TEEC_SUCCESS) {
|
||||||
|
printf("OpteeClientMemInit fail!");
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
status = OpteeClientRkFsInit();
|
||||||
|
if (status != TEEC_SUCCESS) {
|
||||||
|
printf("OpteeClientRkFsInit fail!");
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
OpteeClientRkFsInit();
|
return TEEC_SUCCESS;
|
||||||
|
|
||||||
return status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
void *my_mem_start;
|
void *my_mem_start;
|
||||||
uint32_t my_count;
|
uint32_t my_count;
|
||||||
uint8_t *my_flag;
|
uint8_t *my_flag = NULL;
|
||||||
typedef struct {
|
typedef struct {
|
||||||
void *addrBlock;
|
void *addrBlock;
|
||||||
uint32_t sizeBlock;
|
uint32_t sizeBlock;
|
||||||
|
|
@ -22,14 +22,25 @@ typedef struct {
|
||||||
} ALLOC_FLAG;
|
} ALLOC_FLAG;
|
||||||
ALLOC_FLAG alloc_flags[50];
|
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);
|
memset(start, 0, size);
|
||||||
my_mem_start = start;
|
my_mem_start = start;
|
||||||
my_count = size/4096;
|
my_count = size/4096;
|
||||||
my_flag = malloc(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(my_flag, 0, size/4096);
|
||||||
memset(alloc_flags, 0, 50 * sizeof(ALLOC_FLAG));
|
memset(alloc_flags, 0, 50 * sizeof(ALLOC_FLAG));
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void write_usedblock(void *addr, uint32_t size)
|
void write_usedblock(void *addr, uint32_t size)
|
||||||
|
|
@ -75,7 +86,8 @@ void *my_malloc(uint32_t size)
|
||||||
uint32_t i, j, k, num;
|
uint32_t i, j, k, num;
|
||||||
|
|
||||||
num = (size - 1) / 4096 + 1;
|
num = (size - 1) / 4096 + 1;
|
||||||
|
if (my_count < num)
|
||||||
|
return 0;
|
||||||
for (i = 0; i < my_count - num; i++) {
|
for (i = 0; i < my_count - num; i++) {
|
||||||
if (*(my_flag + i) == 0) {
|
if (*(my_flag + i) == 0) {
|
||||||
for (j = 0; j < num; j++) {
|
for (j = 0; j < num; j++) {
|
||||||
|
|
@ -127,7 +139,7 @@ void my_free(void *ptr)
|
||||||
* Initlialize the memory component, for example providing the
|
* Initlialize the memory component, for example providing the
|
||||||
* containing drivers handle.
|
* containing drivers handle.
|
||||||
*/
|
*/
|
||||||
void OpteeClientMemInit(void)
|
int OpteeClientMemInit(void)
|
||||||
{
|
{
|
||||||
ARM_SMC_ARGS ArmSmcArgs = {0};
|
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",
|
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);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -1233,10 +1233,10 @@ int tee_supp_rk_fs_init(void)
|
||||||
return TEEC_SUCCESS;
|
return TEEC_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpteeClientRkFsInit(void)
|
int OpteeClientRkFsInit(void)
|
||||||
{
|
{
|
||||||
debug(" OpteeClientRkFsInit\n");
|
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)
|
bool tee_supp_param_is_value(struct tee_ioctl_param *param)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1277,10 +1277,10 @@ int tee_supp_rk_fs_init(void)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
void OpteeClientRkFsInit(void)
|
int OpteeClientRkFsInit(void)
|
||||||
{
|
{
|
||||||
debug(" OpteeClientRkFsInit\n");
|
debug(" OpteeClientRkFsInit\n");
|
||||||
tee_supp_rk_fs_init();
|
return tee_supp_rk_fs_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
static int rkss_step = 0;
|
static int rkss_step = 0;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue