Always use named structs in header files

Add tag names to all unnamed structs in header files. This
allows forward declaration of structs, which is necessary to
reduce header file nesting (to be implemented in a subsequent
commit).

Also change the typedef names across the codebase to use the _t
suffix to be more conformant with the Linux coding style. The
coding style actually prefers us not to use typedefs at all but
this is considered a step too far for Trusted Firmware.

Also change the IO framework structs defintions to use typedef'd
structs to be consistent with the rest of the codebase.

Change-Id: I722b2c86fc0d92e4da3b15e5cab20373dd26786f
diff --git a/include/bl31/bl31.h b/include/bl31/bl31.h
index a5539d9..6dd7596 100644
--- a/include/bl31/bl31.h
+++ b/include/bl31/bl31.h
@@ -46,9 +46,9 @@
 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 *bl31_get_next_image_info(uint32_t type);
+extern el_change_info_t *bl31_get_next_image_info(uint32_t type);
 extern void bl31_platform_setup(void);
-extern meminfo *bl31_plat_get_bl32_mem_layout(void);
-extern meminfo *bl31_plat_sec_mem_layout(void);
-extern void bl31_register_bl32_init(int32_t (*)(meminfo *));
+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 *));
 #endif /* __BL31_H__ */
diff --git a/include/bl31/context.h b/include/bl31/context.h
index b0c9810..c7eda7d 100644
--- a/include/bl31/context.h
+++ b/include/bl31/context.h
@@ -177,9 +177,9 @@
  */
 #define DWORD_SHIFT		3
 #define DEFINE_REG_STRUCT(name, num_regs)	\
-	typedef struct {			\
+	typedef struct name {			\
 		uint64_t _regs[num_regs];	\
-	}  __aligned(16) name
+	}  __aligned(16) name##_t
 
 /* Constants to determine the size of individual context structures */
 #define CTX_GPREG_ALL		(CTX_GPREGS_END >> DWORD_SHIFT)
@@ -232,31 +232,31 @@
  * structure at exception entry and exit. Each instance will
  * correspond to either the secure or the non-secure state.
  */
-typedef struct {
-	gp_regs gpregs_ctx;
-	el3_state el3state_ctx;
-	el1_sys_regs sysregs_ctx;
-	fp_regs fpregs_ctx;
-} cpu_context;
+typedef struct cpu_context {
+	gp_regs_t gpregs_ctx;
+	el3_state_t el3state_ctx;
+	el1_sys_regs_t sysregs_ctx;
+	fp_regs_t fpregs_ctx;
+} cpu_context_t;
 
-/* Macros to access members of the 'cpu_context' structure */
-#define get_el3state_ctx(h)	(&((cpu_context *) h)->el3state_ctx)
-#define get_fpregs_ctx(h)	(&((cpu_context *) h)->fpregs_ctx)
-#define get_sysregs_ctx(h)	(&((cpu_context *) h)->sysregs_ctx)
-#define get_gpregs_ctx(h)	(&((cpu_context *) h)->gpregs_ctx)
+/* Macros to access members of the 'cpu_context_t' structure */
+#define get_el3state_ctx(h)	(&((cpu_context_t *) h)->el3state_ctx)
+#define get_fpregs_ctx(h)	(&((cpu_context_t *) h)->fpregs_ctx)
+#define get_sysregs_ctx(h)	(&((cpu_context_t *) h)->sysregs_ctx)
+#define get_gpregs_ctx(h)	(&((cpu_context_t *) h)->gpregs_ctx)
 
 /*
  * Compile time assertions related to the 'cpu_context' structure to
  * ensure that the assembler and the compiler view of the offsets of
  * the structure members is the same.
  */
