Commit 776ff52a authored by Daniel Boulby's avatar Daniel Boulby
Browse files

Fix MISRA Rule 5.7 Part 3



Rule 5.7: A tag name shall be a unique identifier

Follow convention of shorter names for smaller scope to fix
violations of MISRA rule 5.7

Fixed For:
    make ARM_TSP_RAM_LOCATION=tdram LOG_LEVEL=50 PLAT=fvp SPD=opteed

Change-Id: I5fbb5d6ebddf169550eddb07ed880f5c8076bb76
Signed-off-by: default avatarDaniel Boulby <daniel.boulby@arm.com>
parent a138f768
...@@ -43,7 +43,7 @@ typedef struct optee_header { ...@@ -43,7 +43,7 @@ typedef struct optee_header {
uint8_t arch; uint8_t arch;
uint16_t flags; uint16_t flags;
uint32_t nb_images; uint32_t nb_images;
optee_image_t optee_image[]; optee_image_t optee_image_list[];
} optee_header_t; } optee_header_t;
/******************************************************************************* /*******************************************************************************
...@@ -51,11 +51,11 @@ typedef struct optee_header { ...@@ -51,11 +51,11 @@ typedef struct optee_header {
* Return 1 if valid * Return 1 if valid
* Return 0 if invalid * Return 0 if invalid
******************************************************************************/ ******************************************************************************/
static inline int tee_validate_header(optee_header_t *optee_header) static inline int tee_validate_header(optee_header_t *header)
{ {
if ((optee_header->magic == TEE_MAGIC_NUM_OPTEE) && if ((header->magic == TEE_MAGIC_NUM_OPTEE) &&
(optee_header->version == 2) && (header->version == 2) &&
(optee_header->nb_images <= OPTEE_MAX_IMAGE_NUM)) { (header->nb_images <= OPTEE_MAX_IMAGE_NUM)) {
return 1; return 1;
} }
...@@ -68,14 +68,14 @@ static inline int tee_validate_header(optee_header_t *optee_header) ...@@ -68,14 +68,14 @@ static inline int tee_validate_header(optee_header_t *optee_header)
* Return 0 on success or a negative error code otherwise. * Return 0 on success or a negative error code otherwise.
******************************************************************************/ ******************************************************************************/
static int parse_optee_image(image_info_t *image_info, static int parse_optee_image(image_info_t *image_info,
optee_image_t *optee_image) optee_image_t *image)
{ {
uintptr_t init_load_addr, free_end, requested_end; uintptr_t init_load_addr, free_end, requested_end;
size_t init_size; size_t init_size;
init_load_addr = ((uint64_t)optee_image->load_addr_hi << 32) | init_load_addr = ((uint64_t)image->load_addr_hi << 32) |
optee_image->load_addr_lo; image->load_addr_lo;
init_size = optee_image->size; init_size = image->size;
/* /*
* -1 indicates loader decided address; take our pre-mapped area * -1 indicates loader decided address; take our pre-mapped area
...@@ -133,21 +133,21 @@ int parse_optee_header(entry_point_info_t *header_ep, ...@@ -133,21 +133,21 @@ int parse_optee_header(entry_point_info_t *header_ep,
image_info_t *paged_image_info) image_info_t *paged_image_info)
{ {
optee_header_t *optee_header; optee_header_t *header;
int num, ret; int num, ret;
assert(header_ep); assert(header_ep);
optee_header = (optee_header_t *)header_ep->pc; header = (optee_header_t *)header_ep->pc;
assert(optee_header); assert(header);
/* Print the OPTEE header information */ /* Print the OPTEE header information */
INFO("OPTEE ep=0x%x\n", (unsigned int)header_ep->pc); INFO("OPTEE ep=0x%x\n", (unsigned int)header_ep->pc);
INFO("OPTEE header info:\n"); INFO("OPTEE header info:\n");
INFO(" magic=0x%x\n", optee_header->magic); INFO(" magic=0x%x\n", header->magic);
INFO(" version=0x%x\n", optee_header->version); INFO(" version=0x%x\n", header->version);
INFO(" arch=0x%x\n", optee_header->arch); INFO(" arch=0x%x\n", header->arch);
INFO(" flags=0x%x\n", optee_header->flags); INFO(" flags=0x%x\n", header->flags);
INFO(" nb_images=0x%x\n", optee_header->nb_images); INFO(" nb_images=0x%x\n", header->nb_images);
/* /*
* OPTEE image has 3 types: * OPTEE image has 3 types:
...@@ -166,7 +166,7 @@ int parse_optee_header(entry_point_info_t *header_ep, ...@@ -166,7 +166,7 @@ int parse_optee_header(entry_point_info_t *header_ep,
* pager and pageable. Remove skip attr for BL32_EXTRA1_IMAGE_ID * pager and pageable. Remove skip attr for BL32_EXTRA1_IMAGE_ID
* and BL32_EXTRA2_IMAGE_ID to load pager and paged bin. * and BL32_EXTRA2_IMAGE_ID to load pager and paged bin.
*/ */
if (!tee_validate_header(optee_header)) { if (!tee_validate_header(header)) {
INFO("Invalid OPTEE header, set legacy mode.\n"); INFO("Invalid OPTEE header, set legacy mode.\n");
#ifdef AARCH64 #ifdef AARCH64
header_ep->args.arg0 = MODE_RW_64; header_ep->args.arg0 = MODE_RW_64;
...@@ -177,15 +177,15 @@ int parse_optee_header(entry_point_info_t *header_ep, ...@@ -177,15 +177,15 @@ int parse_optee_header(entry_point_info_t *header_ep,
} }
/* Parse OPTEE image */ /* Parse OPTEE image */
for (num = 0; num < optee_header->nb_images; num++) { for (num = 0; num < header->nb_images; num++) {
if (optee_header->optee_image[num].image_id == if (header->optee_image_list[num].image_id ==
OPTEE_PAGER_IMAGE_ID) { OPTEE_PAGER_IMAGE_ID) {
ret = parse_optee_image(pager_image_info, ret = parse_optee_image(pager_image_info,
&optee_header->optee_image[num]); &header->optee_image_list[num]);
} else if (optee_header->optee_image[num].image_id == } else if (header->optee_image_list[num].image_id ==
OPTEE_PAGED_IMAGE_ID) { OPTEE_PAGED_IMAGE_ID) {
ret = parse_optee_image(paged_image_info, ret = parse_optee_image(paged_image_info,
&optee_header->optee_image[num]); &header->optee_image_list[num]);
} else { } else {
ERROR("Parse optee image failed.\n"); ERROR("Parse optee image failed.\n");
return -1; return -1;
...@@ -211,7 +211,7 @@ int parse_optee_header(entry_point_info_t *header_ep, ...@@ -211,7 +211,7 @@ int parse_optee_header(entry_point_info_t *header_ep,
header_ep->args.arg2 = paged_image_info->image_size; header_ep->args.arg2 = paged_image_info->image_size;
/* Set OPTEE runtime arch - aarch32/aarch64 */ /* Set OPTEE runtime arch - aarch32/aarch64 */
if (optee_header->arch == 0) { if (header->arch == 0) {
header_ep->args.arg0 = MODE_RW_32; header_ep->args.arg0 = MODE_RW_32;
} else { } else {
#ifdef AARCH64 #ifdef AARCH64
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
* Address of the entrypoint vector table in OPTEE. It is * Address of the entrypoint vector table in OPTEE. It is
* initialised once on the primary core after a cold boot. * initialised once on the primary core after a cold boot.
******************************************************************************/ ******************************************************************************/
optee_vectors_t *optee_vectors; optee_vectors_t *optee_vector_table;
/******************************************************************************* /*******************************************************************************
* Array to keep track of per-cpu OPTEE state * Array to keep track of per-cpu OPTEE state
...@@ -71,7 +71,7 @@ static uint64_t opteed_sel1_interrupt_handler(uint32_t id, ...@@ -71,7 +71,7 @@ static uint64_t opteed_sel1_interrupt_handler(uint32_t id,
optee_ctx = &opteed_sp_context[linear_id]; optee_ctx = &opteed_sp_context[linear_id];
assert(&optee_ctx->cpu_ctx == cm_get_context(SECURE)); assert(&optee_ctx->cpu_ctx == cm_get_context(SECURE));
cm_set_elr_el3(SECURE, (uint64_t)&optee_vectors->fiq_entry); cm_set_elr_el3(SECURE, (uint64_t)&optee_vector_table->fiq_entry);
cm_el1_sysregs_context_restore(SECURE); cm_el1_sysregs_context_restore(SECURE);
cm_set_next_eret_context(SECURE); cm_set_next_eret_context(SECURE);
...@@ -236,10 +236,10 @@ static uintptr_t opteed_smc_handler(uint32_t smc_fid, ...@@ -236,10 +236,10 @@ static uintptr_t opteed_smc_handler(uint32_t smc_fid,
*/ */
if (GET_SMC_TYPE(smc_fid) == SMC_TYPE_FAST) { if (GET_SMC_TYPE(smc_fid) == SMC_TYPE_FAST) {
cm_set_elr_el3(SECURE, (uint64_t) cm_set_elr_el3(SECURE, (uint64_t)
&optee_vectors->fast_smc_entry); &optee_vector_table->fast_smc_entry);
} else { } else {
cm_set_elr_el3(SECURE, (uint64_t) cm_set_elr_el3(SECURE, (uint64_t)
&optee_vectors->yield_smc_entry); &optee_vector_table->yield_smc_entry);
} }
cm_el1_sysregs_context_restore(SECURE); cm_el1_sysregs_context_restore(SECURE);
...@@ -279,10 +279,10 @@ static uintptr_t opteed_smc_handler(uint32_t smc_fid, ...@@ -279,10 +279,10 @@ static uintptr_t opteed_smc_handler(uint32_t smc_fid,
* Stash the OPTEE entry points information. This is done * Stash the OPTEE entry points information. This is done
* only once on the primary cpu * only once on the primary cpu
*/ */
assert(optee_vectors == NULL); assert(optee_vector_table == NULL);
optee_vectors = (optee_vectors_t *) x1; optee_vector_table = (optee_vectors_t *) x1;
if (optee_vectors) { if (optee_vector_table) {
set_optee_pstate(optee_ctx->state, OPTEE_PSTATE_ON); set_optee_pstate(optee_ctx->state, OPTEE_PSTATE_ON);
/* /*
......
...@@ -30,11 +30,11 @@ static int32_t opteed_cpu_off_handler(u_register_t unused) ...@@ -30,11 +30,11 @@ static int32_t opteed_cpu_off_handler(u_register_t unused)
uint32_t linear_id = plat_my_core_pos(); uint32_t linear_id = plat_my_core_pos();
optee_context_t *optee_ctx = &opteed_sp_context[linear_id]; optee_context_t *optee_ctx = &opteed_sp_context[linear_id];
assert(optee_vectors); assert(optee_vector_table);
assert(get_optee_pstate(optee_ctx->state) == OPTEE_PSTATE_ON); assert(get_optee_pstate(optee_ctx->state) == OPTEE_PSTATE_ON);
/* Program the entry point and enter OPTEE */ /* Program the entry point and enter OPTEE */
cm_set_elr_el3(SECURE, (uint64_t) &optee_vectors->cpu_off_entry); cm_set_elr_el3(SECURE, (uint64_t) &optee_vector_table->cpu_off_entry);
rc = opteed_synchronous_sp_entry(optee_ctx); rc = opteed_synchronous_sp_entry(optee_ctx);
/* /*
...@@ -63,11 +63,11 @@ static void opteed_cpu_suspend_handler(u_register_t max_off_pwrlvl) ...@@ -63,11 +63,11 @@ static void opteed_cpu_suspend_handler(u_register_t max_off_pwrlvl)
uint32_t linear_id = plat_my_core_pos(); uint32_t linear_id = plat_my_core_pos();
optee_context_t *optee_ctx = &opteed_sp_context[linear_id]; optee_context_t *optee_ctx = &opteed_sp_context[linear_id];
assert(optee_vectors); assert(optee_vector_table);
assert(get_optee_pstate(optee_ctx->state) == OPTEE_PSTATE_ON); assert(get_optee_pstate(optee_ctx->state) == OPTEE_PSTATE_ON);
/* Program the entry point and enter OPTEE */ /* Program the entry point and enter OPTEE */
cm_set_elr_el3(SECURE, (uint64_t) &optee_vectors->cpu_suspend_entry); cm_set_elr_el3(SECURE, (uint64_t) &optee_vector_table->cpu_suspend_entry);
rc = opteed_synchronous_sp_entry(optee_ctx); rc = opteed_synchronous_sp_entry(optee_ctx);
/* /*
...@@ -94,11 +94,11 @@ static void opteed_cpu_on_finish_handler(u_register_t unused) ...@@ -94,11 +94,11 @@ static void opteed_cpu_on_finish_handler(u_register_t unused)
optee_context_t *optee_ctx = &opteed_sp_context[linear_id]; optee_context_t *optee_ctx = &opteed_sp_context[linear_id];
entry_point_info_t optee_on_entrypoint; entry_point_info_t optee_on_entrypoint;
assert(optee_vectors); assert(optee_vector_table);
assert(get_optee_pstate(optee_ctx->state) == OPTEE_PSTATE_OFF); assert(get_optee_pstate(optee_ctx->state) == OPTEE_PSTATE_OFF);
opteed_init_optee_ep_state(&optee_on_entrypoint, opteed_rw, opteed_init_optee_ep_state(&optee_on_entrypoint, opteed_rw,
(uint64_t)&optee_vectors->cpu_on_entry, (uint64_t)&optee_vector_table->cpu_on_entry,
0, 0, 0, optee_ctx); 0, 0, 0, optee_ctx);
/* Initialise this cpu's secure context */ /* Initialise this cpu's secure context */
...@@ -129,14 +129,14 @@ static void opteed_cpu_suspend_finish_handler(u_register_t max_off_pwrlvl) ...@@ -129,14 +129,14 @@ static void opteed_cpu_suspend_finish_handler(u_register_t max_off_pwrlvl)
uint32_t linear_id = plat_my_core_pos(); uint32_t linear_id = plat_my_core_pos();
optee_context_t *optee_ctx = &opteed_sp_context[linear_id]; optee_context_t *optee_ctx = &opteed_sp_context[linear_id];
assert(optee_vectors); assert(optee_vector_table);
assert(get_optee_pstate(optee_ctx->state) == OPTEE_PSTATE_SUSPEND); assert(get_optee_pstate(optee_ctx->state) == OPTEE_PSTATE_SUSPEND);
/* Program the entry point, max_off_pwrlvl and enter the SP */ /* Program the entry point, max_off_pwrlvl and enter the SP */
write_ctx_reg(get_gpregs_ctx(&optee_ctx->cpu_ctx), write_ctx_reg(get_gpregs_ctx(&optee_ctx->cpu_ctx),
CTX_GPREG_X0, CTX_GPREG_X0,
max_off_pwrlvl); max_off_pwrlvl);
cm_set_elr_el3(SECURE, (uint64_t) &optee_vectors->cpu_resume_entry); cm_set_elr_el3(SECURE, (uint64_t) &optee_vector_table->cpu_resume_entry);
rc = opteed_synchronous_sp_entry(optee_ctx); rc = opteed_synchronous_sp_entry(optee_ctx);
/* /*
...@@ -168,11 +168,11 @@ static void opteed_system_off(void) ...@@ -168,11 +168,11 @@ static void opteed_system_off(void)
uint32_t linear_id = plat_my_core_pos(); uint32_t linear_id = plat_my_core_pos();
optee_context_t *optee_ctx = &opteed_sp_context[linear_id]; optee_context_t *optee_ctx = &opteed_sp_context[linear_id];
assert(optee_vectors); assert(optee_vector_table);
assert(get_optee_pstate(optee_ctx->state) == OPTEE_PSTATE_ON); assert(get_optee_pstate(optee_ctx->state) == OPTEE_PSTATE_ON);
/* Program the entry point */ /* Program the entry point */
cm_set_elr_el3(SECURE, (uint64_t) &optee_vectors->system_off_entry); cm_set_elr_el3(SECURE, (uint64_t) &optee_vector_table->system_off_entry);
/* Enter OPTEE. We do not care about the return value because we /* Enter OPTEE. We do not care about the return value because we
* must continue the shutdown anyway */ * must continue the shutdown anyway */
...@@ -188,11 +188,11 @@ static void opteed_system_reset(void) ...@@ -188,11 +188,11 @@ static void opteed_system_reset(void)
uint32_t linear_id = plat_my_core_pos(); uint32_t linear_id = plat_my_core_pos();
optee_context_t *optee_ctx = &opteed_sp_context[linear_id]; optee_context_t *optee_ctx = &opteed_sp_context[linear_id];
assert(optee_vectors); assert(optee_vector_table);
assert(get_optee_pstate(optee_ctx->state) == OPTEE_PSTATE_ON); assert(get_optee_pstate(optee_ctx->state) == OPTEE_PSTATE_ON);
/* Program the entry point */ /* Program the entry point */
cm_set_elr_el3(SECURE, (uint64_t) &optee_vectors->system_reset_entry); cm_set_elr_el3(SECURE, (uint64_t) &optee_vector_table->system_reset_entry);
/* Enter OPTEE. We do not care about the return value because we /* Enter OPTEE. We do not care about the return value because we
* must continue the reset anyway */ * must continue the reset anyway */
......
...@@ -154,7 +154,7 @@ void opteed_init_optee_ep_state(struct entry_point_info *optee_ep, ...@@ -154,7 +154,7 @@ void opteed_init_optee_ep_state(struct entry_point_info *optee_ep,
extern optee_context_t opteed_sp_context[OPTEED_CORE_COUNT]; extern optee_context_t opteed_sp_context[OPTEED_CORE_COUNT];
extern uint32_t opteed_rw; extern uint32_t opteed_rw;
extern struct optee_vectors *optee_vectors; extern struct optee_vectors *optee_vector_table;
#endif /*__ASSEMBLY__*/ #endif /*__ASSEMBLY__*/
#endif /* __OPTEED_PRIVATE_H__ */ #endif /* __OPTEED_PRIVATE_H__ */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment