Unverified Commit 74a44dca authored by Dimitris Papastamos's avatar Dimitris Papastamos Committed by GitHub
Browse files

Merge pull request #1399 from danielboulby-arm/db/MISRA

MISRA 5.1, 5.3 & 5.7 compliance changes
parents e109b0ff 776ff52a
...@@ -184,7 +184,7 @@ static void dump_load_info(uintptr_t image_load_addr, ...@@ -184,7 +184,7 @@ static void dump_load_info(uintptr_t image_load_addr,
#endif /* LOAD_IMAGE_V2 */ #endif /* LOAD_IMAGE_V2 */
/* Generic function to return the size of an image */ /* Generic function to return the size of an image */
size_t image_size(unsigned int image_id) size_t get_image_size(unsigned int image_id)
{ {
uintptr_t dev_handle; uintptr_t dev_handle;
uintptr_t image_handle; uintptr_t image_handle;
......
...@@ -15,13 +15,13 @@ ...@@ -15,13 +15,13 @@
* The tf_printf implementation for all BL stages * The tf_printf implementation for all BL stages
***********************************************************/ ***********************************************************/
#define get_num_va_args(args, lcount) \ #define get_num_va_args(_args, _lcount) \
(((lcount) > 1) ? va_arg(args, long long int) : \ (((_lcount) > 1) ? va_arg(_args, long long int) : \
((lcount) ? va_arg(args, long int) : va_arg(args, int))) ((_lcount) ? va_arg(_args, long int) : va_arg(_args, int)))
#define get_unum_va_args(args, lcount) \ #define get_unum_va_args(_args, _lcount) \
(((lcount) > 1) ? va_arg(args, unsigned long long int) : \ (((_lcount) > 1) ? va_arg(_args, unsigned long long int) : \
((lcount) ? va_arg(args, unsigned long int) : va_arg(args, unsigned int))) ((_lcount) ? va_arg(_args, unsigned long int) : va_arg(_args, unsigned int)))
void tf_string_print(const char *str) void tf_string_print(const char *str)
{ {
......
...@@ -342,7 +342,7 @@ void gicv3_rdistif_base_addrs_probe(uintptr_t *rdistif_base_addrs, ...@@ -342,7 +342,7 @@ void gicv3_rdistif_base_addrs_probe(uintptr_t *rdistif_base_addrs,
/******************************************************************************* /*******************************************************************************
* Helper function to configure the default attributes of SPIs. * Helper function to configure the default attributes of SPIs.
******************************************************************************/ ******************************************************************************/
void gicv3_spis_configure_defaults(uintptr_t gicd_base) void gicv3_spis_config_defaults(uintptr_t gicd_base)
{ {
unsigned int index, num_ints; unsigned int index, num_ints;
...@@ -375,7 +375,7 @@ void gicv3_spis_configure_defaults(uintptr_t gicd_base) ...@@ -375,7 +375,7 @@ void gicv3_spis_configure_defaults(uintptr_t gicd_base)
/******************************************************************************* /*******************************************************************************
* Helper function to configure secure G0 and G1S SPIs. * Helper function to configure secure G0 and G1S SPIs.
******************************************************************************/ ******************************************************************************/
void gicv3_secure_spis_configure(uintptr_t gicd_base, void gicv3_secure_spis_config(uintptr_t gicd_base,
unsigned int num_ints, unsigned int num_ints,
const unsigned int *sec_intr_list, const unsigned int *sec_intr_list,
unsigned int int_grp) unsigned int int_grp)
...@@ -423,7 +423,7 @@ void gicv3_secure_spis_configure(uintptr_t gicd_base, ...@@ -423,7 +423,7 @@ void gicv3_secure_spis_configure(uintptr_t gicd_base,
/******************************************************************************* /*******************************************************************************
* Helper function to configure properties of secure SPIs * Helper function to configure properties of secure SPIs
******************************************************************************/ ******************************************************************************/
unsigned int gicv3_secure_spis_configure_props(uintptr_t gicd_base, unsigned int gicv3_secure_spis_config_props(uintptr_t gicd_base,
const interrupt_prop_t *interrupt_props, const interrupt_prop_t *interrupt_props,
unsigned int interrupt_props_num) unsigned int interrupt_props_num)
{ {
...@@ -478,7 +478,7 @@ unsigned int gicv3_secure_spis_configure_props(uintptr_t gicd_base, ...@@ -478,7 +478,7 @@ unsigned int gicv3_secure_spis_configure_props(uintptr_t gicd_base,
/******************************************************************************* /*******************************************************************************
* Helper function to configure the default attributes of SPIs. * Helper function to configure the default attributes of SPIs.
******************************************************************************/ ******************************************************************************/
void gicv3_ppi_sgi_configure_defaults(uintptr_t gicr_base) void gicv3_ppi_sgi_config_defaults(uintptr_t gicr_base)
{ {
unsigned int index; unsigned int index;
...@@ -507,7 +507,7 @@ void gicv3_ppi_sgi_configure_defaults(uintptr_t gicr_base) ...@@ -507,7 +507,7 @@ void gicv3_ppi_sgi_configure_defaults(uintptr_t gicr_base)
/******************************************************************************* /*******************************************************************************
* Helper function to configure secure G0 and G1S SPIs. * Helper function to configure secure G0 and G1S SPIs.
******************************************************************************/ ******************************************************************************/
void gicv3_secure_ppi_sgi_configure(uintptr_t gicr_base, void gicv3_secure_ppi_sgi_config(uintptr_t gicr_base,
unsigned int num_ints, unsigned int num_ints,
const unsigned int *sec_intr_list, const unsigned int *sec_intr_list,
unsigned int int_grp) unsigned int int_grp)
...@@ -546,7 +546,7 @@ void gicv3_secure_ppi_sgi_configure(uintptr_t gicr_base, ...@@ -546,7 +546,7 @@ void gicv3_secure_ppi_sgi_configure(uintptr_t gicr_base,
/******************************************************************************* /*******************************************************************************
* Helper function to configure properties of secure G0 and G1S PPIs and SGIs. * Helper function to configure properties of secure G0 and G1S PPIs and SGIs.
******************************************************************************/ ******************************************************************************/
unsigned int gicv3_secure_ppi_sgi_configure_props(uintptr_t gicr_base, unsigned int gicv3_secure_ppi_sgi_config_props(uintptr_t gicr_base,
const interrupt_prop_t *interrupt_props, const interrupt_prop_t *interrupt_props,
unsigned int interrupt_props_num) unsigned int interrupt_props_num)
{ {
......
...@@ -190,12 +190,12 @@ void gicv3_distif_init(void) ...@@ -190,12 +190,12 @@ void gicv3_distif_init(void)
CTLR_ARE_S_BIT | CTLR_ARE_NS_BIT, RWP_TRUE); CTLR_ARE_S_BIT | CTLR_ARE_NS_BIT, RWP_TRUE);
/* Set the default attribute of all SPIs */ /* Set the default attribute of all SPIs */
gicv3_spis_configure_defaults(gicv3_driver_data->gicd_base); gicv3_spis_config_defaults(gicv3_driver_data->gicd_base);
#if !ERROR_DEPRECATED #if !ERROR_DEPRECATED
if (gicv3_driver_data->interrupt_props != NULL) { if (gicv3_driver_data->interrupt_props != NULL) {
#endif #endif
bitmap = gicv3_secure_spis_configure_props( bitmap = gicv3_secure_spis_config_props(
gicv3_driver_data->gicd_base, gicv3_driver_data->gicd_base,
gicv3_driver_data->interrupt_props, gicv3_driver_data->interrupt_props,
gicv3_driver_data->interrupt_props_num); gicv3_driver_data->interrupt_props_num);
...@@ -213,7 +213,7 @@ void gicv3_distif_init(void) ...@@ -213,7 +213,7 @@ void gicv3_distif_init(void)
/* Configure the G1S SPIs */ /* Configure the G1S SPIs */
if (gicv3_driver_data->g1s_interrupt_array) { if (gicv3_driver_data->g1s_interrupt_array) {
gicv3_secure_spis_configure(gicv3_driver_data->gicd_base, gicv3_secure_spis_config(gicv3_driver_data->gicd_base,
gicv3_driver_data->g1s_interrupt_num, gicv3_driver_data->g1s_interrupt_num,
gicv3_driver_data->g1s_interrupt_array, gicv3_driver_data->g1s_interrupt_array,
INTR_GROUP1S); INTR_GROUP1S);
...@@ -222,7 +222,7 @@ void gicv3_distif_init(void) ...@@ -222,7 +222,7 @@ void gicv3_distif_init(void)
/* Configure the G0 SPIs */ /* Configure the G0 SPIs */
if (gicv3_driver_data->g0_interrupt_array) { if (gicv3_driver_data->g0_interrupt_array) {
gicv3_secure_spis_configure(gicv3_driver_data->gicd_base, gicv3_secure_spis_config(gicv3_driver_data->gicd_base,
gicv3_driver_data->g0_interrupt_num, gicv3_driver_data->g0_interrupt_num,
gicv3_driver_data->g0_interrupt_array, gicv3_driver_data->g0_interrupt_array,
INTR_GROUP0); INTR_GROUP0);
...@@ -263,12 +263,12 @@ void gicv3_rdistif_init(unsigned int proc_num) ...@@ -263,12 +263,12 @@ void gicv3_rdistif_init(unsigned int proc_num)
gicr_base = gicv3_driver_data->rdistif_base_addrs[proc_num]; gicr_base = gicv3_driver_data->rdistif_base_addrs[proc_num];
/* Set the default attribute of all SGIs and PPIs */ /* Set the default attribute of all SGIs and PPIs */
gicv3_ppi_sgi_configure_defaults(gicr_base); gicv3_ppi_sgi_config_defaults(gicr_base);
#if !ERROR_DEPRECATED #if !ERROR_DEPRECATED
if (gicv3_driver_data->interrupt_props != NULL) { if (gicv3_driver_data->interrupt_props != NULL) {
#endif #endif
bitmap = gicv3_secure_ppi_sgi_configure_props(gicr_base, bitmap = gicv3_secure_ppi_sgi_config_props(gicr_base,
gicv3_driver_data->interrupt_props, gicv3_driver_data->interrupt_props,
gicv3_driver_data->interrupt_props_num); gicv3_driver_data->interrupt_props_num);
#if !ERROR_DEPRECATED #if !ERROR_DEPRECATED
...@@ -285,7 +285,7 @@ void gicv3_rdistif_init(unsigned int proc_num) ...@@ -285,7 +285,7 @@ void gicv3_rdistif_init(unsigned int proc_num)
/* Configure the G1S SGIs/PPIs */ /* Configure the G1S SGIs/PPIs */
if (gicv3_driver_data->g1s_interrupt_array) { if (gicv3_driver_data->g1s_interrupt_array) {
gicv3_secure_ppi_sgi_configure(gicr_base, gicv3_secure_ppi_sgi_config(gicr_base,
gicv3_driver_data->g1s_interrupt_num, gicv3_driver_data->g1s_interrupt_num,
gicv3_driver_data->g1s_interrupt_array, gicv3_driver_data->g1s_interrupt_array,
INTR_GROUP1S); INTR_GROUP1S);
...@@ -294,7 +294,7 @@ void gicv3_rdistif_init(unsigned int proc_num) ...@@ -294,7 +294,7 @@ void gicv3_rdistif_init(unsigned int proc_num)
/* Configure the G0 SGIs/PPIs */ /* Configure the G0 SGIs/PPIs */
if (gicv3_driver_data->g0_interrupt_array) { if (gicv3_driver_data->g0_interrupt_array) {
gicv3_secure_ppi_sgi_configure(gicr_base, gicv3_secure_ppi_sgi_config(gicr_base,
gicv3_driver_data->g0_interrupt_num, gicv3_driver_data->g0_interrupt_num,
gicv3_driver_data->g0_interrupt_array, gicv3_driver_data->g0_interrupt_array,
INTR_GROUP0); INTR_GROUP0);
......
...@@ -27,20 +27,20 @@ ...@@ -27,20 +27,20 @@
* GICD_IROUTER. Bits[31:24] in the MPIDR are cleared as they are not relevant * GICD_IROUTER. Bits[31:24] in the MPIDR are cleared as they are not relevant
* to GICv3. * to GICv3.
*/ */
#define gicd_irouter_val_from_mpidr(mpidr, irm) \ #define gicd_irouter_val_from_mpidr(_mpidr, _irm) \
((mpidr & ~(0xff << 24)) | \ ((_mpidr & ~(0xff << 24)) | \
(irm & IROUTER_IRM_MASK) << IROUTER_IRM_SHIFT) (_irm & IROUTER_IRM_MASK) << IROUTER_IRM_SHIFT)
/* /*
* Macro to convert a GICR_TYPER affinity value into a MPIDR value. Bits[31:24] * Macro to convert a GICR_TYPER affinity value into a MPIDR value. Bits[31:24]
* are zeroes. * are zeroes.
*/ */
#ifdef AARCH32 #ifdef AARCH32
#define mpidr_from_gicr_typer(typer_val) (((typer_val) >> 32) & 0xffffff) #define mpidr_from_gicr_typer(_typer_val) (((_typer_val) >> 32) & 0xffffff)
#else #else
#define mpidr_from_gicr_typer(typer_val) \ #define mpidr_from_gicr_typer(_typer_val) \
(((((typer_val) >> 56) & MPIDR_AFFLVL_MASK) << MPIDR_AFF3_SHIFT) | \ (((((_typer_val) >> 56) & MPIDR_AFFLVL_MASK) << MPIDR_AFF3_SHIFT) | \
(((typer_val) >> 32) & 0xffffff)) (((_typer_val) >> 32) & 0xffffff))
#endif #endif
/******************************************************************************* /*******************************************************************************
...@@ -85,22 +85,22 @@ void gicr_set_icfgr1(uintptr_t base, unsigned int id, unsigned int cfg); ...@@ -85,22 +85,22 @@ void gicr_set_icfgr1(uintptr_t base, unsigned int id, unsigned int cfg);
/******************************************************************************* /*******************************************************************************
* Private GICv3 helper function prototypes * Private GICv3 helper function prototypes
******************************************************************************/ ******************************************************************************/
void gicv3_spis_configure_defaults(uintptr_t gicd_base); void gicv3_spis_config_defaults(uintptr_t gicd_base);
void gicv3_ppi_sgi_configure_defaults(uintptr_t gicr_base); void gicv3_ppi_sgi_config_defaults(uintptr_t gicr_base);
#if !ERROR_DEPRECATED #if !ERROR_DEPRECATED
void gicv3_secure_spis_configure(uintptr_t gicd_base, void gicv3_secure_spis_config(uintptr_t gicd_base,
unsigned int num_ints, unsigned int num_ints,
const unsigned int *sec_intr_list, const unsigned int *sec_intr_list,
unsigned int int_grp); unsigned int int_grp);
void gicv3_secure_ppi_sgi_configure(uintptr_t gicr_base, void gicv3_secure_ppi_sgi_config(uintptr_t gicr_base,
unsigned int num_ints, unsigned int num_ints,
const unsigned int *sec_intr_list, const unsigned int *sec_intr_list,
unsigned int int_grp); unsigned int int_grp);
#endif #endif
unsigned int gicv3_secure_ppi_sgi_configure_props(uintptr_t gicr_base, unsigned int gicv3_secure_ppi_sgi_config_props(uintptr_t gicr_base,
const interrupt_prop_t *interrupt_props, const interrupt_prop_t *interrupt_props,
unsigned int interrupt_props_num); unsigned int interrupt_props_num);
unsigned int gicv3_secure_spis_configure_props(uintptr_t gicd_base, unsigned int gicv3_secure_spis_config_props(uintptr_t gicd_base,
const interrupt_prop_t *interrupt_props, const interrupt_prop_t *interrupt_props,
unsigned int interrupt_props_num); unsigned int interrupt_props_num);
void gicv3_rdistif_base_addrs_probe(uintptr_t *rdistif_base_addrs, void gicv3_rdistif_base_addrs_probe(uintptr_t *rdistif_base_addrs,
......
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
#include <smmu_v3.h> #include <smmu_v3.h>
/* Test for pending invalidate */ /* Test for pending invalidate */
#define INVAL_PENDING(base) \ #define INVAL_PENDING(_base) \
smmuv3_read_s_init(base) & SMMU_S_INIT_INV_ALL_MASK smmuv3_read_s_init(_base) & SMMU_S_INIT_INV_ALL_MASK
static inline uint32_t smmuv3_read_s_idr1(uintptr_t base) static inline uint32_t smmuv3_read_s_idr1(uintptr_t base)
{ {
......
...@@ -54,7 +54,7 @@ static inline void _tzc400_write_gate_keeper(uintptr_t base, unsigned int val) ...@@ -54,7 +54,7 @@ static inline void _tzc400_write_gate_keeper(uintptr_t base, unsigned int val)
/* /*
* Get the open status information for all filter units. * Get the open status information for all filter units.
*/ */
#define get_gate_keeper_os(base) ((_tzc400_read_gate_keeper(base) >> \ #define get_gate_keeper_os(_base) ((_tzc400_read_gate_keeper(_base) >> \
GATE_KEEPER_OS_SHIFT) & \ GATE_KEEPER_OS_SHIFT) & \
GATE_KEEPER_OS_MASK) GATE_KEEPER_OS_MASK)
......
...@@ -207,7 +207,7 @@ typedef struct bl31_params { ...@@ -207,7 +207,7 @@ typedef struct bl31_params {
/******************************************************************************* /*******************************************************************************
* Function & variable prototypes * Function & variable prototypes
******************************************************************************/ ******************************************************************************/
size_t image_size(unsigned int image_id); size_t get_image_size(unsigned int image_id);
int is_mem_free(uintptr_t free_base, size_t free_size, int is_mem_free(uintptr_t free_base, size_t free_size,
uintptr_t addr, size_t size); uintptr_t addr, size_t size);
......
/* /*
* Copyright (c) 2017, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved.
* *
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
* valid. Therefore, the caller is expected to check it is the case using the * valid. Therefore, the caller is expected to check it is the case using the
* CHECK_VIRT_ADDR_SPACE_SIZE() macro first. * CHECK_VIRT_ADDR_SPACE_SIZE() macro first.
*/ */
#define GET_XLAT_TABLE_LEVEL_BASE(virt_addr_space_size) \ #define GET_XLAT_TABLE_LEVEL_BASE(_virt_addr_space_size) \
(((virt_addr_space_size) > (ULL(1) << L1_XLAT_ADDRESS_SHIFT)) ? 1 : 2) (((_virt_addr_space_size) > (ULL(1) << L1_XLAT_ADDRESS_SHIFT)) ? 1 : 2)
#endif /* __XLAT_TABLES_AARCH32_H__ */ #endif /* __XLAT_TABLES_AARCH32_H__ */
/* /*
* Copyright (c) 2017, ARM Limited and Contributors. All rights reserved. * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved.
* *
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
...@@ -74,10 +74,10 @@ unsigned long long tcr_physical_addr_size_bits(unsigned long long max_addr); ...@@ -74,10 +74,10 @@ unsigned long long tcr_physical_addr_size_bits(unsigned long long max_addr);
* valid. Therefore, the caller is expected to check it is the case using the * valid. Therefore, the caller is expected to check it is the case using the
* CHECK_VIRT_ADDR_SPACE_SIZE() macro first. * CHECK_VIRT_ADDR_SPACE_SIZE() macro first.
*/ */
#define GET_XLAT_TABLE_LEVEL_BASE(virt_addr_space_size) \ #define GET_XLAT_TABLE_LEVEL_BASE(_virt_addr_space_size) \
(((virt_addr_space_size) > (ULL(1) << L0_XLAT_ADDRESS_SHIFT)) \ (((_virt_addr_space_size) > (ULL(1) << L0_XLAT_ADDRESS_SHIFT)) \
? 0 \ ? 0 \
: (((virt_addr_space_size) > (ULL(1) << L1_XLAT_ADDRESS_SHIFT)) \ : (((_virt_addr_space_size) > (ULL(1) << L1_XLAT_ADDRESS_SHIFT)) \
? 1 : 2)) ? 1 : 2))
#endif /* __XLAT_TABLES_AARCH64_H__ */ #endif /* __XLAT_TABLES_AARCH64_H__ */
...@@ -10,12 +10,12 @@ ...@@ -10,12 +10,12 @@
#define CPUAMU_NR_COUNTERS 5U #define CPUAMU_NR_COUNTERS 5U
struct amu_ctx { struct cpuamu_ctx {
uint64_t cnts[CPUAMU_NR_COUNTERS]; uint64_t cnts[CPUAMU_NR_COUNTERS];
unsigned int mask; unsigned int mask;
}; };
static struct amu_ctx amu_ctxs[PLATFORM_CORE_COUNT]; static struct cpuamu_ctx cpuamu_ctxs[PLATFORM_CORE_COUNT];
int midr_match(unsigned int cpu_midr) int midr_match(unsigned int cpu_midr)
{ {
...@@ -29,7 +29,7 @@ int midr_match(unsigned int cpu_midr) ...@@ -29,7 +29,7 @@ int midr_match(unsigned int cpu_midr)
void cpuamu_context_save(unsigned int nr_counters) void cpuamu_context_save(unsigned int nr_counters)
{ {
struct amu_ctx *ctx = &amu_ctxs[plat_my_core_pos()]; struct cpuamu_ctx *ctx = &cpuamu_ctxs[plat_my_core_pos()];
unsigned int i; unsigned int i;
assert(nr_counters <= CPUAMU_NR_COUNTERS); assert(nr_counters <= CPUAMU_NR_COUNTERS);
...@@ -48,7 +48,7 @@ void cpuamu_context_save(unsigned int nr_counters) ...@@ -48,7 +48,7 @@ void cpuamu_context_save(unsigned int nr_counters)
void cpuamu_context_restore(unsigned int nr_counters) void cpuamu_context_restore(unsigned int nr_counters)
{ {
struct amu_ctx *ctx = &amu_ctxs[plat_my_core_pos()]; struct cpuamu_ctx *ctx = &cpuamu_ctxs[plat_my_core_pos()];
unsigned int i; unsigned int i;
assert(nr_counters <= CPUAMU_NR_COUNTERS); assert(nr_counters <= CPUAMU_NR_COUNTERS);
......
...@@ -34,9 +34,9 @@ ...@@ -34,9 +34,9 @@
* accesses regardless of status of address translation. * accesses regardless of status of address translation.
*/ */
#define assert_bakery_entry_valid(entry, bakery) do { \ #define assert_bakery_entry_valid(_entry, _bakery) do { \
assert(bakery); \ assert(_bakery); \
assert(entry < BAKERY_LOCK_MAX_CPUS); \ assert(_entry < BAKERY_LOCK_MAX_CPUS); \
} while (0) } while (0)
/* Obtain a ticket for a given CPU */ /* Obtain a ticket for a given CPU */
......
...@@ -53,18 +53,18 @@ CASSERT((PLAT_PERCPU_BAKERY_LOCK_SIZE & (CACHE_WRITEBACK_GRANULE - 1)) == 0, \ ...@@ -53,18 +53,18 @@ CASSERT((PLAT_PERCPU_BAKERY_LOCK_SIZE & (CACHE_WRITEBACK_GRANULE - 1)) == 0, \
IMPORT_SYM(uintptr_t, __PERCPU_BAKERY_LOCK_SIZE__, PERCPU_BAKERY_LOCK_SIZE); IMPORT_SYM(uintptr_t, __PERCPU_BAKERY_LOCK_SIZE__, PERCPU_BAKERY_LOCK_SIZE);
#endif #endif
#define get_bakery_info(cpu_ix, lock) \ #define get_bakery_info(_cpu_ix, _lock) \
(bakery_info_t *)((uintptr_t)lock + cpu_ix * PERCPU_BAKERY_LOCK_SIZE) (bakery_info_t *)((uintptr_t)_lock + _cpu_ix * PERCPU_BAKERY_LOCK_SIZE)
#define write_cache_op(addr, cached) \ #define write_cache_op(_addr, _cached) \
do { \ do { \
(cached ? dccvac((uintptr_t)addr) :\ (_cached ? dccvac((uintptr_t)_addr) :\
dcivac((uintptr_t)addr));\ dcivac((uintptr_t)_addr));\
dsbish();\ dsbish();\
} while (0) } while (0)
#define read_cache_op(addr, cached) if (cached) \ #define read_cache_op(_addr, _cached) if (_cached) \
dccivac((uintptr_t)addr) dccivac((uintptr_t)_addr)
/* Helper function to check if the lock is acquired */ /* Helper function to check if the lock is acquired */
static inline int is_lock_acquired(const bakery_info_t *my_bakery_info, static inline int is_lock_acquired(const bakery_info_t *my_bakery_info,
......
...@@ -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
......
...@@ -65,8 +65,8 @@ ...@@ -65,8 +65,8 @@
#endif #endif
#define psci_lock_init(non_cpu_pd_node, idx) \ #define psci_lock_init(_non_cpu_pd_node, _idx) \
((non_cpu_pd_node)[(idx)].lock_index = (idx)) ((_non_cpu_pd_node)[(_idx)].lock_index = (_idx))
/* /*
* The PSCI capability which are provided by the generic code but does not * The PSCI capability which are provided by the generic code but does not
...@@ -96,35 +96,35 @@ ...@@ -96,35 +96,35 @@
/* /*
* Helper macros to get/set the fields of PSCI per-cpu data. * Helper macros to get/set the fields of PSCI per-cpu data.
*/ */
#define psci_set_aff_info_state(aff_state) \ #define psci_set_aff_info_state(_aff_state) \
set_cpu_data(psci_svc_cpu_data.aff_info_state, aff_state) set_cpu_data(psci_svc_cpu_data.aff_info_state, _aff_state)
#define psci_get_aff_info_state() \ #define psci_get_aff_info_state() \
get_cpu_data(psci_svc_cpu_data.aff_info_state) get_cpu_data(psci_svc_cpu_data.aff_info_state)
#define psci_get_aff_info_state_by_idx(idx) \ #define psci_get_aff_info_state_by_idx(_idx) \
get_cpu_data_by_index(idx, psci_svc_cpu_data.aff_info_state) get_cpu_data_by_index(_idx, psci_svc_cpu_data.aff_info_state)
#define psci_set_aff_info_state_by_idx(idx, aff_state) \ #define psci_set_aff_info_state_by_idx(_idx, _aff_state) \
set_cpu_data_by_index(idx, psci_svc_cpu_data.aff_info_state,\ set_cpu_data_by_index(_idx, psci_svc_cpu_data.aff_info_state,\
aff_state) _aff_state)
#define psci_get_suspend_pwrlvl() \ #define psci_get_suspend_pwrlvl() \
get_cpu_data(psci_svc_cpu_data.target_pwrlvl) get_cpu_data(psci_svc_cpu_data.target_pwrlvl)
#define psci_set_suspend_pwrlvl(target_lvl) \ #define psci_set_suspend_pwrlvl(_target_lvl) \
set_cpu_data(psci_svc_cpu_data.target_pwrlvl, target_lvl) set_cpu_data(psci_svc_cpu_data.target_pwrlvl, _target_lvl)
#define psci_set_cpu_local_state(state) \ #define psci_set_cpu_local_state(_state) \
set_cpu_data(psci_svc_cpu_data.local_state, state) set_cpu_data(psci_svc_cpu_data.local_state, _state)
#define psci_get_cpu_local_state() \ #define psci_get_cpu_local_state() \
get_cpu_data(psci_svc_cpu_data.local_state) get_cpu_data(psci_svc_cpu_data.local_state)
#define psci_get_cpu_local_state_by_idx(idx) \ #define psci_get_cpu_local_state_by_idx(_idx) \
get_cpu_data_by_index(idx, psci_svc_cpu_data.local_state) get_cpu_data_by_index(_idx, psci_svc_cpu_data.local_state)
/* /*
* Helper macros for the CPU level spinlocks * Helper macros for the CPU level spinlocks
*/ */
#define psci_spin_lock_cpu(idx) spin_lock(&psci_cpu_pd_nodes[idx].cpu_lock) #define psci_spin_lock_cpu(_idx) spin_lock(&psci_cpu_pd_nodes[_idx].cpu_lock)
#define psci_spin_unlock_cpu(idx) spin_unlock(&psci_cpu_pd_nodes[idx].cpu_lock) #define psci_spin_unlock_cpu(_idx) spin_unlock(&psci_cpu_pd_nodes[_idx].cpu_lock)
/* Helper macro to identify a CPU standby request in PSCI Suspend call */ /* Helper macro to identify a CPU standby request in PSCI Suspend call */
#define is_cpu_standby_req(is_power_down_state, retn_lvl) \ #define is_cpu_standby_req(_is_power_down_state, _retn_lvl) \
(((!(is_power_down_state)) && ((retn_lvl) == 0)) ? 1 : 0) (((!(_is_power_down_state)) && ((_retn_lvl) == 0)) ? 1 : 0)
/******************************************************************************* /*******************************************************************************
* The following two data structures implement the power domain tree. The tree * The following two data structures implement the power domain tree. The tree
......
...@@ -18,8 +18,8 @@ ...@@ -18,8 +18,8 @@
#define MHU_V2_ACCESS_REQ_OFFSET 0xF88 #define MHU_V2_ACCESS_REQ_OFFSET 0xF88
#define MHU_V2_ACCESS_READY_OFFSET 0xF8C #define MHU_V2_ACCESS_READY_OFFSET 0xF8C
#define SENDER_REG_STAT(CHANNEL) (0x20 * (CHANNEL)) #define SENDER_REG_STAT(_channel) (0x20 * (_channel))
#define SENDER_REG_SET(CHANNEL) (0x20 * (CHANNEL)) + 0xC #define SENDER_REG_SET(_channel) ((0x20 * (_channel)) + 0xC)
/* Helper macro to ring doorbell */ /* Helper macro to ring doorbell */
#define MHU_RING_DOORBELL(addr, modify_mask, preserve_mask) do { \ #define MHU_RING_DOORBELL(addr, modify_mask, preserve_mask) do { \
......
...@@ -60,14 +60,14 @@ ...@@ -60,14 +60,14 @@
* Helper macro to create an SCMI message header given protocol, message id * Helper macro to create an SCMI message header given protocol, message id
* and token. * and token.
*/ */
#define SCMI_MSG_CREATE(protocol, msg_id, token) \ #define SCMI_MSG_CREATE(_protocol, _msg_id, _token) \
((((protocol) & SCMI_MSG_PROTO_ID_MASK) << SCMI_MSG_PROTO_ID_SHIFT) | \ ((((_protocol) & SCMI_MSG_PROTO_ID_MASK) << SCMI_MSG_PROTO_ID_SHIFT) | \
(((msg_id) & SCMI_MSG_ID_MASK) << SCMI_MSG_ID_SHIFT) | \ (((_msg_id) & SCMI_MSG_ID_MASK) << SCMI_MSG_ID_SHIFT) | \
(((token) & SCMI_MSG_TOKEN_MASK) << SCMI_MSG_TOKEN_SHIFT)) (((_token) & SCMI_MSG_TOKEN_MASK) << SCMI_MSG_TOKEN_SHIFT))
/* Helper macro to get the token from a SCMI message header */ /* Helper macro to get the token from a SCMI message header */
#define SCMI_MSG_GET_TOKEN(msg) \ #define SCMI_MSG_GET_TOKEN(_msg) \
(((msg) >> SCMI_MSG_TOKEN_SHIFT) & SCMI_MSG_TOKEN_MASK) (((_msg) >> SCMI_MSG_TOKEN_SHIFT) & SCMI_MSG_TOKEN_MASK)
/* SCMI Channel Status bit fields */ /* SCMI Channel Status bit fields */
#define SCMI_CH_STATUS_RES0_MASK 0xFFFFFFFE #define SCMI_CH_STATUS_RES0_MASK 0xFFFFFFFE
......
...@@ -36,21 +36,21 @@ ...@@ -36,21 +36,21 @@
#define SCMI_PWR_STATE_MAX_PWR_LVL_WIDTH 4 #define SCMI_PWR_STATE_MAX_PWR_LVL_WIDTH 4
#define SCMI_PWR_STATE_MAX_PWR_LVL_MASK \ #define SCMI_PWR_STATE_MAX_PWR_LVL_MASK \
((1 << SCMI_PWR_STATE_MAX_PWR_LVL_WIDTH) - 1) ((1 << SCMI_PWR_STATE_MAX_PWR_LVL_WIDTH) - 1)
#define SCMI_SET_PWR_STATE_MAX_PWR_LVL(pwr_state, max_lvl) \ #define SCMI_SET_PWR_STATE_MAX_PWR_LVL(_power_state, _max_level) \
(pwr_state) |= ((max_lvl) & SCMI_PWR_STATE_MAX_PWR_LVL_MASK) \ (_power_state) |= ((_max_level) & SCMI_PWR_STATE_MAX_PWR_LVL_MASK)\
<< SCMI_PWR_STATE_MAX_PWR_LVL_SHIFT << SCMI_PWR_STATE_MAX_PWR_LVL_SHIFT
#define SCMI_GET_PWR_STATE_MAX_PWR_LVL(pwr_state) \ #define SCMI_GET_PWR_STATE_MAX_PWR_LVL(_power_state) \
(((pwr_state) >> SCMI_PWR_STATE_MAX_PWR_LVL_SHIFT) \ (((_power_state) >> SCMI_PWR_STATE_MAX_PWR_LVL_SHIFT) \
& SCMI_PWR_STATE_MAX_PWR_LVL_MASK) & SCMI_PWR_STATE_MAX_PWR_LVL_MASK)
#define SCMI_PWR_STATE_LVL_WIDTH 4 #define SCMI_PWR_STATE_LVL_WIDTH 4
#define SCMI_PWR_STATE_LVL_MASK \ #define SCMI_PWR_STATE_LVL_MASK \
((1 << SCMI_PWR_STATE_LVL_WIDTH) - 1) ((1 << SCMI_PWR_STATE_LVL_WIDTH) - 1)
#define SCMI_SET_PWR_STATE_LVL(pwr_state, lvl, lvl_state) \ #define SCMI_SET_PWR_STATE_LVL(_power_state, _level, _level_state) \
(pwr_state) |= ((lvl_state) & SCMI_PWR_STATE_LVL_MASK) \ (_power_state) |= ((_level_state) & SCMI_PWR_STATE_LVL_MASK) \
<< (SCMI_PWR_STATE_LVL_WIDTH * (lvl)) << (SCMI_PWR_STATE_LVL_WIDTH * (_level))
#define SCMI_GET_PWR_STATE_LVL(pwr_state, lvl) \ #define SCMI_GET_PWR_STATE_LVL(_power_state, _level) \
(((pwr_state) >> (SCMI_PWR_STATE_LVL_WIDTH * (lvl))) & \ (((_power_state) >> (SCMI_PWR_STATE_LVL_WIDTH * (_level))) & \
SCMI_PWR_STATE_LVL_MASK) SCMI_PWR_STATE_LVL_MASK)
/* /*
...@@ -69,7 +69,7 @@ typedef enum { ...@@ -69,7 +69,7 @@ typedef enum {
static void *scmi_handle; static void *scmi_handle;
/* The SCMI channel global object */ /* The SCMI channel global object */
static scmi_channel_t scmi_channel; static scmi_channel_t channel;
ARM_INSTANTIATE_LOCK; ARM_INSTANTIATE_LOCK;
...@@ -308,9 +308,9 @@ scmi_channel_plat_info_t plat_css_scmi_plat_info = { ...@@ -308,9 +308,9 @@ scmi_channel_plat_info_t plat_css_scmi_plat_info = {
void plat_arm_pwrc_setup(void) void plat_arm_pwrc_setup(void)
{ {
scmi_channel.info = &plat_css_scmi_plat_info; channel.info = &plat_css_scmi_plat_info;
scmi_channel.lock = ARM_LOCK_GET_INSTANCE; channel.lock = ARM_LOCK_GET_INSTANCE;
scmi_handle = scmi_init(&scmi_channel); scmi_handle = scmi_init(&channel);
if (scmi_handle == NULL) { if (scmi_handle == NULL) {
ERROR("SCMI Initialization failed\n"); ERROR("SCMI Initialization failed\n");
panic(); panic();
......
...@@ -67,18 +67,18 @@ typedef struct structure_header { ...@@ -67,18 +67,18 @@ typedef struct structure_header {
uint32_t reg[2]; uint32_t reg[2];
} struct_header_t; } struct_header_t;
#define GET_SDS_HEADER_ID(header) \ #define GET_SDS_HEADER_ID(_header) \
((((struct_header_t *)(header))->reg[0]) & SDS_HEADER_ID_MASK) ((((struct_header_t *)(_header))->reg[0]) & SDS_HEADER_ID_MASK)
#define GET_SDS_HEADER_VERSION(header) \ #define GET_SDS_HEADER_VERSION(_header) \
(((((struct_header_t *)(header))->reg[0]) >> SDS_HEADER_MINOR_VERSION_SHIFT)\ (((((struct_header_t *)(_header))->reg[0]) >> SDS_HEADER_MINOR_VERSION_SHIFT)\
& SDS_HEADER_VERSION_MASK) & SDS_HEADER_VERSION_MASK)
#define GET_SDS_HEADER_STRUCT_SIZE(header) \ #define GET_SDS_HEADER_STRUCT_SIZE(_header) \
(((((struct_header_t *)(header))->reg[1]) >> SDS_HEADER_STRUCT_SIZE_SHIFT)\ (((((struct_header_t *)(_header))->reg[1]) >> SDS_HEADER_STRUCT_SIZE_SHIFT)\
& SDS_HEADER_STRUCT_SIZE_MASK) & SDS_HEADER_STRUCT_SIZE_MASK)
#define IS_SDS_HEADER_VALID(header) \ #define IS_SDS_HEADER_VALID(_header) \
((((struct_header_t *)(header))->reg[1]) & SDS_HEADER_VALID_MASK) ((((struct_header_t *)(_header))->reg[1]) & SDS_HEADER_VALID_MASK)
#define GET_SDS_STRUCT_FIELD(header, field_offset) \ #define GET_SDS_STRUCT_FIELD(_header, _field_offset) \
((((uint8_t *)(header)) + sizeof(struct_header_t)) + (field_offset)) ((((uint8_t *)(_header)) + sizeof(struct_header_t)) + (_field_offset))
/* Region Descriptor describing the SDS Memory Region */ /* Region Descriptor describing the SDS Memory Region */
typedef struct region_descriptor { typedef struct region_descriptor {
......
...@@ -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);
/* /*
......
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