Merge pull request #48 from danh-arm/dh/major-refactoring
dh/major refactoring
diff --git a/Makefile b/Makefile
index f4b74fe..3064aa4 100644
--- a/Makefile
+++ b/Makefile
@@ -59,14 +59,14 @@
BUILD_TYPE := release
endif
-BL_COMMON_SOURCES := misc_helpers.S \
- cache_helpers.S \
- tlb_helpers.S \
- xlat_helpers.c \
- std.c \
- bl_common.c \
- platform_helpers.S \
- io_storage.c
+BL_COMMON_SOURCES := common/bl_common.c \
+ lib/aarch64/cache_helpers.S \
+ lib/aarch64/misc_helpers.S \
+ lib/aarch64/tlb_helpers.S \
+ lib/aarch64/xlat_helpers.c \
+ lib/stdlib/std.c \
+ lib/io_storage.c \
+ plat/common/aarch64/platform_helpers.S
ARCH ?= aarch64
@@ -132,12 +132,17 @@
.SUFFIXES:
-INCLUDES += -Ilib/include/ \
- -Idrivers/io \
- -Iinclude/${ARCH}/ \
- -Iinclude/ \
- -Iarch/system/gic \
- -Iservices/std_svc/psci \
+INCLUDES += -Iinclude/bl1 \
+ -Iinclude/bl2 \
+ -Iinclude/bl31 \
+ -Iinclude/bl31/services \
+ -Iinclude/bl32 \
+ -Iinclude/bl32/payloads \
+ -Iinclude/common \
+ -Iinclude/drivers \
+ -Iinclude/drivers/arm \
+ -Iinclude/lib \
+ -Iinclude/lib/aarch64 \
-Iinclude/stdlib \
-Iinclude/stdlib/sys \
-Iplat/${PLAT} \
@@ -156,13 +161,6 @@
LDFLAGS += --gc-sections
-vpath %.ld.S bl1:bl2:bl31
-vpath %.c bl1:bl2:bl31
-vpath %.c bl1/${ARCH}:bl2/${ARCH}:bl31/${ARCH}
-vpath %.S bl1/${ARCH}:bl2/${ARCH}:bl31/${ARCH}
-vpath %.c lib/arch/${ARCH} # One of the missing paths needed for BL_COMMON_SOURCES
-
-
ifneq (${DEBUG}, 0)
#CFLAGS += -g -O0
CFLAGS += -g
diff --git a/arch/system/gic/gic_v2.h b/arch/system/gic/gic_v2.h
deleted file mode 100644
index 30bd4fc..0000000
--- a/arch/system/gic/gic_v2.h
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * Neither the name of ARM nor the names of its contributors may be used
- * to endorse or promote products derived from this software without specific
- * prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __GIC_V2_H__
-#define __GIC_V2_H__
-
-#include <mmio.h>
-
-/*******************************************************************************
- * GIC Distributor interface accessors for reading entire registers
- ******************************************************************************/
-
-static inline unsigned int gicd_read_ctlr(unsigned int base)
-{
- return mmio_read_32(base + GICD_CTLR);
-}
-
-static inline unsigned int gicd_read_typer(unsigned int base)
-{
- return mmio_read_32(base + GICD_TYPER);
-}
-
-static inline unsigned int gicd_read_sgir(unsigned int base)
-{
- return mmio_read_32(base + GICD_SGIR);
-}
-
-
-/*******************************************************************************
- * GIC Distributor interface accessors for writing entire registers
- ******************************************************************************/
-
-static inline void gicd_write_ctlr(unsigned int base, unsigned int val)
-{
- mmio_write_32(base + GICD_CTLR, val);
-}
-
-static inline void gicd_write_sgir(unsigned int base, unsigned int val)
-{
- mmio_write_32(base + GICD_SGIR, val);
-}
-
-
-/*******************************************************************************
- * GIC CPU interface accessors for reading entire registers
- ******************************************************************************/
-
-static inline unsigned int gicc_read_ctlr(unsigned int base)
-{
- return mmio_read_32(base + GICC_CTLR);
-}
-
-static inline unsigned int gicc_read_pmr(unsigned int base)
-{
- return mmio_read_32(base + GICC_PMR);
-}
-
-static inline unsigned int gicc_read_BPR(unsigned int base)
-{
- return mmio_read_32(base + GICC_BPR);
-}
-
-static inline unsigned int gicc_read_IAR(unsigned int base)
-{
- return mmio_read_32(base + GICC_IAR);
-}
-
-static inline unsigned int gicc_read_EOIR(unsigned int base)
-{
- return mmio_read_32(base + GICC_EOIR);
-}
-
-static inline unsigned int gicc_read_hppir(unsigned int base)
-{
- return mmio_read_32(base + GICC_HPPIR);
-}
-
-static inline unsigned int gicc_read_dir(unsigned int base)
-{
- return mmio_read_32(base + GICC_DIR);
-}
-
-static inline unsigned int gicc_read_iidr(unsigned int base)
-{
- return mmio_read_32(base + GICC_IIDR);
-}
-
-
-/*******************************************************************************
- * GIC CPU interface accessors for writing entire registers
- ******************************************************************************/
-
-static inline void gicc_write_ctlr(unsigned int base, unsigned int val)
-{
- mmio_write_32(base + GICC_CTLR, val);
-}
-
-static inline void gicc_write_pmr(unsigned int base, unsigned int val)
-{
- mmio_write_32(base + GICC_PMR, val);
-}
-
-static inline void gicc_write_BPR(unsigned int base, unsigned int val)
-{
- mmio_write_32(base + GICC_BPR, val);
-}
-
-
-static inline void gicc_write_IAR(unsigned int base, unsigned int val)
-{
- mmio_write_32(base + GICC_IAR, val);
-}
-
-static inline void gicc_write_EOIR(unsigned int base, unsigned int val)
-{
- mmio_write_32(base + GICC_EOIR, val);
-}
-
-static inline void gicc_write_hppir(unsigned int base, unsigned int val)
-{
- mmio_write_32(base + GICC_HPPIR, val);
-}
-
-static inline void gicc_write_dir(unsigned int base, unsigned int val)
-{
- mmio_write_32(base + GICC_DIR, val);
-}
-
-#endif /* __GIC_V2_H__ */
diff --git a/bl1/aarch64/bl1_arch_setup.c b/bl1/aarch64/bl1_arch_setup.c
index 417a536..758b8e8 100644
--- a/bl1/aarch64/bl1_arch_setup.c
+++ b/bl1/aarch64/bl1_arch_setup.c
@@ -28,9 +28,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+#include <arch.h>
#include <arch_helpers.h>
-#include <platform.h>
-#include <assert.h>
/*******************************************************************************
* Function that does the first bit of architectural setup that affects
diff --git a/bl1/aarch64/bl1_exceptions.S b/bl1/aarch64/bl1_exceptions.S
index e57f228..68d088b 100644
--- a/bl1/aarch64/bl1_exceptions.S
+++ b/bl1/aarch64/bl1_exceptions.S
@@ -29,11 +29,9 @@
*/
#include <arch.h>
+#include <asm_macros.S>
#include <bl_common.h>
-#include <bl1.h>
-#include <platform.h>
#include <runtime_svc.h>
-#include <asm_macros.S>
.globl bl1_exceptions
diff --git a/bl1/bl1.mk b/bl1/bl1.mk
index c2101b0..032dc5e 100644
--- a/bl1/bl1.mk
+++ b/bl1/bl1.mk
@@ -28,25 +28,10 @@
# POSSIBILITY OF SUCH DAMAGE.
#
-vpath %.c plat/${PLAT} \
- plat/${PLAT}/${ARCH} \
- common \
- lib \
- arch/${ARCH} \
- lib/arch/${ARCH} \
- ${PLAT_BL1_C_VPATH}
-
-vpath %.S arch/${ARCH}/cpu \
- plat/common/${ARCH} \
- plat/${PLAT}/${ARCH} \
- include \
- lib/arch/${ARCH} \
- ${PLAT_BL1_S_VPATH}
-
-BL1_SOURCES += bl1_arch_setup.c \
- bl1_entrypoint.S \
- bl1_exceptions.S \
- bl1_main.c \
- cpu_helpers.S
+BL1_SOURCES += bl1/bl1_main.c \
+ bl1/aarch64/bl1_arch_setup.c \
+ bl1/aarch64/bl1_entrypoint.S \
+ bl1/aarch64/bl1_exceptions.S \
+ lib/aarch64/cpu_helpers.S
-BL1_LINKERFILE := bl1.ld.S
+BL1_LINKERFILE := bl1/bl1.ld.S
diff --git a/bl1/bl1_main.c b/bl1/bl1_main.c
index dbf6c9d..de7bc31 100644
--- a/bl1/bl1_main.c
+++ b/bl1/bl1_main.c
@@ -28,15 +28,14 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
+#include <arch.h>
#include <arch_helpers.h>
-#include <platform.h>
-#include <semihosting.h>
+#include <assert.h>
+#include <bl_common.h>
#include <bl1.h>
-
-void bl1_arch_next_el_setup(void);
+#include <platform.h>
+#include <stdio.h>
+#include "bl1_private.h"
/*******************************************************************************
* Function to perform late architectural and platform specific initialization.
@@ -52,8 +51,8 @@
#endif
unsigned long bl2_base;
unsigned int load_type = TOP_LOAD, spsr;
- meminfo *bl1_tzram_layout;
- meminfo *bl2_tzram_layout = 0x0;
+ meminfo_t *bl1_tzram_layout;
+ meminfo_t *bl2_tzram_layout = 0x0;
/*
* Ensure that MMU/Caches and coherency are turned on
@@ -88,7 +87,7 @@
* to BL2. BL2 will read the memory layout before using its
* memory for other purposes.
*/
- bl2_tzram_layout = (meminfo *) bl1_tzram_layout->free_base;
+ bl2_tzram_layout = (meminfo_t *) bl1_tzram_layout->free_base;
init_bl2_mem_layout(bl1_tzram_layout,
bl2_tzram_layout,
load_type,
diff --git a/include/bl1.h b/bl1/bl1_private.h
similarity index 87%
copy from include/bl1.h
copy to bl1/bl1_private.h
index e1d50c0..b2ebf21 100644
--- a/include/bl1.h
+++ b/bl1/bl1_private.h
@@ -28,19 +28,13 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef __BL1_H__
-#define __BL1_H__
-
-#include <bl_common.h>
-
-#ifndef __ASSEMBLY__
+#ifndef __BL1_PRIVATE_H__
+#define __BL1_PRIVATE_H__
/******************************************
* Function prototypes
*****************************************/
-extern void bl1_platform_setup(void);
-extern meminfo *bl1_plat_sec_mem_layout(void);
-
-#endif /*__ASSEMBLY__*/
+extern void bl1_arch_setup(void);
+extern void bl1_arch_next_el_setup(void);
-#endif /* __BL1_H__ */
+#endif /* __BL1_PRIVATE_H__ */
diff --git a/bl2/aarch64/bl2_arch_setup.c b/bl2/aarch64/bl2_arch_setup.c
index 7ecf669..0eafd15 100644
--- a/bl2/aarch64/bl2_arch_setup.c
+++ b/bl2/aarch64/bl2_arch_setup.c
@@ -28,8 +28,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+#include <arch.h>
#include <arch_helpers.h>
-#include <platform.h>
/*******************************************************************************
* Place holder function to perform any S-EL1 specific architectural setup. At
diff --git a/bl2/aarch64/bl2_entrypoint.S b/bl2/aarch64/bl2_entrypoint.S
index 6bc779a..b8af9a5 100644
--- a/bl2/aarch64/bl2_entrypoint.S
+++ b/bl2/aarch64/bl2_entrypoint.S
@@ -28,9 +28,9 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <bl_common.h>
#include <arch.h>
#include <asm_macros.S>
+#include <bl_common.h>
.globl bl2_entrypoint
diff --git a/bl2/bl2.mk b/bl2/bl2.mk
index d53c1aa..1e82078 100644
--- a/bl2/bl2.mk
+++ b/bl2/bl2.mk
@@ -28,25 +28,10 @@
# POSSIBILITY OF SUCH DAMAGE.
#
-vpath %.c common \
- lib \
- plat/${PLAT} \
- plat/${PLAT}/${ARCH} \
- arch/${ARCH} \
- ${PLAT_BL2_C_VPATH}
-
-vpath %.S lib/arch/${ARCH} \
- include \
- lib/sync/locks/exclusive \
- common/${ARCH} \
- ${PLAT_BL2_S_VPATH}
-
-BL2_SOURCES += bl2_entrypoint.S \
- bl2_arch_setup.c \
- bl2_main.c \
- spinlock.S \
- early_exceptions.S
-
-BL2_LINKERFILE := bl2.ld.S
+BL2_SOURCES += bl2/bl2_main.c \
+ bl2/aarch64/bl2_entrypoint.S \
+ bl2/aarch64/bl2_arch_setup.c \
+ common/aarch64/early_exceptions.S \
+ lib/locks/exclusive/spinlock.S
-CFLAGS += $(DEFINES)
+BL2_LINKERFILE := bl2/bl2.ld.S
diff --git a/bl2/bl2_main.c b/bl2/bl2_main.c
index 1deebc8..ac28559 100644
--- a/bl2/bl2_main.c
+++ b/bl2/bl2_main.c
@@ -28,16 +28,15 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
+#include <arch.h>
#include <arch_helpers.h>
-#include <console.h>
-#include <platform.h>
-#include <semihosting.h>
+#include <assert.h>
#include <bl_common.h>
#include <bl2.h>
-#include "debug.h"
+#include <debug.h>
+#include <platform.h>
+#include <stdio.h>
+#include "bl2_private.h"
/*******************************************************************************
* The only thing to do in BL2 is to load further images and pass control to
@@ -47,8 +46,8 @@
******************************************************************************/
void bl2_main(void)
{
- meminfo *bl2_tzram_layout;
- bl31_args *bl2_to_bl31_args;
+ meminfo_t *bl2_tzram_layout;
+ bl31_args_t *bl2_to_bl31_args;
unsigned long bl31_base, bl32_base = 0, bl33_base, el_status;
unsigned int bl2_load, bl31_load, mode;
diff --git a/include/bl1.h b/bl2/bl2_private.h
similarity index 87%
copy from include/bl1.h
copy to bl2/bl2_private.h
index e1d50c0..2a66d42 100644
--- a/include/bl1.h
+++ b/bl2/bl2_private.h
@@ -28,19 +28,12 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef __BL1_H__
-#define __BL1_H__
-
-#include <bl_common.h>
-
-#ifndef __ASSEMBLY__
+#ifndef __BL2_PRIVATE_H__
+#define __BL2_PRIVATE_H__
/******************************************
* Function prototypes
*****************************************/
-extern void bl1_platform_setup(void);
-extern meminfo *bl1_plat_sec_mem_layout(void);
-
-#endif /*__ASSEMBLY__*/
+extern void bl2_arch_setup(void);
-#endif /* __BL1_H__ */
+#endif /* __BL2_PRIVATE_H__ */
diff --git a/bl31/aarch64/bl31_arch_setup.c b/bl31/aarch64/bl31_arch_setup.c
index 793b895..acaa6b5 100644
--- a/bl31/aarch64/bl31_arch_setup.c
+++ b/bl31/aarch64/bl31_arch_setup.c
@@ -28,9 +28,12 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+#include <arch.h>
#include <arch_helpers.h>
-#include <platform.h>
#include <assert.h>
+#include <bl_common.h>
+#include <bl31.h>
+#include <platform.h>
/*******************************************************************************
* This duplicates what the primary cpu did after a cold boot in BL1. The same
diff --git a/bl31/aarch64/bl31_entrypoint.S b/bl31/aarch64/bl31_entrypoint.S
index d35b50a..39fa605 100644
--- a/bl31/aarch64/bl31_entrypoint.S
+++ b/bl31/aarch64/bl31_entrypoint.S
@@ -28,11 +28,10 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <bl_common.h>
-#include <platform.h>
#include <arch.h>
-#include "cm_macros.S"
#include <asm_macros.S>
+#include <bl_common.h>
+#include <cm_macros.S>
.globl bl31_entrypoint
diff --git a/bl31/aarch64/context.S b/bl31/aarch64/context.S
index 2b2e7bf..45d4a22 100644
--- a/bl31/aarch64/context.S
+++ b/bl31/aarch64/context.S
@@ -28,8 +28,9 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <context.h>
+#include <arch.h>
#include <asm_macros.S>
+#include <context.h>
/* -----------------------------------------------------
* The following function strictly follows the AArch64
diff --git a/bl31/aarch64/runtime_exceptions.S b/bl31/aarch64/runtime_exceptions.S
index d00c1d7..53cc176 100644
--- a/bl31/aarch64/runtime_exceptions.S
+++ b/bl31/aarch64/runtime_exceptions.S
@@ -29,11 +29,11 @@
*/
#include <arch.h>
-#include <runtime_svc.h>
-#include <platform.h>
+#include <asm_macros.S>
+#include <cm_macros.S>
#include <context.h>
-#include "asm_macros.S"
-#include "cm_macros.S"
+#include <platform.h>
+#include <runtime_svc.h>
.globl runtime_exceptions
.globl el3_exit
diff --git a/bl31/bl31.mk b/bl31/bl31.mk
index 38765bc..ef40f67 100644
--- a/bl31/bl31.mk
+++ b/bl31/bl31.mk
@@ -28,46 +28,23 @@
# POSSIBILITY OF SUCH DAMAGE.
#
-vpath %.c common \
- lib \
- arch/system/gic \
- plat/${PLAT} \
- arch/${ARCH} \
- services/std_svc \
- services/std_svc/psci \
- lib/sync/locks/bakery \
- plat/${PLAT}/${ARCH} \
- ${PLAT_BL31_C_VPATH}
-
-vpath %.S lib/arch/${ARCH} \
- services/std_svc \
- services/std_svc/psci \
- include \
- plat/${PLAT}/${ARCH} \
- lib/sync/locks/exclusive \
- plat/common/${ARCH} \
- arch/system/gic/${ARCH} \
- common/${ARCH} \
- ${PLAT_BL31_S_VPATH}
-
-BL31_SOURCES += bl31_arch_setup.c \
- bl31_entrypoint.S \
- runtime_exceptions.S \
- bl31_main.c \
- std_svc_setup.c \
- psci_entry.S \
- psci_setup.c \
- psci_common.c \
- psci_afflvl_on.c \
- psci_main.c \
- psci_afflvl_off.c \
- psci_afflvl_suspend.c \
- spinlock.S \
- gic_v3_sysregs.S \
- bakery_lock.c \
- runtime_svc.c \
- early_exceptions.S \
- context_mgmt.c \
- context.S
+BL31_SOURCES += bl31/bl31_main.c \
+ bl31/context_mgmt.c \
+ bl31/runtime_svc.c \
+ bl31/aarch64/bl31_arch_setup.c \
+ bl31/aarch64/bl31_entrypoint.S \
+ bl31/aarch64/context.S \
+ bl31/aarch64/runtime_exceptions.S \
+ common/aarch64/early_exceptions.S \
+ lib/locks/bakery/bakery_lock.c \
+ lib/locks/exclusive/spinlock.S \
+ services/std_svc/std_svc_setup.c \
+ services/std_svc/psci/psci_afflvl_off.c \
+ services/std_svc/psci/psci_afflvl_on.c \
+ services/std_svc/psci/psci_afflvl_suspend.c \
+ services/std_svc/psci/psci_common.c \
+ services/std_svc/psci/psci_entry.S \
+ services/std_svc/psci/psci_main.c \
+ services/std_svc/psci/psci_setup.c
-BL31_LINKERFILE := bl31.ld.S
+BL31_LINKERFILE := bl31/bl31.ld.S
diff --git a/bl31/bl31_main.c b/bl31/bl31_main.c
index 536bb86..cf826d0 100644
--- a/bl31/bl31_main.c
+++ b/bl31/bl31_main.c
@@ -28,17 +28,14 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
+#include <arch.h>
#include <arch_helpers.h>
-#include <console.h>
-#include <platform.h>
-#include <semihosting.h>
+#include <assert.h>
#include <bl_common.h>
#include <bl31.h>
-#include <runtime_svc.h>
#include <context_mgmt.h>
+#include <runtime_svc.h>
+#include <stdio.h>
/*******************************************************************************
@@ -47,7 +44,7 @@
* for SP execution. In cases where both SPD and SP are absent, or when SPD
* finds it impossible to execute SP, this pointer is left as NULL
******************************************************************************/
-static int32_t (*bl32_init)(meminfo *);
+static int32_t (*bl32_init)(meminfo_t *);
/*******************************************************************************
* Variable to indicate whether next image to execute after BL31 is BL33
@@ -153,7 +150,7 @@
******************************************************************************/
void bl31_prepare_next_image_entry()
{
- el_change_info *next_image_info;
+ el_change_info_t *next_image_info;
uint32_t scr, image_type;
/* Determine which image to execute next */
@@ -190,7 +187,7 @@
* This function initializes the pointer to BL32 init function. This is expected
* to be called by the SPD after it finishes all its initialization
******************************************************************************/
-void bl31_register_bl32_init(int32_t (*func)(meminfo *))
+void bl31_register_bl32_init(int32_t (*func)(meminfo_t *))
{
bl32_init = func;
}
diff --git a/bl31/context_mgmt.c b/bl31/context_mgmt.c
index 60c3492..8d1396e 100644
--- a/bl31/context_mgmt.c
+++ b/bl31/context_mgmt.c
@@ -28,15 +28,13 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <stdio.h>
-#include <errno.h>
-#include <string.h>
-#include <assert.h>
#include <arch_helpers.h>
-#include <platform.h>
+#include <assert.h>
#include <bl_common.h>
-#include <runtime_svc.h>
+#include <context.h>
#include <context_mgmt.h>
+#include <platform.h>
+#include <runtime_svc.h>
/*******************************************************************************
* Data structure which holds the pointers to non-secure and secure security
@@ -45,9 +43,9 @@
******************************************************************************/
typedef struct {
void *ptr[2];
-} __aligned (CACHE_WRITEBACK_GRANULE) context_info;
+} __aligned (CACHE_WRITEBACK_GRANULE) context_info_t;
-static context_info cm_context_info[PLATFORM_CORE_COUNT];
+static context_info_t cm_context_info[PLATFORM_CORE_COUNT];
/*******************************************************************************
* Context management library initialisation routine. This library is used by
@@ -104,7 +102,7 @@
******************************************************************************/
void cm_el3_sysregs_context_save(uint32_t security_state)
{
- cpu_context *ctx;
+ cpu_context_t *ctx;
ctx = cm_get_context(read_mpidr(), security_state);
assert(ctx);
@@ -114,7 +112,7 @@
void cm_el3_sysregs_context_restore(uint32_t security_state)
{
- cpu_context *ctx;
+ cpu_context_t *ctx;
ctx = cm_get_context(read_mpidr(), security_state);
assert(ctx);
@@ -124,7 +122,7 @@
void cm_el1_sysregs_context_save(uint32_t security_state)
{
- cpu_context *ctx;
+ cpu_context_t *ctx;
ctx = cm_get_context(read_mpidr(), security_state);
assert(ctx);
@@ -134,7 +132,7 @@
void cm_el1_sysregs_context_restore(uint32_t security_state)
{
- cpu_context *ctx;
+ cpu_context_t *ctx;
ctx = cm_get_context(read_mpidr(), security_state);
assert(ctx);
@@ -151,8 +149,8 @@
void cm_set_el3_eret_context(uint32_t security_state, uint64_t entrypoint,
uint32_t spsr, uint32_t scr)
{
- cpu_context *ctx;
- el3_state *state;
+ cpu_context_t *ctx;
+ el3_state_t *state;
ctx = cm_get_context(read_mpidr(), security_state);
assert(ctx);
@@ -170,8 +168,8 @@
******************************************************************************/
void cm_set_el3_elr(uint32_t security_state, uint64_t entrypoint)
{
- cpu_context *ctx;
- el3_state *state;
+ cpu_context_t *ctx;
+ el3_state_t *state;
ctx = cm_get_context(read_mpidr(), security_state);
assert(ctx);
@@ -188,7 +186,7 @@
******************************************************************************/
void cm_set_next_eret_context(uint32_t security_state)
{
- cpu_context *ctx;
+ cpu_context_t *ctx;
#if DEBUG
uint64_t sp_mode;
#endif
@@ -220,8 +218,8 @@
******************************************************************************/
void cm_init_exception_stack(uint64_t mpidr, uint32_t security_state)
{
- cpu_context *ctx;
- el3_state *state;
+ cpu_context_t *ctx;
+ el3_state_t *state;
ctx = cm_get_context(mpidr, security_state);
assert(ctx);
diff --git a/common/runtime_svc.c b/bl31/runtime_svc.c
similarity index 91%
rename from common/runtime_svc.c
rename to bl31/runtime_svc.c
index 1628e8d..9a68e50 100644
--- a/common/runtime_svc.c
+++ b/bl31/runtime_svc.c
@@ -28,20 +28,10 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <stdio.h>
-#include <string.h>
+#include <debug.h>
#include <errno.h>
-#include <assert.h>
-#include <arch_helpers.h>
-#include <console.h>
-#include <platform.h>
-#include <semihosting.h>
-#include <bl_common.h>
-#include <psci.h>
#include <runtime_svc.h>
-#include <context.h>
-#include <debug.h>
-#include <context_mgmt.h>
+#include <string.h>
/*******************************************************************************
* The 'rt_svc_descs' array holds the runtime service descriptors exported by
@@ -55,12 +45,12 @@
#define RT_SVC_DESCS_START ((uint64_t) (&__RT_SVC_DESCS_START__))
#define RT_SVC_DESCS_END ((uint64_t) (&__RT_SVC_DESCS_END__))
uint8_t rt_svc_descs_indices[MAX_RT_SVCS];
-static rt_svc_desc *rt_svc_descs;
+static rt_svc_desc_t *rt_svc_descs;
/*******************************************************************************
* Simple routine to sanity check a runtime service descriptor before using it
******************************************************************************/
-static int32_t validate_rt_svc_desc(rt_svc_desc *desc)
+static int32_t validate_rt_svc_desc(rt_svc_desc_t *desc)
{
if (desc == NULL)
return -EINVAL;
@@ -96,14 +86,14 @@
/* If no runtime services are implemented then simply bail out */
rt_svc_descs_num = RT_SVC_DESCS_END - RT_SVC_DESCS_START;
- rt_svc_descs_num /= sizeof(rt_svc_desc);
+ rt_svc_descs_num /= sizeof(rt_svc_desc_t);
if (rt_svc_descs_num == 0)
return;
/* Initialise internal variables to invalid state */
memset(rt_svc_descs_indices, -1, sizeof(rt_svc_descs_indices));
- rt_svc_descs = (rt_svc_desc *) RT_SVC_DESCS_START;
+ rt_svc_descs = (rt_svc_desc_t *) RT_SVC_DESCS_START;
for (index = 0; index < rt_svc_descs_num; index++) {
/*
@@ -148,7 +138,7 @@
void fault_handler(void *handle)
{
- gp_regs *gpregs_ctx = get_gpregs_ctx(handle);
+ gp_regs_t *gpregs_ctx = get_gpregs_ctx(handle);
ERROR("Unhandled synchronous fault. Register dump @ 0x%x \n",
gpregs_ctx);
panic();
diff --git a/bl32/tsp/aarch64/tsp_entrypoint.S b/bl32/tsp/aarch64/tsp_entrypoint.S
index 8bfe454..97d54f6 100644
--- a/bl32/tsp/aarch64/tsp_entrypoint.S
+++ b/bl32/tsp/aarch64/tsp_entrypoint.S
@@ -28,10 +28,9 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <bl_common.h>
#include <arch.h>
-#include <tsp.h>
#include <asm_macros.S>
+#include <tsp.h>
.globl tsp_entrypoint
diff --git a/bl32/tsp/aarch64/tsp_request.S b/bl32/tsp/aarch64/tsp_request.S
index da7d6e6..6aa0873 100644
--- a/bl32/tsp/aarch64/tsp_request.S
+++ b/bl32/tsp/aarch64/tsp_request.S
@@ -28,8 +28,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <tsp.h>
#include <asm_macros.S>
+#include <tsp.h>
.globl tsp_get_magic
diff --git a/bl32/tsp/tsp-fvp.mk b/bl32/tsp/tsp-fvp.mk
index 02fae09..3bcf439 100644
--- a/bl32/tsp/tsp-fvp.mk
+++ b/bl32/tsp/tsp-fvp.mk
@@ -28,11 +28,7 @@
# POSSIBILITY OF SUCH DAMAGE.
#
-
-vpath %.c ${PLAT_BL2_C_VPATH}
-vpath %.S ${PLAT_BL2_S_VPATH}
-
# TSP source files specific to FVP platform
-BL32_SOURCES += bl32_plat_setup.c \
- platform_mp_stack.S \
- plat_common.c
+BL32_SOURCES += plat/common/aarch64/platform_mp_stack.S \
+ plat/fvp/bl32_plat_setup.c \
+ plat/fvp/aarch64/plat_common.c
diff --git a/bl32/tsp/tsp.mk b/bl32/tsp/tsp.mk
index 2aedf61..c478b43 100644
--- a/bl32/tsp/tsp.mk
+++ b/bl32/tsp/tsp.mk
@@ -28,29 +28,13 @@
# POSSIBILITY OF SUCH DAMAGE.
#
-vpath %.c common \
- lib \
- plat/${PLAT} \
- plat/${PLAT}/${ARCH} \
- arch/${ARCH}
-
-vpath %.S lib/arch/${ARCH} \
- include \
- lib/sync/locks/exclusive \
- common/${ARCH}
-
-BL32_SOURCES += tsp_entrypoint.S \
- tsp_main.c \
- tsp_request.S \
- spinlock.S \
- early_exceptions.S
-
-BL32_LINKERFILE := tsp.ld.S
+BL32_SOURCES += bl32/tsp/tsp_main.c \
+ bl32/tsp/aarch64/tsp_entrypoint.S \
+ bl32/tsp/aarch64/tsp_request.S \
+ common/aarch64/early_exceptions.S \
+ lib/locks/exclusive/spinlock.S
-vpath %.ld.S ${BL32_ROOT}
-vpath %.c ${BL32_ROOT}
-vpath %.c ${BL32_ROOT}/${ARCH}
-vpath %.S ${BL32_ROOT}/${ARCH}
+BL32_LINKERFILE := bl32/tsp/tsp.ld.S
# Include the platform-specific TSP Makefile
# If no platform-specific TSP Makefile exists, it means TSP is not supported
diff --git a/bl32/tsp/tsp_main.c b/bl32/tsp/tsp_main.c
index 366aef0..a667ffc 100644
--- a/bl32/tsp/tsp_main.c
+++ b/bl32/tsp/tsp_main.c
@@ -28,13 +28,14 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <bl32.h>
-#include <tsp.h>
#include <arch_helpers.h>
-#include <stdio.h>
-#include <platform.h>
+#include <bl_common.h>
+#include <bl32.h>
#include <debug.h>
+#include <platform.h>
#include <spinlock.h>
+#include <stdio.h>
+#include <tsp.h>
/*******************************************************************************
* Lock to control access to the console
@@ -45,19 +46,19 @@
* Per cpu data structure to populate parameters for an SMC in C code and use
* a pointer to this structure in assembler code to populate x0-x7
******************************************************************************/
-static tsp_args tsp_smc_args[PLATFORM_CORE_COUNT];
+static tsp_args_t tsp_smc_args[PLATFORM_CORE_COUNT];
/*******************************************************************************
* Per cpu data structure to keep track of TSP activity
******************************************************************************/
-static work_statistics tsp_stats[PLATFORM_CORE_COUNT];
+static work_statistics_t tsp_stats[PLATFORM_CORE_COUNT];
/*******************************************************************************
* Single reference to the various entry points exported by the test secure
* payload. A single copy should suffice for all cpus as they are not expected
* to change.
******************************************************************************/
-static const entry_info tsp_entry_info = {
+static const entry_info_t tsp_entry_info = {
tsp_fast_smc_entry,
tsp_cpu_on_entry,
tsp_cpu_off_entry,
@@ -65,7 +66,7 @@
tsp_cpu_suspend_entry,
};
-static tsp_args *set_smc_args(uint64_t arg0,
+static tsp_args_t *set_smc_args(uint64_t arg0,
uint64_t arg1,
uint64_t arg2,
uint64_t arg3,
@@ -76,7 +77,7 @@
{
uint64_t mpidr = read_mpidr();
uint32_t linear_id;
- tsp_args *pcpu_smc_args;
+ tsp_args_t *pcpu_smc_args;
/*
* Return to Secure Monitor by raising an SMC. The results of the
@@ -107,7 +108,7 @@
uint32_t linear_id = platform_get_core_pos(mpidr);
#if DEBUG
- meminfo *mem_layout = bl32_plat_sec_mem_layout();
+ meminfo_t *mem_layout = bl32_plat_sec_mem_layout();
#endif
/* Initialize the platform */
@@ -145,7 +146,7 @@
* after this cpu's architectural state has been setup in response to an earlier
* psci cpu_on request.
******************************************************************************/
-tsp_args *tsp_cpu_on_main(void)
+tsp_args_t *tsp_cpu_on_main(void)
{
uint64_t mpidr = read_mpidr();
uint32_t linear_id = platform_get_core_pos(mpidr);
@@ -171,7 +172,7 @@
* This function performs any remaining book keeping in the test secure payload
* before this cpu is turned off in response to a psci cpu_off request.
******************************************************************************/
-tsp_args *tsp_cpu_off_main(uint64_t arg0,
+tsp_args_t *tsp_cpu_off_main(uint64_t arg0,
uint64_t arg1,
uint64_t arg2,
uint64_t arg3,
@@ -206,7 +207,7 @@
* this cpu's architectural state is saved in response to an earlier psci
* cpu_suspend request.
******************************************************************************/
-tsp_args *tsp_cpu_suspend_main(uint64_t power_state,
+tsp_args_t *tsp_cpu_suspend_main(uint64_t power_state,
uint64_t arg1,
uint64_t arg2,
uint64_t arg3,
@@ -241,7 +242,7 @@
* cpu's architectural state has been restored after wakeup from an earlier psci
* cpu_suspend request.
******************************************************************************/
-tsp_args *tsp_cpu_resume_main(uint64_t suspend_level,
+tsp_args_t *tsp_cpu_resume_main(uint64_t suspend_level,
uint64_t arg1,
uint64_t arg2,
uint64_t arg3,
@@ -277,7 +278,7 @@
* in the function arguments in order. Once the service is rendered, this
* function returns to Secure Monitor by raising SMC
******************************************************************************/
-tsp_args *tsp_fast_smc_handler(uint64_t func,
+tsp_args_t *tsp_fast_smc_handler(uint64_t func,
uint64_t arg1,
uint64_t arg2,
uint64_t arg3,
diff --git a/common/aarch64/early_exceptions.S b/common/aarch64/early_exceptions.S
index 41bff97..90f5421 100644
--- a/common/aarch64/early_exceptions.S
+++ b/common/aarch64/early_exceptions.S
@@ -28,11 +28,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <arch.h>
-#include <bl_common.h>
-#include <platform.h>
-#include <runtime_svc.h>
#include <asm_macros.S>
+#include <runtime_svc.h>
.globl early_exceptions
diff --git a/common/bl_common.c b/common/bl_common.c
index b03165b..af2b7b7 100644
--- a/common/bl_common.c
+++ b/common/bl_common.c
@@ -28,17 +28,14 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <assert.h>
+#include <arch.h>
#include <arch_helpers.h>
-#include <console.h>
-#include <platform.h>
-#include <semihosting.h>
+#include <assert.h>
#include <bl_common.h>
-#include "io_storage.h"
-#include "debug.h"
+#include <debug.h>
+#include <io_storage.h>
+#include <platform.h>
+#include <stdio.h>
unsigned long page_align(unsigned long value, unsigned dir)
{
@@ -74,7 +71,7 @@
write_scr(scr);
}
-void __dead2 drop_el(aapcs64_params *args,
+void __dead2 drop_el(aapcs64_params_t *args,
unsigned long spsr,
unsigned long entrypoint)
{
@@ -90,7 +87,7 @@
args->arg7);
}
-void __dead2 raise_el(aapcs64_params *args)
+void __dead2 raise_el(aapcs64_params_t *args)
{
smc(args->arg0,
args->arg1,
@@ -107,7 +104,7 @@
* Add support for dropping into EL0 etc. Consider adding support
* for switching from S-EL1 to S-EL0/1 etc.
*/
-void __dead2 change_el(el_change_info *info)
+void __dead2 change_el(el_change_info_t *info)
{
unsigned long current_el = read_current_el();
@@ -156,8 +153,8 @@
* TODO: Revisit if this and init_bl2_mem_layout can be replaced by a single
* routine.
******************************************************************************/
-void init_bl31_mem_layout(const meminfo *bl2_mem_layout,
- meminfo *bl31_mem_layout,
+void init_bl31_mem_layout(const meminfo_t *bl2_mem_layout,
+ meminfo_t *bl31_mem_layout,
unsigned int load_type)
{
if (load_type == BOT_LOAD) {
@@ -200,7 +197,7 @@
bl31_mem_layout->total_size = bl2_mem_layout->total_size;
bl31_mem_layout->attr = load_type;
- flush_dcache_range((unsigned long) bl31_mem_layout, sizeof(meminfo));
+ flush_dcache_range((unsigned long) bl31_mem_layout, sizeof(meminfo_t));
return;
}
@@ -210,8 +207,8 @@
* this information, it populates bl2_mem_layout to tell BL2 how much memory
* it has access to and how much is available for use.
******************************************************************************/
-void init_bl2_mem_layout(meminfo *bl1_mem_layout,
- meminfo *bl2_mem_layout,
+void init_bl2_mem_layout(meminfo_t *bl1_mem_layout,
+ meminfo_t *bl2_mem_layout,
unsigned int load_type,
unsigned long bl2_base)
{
@@ -232,13 +229,13 @@
bl2_mem_layout->free_size = bl1_mem_layout->free_size;
bl2_mem_layout->attr = load_type;
- flush_dcache_range((unsigned long) bl2_mem_layout, sizeof(meminfo));
+ flush_dcache_range((unsigned long) bl2_mem_layout, sizeof(meminfo_t));
return;
}
static void dump_load_info(unsigned long image_load_addr,
unsigned long image_size,
- const meminfo *mem_layout)
+ const meminfo_t *mem_layout)
{
#if DEBUG
printf("Trying to load image at address 0x%lx, size = 0x%lx\r\n",
@@ -301,7 +298,7 @@
* the bottom or top of the free memory. It updates the memory layout if the
* load is successful.
******************************************************************************/
-unsigned long load_image(meminfo *mem_layout,
+unsigned long load_image(meminfo_t *mem_layout,
const char *image_name,
unsigned int load_type,
unsigned long fixed_addr)
@@ -553,7 +550,7 @@
void *first_arg,
void *second_arg)
{
- el_change_info run_image_info;
+ el_change_info_t run_image_info;
unsigned long current_el = read_current_el();
/* Tell next EL what we want done */
diff --git a/drivers/arm/interconnect/cci-400/cci400.c b/drivers/arm/cci400/cci400.c
similarity index 98%
rename from drivers/arm/interconnect/cci-400/cci400.c
rename to drivers/arm/cci400/cci400.c
index cd5446f..02f7f95 100644
--- a/drivers/arm/interconnect/cci-400/cci400.c
+++ b/drivers/arm/cci400/cci400.c
@@ -28,9 +28,9 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <assert.h>
-#include <platform.h>
#include <cci400.h>
+#include <mmio.h>
+#include <platform.h>
static inline unsigned long get_slave_iface_base(unsigned long mpidr)
{
@@ -44,7 +44,8 @@
DVM_EN_BIT | SNOOP_EN_BIT);
/* Wait for the dust to settle down */
- while (mmio_read_32(CCI400_BASE + STATUS_REG) & CHANGE_PENDING_BIT);
+ while (mmio_read_32(CCI400_BASE + STATUS_REG) & CHANGE_PENDING_BIT)
+ ;
}
void cci_disable_coherency(unsigned long mpidr)
@@ -54,6 +55,7 @@
~(DVM_EN_BIT | SNOOP_EN_BIT));
/* Wait for the dust to settle down */
- while (mmio_read_32(CCI400_BASE + STATUS_REG) & CHANGE_PENDING_BIT);
+ while (mmio_read_32(CCI400_BASE + STATUS_REG) & CHANGE_PENDING_BIT)
+ ;
}
diff --git a/arch/system/gic/aarch64/gic_v3_sysregs.S b/drivers/arm/gic/aarch64/gic_v3_sysregs.S
similarity index 100%
rename from arch/system/gic/aarch64/gic_v3_sysregs.S
rename to drivers/arm/gic/aarch64/gic_v3_sysregs.S
diff --git a/arch/system/gic/gic_v2.c b/drivers/arm/gic/gic_v2.c
similarity index 99%
rename from arch/system/gic/gic_v2.c
rename to drivers/arm/gic/gic_v2.c
index 6af0378..b011900 100644
--- a/arch/system/gic/gic_v2.c
+++ b/drivers/arm/gic/gic_v2.c
@@ -29,7 +29,7 @@
*/
#include <assert.h>
-#include <gic.h>
+#include <gic_v2.h>
#include <mmio.h>
/*******************************************************************************
diff --git a/arch/system/gic/gic_v3.c b/drivers/arm/gic/gic_v3.c
similarity index 97%
rename from arch/system/gic/gic_v3.c
rename to drivers/arm/gic/gic_v3.c
index b7db1f0..f429662 100644
--- a/arch/system/gic/gic_v3.c
+++ b/drivers/arm/gic/gic_v3.c
@@ -28,12 +28,9 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <stdint.h>
#include <arch.h>
-#include <platform.h>
-#include <gic.h>
-#include <gic_v3.h>
#include <debug.h>
+#include <gic_v3.h>
uintptr_t gicv3_get_rdist(uintptr_t gicr_base, uint64_t mpidr)
{
diff --git a/drivers/arm/peripherals/pl011/pl011.c b/drivers/arm/pl011/pl011.c
similarity index 99%
rename from drivers/arm/peripherals/pl011/pl011.c
rename to drivers/arm/pl011/pl011.c
index 8288cd8..f12bd23 100644
--- a/drivers/arm/peripherals/pl011/pl011.c
+++ b/drivers/arm/pl011/pl011.c
@@ -28,9 +28,9 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+#include <assert.h>
#include <platform.h>
#include <pl011.h>
-#include <assert.h>
void pl011_setbaudrate(unsigned long base_addr, unsigned int baudrate)
{
diff --git a/drivers/arm/peripherals/pl011/pl011_console.c b/drivers/arm/pl011/pl011_console.c
similarity index 99%
rename from drivers/arm/peripherals/pl011/pl011_console.c
rename to drivers/arm/pl011/pl011_console.c
index 1a684ff..3b0e237 100644
--- a/drivers/arm/peripherals/pl011/pl011_console.c
+++ b/drivers/arm/pl011/pl011_console.c
@@ -28,10 +28,10 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+#include <assert.h>
#include <console.h>
#include <platform.h>
#include <pl011.h>
-#include <assert.h>
static unsigned long uart_base;
diff --git a/drivers/arm/interconnect/tzc-400/tzc400.c b/drivers/arm/tzc400/tzc400.c
similarity index 93%
rename from drivers/arm/interconnect/tzc-400/tzc400.c
rename to drivers/arm/tzc400/tzc400.c
index b88e34a..c1716db 100644
--- a/drivers/arm/interconnect/tzc-400/tzc400.c
+++ b/drivers/arm/tzc400/tzc400.c
@@ -29,10 +29,10 @@
*/
#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)
{
@@ -49,7 +49,7 @@
mmio_write_32(base + GATE_KEEPER_OFF, val);
}
-static void tzc_write_action(uint64_t base, enum tzc_action action)
+static void tzc_write_action(uint64_t base, tzc_action_t action)
{
mmio_write_32(base + ACTION_OFF, action);
}
@@ -130,7 +130,7 @@
}
-void tzc_init(struct tzc_instance *controller)
+void tzc_init(tzc_instance_t *controller)
{
uint32_t tzc_id, tzc_build;
@@ -166,12 +166,12 @@
* this cannot be changed. It is, however, possible to change some region 0
* permissions.
*/
-void tzc_configure_region(const struct tzc_instance *controller,
+void tzc_configure_region(const tzc_instance_t *controller,
uint32_t filters,
uint8_t region,
uint64_t region_base,
uint64_t region_top,
- enum tzc_region_attributes sec_attr,
+ tzc_region_attributes_t sec_attr,
uint32_t ns_device_access)
{
uint64_t max_addr;
@@ -218,7 +218,7 @@
}
-void tzc_set_action(const struct tzc_instance *controller, enum tzc_action action)
+void tzc_set_action(const tzc_instance_t *controller, tzc_action_t action)
{
assert(controller != NULL);
@@ -231,7 +231,7 @@
}
-void tzc_enable_filters(const struct tzc_instance *controller)
+void tzc_enable_filters(const tzc_instance_t *controller)
{
uint32_t state;
uint32_t filter;
@@ -250,7 +250,7 @@
}
-void tzc_disable_filters(const struct tzc_instance *controller)
+void tzc_disable_filters(const tzc_instance_t *controller)
{
uint32_t filter;
diff --git a/drivers/io/io_fip.c b/drivers/io/io_fip.c
index 1eb76fa..b2dcfcc 100644
--- a/drivers/io/io_fip.c
+++ b/drivers/io/io_fip.c
@@ -28,17 +28,17 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <stdint.h>
-#include <uuid.h>
+#include <assert.h>
+#include <debug.h>
#include <errno.h>
+#include <firmware_image_package.h>
+#include <io_driver.h>
+#include <io_fip.h>
+#include <io_storage.h>
+#include <platform.h>
+#include <stdint.h>
#include <string.h>
-#include <assert.h>
-#include "platform.h"
-#include "firmware_image_package.h"
-#include "io_storage.h"
-#include "io_driver.h"
-#include "io_fip.h"
-#include "debug.h"
+#include <uuid.h>
/* Useful for printing UUIDs when debugging.*/
#define PRINT_UUID2(x) \
@@ -51,7 +51,7 @@
typedef struct {
const char *name;
const uuid_t uuid;
-} plat_fip_name_uuid;
+} plat_fip_name_uuid_t;
typedef struct {
/* Put file_pos above the struct to allow {0} on static init.
@@ -59,10 +59,10 @@
* http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53119
*/
unsigned int file_pos;
- fip_toc_entry entry;
-} file_state;
+ fip_toc_entry_t entry;
+} file_state_t;
-static plat_fip_name_uuid name_uuid[] = {
+static plat_fip_name_uuid_t name_uuid[] = {
{BL2_IMAGE_NAME, UUID_TRUSTED_BOOT_FIRMWARE_BL2},
{BL31_IMAGE_NAME, UUID_EL3_RUNTIME_FIRMWARE_BL31},
{BL32_IMAGE_NAME, UUID_SECURE_PAYLOAD_BL32},
@@ -70,21 +70,21 @@
};
static const uuid_t uuid_null = {0};
-static file_state current_file = {0};
+static file_state_t current_file = {0};
static io_dev_handle backend_dev_handle;
static void *backend_image_spec;
/* Firmware Image Package driver functions */
-static int fip_dev_open(void *spec, struct io_dev_info **dev_info);
-static int fip_file_open(struct io_dev_info *dev_info, const void *spec,
- struct io_entity *entity);
-static int fip_file_len(struct io_entity *entity, size_t *length);
-static int fip_file_read(struct io_entity *entity, void *buffer, size_t length,
+static int fip_dev_open(void *spec, io_dev_info_t **dev_info);
+static int fip_file_open(io_dev_info_t *dev_info, const void *spec,
+ io_entity_t *entity);
+static int fip_file_len(io_entity_t *entity, size_t *length);
+static int fip_file_read(io_entity_t *entity, void *buffer, size_t length,
size_t *length_read);
-static int fip_file_close(struct io_entity *entity);
-static int fip_dev_init(struct io_dev_info *dev_info, const void *init_params);
-static int fip_dev_close(struct io_dev_info *dev_info);
+static int fip_file_close(io_entity_t *entity);
+static int fip_dev_init(io_dev_info_t *dev_info, const void *init_params);
+static int fip_dev_close(io_dev_info_t *dev_info);
static inline int copy_uuid(uuid_t *dst, const uuid_t *src)
@@ -102,7 +102,7 @@
/* TODO: We could check version numbers or do a package checksum? */
-static inline int is_valid_header(fip_toc_header *header)
+static inline int is_valid_header(fip_toc_header_t *header)
{
if ((header->name == TOC_HEADER_NAME) && (header->serial_number != 0)) {
return 1;
@@ -129,7 +129,7 @@
/* Identify the device type as a virtual driver */
-io_type device_type_fip(void)
+io_type_t device_type_fip(void)
{
return IO_TYPE_FIRMWARE_IMAGE_PACKAGE;
}
@@ -161,7 +161,7 @@
/* Open a connection to the FIP device */
static int fip_dev_open(void *spec __attribute__((unused)),
- struct io_dev_info **dev_info)
+ io_dev_info_t **dev_info)
{
assert(dev_info != NULL);
*dev_info = &fip_dev_info;
@@ -171,12 +171,12 @@
/* Do some basic package checks. */
-static int fip_dev_init(struct io_dev_info *dev_info, const void *init_params)
+static int fip_dev_init(io_dev_info_t *dev_info, const void *init_params)
{
int result = IO_FAIL;
char *image_name = (char *)init_params;
io_handle backend_handle;
- fip_toc_header header;
+ fip_toc_header_t header;
size_t bytes_read;
/* Obtain a reference to the image by querying the platform layer */
@@ -215,7 +215,7 @@
}
/* Close a connection to the FIP device */
-static int fip_dev_close(struct io_dev_info *dev_info)
+static int fip_dev_close(io_dev_info_t *dev_info)
{
/* TODO: Consider tracking open files and cleaning them up here */
@@ -228,13 +228,13 @@
/* Open a file for access from package. */
-static int fip_file_open(struct io_dev_info *dev_info, const void *spec,
- struct io_entity *entity)
+static int fip_file_open(io_dev_info_t *dev_info, const void *spec,
+ io_entity_t *entity)
{
int result = IO_FAIL;
io_handle backend_handle;
uuid_t file_uuid;
- const io_file_spec *file_spec = (io_file_spec *)spec;
+ const io_file_spec_t *file_spec = (io_file_spec_t *)spec;
size_t bytes_read;
int found_file = 0;
@@ -262,7 +262,7 @@
}
/* Seek past the FIP header into the Table of Contents */
- result = io_seek(backend_handle, IO_SEEK_SET, sizeof(fip_toc_header));
+ result = io_seek(backend_handle, IO_SEEK_SET, sizeof(fip_toc_header_t));
if (result != IO_SUCCESS) {
WARN("fip_file_open: failed to seek\n");
result = IO_FAIL;
@@ -310,23 +310,23 @@
/* Return the size of a file in package */
-static int fip_file_len(struct io_entity *entity, size_t *length)
+static int fip_file_len(io_entity_t *entity, size_t *length)
{
assert(entity != NULL);
assert(length != NULL);
- *length = ((file_state *)entity->info)->entry.size;
+ *length = ((file_state_t *)entity->info)->entry.size;
return IO_SUCCESS;
}
/* Read data from a file in package */
-static int fip_file_read(struct io_entity *entity, void *buffer, size_t length,
+static int fip_file_read(io_entity_t *entity, void *buffer, size_t length,
size_t *length_read)
{
int result = IO_FAIL;
- file_state *fp;
+ file_state_t *fp;
size_t file_offset;
size_t bytes_read;
io_handle backend_handle;
@@ -345,7 +345,7 @@
goto fip_file_read_exit;
}
- fp = (file_state *)entity->info;
+ fp = (file_state_t *)entity->info;
/* Seek to the position in the FIP where the payload lives */
file_offset = fp->entry.offset_address + fp->file_pos;
@@ -378,7 +378,7 @@
/* Close a file in package */
-static int fip_file_close(struct io_entity *entity)
+static int fip_file_close(io_entity_t *entity)
{
/* Clear our current file pointer.
* If we had malloc() we would free() here.
@@ -396,7 +396,7 @@
/* Exported functions */
/* Register the Firmware Image Package driver with the IO abstraction */
-int register_io_dev_fip(struct io_dev_connector **dev_con)
+int register_io_dev_fip(io_dev_connector_t **dev_con)
{
int result = IO_FAIL;
assert(dev_con != NULL);
diff --git a/drivers/io/io_memmap.c b/drivers/io/io_memmap.c
index 40b8e9a..a40e612 100644
--- a/drivers/io/io_memmap.c
+++ b/drivers/io/io_memmap.c
@@ -29,10 +29,10 @@
*/
#include <assert.h>
+#include <debug.h>
+#include <io_driver.h>
+#include <io_storage.h>
#include <string.h>
-#include "io_storage.h"
-#include "io_driver.h"
-#include "debug.h"
/* 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
@@ -45,28 +45,28 @@
int in_use;
size_t base;
size_t file_pos;
-} file_state;
+} file_state_t;
-static file_state current_file = {0};
+static file_state_t current_file = {0};
/* Identify the device type as memmap */
-io_type device_type_memmap(void)
+io_type_t device_type_memmap(void)
{
return IO_TYPE_MEMMAP;
}
/* Memmap device functions */
-static int memmap_dev_open(void *spec, struct io_dev_info **dev_info);
-static int memmap_block_open(struct io_dev_info *dev_info, const void *spec,
- struct io_entity *entity);
-static int memmap_block_seek(struct io_entity *entity, int mode,
+static int memmap_dev_open(void *spec, io_dev_info_t **dev_info);
+static int memmap_block_open(io_dev_info_t *dev_info, const void *spec,
+ io_entity_t *entity);
+static int memmap_block_seek(io_entity_t *entity, int mode,
ssize_t offset);
-static int memmap_block_read(struct io_entity *entity, void *buffer,
+static int memmap_block_read(io_entity_t *entity, void *buffer,
size_t length, size_t *length_read);
-static int memmap_block_write(struct io_entity *entity, const void *buffer,
+static int memmap_block_write(io_entity_t *entity, const void *buffer,
size_t length, size_t *length_written);
-static int memmap_block_close(struct io_entity *entity);
-static int memmap_dev_close(struct io_dev_info *dev_info);
+static int memmap_block_close(io_entity_t *entity);
+static int memmap_dev_close(io_dev_info_t *dev_info);
static struct io_dev_connector memmap_dev_connector = {
@@ -95,7 +95,7 @@
/* Open a connection to the memmap device */
static int memmap_dev_open(void *spec __attribute__((unused)),
- struct io_dev_info **dev_info)
+ io_dev_info_t **dev_info)
{
assert(dev_info != NULL);
*dev_info = &memmap_dev_info;
@@ -106,7 +106,7 @@
/* Close a connection to the memmap device */
-static int memmap_dev_close(struct io_dev_info *dev_info)
+static int memmap_dev_close(io_dev_info_t *dev_info)
{
/* NOP */
/* TODO: Consider tracking open files and cleaning them up here */
@@ -116,11 +116,11 @@
/* Open a file on the memmap device */
/* TODO: Can we do any sensible limit checks on requested memory */
-static int memmap_block_open(struct io_dev_info *dev_info, const void *spec,
- struct io_entity *entity)
+static int memmap_block_open(io_dev_info_t *dev_info, const void *spec,
+ io_entity_t *entity)
{
int result = IO_FAIL;
- const io_block_spec *block_spec = (io_block_spec *)spec;
+ const io_block_spec_t *block_spec = (io_block_spec_t *)spec;
/* Since we need to track open state for seek() we only allow one open
* spec at a time. When we have dynamic memory we can malloc and set
@@ -146,7 +146,7 @@
/* Seek to a particular file offset on the memmap device */
-static int memmap_block_seek(struct io_entity *entity, int mode, ssize_t offset)
+static int memmap_block_seek(io_entity_t *entity, int mode, ssize_t offset)
{
int result = IO_FAIL;
@@ -155,7 +155,7 @@
assert(entity != NULL);
/* TODO: can we do some basic limit checks on seek? */
- ((file_state *)entity->info)->file_pos = offset;
+ ((file_state_t *)entity->info)->file_pos = offset;
result = IO_SUCCESS;
} else {
result = IO_FAIL;
@@ -166,16 +166,16 @@
/* Read data from a file on the memmap device */
-static int memmap_block_read(struct io_entity *entity, void *buffer,
+static int memmap_block_read(io_entity_t *entity, void *buffer,
size_t length, size_t *length_read)
{
- file_state *fp;
+ file_state_t *fp;
assert(entity != NULL);
assert(buffer != NULL);
assert(length_read != NULL);
- fp = (file_state *)entity->info;
+ fp = (file_state_t *)entity->info;
memcpy(buffer, (void *)(fp->base + fp->file_pos), length);
@@ -188,16 +188,16 @@
/* Write data to a file on the memmap device */
-static int memmap_block_write(struct io_entity *entity, const void *buffer,
+static int memmap_block_write(io_entity_t *entity, const void *buffer,
size_t length, size_t *length_written)
{
- file_state *fp;
+ file_state_t *fp;
assert(entity != NULL);
assert(buffer != NULL);
assert(length_written != NULL);
- fp = (file_state *)entity->info;
+ fp = (file_state_t *)entity->info;
memcpy((void *)(fp->base + fp->file_pos), buffer, length);
@@ -211,7 +211,7 @@
/* Close a file on the memmap device */
-static int memmap_block_close(struct io_entity *entity)
+static int memmap_block_close(io_entity_t *entity)
{
assert(entity != NULL);
@@ -227,7 +227,7 @@
/* Exported functions */
/* Register the memmap driver with the IO abstraction */
-int register_io_dev_memmap(struct io_dev_connector **dev_con)
+int register_io_dev_memmap(io_dev_connector_t **dev_con)
{
int result = IO_FAIL;
assert(dev_con != NULL);
diff --git a/drivers/io/io_semihosting.c b/drivers/io/io_semihosting.c
index 14ec687..a37693d 100644
--- a/drivers/io/io_semihosting.c
+++ b/drivers/io/io_semihosting.c
@@ -29,14 +29,14 @@
*/
#include <assert.h>
-#include "io_storage.h"
-#include "io_driver.h"
-#include "semihosting.h"
+#include <io_driver.h>
+#include <io_storage.h>
+#include <semihosting.h>
/* Identify the device type as semihosting */
-static io_type device_type_sh(void)
+static io_type_t device_type_sh(void)
{
return IO_TYPE_SEMIHOSTING;
}
@@ -44,16 +44,16 @@
/* Semi-hosting functions, device info and handle */
-static int sh_dev_open(void *spec, struct io_dev_info **dev_info);
-static int sh_file_open(struct io_dev_info *dev_info, const void *spec,
- struct io_entity *entity);
-static int sh_file_seek(struct io_entity *entity, int mode, ssize_t offset);
-static int sh_file_len(struct io_entity *entity, size_t *length);
-static int sh_file_read(struct io_entity *entity, void *buffer, size_t length,
+static int sh_dev_open(void *spec, io_dev_info_t **dev_info);
+static int sh_file_open(io_dev_info_t *dev_info, const void *spec,
+ io_entity_t *entity);
+static int sh_file_seek(io_entity_t *entity, int mode, ssize_t offset);
+static int sh_file_len(io_entity_t *entity, size_t *length);
+static int sh_file_read(io_entity_t *entity, void *buffer, size_t length,
size_t *length_read);
-static int sh_file_write(struct io_entity *entity, const void *buffer,
+static int sh_file_write(io_entity_t *entity, const void *buffer,
size_t length, size_t *length_written);
-static int sh_file_close(struct io_entity *entity);
+static int sh_file_close(io_entity_t *entity);
static struct io_dev_connector sh_dev_connector = {
.dev_open = sh_dev_open
@@ -80,7 +80,7 @@
/* Open a connection to the semi-hosting device */
-static int sh_dev_open(void *spec __unused, struct io_dev_info **dev_info)
+static int sh_dev_open(void *spec __unused, io_dev_info_t **dev_info)
{
int result = IO_SUCCESS;
assert(dev_info != NULL);
@@ -90,12 +90,12 @@
/* Open a file on the semi-hosting device */
-static int sh_file_open(struct io_dev_info *dev_info __attribute__((unused)),
- const void *spec, struct io_entity *entity)
+static int sh_file_open(io_dev_info_t *dev_info __attribute__((unused)),
+ const void *spec, io_entity_t *entity)
{
int result = IO_FAIL;
long sh_result = -1;
- const io_file_spec *file_spec = (io_file_spec *)spec;
+ const io_file_spec_t *file_spec = (io_file_spec_t *)spec;
assert(file_spec != NULL);
assert(entity != NULL);
@@ -113,7 +113,7 @@
/* Seek to a particular file offset on the semi-hosting device */
-static int sh_file_seek(struct io_entity *entity, int mode, ssize_t offset)
+static int sh_file_seek(io_entity_t *entity, int mode, ssize_t offset)
{
int result = IO_FAIL;
long file_handle, sh_result;
@@ -131,7 +131,7 @@
/* Return the size of a file on the semi-hosting device */
-static int sh_file_len(struct io_entity *entity, size_t *length)
+static int sh_file_len(io_entity_t *entity, size_t *length)
{
int result = IO_FAIL;
@@ -151,7 +151,7 @@
/* Read data from a file on the semi-hosting device */
-static int sh_file_read(struct io_entity *entity, void *buffer, size_t length,
+static int sh_file_read(io_entity_t *entity, void *buffer, size_t length,
size_t *length_read)
{
int result = IO_FAIL;
@@ -178,7 +178,7 @@
/* Write data to a file on the semi-hosting device */
-static int sh_file_write(struct io_entity *entity, const void *buffer,
+static int sh_file_write(io_entity_t *entity, const void *buffer,
size_t length, size_t *length_written)
{
int result = IO_FAIL;
@@ -205,7 +205,7 @@
/* Close a file on the semi-hosting device */
-static int sh_file_close(struct io_entity *entity)
+static int sh_file_close(io_entity_t *entity)
{
int result = IO_FAIL;
long sh_result = -1;
@@ -226,7 +226,7 @@
/* Exported functions */
/* Register the semi-hosting driver with the IO abstraction */
-int register_io_dev_sh(struct io_dev_connector **dev_con)
+int register_io_dev_sh(io_dev_connector_t **dev_con)
{
int result = IO_FAIL;
assert(dev_con != NULL);
diff --git a/include/bl1.h b/include/bl1/bl1.h
similarity index 90%
rename from include/bl1.h
rename to include/bl1/bl1.h
index e1d50c0..d8afae4 100644
--- a/include/bl1.h
+++ b/include/bl1/bl1.h
@@ -31,16 +31,16 @@
#ifndef __BL1_H__
#define __BL1_H__
-#include <bl_common.h>
-#ifndef __ASSEMBLY__
+/******************************************
+ * Forward declarations
+ *****************************************/
+struct meminfo;
/******************************************
* Function prototypes
*****************************************/
extern void bl1_platform_setup(void);
-extern meminfo *bl1_plat_sec_mem_layout(void);
-
-#endif /*__ASSEMBLY__*/
+extern struct meminfo *bl1_plat_sec_mem_layout(void);
#endif /* __BL1_H__ */
diff --git a/include/bl2.h b/include/bl2/bl2.h
similarity index 88%
rename from include/bl2.h
rename to include/bl2/bl2.h
index d0ff69b..25b6f9c 100644
--- a/include/bl2.h
+++ b/include/bl2/bl2.h
@@ -31,18 +31,22 @@
#ifndef __BL2_H__
#define __BL2_H__
-#include <bl_common.h>
-
/******************************************
* Data declarations
*****************************************/
extern unsigned long long bl2_entrypoint;
/******************************************
+ * Forward declarations
+ *****************************************/
+struct meminfo;
+struct bl31_args;
+
+/******************************************
* Function prototypes
*****************************************/
extern void bl2_platform_setup(void);
-extern meminfo *bl2_plat_sec_mem_layout(void);
-extern bl31_args *bl2_get_bl31_args_ptr(void);
+extern struct meminfo *bl2_plat_sec_mem_layout(void);
+extern struct bl31_args *bl2_get_bl31_args_ptr(void);
#endif /* __BL2_H__ */
diff --git a/include/bl31.h b/include/bl31/bl31.h
similarity index 82%
rename from include/bl31.h
rename to include/bl31/bl31.h
index b8c603a..b60e32c 100644
--- a/include/bl31.h
+++ b/include/bl31/bl31.h
@@ -31,23 +31,31 @@
#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
******************************************************************************/
+extern void bl31_arch_setup(void);
extern void bl31_next_el_arch_setup(uint32_t security_state);
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 struct el_change_info *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 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/cm_macros.S b/include/bl31/cm_macros.S
similarity index 98%
rename from include/cm_macros.S
rename to include/bl31/cm_macros.S
index 9eeec18..d264956 100644
--- a/include/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/context.h b/include/bl31/context.h
similarity index 89%
rename from include/context.h
rename to include/bl31/context.h
index cb4cd8e..989b2e6 100644
--- a/include/context.h
+++ b/include/bl31/context.h
@@ -31,9 +31,6 @@
#ifndef __CONTEXT_H__
#define __CONTEXT_H__
-#include <bl_common.h>
-#include <arch.h>
-
/*******************************************************************************
* Constants that allow assembler code to access members of and the 'gp_regs'
* structure at their correct offsets.
@@ -171,15 +168,18 @@
#ifndef __ASSEMBLY__
+#include <cassert.h>
+#include <stdint.h>
+
/*
* Common constants to help define the 'cpu_context' structure and its
* members below.
*/
#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/context_mgmt.h b/include/bl31/context_mgmt.h
similarity index 97%
rename from include/context_mgmt.h
rename to include/bl31/context_mgmt.h
index 35f7c8c..efcdcd2 100644
--- a/include/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/runtime_svc.h b/include/bl31/runtime_svc.h
similarity index 94%
rename from include/runtime_svc.h
rename to include/bl31/runtime_svc.h
index 148c0bc..12b5db8 100644
--- a/include/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 <bl_common.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)
@@ -130,7 +132,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 +177,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 +185,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 +216,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);
@@ -261,6 +263,7 @@
extern uint64_t __RT_SVC_DESCS_START__;
extern uint64_t __RT_SVC_DESCS_END__;
extern uint64_t get_exception_stack(uint64_t mpidr);
+extern void runtime_exceptions(void);
extern void fault_handler(void *handle);
#endif /*__ASSEMBLY__*/
#endif /* __RUNTIME_SVC_H__ */
diff --git a/include/psci.h b/include/bl31/services/psci.h
similarity index 94%
rename from include/psci.h
rename to include/bl31/services/psci.h
index e290793..570fe5b 100644
--- a/include/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,11 +132,15 @@
#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
******************************************************************************/
-typedef struct {
+typedef struct plat_pm_ops {
int (*affinst_standby)(unsigned int);
int (*affinst_on)(unsigned long,
unsigned long,
@@ -152,7 +157,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 +165,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 +173,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,10 +192,23 @@
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);
+extern uint64_t psci_smc_handler(uint32_t smc_fid,
+ uint64_t x1,
+ uint64_t x2,
+ uint64_t x3,
+ uint64_t x4,
+ void *cookie,
+ void *handle,
+ uint64_t flags);
+
+/* PSCI setup function */
+extern int32_t psci_setup(void);
+
+
#endif /*__ASSEMBLY__*/
diff --git a/include/std_svc.h b/include/bl31/services/std_svc.h
similarity index 100%
rename from include/std_svc.h
rename to include/bl31/services/std_svc.h
diff --git a/include/bl32.h b/include/bl32/bl32.h
similarity index 85%
rename from include/bl32.h
rename to include/bl32/bl32.h
index 88e18bd..3239487 100644
--- a/include/bl32.h
+++ b/include/bl32/bl32.h
@@ -31,15 +31,18 @@
#ifndef __BL32_H__
#define __BL32_H__
-#ifndef __ASSEMBLY__
#include <stdint.h>
-#include <bl_common.h>
+/******************************************
+ * Forward declarations
+ *****************************************/
+struct meminfo;
+/******************************************
+ * Function prototypes
+ *****************************************/
extern void bl32_platform_setup(void);
-extern meminfo *bl32_plat_sec_mem_layout(void);
+extern struct meminfo *bl32_plat_sec_mem_layout(void);
extern uint64_t bl32_main(void);
-#endif /* __ASSEMBLY__ */
-
#endif /* __BL32_H__ */
diff --git a/include/tsp.h b/include/bl32/payloads/tsp.h
similarity index 87%
rename from include/tsp.h
rename to include/bl32/payloads/tsp.h
index 9d747d7..1f542d5 100644
--- a/include/tsp.h
+++ b/include/bl32/payloads/tsp.h
@@ -31,9 +31,6 @@
#ifndef __TSP_H__
#define __TSP_H__
-#include <bl_common.h>
-#include <platform.h>
-
/*
* SMC function IDs that TSP uses to signal various forms of completions
* to the secure payload dispatcher.
@@ -86,9 +83,12 @@
#define TSP_ARGS_END 0x40
#ifndef __ASSEMBLY__
+
+#include <cassert.h>
+#include <platform.h> /* For CACHE_WRITEBACK_GRANULE */
#include <stdint.h>
-typedef void (*tsp_generic_fptr)(uint64_t arg0,
+typedef void (*tsp_generic_fptr_t)(uint64_t arg0,
uint64_t arg1,
uint64_t arg2,
uint64_t arg3,
@@ -97,26 +97,26 @@
uint64_t arg6,
uint64_t arg7);
-typedef struct {
- tsp_generic_fptr fast_smc_entry;
- tsp_generic_fptr cpu_on_entry;
- tsp_generic_fptr cpu_off_entry;
- tsp_generic_fptr cpu_resume_entry;
- tsp_generic_fptr cpu_suspend_entry;
-} entry_info;
+typedef struct entry_info {
+ tsp_generic_fptr_t fast_smc_entry;
+ tsp_generic_fptr_t cpu_on_entry;
+ tsp_generic_fptr_t cpu_off_entry;
+ tsp_generic_fptr_t cpu_resume_entry;
+ tsp_generic_fptr_t cpu_suspend_entry;
+} entry_info_t;
-typedef struct {
+typedef struct work_statistics {
uint32_t smc_count; /* Number of returns on this cpu */
uint32_t eret_count; /* Number of entries on this cpu */
uint32_t cpu_on_count; /* Number of cpu on requests */
uint32_t cpu_off_count; /* Number of cpu off requests */
uint32_t cpu_suspend_count; /* Number of cpu suspend requests */
uint32_t cpu_resume_count; /* Number of cpu resume requests */
-} __aligned(CACHE_WRITEBACK_GRANULE) work_statistics;
+} __aligned(CACHE_WRITEBACK_GRANULE) work_statistics_t;
-typedef struct {
+typedef struct tsp_args {
uint64_t _regs[TSP_ARGS_END >> 3];
-} __aligned(CACHE_WRITEBACK_GRANULE) tsp_args;
+} __aligned(CACHE_WRITEBACK_GRANULE) tsp_args_t;
/* Macros to access members of the above structure using their offsets */
#define read_sp_arg(args, offset) ((args)->_regs[offset >> 3])
@@ -127,7 +127,7 @@
* Ensure that the assembler's view of the size of the tsp_args is the
* same as the compilers
*/
-CASSERT(TSP_ARGS_SIZE == sizeof(tsp_args), assert_sp_args_size_mismatch);
+CASSERT(TSP_ARGS_SIZE == sizeof(tsp_args_t), assert_sp_args_size_mismatch);
extern void tsp_get_magic(uint64_t args[4]);
@@ -147,7 +147,7 @@
uint64_t arg5,
uint64_t arg6,
uint64_t arg7);
-extern tsp_args *tsp_cpu_resume_main(uint64_t arg0,
+extern tsp_args_t *tsp_cpu_resume_main(uint64_t arg0,
uint64_t arg1,
uint64_t arg2,
uint64_t arg3,
@@ -163,7 +163,7 @@
uint64_t arg5,
uint64_t arg6,
uint64_t arg7);
-extern tsp_args *tsp_cpu_suspend_main(uint64_t arg0,
+extern tsp_args_t *tsp_cpu_suspend_main(uint64_t arg0,
uint64_t arg1,
uint64_t arg2,
uint64_t arg3,
@@ -179,7 +179,7 @@
uint64_t arg5,
uint64_t arg6,
uint64_t arg7);
-extern tsp_args *tsp_cpu_on_main(void);
+extern tsp_args_t *tsp_cpu_on_main(void);
extern void tsp_cpu_off_entry(uint64_t arg0,
uint64_t arg1,
uint64_t arg2,
@@ -188,7 +188,7 @@
uint64_t arg5,
uint64_t arg6,
uint64_t arg7);
-extern tsp_args *tsp_cpu_off_main(uint64_t arg0,
+extern tsp_args_t *tsp_cpu_off_main(uint64_t arg0,
uint64_t arg1,
uint64_t arg2,
uint64_t arg3,
diff --git a/include/asm_macros.S b/include/common/asm_macros.S
similarity index 99%
rename from include/asm_macros.S
rename to include/common/asm_macros.S
index 8bcb7d2..6cf1a19 100644
--- a/include/asm_macros.S
+++ b/include/common/asm_macros.S
@@ -28,6 +28,9 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+#include <arch.h>
+
+
.macro func_prologue
stp x29, x30, [sp, #-0x10]!
mov x29,sp
diff --git a/include/bl_common.h b/include/common/bl_common.h
similarity index 77%
rename from include/bl_common.h
rename to include/common/bl_common.h
index ba6dc11..9fba9c0 100644
--- a/include/bl_common.h
+++ b/include/common/bl_common.h
@@ -48,14 +48,6 @@
#define BOT_LOAD !TOP_LOAD
#define LOAD_MASK (1 << 0)
-/*******************************************************************************
- * Macro to flag a compile time assertion. It uses the preprocessor to generate
- * an invalid C construct if 'cond' evaluates to false.
- * The following compilation error is triggered if the assertion fails:
- * "error: size of array 'msg' is negative"
- ******************************************************************************/
-#define CASSERT(cond, msg) typedef char msg[(cond) ? 1 : -1]
-
/******************************************************************************
* Opcode passed in x0 to tell next EL that we want to run an image.
* Corresponds to the function ID of the only SMC that the BL1 exception
@@ -66,22 +58,23 @@
#ifndef __ASSEMBLY__
-#include <stdio.h>
+
+#include <cdefs.h> /* For __dead2 */
/*******************************************************************************
* Structure used for telling the next BL how much of a particular type of
* memory is available for its use and how much is already used.
******************************************************************************/
-typedef struct {
+typedef struct meminfo {
unsigned long total_base;
long total_size;
unsigned long free_base;
long free_size;
unsigned long attr;
unsigned long next;
-} meminfo;
+} meminfo_t;
-typedef struct {
+typedef struct aapcs64_params {
unsigned long arg0;
unsigned long arg1;
unsigned long arg2;
@@ -90,56 +83,59 @@
unsigned long arg5;
unsigned long arg6;
unsigned long arg7;
-} aapcs64_params;
+} aapcs64_params_t;
/*******************************************************************************
* This structure represents the superset of information needed while switching
* exception levels. The only two mechanisms to do so are ERET & SMC. In case of
* SMC all members apart from 'aapcs64_params' will be ignored.
******************************************************************************/
-typedef struct {
+typedef struct el_change_info {
unsigned long entrypoint;
unsigned long spsr;
unsigned long security_state;
- aapcs64_params args;
-} el_change_info;
+ aapcs64_params_t args;
+} el_change_info_t;
/*******************************************************************************
* This structure represents the superset of information that can be passed to
* BL31 e.g. while passing control to it from BL2. The BL32 parameters will be
* populated only if BL2 detects its presence.
******************************************************************************/
-typedef struct {
- meminfo bl31_meminfo;
- el_change_info bl32_image_info;
- meminfo bl32_meminfo;
- el_change_info bl33_image_info;
- meminfo bl33_meminfo;
-} bl31_args;
+typedef struct bl31_args {
+ meminfo_t bl31_meminfo;
+ el_change_info_t bl32_image_info;
+ meminfo_t bl32_meminfo;
+ el_change_info_t bl33_image_info;
+ meminfo_t bl33_meminfo;
+} bl31_args_t;
/*******************************************************************************
* Function & variable prototypes
******************************************************************************/
extern unsigned long page_align(unsigned long, unsigned);
extern void change_security_state(unsigned int);
-extern void __dead2 drop_el(aapcs64_params *, unsigned long, unsigned long);
-extern void __dead2 raise_el(aapcs64_params *);
-extern void __dead2 change_el(el_change_info *);
+extern void __dead2 drop_el(aapcs64_params_t *, unsigned long, unsigned long);
+extern void __dead2 raise_el(aapcs64_params_t *);
+extern void __dead2 change_el(el_change_info_t *);
extern unsigned long make_spsr(unsigned long, unsigned long, unsigned long);
-extern void init_bl2_mem_layout(meminfo *,
- meminfo *,
- unsigned int,
- unsigned long) __attribute__((weak));
-extern void init_bl31_mem_layout(const meminfo *,
- meminfo *,
- unsigned int) __attribute__((weak));
+extern void init_bl2_mem_layout(meminfo_t *,
+ meminfo_t *,
+ unsigned int,
+ unsigned long) __attribute__((weak));
+extern void init_bl31_mem_layout(const meminfo_t *,
+ meminfo_t *,
+ unsigned int) __attribute__((weak));
extern unsigned long image_size(const char *);
-extern unsigned long load_image(meminfo *, const char *, unsigned int, unsigned long);
+extern unsigned long load_image(meminfo_t *,
+ const char *,
+ unsigned int,
+ unsigned long);
extern void __dead2 run_image(unsigned long entrypoint,
- unsigned long spsr,
- unsigned long security_state,
- void *first_arg,
- void *second_arg);
+ unsigned long spsr,
+ unsigned long security_state,
+ void *first_arg,
+ void *second_arg);
extern unsigned long *get_el_change_mem_ptr(void);
extern const char build_message[];
diff --git a/include/debug.h b/include/common/debug.h
similarity index 96%
rename from include/debug.h
rename to include/common/debug.h
index f829477..e4fa31e 100644
--- a/include/debug.h
+++ b/include/common/debug.h
@@ -31,9 +31,6 @@
#ifndef __DEBUG_H__
#define __DEBUG_H__
-/* Do not try to call this from ASM code. */
-#ifndef __ASSEMBLY__
-
#include <stdio.h>
/* If building the project with DEBUG disabled the INFO and WARN macros
@@ -66,5 +63,4 @@
;
}
-#endif /* __ASSEMBLY__ */
#endif /* __DEBUG_H__ */
diff --git a/include/firmware_image_package.h b/include/common/firmware_image_package.h
similarity index 95%
rename from include/firmware_image_package.h
rename to include/common/firmware_image_package.h
index ff5e971..f4554ec 100644
--- a/include/firmware_image_package.h
+++ b/include/common/firmware_image_package.h
@@ -50,17 +50,17 @@
#define UUID_NON_TRUSTED_FIRMWARE_BL33 \
{0xa7eed0d6, 0xeafc, 0x4bd5, 0x97, 0x82, {0x99, 0x34, 0xf2, 0x34, 0xb6, 0xe4} }
-typedef struct {
+typedef struct fip_toc_header {
uint32_t name;
uint32_t serial_number;
uint64_t flags;
-} fip_toc_header;
+} fip_toc_header_t;
-typedef struct {
+typedef struct fip_toc_entry {
uuid_t uuid;
uint64_t offset_address;
uint64_t size;
uint64_t flags;
-} fip_toc_entry;
+} fip_toc_entry_t;
#endif /* __FIRMWARE_IMAGE_PACKAGE_H__ */
diff --git a/drivers/arm/interconnect/cci-400/cci400.h b/include/drivers/arm/cci400.h
similarity index 100%
rename from drivers/arm/interconnect/cci-400/cci400.h
rename to include/drivers/arm/cci400.h
diff --git a/arch/system/gic/gic.h b/include/drivers/arm/gic_v2.h
similarity index 66%
rename from arch/system/gic/gic.h
rename to include/drivers/arm/gic_v2.h
index 3266043..ccf3d32 100644
--- a/arch/system/gic/gic.h
+++ b/include/drivers/arm/gic_v2.h
@@ -28,10 +28,11 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef __GIC_H__
-#define __GIC_H__
+#ifndef __GIC_V2_H__
+#define __GIC_V2_H__
-#define MAX_SPIS 480
+
+#define GIC400_NUM_SPIS 480
#define MAX_PPIS 14
#define MAX_SGIS 16
@@ -131,31 +132,13 @@
#define GICV_HIGHESTPEND 0x18
#define GICV_DEACTIVATE 0x1000
-/* GICv3 Re-distributor interface registers & shifts */
-#define GICR_PCPUBASE_SHIFT 0x11
-#define GICR_TYPER 0x08
-#define GICR_WAKER 0x14
-
-/* GICR_WAKER bit definitions */
-#define WAKER_CA (1UL << 2)
-#define WAKER_PS (1UL << 1)
-
-/* GICR_TYPER bit definitions */
-#define GICR_TYPER_AFF_SHIFT 32
-#define GICR_TYPER_AFF_MASK 0xffffffff
-#define GICR_TYPER_LAST (1UL << 4)
-
-/* GICv3 ICC_SRE register bit definitions*/
-#define ICC_SRE_EN (1UL << 3)
-#define ICC_SRE_SRE (1UL << 0)
-
#ifndef __ASSEMBLY__
-#include <gic_v2.h>
-#include <gic_v3.h>
+#include <mmio.h>
+
/*******************************************************************************
- * Function prototypes
+ * GIC Distributor function prototypes
******************************************************************************/
extern unsigned int gicd_read_igroupr(unsigned int, unsigned int);
@@ -194,17 +177,127 @@
extern void gicd_set_ipriorityr(unsigned int, unsigned int, unsigned int);
extern void gicd_set_itargetsr(unsigned int, unsigned int, unsigned int);
-/* GICv3 functions */
-extern unsigned int read_icc_sre_el1(void);
-extern unsigned int read_icc_sre_el2(void);
-extern unsigned int read_icc_sre_el3(void);
-extern void write_icc_sre_el1(unsigned int);
-extern void write_icc_sre_el2(unsigned int);
-extern void write_icc_sre_el3(unsigned int);
-extern void write_icc_pmr_el1(unsigned int);
+/*******************************************************************************
+ * GIC Distributor interface accessors for reading entire registers
+ ******************************************************************************/
-#endif /*__ASSEMBLY__*/
+static inline unsigned int gicd_read_ctlr(unsigned int base)
+{
+ return mmio_read_32(base + GICD_CTLR);
+}
+
+static inline unsigned int gicd_read_typer(unsigned int base)
+{
+ return mmio_read_32(base + GICD_TYPER);
+}
+
+static inline unsigned int gicd_read_sgir(unsigned int base)
+{
+ return mmio_read_32(base + GICD_SGIR);
+}
+
+
+/*******************************************************************************
+ * GIC Distributor interface accessors for writing entire registers
+ ******************************************************************************/
+
+static inline void gicd_write_ctlr(unsigned int base, unsigned int val)
+{
+ mmio_write_32(base + GICD_CTLR, val);
+}
+
+static inline void gicd_write_sgir(unsigned int base, unsigned int val)
+{
+ mmio_write_32(base + GICD_SGIR, val);
+}
+
+
+/*******************************************************************************
+ * GIC CPU interface accessors for reading entire registers
+ ******************************************************************************/
-#endif /* __GIC_H__ */
+static inline unsigned int gicc_read_ctlr(unsigned int base)
+{
+ return mmio_read_32(base + GICC_CTLR);
+}
+
+static inline unsigned int gicc_read_pmr(unsigned int base)
+{
+ return mmio_read_32(base + GICC_PMR);
+}
+
+static inline unsigned int gicc_read_BPR(unsigned int base)
+{
+ return mmio_read_32(base + GICC_BPR);
+}
+
+static inline unsigned int gicc_read_IAR(unsigned int base)
+{
+ return mmio_read_32(base + GICC_IAR);
+}
+
+static inline unsigned int gicc_read_EOIR(unsigned int base)
+{
+ return mmio_read_32(base + GICC_EOIR);
+}
+
+static inline unsigned int gicc_read_hppir(unsigned int base)
+{
+ return mmio_read_32(base + GICC_HPPIR);
+}
+
+static inline unsigned int gicc_read_dir(unsigned int base)
+{
+ return mmio_read_32(base + GICC_DIR);
+}
+
+static inline unsigned int gicc_read_iidr(unsigned int base)
+{
+ return mmio_read_32(base + GICC_IIDR);
+}
+
+
+/*******************************************************************************
+ * GIC CPU interface accessors for writing entire registers
+ ******************************************************************************/
+
+static inline void gicc_write_ctlr(unsigned int base, unsigned int val)
+{
+ mmio_write_32(base + GICC_CTLR, val);
+}
+
+static inline void gicc_write_pmr(unsigned int base, unsigned int val)
+{
+ mmio_write_32(base + GICC_PMR, val);
+}
+
+static inline void gicc_write_BPR(unsigned int base, unsigned int val)
+{
+ mmio_write_32(base + GICC_BPR, val);
+}
+
+
+static inline void gicc_write_IAR(unsigned int base, unsigned int val)
+{
+ mmio_write_32(base + GICC_IAR, val);
+}
+
+static inline void gicc_write_EOIR(unsigned int base, unsigned int val)
+{
+ mmio_write_32(base + GICC_EOIR, val);
+}
+
+static inline void gicc_write_hppir(unsigned int base, unsigned int val)
+{
+ mmio_write_32(base + GICC_HPPIR, val);
+}
+
+static inline void gicc_write_dir(unsigned int base, unsigned int val)
+{
+ mmio_write_32(base + GICC_DIR, val);
+}
+
+#endif /*__ASSEMBLY__*/
+#endif /* __GIC_V2_H__ */
diff --git a/arch/system/gic/gic_v3.h b/include/drivers/arm/gic_v3.h
similarity index 67%
rename from arch/system/gic/gic_v3.h
rename to include/drivers/arm/gic_v3.h
index df7e7fd..6f072a3 100644
--- a/arch/system/gic/gic_v3.h
+++ b/include/drivers/arm/gic_v3.h
@@ -31,9 +31,31 @@
#ifndef __GIC_V3_H__
#define __GIC_V3_H__
-#include <stdint.h>
#include <mmio.h>
+#include <stdint.h>
+
+
+/* GICv3 Re-distributor interface registers & shifts */
+#define GICR_PCPUBASE_SHIFT 0x11
+#define GICR_TYPER 0x08
+#define GICR_WAKER 0x14
+/* GICR_WAKER bit definitions */
+#define WAKER_CA (1UL << 2)
+#define WAKER_PS (1UL << 1)
+
+/* GICR_TYPER bit definitions */
+#define GICR_TYPER_AFF_SHIFT 32
+#define GICR_TYPER_AFF_MASK 0xffffffff
+#define GICR_TYPER_LAST (1UL << 4)
+
+/* GICv3 ICC_SRE register bit definitions*/
+#define ICC_SRE_EN (1UL << 3)
+#define ICC_SRE_SRE (1UL << 0)
+
+/*******************************************************************************
+ * GICv3 defintions
+ ******************************************************************************/
#define GICV3_AFFLVL_MASK 0xff
#define GICV3_AFF0_SHIFT 0
#define GICV3_AFF1_SHIFT 8
@@ -41,8 +63,19 @@
#define GICV3_AFF3_SHIFT 24
#define GICV3_AFFINITY_MASK 0xffffffff
+/*******************************************************************************
+ * Function prototypes
+ ******************************************************************************/
uintptr_t gicv3_get_rdist(uintptr_t gicr_base, uint64_t mpidr);
+extern unsigned int read_icc_sre_el1(void);
+extern unsigned int read_icc_sre_el2(void);
+extern unsigned int read_icc_sre_el3(void);
+extern void write_icc_sre_el1(unsigned int);
+extern void write_icc_sre_el2(unsigned int);
+extern void write_icc_sre_el3(unsigned int);
+extern void write_icc_pmr_el1(unsigned int);
+
/*******************************************************************************
* GIC Redistributor interface accessors
******************************************************************************/
diff --git a/drivers/arm/peripherals/pl011/pl011.h b/include/drivers/arm/pl011.h
similarity index 99%
rename from drivers/arm/peripherals/pl011/pl011.h
rename to include/drivers/arm/pl011.h
index 5ad2fc7..28aef54 100644
--- a/drivers/arm/peripherals/pl011/pl011.h
+++ b/include/drivers/arm/pl011.h
@@ -31,6 +31,9 @@
#ifndef __PL011_H__
#define __PL011_H__
+#include <mmio.h>
+
+
/* PL011 Registers */
#define UARTDR 0x000
#define UARTRSR 0x004
diff --git a/drivers/arm/interconnect/tzc-400/tzc400.h b/include/drivers/arm/tzc400.h
similarity index 92%
rename from drivers/arm/interconnect/tzc-400/tzc400.h
rename to include/drivers/arm/tzc400.h
index 7eaafd2..b4aa3ba 100644
--- a/drivers/arm/interconnect/tzc-400/tzc400.h
+++ b/include/drivers/arm/tzc400.h
@@ -147,8 +147,6 @@
/* Filters are bit mapped 0 to 3. */
#define TZC400_COMPONENT_ID 0xb105f00d
-#ifndef __ASSEMBLY__
-
/*******************************************************************************
* Function & variable prototypes
******************************************************************************/
@@ -165,23 +163,23 @@
* TZC_ACTION_ERR_INT - Raise interrupt, raise exception -> sync
* external data abort
*/
-enum tzc_action {
+typedef enum {
TZC_ACTION_NONE = 0,
TZC_ACTION_ERR = 1,
TZC_ACTION_INT = 2,
TZC_ACTION_ERR_INT = (TZC_ACTION_ERR | TZC_ACTION_INT)
-};
+} tzc_action_t;
/*
* Controls secure access to a region. If not enabled secure access is not
* allowed to region.
*/
-enum tzc_region_attributes {
+typedef enum {
TZC_REGION_S_NONE = 0,
TZC_REGION_S_RD = 1,
TZC_REGION_S_WR = 2,
TZC_REGION_S_RDWR = (TZC_REGION_S_RD | TZC_REGION_S_WR)
-};
+} tzc_region_attributes_t;
/*
* Implementation defined values used to validate inputs later.
@@ -189,23 +187,21 @@
* Regions : max of 9 ; 0 to 8
* Address width : Values between 32 to 64
*/
-struct tzc_instance {
+typedef struct tzc_instance {
uint64_t base;
uint32_t aid_width;
uint8_t addr_width;
uint8_t num_filters;
uint8_t num_regions;
-};
+} tzc_instance_t ;
-void tzc_init(struct tzc_instance *controller);
-void tzc_configure_region(const struct tzc_instance *controller, uint32_t filters,
+void tzc_init(tzc_instance_t *controller);
+void tzc_configure_region(const tzc_instance_t *controller, uint32_t filters,
uint8_t region, uint64_t region_base, uint64_t region_top,
- enum tzc_region_attributes sec_attr, uint32_t ns_device_access);
-void tzc_enable_filters(const struct tzc_instance *controller);
-void tzc_disable_filters(const struct tzc_instance *controller);
-void tzc_set_action(const struct tzc_instance *controller,
- enum tzc_action action);
+ tzc_region_attributes_t sec_attr, uint32_t ns_device_access);
+void tzc_enable_filters(const tzc_instance_t *controller);
+void tzc_disable_filters(const tzc_instance_t *controller);
+void tzc_set_action(const tzc_instance_t *controller, tzc_action_t action);
-#endif /*__ASSEMBLY__*/
#endif /* __TZC400__ */
diff --git a/drivers/console/console.h b/include/drivers/console.h
similarity index 100%
rename from drivers/console/console.h
rename to include/drivers/console.h
diff --git a/drivers/io/io_driver.h b/include/drivers/io_driver.h
similarity index 70%
rename from drivers/io/io_driver.h
rename to include/drivers/io_driver.h
index 82dbbf1..cc01d3b 100644
--- a/drivers/io/io_driver.h
+++ b/include/drivers/io_driver.h
@@ -31,63 +31,65 @@
#ifndef __IO_DRIVER_H__
#define __IO_DRIVER_H__
-#include "platform.h" /* For MAX_IO_DEVICES */
+#include <io_storage.h>
+#include <platform.h> /* For MAX_IO_DEVICES */
+#include <stdint.h>
/* Generic IO entity structure,representing an accessible IO construct on the
* device, such as a file */
-struct io_entity {
+typedef struct io_entity {
io_dev_handle dev_handle;
uintptr_t info;
-};
+} io_entity_t;
/* Device info structure, providing device-specific functions and a means of
* adding driver-specific state */
-struct io_dev_info {
+typedef struct io_dev_info {
struct io_dev_funcs *funcs;
uintptr_t info;
-};
+} io_dev_info_t;
/* Structure used to create a connection to a type of device */
-struct io_dev_connector {
+typedef struct io_dev_connector {
/* dev_open opens a connection to a particular device driver */
- int (*dev_open)(void *spec, struct io_dev_info **dev_info);
-};
+ int (*dev_open)(void *spec, io_dev_info_t **dev_info);
+} io_dev_connector_t;
/* Structure to hold device driver function pointers */
-struct io_dev_funcs {
- io_type (*type)(void);
- int (*open)(struct io_dev_info *dev_info, const void *spec,
- struct io_entity *entity);
- int (*seek)(struct io_entity *entity, int mode, ssize_t offset);
- int (*size)(struct io_entity *entity, size_t *length);
- int (*read)(struct io_entity *entity, void *buffer, size_t length,
+typedef struct io_dev_funcs {
+ io_type_t (*type)(void);
+ int (*open)(io_dev_info_t *dev_info, const void *spec,
+ io_entity_t *entity);
+ int (*seek)(io_entity_t *entity, int mode, ssize_t offset);
+ int (*size)(io_entity_t *entity, size_t *length);
+ int (*read)(io_entity_t *entity, void *buffer, size_t length,
size_t *length_read);
- int (*write)(struct io_entity *entity, const void *buffer,
+ int (*write)(io_entity_t *entity, const void *buffer,
size_t length, size_t *length_written);
- int (*close)(struct io_entity *entity);
- int (*dev_init)(struct io_dev_info *dev_info, const void *init_params);
- int (*dev_close)(struct io_dev_info *dev_info);
-};
+ int (*close)(io_entity_t *entity);
+ int (*dev_init)(io_dev_info_t *dev_info, const void *init_params);
+ int (*dev_close)(io_dev_info_t *dev_info);
+} io_dev_funcs_t;
/* IO platform data - used to track devices registered for a specific
* platform */
-struct io_plat_data {
- struct io_dev_info *devices[MAX_IO_DEVICES];
+typedef struct io_plat_data {
+ io_dev_info_t *devices[MAX_IO_DEVICES];
unsigned int dev_count;
-};
+} io_plat_data_t;
/* Operations intended to be performed during platform initialisation */
/* Initialise the IO layer */
-void io_init(struct io_plat_data *data);
+void io_init(io_plat_data_t *data);
/* Register a device driver */
-int io_register_device(struct io_dev_info *dev_info);
+int io_register_device(io_dev_info_t *dev_info);
#endif /* __IO_DRIVER_H__ */
diff --git a/drivers/io/io_fip.h b/include/drivers/io_fip.h
similarity index 98%
rename from drivers/io/io_fip.h
rename to include/drivers/io_fip.h
index 56dd1e0..212570d 100644
--- a/drivers/io/io_fip.h
+++ b/include/drivers/io_fip.h
@@ -31,6 +31,8 @@
#ifndef __IO_FIP_H__
#define __IO_FIP_H__
+struct io_dev_connector;
+
int register_io_dev_fip(struct io_dev_connector **dev_con);
#endif /* __IO_FIP_H__ */
diff --git a/drivers/io/io_memmap.h b/include/drivers/io_memmap.h
similarity index 98%
rename from drivers/io/io_memmap.h
rename to include/drivers/io_memmap.h
index 5fa7bc9..0e59ecb 100644
--- a/drivers/io/io_memmap.h
+++ b/include/drivers/io_memmap.h
@@ -31,6 +31,8 @@
#ifndef __IO_MEMMAP_H__
#define __IO_MEMMAP_H__
+struct io_dev_connector;
+
int register_io_dev_memmap(struct io_dev_connector **dev_con);
#endif /* __IO_MEMMAP_H__ */
diff --git a/drivers/io/io_semihosting.h b/include/drivers/io_semihosting.h
similarity index 97%
rename from drivers/io/io_semihosting.h
rename to include/drivers/io_semihosting.h
index 7dc632d..eab290a 100644
--- a/drivers/io/io_semihosting.h
+++ b/include/drivers/io_semihosting.h
@@ -31,6 +31,8 @@
#ifndef __IO_SH_H__
#define __IO_SH_H__
+struct io_dev_connector;
+
int register_io_dev_sh(struct io_dev_connector **dev_con);
#endif /* __IO_SH_H__ */
diff --git a/include/aarch64/arch.h b/include/lib/aarch64/arch.h
similarity index 95%
rename from include/aarch64/arch.h
rename to include/lib/aarch64/arch.h
index a41e82b..d7e65b3 100644
--- a/include/aarch64/arch.h
+++ b/include/lib/aarch64/arch.h
@@ -31,7 +31,6 @@
#ifndef __ARCH_H__
#define __ARCH_H__
-#include <bl_common.h>
/*******************************************************************************
* MIDR bit definitions
@@ -330,16 +329,4 @@
#define EC_BITS(x) (x >> ESR_EC_SHIFT) & ESR_EC_MASK
-#ifndef __ASSEMBLY__
-/*******************************************************************************
- * Function prototypes
- ******************************************************************************/
-
-extern void early_exceptions(void);
-extern void runtime_exceptions(void);
-extern void bl1_arch_setup(void);
-extern void bl2_arch_setup(void);
-extern void bl31_arch_setup(void);
-#endif /*__ASSEMBLY__*/
-
#endif /* __ARCH_H__ */
diff --git a/include/aarch64/arch_helpers.h b/include/lib/aarch64/arch_helpers.h
similarity index 98%
rename from include/aarch64/arch_helpers.h
rename to include/lib/aarch64/arch_helpers.h
index f55c003..565b1b4 100644
--- a/include/aarch64/arch_helpers.h
+++ b/include/lib/aarch64/arch_helpers.h
@@ -31,10 +31,8 @@
#ifndef __ARCH_HELPERS_H__
#define __ARCH_HELPERS_H__
-#include <arch.h>
+#include <cdefs.h> /* For __dead2 */
-#ifndef __ASSEMBLY__
-#include <stdio.h>
/*******************************************************************************
* Aarch64 translation tables manipulation helper prototypes
@@ -268,6 +266,5 @@
extern void write_cptr_el2(unsigned long);
extern void write_cptr_el3(unsigned long);
-#endif /*__ASSEMBLY__*/
#endif /* __ARCH_HELPERS_H__ */
diff --git a/include/aarch64/xlat_tables.h b/include/lib/aarch64/xlat_tables.h
similarity index 94%
rename from include/aarch64/xlat_tables.h
rename to include/lib/aarch64/xlat_tables.h
index 01b1afe..d7e1c60 100644
--- a/include/aarch64/xlat_tables.h
+++ b/include/lib/aarch64/xlat_tables.h
@@ -49,20 +49,20 @@
MT_SECURE = 0 << 2,
MT_NS = 1 << 2
-} mmap_attr;
+} mmap_attr_t;
/*
* Structure for specifying a single region of memory.
*/
-typedef struct {
+typedef struct mmap_region {
unsigned long base;
unsigned long size;
- mmap_attr attr;
-} mmap_region;
+ mmap_attr_t attr;
+} mmap_region_t;
extern void mmap_add_region(unsigned long base, unsigned long size,
unsigned attr);
-extern void mmap_add(const mmap_region *mm);
+extern void mmap_add(const mmap_region_t *mm);
extern void init_xlat_tables(void);
diff --git a/include/bakery_lock.h b/include/lib/bakery_lock.h
similarity index 85%
rename from include/bakery_lock.h
rename to include/lib/bakery_lock.h
index da5d9dd..e6744a5 100644
--- a/include/bakery_lock.h
+++ b/include/lib/bakery_lock.h
@@ -35,19 +35,17 @@
#define BAKERY_LOCK_MAX_CPUS PLATFORM_CORE_COUNT
-#ifndef __ASSEMBLY__
-typedef struct {
+typedef struct bakery_lock {
int owner;
volatile char entering[BAKERY_LOCK_MAX_CPUS];
volatile unsigned number[BAKERY_LOCK_MAX_CPUS];
-} bakery_lock;
+} bakery_lock_t;
#define NO_OWNER (-1)
-void bakery_lock_init(bakery_lock* bakery);
-void bakery_lock_get(unsigned long mpidr, bakery_lock* bakery);
-void bakery_lock_release(unsigned long mpidr, bakery_lock* bakery);
-int bakery_lock_try(unsigned long mpidr, bakery_lock* bakery);
-#endif /*__ASSEMBLY__*/
+void bakery_lock_init(bakery_lock_t *bakery);
+void bakery_lock_get(unsigned long mpidr, bakery_lock_t *bakery);
+void bakery_lock_release(unsigned long mpidr, bakery_lock_t *bakery);
+int bakery_lock_try(unsigned long mpidr, bakery_lock_t *bakery);
#endif /* __BAKERY_LOCK_H__ */
diff --git a/drivers/io/io_semihosting.h b/include/lib/cassert.h
similarity index 73%
copy from drivers/io/io_semihosting.h
copy to include/lib/cassert.h
index 7dc632d..0e5529d 100644
--- a/drivers/io/io_semihosting.h
+++ b/include/lib/cassert.h
@@ -28,9 +28,15 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef __IO_SH_H__
-#define __IO_SH_H__
+#ifndef __CASSERT_H__
+#define __CASSERT_H__
-int register_io_dev_sh(struct io_dev_connector **dev_con);
+/*******************************************************************************
+ * Macro to flag a compile time assertion. It uses the preprocessor to generate
+ * an invalid C construct if 'cond' evaluates to false.
+ * The following compilation error is triggered if the assertion fails:
+ * "error: size of array 'msg' is negative"
+ ******************************************************************************/
+#define CASSERT(cond, msg) typedef char msg[(cond) ? 1 : -1]
-#endif /* __IO_SH_H__ */
+#endif /* __CASSERT_H__ */
diff --git a/include/io_storage.h b/include/lib/io_storage.h
similarity index 93%
rename from include/io_storage.h
rename to include/lib/io_storage.h
index 04e63c3..b6c5f9f 100644
--- a/include/io_storage.h
+++ b/include/lib/io_storage.h
@@ -31,11 +31,8 @@
#ifndef __IO_H__
#define __IO_H__
-#ifndef __ASSEMBLY__
+#include <stdio.h> /* For ssize_t */
-#include <stdint.h>
-#include <stdio.h> /* For ssize_t */
-
/* Device type which can be used to enable policy decisions about which device
* to access */
@@ -45,7 +42,7 @@
IO_TYPE_MEMMAP,
IO_TYPE_FIRMWARE_IMAGE_PACKAGE,
IO_TYPE_MAX
-} io_type;
+} io_type_t;
/* Modes used when seeking data on a supported device */
@@ -55,7 +52,7 @@
IO_SEEK_END,
IO_SEEK_CUR,
IO_SEEK_MAX
-} io_seek_mode;
+} io_seek_mode_t;
/* Connector type, providing a means of identifying a device to open */
@@ -71,18 +68,18 @@
/* File specification - used to refer to data on a device supporting file-like
* entities */
-typedef struct {
+typedef struct io_file_spec {
const char *path;
unsigned int mode;
-} io_file_spec;
+} io_file_spec_t;
/* Block specification - used to refer to data on a device supporting
* block-like entities */
-typedef struct {
+typedef struct io_block_spec {
unsigned long offset;
size_t length;
-} io_block_spec;
+} io_block_spec_t;
/* Access modes used when accessing data on a device */
@@ -116,7 +113,7 @@
/* Synchronous operations */
int io_open(io_dev_handle dev_handle, const void *spec, io_handle *handle);
-int io_seek(io_handle handle, io_seek_mode mode, ssize_t offset);
+int io_seek(io_handle handle, io_seek_mode_t mode, ssize_t offset);
int io_size(io_handle handle, size_t *length);
@@ -128,5 +125,4 @@
int io_close(io_handle handle);
-#endif /* __ASSEMBLY__ */
#endif /* __IO_H__ */
diff --git a/include/mmio.h b/include/lib/mmio.h
similarity index 97%
rename from include/mmio.h
rename to include/lib/mmio.h
index c79c3f5..d3c2cae 100644
--- a/include/mmio.h
+++ b/include/lib/mmio.h
@@ -31,8 +31,6 @@
#ifndef __MMIO_H__
#define __MMIO_H__
-#ifndef __ASSEMBLY__
-
#include <stdint.h>
extern void mmio_write_8(uintptr_t addr, uint8_t value);
@@ -44,6 +42,4 @@
extern void mmio_write_64(uintptr_t addr, uint64_t value);
extern uint64_t mmio_read_64(uintptr_t addr);
-#endif /*__ASSEMBLY__*/
-
#endif /* __MMIO_H__ */
diff --git a/include/semihosting.h b/include/lib/semihosting.h
similarity index 98%
rename from include/semihosting.h
rename to include/lib/semihosting.h
index e688618..9d0b39f 100644
--- a/include/semihosting.h
+++ b/include/lib/semihosting.h
@@ -31,6 +31,9 @@
#ifndef __SEMIHOSTING_H__
#define __SEMIHOSTING_H__
+#include <stdio.h> /* For ssize_t */
+
+
#define SEMIHOSTING_SYS_OPEN 0x01
#define SEMIHOSTING_SYS_CLOSE 0x02
#define SEMIHOSTING_SYS_WRITE0 0x04
diff --git a/include/spinlock.h b/include/lib/spinlock.h
similarity index 98%
rename from include/spinlock.h
rename to include/lib/spinlock.h
index 94aaa1a..cb0bc3e 100644
--- a/include/spinlock.h
+++ b/include/lib/spinlock.h
@@ -31,7 +31,7 @@
#ifndef __SPINLOCK_H__
#define __SPINLOCK_H__
-typedef struct {
+typedef struct spinlock {
volatile unsigned int lock;
} spinlock_t;
diff --git a/include/pm.h b/include/pm.h
deleted file mode 100644
index bfdbf67..0000000
--- a/include/pm.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * Neither the name of ARM nor the names of its contributors may be used
- * to endorse or promote products derived from this software without specific
- * prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __PM_H__
-#define __PM_H__
-
-#ifndef __ASSEMBLY__
-
-/*******************************************************************************
- * Structure populated by platform specific code to export routines which
- * perform common low level pm functions
- ******************************************************************************/
-typedef struct {
- int (*cpu_on)(unsigned long);
- int (*cpu_off)(unsigned long);
- int (*cpu_suspend)(unsigned long);
- int (*affinity_info)(unsigned long, unsigned int);
-} pm_frontend_ops;
-
-/*******************************************************************************
- * Structure populated by a generic power management api implementation e.g.
- * psci to perform api specific bits after a cpu has been turned on.
- ******************************************************************************/
-typedef struct {
- unsigned long (*cpu_off_finisher)(unsigned long);
- unsigned long (*cpu_suspend_finisher)(unsigned long);
-} pm_backend_ops;
-
-/*******************************************************************************
- * Function & variable prototypes
- ******************************************************************************/
-extern pm_frontend_ops *get_pm_frontend_ops(void);
-extern pm_backend_ops *get_pm_backend_ops(void);
-extern void set_pm_frontend_ops(pm_frontend_ops *);
-extern void set_pm_backend_ops(pm_backend_ops *);
-
-#endif /*__ASSEMBLY__*/
-
-#endif /* __PM_H__ */
diff --git a/lib/arch/aarch64/cache_helpers.S b/lib/aarch64/cache_helpers.S
similarity index 99%
rename from lib/arch/aarch64/cache_helpers.S
rename to lib/aarch64/cache_helpers.S
index 2696d90..2649ad0 100644
--- a/lib/arch/aarch64/cache_helpers.S
+++ b/lib/aarch64/cache_helpers.S
@@ -28,7 +28,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <arch_helpers.h>
+#include <arch.h>
#include <asm_macros.S>
.globl dcisw
diff --git a/arch/aarch64/cpu/cpu_helpers.S b/lib/aarch64/cpu_helpers.S
similarity index 100%
rename from arch/aarch64/cpu/cpu_helpers.S
rename to lib/aarch64/cpu_helpers.S
diff --git a/lib/arch/aarch64/misc_helpers.S b/lib/aarch64/misc_helpers.S
similarity index 98%
rename from lib/arch/aarch64/misc_helpers.S
rename to lib/aarch64/misc_helpers.S
index e3b4ab5..e7b2331 100644
--- a/lib/arch/aarch64/misc_helpers.S
+++ b/lib/aarch64/misc_helpers.S
@@ -28,8 +28,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <arch_helpers.h>
-#include <runtime_svc.h>
+#include <arch.h>
#include <asm_macros.S>
.globl enable_irq
diff --git a/lib/arch/aarch64/sysreg_helpers.S b/lib/aarch64/sysreg_helpers.S
similarity index 99%
rename from lib/arch/aarch64/sysreg_helpers.S
rename to lib/aarch64/sysreg_helpers.S
index 8e816f0..61468f9 100644
--- a/lib/arch/aarch64/sysreg_helpers.S
+++ b/lib/aarch64/sysreg_helpers.S
@@ -28,7 +28,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <arch_helpers.h>
+#include <arch.h>
#include <asm_macros.S>
.globl read_vbar_el1
diff --git a/lib/arch/aarch64/tlb_helpers.S b/lib/aarch64/tlb_helpers.S
similarity index 98%
rename from lib/arch/aarch64/tlb_helpers.S
rename to lib/aarch64/tlb_helpers.S
index 4244974..ec1558b 100644
--- a/lib/arch/aarch64/tlb_helpers.S
+++ b/lib/aarch64/tlb_helpers.S
@@ -28,7 +28,6 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <arch_helpers.h>
#include <asm_macros.S>
.globl tlbialle1
diff --git a/lib/arch/aarch64/xlat_helpers.c b/lib/aarch64/xlat_helpers.c
similarity index 99%
rename from lib/arch/aarch64/xlat_helpers.c
rename to lib/aarch64/xlat_helpers.c
index 87d24ec..d401ffc 100644
--- a/lib/arch/aarch64/xlat_helpers.c
+++ b/lib/aarch64/xlat_helpers.c
@@ -28,9 +28,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <string.h>
-#include <assert.h>
#include <arch.h>
+#include <assert.h>
/*******************************************************************************
* Helper to create a level 1/2 table descriptor which points to a level 2/3
diff --git a/lib/arch/aarch64/xlat_tables.c b/lib/aarch64/xlat_tables.c
similarity index 94%
rename from lib/arch/aarch64/xlat_tables.c
rename to lib/aarch64/xlat_tables.c
index 33a8b6d..6e04f65 100644
--- a/lib/arch/aarch64/xlat_tables.c
+++ b/lib/aarch64/xlat_tables.c
@@ -61,14 +61,14 @@
* Array of all memory regions stored in order of ascending base address.
* The list is terminated by the first entry with size == 0.
*/
-static mmap_region mmap[MAX_MMAP_REGIONS + 1];
+static mmap_region_t mmap[MAX_MMAP_REGIONS + 1];
static void print_mmap(void)
{
#if DEBUG_XLAT_TABLE
debug_print("mmap:\n");
- mmap_region *mm = mmap;
+ mmap_region_t *mm = mmap;
while (mm->size) {
debug_print(" %010lx %10lx %x\n", mm->base, mm->size, mm->attr);
++mm;
@@ -79,8 +79,8 @@
void mmap_add_region(unsigned long base, unsigned long size, unsigned attr)
{
- mmap_region *mm = mmap;
- mmap_region *mm_last = mm + sizeof(mmap) / sizeof(mmap[0]) - 1;
+ mmap_region_t *mm = mmap;
+ mmap_region_t *mm_last = mm + sizeof(mmap) / sizeof(mmap[0]) - 1;
assert(IS_PAGE_ALIGNED(base));
assert(IS_PAGE_ALIGNED(size));
@@ -103,7 +103,7 @@
mm->attr = attr;
}
-void mmap_add(const mmap_region *mm)
+void mmap_add(const mmap_region_t *mm)
{
while (mm->size) {
mmap_add_region(mm->base, mm->size, mm->attr);
@@ -140,7 +140,7 @@
return desc;
}
-static int mmap_region_attr(mmap_region *mm, unsigned long base,
+static int mmap_region_attr(mmap_region_t *mm, unsigned long base,
unsigned long size)
{
int attr = mm->attr;
@@ -167,7 +167,7 @@
}
}
-static mmap_region *init_xlation_table(mmap_region *mm, unsigned long base,
+static mmap_region_t *init_xlation_table(mmap_region_t *mm, unsigned long base,
unsigned long *table, unsigned level)
{
unsigned level_size_shift = L1_XLAT_ADDRESS_SHIFT - (level - 1) *
diff --git a/lib/io_storage.c b/lib/io_storage.c
index aeb8edb..01ca1c6 100644
--- a/lib/io_storage.c
+++ b/lib/io_storage.c
@@ -28,11 +28,10 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-
-#include <stddef.h>
#include <assert.h>
-#include "io_storage.h"
-#include "io_driver.h"
+#include <io_driver.h>
+#include <io_storage.h>
+#include <stddef.h>
#define MAX_DEVICES(plat_data) \
@@ -40,24 +39,24 @@
/* Storage for a fixed maximum number of IO entities, definable by platform */
-static struct io_entity entity_pool[MAX_IO_HANDLES];
+static io_entity_t entity_pool[MAX_IO_HANDLES];
/* Simple way of tracking used storage - each entry is NULL or a pointer to an
* entity */
-static struct io_entity *entity_map[MAX_IO_HANDLES];
+static io_entity_t *entity_map[MAX_IO_HANDLES];
/* Track number of allocated entities */
static unsigned int entity_count;
/* Used to keep a reference to platform-specific data */
-static struct io_plat_data *platform_data;
+static io_plat_data_t *platform_data;
#if DEBUG /* Extra validation functions only used in debug builds */
/* Return a boolean value indicating whether a device connector is valid */
-static int is_valid_dev_connector(const struct io_dev_connector *dev_con)
+static int is_valid_dev_connector(const io_dev_connector_t *dev_con)
{
int result = (dev_con != NULL) && (dev_con->dev_open != NULL);
return result;
@@ -67,7 +66,7 @@
/* Return a boolean value indicating whether a device handle is valid */
static int is_valid_dev(io_dev_handle handle)
{
- const struct io_dev_info *dev = handle;
+ const io_dev_info_t *dev = handle;
int result = (dev != NULL) && (dev->funcs != NULL) &&
(dev->funcs->type != NULL) &&
(dev->funcs->type() < IO_TYPE_MAX);
@@ -78,14 +77,14 @@
/* Return a boolean value indicating whether an IO entity is valid */
static int is_valid_entity(io_handle handle)
{
- const struct io_entity *entity = handle;
+ const io_entity_t *entity = handle;
int result = (entity != NULL) && (is_valid_dev(entity->dev_handle));
return result;
}
/* Return a boolean value indicating whether a seek mode is valid */
-static int is_valid_seek_mode(io_seek_mode mode)
+static int is_valid_seek_mode(io_seek_mode_t mode)
{
return ((mode != IO_SEEK_INVALID) && (mode < IO_SEEK_MAX));
}
@@ -94,8 +93,8 @@
/* Open a connection to a specific device */
-static int dev_open(const struct io_dev_connector *dev_con, void *dev_spec,
- struct io_dev_info **dev_info)
+static int dev_open(const io_dev_connector_t *dev_con, void *dev_spec,
+ io_dev_info_t **dev_info)
{
int result = IO_FAIL;
assert(dev_info != NULL);
@@ -107,7 +106,7 @@
/* Set a handle to track an entity */
-static void set_handle(io_handle *handle, struct io_entity *entity)
+static void set_handle(io_handle *handle, io_entity_t *entity)
{
assert(handle != NULL);
*handle = entity;
@@ -217,7 +216,7 @@
assert(dev_handle != NULL);
assert(is_valid_dev(dev_handle));
- struct io_dev_info *dev = dev_handle;
+ io_dev_info_t *dev = dev_handle;
if (dev->funcs->dev_init != NULL) {
result = dev->funcs->dev_init(dev, init_params);
@@ -238,7 +237,7 @@
assert(dev_handle != NULL);
assert(is_valid_dev(dev_handle));
- struct io_dev_info *dev = dev_handle;
+ io_dev_info_t *dev = dev_handle;
if (dev->funcs->dev_close != NULL) {
result = dev->funcs->dev_close(dev);
@@ -261,8 +260,8 @@
assert((spec != NULL) && (handle != NULL));
assert(is_valid_dev(dev_handle));
- struct io_dev_info *dev = dev_handle;
- struct io_entity *entity;
+ io_dev_info_t *dev = dev_handle;
+ io_entity_t *entity;
result = allocate_entity(&entity);
@@ -281,14 +280,14 @@
/* Seek to a specific position in an IO entity */
-int io_seek(io_handle handle, io_seek_mode mode, ssize_t offset)
+int io_seek(io_handle handle, io_seek_mode_t mode, ssize_t offset)
{
int result = IO_FAIL;
assert(is_valid_entity(handle) && is_valid_seek_mode(mode));
- struct io_entity *entity = handle;
+ io_entity_t *entity = handle;
- struct io_dev_info *dev = entity->dev_handle;
+ io_dev_info_t *dev = entity->dev_handle;
if (dev->funcs->seek != NULL)
result = dev->funcs->seek(entity, mode, offset);
@@ -305,9 +304,9 @@
int result = IO_FAIL;
assert(is_valid_entity(handle) && (length != NULL));
- struct io_entity *entity = handle;
+ io_entity_t *entity = handle;
- struct io_dev_info *dev = entity->dev_handle;
+ io_dev_info_t *dev = entity->dev_handle;
if (dev->funcs->size != NULL)
result = dev->funcs->size(entity, length);
@@ -324,9 +323,9 @@
int result = IO_FAIL;
assert(is_valid_entity(handle) && (buffer != NULL));
- struct io_entity *entity = handle;
+ io_entity_t *entity = handle;
- struct io_dev_info *dev = entity->dev_handle;
+ io_dev_info_t *dev = entity->dev_handle;
if (dev->funcs->read != NULL)
result = dev->funcs->read(entity, buffer, length, length_read);
@@ -344,9 +343,9 @@
int result = IO_FAIL;
assert(is_valid_entity(handle) && (buffer != NULL));
- struct io_entity *entity = handle;
+ io_entity_t *entity = handle;
- struct io_dev_info *dev = entity->dev_handle;
+ io_dev_info_t *dev = entity->dev_handle;
if (dev->funcs->write != NULL) {
result = dev->funcs->write(entity, buffer, length,
@@ -364,9 +363,9 @@
int result = IO_FAIL;
assert(is_valid_entity(handle));
- struct io_entity *entity = handle;
+ io_entity_t *entity = handle;
- struct io_dev_info *dev = entity->dev_handle;
+ io_dev_info_t *dev = entity->dev_handle;
if (dev->funcs->close != NULL)
result = dev->funcs->close(entity);
diff --git a/lib/sync/locks/bakery/bakery_lock.c b/lib/locks/bakery/bakery_lock.c
similarity index 95%
rename from lib/sync/locks/bakery/bakery_lock.c
rename to lib/locks/bakery/bakery_lock.c
index ec08135..6d4ab87 100644
--- a/lib/sync/locks/bakery/bakery_lock.c
+++ b/lib/locks/bakery/bakery_lock.c
@@ -28,11 +28,10 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+#include <arch_helpers.h>
#include <assert.h>
-#include <string.h>
-
#include <bakery_lock.h>
-#include <arch_helpers.h>
+#include <string.h>
/*
* Functions in this file implement Bakery Algorithm for mutual exclusion.
@@ -59,14 +58,14 @@
#define assert_bakery_entry_valid(entry, bakery) do { \
assert(bakery); \
assert(entry < BAKERY_LOCK_MAX_CPUS); \
-} while(0)
+} while (0)
/* Convert a ticket to priority */
#define PRIORITY(t, pos) (((t) << 8) | (pos))
/* Initialize Bakery Lock to reset ownership and all ticket values */
-void bakery_lock_init(bakery_lock * bakery)
+void bakery_lock_init(bakery_lock_t *bakery)
{
assert(bakery);
@@ -77,7 +76,7 @@
/* Obtain a ticket for a given CPU */
-static unsigned int bakery_get_ticket(bakery_lock *bakery, unsigned int me)
+static unsigned int bakery_get_ticket(bakery_lock_t *bakery, unsigned int me)
{
unsigned int my_ticket, their_ticket;
unsigned int they;
@@ -124,7 +123,7 @@
* of others'. The CPU with the highest priority (lowest numerical value)
* acquires the lock
*/
-void bakery_lock_get(unsigned long mpidr, bakery_lock *bakery)
+void bakery_lock_get(unsigned long mpidr, bakery_lock_t *bakery)
{
unsigned int they, me;
unsigned int my_ticket, my_prio, their_ticket;
@@ -176,7 +175,7 @@
/* Release the lock and signal contenders */
-void bakery_lock_release(unsigned long mpidr, bakery_lock * bakery)
+void bakery_lock_release(unsigned long mpidr, bakery_lock_t *bakery)
{
unsigned int me = platform_get_core_pos(mpidr);
diff --git a/lib/sync/locks/exclusive/spinlock.S b/lib/locks/exclusive/spinlock.S
similarity index 100%
rename from lib/sync/locks/exclusive/spinlock.S
rename to lib/locks/exclusive/spinlock.S
diff --git a/lib/semihosting/semihosting.c b/lib/semihosting/semihosting.c
index d5b8524..1bce377 100644
--- a/lib/semihosting/semihosting.c
+++ b/lib/semihosting/semihosting.c
@@ -29,10 +29,9 @@
*/
#include <assert.h>
-#include <string.h>
#include <errno.h>
-#include <stdio.h>
#include <semihosting.h>
+#include <string.h>
#ifndef SEMIHOSTING_SUPPORTED
#define SEMIHOSTING_SUPPORTED 1
@@ -45,23 +44,23 @@
const char *file_name;
unsigned long mode;
size_t name_length;
-} smh_file_open_block;
+} smh_file_open_block_t;
typedef struct {
long handle;
void *buffer;
size_t length;
-} smh_file_read_write_block;
+} smh_file_read_write_block_t;
typedef struct {
long handle;
ssize_t location;
-} smh_file_seek_block;
+} smh_file_seek_block_t;
typedef struct {
char *command_line;
size_t command_length;
-} smh_system_block;
+} smh_system_block_t;
long semihosting_connection_supported(void)
{
@@ -70,7 +69,7 @@
long semihosting_file_open(const char *file_name, size_t mode)
{
- smh_file_open_block open_block;
+ smh_file_open_block_t open_block;
open_block.file_name = file_name;
open_block.mode = mode;
@@ -82,7 +81,7 @@
long semihosting_file_seek(long file_handle, ssize_t offset)
{
- smh_file_seek_block seek_block;
+ smh_file_seek_block_t seek_block;
long result;
seek_block.handle = file_handle;
@@ -99,7 +98,7 @@
long semihosting_file_read(long file_handle, size_t *length, void *buffer)
{
- smh_file_read_write_block read_block;
+ smh_file_read_write_block_t read_block;
long result = -EINVAL;
if ((length == NULL) || (buffer == NULL))
@@ -125,7 +124,7 @@
size_t *length,
const void *buffer)
{
- smh_file_read_write_block write_block;
+ smh_file_read_write_block_t write_block;
if ((length == NULL) || (buffer == NULL))
return -EINVAL;
@@ -169,7 +168,7 @@
long semihosting_system(char *command_line)
{
- smh_system_block system_block;
+ smh_system_block_t system_block;
system_block.command_line = command_line;
system_block.command_length = strlen(command_line);
diff --git a/plat/common/aarch64/platform_helpers.S b/plat/common/aarch64/platform_helpers.S
index 29268ba..7e20121 100644
--- a/plat/common/aarch64/platform_helpers.S
+++ b/plat/common/aarch64/platform_helpers.S
@@ -29,8 +29,8 @@
*/
#include <arch.h>
-#include <platform.h>
#include <asm_macros.S>
+#include <platform.h>
.weak platform_get_core_pos
diff --git a/plat/common/aarch64/platform_mp_stack.S b/plat/common/aarch64/platform_mp_stack.S
index 1438814..ebbf509 100644
--- a/plat/common/aarch64/platform_mp_stack.S
+++ b/plat/common/aarch64/platform_mp_stack.S
@@ -29,8 +29,8 @@
*/
#include <arch.h>
-#include <platform.h>
#include <asm_macros.S>
+#include <platform.h>
.local pcpu_dv_mem_stack
diff --git a/plat/common/aarch64/platform_up_stack.S b/plat/common/aarch64/platform_up_stack.S
index b321a4e..880793d 100644
--- a/plat/common/aarch64/platform_up_stack.S
+++ b/plat/common/aarch64/platform_up_stack.S
@@ -29,8 +29,8 @@
*/
#include <arch.h>
-#include <platform.h>
#include <asm_macros.S>
+#include <platform.h>
.local pcpu_dv_mem_stack
diff --git a/plat/fvp/aarch64/bl1_plat_helpers.S b/plat/fvp/aarch64/bl1_plat_helpers.S
index 15e3a21..92075ea 100644
--- a/plat/fvp/aarch64/bl1_plat_helpers.S
+++ b/plat/fvp/aarch64/bl1_plat_helpers.S
@@ -29,10 +29,10 @@
*/
#include <arch.h>
-#include <platform.h>
-#include <fvp_pwrc.h>
-#include <gic.h>
#include <asm_macros.S>
+#include <gic_v2.h>
+#include <platform.h>
+#include "../drivers/pwrc/fvp_pwrc.h"
.globl platform_get_entrypoint
.globl platform_cold_boot_init
diff --git a/plat/fvp/aarch64/plat_common.c b/plat/fvp/aarch64/plat_common.c
index dd362f0..c8e529d 100644
--- a/plat/fvp/aarch64/plat_common.c
+++ b/plat/fvp/aarch64/plat_common.c
@@ -28,9 +28,12 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <assert.h>
+#include <arch.h>
#include <arch_helpers.h>
-#include "debug.h"
+#include <assert.h>
+#include <bl_common.h>
+#include <debug.h>
+#include <mmio.h>
#include <platform.h>
#include <xlat_tables.h>
@@ -122,7 +125,7 @@
* This doesn't include TZRAM as the 'mem_layout' argument passed to to
* configure_mmu() will give the available subset of that,
*/
-const mmap_region fvp_mmap[] = {
+const mmap_region_t fvp_mmap[] = {
{ TZROM_BASE, TZROM_SIZE, MT_MEMORY | MT_RO | MT_SECURE },
{ TZDRAM_BASE, TZDRAM_SIZE, MT_MEMORY | MT_RW | MT_SECURE },
{ FLASH0_BASE, FLASH0_SIZE, MT_MEMORY | MT_RO | MT_SECURE },
@@ -140,7 +143,7 @@
/*******************************************************************************
* Setup the pagetables as per the platform memory map & initialize the mmu
*******************************************************************************/
-void configure_mmu(meminfo *mem_layout,
+void configure_mmu(meminfo_t *mem_layout,
unsigned long ro_start,
unsigned long ro_limit,
unsigned long coh_start,
diff --git a/plat/fvp/aarch64/plat_helpers.S b/plat/fvp/aarch64/plat_helpers.S
index ab826f4..0057903 100644
--- a/plat/fvp/aarch64/plat_helpers.S
+++ b/plat/fvp/aarch64/plat_helpers.S
@@ -29,8 +29,9 @@
*/
#include <arch.h>
-#include <platform.h>
#include <asm_macros.S>
+#include <bl_common.h>
+#include <platform.h>
.globl plat_report_exception
diff --git a/plat/fvp/bl1_plat_setup.c b/plat/fvp/bl1_plat_setup.c
index 67694f4..e92303d 100644
--- a/plat/fvp/bl1_plat_setup.c
+++ b/plat/fvp/bl1_plat_setup.c
@@ -28,12 +28,14 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <assert.h>
#include <arch_helpers.h>
-#include <platform.h>
+#include <assert.h>
+#include <bl_common.h>
#include <bl1.h>
#include <console.h>
#include <cci400.h>
+#include <mmio.h>
+#include <platform.h>
/*******************************************************************************
* Declarations of linker defined symbols which will help us find the layout
@@ -60,9 +62,9 @@
/* Data structure which holds the extents of the trusted SRAM for BL1*/
-static meminfo bl1_tzram_layout;
+static meminfo_t bl1_tzram_layout;
-meminfo *bl1_plat_sec_mem_layout(void)
+meminfo_t *bl1_plat_sec_mem_layout(void)
{
return &bl1_tzram_layout;
}
diff --git a/plat/fvp/bl2_plat_setup.c b/plat/fvp/bl2_plat_setup.c
index da6a485..a4960aa 100644
--- a/plat/fvp/bl2_plat_setup.c
+++ b/plat/fvp/bl2_plat_setup.c
@@ -28,12 +28,12 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <assert.h>
#include <arch_helpers.h>
-#include <platform.h>
-#include <bl2.h>
+#include <assert.h>
#include <bl_common.h>
+#include <bl2.h>
#include <console.h>
+#include <platform.h>
/*******************************************************************************
* Declarations of linker defined symbols which will help us find the layout
@@ -68,7 +68,7 @@
extern unsigned char **bl2_el_change_mem_ptr;
/* Data structure which holds the extents of the trusted SRAM for BL2 */
-static meminfo bl2_tzram_layout
+static meminfo_t bl2_tzram_layout
__attribute__ ((aligned(PLATFORM_CACHE_LINE_SIZE),
section("tzfw_coherent_mem")));
@@ -76,9 +76,9 @@
* Reference to structure which holds the arguments which need to be passed
* to BL31
******************************************************************************/
-static bl31_args *bl2_to_bl31_args;
+static bl31_args_t *bl2_to_bl31_args;
-meminfo *bl2_plat_sec_mem_layout(void)
+meminfo_t *bl2_plat_sec_mem_layout(void)
{
return &bl2_tzram_layout;
}
@@ -87,7 +87,7 @@
* This function returns a pointer to the memory that the platform has kept
* aside to pass all the information that BL31 could need.
******************************************************************************/
-bl31_args *bl2_get_bl31_args_ptr(void)
+bl31_args_t *bl2_get_bl31_args_ptr(void)
{
return bl2_to_bl31_args;
}
@@ -97,7 +97,7 @@
* in x0. This memory layout is sitting at the base of the free trusted SRAM.
* Copy it to a safe loaction before its reclaimed by later BL2 functionality.
******************************************************************************/
-void bl2_early_platform_setup(meminfo *mem_layout,
+void bl2_early_platform_setup(meminfo_t *mem_layout,
void *data)
{
/* Setup the BL2 memory layout */
@@ -137,10 +137,10 @@
* Ensure that the secure DRAM memory used for passing BL31 arguments
* does not overlap with the BL32_BASE.
*/
- assert (BL32_BASE > TZDRAM_BASE + sizeof(bl31_args));
+ assert (BL32_BASE > TZDRAM_BASE + sizeof(bl31_args_t));
/* Use the Trusted DRAM for passing args to BL31 */
- bl2_to_bl31_args = (bl31_args *) TZDRAM_BASE;
+ bl2_to_bl31_args = (bl31_args_t *) TZDRAM_BASE;
/* Populate the extents of memory available for loading BL33 */
bl2_to_bl31_args->bl33_meminfo.total_base = DRAM_BASE;
diff --git a/plat/fvp/bl31_plat_setup.c b/plat/fvp/bl31_plat_setup.c
index 9bf83eb..aa7b2d8 100644
--- a/plat/fvp/bl31_plat_setup.c
+++ b/plat/fvp/bl31_plat_setup.c
@@ -28,10 +28,14 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <platform.h>
#include <arch.h>
-#include <fvp_pwrc.h>
+#include <bl_common.h>
+#include <bl31.h>
#include <console.h>
+#include <mmio.h>
+#include <platform.h>
+#include <stddef.h>
+#include "drivers/pwrc/fvp_pwrc.h"
/*******************************************************************************
* Declarations of linker defined symbols which will help us find the layout
@@ -66,14 +70,14 @@
* Reference to structure which holds the arguments that have been passed to
* BL31 from BL2.
******************************************************************************/
-static bl31_args *bl2_to_bl31_args;
+static bl31_args_t *bl2_to_bl31_args;
-meminfo *bl31_plat_sec_mem_layout(void)
+meminfo_t *bl31_plat_sec_mem_layout(void)
{
return &bl2_to_bl31_args->bl31_meminfo;
}
-meminfo *bl31_plat_get_bl32_mem_layout(void)
+meminfo_t *bl31_plat_get_bl32_mem_layout(void)
{
return &bl2_to_bl31_args->bl32_meminfo;
}
@@ -84,9 +88,9 @@
* while BL32 corresponds to the secure image type. A NULL pointer is returned
* if the image does not exist.
******************************************************************************/
-el_change_info *bl31_get_next_image_info(uint32_t type)
+el_change_info_t *bl31_get_next_image_info(uint32_t type)
{
- el_change_info *next_image_info;
+ el_change_info_t *next_image_info;
next_image_info = (type == NON_SECURE) ?
&bl2_to_bl31_args->bl33_image_info :
@@ -110,7 +114,7 @@
* has flushed this information to memory, so we are guaranteed to pick up good
* data
******************************************************************************/
-void bl31_early_platform_setup(bl31_args *from_bl2,
+void bl31_early_platform_setup(bl31_args_t *from_bl2,
void *data)
{
bl2_to_bl31_args = from_bl2;
diff --git a/plat/fvp/bl32_plat_setup.c b/plat/fvp/bl32_plat_setup.c
index ba418fd..b71800e 100644
--- a/plat/fvp/bl32_plat_setup.c
+++ b/plat/fvp/bl32_plat_setup.c
@@ -28,13 +28,11 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <string.h>
-#include <assert.h>
#include <arch_helpers.h>
-#include <platform.h>
-#include <bl32.h>
#include <bl_common.h>
+#include <bl32.h>
#include <console.h>
+#include <platform.h>
/*******************************************************************************
* Declarations of linker defined symbols which will help us find the layout
@@ -66,11 +64,11 @@
#define BL32_COHERENT_RAM_LIMIT (unsigned long)(&__COHERENT_RAM_END__)
/* Data structure which holds the extents of the trusted SRAM for BL32 */
-static meminfo bl32_tzdram_layout
+static meminfo_t bl32_tzdram_layout
__attribute__ ((aligned(PLATFORM_CACHE_LINE_SIZE),
section("tzfw_coherent_mem")));
-meminfo *bl32_plat_sec_mem_layout(void)
+meminfo_t *bl32_plat_sec_mem_layout(void)
{
return &bl32_tzdram_layout;
}
@@ -79,7 +77,7 @@
* BL1 has passed the extents of the trusted SRAM that's at BL32's disposal.
* Initialize the BL32 data structure with the memory extends
******************************************************************************/
-void bl32_early_platform_setup(meminfo *mem_layout,
+void bl32_early_platform_setup(meminfo_t *mem_layout,
void *data)
{
/* Setup the BL32 memory layout */
diff --git a/drivers/power/fvp_pwrc.c b/plat/fvp/drivers/pwrc/fvp_pwrc.c
similarity index 93%
rename from drivers/power/fvp_pwrc.c
rename to plat/fvp/drivers/pwrc/fvp_pwrc.c
index 3916c04..7a7f516 100644
--- a/drivers/power/fvp_pwrc.c
+++ b/plat/fvp/drivers/pwrc/fvp_pwrc.c
@@ -28,20 +28,15 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <string.h>
-#include <stdio.h>
-#include <errno.h>
-#include <assert.h>
-#include <arch_helpers.h>
-#include <platform.h>
-#include <fvp_pwrc.h>
#include <bakery_lock.h>
+#include <mmio.h>
+#include "fvp_pwrc.h"
/*
* TODO: Someday there will be a generic power controller api. At the moment
* each platform has its own pwrc so just exporting functions is fine.
*/
-static bakery_lock pwrc_lock __attribute__ ((section("tzfw_coherent_mem")));
+static bakery_lock_t pwrc_lock __attribute__ ((section("tzfw_coherent_mem")));
unsigned int fvp_pwrc_get_cpu_wkr(unsigned long mpidr)
{
diff --git a/drivers/power/fvp_pwrc.h b/plat/fvp/drivers/pwrc/fvp_pwrc.h
similarity index 100%
rename from drivers/power/fvp_pwrc.h
rename to plat/fvp/drivers/pwrc/fvp_pwrc.h
diff --git a/plat/fvp/plat_gic.c b/plat/fvp/plat_gic.c
index 8929172..8457af1 100644
--- a/plat/fvp/plat_gic.c
+++ b/plat/fvp/plat_gic.c
@@ -28,11 +28,12 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <stdint.h>
#include <arch_helpers.h>
-#include <platform.h>
-#include <gic.h>
#include <debug.h>
+#include <gic_v2.h>
+#include <gic_v3.h>
+#include <platform.h>
+#include <stdint.h>
/*******************************************************************************
diff --git a/plat/fvp/plat_io_storage.c b/plat/fvp/plat_io_storage.c
index 3c34f15..3727d26 100644
--- a/plat/fvp/plat_io_storage.c
+++ b/plat/fvp/plat_io_storage.c
@@ -29,51 +29,51 @@
*/
#include <assert.h>
+#include <debug.h>
+#include <io_driver.h>
+#include <io_fip.h>
+#include <io_memmap.h>
+#include <io_storage.h>
+#include <io_semihosting.h>
+#include <platform.h>
+#include <semihosting.h> /* For FOPEN_MODE_... */
#include <string.h>
-#include "platform.h"
-#include "io_storage.h"
-#include "io_driver.h"
-#include "io_semihosting.h"
-#include "semihosting.h" /* For FOPEN_MODE_... */
-#include "io_fip.h"
-#include "io_memmap.h"
-#include "debug.h"
/* IO devices */
-static struct io_plat_data io_data;
-static struct io_dev_connector *sh_dev_con;
+static io_plat_data_t io_data;
+static io_dev_connector_t *sh_dev_con;
static void *const sh_dev_spec;
static void *const sh_init_params;
static io_dev_handle sh_dev_handle;
-static struct io_dev_connector *fip_dev_con;
+static io_dev_connector_t *fip_dev_con;
static void *const fip_dev_spec;
static io_dev_handle fip_dev_handle;
-static struct io_dev_connector *memmap_dev_con;
+static io_dev_connector_t *memmap_dev_con;
static void *const memmap_dev_spec;
static void *const memmap_init_params;
static io_dev_handle memmap_dev_handle;
-static io_block_spec fip_block_spec = {
+static io_block_spec_t fip_block_spec = {
.offset = FLASH0_BASE,
.length = FLASH0_SIZE
};
-static io_file_spec bl2_file_spec = {
+static io_file_spec_t bl2_file_spec = {
.path = BL2_IMAGE_NAME,
.mode = FOPEN_MODE_RB
};
-static io_file_spec bl31_file_spec = {
+static io_file_spec_t bl31_file_spec = {
.path = BL31_IMAGE_NAME,
.mode = FOPEN_MODE_RB
};
-static io_file_spec bl32_file_spec = {
+static io_file_spec_t bl32_file_spec = {
.path = BL32_IMAGE_NAME,
.mode = FOPEN_MODE_RB
};
-static io_file_spec bl33_file_spec = {
+static io_file_spec_t bl33_file_spec = {
.path = BL33_IMAGE_NAME,
.mode = FOPEN_MODE_RB
};
@@ -194,7 +194,7 @@
if (strcmp(policy->image_name, image_name) == 0) {
result = policy->check(policy->image_spec);
if (result == IO_SUCCESS) {
- *(io_file_spec **)image_spec =
+ *(io_file_spec_t **)image_spec =
policy->image_spec;
*dev_handle = *(policy->dev_handle);
break;
@@ -203,7 +203,7 @@
policy->image_spec);
if (result == IO_SUCCESS) {
*dev_handle = sh_dev_handle;
- *(io_file_spec **)image_spec =
+ *(io_file_spec_t **)image_spec =
policy->image_spec;
}
}
diff --git a/plat/fvp/plat_pm.c b/plat/fvp/plat_pm.c
index 7b51476..c80d315 100644
--- a/plat/fvp/plat_pm.c
+++ b/plat/fvp/plat_pm.c
@@ -28,20 +28,14 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
#include <arch_helpers.h>
-#include <console.h>
-#include <platform.h>
-#include <bl_common.h>
-#include <bl31.h>
+#include <assert.h>
#include <bakery_lock.h>
#include <cci400.h>
-#include <gic.h>
-#include <fvp_pwrc.h>
-/* Only included for error codes */
+#include <mmio.h>
+#include <platform.h>
#include <psci.h>
+#include "drivers/pwrc/fvp_pwrc.h"
/*******************************************************************************
* FVP handler called when an affinity instance is about to enter standby.
@@ -78,7 +72,7 @@
{
int rc = PSCI_E_SUCCESS;
unsigned long linear_id;
- mailbox *fvp_mboxes;
+ mailbox_t *fvp_mboxes;
unsigned int psysr;
/*
@@ -100,7 +94,7 @@
} while (psysr & PSYSR_AFF_L0);
linear_id = platform_get_core_pos(mpidr);
- fvp_mboxes = (mailbox *) (TZDRAM_BASE + MBOX_OFF);
+ fvp_mboxes = (mailbox_t *) (TZDRAM_BASE + MBOX_OFF);
fvp_mboxes[linear_id].value = sec_entrypoint;
flush_dcache_range((unsigned long) &fvp_mboxes[linear_id],
sizeof(unsigned long));
@@ -209,7 +203,7 @@
int rc = PSCI_E_SUCCESS;
unsigned int gicc_base, ectlr;
unsigned long cpu_setup, cci_setup, linear_id;
- mailbox *fvp_mboxes;
+ mailbox_t *fvp_mboxes;
switch (afflvl) {
case MPIDR_AFFLVL1:
@@ -247,7 +241,7 @@
/* Program the jump address for the target cpu */
linear_id = platform_get_core_pos(mpidr);
- fvp_mboxes = (mailbox *) (TZDRAM_BASE + MBOX_OFF);
+ fvp_mboxes = (mailbox_t *) (TZDRAM_BASE + MBOX_OFF);
fvp_mboxes[linear_id].value = sec_entrypoint;
flush_dcache_range((unsigned long) &fvp_mboxes[linear_id],
sizeof(unsigned long));
@@ -288,7 +282,7 @@
{
int rc = PSCI_E_SUCCESS;
unsigned long linear_id, cpu_setup, cci_setup;
- mailbox *fvp_mboxes;
+ mailbox_t *fvp_mboxes;
unsigned int gicd_base, gicc_base, reg_val, ectlr;
switch (afflvl) {
@@ -341,7 +335,7 @@
fvp_pwrc_clr_wen(mpidr);
/* Zero the jump address in the mailbox for this cpu */
- fvp_mboxes = (mailbox *) (TZDRAM_BASE + MBOX_OFF);
+ fvp_mboxes = (mailbox_t *) (TZDRAM_BASE + MBOX_OFF);
linear_id = platform_get_core_pos(mpidr);
fvp_mboxes[linear_id].value = 0;
flush_dcache_range((unsigned long) &fvp_mboxes[linear_id],
@@ -394,7 +388,7 @@
/*******************************************************************************
* Export the platform handlers to enable psci to invoke them
******************************************************************************/
-static plat_pm_ops fvp_plat_pm_ops = {
+static plat_pm_ops_t fvp_plat_pm_ops = {
fvp_affinst_standby,
fvp_affinst_on,
fvp_affinst_off,
@@ -406,7 +400,7 @@
/*******************************************************************************
* Export the platform specific power ops & initialize the fvp power controller
******************************************************************************/
-int platform_setup_pm(plat_pm_ops **plat_ops)
+int platform_setup_pm(plat_pm_ops_t **plat_ops)
{
*plat_ops = &fvp_plat_pm_ops;
return 0;
diff --git a/plat/fvp/plat_security.c b/plat/fvp/plat_security.c
index a60eca3..32306cd 100644
--- a/plat/fvp/plat_security.c
+++ b/plat/fvp/plat_security.c
@@ -29,9 +29,9 @@
*/
#include <assert.h>
-#include "platform.h"
-#include "tzc400.h"
-#include "debug.h"
+#include <platform.h>
+#include <tzc400.h>
+#include <debug.h>
/* Used to improve readability for configuring regions. */
#define FILTER_SHIFT(filter) (1 << filter)
@@ -44,7 +44,7 @@
*/
void plat_security_setup(void)
{
- struct tzc_instance controller;
+ tzc_instance_t controller;
/*
* The Base FVP has a TrustZone address space controller, the Foundation
diff --git a/plat/fvp/plat_topology.c b/plat/fvp/plat_topology.c
index 0c8c525..04b409e 100644
--- a/plat/fvp/plat_topology.c
+++ b/plat/fvp/plat_topology.c
@@ -28,12 +28,11 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <string.h>
#include <assert.h>
#include <platform.h>
-#include <fvp_pwrc.h>
/* TODO: Reusing psci error codes & state information. Get our own! */
#include <psci.h>
+#include "drivers/pwrc/fvp_pwrc.h"
/* We treat '255' as an invalid affinity instance */
#define AFFINST_INVAL 0xff
@@ -46,20 +45,20 @@
* marks the absent affinity level instances as PSCI_AFF_ABSENT e.g. there is no
* cluster 1 on the Foundation FVP. The 'data' field is currently unused.
******************************************************************************/
-typedef struct {
+typedef struct affinity_info {
unsigned char sibling;
unsigned char child;
unsigned char state;
unsigned int data;
-} affinity_info;
+} affinity_info_t;
/*******************************************************************************
* The following two data structures store the topology tree for the fvp. There
* is a separate array for each affinity level i.e. cpus and clusters. The child
* and sibling references allow traversal inside and in between the two arrays.
******************************************************************************/
-static affinity_info fvp_aff1_topology_map[PLATFORM_CLUSTER_COUNT];
-static affinity_info fvp_aff0_topology_map[PLATFORM_CORE_COUNT];
+static affinity_info_t fvp_aff1_topology_map[PLATFORM_CLUSTER_COUNT];
+static affinity_info_t fvp_aff0_topology_map[PLATFORM_CORE_COUNT];
/* Simple global variable to safeguard us from stupidity */
static unsigned int topology_setup_done;
diff --git a/plat/fvp/platform.h b/plat/fvp/platform.h
index 01b995b..1ffdc98 100644
--- a/plat/fvp/platform.h
+++ b/plat/fvp/platform.h
@@ -32,10 +32,6 @@
#define __PLATFORM_H__
#include <arch.h>
-#include <mmio.h>
-#include <psci.h>
-#include <bl_common.h>
-#include "io_storage.h"
/*******************************************************************************
@@ -340,10 +336,20 @@
#ifndef __ASSEMBLY__
-typedef volatile struct {
+#include <stdint.h>
+
+
+typedef volatile struct mailbox {
unsigned long value
__attribute__((__aligned__(CACHE_WRITEBACK_GRANULE)));
-} mailbox;
+} mailbox_t;
+
+/*******************************************************************************
+ * Forward declarations
+ ******************************************************************************/
+struct plat_pm_ops;
+struct meminfo;
+struct io_dev_info;
/*******************************************************************************
* Function and variable prototypes
@@ -364,11 +370,11 @@
extern void bl1_plat_arch_setup(void);
extern void bl2_plat_arch_setup(void);
extern void bl31_plat_arch_setup(void);
-extern int platform_setup_pm(plat_pm_ops **);
+extern int platform_setup_pm(struct plat_pm_ops **);
extern unsigned int platform_get_core_pos(unsigned long mpidr);
extern void disable_mmu(void);
extern void enable_mmu(void);
-extern void configure_mmu(meminfo *,
+extern void configure_mmu(struct meminfo *,
unsigned long,
unsigned long,
unsigned long,
@@ -395,7 +401,7 @@
/* Declarations for plat_io_storage.c */
extern void io_setup(void);
extern int plat_get_image_source(const char *image_name,
- io_dev_handle *dev_handle, void **image_spec);
+ struct io_dev_info **dev_handle, void **image_spec);
/* Declarations for plat_security.c */
extern void plat_security_setup(void);
diff --git a/plat/fvp/platform.mk b/plat/fvp/platform.mk
index 0fc45de..ea72a31 100644
--- a/plat/fvp/platform.mk
+++ b/plat/fvp/platform.mk
@@ -28,74 +28,45 @@
# POSSIBILITY OF SUCH DAMAGE.
#
-PLAT_INCLUDES := -Idrivers/arm/interconnect/cci-400 \
- -Idrivers/arm/interconnect/tzc-400 \
- -Idrivers/console \
- -Idrivers/arm/peripherals/pl011 \
- -Idrivers/power
+#
+# No additional platform system include directories required
+#
+# PLAT_INCLUDES :=
-PLAT_BL1_C_VPATH := drivers/arm/interconnect/cci-400 \
- drivers/arm/peripherals/pl011 \
- lib/arch/${ARCH} \
- lib/semihosting \
- lib/stdlib \
- drivers/io
+PLAT_BL_COMMON_SOURCES := drivers/arm/pl011/pl011.c \
+ drivers/arm/pl011/pl011_console.c \
+ drivers/io/io_fip.c \
+ drivers/io/io_memmap.c \
+ drivers/io/io_semihosting.c \
+ lib/mmio.c \
+ lib/aarch64/sysreg_helpers.S \
+ lib/aarch64/xlat_tables.c \
+ lib/semihosting/semihosting.c \
+ lib/semihosting/aarch64/semihosting_call.S \
+ plat/fvp/plat_io_storage.c
-PLAT_BL1_S_VPATH := lib/semihosting/${ARCH}
+BL1_SOURCES += drivers/arm/cci400/cci400.c \
+ plat/common/aarch64/platform_up_stack.S \
+ plat/fvp/bl1_plat_setup.c \
+ plat/fvp/aarch64/bl1_plat_helpers.S \
+ plat/fvp/aarch64/plat_common.c \
+ plat/fvp/aarch64/plat_helpers.S
-PLAT_BL2_C_VPATH := drivers/arm/interconnect/cci-400 \
- drivers/arm/interconnect/tzc-400 \
- drivers/arm/peripherals/pl011 \
- lib/arch/${ARCH} \
- lib/stdlib \
- lib/semihosting \
- drivers/io
-
-PLAT_BL2_S_VPATH := lib/semihosting/${ARCH}
-
-PLAT_BL31_C_VPATH := drivers/arm/interconnect/cci-400 \
- drivers/arm/peripherals/pl011 \
- lib/arch/${ARCH} \
- lib/semihosting \
- lib/stdlib \
- drivers/power \
- drivers/io
-
-PLAT_BL31_S_VPATH := lib/semihosting/${ARCH}
-
-PLAT_BL_COMMON_SOURCES := semihosting_call.S \
- mmio.c \
- pl011_console.c \
- pl011.c \
- semihosting.c \
- sysreg_helpers.S \
- plat_io_storage.c \
- io_semihosting.c \
- io_fip.c \
- io_memmap.c \
- xlat_tables.c
-
-BL1_SOURCES += bl1_plat_setup.c \
- bl1_plat_helpers.S \
- plat_helpers.S \
- platform_up_stack.S \
- plat_common.c \
- cci400.c
-
-BL2_SOURCES += bl2_plat_setup.c \
- platform_up_stack.S \
- plat_common.c \
- plat_security.c \
- tzc400.c
+BL2_SOURCES += drivers/arm/tzc400/tzc400.c \
+ plat/common/aarch64/platform_up_stack.S \
+ plat/fvp/bl2_plat_setup.c \
+ plat/fvp/plat_security.c \
+ plat/fvp/aarch64/plat_common.c
-BL31_SOURCES += bl31_plat_setup.c \
- plat_helpers.S \
- platform_mp_stack.S \
- plat_common.c \
- plat_pm.c \
- plat_topology.c \
- plat_gic.c \
- fvp_pwrc.c \
- cci400.c \
- gic_v2.c \
- gic_v3.c
+BL31_SOURCES += drivers/arm/gic/gic_v2.c \
+ drivers/arm/gic/gic_v3.c \
+ drivers/arm/gic/aarch64/gic_v3_sysregs.S \
+ drivers/arm/cci400/cci400.c \
+ plat/common/aarch64/platform_mp_stack.S \
+ plat/fvp/bl31_plat_setup.c \
+ plat/fvp/plat_gic.c \
+ plat/fvp/plat_pm.c \
+ plat/fvp/plat_topology.c \
+ plat/fvp/aarch64/plat_helpers.S \
+ plat/fvp/aarch64/plat_common.c \
+ plat/fvp/drivers/pwrc/fvp_pwrc.c
diff --git a/services/spd/tspd/tspd.mk b/services/spd/tspd/tspd.mk
index bbf9f67..a32f4c4 100644
--- a/services/spd/tspd/tspd.mk
+++ b/services/spd/tspd/tspd.mk
@@ -29,16 +29,12 @@
#
TSPD_DIR := services/spd/tspd
-SPD_INCLUDES := -Iinclude/spd/tspd \
- -I${TSPD_DIR}
-
-SPD_SOURCES := tspd_common.c \
- tspd_main.c \
- tspd_pm.c \
- tspd_helpers.S
+SPD_INCLUDES := -Iinclude/bl32/payloads
-vpath %.c ${TSPD_DIR}
-vpath %.S ${TSPD_DIR}
+SPD_SOURCES := services/spd/tspd/tspd_common.c \
+ services/spd/tspd/tspd_helpers.S \
+ services/spd/tspd/tspd_main.c \
+ services/spd/tspd/tspd_pm.c
# This dispatcher is paired with a Test Secure Payload source and we intend to
# build the Test Secure Payload along with this dispatcher.
diff --git a/services/spd/tspd/tspd_common.c b/services/spd/tspd/tspd_common.c
index b806543..13023d2 100644
--- a/services/spd/tspd/tspd_common.c
+++ b/services/spd/tspd/tspd_common.c
@@ -28,16 +28,13 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <stdio.h>
-#include <errno.h>
-#include <string.h>
-#include <assert.h>
#include <arch_helpers.h>
-#include <platform.h>
+#include <assert.h>
#include <bl_common.h>
-#include <runtime_svc.h>
#include <context_mgmt.h>
-#include <tspd_private.h>
+#include <platform.h>
+#include <string.h>
+#include "tspd_private.h"
/*******************************************************************************
* Given a secure payload entrypoint, register width, cpu id & pointer to a
@@ -47,10 +44,10 @@
int32_t tspd_init_secure_context(uint64_t entrypoint,
uint32_t rw,
uint64_t mpidr,
- tsp_context *tsp_ctx)
+ tsp_context_t *tsp_ctx)
{
uint32_t scr, sctlr;
- el1_sys_regs *el1_state;
+ el1_sys_regs_t *el1_state;
uint32_t spsr;
/* Passing a NULL context is a critical programming error */
@@ -110,7 +107,7 @@
* 3. Calls el3_exit() so that the EL3 system and general purpose registers
* from the tsp_ctx->cpu_ctx are used to enter the secure payload image.
******************************************************************************/
-uint64_t tspd_synchronous_sp_entry(tsp_context *tsp_ctx)
+uint64_t tspd_synchronous_sp_entry(tsp_context_t *tsp_ctx)
{
uint64_t rc;
@@ -138,7 +135,7 @@
* 3. It does not need to save any general purpose or EL3 system register state
* as the generic smc entry routine should have saved those.
******************************************************************************/
-void tspd_synchronous_sp_exit(tsp_context *tsp_ctx, uint64_t ret)
+void tspd_synchronous_sp_exit(tsp_context_t *tsp_ctx, uint64_t ret)
{
/* Save the Secure EL1 system register context */
assert(cm_get_context(read_mpidr(), SECURE) == &tsp_ctx->cpu_ctx);
diff --git a/services/spd/tspd/tspd_helpers.S b/services/spd/tspd/tspd_helpers.S
index 27fbb5a..dd3b07b 100644
--- a/services/spd/tspd/tspd_helpers.S
+++ b/services/spd/tspd/tspd_helpers.S
@@ -28,10 +28,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <context.h>
-#include <tspd_private.h>
#include <asm_macros.S>
-#include <cm_macros.S>
+#include "tspd_private.h"
.global tspd_enter_sp
/* ---------------------------------------------
diff --git a/services/spd/tspd/tspd_main.c b/services/spd/tspd/tspd_main.c
index 543266e..9fda307 100644
--- a/services/spd/tspd/tspd_main.c
+++ b/services/spd/tspd/tspd_main.c
@@ -38,31 +38,27 @@
* handle the request locally or delegate it to the Secure Payload. It is also
* responsible for initialising and maintaining communication with the SP.
******************************************************************************/
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
#include <arch_helpers.h>
-#include <console.h>
-#include <platform.h>
+#include <assert.h>
+#include <bl_common.h>
+#include <bl31.h>
#include <context_mgmt.h>
#include <runtime_svc.h>
-#include <bl31.h>
+#include <stddef.h>
#include <tsp.h>
-#include <psci.h>
-#include <tspd_private.h>
-#include <debug.h>
#include <uuid.h>
+#include "tspd_private.h"
/*******************************************************************************
* Single structure to hold information about the various entry points into the
* Secure Payload. It is initialised once on the primary core after a cold boot.
******************************************************************************/
-entry_info *tsp_entry_info;
+entry_info_t *tsp_entry_info;
/*******************************************************************************
* Array to keep track of per-cpu Secure Payload state
******************************************************************************/
-tsp_context tspd_sp_context[TSPD_CORE_COUNT];
+tsp_context_t tspd_sp_context[TSPD_CORE_COUNT];
/* TSP UID */
@@ -70,7 +66,7 @@
0x5b3056a0, 0x3291, 0x427b, 0x98, 0x11,
0x71, 0x68, 0xca, 0x50, 0xf3, 0xfa);
-int32_t tspd_init(meminfo *bl32_meminfo);
+int32_t tspd_init(meminfo_t *bl32_meminfo);
/*******************************************************************************
@@ -80,7 +76,7 @@
******************************************************************************/
int32_t tspd_setup(void)
{
- el_change_info *image_info;
+ el_change_info_t *image_info;
int32_t rc;
uint64_t mpidr = read_mpidr();
uint32_t linear_id;
@@ -133,12 +129,12 @@
* back to this routine through a SMC. It also passes the extents of memory made
* available to BL32 by BL31.
******************************************************************************/
-int32_t tspd_init(meminfo *bl32_meminfo)
+int32_t tspd_init(meminfo_t *bl32_meminfo)
{
uint64_t mpidr = read_mpidr();
uint32_t linear_id = platform_get_core_pos(mpidr);
uint64_t rc;
- tsp_context *tsp_ctx = &tspd_sp_context[linear_id];
+ tsp_context_t *tsp_ctx = &tspd_sp_context[linear_id];
/*
* Arrange for passing a pointer to the meminfo structure
@@ -189,11 +185,11 @@
void *handle,
uint64_t flags)
{
- cpu_context *ns_cpu_context;
- gp_regs *ns_gp_regs;
+ cpu_context_t *ns_cpu_context;
+ gp_regs_t *ns_gp_regs;
unsigned long mpidr = read_mpidr();
uint32_t linear_id = platform_get_core_pos(mpidr), ns;
- tsp_context *tsp_ctx = &tspd_sp_context[linear_id];
+ tsp_context_t *tsp_ctx = &tspd_sp_context[linear_id];
/* Determine which security state this SMC originated from */
ns = is_caller_non_secure(flags);
@@ -213,7 +209,7 @@
* only once on the primary cpu
*/
assert(tsp_entry_info == NULL);
- tsp_entry_info = (entry_info *) x1;
+ tsp_entry_info = (entry_info_t *) x1;
/*
* SP reports completion. The SPD must have initiated
diff --git a/services/spd/tspd/tspd_pm.c b/services/spd/tspd/tspd_pm.c
index 4ebafc7..2447d9e 100644
--- a/services/spd/tspd/tspd_pm.c
+++ b/services/spd/tspd/tspd_pm.c
@@ -28,19 +28,13 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
#include <arch_helpers.h>
-#include <console.h>
-#include <platform.h>
+#include <assert.h>
+#include <bl_common.h>
#include <context_mgmt.h>
-#include <runtime_svc.h>
-#include <bl31.h>
-#include <bl32.h>
-#include <psci.h>
-#include <tspd_private.h>
#include <debug.h>
+#include <tsp.h>
+#include "tspd_private.h"
/*******************************************************************************
* The target cpu is being turned on. Allow the TSPD/TSP to perform any actions
@@ -59,7 +53,7 @@
int32_t rc = 0;
uint64_t mpidr = read_mpidr();
uint32_t linear_id = platform_get_core_pos(mpidr);
- tsp_context *tsp_ctx = &tspd_sp_context[linear_id];
+ tsp_context_t *tsp_ctx = &tspd_sp_context[linear_id];
assert(tsp_entry_info);
assert(tsp_ctx->state == TSP_STATE_ON);
@@ -93,7 +87,7 @@
int32_t rc = 0;
uint64_t mpidr = read_mpidr();
uint32_t linear_id = platform_get_core_pos(mpidr);
- tsp_context *tsp_ctx = &tspd_sp_context[linear_id];
+ tsp_context_t *tsp_ctx = &tspd_sp_context[linear_id];
assert(tsp_entry_info);
assert(tsp_ctx->state == TSP_STATE_ON);
@@ -127,7 +121,7 @@
int32_t rc = 0;
uint64_t mpidr = read_mpidr();
uint32_t linear_id = platform_get_core_pos(mpidr);
- tsp_context *tsp_ctx = &tspd_sp_context[linear_id];
+ tsp_context_t *tsp_ctx = &tspd_sp_context[linear_id];
assert(tsp_entry_info);
assert(tsp_ctx->state == TSP_STATE_OFF);
@@ -162,7 +156,7 @@
int32_t rc = 0;
uint64_t mpidr = read_mpidr();
uint32_t linear_id = platform_get_core_pos(mpidr);
- tsp_context *tsp_ctx = &tspd_sp_context[linear_id];
+ tsp_context_t *tsp_ctx = &tspd_sp_context[linear_id];
assert(tsp_entry_info);
assert(tsp_ctx->state == TSP_STATE_SUSPEND);
@@ -198,7 +192,7 @@
* Structure populated by the TSP Dispatcher to be given a chance to perform any
* TSP bookkeeping before PSCI executes a power mgmt. operation.
******************************************************************************/
-const spd_pm_ops tspd_pm = {
+const spd_pm_ops_t tspd_pm = {
tspd_cpu_on_handler,
tspd_cpu_off_handler,
tspd_cpu_suspend_handler,
diff --git a/services/spd/tspd/tspd_private.h b/services/spd/tspd/tspd_private.h
index 69cf199..81484e1 100644
--- a/services/spd/tspd/tspd_private.h
+++ b/services/spd/tspd/tspd_private.h
@@ -28,13 +28,13 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef __SPD_PRIVATE_H__
-#define __SPD_PRIVATE_H__
+#ifndef __TSPD_PRIVATE_H__
+#define __TSPD_PRIVATE_H__
-#include <context.h>
#include <arch.h>
+#include <context.h>
+#include <platform.h>
#include <psci.h>
-#include <tsp.h>
/*******************************************************************************
* Secure Payload PM state information e.g. SP is suspended, uninitialised etc
@@ -90,6 +90,9 @@
#ifndef __ASSEMBLY__
+#include <cassert.h>
+#include <stdint.h>
+
/* AArch64 callee saved general purpose register context structure. */
DEFINE_REG_STRUCT(c_rt_regs, TSPD_C_RT_CTX_ENTRIES);
@@ -98,7 +101,7 @@
* have the same double word aligned view of the size of the C runtime
* register context.
*/
-CASSERT(TSPD_C_RT_CTX_SIZE == sizeof(c_rt_regs), \
+CASSERT(TSPD_C_RT_CTX_SIZE == sizeof(c_rt_regs_t), \
assert_spd_c_rt_regs_size_mismatch);
/*******************************************************************************
@@ -109,29 +112,34 @@
* from a synchronous entry into the SP.
* 'cpu_ctx' - space to maintain SP architectural state
******************************************************************************/
-typedef struct {
+typedef struct tsp_context {
uint32_t state;
uint64_t mpidr;
uint64_t c_rt_ctx;
- cpu_context cpu_ctx;
-} tsp_context;
+ cpu_context_t cpu_ctx;
+} tsp_context_t;
/* TSPD power management handlers */
-extern const spd_pm_ops tspd_pm;
+extern const spd_pm_ops_t tspd_pm;
/*******************************************************************************
+ * Forward declarations
+ ******************************************************************************/
+struct entry_info;
+
+/*******************************************************************************
* Function & Data prototypes
******************************************************************************/
extern uint64_t tspd_enter_sp(uint64_t *c_rt_ctx);
extern void __dead2 tspd_exit_sp(uint64_t c_rt_ctx, uint64_t ret);
-extern uint64_t tspd_synchronous_sp_entry(tsp_context *tsp_ctx);
-extern void __dead2 tspd_synchronous_sp_exit(tsp_context *tsp_ctx, uint64_t ret);
+extern uint64_t tspd_synchronous_sp_entry(tsp_context_t *tsp_ctx);
+extern void __dead2 tspd_synchronous_sp_exit(tsp_context_t *tsp_ctx, uint64_t ret);
extern int32_t tspd_init_secure_context(uint64_t entrypoint,
uint32_t rw,
uint64_t mpidr,
- tsp_context *tsp_ctx);
-extern tsp_context tspd_sp_context[TSPD_CORE_COUNT];
-extern entry_info *tsp_entry_info;
+ tsp_context_t *tsp_ctx);
+extern tsp_context_t tspd_sp_context[TSPD_CORE_COUNT];
+extern struct entry_info *tsp_entry_info;
#endif /*__ASSEMBLY__*/
-#endif /* __SPD_PRIVATE_H__ */
+#endif /* __TSPD_PRIVATE_H__ */
diff --git a/services/std_svc/psci/psci_afflvl_off.c b/services/std_svc/psci/psci_afflvl_off.c
index f6bd40c..e007bc3 100644
--- a/services/std_svc/psci/psci_afflvl_off.c
+++ b/services/std_svc/psci/psci_afflvl_off.c
@@ -28,23 +28,19 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
-#include <debug.h>
+#include <arch.h>
#include <arch_helpers.h>
-#include <console.h>
-#include <platform.h>
-#include <psci.h>
-#include <psci_private.h>
+#include <assert.h>
+#include <string.h>
+#include "psci_private.h"
-typedef int (*afflvl_off_handler)(unsigned long, aff_map_node *);
+typedef int (*afflvl_off_handler_t)(unsigned long, aff_map_node_t *);
/*******************************************************************************
* The next three functions implement a handler for each supported affinity
* level which is called when that affinity level is turned off.
******************************************************************************/
-static int psci_afflvl0_off(unsigned long mpidr, aff_map_node *cpu_node)
+static int psci_afflvl0_off(unsigned long mpidr, aff_map_node_t *cpu_node)
{
unsigned int index, plat_state;
int rc = PSCI_E_SUCCESS;
@@ -111,7 +107,7 @@
return rc;
}
-static int psci_afflvl1_off(unsigned long mpidr, aff_map_node *cluster_node)
+static int psci_afflvl1_off(unsigned long mpidr, aff_map_node_t *cluster_node)
{
int rc = PSCI_E_SUCCESS;
unsigned int plat_state;
@@ -148,7 +144,7 @@
return rc;
}
-static int psci_afflvl2_off(unsigned long mpidr, aff_map_node *system_node)
+static int psci_afflvl2_off(unsigned long mpidr, aff_map_node_t *system_node)
{
int rc = PSCI_E_SUCCESS;
unsigned int plat_state;
@@ -178,7 +174,7 @@
return rc;
}
-static const afflvl_off_handler psci_afflvl_off_handlers[] = {
+static const afflvl_off_handler_t psci_afflvl_off_handlers[] = {
psci_afflvl0_off,
psci_afflvl1_off,
psci_afflvl2_off,
@@ -189,13 +185,13 @@
* topology tree and calls the off handler for the corresponding affinity
* levels
******************************************************************************/
-static int psci_call_off_handlers(mpidr_aff_map_nodes mpidr_nodes,
+static int psci_call_off_handlers(mpidr_aff_map_nodes_t mpidr_nodes,
int start_afflvl,
int end_afflvl,
unsigned long mpidr)
{
int rc = PSCI_E_INVALID_PARAMS, level;
- aff_map_node *node;
+ aff_map_node_t *node;
for (level = start_afflvl; level <= end_afflvl; level++) {
node = mpidr_nodes[level];
@@ -242,7 +238,7 @@
int end_afflvl)
{
int rc = PSCI_E_SUCCESS;
- mpidr_aff_map_nodes mpidr_nodes;
+ mpidr_aff_map_nodes_t mpidr_nodes;
mpidr &= MPIDR_AFFINITY_MASK;;
diff --git a/services/std_svc/psci/psci_afflvl_on.c b/services/std_svc/psci/psci_afflvl_on.c
index 0878f21..8f9bb4d 100644
--- a/services/std_svc/psci/psci_afflvl_on.c
+++ b/services/std_svc/psci/psci_afflvl_on.c
@@ -28,19 +28,18 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
-#include <debug.h>
+#include <arch.h>
#include <arch_helpers.h>
-#include <console.h>
-#include <platform.h>
-#include <psci.h>
-#include <psci_private.h>
+#include <assert.h>
+#include <bl_common.h>
+#include <bl31.h>
#include <context_mgmt.h>
+#include <runtime_svc.h>
+#include <stddef.h>
+#include "psci_private.h"
-typedef int (*afflvl_on_handler)(unsigned long,
- aff_map_node *,
+typedef int (*afflvl_on_handler_t)(unsigned long,
+ aff_map_node_t *,
unsigned long,
unsigned long);
@@ -48,7 +47,7 @@
* This function checks whether a cpu which has been requested to be turned on
* is OFF to begin with.
******************************************************************************/
-static int cpu_on_validate_state(aff_map_node *node)
+static int cpu_on_validate_state(aff_map_node_t *node)
{
unsigned int psci_state;
@@ -71,7 +70,7 @@
* TODO: Split this code across separate handlers for each type of setup?
******************************************************************************/
static int psci_afflvl0_on(unsigned long target_cpu,
- aff_map_node *cpu_node,
+ aff_map_node_t *cpu_node,
unsigned long ns_entrypoint,
unsigned long context_id)
{
@@ -139,7 +138,7 @@
* TODO: Split this code across separate handlers for each type of setup?
******************************************************************************/
static int psci_afflvl1_on(unsigned long target_cpu,
- aff_map_node *cluster_node,
+ aff_map_node_t *cluster_node,
unsigned long ns_entrypoint,
unsigned long context_id)
{
@@ -180,7 +179,7 @@
* TODO: Split this code across separate handlers for each type of setup?
******************************************************************************/
static int psci_afflvl2_on(unsigned long target_cpu,
- aff_map_node *system_node,
+ aff_map_node_t *system_node,
unsigned long ns_entrypoint,
unsigned long context_id)
{
@@ -217,7 +216,7 @@
}
/* Private data structure to make this handlers accessible through indexing */
-static const afflvl_on_handler psci_afflvl_on_handlers[] = {
+static const afflvl_on_handler_t psci_afflvl_on_handlers[] = {
psci_afflvl0_on,
psci_afflvl1_on,
psci_afflvl2_on,
@@ -228,7 +227,7 @@
* topology tree and calls the on handler for the corresponding affinity
* levels
******************************************************************************/
-static int psci_call_on_handlers(mpidr_aff_map_nodes target_cpu_nodes,
+static int psci_call_on_handlers(mpidr_aff_map_nodes_t target_cpu_nodes,
int start_afflvl,
int end_afflvl,
unsigned long target_cpu,
@@ -236,7 +235,7 @@
unsigned long context_id)
{
int rc = PSCI_E_INVALID_PARAMS, level;
- aff_map_node *node;
+ aff_map_node_t *node;
for (level = end_afflvl; level >= start_afflvl; level--) {
node = target_cpu_nodes[level];
@@ -282,7 +281,7 @@
int end_afflvl)
{
int rc = PSCI_E_SUCCESS;
- mpidr_aff_map_nodes target_cpu_nodes;
+ mpidr_aff_map_nodes_t target_cpu_nodes;
unsigned long mpidr = read_mpidr() & MPIDR_AFFINITY_MASK;
/*
@@ -334,7 +333,7 @@
* are called by the common finisher routine in psci_common.c.
******************************************************************************/
static unsigned int psci_afflvl0_on_finish(unsigned long mpidr,
- aff_map_node *cpu_node)
+ aff_map_node_t *cpu_node)
{
unsigned int index, plat_state, state, rc = PSCI_E_SUCCESS;
@@ -409,7 +408,7 @@
}
static unsigned int psci_afflvl1_on_finish(unsigned long mpidr,
- aff_map_node *cluster_node)
+ aff_map_node_t *cluster_node)
{
unsigned int plat_state, rc = PSCI_E_SUCCESS;
@@ -441,7 +440,7 @@
static unsigned int psci_afflvl2_on_finish(unsigned long mpidr,
- aff_map_node *system_node)
+ aff_map_node_t *system_node)
{
unsigned int plat_state, rc = PSCI_E_SUCCESS;
@@ -477,7 +476,7 @@
return rc;
}
-const afflvl_power_on_finisher psci_afflvl_on_finishers[] = {
+const afflvl_power_on_finisher_t psci_afflvl_on_finishers[] = {
psci_afflvl0_on_finish,
psci_afflvl1_on_finish,
psci_afflvl2_on_finish,
diff --git a/services/std_svc/psci/psci_afflvl_suspend.c b/services/std_svc/psci/psci_afflvl_suspend.c
index fc6fe1f..dc12f7a 100644
--- a/services/std_svc/psci/psci_afflvl_suspend.c
+++ b/services/std_svc/psci/psci_afflvl_suspend.c
@@ -28,19 +28,18 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <stdio.h>
-#include <string.h>
#include <assert.h>
-#include <debug.h>
+#include <bl_common.h>
+#include <arch.h>
#include <arch_helpers.h>
-#include <console.h>
-#include <platform.h>
-#include <psci.h>
-#include <psci_private.h>
+#include <context.h>
#include <context_mgmt.h>
+#include <runtime_svc.h>
+#include <stddef.h>
+#include "psci_private.h"
-typedef int (*afflvl_suspend_handler)(unsigned long,
- aff_map_node *,
+typedef int (*afflvl_suspend_handler_t)(unsigned long,
+ aff_map_node_t *,
unsigned long,
unsigned long,
unsigned int);
@@ -49,7 +48,7 @@
* This function sets the power state of the current cpu while
* powering down during a cpu_suspend call
******************************************************************************/
-void psci_set_suspend_power_state(aff_map_node *node, unsigned int power_state)
+void psci_set_suspend_power_state(aff_map_node_t *node, unsigned int power_state)
{
/*
* Check that nobody else is calling this function on our behalf &
@@ -67,7 +66,7 @@
*/
flush_dcache_range(
(unsigned long)&psci_suspend_context[node->data],
- sizeof(suspend_context));
+ sizeof(suspend_context_t));
}
/*******************************************************************************
@@ -77,7 +76,7 @@
******************************************************************************/
int psci_get_suspend_afflvl(unsigned long mpidr)
{
- aff_map_node *node;
+ aff_map_node_t *node;
node = psci_get_aff_map_node(mpidr & MPIDR_AFFINITY_MASK,
MPIDR_AFFLVL0);
@@ -92,7 +91,7 @@
* down during a cpu_suspend call. Returns PSCI_INVALID_DATA if the
* power state saved for the node is invalid
******************************************************************************/
-int psci_get_aff_map_node_suspend_afflvl(aff_map_node *node)
+int psci_get_aff_map_node_suspend_afflvl(aff_map_node_t *node)
{
unsigned int power_state;
@@ -110,7 +109,7 @@
******************************************************************************/
int psci_get_suspend_stateid(unsigned long mpidr)
{
- aff_map_node *node;
+ aff_map_node_t *node;
unsigned int power_state;
node = psci_get_aff_map_node(mpidr & MPIDR_AFFINITY_MASK,
@@ -128,14 +127,14 @@
* level which is called when that affinity level is about to be suspended.
******************************************************************************/
static int psci_afflvl0_suspend(unsigned long mpidr,
- aff_map_node *cpu_node,
+ aff_map_node_t *cpu_node,
unsigned long ns_entrypoint,
unsigned long context_id,
unsigned int power_state)
{
unsigned int index, plat_state;
unsigned long psci_entrypoint, sctlr;
- el3_state *saved_el3_state;
+ el3_state_t *saved_el3_state;
int rc = PSCI_E_SUCCESS;
/* Sanity check to safeguard against data corruption */
@@ -227,7 +226,7 @@
}
static int psci_afflvl1_suspend(unsigned long mpidr,
- aff_map_node *cluster_node,
+ aff_map_node_t *cluster_node,
unsigned long ns_entrypoint,
unsigned long context_id,
unsigned int power_state)
@@ -281,7 +280,7 @@
static int psci_afflvl2_suspend(unsigned long mpidr,
- aff_map_node *system_node,
+ aff_map_node_t *system_node,
unsigned long ns_entrypoint,
unsigned long context_id,
unsigned int power_state)
@@ -325,7 +324,7 @@
return rc;
}
-static const afflvl_suspend_handler psci_afflvl_suspend_handlers[] = {
+static const afflvl_suspend_handler_t psci_afflvl_suspend_handlers[] = {
psci_afflvl0_suspend,
psci_afflvl1_suspend,
psci_afflvl2_suspend,
@@ -336,7 +335,7 @@
* topology tree and calls the suspend handler for the corresponding affinity
* levels
******************************************************************************/
-static int psci_call_suspend_handlers(mpidr_aff_map_nodes mpidr_nodes,
+static int psci_call_suspend_handlers(mpidr_aff_map_nodes_t mpidr_nodes,
int start_afflvl,
int end_afflvl,
unsigned long mpidr,
@@ -345,7 +344,7 @@
unsigned int power_state)
{
int rc = PSCI_E_INVALID_PARAMS, level;
- aff_map_node *node;
+ aff_map_node_t *node;
for (level = start_afflvl; level <= end_afflvl; level++) {
node = mpidr_nodes[level];
@@ -399,7 +398,7 @@
int end_afflvl)
{
int rc = PSCI_E_SUCCESS;
- mpidr_aff_map_nodes mpidr_nodes;
+ mpidr_aff_map_nodes_t mpidr_nodes;
mpidr &= MPIDR_AFFINITY_MASK;
@@ -452,7 +451,7 @@
* are called by the common finisher routine in psci_common.c.
******************************************************************************/
static unsigned int psci_afflvl0_suspend_finish(unsigned long mpidr,
- aff_map_node *cpu_node)
+ aff_map_node_t *cpu_node)
{
unsigned int index, plat_state, state, rc = PSCI_E_SUCCESS;
int32_t suspend_level;
@@ -532,7 +531,7 @@
}
static unsigned int psci_afflvl1_suspend_finish(unsigned long mpidr,
- aff_map_node *cluster_node)
+ aff_map_node_t *cluster_node)
{
unsigned int plat_state, rc = PSCI_E_SUCCESS;
@@ -564,7 +563,7 @@
static unsigned int psci_afflvl2_suspend_finish(unsigned long mpidr,
- aff_map_node *system_node)
+ aff_map_node_t *system_node)
{
unsigned int plat_state, rc = PSCI_E_SUCCESS;;
@@ -600,7 +599,7 @@
return rc;
}
-const afflvl_power_on_finisher psci_afflvl_suspend_finishers[] = {
+const afflvl_power_on_finisher_t psci_afflvl_suspend_finishers[] = {
psci_afflvl0_suspend_finish,
psci_afflvl1_suspend_finish,
psci_afflvl2_suspend_finish,
diff --git a/services/std_svc/psci/psci_common.c b/services/std_svc/psci/psci_common.c
index 8b49b77..1d5c362 100644
--- a/services/std_svc/psci/psci_common.c
+++ b/services/std_svc/psci/psci_common.c
@@ -28,23 +28,20 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
+#include <arch.h>
#include <arch_helpers.h>
-#include <console.h>
-#include <platform.h>
-#include <psci.h>
-#include <psci_private.h>
+#include <assert.h>
+#include <bl_common.h>
+#include <context.h>
#include <context_mgmt.h>
-#include <runtime_svc.h>
-#include "debug.h"
+#include <debug.h>
+#include "psci_private.h"
/*
* SPD power management operations, expected to be supplied by the registered
* SPD on successful SP initialization
*/
-const spd_pm_ops *psci_spd_pm;
+const spd_pm_ops_t *psci_spd_pm;
/*******************************************************************************
* Arrays that contains information needs to resume a cpu's execution when woken
@@ -52,8 +49,8 @@
* free index in the 'psci_ns_entry_info' & 'psci_suspend_context' arrays. Each
* cpu is allocated a single entry in each array during startup.
******************************************************************************/
-suspend_context psci_suspend_context[PSCI_NUM_AFFS];
-ns_entry_info psci_ns_entry_info[PSCI_NUM_AFFS];
+suspend_context_t psci_suspend_context[PSCI_NUM_AFFS];
+ns_entry_info_t psci_ns_entry_info[PSCI_NUM_AFFS];
unsigned int psci_ns_einfo_idx;
/*******************************************************************************
@@ -61,7 +58,7 @@
* management of affinity instances. Each node (aff_map_node) in the array
* corresponds to an affinity instance e.g. cluster, cpu within an mpidr
******************************************************************************/
-aff_map_node psci_aff_map[PSCI_NUM_AFFS]
+aff_map_node_t psci_aff_map[PSCI_NUM_AFFS]
__attribute__ ((section("tzfw_coherent_mem")));
/*******************************************************************************
@@ -72,12 +69,12 @@
* level i.e. start index and end index needs to be present. 'psci_aff_limits'
* stores this information.
******************************************************************************/
-aff_limits_node psci_aff_limits[MPIDR_MAX_AFFLVL + 1];
+aff_limits_node_t psci_aff_limits[MPIDR_MAX_AFFLVL + 1];
/*******************************************************************************
* Pointer to functions exported by the platform to complete power mgmt. ops
******************************************************************************/
-plat_pm_ops *psci_plat_pm_ops;
+plat_pm_ops_t *psci_plat_pm_ops;
/*******************************************************************************
* Routine to return the maximum affinity level to traverse to after a cpu has
@@ -89,7 +86,7 @@
******************************************************************************/
int get_power_on_target_afflvl(unsigned long mpidr)
{
- aff_map_node *node;
+ aff_map_node_t *node;
unsigned int state;
int afflvl;
@@ -180,7 +177,7 @@
void psci_acquire_afflvl_locks(unsigned long mpidr,
int start_afflvl,
int end_afflvl,
- mpidr_aff_map_nodes mpidr_nodes)
+ mpidr_aff_map_nodes_t mpidr_nodes)
{
int level;
@@ -199,7 +196,7 @@
void psci_release_afflvl_locks(unsigned long mpidr,
int start_afflvl,
int end_afflvl,
- mpidr_aff_map_nodes mpidr_nodes)
+ mpidr_aff_map_nodes_t mpidr_nodes)
{
int level;
@@ -216,7 +213,7 @@
******************************************************************************/
int psci_validate_mpidr(unsigned long mpidr, int level)
{
- aff_map_node *node;
+ aff_map_node_t *node;
node = psci_get_aff_map_node(mpidr, level);
if (node && (node->state & PSCI_AFF_PRESENT))
@@ -234,8 +231,8 @@
{
unsigned long sctlr = 0, scr, el_status, id_aa64pfr0;
uint64_t mpidr = read_mpidr();
- cpu_context *ns_entry_context;
- gp_regs *ns_entry_gpregs;
+ cpu_context_t *ns_entry_context;
+ gp_regs_t *ns_entry_gpregs;
scr = read_scr();
@@ -267,7 +264,7 @@
write_sctlr_el1(sctlr);
/* Fulfill the cpu_on entry reqs. as per the psci spec */
- ns_entry_context = (cpu_context *) cm_get_context(mpidr, NON_SECURE);
+ ns_entry_context = (cpu_context_t *) cm_get_context(mpidr, NON_SECURE);
assert(ns_entry_context);
/*
@@ -380,7 +377,7 @@
* This function takes a pointer to an affinity node in the topology tree and
* returns its state. State of a non-leaf node needs to be calculated.
******************************************************************************/
-unsigned short psci_get_state(aff_map_node *node)
+unsigned short psci_get_state(aff_map_node_t *node)
{
assert(node->level >= MPIDR_AFFLVL0 && node->level <= MPIDR_MAX_AFFLVL);
@@ -407,7 +404,7 @@
* a target state. State of a non-leaf node needs to be converted to a reference
* count. State of a leaf node can be set directly.
******************************************************************************/
-void psci_set_state(aff_map_node *node, unsigned short state)
+void psci_set_state(aff_map_node_t *node, unsigned short state)
{
assert(node->level >= MPIDR_AFFLVL0 && node->level <= MPIDR_MAX_AFFLVL);
@@ -448,7 +445,7 @@
* tell whether that's actually happenned or not. So we err on the side of
* caution & treat the affinity level as being turned off.
******************************************************************************/
-unsigned short psci_get_phys_state(aff_map_node *node)
+unsigned short psci_get_phys_state(aff_map_node_t *node)
{
unsigned int state;
@@ -461,14 +458,14 @@
* topology tree and calls the physical power on handler for the corresponding
* affinity levels
******************************************************************************/
-static int psci_call_power_on_handlers(mpidr_aff_map_nodes mpidr_nodes,
+static int psci_call_power_on_handlers(mpidr_aff_map_nodes_t mpidr_nodes,
int start_afflvl,
int end_afflvl,
- afflvl_power_on_finisher *pon_handlers,
+ afflvl_power_on_finisher_t *pon_handlers,
unsigned long mpidr)
{
int rc = PSCI_E_INVALID_PARAMS, level;
- aff_map_node *node;
+ aff_map_node_t *node;
for (level = end_afflvl; level >= start_afflvl; level--) {
node = mpidr_nodes[level];
@@ -511,9 +508,9 @@
void psci_afflvl_power_on_finish(unsigned long mpidr,
int start_afflvl,
int end_afflvl,
- afflvl_power_on_finisher *pon_handlers)
+ afflvl_power_on_finisher_t *pon_handlers)
{
- mpidr_aff_map_nodes mpidr_nodes;
+ mpidr_aff_map_nodes_t mpidr_nodes;
int rc;
mpidr &= MPIDR_AFFINITY_MASK;
@@ -565,7 +562,7 @@
* management operation. The power management hooks are expected to be provided
* by the SPD, after it finishes all its initialization
******************************************************************************/
-void psci_register_spd_pm_hook(const spd_pm_ops *pm)
+void psci_register_spd_pm_hook(const spd_pm_ops_t *pm)
{
psci_spd_pm = pm;
}
diff --git a/services/std_svc/psci/psci_entry.S b/services/std_svc/psci/psci_entry.S
index bdd571e..e2c690d 100644
--- a/services/std_svc/psci/psci_entry.S
+++ b/services/std_svc/psci/psci_entry.S
@@ -29,12 +29,9 @@
*/
#include <arch.h>
-#include <platform.h>
-#include <psci.h>
-#include <psci_private.h>
-#include <runtime_svc.h>
#include <asm_macros.S>
#include <cm_macros.S>
+#include <psci.h>
.globl psci_aff_on_finish_entry
.globl psci_aff_suspend_finish_entry
diff --git a/services/std_svc/psci/psci_main.c b/services/std_svc/psci/psci_main.c
index c90929d..1bcf216 100644
--- a/services/std_svc/psci/psci_main.c
+++ b/services/std_svc/psci/psci_main.c
@@ -28,16 +28,12 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
+#include <arch.h>
#include <arch_helpers.h>
-#include <console.h>
-#include <platform.h>
-#include <psci_private.h>
+#include <assert.h>
#include <runtime_svc.h>
#include <debug.h>
-#include <context_mgmt.h>
+#include "psci_private.h"
/*******************************************************************************
* PSCI frontend api for servicing SMCs. Described in the PSCI spec.
@@ -144,7 +140,7 @@
{
int rc = PSCI_E_INVALID_PARAMS;
unsigned int aff_state;
- aff_map_node *node;
+ aff_map_node_t *node;
if (lowest_affinity_level > get_max_afflvl())
return rc;
diff --git a/services/std_svc/psci/psci_private.h b/services/std_svc/psci/psci_private.h
index 8cb3aab..b0b5cc9 100644
--- a/services/std_svc/psci/psci_private.h
+++ b/services/std_svc/psci/psci_private.h
@@ -33,79 +33,79 @@
#include <arch.h>
#include <bakery_lock.h>
+#include <psci.h>
-#ifndef __ASSEMBLY__
/*******************************************************************************
* The following two data structures hold the generic information to bringup
* a suspended/hotplugged out cpu
******************************************************************************/
-typedef struct {
+typedef struct eret_params {
unsigned long entrypoint;
unsigned long spsr;
-} eret_params;
+} eret_params_t;
-typedef struct {
- eret_params eret_info;
+typedef struct ns_entry_info {
+ eret_params_t eret_info;
unsigned long context_id;
unsigned int scr;
unsigned int sctlr;
-} ns_entry_info;
+} ns_entry_info_t;
/*******************************************************************************
* The following two data structures hold the topology tree which in turn tracks
* the state of the all the affinity instances supported by the platform.
******************************************************************************/
-typedef struct {
+typedef struct aff_map_node {
unsigned long mpidr;
unsigned short ref_count;
unsigned char state;
unsigned char level;
unsigned int data;
- bakery_lock lock;
-} aff_map_node;
+ bakery_lock_t lock;
+} aff_map_node_t;
-typedef struct {
+typedef struct aff_limits_node {
int min;
int max;
-} aff_limits_node;
+} aff_limits_node_t;
/*******************************************************************************
* This data structure holds secure world context that needs to be preserved
* across cpu_suspend calls which enter the power down state.
******************************************************************************/
-typedef struct {
+typedef struct suspend_context {
unsigned int power_state;
-} __aligned(CACHE_WRITEBACK_GRANULE) suspend_context;
+} __aligned(CACHE_WRITEBACK_GRANULE) suspend_context_t;
-typedef aff_map_node (*mpidr_aff_map_nodes[MPIDR_MAX_AFFLVL]);
-typedef unsigned int (*afflvl_power_on_finisher)(unsigned long,
- aff_map_node *);
+typedef aff_map_node_t (*mpidr_aff_map_nodes_t[MPIDR_MAX_AFFLVL]);
+typedef unsigned int (*afflvl_power_on_finisher_t)(unsigned long,
+ aff_map_node_t *);
/*******************************************************************************
* Data prototypes
******************************************************************************/
-extern suspend_context psci_suspend_context[PSCI_NUM_AFFS];
-extern ns_entry_info psci_ns_entry_info[PSCI_NUM_AFFS];
+extern suspend_context_t psci_suspend_context[PSCI_NUM_AFFS];
+extern ns_entry_info_t psci_ns_entry_info[PSCI_NUM_AFFS];
extern unsigned int psci_ns_einfo_idx;
-extern aff_limits_node psci_aff_limits[MPIDR_MAX_AFFLVL + 1];
-extern plat_pm_ops *psci_plat_pm_ops;
-extern aff_map_node psci_aff_map[PSCI_NUM_AFFS];
-extern afflvl_power_on_finisher psci_afflvl_off_finish_handlers[];
-extern afflvl_power_on_finisher psci_afflvl_sus_finish_handlers[];
+extern aff_limits_node_t psci_aff_limits[MPIDR_MAX_AFFLVL + 1];
+extern plat_pm_ops_t *psci_plat_pm_ops;
+extern aff_map_node_t psci_aff_map[PSCI_NUM_AFFS];
+extern afflvl_power_on_finisher_t psci_afflvl_off_finish_handlers[];
+extern afflvl_power_on_finisher_t psci_afflvl_sus_finish_handlers[];
/*******************************************************************************
* SPD's power management hooks registered with PSCI
******************************************************************************/
-extern const spd_pm_ops *psci_spd_pm;
+extern const spd_pm_ops_t *psci_spd_pm;
/*******************************************************************************
* Function prototypes
******************************************************************************/
/* Private exported functions from psci_common.c */
extern int get_max_afflvl(void);
-extern unsigned short psci_get_state(aff_map_node *node);
-extern unsigned short psci_get_phys_state(aff_map_node *node);
-extern void psci_set_state(aff_map_node *node, unsigned short state);
+extern unsigned short psci_get_state(aff_map_node_t *node);
+extern unsigned short psci_get_phys_state(aff_map_node_t *node);
+extern void psci_set_state(aff_map_node_t *node, unsigned short state);
extern void psci_get_ns_entry_info(unsigned int index);
extern unsigned long mpidr_set_aff_inst(unsigned long, unsigned char, int);
extern int psci_validate_mpidr(unsigned long, int);
@@ -113,7 +113,7 @@
extern void psci_afflvl_power_on_finish(unsigned long,
int,
int,
- afflvl_power_on_finisher *);
+ afflvl_power_on_finisher_t *);
extern int psci_set_ns_entry_info(unsigned int index,
unsigned long entrypoint,
unsigned long context_id);
@@ -121,18 +121,18 @@
extern void psci_acquire_afflvl_locks(unsigned long mpidr,
int start_afflvl,
int end_afflvl,
- mpidr_aff_map_nodes mpidr_nodes);
+ mpidr_aff_map_nodes_t mpidr_nodes);
extern void psci_release_afflvl_locks(unsigned long mpidr,
int start_afflvl,
int end_afflvl,
- mpidr_aff_map_nodes mpidr_nodes);
+ mpidr_aff_map_nodes_t mpidr_nodes);
/* Private exported functions from psci_setup.c */
extern int psci_get_aff_map_nodes(unsigned long mpidr,
int start_afflvl,
int end_afflvl,
- mpidr_aff_map_nodes mpidr_nodes);
-extern aff_map_node *psci_get_aff_map_node(unsigned long, int);
+ mpidr_aff_map_nodes_t mpidr_nodes);
+extern aff_map_node_t *psci_get_aff_map_node(unsigned long, int);
/* Private exported functions from psci_affinity_on.c */
extern int psci_afflvl_on(unsigned long,
@@ -145,9 +145,9 @@
extern int psci_afflvl_off(unsigned long, int, int);
/* Private exported functions from psci_affinity_suspend.c */
-extern void psci_set_suspend_power_state(aff_map_node *node,
+extern void psci_set_suspend_power_state(aff_map_node_t *node,
unsigned int power_state);
-extern int psci_get_aff_map_node_suspend_afflvl(aff_map_node *node);
+extern int psci_get_aff_map_node_suspend_afflvl(aff_map_node_t *node);
extern int psci_afflvl_suspend(unsigned long,
unsigned long,
unsigned long,
@@ -156,19 +156,5 @@
int);
extern unsigned int psci_afflvl_suspend_finish(unsigned long, int, int);
-/* Private exported functions from psci_main.c */
-extern uint64_t psci_smc_handler(uint32_t smc_fid,
- uint64_t x1,
- uint64_t x2,
- uint64_t x3,
- uint64_t x4,
- void *cookie,
- void *handle,
- uint64_t flags);
-
-/* PSCI setup function */
-extern int32_t psci_setup(void);
-
-#endif /*__ASSEMBLY__*/
#endif /* __PSCI_PRIVATE_H__ */
diff --git a/services/std_svc/psci/psci_setup.c b/services/std_svc/psci/psci_setup.c
index 4525d78..71d3f1e 100644
--- a/services/std_svc/psci/psci_setup.c
+++ b/services/std_svc/psci/psci_setup.c
@@ -28,15 +28,15 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
+#include <arch.h>
#include <arch_helpers.h>
-#include <console.h>
-#include <platform.h>
-#include <psci_private.h>
+#include <assert.h>
+#include <bl_common.h>
+#include <context.h>
#include <context_mgmt.h>
-#include <runtime_svc.h>
+#include <platform.h>
+#include <stddef.h>
+#include "psci_private.h"
/*******************************************************************************
* Per cpu non-secure contexts used to program the architectural state prior
@@ -45,7 +45,7 @@
* of relying on platform defined constants. Using PSCI_NUM_AFFS will be an
* overkill.
******************************************************************************/
-static cpu_context psci_ns_context[PLATFORM_CORE_COUNT];
+static cpu_context_t psci_ns_context[PLATFORM_CORE_COUNT];
/*******************************************************************************
* Routines for retrieving the node corresponding to an affinity level instance
@@ -81,7 +81,7 @@
return mid;
}
-aff_map_node *psci_get_aff_map_node(unsigned long mpidr, int aff_lvl)
+aff_map_node_t *psci_get_aff_map_node(unsigned long mpidr, int aff_lvl)
{
int rc;
@@ -106,10 +106,10 @@
int psci_get_aff_map_nodes(unsigned long mpidr,
int start_afflvl,
int end_afflvl,
- mpidr_aff_map_nodes mpidr_nodes)
+ mpidr_aff_map_nodes_t mpidr_nodes)
{
int rc = PSCI_E_INVALID_PARAMS, level;
- aff_map_node *node;
+ aff_map_node_t *node;
rc = psci_check_afflvl_range(start_afflvl, end_afflvl);
if (rc != PSCI_E_SUCCESS)
@@ -285,7 +285,7 @@
{
unsigned long mpidr = read_mpidr();
int afflvl, affmap_idx, max_afflvl;
- aff_map_node *node;
+ aff_map_node_t *node;
psci_ns_einfo_idx = 0;
psci_plat_pm_ops = NULL;
diff --git a/services/std_svc/std_svc_setup.c b/services/std_svc/std_svc_setup.c
index 080836a..6cb0319 100644
--- a/services/std_svc/std_svc_setup.c
+++ b/services/std_svc/std_svc_setup.c
@@ -28,14 +28,12 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <stdint.h>
-#include <uuid.h>
-#include <context_mgmt.h>
+#include <debug.h>
+#include <psci.h>
#include <runtime_svc.h>
#include <std_svc.h>
-#include <psci.h>
-#include <psci_private.h>
-#include <debug.h>
+#include <stdint.h>
+#include <uuid.h>
/* Standard Service UUID */
DEFINE_SVC_UUID(arm_svc_uid,
diff --git a/tools/fip_create/fip_create.c b/tools/fip_create/fip_create.c
index 71ee1de..c97204a 100644
--- a/tools/fip_create/fip_create.c
+++ b/tools/fip_create/fip_create.c
@@ -43,7 +43,7 @@
#define OPT_DUMP 1
#define OPT_HELP 2
-file_info files[MAX_FILES];
+file_info_t files[MAX_FILES];
unsigned file_info_count = 0;
uuid_t uuid_null = {0};
@@ -54,7 +54,7 @@
*/
/* Currently only BL2 and BL31 images are supported. */
-static entry_lookup_list toc_entry_lookup_list[] = {
+static entry_lookup_list_t toc_entry_lookup_list[] = {
{ "Trusted Boot Firmware BL2", UUID_TRUSTED_BOOT_FIRMWARE_BL2,
"bl2", NULL, FLAG_FILENAME },
{ "SCP Firmware BL3-0", UUID_SCP_FIRMWARE_BL30,
@@ -84,7 +84,7 @@
static void print_usage(void)
{
- entry_lookup_list *entry = toc_entry_lookup_list;
+ entry_lookup_list_t *entry = toc_entry_lookup_list;
printf("Usage: fip_create [options] FIP_FILENAME\n\n");
printf("\tThis tool is used to create a Firmware Image Package.\n\n");
@@ -102,7 +102,7 @@
}
-static entry_lookup_list *get_entry_lookup_from_uuid(const uuid_t *uuid)
+static entry_lookup_list_t *get_entry_lookup_from_uuid(const uuid_t *uuid)
{
unsigned int lookup_index = 0;
@@ -117,7 +117,7 @@
}
-static file_info *find_file_info_from_uuid(const uuid_t *uuid)
+static file_info_t *find_file_info_from_uuid(const uuid_t *uuid)
{
int index;
@@ -130,9 +130,9 @@
}
-static int add_file_info_entry(entry_lookup_list *lookup_entry, char *filename)
+static int add_file_info_entry(entry_lookup_list_t *lookup_entry, char *filename)
{
- file_info *file_info_entry;
+ file_info_t *file_info_entry;
int error;
struct stat file_status;
bool is_new_entry = false;
@@ -213,7 +213,7 @@
}
-static int read_file_to_memory(void *memory, const file_info *info)
+static int read_file_to_memory(void *memory, const file_info_t *info)
{
FILE *stream;
unsigned int bytes_read;
@@ -258,8 +258,8 @@
int status;
uint8_t *fip_base_address;
void *entry_address;
- fip_toc_header *toc_header;
- fip_toc_entry *toc_entry;
+ fip_toc_header_t *toc_header;
+ fip_toc_entry_t *toc_entry;
unsigned int entry_index;
unsigned int toc_size;
unsigned int fip_size;
@@ -277,8 +277,8 @@
}
/* Allocate memory for entire package, including the final null entry */
- toc_size = (sizeof(fip_toc_header) +
- (sizeof(fip_toc_entry) * (file_info_count + 1)));
+ toc_size = (sizeof(fip_toc_header_t) +
+ (sizeof(fip_toc_entry_t) * (file_info_count + 1)));
fip_size = toc_size + payload_size;
fip_base_address = malloc(fip_size);
if (fip_base_address == NULL) {
@@ -289,13 +289,13 @@
memset(fip_base_address, 0, fip_size);
/* Create ToC Header */
- toc_header = (fip_toc_header *)fip_base_address;
+ toc_header = (fip_toc_header_t *)fip_base_address;
toc_header->name = TOC_HEADER_NAME;
toc_header->serial_number = TOC_HEADER_SERIAL_NUMBER;
toc_header->flags = 0;
- toc_entry = (fip_toc_entry *)(fip_base_address +
- sizeof(fip_toc_header));
+ toc_entry = (fip_toc_entry_t *)(fip_base_address +
+ sizeof(fip_toc_header_t));
/* Calculate the starting address of the first image, right after the
* toc header.
@@ -345,8 +345,8 @@
unsigned int image_offset;
unsigned int image_size = 0;
- image_offset = sizeof(fip_toc_header) +
- (sizeof(fip_toc_entry) * (file_info_count + 1));
+ image_offset = sizeof(fip_toc_header_t) +
+ (sizeof(fip_toc_entry_t) * (file_info_count + 1));
printf("Firmware Image Package ToC:\n");
printf("---------------------------\n");
@@ -376,10 +376,10 @@
char *fip_buffer;
char *fip_buffer_end;
int fip_size, read_fip_size;
- fip_toc_header *toc_header;
- fip_toc_entry *toc_entry;
+ fip_toc_header_t *toc_header;
+ fip_toc_entry_t *toc_entry;
bool found_last_toc_entry = false;
- file_info *file_info_entry;
+ file_info_t *file_info_entry;
int status = -1;
struct stat st;
@@ -419,19 +419,19 @@
fip = NULL;
/* The package must at least contain the ToC Header */
- if (fip_size < sizeof(fip_toc_header)) {
+ if (fip_size < sizeof(fip_toc_header_t)) {
printf("ERROR: Given FIP is smaller than the ToC header.\n");
status = EINVAL;
goto parse_fip_free;
}
/* Set the ToC Header at the base of the buffer */
- toc_header = (fip_toc_header *)fip_buffer;
+ toc_header = (fip_toc_header_t *)fip_buffer;
/* The first toc entry should be just after the ToC header */
- toc_entry = (fip_toc_entry *)(toc_header + 1);
+ toc_entry = (fip_toc_entry_t *)(toc_header + 1);
/* While the ToC entry is contained into the buffer */
int cnt = 0;
- while (((char *)toc_entry + sizeof(fip_toc_entry)) < fip_buffer_end) {
+ while (((char *)toc_entry + sizeof(fip_toc_entry_t)) < fip_buffer_end) {
cnt++;
/* Check if the ToC Entry is the last one */
if (compare_uuids(&toc_entry->uuid, &uuid_null) == 0) {
@@ -444,7 +444,7 @@
/* Get the new entry in the array and clear it */
file_info_entry = &files[file_info_count++];
- memset(file_info_entry, 0, sizeof(file_info));
+ memset(file_info_entry, 0, sizeof(file_info_t));
/* Copy the info from the ToC entry */
copy_uuid(&file_info_entry->name_uuid, &toc_entry->uuid);
@@ -523,7 +523,7 @@
int c;
int status = 0;
int option_index = 0;
- entry_lookup_list *lookup_entry;
+ entry_lookup_list_t *lookup_entry;
int do_dump = 0;
/* restart parse to process all options. starts at 1. */
@@ -591,11 +591,11 @@
* Add 'dump' option, 'help' option and end marker.
*/
static struct option long_options[(sizeof(toc_entry_lookup_list)/
- sizeof(entry_lookup_list)) + 2];
+ sizeof(entry_lookup_list_t)) + 2];
for (i = 0;
/* -1 because we dont want to process end marker in toc table */
- i < sizeof(toc_entry_lookup_list)/sizeof(entry_lookup_list) - 1;
+ i < sizeof(toc_entry_lookup_list)/sizeof(entry_lookup_list_t) - 1;
i++) {
long_options[i].name = toc_entry_lookup_list[i].command_line_name;
/* The only flag defined at the moment is for a FILENAME */
diff --git a/tools/fip_create/fip_create.h b/tools/fip_create/fip_create.h
index f2e022f..ef321cd 100644
--- a/tools/fip_create/fip_create.h
+++ b/tools/fip_create/fip_create.h
@@ -41,20 +41,20 @@
#define FLAG_FILENAME (1 << 0)
-typedef struct {
+typedef struct entry_lookup_list {
const char *name;
uuid_t name_uuid;
const char *command_line_name;
struct file_info *info;
unsigned int flags;
-} entry_lookup_list;
+} entry_lookup_list_t;
-typedef struct {
+typedef struct file_info {
uuid_t name_uuid;
const char *filename;
unsigned int size;
void *image_buffer;
- entry_lookup_list *entry;
-} file_info;
+ entry_lookup_list_t *entry;
+} file_info_t;
#endif /* __FIP_CREATE_H__ */
diff --git a/tools/fip_create/firmware_image_package.h b/tools/fip_create/firmware_image_package.h
index 2c0d017..cc61903 120000
--- a/tools/fip_create/firmware_image_package.h
+++ b/tools/fip_create/firmware_image_package.h
@@ -1 +1 @@
-../../include/firmware_image_package.h
\ No newline at end of file
+../../include/common/firmware_image_package.h
\ No newline at end of file