Fix MISRA rule 8.4 in common code
authorRoberto Vargas <roberto.vargas@arm.com>
Mon, 12 Feb 2018 12:36:17 +0000 (12:36 +0000)
committerRoberto Vargas <roberto.vargas@arm.com>
Wed, 28 Feb 2018 17:18:46 +0000 (17:18 +0000)
Rule 8.4: A compatible declaration shall be visible when
          an object or function with external linkage is defined.

Change-Id: I26e042cb251a6f9590afa1340fdac73e42f23979
Signed-off-by: Roberto Vargas <roberto.vargas@arm.com>
28 files changed:
Makefile
bl2/aarch64/bl2_arch_setup.c
bl2/bl2_main.c
bl2/bl2_private.h
bl2u/bl2u_main.c
bl31/bl31_main.c
drivers/arm/gic/common/gic_common_private.h
drivers/arm/gic/v2/gicv2_helpers.c
drivers/arm/gic/v2/gicv2_main.c
drivers/io/io_fip.c
drivers/io/io_memmap.c
drivers/io/io_semihosting.c
include/bl1/bl1.h
include/bl2/bl2.h [new file with mode: 0644]
include/bl2u/bl2u.h [new file with mode: 0644]
include/bl31/bl31.h
include/common/runtime_svc.h
include/lib/cpus/errata_report.h
include/lib/el3_runtime/cpu_data.h
include/lib/el3_runtime/pubsub.h
include/plat/common/platform.h
lib/extensions/spe/spe.c
lib/stdlib/abort.c
lib/stdlib/exit.c
lib/stdlib/sscanf.c
plat/common/plat_bl_common.c
services/arm_arch_svc/arm_arch_svc_setup.c
services/std_svc/std_svc_setup.c

index 87e35e9106ac5a87723a5d7ce4cbd4ea85ee37d3..db15930e8c30abb2fae1accec907d96e61e22a7f 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -200,6 +200,8 @@ BL_COMMON_SOURCES   +=      common/bl_common.c                      \
                                ${STDLIB_SRCS}
 
 INCLUDES               +=      -Iinclude/bl1                           \
+                               -Iinclude/bl2                           \
+                               -Iinclude/bl2u                          \
                                -Iinclude/bl31                          \
                                -Iinclude/common                        \
                                -Iinclude/common/${ARCH}                \
index 038a0758ecbb044fc586719f1d8debf5b525dda7..54052f7d10136ab9124849c9ed75ec04fb491f3f 100644 (file)
@@ -1,11 +1,12 @@
 /*
- * Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
 
 #include <arch.h>
 #include <arch_helpers.h>
+#include "../bl2_private.h"
 
 /*******************************************************************************
  * Place holder function to perform any S-EL1 specific architectural setup. At
index c85db2d4b58f4c5e940ae3a88c1c8418bc14d154..41d17455756e2191707ff8cac581a33c11e48c40 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * 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
  */
@@ -7,6 +7,7 @@
 #include <arch_helpers.h>
 #include <auth_mod.h>
 #include <bl1.h>
+#include <bl2.h>
 #include <bl_common.h>
 #include <console.h>
 #include <debug.h>
index ea2f33aaed8c7f0da4bb9cabaad8402b1e387d9b..50295d674fdf8433af8690481e13d0e00be1aca5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * 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
  */
@@ -17,6 +17,6 @@ struct entry_point_info;
  *****************************************/
 void bl2_arch_setup(void);
 struct entry_point_info *bl2_load_images(void);
-void bl2_run_next_image(const entry_point_info_t *bl_ep_info);
+void bl2_run_next_image(const struct entry_point_info *bl_ep_info);
 
 #endif /* __BL2_PRIVATE_H__ */
index 09ad4683f09d4f29e41e7fdafafcc2e27c5c4e8e..a7e3fb916ef85d3eb50c5aafa36fa43990c96630 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -9,6 +9,7 @@
 #include <assert.h>
 #include <auth_mod.h>
 #include <bl1.h>
+#include <bl2u.h>
 #include <bl_common.h>
 #include <console.h>
 #include <debug.h>
index a34cf86d418b1e8d96688c8b1c0a922439b57f47..0664741242a585c9ea5dd3f2ed96a6bf8a1dfbaf 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * 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
  */
@@ -17,6 +17,7 @@
 #include <pmf.h>
 #include <runtime_instr.h>
 #include <runtime_svc.h>
+#include <std_svc.h>
 #include <string.h>
 
 #if ENABLE_RUNTIME_INSTRUMENTATION
index 2021f9aae9cfd58c5a6d9c98d4e2d2c3e7640447..fa34e477c88702cf01684a25c08a9c4c483e7917 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016-2017, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2016-2018, ARM Limited and Contributors. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -49,6 +49,9 @@ unsigned int gicd_read_icactiver(uintptr_t base, unsigned int id);
 unsigned int gicd_read_ipriorityr(uintptr_t base, unsigned int id);
 unsigned int gicd_read_icfgr(uintptr_t base, unsigned int id);
 unsigned int gicd_read_nsacr(uintptr_t base, unsigned int id);
+unsigned int gicd_read_spendsgir(uintptr_t base, unsigned int id);
+unsigned int gicd_read_cpendsgir(uintptr_t base, unsigned int id);
+unsigned int gicd_read_itargetsr(uintptr_t base, unsigned int id);
 void gicd_write_igroupr(uintptr_t base, unsigned int id, unsigned int val);
 void gicd_write_isenabler(uintptr_t base, unsigned int id, unsigned int val);
 void gicd_write_icenabler(uintptr_t base, unsigned int id, unsigned int val);
@@ -59,6 +62,9 @@ void gicd_write_icactiver(uintptr_t base, unsigned int id, unsigned int val);
 void gicd_write_ipriorityr(uintptr_t base, unsigned int id, unsigned int val);
 void gicd_write_icfgr(uintptr_t base, unsigned int id, unsigned int val);
 void gicd_write_nsacr(uintptr_t base, unsigned int id, unsigned int val);
+void gicd_write_spendsgir(uintptr_t base, unsigned int id, unsigned int val);
+void gicd_write_cpendsgir(uintptr_t base, unsigned int id, unsigned int val);
+void gicd_write_itargetsr(uintptr_t base, unsigned int id, unsigned int val);
 
 /*******************************************************************************
  * GIC Distributor function prototypes for accessing the GIC registers
index 0df50fb008d897eddb83aa488ffa731b625dd80f..421669fc197eb48067a7ff19f91cdcd35a090b77 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -9,6 +9,7 @@
 #include <assert.h>
 #include <debug.h>
 #include <gic_common.h>
+#include <gicv2.h>
 #include <interrupt_props.h>
 #include "../common/gic_common_private.h"
 #include "gicv2_private.h"
index 879865947195d0ce3e0bad7dc74a39e8f986f26a..c65f972d0949d3072cd4b783cbe7dc31d0313a62 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -22,7 +22,7 @@ static const gicv2_driver_data_t *driver_data;
  * spinlock are used either at boot time (when only a single CPU is active), or
  * when the system is fully coherent.
  */
-spinlock_t gic_lock;
+static spinlock_t gic_lock;
 
 /*******************************************************************************
  * Enable secure interrupts and use FIQs to route them. Disable legacy bypass
index a23940d81f9e700cfb7567af02bdcff1d0c9b36c..487f58611751320327cae168413be7a039f25993 100644 (file)
@@ -69,7 +69,7 @@ static inline int is_valid_header(fip_toc_header_t *header)
 
 
 /* Identify the device type as a virtual driver */
-io_type_t device_type_fip(void)
+static io_type_t device_type_fip(void)
 {
        return IO_TYPE_FIRMWARE_IMAGE_PACKAGE;
 }
index b7e26bd4a889c7c301a987dbe5a9faf4e07ea679..bf59d6a5c742cdcf93afb5ff1ac3e00ac9e4030e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014-2017, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2014-2018, ARM Limited and Contributors. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -7,6 +7,7 @@
 #include <assert.h>
 #include <debug.h>
 #include <io_driver.h>
+#include <io_memmap.h>
 #include <io_storage.h>
 #include <string.h>
 #include <utils.h>
@@ -28,7 +29,7 @@ typedef struct {
 static file_state_t current_file = {0};
 
 /* Identify the device type as memmap */
-io_type_t device_type_memmap(void)
+static io_type_t device_type_memmap(void)
 {
        return IO_TYPE_MEMMAP;
 }
index f1dfa208af9ec598f1db9cc5296ff7c4c290aa7b..4abf44f7d2e21b0b4c4a62f5227dd6b033883695 100644 (file)
@@ -1,11 +1,12 @@
 /*
- * Copyright (c) 2014, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2014-2018, ARM Limited and Contributors. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
 
 #include <assert.h>
 #include <io_driver.h>
+#include <io_semihosting.h>
 #include <io_storage.h>
 #include <semihosting.h>
 
index b04210077a3b10a55db6119216897ac8cf19092b..41d436debd5757048936f3f702ec29fb79858282 100644 (file)
 #ifndef __ASSEMBLY__
 #include <cassert.h>
 
+struct entry_point_info;
+
+register_t bl1_smc_wrapper(uint32_t smc_fid,
+       void *cookie,
+       void *handle,
+       unsigned int flags);
+
+register_t bl1_smc_handler(unsigned int smc_fid,
+       register_t x1,
+       register_t x2,
+       register_t x3,
+       register_t x4,
+       void *cookie,
+       void *handle,
+       unsigned int flags);
+
+void bl1_print_next_bl_ep_info(const struct entry_point_info *bl_ep_info);
+
+void bl1_main(void);
+
 /*
  * Check if the total number of FWU SMC calls are as expected.
  */
diff --git a/include/bl2/bl2.h b/include/bl2/bl2.h
new file mode 100644 (file)
index 0000000..89ff06e
--- /dev/null
@@ -0,0 +1,12 @@
+/*
+ * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef BL2_H__
+#define BL2_H__
+
+void bl2_main(void);
+
+#endif /* BL2_H__ */
diff --git a/include/bl2u/bl2u.h b/include/bl2u/bl2u.h
new file mode 100644 (file)
index 0000000..7017b3a
--- /dev/null
@@ -0,0 +1,12 @@
+/*
+ * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef BL2_H__
+#define BL2_H__
+
+void bl2u_main(void);
+
+#endif /* BL2_H__ */
index aac6e2893bbb941bef724a394a78700983937da1..7c35922c3c0243d06479082dcb2749f3815ed4f2 100644 (file)
@@ -18,5 +18,7 @@ uint32_t bl31_get_next_image_type(void);
 void bl31_prepare_next_image_entry(void);
 void bl31_register_bl32_init(int32_t (*func)(void));
 void bl31_warm_entrypoint(void);
+void bl31_main(void);
+void bl31_lib_init(void);
 
 #endif /* __BL31_H__ */
index e179e4bacb8850d7d5144a90d0cfaa8f999a22c5..6150b3227cc3532d7404b7ef2b41c55a40329ea5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013-2016, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -126,5 +126,7 @@ extern uintptr_t __RT_SVC_DESCS_START__;
 extern uintptr_t __RT_SVC_DESCS_END__;
 void init_crash_reporting(void);
 
+extern uint8_t rt_svc_descs_indices[MAX_RT_SVCS];
+
 #endif /*__ASSEMBLY__*/
 #endif /* __RUNTIME_SVC_H__ */
index 14f24073a09ecc86d2364ec0537a3bcecc4af643..d2138bf553617c0da5361e70d22805bb1ce61771 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * 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
  */
@@ -20,6 +20,9 @@ void print_errata_status(void);
 static inline void print_errata_status(void) {}
 #endif
 
+void errata_print_msg(unsigned int status, const char *cpu, const char *id);
+int errata_needs_reporting(spinlock_t *lock, uint32_t *reported);
+
 #endif /* __ASSEMBLY__ */
 
 /* Errata status */
index 3f48de5ef91660c315e2129a321712dce99a9f82..15d34ebf8bf9bae2db469ae1803fc52347ace212 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014-2017, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2014-2018, ARM Limited and Contributors. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -102,6 +102,8 @@ typedef struct cpu_data {
 #endif
 } __aligned(CACHE_WRITEBACK_GRANULE) cpu_data_t;
 
+extern cpu_data_t percpu_data[PLATFORM_CORE_COUNT];
+
 #if CRASH_REPORTING
 /* verify assembler offsets match data structures */
 CASSERT(CPU_DATA_CRASH_BUF_OFFSET == __builtin_offsetof
index 9a854808f6c76a063da7514124d4f3ca05a7f325..2c8a1967e5a4087c54b7a0285de978394ea33810 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * 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
  */
  * Have the function func called back when the specified event happens. This
  * macro places the function address into the pubsub section, which is picked up
  * and invoked by the invoke_pubsubs() function via. the PUBLISH_EVENT* macros.
+ *
+ * The extern declaration is there to satisfy MISRA C-2012 rule 8.4.
  */
 #define SUBSCRIBE_TO_EVENT(event, func) \
-       pubsub_cb_t __cb_func_##func##event __pubsub_section(event) = func
+       extern pubsub_cb_t __cb_func_##func##event __pubsub_section(event); \
+       pubsub_cb_t __cb_func_##func##event __pubsub_section(event) = (func)
 
 /*
  * Iterate over subscribed handlers for a defined event. 'event' is the name of
index e614cdb996016d2fc9155cfda46cb38398242034..aa181c826b4142d9ef1b27cf48872739880a2c46 100644 (file)
@@ -386,12 +386,14 @@ int platform_setup_pm(const plat_pm_ops_t **);
 
 unsigned int plat_get_aff_count(unsigned int, unsigned long);
 unsigned int plat_get_aff_state(unsigned int, unsigned long);
+
 #else /* __ENABLE_PLAT_COMPAT__ */
 /*
  * The below function enable Trusted Firmware components like SPDs which
  * haven't migrated to the new platform API to compile on platforms which
  * have the compatibility layer disabled.
  */
+unsigned int platform_core_pos_helper(unsigned long mpidr);
 unsigned int platform_get_core_pos(unsigned long mpidr) __deprecated;
 
 #endif /* __ENABLE_PLAT_COMPAT__ */
index 3b297f21a20208d29ff7342c36ed2f8d52145ef8..a1ed7b70be72e77752106698bb0ec0bee31e0398 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * 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
  */
@@ -7,6 +7,7 @@
 #include <arch.h>
 #include <arch_helpers.h>
 #include <pubsub.h>
+#include <spe.h>
 
 /*
  * The assembler does not yet understand the psb csync mnemonic
index af19ccfa4feb8ab613fa6307d9be7273f2413a94..65ce4ccaf2c6de26c72a6b78841e2503b884ca64 100644 (file)
@@ -1,10 +1,11 @@
 /*
- * Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
 
 #include <debug.h>
+#include <stdlib.h>
 
 /*
  * This is a basic implementation. This could be improved.
index 3d23d7be5bddf0b4e53266a3954ce98cfb445099..afc3f934390d04ec4c121461a5ace26bdd91e78d 100644 (file)
@@ -1,10 +1,11 @@
 /*
- * Copyright (c) 2015, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
 
 #include <debug.h>
+#include <stdlib.h>
 
 void exit(int v)
 {
index 674ae79f9c9e4f83e1b001749d18b05c05f9c0e9..a5876cff3057c51d9cc0d978f15d1ef12bdfc9ca 100644 (file)
@@ -1,9 +1,10 @@
 /*
- * Copyright (c) 2015, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
 
+#include <stdio.h>
 #include <sys/cdefs.h>
 
 /*
index 502bb540508c3de934e0330135c97a22cffb0012..b471a7e7b5600f1e87dce32426b0c74a486cf0c0 100644 (file)
@@ -36,6 +36,7 @@ void bl2_plat_preload_setup(void)
 {
 }
 
+#if LOAD_IMAGE_V2
 int bl2_plat_handle_pre_image_load(unsigned int image_id)
 {
        return 0;
@@ -45,6 +46,7 @@ int bl2_plat_handle_post_image_load(unsigned int image_id)
 {
        return 0;
 }
+#endif
 
 int plat_try_next_boot_source(void)
 {
index eedac86944250eeb1d9c4c4d03ba9928b815be88..a809c429a047851211ecfde8f6e1201b20bc512a 100644 (file)
@@ -33,7 +33,7 @@ static int32_t smccc_arch_features(u_register_t arg)
 /*
  * Top-level Arm Architectural Service SMC handler.
  */
-uintptr_t arm_arch_svc_smc_handler(uint32_t smc_fid,
+static uintptr_t arm_arch_svc_smc_handler(uint32_t smc_fid,
        u_register_t x1,
        u_register_t x2,
        u_register_t x3,
index ffc34716e6ba7965f4a17d171a1526594f157bd4..eae078ed870dd09d8e4da5df83cda7318a6c4841 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014-2017, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2014-2018, ARM Limited and Contributors. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -58,7 +58,7 @@ static int32_t std_svc_setup(void)
  * Top-level Standard Service SMC handler. This handler will in turn dispatch
  * calls to PSCI SMC handler
  */
-uintptr_t std_svc_smc_handler(uint32_t smc_fid,
+static uintptr_t std_svc_smc_handler(uint32_t smc_fid,
                             u_register_t x1,
                             u_register_t x2,
                             u_register_t x3,