Commit 5bd1a177 authored by Anthony Zhou's avatar Anthony Zhou Committed by Varun Wadekar
Browse files

Tegra: fiq_glue: fix MISRA defects



Main fixes:

* Added explicit casts (e.g. 0U) to integers in order for them to be
  compatible with whatever operation they're used in [Rule 10.1]

* Convert object type to match the type of function parameters
  [Rule 10.3]

* Added curly braces ({}) around if statements in order to
  make them compound [Rule 15.6]

* Expressions resulting from the expansion of macro parameters
  shall be enclosed in parentheses[Rule 20.7]

Change-Id: I5cf83caafcc1650b545ca731bf3eb8f0bfeb362b
Signed-off-by: default avatarAnthony Zhou <anzhou@nvidia.com>
parent 31d97dc2
...@@ -18,13 +18,13 @@ ...@@ -18,13 +18,13 @@
#include <tegra_def.h> #include <tegra_def.h>
#include <tegra_private.h> #include <tegra_private.h>
DEFINE_BAKERY_LOCK(tegra_fiq_lock); static DEFINE_BAKERY_LOCK(tegra_fiq_lock);
/******************************************************************************* /*******************************************************************************
* Static variables * Static variables
******************************************************************************/ ******************************************************************************/
static uint64_t ns_fiq_handler_addr; static uint64_t ns_fiq_handler_addr;
static unsigned int fiq_handler_active; static uint32_t fiq_handler_active;
static pcpu_fiq_state_t fiq_state[PLATFORM_CORE_COUNT]; static pcpu_fiq_state_t fiq_state[PLATFORM_CORE_COUNT];
/******************************************************************************* /*******************************************************************************
...@@ -37,7 +37,7 @@ static uint64_t tegra_fiq_interrupt_handler(uint32_t id, ...@@ -37,7 +37,7 @@ static uint64_t tegra_fiq_interrupt_handler(uint32_t id,
{ {
cpu_context_t *ctx = cm_get_context(NON_SECURE); cpu_context_t *ctx = cm_get_context(NON_SECURE);
el3_state_t *el3state_ctx = get_el3state_ctx(ctx); el3_state_t *el3state_ctx = get_el3state_ctx(ctx);
int cpu = plat_my_core_pos(); uint32_t cpu = plat_my_core_pos();
uint32_t irq; uint32_t irq;
bakery_lock_get(&tegra_fiq_lock); bakery_lock_get(&tegra_fiq_lock);
...@@ -52,22 +52,23 @@ static uint64_t tegra_fiq_interrupt_handler(uint32_t id, ...@@ -52,22 +52,23 @@ static uint64_t tegra_fiq_interrupt_handler(uint32_t id,
* Save elr_el3 and spsr_el3 from the saved context, and overwrite * Save elr_el3 and spsr_el3 from the saved context, and overwrite
* the context with the NS fiq_handler_addr and SPSR value. * the context with the NS fiq_handler_addr and SPSR value.
*/ */
fiq_state[cpu].elr_el3 = read_ctx_reg(el3state_ctx, CTX_ELR_EL3); fiq_state[cpu].elr_el3 = read_ctx_reg((el3state_ctx), (uint32_t)(CTX_ELR_EL3));
fiq_state[cpu].spsr_el3 = read_ctx_reg(el3state_ctx, CTX_SPSR_EL3); fiq_state[cpu].spsr_el3 = read_ctx_reg((el3state_ctx), (uint32_t)(CTX_SPSR_EL3));
/* /*
* Set the new ELR to continue execution in the NS world using the * Set the new ELR to continue execution in the NS world using the
* FIQ handler registered earlier. * FIQ handler registered earlier.
*/ */
assert(ns_fiq_handler_addr); assert(ns_fiq_handler_addr);
write_ctx_reg(el3state_ctx, CTX_ELR_EL3, ns_fiq_handler_addr); write_ctx_reg((el3state_ctx), (uint32_t)(CTX_ELR_EL3), (ns_fiq_handler_addr));
/* /*
* Mark this interrupt as complete to avoid a FIQ storm. * Mark this interrupt as complete to avoid a FIQ storm.
*/ */
irq = plat_ic_acknowledge_interrupt(); irq = plat_ic_acknowledge_interrupt();
if (irq < 1022) if (irq < 1022U) {
plat_ic_end_of_interrupt(irq); plat_ic_end_of_interrupt(irq);
}
bakery_lock_release(&tegra_fiq_lock); bakery_lock_release(&tegra_fiq_lock);
...@@ -79,27 +80,27 @@ static uint64_t tegra_fiq_interrupt_handler(uint32_t id, ...@@ -79,27 +80,27 @@ static uint64_t tegra_fiq_interrupt_handler(uint32_t id,
******************************************************************************/ ******************************************************************************/
void tegra_fiq_handler_setup(void) void tegra_fiq_handler_setup(void)
{ {
uint64_t flags; uint32_t flags;
int rc; int32_t rc;
/* return if already registered */ /* return if already registered */
if (fiq_handler_active) if (fiq_handler_active == 0U) {
return; /*
* Register an interrupt handler for FIQ interrupts generated for
/* * NS interrupt sources
* Register an interrupt handler for FIQ interrupts generated for */
* NS interrupt sources flags = 0U;
*/ set_interrupt_rm_flag((flags), (NON_SECURE));
flags = 0; rc = register_interrupt_type_handler(INTR_TYPE_EL3,
set_interrupt_rm_flag(flags, NON_SECURE); tegra_fiq_interrupt_handler,
rc = register_interrupt_type_handler(INTR_TYPE_EL3, flags);
tegra_fiq_interrupt_handler, if (rc != 0) {
flags); panic();
if (rc) }
panic();
/* handler is now active */
/* handler is now active */ fiq_handler_active = 1;
fiq_handler_active = 1; }
} }
/******************************************************************************* /*******************************************************************************
...@@ -113,26 +114,26 @@ void tegra_fiq_set_ns_entrypoint(uint64_t entrypoint) ...@@ -113,26 +114,26 @@ void tegra_fiq_set_ns_entrypoint(uint64_t entrypoint)
/******************************************************************************* /*******************************************************************************
* Handler to return the NS EL1/EL0 CPU context * Handler to return the NS EL1/EL0 CPU context
******************************************************************************/ ******************************************************************************/
int tegra_fiq_get_intr_context(void) int32_t tegra_fiq_get_intr_context(void)
{ {
cpu_context_t *ctx = cm_get_context(NON_SECURE); cpu_context_t *ctx = cm_get_context(NON_SECURE);
gp_regs_t *gpregs_ctx = get_gpregs_ctx(ctx); gp_regs_t *gpregs_ctx = get_gpregs_ctx(ctx);
el1_sys_regs_t *el1state_ctx = get_sysregs_ctx(ctx); const el1_sys_regs_t *el1state_ctx = get_sysregs_ctx(ctx);
int cpu = plat_my_core_pos(); uint32_t cpu = plat_my_core_pos();
uint64_t val; uint64_t val;
/* /*
* We store the ELR_EL3, SPSR_EL3, SP_EL0 and SP_EL1 registers so * We store the ELR_EL3, SPSR_EL3, SP_EL0 and SP_EL1 registers so
* that el3_exit() sends these values back to the NS world. * that el3_exit() sends these values back to the NS world.
*/ */
write_ctx_reg(gpregs_ctx, CTX_GPREG_X0, fiq_state[cpu].elr_el3); write_ctx_reg((gpregs_ctx), (uint32_t)(CTX_GPREG_X0), (fiq_state[cpu].elr_el3));
write_ctx_reg(gpregs_ctx, CTX_GPREG_X1, fiq_state[cpu].spsr_el3); write_ctx_reg((gpregs_ctx), (uint32_t)(CTX_GPREG_X1), (fiq_state[cpu].spsr_el3));
val = read_ctx_reg(gpregs_ctx, CTX_GPREG_SP_EL0); val = read_ctx_reg((gpregs_ctx), (uint32_t)(CTX_GPREG_SP_EL0));
write_ctx_reg(gpregs_ctx, CTX_GPREG_X2, val); write_ctx_reg((gpregs_ctx), (uint32_t)(CTX_GPREG_X2), (val));
val = read_ctx_reg(el1state_ctx, CTX_SP_EL1); val = read_ctx_reg((el1state_ctx), (uint32_t)(CTX_SP_EL1));
write_ctx_reg(gpregs_ctx, CTX_GPREG_X3, val); write_ctx_reg((gpregs_ctx), (uint32_t)(CTX_GPREG_X3), (val));
return 0; return 0;
} }
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