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,21 +149,23 @@ 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;
|
|
||||||
|
|
||||||
dev_desc = rockchip_get_bootdev();
|
if (dev_desc == NULL) {
|
||||||
if (!dev_desc) {
|
dev_desc = rockchip_get_bootdev();
|
||||||
printf("%s: Could not find device\n", __func__);
|
if (!dev_desc) {
|
||||||
return TEEC_ERROR_GENERIC;
|
printf("%s: Could not find device\n", __func__);
|
||||||
}
|
return TEEC_ERROR_GENERIC;
|
||||||
|
}
|
||||||
|
|
||||||
if (part_get_info_by_name(dev_desc, "security", &part_info) < 0) {
|
if (part_get_info_by_name(dev_desc, "security", &part_info) < 0) {
|
||||||
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) {
|
||||||
|
|
@ -176,18 +178,18 @@ 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;
|
|
||||||
|
|
||||||
dev_desc = rockchip_get_bootdev();
|
if (dev_desc == NULL) {
|
||||||
if (!dev_desc) {
|
dev_desc = rockchip_get_bootdev();
|
||||||
printf("%s: Could not find device\n", __func__);
|
if (!dev_desc) {
|
||||||
return TEEC_ERROR_GENERIC;
|
printf("%s: Could not find device\n", __func__);
|
||||||
}
|
return TEEC_ERROR_GENERIC;
|
||||||
|
}
|
||||||
|
|
||||||
if (part_get_info_by_name(dev_desc, "security", &part_info) < 0) {
|
if (part_get_info_by_name(dev_desc, "security", &part_info) < 0) {
|
||||||
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) {
|
||||||
|
|
@ -200,18 +202,18 @@ 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;
|
|
||||||
|
|
||||||
dev_desc = rockchip_get_bootdev();
|
if (dev_desc == NULL) {
|
||||||
if (!dev_desc) {
|
dev_desc = rockchip_get_bootdev();
|
||||||
printf("%s: Could not find device\n", __func__);
|
if (!dev_desc) {
|
||||||
return TEEC_ERROR_GENERIC;
|
printf("%s: Could not find device\n", __func__);
|
||||||
}
|
return TEEC_ERROR_GENERIC;
|
||||||
|
}
|
||||||
|
|
||||||
if (part_get_info_by_name(dev_desc, "security", &part_info) < 0) {
|
if (part_get_info_by_name(dev_desc, "security", &part_info) < 0) {
|
||||||
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) {
|
||||||
|
|
|
||||||
|
|
@ -161,21 +161,23 @@ 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;
|
|
||||||
|
|
||||||
dev_desc = rockchip_get_bootdev();
|
if (dev_desc == NULL) {
|
||||||
if (!dev_desc) {
|
dev_desc = rockchip_get_bootdev();
|
||||||
printf("%s: Could not find device\n", __func__);
|
if (!dev_desc) {
|
||||||
return -1;
|
printf("%s: Could not find device\n", __func__);
|
||||||
}
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (part_get_info_by_name(dev_desc, "security", &part_info) < 0) {
|
if (part_get_info_by_name(dev_desc, "security", &part_info) < 0) {
|
||||||
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) {
|
||||||
|
|
@ -193,18 +195,18 @@ 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;
|
|
||||||
|
|
||||||
dev_desc = rockchip_get_bootdev();
|
if (dev_desc == NULL) {
|
||||||
if (!dev_desc) {
|
dev_desc = rockchip_get_bootdev();
|
||||||
printf("%s: Could not find device\n", __func__);
|
if (!dev_desc) {
|
||||||
return -1;
|
printf("%s: Could not find device\n", __func__);
|
||||||
}
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (part_get_info_by_name(dev_desc, "security", &part_info) < 0) {
|
if (part_get_info_by_name(dev_desc, "security", &part_info) < 0) {
|
||||||
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) {
|
||||||
|
|
@ -222,18 +224,18 @@ 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;
|
|
||||||
|
|
||||||
dev_desc = rockchip_get_bootdev();
|
if (dev_desc == NULL) {
|
||||||
if (!dev_desc) {
|
dev_desc = rockchip_get_bootdev();
|
||||||
printf("%s: Could not find device\n", __func__);
|
if (!dev_desc) {
|
||||||
return -1;
|
printf("%s: Could not find device\n", __func__);
|
||||||
}
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (part_get_info_by_name(dev_desc, "security", &part_info) < 0) {
|
if (part_get_info_by_name(dev_desc, "security", &part_info) < 0) {
|
||||||
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) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue