diff options
author | Antonio Nino Diaz <antonio.ninodiaz@arm.com> | 2018-10-31 15:25:35 +0000 |
---|---|---|
committer | Antonio Nino Diaz <antonio.ninodiaz@arm.com> | 2018-11-01 14:15:39 +0000 |
commit | a0fee7474fb946fcbcd43c4947cf113147e26301 (patch) | |
tree | da05ee3a1ec652ea8aede81f84af0d4e48237a8c /include | |
parent | 3c1fb7a7006b2cd076d958aa8ba14eba25e82de8 (diff) |
context_mgmt: Fix MISRA defects
The macro EL_IMPLEMENTED() has been deprecated in favour of the new
function el_implemented().
Change-Id: Ic9b1b81480b5e019b50a050e8c1a199991bf0ca9
Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/common/ep_info.h | 2 | ||||
-rw-r--r-- | include/lib/aarch32/arch_helpers.h | 6 | ||||
-rw-r--r-- | include/lib/aarch64/arch_helpers.h | 27 | ||||
-rw-r--r-- | include/lib/el3_runtime/aarch32/context.h | 32 | ||||
-rw-r--r-- | include/lib/el3_runtime/aarch64/context.h | 6 | ||||
-rw-r--r-- | include/lib/el3_runtime/context_mgmt.h | 9 | ||||
-rw-r--r-- | include/lib/el3_runtime/cpu_data.h | 4 |
7 files changed, 49 insertions, 37 deletions
diff --git a/include/common/ep_info.h b/include/common/ep_info.h index bf3f7823..db2355ab 100644 --- a/include/common/ep_info.h +++ b/include/common/ep_info.h @@ -30,7 +30,7 @@ #define PARAM_EP_SECURITY_MASK U(0x1) /* Secure or Non-secure image */ -#define GET_SECURITY_STATE(x) (x & PARAM_EP_SECURITY_MASK) +#define GET_SECURITY_STATE(x) ((x) & PARAM_EP_SECURITY_MASK) #define SET_SECURITY_STATE(x, security) \ ((x) = ((x) & ~PARAM_EP_SECURITY_MASK) | (security)) diff --git a/include/lib/aarch32/arch_helpers.h b/include/lib/aarch32/arch_helpers.h index 5d9c1c15..03f0e869 100644 --- a/include/lib/aarch32/arch_helpers.h +++ b/include/lib/aarch32/arch_helpers.h @@ -4,8 +4,8 @@ * SPDX-License-Identifier: BSD-3-Clause */ -#ifndef __ARCH_HELPERS_H__ -#define __ARCH_HELPERS_H__ +#ifndef ARCH_HELPERS_H +#define ARCH_HELPERS_H #include <arch.h> /* for additional register definitions */ #include <cdefs.h> @@ -381,4 +381,4 @@ static inline unsigned int get_current_el(void) #define write_icc_sgi0r_el1(_v) \ write64_icc_sgi0r_el1(_v) -#endif /* __ARCH_HELPERS_H__ */ +#endif /* ARCH_HELPERS_H */ diff --git a/include/lib/aarch64/arch_helpers.h b/include/lib/aarch64/arch_helpers.h index d90061f2..61f9830d 100644 --- a/include/lib/aarch64/arch_helpers.h +++ b/include/lib/aarch64/arch_helpers.h @@ -4,11 +4,12 @@ * SPDX-License-Identifier: BSD-3-Clause */ -#ifndef __ARCH_HELPERS_H__ -#define __ARCH_HELPERS_H__ +#ifndef ARCH_HELPERS_H +#define ARCH_HELPERS_H #include <arch.h> /* for additional register definitions */ #include <cdefs.h> /* For __dead2 */ +#include <stdbool.h> #include <stdint.h> #include <string.h> @@ -363,12 +364,22 @@ static inline unsigned int get_current_el(void) } /* - * Check if an EL is implemented from AA64PFR0 register fields. 'el' argument - * must be one of 1, 2 or 3. + * Check if an EL is implemented from AA64PFR0 register fields. */ -#define EL_IMPLEMENTED(el) \ - ((read_id_aa64pfr0_el1() >> ID_AA64PFR0_EL##el##_SHIFT) \ - & ID_AA64PFR0_ELX_MASK) +static inline uint64_t el_implemented(unsigned int el) +{ + if (el > 3U) { + return EL_IMPL_NONE; + } else { + unsigned int shift = ID_AA64PFR0_EL1_SHIFT * el; + + return (read_id_aa64pfr0_el1() >> shift) & ID_AA64PFR0_ELX_MASK; + } +} + +#if !ERROR_DEPRECATED +#define EL_IMPLEMENTED(_el) el_implemented(_el) +#endif /* Previously defined accesor functions with incomplete register names */ @@ -389,4 +400,4 @@ static inline unsigned int get_current_el(void) #define read_cpacr() read_cpacr_el1() #define write_cpacr(_v) write_cpacr_el1(_v) -#endif /* __ARCH_HELPERS_H__ */ +#endif /* ARCH_HELPERS_H */ diff --git a/include/lib/el3_runtime/aarch32/context.h b/include/lib/el3_runtime/aarch32/context.h index 64473605..1ea19ca7 100644 --- a/include/lib/el3_runtime/aarch32/context.h +++ b/include/lib/el3_runtime/aarch32/context.h @@ -1,26 +1,28 @@ /* - * Copyright (c) 2016, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2016-2018, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ -#ifndef __CONTEXT_H__ -#define __CONTEXT_H__ +#ifndef CONTEXT_H +#define CONTEXT_H + +#include <utils_def.h> /******************************************************************************* * Constants that allow assembler code to access members of and the 'regs' * structure at their correct offsets. ******************************************************************************/ -#define CTX_REGS_OFFSET 0x0 -#define CTX_GPREG_R0 0x0 -#define CTX_GPREG_R1 0x4 -#define CTX_GPREG_R2 0x8 -#define CTX_GPREG_R3 0xC -#define CTX_LR 0x10 -#define CTX_SCR 0x14 -#define CTX_SPSR 0x18 -#define CTX_NS_SCTLR 0x1C -#define CTX_REGS_END 0x20 +#define CTX_REGS_OFFSET U(0x0) +#define CTX_GPREG_R0 U(0x0) +#define CTX_GPREG_R1 U(0x4) +#define CTX_GPREG_R2 U(0x8) +#define CTX_GPREG_R3 U(0xC) +#define CTX_LR U(0x10) +#define CTX_SCR U(0x14) +#define CTX_SPSR U(0x18) +#define CTX_NS_SCTLR U(0x1C) +#define CTX_REGS_END U(0x20) #ifndef __ASSEMBLY__ @@ -31,7 +33,7 @@ * Common constants to help define the 'cpu_context' structure and its * members below. */ -#define WORD_SHIFT 2 +#define WORD_SHIFT U(2) #define DEFINE_REG_STRUCT(name, num_regs) \ typedef struct name { \ uint32_t _regs[num_regs]; \ @@ -64,4 +66,4 @@ CASSERT(CTX_REGS_OFFSET == __builtin_offsetof(cpu_context_t, regs_ctx), \ #endif /* __ASSEMBLY__ */ -#endif /* __CONTEXT_H__ */ +#endif /* CONTEXT_H */ diff --git a/include/lib/el3_runtime/aarch64/context.h b/include/lib/el3_runtime/aarch64/context.h index b990674c..8c5f4c68 100644 --- a/include/lib/el3_runtime/aarch64/context.h +++ b/include/lib/el3_runtime/aarch64/context.h @@ -4,8 +4,8 @@ * SPDX-License-Identifier: BSD-3-Clause */ -#ifndef __CONTEXT_H__ -#define __CONTEXT_H__ +#ifndef CONTEXT_H +#define CONTEXT_H #include <utils_def.h> @@ -347,4 +347,4 @@ void fpregs_context_restore(fp_regs_t *regs); #endif /* __ASSEMBLY__ */ -#endif /* __CONTEXT_H__ */ +#endif /* CONTEXT_H */ diff --git a/include/lib/el3_runtime/context_mgmt.h b/include/lib/el3_runtime/context_mgmt.h index c5bbb2b4..149ac3ff 100644 --- a/include/lib/el3_runtime/context_mgmt.h +++ b/include/lib/el3_runtime/context_mgmt.h @@ -1,16 +1,15 @@ /* - * Copyright (c) 2013-2017, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ -#ifndef __CM_H__ -#define __CM_H__ +#ifndef CONTEXT_MGMT_H +#define CONTEXT_MGMT_H #include <arch.h> #include <assert.h> #include <context.h> -#include <context_mgmt.h> #include <stdint.h> /******************************************************************************* @@ -80,4 +79,4 @@ void *cm_get_next_context(void); void cm_set_next_context(void *context); #endif /* AARCH32 */ -#endif /* __CM_H__ */ +#endif /* CONTEXT_MGMT_H */ diff --git a/include/lib/el3_runtime/cpu_data.h b/include/lib/el3_runtime/cpu_data.h index b6959509..561f8bee 100644 --- a/include/lib/el3_runtime/cpu_data.h +++ b/include/lib/el3_runtime/cpu_data.h @@ -144,9 +144,9 @@ void init_cpu_data_ptr(void); void init_cpu_ops(void); #define get_cpu_data(_m) _cpu_data()->_m -#define set_cpu_data(_m, _v) _cpu_data()->_m = _v +#define set_cpu_data(_m, _v) _cpu_data()->_m = (_v) #define get_cpu_data_by_index(_ix, _m) _cpu_data_by_index(_ix)->_m -#define set_cpu_data_by_index(_ix, _m, _v) _cpu_data_by_index(_ix)->_m = _v +#define set_cpu_data_by_index(_ix, _m, _v) _cpu_data_by_index(_ix)->_m = (_v) /* ((cpu_data_t *)0)->_m is a dummy to get the sizeof the struct member _m */ #define flush_cpu_data(_m) flush_dcache_range((uintptr_t) \ &(_cpu_data()->_m), \ |