-CASSERT(CTX_GPREGS_OFFSET == __builtin_offsetof(cpu_context, gpregs_ctx), \
+CASSERT(CTX_GPREGS_OFFSET == __builtin_offsetof(cpu_context_t, gpregs_ctx), \
 	assert_core_context_gp_offset_mismatch);
-CASSERT(CTX_SYSREGS_OFFSET == __builtin_offsetof(cpu_context, sysregs_ctx), \
+CASSERT(CTX_SYSREGS_OFFSET == __builtin_offsetof(cpu_context_t, sysregs_ctx), \
 	assert_core_context_sys_offset_mismatch);
-CASSERT(CTX_FPREGS_OFFSET == __builtin_offsetof(cpu_context, fpregs_ctx), \
+CASSERT(CTX_FPREGS_OFFSET == __builtin_offsetof(cpu_context_t, fpregs_ctx), \
 	assert_core_context_fp_offset_mismatch);
-CASSERT(CTX_EL3STATE_OFFSET == __builtin_offsetof(cpu_context, el3state_ctx), \
+CASSERT(CTX_EL3STATE_OFFSET == __builtin_offsetof(cpu_context_t, el3state_ctx), \
 	assert_core_context_el3state_offset_mismatch);
 
 /*
@@ -298,12 +298,12 @@
 /*******************************************************************************
  * Function prototypes
  ******************************************************************************/
-void el3_sysregs_context_save(el3_state *regs);
-void el3_sysregs_context_restore(el3_state *regs);
-void el1_sysregs_context_save(el1_sys_regs *regs);
-void el1_sysregs_context_restore(el1_sys_regs *regs);
-void fpregs_context_save(fp_regs *regs);
-void fpregs_context_restore(fp_regs *regs);
+void el3_sysregs_context_save(el3_state_t *regs);
+void el3_sysregs_context_restore(el3_state_t *regs);
+void el1_sysregs_context_save(el1_sys_regs_t *regs);
+void el1_sysregs_context_restore(el1_sys_regs_t *regs);
+void fpregs_context_save(fp_regs_t *regs);
+void fpregs_context_restore(fp_regs_t *regs);
 
 #undef CTX_SYSREG_ALL
 #undef CTX_FP_ALL
diff --git a/include/bl31/runtime_svc.h b/include/bl31/runtime_svc.h
index 90d6700..ac85fa3 100644
--- a/include/bl31/runtime_svc.h
+++ b/include/bl31/runtime_svc.h
@@ -130,7 +130,7 @@
 #define is_caller_secure(_f)		(!(is_caller_non_secure(_f)))
 
 /* Prototype for runtime service initializing function */
-typedef int32_t (*rt_svc_init)(void);
+typedef int32_t (*rt_svc_init_t)(void);
 
 /* Convenience macros to return from SMC handler */
 #define SMC_RET1(_h, _x0)	{ \
@@ -175,7 +175,7 @@
  * can be accessed using the handle pointer. The cookie parameter is reserved
  * for future use
  */
-typedef uint64_t (*rt_svc_handle)(uint32_t smc_fid,
+typedef uint64_t (*rt_svc_handle_t)(uint32_t smc_fid,
 				  uint64_t x1,
 				  uint64_t x2,
 				  uint64_t x3,
@@ -183,20 +183,20 @@
 				  void *cookie,
 				  void *handle,
 				  uint64_t flags);
-typedef struct {
+typedef struct rt_svc_desc {
 	uint8_t start_oen;
 	uint8_t end_oen;
 	uint8_t call_type;
 	const char *name;
-	rt_svc_init init;
-	rt_svc_handle handle;
-} rt_svc_desc;
+	rt_svc_init_t init;
+	rt_svc_handle_t handle;
+} rt_svc_desc_t;
 
 /*
  * Convenience macro to declare a service descriptor
  */
 #define DECLARE_RT_SVC(_name, _start, _end, _type, _setup, _smch) \
-	static const rt_svc_desc __svc_desc_ ## _name \
+	static const rt_svc_desc_t __svc_desc_ ## _name \
 		__attribute__ ((section("rt_svc_descs"), used)) = { \
 			_start, \
 			_end, \
@@ -214,11 +214,11 @@
  * 3. ensure that the assembler and the compiler see the handler
  *    routine at the same offset.
  */
-CASSERT((sizeof(rt_svc_desc) == SIZEOF_RT_SVC_DESC), \
+CASSERT((sizeof(rt_svc_desc_t) == SIZEOF_RT_SVC_DESC), \
 	assert_sizeof_rt_svc_desc_mismatch);
-CASSERT(RT_SVC_DESC_INIT == __builtin_offsetof(rt_svc_desc, init), \
+CASSERT(RT_SVC_DESC_INIT == __builtin_offsetof(rt_svc_desc_t, init), \
 	assert_rt_svc_desc_init_offset_mismatch);
-CASSERT(RT_SVC_DESC_HANDLE == __builtin_offsetof(rt_svc_desc, handle), \
+CASSERT(RT_SVC_DESC_HANDLE == __builtin_offsetof(rt_svc_desc_t, handle), \
 	assert_rt_svc_desc_handle_offset_mismatch);
 
 
diff --git a/include/bl31/services/psci.h b/include/bl31/services/psci.h
index 351453f..ab7b7bd 100644
--- a/include/bl31/services/psci.h
+++ b/include/bl31/services/psci.h
@@ -135,7 +135,7 @@
  * Structure populated by platform specific code to export routines which
  * perform common low level pm functions
  ******************************************************************************/
-typedef struct {
+typedef struct plat_pm_ops {
 	int (*affinst_standby)(unsigned int);
 	int (*affinst_on)(unsigned long,
 			  unsigned long,
@@ -152,7 +152,7 @@
 	int (*affinst_suspend_finish)(unsigned long,
 				      unsigned int,
 				      unsigned int);
-} plat_pm_ops;
+} plat_pm_ops_t;
 
 /*******************************************************************************
  * Optional structure populated by the Secure Payload Dispatcher to be given a
@@ -160,7 +160,7 @@
  * operation. It also allows PSCI to determine certain properties of the SP e.g.
  * migrate capability etc.
  ******************************************************************************/
-typedef struct {
+typedef struct spd_pm_ops {
 	void (*svc_on)(uint64_t target_cpu);
 	int32_t (*svc_off)(uint64_t __unused);
 	void (*svc_suspend)(uint64_t power_state);
@@ -168,7 +168,7 @@
 	void (*svc_suspend_finish)(uint64_t suspend_level);
 	void (*svc_migrate)(uint64_t __unused1, uint64_t __unused2);
 	int32_t (*svc_migrate_info)(uint64_t *__unused);
-} spd_pm_ops;
+} spd_pm_ops_t;
 
 /*******************************************************************************
  * Function & Data prototypes
@@ -187,7 +187,7 @@
 		       unsigned long);
 extern void psci_aff_on_finish_entry(void);
 extern void psci_aff_suspend_finish_entry(void);
-extern void psci_register_spd_pm_hook(const spd_pm_ops *);
+extern void psci_register_spd_pm_hook(const spd_pm_ops_t *);
 extern int psci_get_suspend_stateid(unsigned long mpidr);
 extern int psci_get_suspend_afflvl(unsigned long mpidr);