lib: optee_client: search security partition once
Change-Id: I4f3fbdb1e319e5b200225353a2d945bebd888f8c Signed-off-by: Hisping Lin <hisping.lin@rock-chips.com>
This commit is contained in:
parent
1b4602e039
commit
bdf50261ca
|
|
@ -149,12 +149,13 @@ static char dir_cache[RKSS_NAME_MAX_LENGTH][12];
|
||||||
static int dir_num;
|
static int dir_num;
|
||||||
static int dir_seek;
|
static int dir_seek;
|
||||||
|
|
||||||
|
static struct blk_desc *dev_desc = NULL;
|
||||||
|
static disk_partition_t part_info;
|
||||||
static int rkss_read_multi_sections(unsigned char *data, unsigned long index, unsigned int num)
|
static int rkss_read_multi_sections(unsigned char *data, unsigned long index, unsigned int num)
|
||||||
{
|
{
|
||||||
unsigned long ret;
|
unsigned long ret;
|
||||||
struct blk_desc *dev_desc;
|
|
||||||
disk_partition_t part_info;
|
|
||||||
|
|
||||||
|
if (dev_desc == NULL) {
|
||||||
dev_desc = rockchip_get_bootdev();
|
dev_desc = rockchip_get_bootdev();
|
||||||
if (!dev_desc) {
|
if (!dev_desc) {
|
||||||
printf("%s: Could not find device\n", __func__);
|
printf("%s: Could not find device\n", __func__);
|
||||||
|
|
@ -165,6 +166,7 @@ static int rkss_read_multi_sections(unsigned char *data, unsigned long index, un
|
||||||
printf("Could not find security partition\n");
|
printf("Could not find security partition\n");
|
||||||
return TEEC_ERROR_GENERIC;
|
return TEEC_ERROR_GENERIC;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ret = blk_dread(dev_desc, part_info.start + index, num, data);
|
ret = blk_dread(dev_desc, part_info.start + index, num, data);
|
||||||
if (ret != num) {
|
if (ret != num) {
|
||||||
printf("blk_dread fail \n");
|
printf("blk_dread fail \n");
|
||||||
|
|
@ -176,9 +178,8 @@ static int rkss_read_multi_sections(unsigned char *data, unsigned long index, un
|
||||||
static int rkss_write_multi_sections(unsigned char *data, unsigned long index, unsigned int num)
|
static int rkss_write_multi_sections(unsigned char *data, unsigned long index, unsigned int num)
|
||||||
{
|
{
|
||||||
unsigned long ret;
|
unsigned long ret;
|
||||||
struct blk_desc *dev_desc;
|
|
||||||
disk_partition_t part_info;
|
|
||||||
|
|
||||||
|
if (dev_desc == NULL) {
|
||||||
dev_desc = rockchip_get_bootdev();
|
dev_desc = rockchip_get_bootdev();
|
||||||
if (!dev_desc) {
|
if (!dev_desc) {
|
||||||
printf("%s: Could not find device\n", __func__);
|
printf("%s: Could not find device\n", __func__);
|
||||||
|
|
@ -189,6 +190,7 @@ static int rkss_write_multi_sections(unsigned char *data, unsigned long index, u
|
||||||
printf("Could not find security partition\n");
|
printf("Could not find security partition\n");
|
||||||
return TEEC_ERROR_GENERIC;
|
return TEEC_ERROR_GENERIC;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ret = blk_dwrite(dev_desc, part_info.start + index, num, data);
|
ret = blk_dwrite(dev_desc, part_info.start + index, num, data);
|
||||||
if (ret != num) {
|
if (ret != num) {
|
||||||
printf("blk_dwrite fail \n");
|
printf("blk_dwrite fail \n");
|
||||||
|
|
@ -200,9 +202,8 @@ static int rkss_write_multi_sections(unsigned char *data, unsigned long index, u
|
||||||
static int rkss_read_patition_tables(unsigned char *data)
|
static int rkss_read_patition_tables(unsigned char *data)
|
||||||
{
|
{
|
||||||
unsigned long ret;
|
unsigned long ret;
|
||||||
struct blk_desc *dev_desc;
|
|
||||||
disk_partition_t part_info;
|
|
||||||
|
|
||||||
|
if (dev_desc == NULL) {
|
||||||
dev_desc = rockchip_get_bootdev();
|
dev_desc = rockchip_get_bootdev();
|
||||||
if (!dev_desc) {
|
if (!dev_desc) {
|
||||||
printf("%s: Could not find device\n", __func__);
|
printf("%s: Could not find device\n", __func__);
|
||||||
|
|
@ -213,6 +214,7 @@ static int rkss_read_patition_tables(unsigned char *data)
|
||||||
printf("Could not find security partition\n");
|
printf("Could not find security partition\n");
|
||||||
return TEEC_ERROR_GENERIC;
|
return TEEC_ERROR_GENERIC;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ret = blk_dread(dev_desc, part_info.start, RKSS_PARTITION_TABLE_COUNT, data);
|
ret = blk_dread(dev_desc, part_info.start, RKSS_PARTITION_TABLE_COUNT, data);
|
||||||
if (ret != RKSS_PARTITION_TABLE_COUNT) {
|
if (ret != RKSS_PARTITION_TABLE_COUNT) {
|
||||||
printf("blk_dread fail \n");
|
printf("blk_dread fail \n");
|
||||||
|
|
|
||||||
|
|
@ -161,12 +161,13 @@ extern unsigned long blk_dread(struct blk_desc *block_dev, lbaint_t start,
|
||||||
extern unsigned long blk_dwrite(struct blk_desc *block_dev, lbaint_t start,
|
extern unsigned long blk_dwrite(struct blk_desc *block_dev, lbaint_t start,
|
||||||
lbaint_t blkcnt, const void *buffer);
|
lbaint_t blkcnt, const void *buffer);
|
||||||
|
|
||||||
|
static struct blk_desc *dev_desc = NULL;
|
||||||
|
static disk_partition_t part_info;
|
||||||
static int rkss_read_multi_sections(unsigned char *data, unsigned long index, unsigned int num)
|
static int rkss_read_multi_sections(unsigned char *data, unsigned long index, unsigned int num)
|
||||||
{
|
{
|
||||||
unsigned long ret;
|
unsigned long ret;
|
||||||
struct blk_desc *dev_desc;
|
|
||||||
disk_partition_t part_info;
|
|
||||||
|
|
||||||
|
if (dev_desc == NULL) {
|
||||||
dev_desc = rockchip_get_bootdev();
|
dev_desc = rockchip_get_bootdev();
|
||||||
if (!dev_desc) {
|
if (!dev_desc) {
|
||||||
printf("%s: Could not find device\n", __func__);
|
printf("%s: Could not find device\n", __func__);
|
||||||
|
|
@ -177,6 +178,7 @@ static int rkss_read_multi_sections(unsigned char *data, unsigned long index, un
|
||||||
printf("Could not find security partition\n");
|
printf("Could not find security partition\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ret = blk_dread(dev_desc, part_info.start + index, num, data);
|
ret = blk_dread(dev_desc, part_info.start + index, num, data);
|
||||||
if (ret != num) {
|
if (ret != num) {
|
||||||
printf("blk_dread fail \n");
|
printf("blk_dread fail \n");
|
||||||
|
|
@ -193,9 +195,8 @@ static int rkss_read_section(struct rk_secure_storage *rkss)
|
||||||
static int rkss_write_multi_sections(unsigned char *data, unsigned long index, unsigned int num)
|
static int rkss_write_multi_sections(unsigned char *data, unsigned long index, unsigned int num)
|
||||||
{
|
{
|
||||||
unsigned long ret;
|
unsigned long ret;
|
||||||
struct blk_desc *dev_desc;
|
|
||||||
disk_partition_t part_info;
|
|
||||||
|
|
||||||
|
if (dev_desc == NULL) {
|
||||||
dev_desc = rockchip_get_bootdev();
|
dev_desc = rockchip_get_bootdev();
|
||||||
if (!dev_desc) {
|
if (!dev_desc) {
|
||||||
printf("%s: Could not find device\n", __func__);
|
printf("%s: Could not find device\n", __func__);
|
||||||
|
|
@ -206,6 +207,7 @@ static int rkss_write_multi_sections(unsigned char *data, unsigned long index, u
|
||||||
printf("Could not find security partition\n");
|
printf("Could not find security partition\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ret = blk_dwrite(dev_desc, part_info.start + index, num, data);
|
ret = blk_dwrite(dev_desc, part_info.start + index, num, data);
|
||||||
if (ret != num) {
|
if (ret != num) {
|
||||||
printf("blk_dwrite fail \n");
|
printf("blk_dwrite fail \n");
|
||||||
|
|
@ -222,9 +224,8 @@ static int rkss_write_section(struct rk_secure_storage *rkss)
|
||||||
static int rkss_read_patition_tables(unsigned char *data)
|
static int rkss_read_patition_tables(unsigned char *data)
|
||||||
{
|
{
|
||||||
unsigned long ret;
|
unsigned long ret;
|
||||||
struct blk_desc *dev_desc;
|
|
||||||
disk_partition_t part_info;
|
|
||||||
|
|
||||||
|
if (dev_desc == NULL) {
|
||||||
dev_desc = rockchip_get_bootdev();
|
dev_desc = rockchip_get_bootdev();
|
||||||
if (!dev_desc) {
|
if (!dev_desc) {
|
||||||
printf("%s: Could not find device\n", __func__);
|
printf("%s: Could not find device\n", __func__);
|
||||||
|
|
@ -235,6 +236,7 @@ static int rkss_read_patition_tables(unsigned char *data)
|
||||||
printf("Could not find security partition\n");
|
printf("Could not find security partition\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ret = blk_dread(dev_desc, part_info.start, RKSS_PARTITION_TABLE_COUNT, data);
|
ret = blk_dread(dev_desc, part_info.start, RKSS_PARTITION_TABLE_COUNT, data);
|
||||||
if (ret != RKSS_PARTITION_TABLE_COUNT) {
|
if (ret != RKSS_PARTITION_TABLE_COUNT) {
|
||||||
printf("blk_dread fail \n");
|
printf("blk_dread fail \n");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue