Commit 97043ac9 authored by Dan Handley's avatar Dan Handley
Browse files

Reduce deep nesting of header files

Reduce the number of header files included from other header
files as much as possible without splitting the files. Use forward
declarations where possible. This allows removal of some unnecessary
"#ifndef __ASSEMBLY__" statements.

Also, review the .c and .S files for which header files really need
including and reorder the #include statements alphabetically.

Fixes ARM-software/tf-issues#31

Change-Id: Iec92fb976334c77453e010b60bcf56f3be72bd3e
parent fb037bfb
...@@ -28,9 +28,9 @@ ...@@ -28,9 +28,9 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <assert.h>
#include <platform.h> #include <platform.h>
#include <pl011.h> #include <pl011.h>
#include <assert.h>
void pl011_setbaudrate(unsigned long base_addr, unsigned int baudrate) void pl011_setbaudrate(unsigned long base_addr, unsigned int baudrate)
{ {
......
...@@ -28,10 +28,10 @@ ...@@ -28,10 +28,10 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <assert.h>
#include <console.h> #include <console.h>
#include <platform.h> #include <platform.h>
#include <pl011.h> #include <pl011.h>
#include <assert.h>
static unsigned long uart_base; static unsigned long uart_base;
......
...@@ -29,10 +29,10 @@ ...@@ -29,10 +29,10 @@
*/ */
#include <assert.h> #include <assert.h>
#include <arch_helpers.h>
#include <tzc400.h>
#include <mmio.h>
#include <debug.h> #include <debug.h>
#include <mmio.h>
#include <stddef.h>
#include <tzc400.h>
static uint32_t tzc_read_build_config(uint64_t base) static uint32_t tzc_read_build_config(uint64_t base)
{ {
......
...@@ -28,17 +28,17 @@ ...@@ -28,17 +28,17 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <stdint.h>
#include <uuid.h>
#include <errno.h>
#include <string.h>
#include <assert.h> #include <assert.h>
#include <platform.h> #include <debug.h>
#include <errno.h>
#include <firmware_image_package.h> #include <firmware_image_package.h>
#include <io_storage.h>
#include <io_driver.h> #include <io_driver.h>
#include <io_fip.h> #include <io_fip.h>
#include <debug.h> #include <io_storage.h>
#include <platform.h>
#include <stdint.h>
#include <string.h>
#include <uuid.h>
/* Useful for printing UUIDs when debugging.*/ /* Useful for printing UUIDs when debugging.*/
#define PRINT_UUID2(x) \ #define PRINT_UUID2(x) \
......
...@@ -29,10 +29,10 @@ ...@@ -29,10 +29,10 @@
*/ */
#include <assert.h> #include <assert.h>
#include <string.h>
#include <io_storage.h>
#include <io_driver.h>
#include <debug.h> #include <debug.h>
#include <io_driver.h>
#include <io_storage.h>
#include <string.h>
/* As we need to be able to keep state for seek, only one file can be open /* As we need to be able to keep state for seek, only one file can be open
* at a time. Make this a structure and point to the entity->info. When we * at a time. Make this a structure and point to the entity->info. When we
......
...@@ -29,8 +29,8 @@ ...@@ -29,8 +29,8 @@
*/ */
#include <assert.h> #include <assert.h>
#include <io_storage.h>
#include <io_driver.h> #include <io_driver.h>
#include <io_storage.h>
#include <semihosting.h> #include <semihosting.h>
......
...@@ -31,16 +31,16 @@ ...@@ -31,16 +31,16 @@
#ifndef __BL1_H__ #ifndef __BL1_H__
#define __BL1_H__ #define __BL1_H__
#include <bl_common.h>
#ifndef __ASSEMBLY__ /******************************************
* Forward declarations
*****************************************/
struct meminfo;
/****************************************** /******************************************
* Function prototypes * Function prototypes
*****************************************/ *****************************************/
extern void bl1_platform_setup(void); extern void bl1_platform_setup(void);
extern meminfo_t *bl1_plat_sec_mem_layout(void); extern struct meminfo *bl1_plat_sec_mem_layout(void);
#endif /*__ASSEMBLY__*/
#endif /* __BL1_H__ */ #endif /* __BL1_H__ */
...@@ -31,18 +31,22 @@ ...@@ -31,18 +31,22 @@
#ifndef __BL2_H__ #ifndef __BL2_H__
#define __BL2_H__ #define __BL2_H__
#include <bl_common.h>
/****************************************** /******************************************
* Data declarations * Data declarations
*****************************************/ *****************************************/
extern unsigned long long bl2_entrypoint; extern unsigned long long bl2_entrypoint;
/******************************************
* Forward declarations
*****************************************/
struct meminfo;
struct bl31_args;
/****************************************** /******************************************
* Function prototypes * Function prototypes
*****************************************/ *****************************************/
extern void bl2_platform_setup(void); extern void bl2_platform_setup(void);
extern meminfo_t *bl2_plat_sec_mem_layout(void); extern struct meminfo *bl2_plat_sec_mem_layout(void);
extern bl31_args_t *bl2_get_bl31_args_ptr(void); extern struct bl31_args *bl2_get_bl31_args_ptr(void);
#endif /* __BL2_H__ */ #endif /* __BL2_H__ */
...@@ -31,13 +31,19 @@ ...@@ -31,13 +31,19 @@
#ifndef __BL31_H__ #ifndef __BL31_H__
#define __BL31_H__ #define __BL31_H__
#include <bl_common.h> #include <stdint.h>
/******************************************************************************* /*******************************************************************************
* Data declarations * Data declarations
******************************************************************************/ ******************************************************************************/
extern unsigned long bl31_entrypoint; extern unsigned long bl31_entrypoint;
/******************************************
* Forward declarations
*****************************************/
struct meminfo;
struct el_change_info;
/******************************************************************************* /*******************************************************************************
* Function prototypes * Function prototypes
******************************************************************************/ ******************************************************************************/
...@@ -46,9 +52,10 @@ extern void bl31_next_el_arch_setup(uint32_t security_state); ...@@ -46,9 +52,10 @@ extern void bl31_next_el_arch_setup(uint32_t security_state);
extern void bl31_set_next_image_type(uint32_t type); extern void bl31_set_next_image_type(uint32_t type);
extern uint32_t bl31_get_next_image_type(void); extern uint32_t bl31_get_next_image_type(void);
extern void bl31_prepare_next_image_entry(); extern void bl31_prepare_next_image_entry();
extern el_change_info_t *bl31_get_next_image_info(uint32_t type); extern struct el_change_info *bl31_get_next_image_info(uint32_t type);
extern void bl31_platform_setup(void); extern void bl31_platform_setup(void);
extern meminfo_t *bl31_plat_get_bl32_mem_layout(void); extern struct meminfo *bl31_plat_get_bl32_mem_layout(void);
extern meminfo_t *bl31_plat_sec_mem_layout(void); extern struct meminfo *bl31_plat_sec_mem_layout(void);
extern void bl31_register_bl32_init(int32_t (*)(meminfo_t *)); extern void bl31_register_bl32_init(int32_t (*)(struct meminfo *));
#endif /* __BL31_H__ */ #endif /* __BL31_H__ */
...@@ -27,6 +27,11 @@ ...@@ -27,6 +27,11 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <arch.h>
#include <context.h>
/* --------------------------------------------- /* ---------------------------------------------
* Zero out the callee saved register to prevent * Zero out the callee saved register to prevent
* leakage of secure state into the normal world * leakage of secure state into the normal world
......
...@@ -31,9 +31,6 @@ ...@@ -31,9 +31,6 @@
#ifndef __CONTEXT_H__ #ifndef __CONTEXT_H__
#define __CONTEXT_H__ #define __CONTEXT_H__
#include <arch.h>
#include <cassert.h>
/******************************************************************************* /*******************************************************************************
* Constants that allow assembler code to access members of and the 'gp_regs' * Constants that allow assembler code to access members of and the 'gp_regs'
* structure at their correct offsets. * structure at their correct offsets.
...@@ -171,6 +168,9 @@ ...@@ -171,6 +168,9 @@
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
#include <cassert.h>
#include <stdint.h>
/* /*
* Common constants to help define the 'cpu_context' structure and its * Common constants to help define the 'cpu_context' structure and its
* members below. * members below.
......
...@@ -31,9 +31,8 @@ ...@@ -31,9 +31,8 @@
#ifndef __CM_H__ #ifndef __CM_H__
#define __CM_H__ #define __CM_H__
#include <context.h> #include <stdint.h>
#ifndef __ASSEMBLY__
/******************************************************************************* /*******************************************************************************
* Function & variable prototypes * Function & variable prototypes
******************************************************************************/ ******************************************************************************/
...@@ -51,5 +50,5 @@ extern void cm_set_el3_eret_context(uint32_t security_state, uint64_t entrypoint ...@@ -51,5 +50,5 @@ extern void cm_set_el3_eret_context(uint32_t security_state, uint64_t entrypoint
extern void cm_set_el3_elr(uint32_t security_state, uint64_t entrypoint); extern void cm_set_el3_elr(uint32_t security_state, uint64_t entrypoint);
extern void cm_set_next_eret_context(uint32_t security_state); extern void cm_set_next_eret_context(uint32_t security_state);
extern void cm_init_exception_stack(uint64_t mpidr, uint32_t security_state); extern void cm_init_exception_stack(uint64_t mpidr, uint32_t security_state);
#endif /*__ASSEMBLY__*/
#endif /* __CM_H__ */ #endif /* __CM_H__ */
...@@ -30,8 +30,6 @@ ...@@ -30,8 +30,6 @@
#ifndef __RUNTIME_SVC_H__ #ifndef __RUNTIME_SVC_H__
#define __RUNTIME_SVC_H__ #define __RUNTIME_SVC_H__
#include <psci.h>
#include <cassert.h>
/******************************************************************************* /*******************************************************************************
* Bit definitions inside the function id as per the SMC calling convention * Bit definitions inside the function id as per the SMC calling convention
...@@ -122,6 +120,10 @@ ...@@ -122,6 +120,10 @@
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
#include <cassert.h>
#include <context.h>
#include <stdint.h>
/* Various flags passed to SMC handlers */ /* Various flags passed to SMC handlers */
#define SMC_FROM_SECURE (0 << 0) #define SMC_FROM_SECURE (0 << 0)
#define SMC_FROM_NON_SECURE (1 << 0) #define SMC_FROM_NON_SECURE (1 << 0)
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#ifndef __PSCI_H__ #ifndef __PSCI_H__
#define __PSCI_H__ #define __PSCI_H__
/******************************************************************************* /*******************************************************************************
* Defines for runtime services func ids * Defines for runtime services func ids
******************************************************************************/ ******************************************************************************/
...@@ -131,6 +132,10 @@ ...@@ -131,6 +132,10 @@
#define PSCI_NUM_AFFS 32ull #define PSCI_NUM_AFFS 32ull
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
#include <stdint.h>
/******************************************************************************* /*******************************************************************************
* Structure populated by platform specific code to export routines which * Structure populated by platform specific code to export routines which
* perform common low level pm functions * perform common low level pm functions
......
...@@ -31,15 +31,18 @@ ...@@ -31,15 +31,18 @@
#ifndef __BL32_H__ #ifndef __BL32_H__
#define __BL32_H__ #define __BL32_H__
#ifndef __ASSEMBLY__
#include <stdint.h> #include <stdint.h>
#include <bl_common.h> /******************************************
* Forward declarations
*****************************************/
struct meminfo;
/******************************************
* Function prototypes
*****************************************/
extern void bl32_platform_setup(void); extern void bl32_platform_setup(void);
extern meminfo_t *bl32_plat_sec_mem_layout(void); extern struct meminfo *bl32_plat_sec_mem_layout(void);
extern uint64_t bl32_main(void); extern uint64_t bl32_main(void);
#endif /* __ASSEMBLY__ */
#endif /* __BL32_H__ */ #endif /* __BL32_H__ */
...@@ -31,9 +31,6 @@ ...@@ -31,9 +31,6 @@
#ifndef __TSP_H__ #ifndef __TSP_H__
#define __TSP_H__ #define __TSP_H__
#include <platform.h>
#include <cassert.h>
/* /*
* SMC function IDs that TSP uses to signal various forms of completions * SMC function IDs that TSP uses to signal various forms of completions
* to the secure payload dispatcher. * to the secure payload dispatcher.
...@@ -86,6 +83,9 @@ ...@@ -86,6 +83,9 @@
#define TSP_ARGS_END 0x40 #define TSP_ARGS_END 0x40
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
#include <cassert.h>
#include <platform.h> /* For CACHE_WRITEBACK_GRANULE */
#include <stdint.h> #include <stdint.h>
typedef void (*tsp_generic_fptr_t)(uint64_t arg0, typedef void (*tsp_generic_fptr_t)(uint64_t arg0,
......
...@@ -28,6 +28,9 @@ ...@@ -28,6 +28,9 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <arch.h>
.macro func_prologue .macro func_prologue
stp x29, x30, [sp, #-0x10]! stp x29, x30, [sp, #-0x10]!
mov x29,sp mov x29,sp
......
...@@ -58,7 +58,8 @@ ...@@ -58,7 +58,8 @@
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
#include <stdio.h>
#include <cdefs.h> /* For __dead2 */
/******************************************************************************* /*******************************************************************************
* Structure used for telling the next BL how much of a particular type of * Structure used for telling the next BL how much of a particular type of
......
...@@ -31,9 +31,6 @@ ...@@ -31,9 +31,6 @@
#ifndef __DEBUG_H__ #ifndef __DEBUG_H__
#define __DEBUG_H__ #define __DEBUG_H__
/* Do not try to call this from ASM code. */
#ifndef __ASSEMBLY__
#include <stdio.h> #include <stdio.h>
/* If building the project with DEBUG disabled the INFO and WARN macros /* If building the project with DEBUG disabled the INFO and WARN macros
...@@ -66,5 +63,4 @@ static inline void __attribute__((noreturn)) panic(void) ...@@ -66,5 +63,4 @@ static inline void __attribute__((noreturn)) panic(void)
; ;
} }
#endif /* __ASSEMBLY__ */
#endif /* __DEBUG_H__ */ #endif /* __DEBUG_H__ */
...@@ -31,6 +31,9 @@ ...@@ -31,6 +31,9 @@
#ifndef __PL011_H__ #ifndef __PL011_H__
#define __PL011_H__ #define __PL011_H__
#include <mmio.h>
/* PL011 Registers */ /* PL011 Registers */
#define UARTDR 0x000 #define UARTDR 0x000
#define UARTRSR 0x004 #define UARTRSR 0x004
......
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