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
diff --git a/include/bl31/bl31.h b/include/bl31/bl31.h
index 6dd7596..b60e32c 100644
--- a/include/bl31/bl31.h
+++ b/include/bl31/bl31.h
@@ -31,13 +31,19 @@
#ifndef __BL31_H__
#define __BL31_H__
-#include <bl_common.h>
+#include <stdint.h>
/*******************************************************************************
* Data declarations
******************************************************************************/
extern unsigned long bl31_entrypoint;
+/******************************************
+ * Forward declarations
+ *****************************************/
+struct meminfo;
+struct el_change_info;
+
/*******************************************************************************
* Function prototypes
******************************************************************************/
@@ -46,9 +52,10 @@
extern void bl31_set_next_image_type(uint32_t type);
extern uint32_t bl31_get_next_image_type(void);
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 meminfo_t *bl31_plat_get_bl32_mem_layout(void);
-extern meminfo_t *bl31_plat_sec_mem_layout(void);
-extern void bl31_register_bl32_init(int32_t (*)(meminfo_t *));
+extern struct meminfo *bl31_plat_get_bl32_mem_layout(void);
+extern struct meminfo *bl31_plat_sec_mem_layout(void);
+extern void bl31_register_bl32_init(int32_t (*)(struct meminfo *));
+
#endif /* __BL31_H__ */
diff --git a/include/bl31/cm_macros.S b/include/bl31/cm_macros.S
index 9eeec18..d264956 100644
--- a/include/bl31/cm_macros.S
+++ b/include/bl31/cm_macros.S
@@ -27,6 +27,11 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
+
+#include <arch.h>
+#include <context.h>
+
+
/* ---------------------------------------------
* Zero out the callee saved register to prevent
* leakage of secure state into the normal world
diff --git a/include/bl31/context.h b/include/bl31/context.h
index c7eda7d..989b2e6 100644
--- a/include/bl31/context.h
+++ b/include/bl31/context.h
@@ -31,9 +31,6 @@
#ifndef __CONTEXT_H__
#define __CONTEXT_H__
-#include <arch.h>
-#include <cassert.h>
-
/*******************************************************************************
* Constants that allow assembler code to access members of and the 'gp_regs'
* structure at their correct offsets.
@@ -171,6 +168,9 @@
#ifndef __ASSEMBLY__
+#include <cassert.h>
+#include <stdint.h>
+
/*
* Common constants to help define the 'cpu_context' structure and its
* members below.
diff --git a/include/bl31/context_mgmt.h b/include/bl31/context_mgmt.h
index 35f7c8c..efcdcd2 100644
--- a/include/bl31/context_mgmt.h
+++ b/include/bl31/context_mgmt.h
@@ -31,9 +31,8 @@
#ifndef __CM_H__
#define __CM_H__
-#include <context.h>
+#include <stdint.h>
-#ifndef __ASSEMBLY__
/*******************************************************************************
* Function & variable prototypes
******************************************************************************/
@@ -51,5 +50,5 @@
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_init_exception_stack(uint64_t mpidr, uint32_t security_state);
-#endif /*__ASSEMBLY__*/
+
#endif /* __CM_H__ */
diff --git a/include/bl31/runtime_svc.h b/include/bl31/runtime_svc.h
index ac85fa3..12b5db8 100644
--- a/include/bl31/runtime_svc.h
+++ b/include/bl31/runtime_svc.h
@@ -30,8 +30,6 @@
#ifndef __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
@@ -122,6 +120,10 @@
#ifndef __ASSEMBLY__
+#include <cassert.h>
+#include <context.h>
+#include <stdint.h>
+
/* Various flags passed to SMC handlers */
#define SMC_FROM_SECURE (0 << 0)
#define SMC_FROM_NON_SECURE (1 << 0)
diff --git a/include/bl31/services/psci.h b/include/bl31/services/psci.h
index ab7b7bd..570fe5b 100644
--- a/include/bl31/services/psci.h
+++ b/include/bl31/services/psci.h
@@ -31,6 +31,7 @@
#ifndef __PSCI_H__
#define __PSCI_H__
+
/*******************************************************************************
* Defines for runtime services func ids
******************************************************************************/
@@ -131,6 +132,10 @@
#define PSCI_NUM_AFFS 32ull
#ifndef __ASSEMBLY__
+
+#include <stdint.h>
+
+
/*******************************************************************************
* Structure populated by platform specific code to export routines which
* perform common low level pm functions