Unverified Commit 0d3a27e7 authored by davidcunado-arm's avatar davidcunado-arm Committed by GitHub
Browse files

Merge pull request #1200 from robertovargas-arm/bl2-el3

Add BL2_AT_EL3 build option
parents 0caaa03b 76d26733
...@@ -21,6 +21,10 @@ ...@@ -21,6 +21,10 @@
/* Word size for 64-bit CPUs */ /* Word size for 64-bit CPUs */
#define CPU_WORD_SIZE 8 #define CPU_WORD_SIZE 8
#if defined(IMAGE_BL1) || defined(IMAGE_BL31) ||(defined(IMAGE_BL2) && BL2_AT_EL3)
#define IMAGE_AT_EL3
#endif
/* /*
* Whether errata status needs reporting. Errata status is printed in debug * Whether errata status needs reporting. Errata status is printed in debug
* builds for both BL1 and BL31 images. * builds for both BL1 and BL31 images.
...@@ -38,7 +42,7 @@ ...@@ -38,7 +42,7 @@
CPU_MIDR: /* cpu_ops midr */ CPU_MIDR: /* cpu_ops midr */
.space 8 .space 8
/* Reset fn is needed in BL at reset vector */ /* Reset fn is needed in BL at reset vector */
#if defined(IMAGE_BL1) || defined(IMAGE_BL31) #if defined(IMAGE_AT_EL3)
CPU_RESET_FUNC: /* cpu_ops reset_func */ CPU_RESET_FUNC: /* cpu_ops reset_func */
.space 8 .space 8
#endif #endif
...@@ -54,7 +58,7 @@ CPU_PWR_DWN_OPS: /* cpu_ops power down functions */ ...@@ -54,7 +58,7 @@ CPU_PWR_DWN_OPS: /* cpu_ops power down functions */
#if REPORT_ERRATA #if REPORT_ERRATA
CPU_ERRATA_FUNC: CPU_ERRATA_FUNC:
.space 8 .space 8
#ifdef IMAGE_BL31 #if defined(IMAGE_BL31)
CPU_ERRATA_LOCK: CPU_ERRATA_LOCK:
.space 8 .space 8
CPU_ERRATA_PRINTED: CPU_ERRATA_PRINTED:
...@@ -124,7 +128,7 @@ CPU_OPS_SIZE = . ...@@ -124,7 +128,7 @@ CPU_OPS_SIZE = .
.align 3 .align 3
.type cpu_ops_\_name, %object .type cpu_ops_\_name, %object
.quad \_midr .quad \_midr
#if defined(IMAGE_BL1) || defined(IMAGE_BL31) #if defined(IMAGE_AT_EL3)
.quad \_resetfunc .quad \_resetfunc
#endif #endif
#ifdef IMAGE_BL31 #ifdef IMAGE_BL31
......
...@@ -168,7 +168,7 @@ struct xlat_ctx { ...@@ -168,7 +168,7 @@ struct xlat_ctx {
* This IMAGE_EL macro must not to be used outside the library, and it is only * This IMAGE_EL macro must not to be used outside the library, and it is only
* used in AArch64. * used in AArch64.
*/ */
#if defined(IMAGE_BL1) || defined(IMAGE_BL31) #if defined(IMAGE_BL1) || defined(IMAGE_BL31) || (defined(IMAGE_BL2) && BL2_AT_EL3)
# define IMAGE_EL 3 # define IMAGE_EL 3
# define IMAGE_XLAT_DEFAULT_REGIME EL3_REGIME # define IMAGE_XLAT_DEFAULT_REGIME EL3_REGIME
#else #else
......
...@@ -334,6 +334,11 @@ ...@@ -334,6 +334,11 @@
#define BL2_BASE (BL1_RW_BASE - PLAT_ARM_MAX_BL2_SIZE) #define BL2_BASE (BL1_RW_BASE - PLAT_ARM_MAX_BL2_SIZE)
#define BL2_LIMIT BL1_RW_BASE #define BL2_LIMIT BL1_RW_BASE
#elif BL2_AT_EL3
#define BL2_BASE ARM_BL_RAM_BASE
#define BL2_LIMIT (ARM_BL_RAM_BASE + ARM_BL_RAM_SIZE)
#elif defined(AARCH32) || JUNO_AARCH32_EL3_RUNTIME #elif defined(AARCH32) || JUNO_AARCH32_EL3_RUNTIME
/* /*
* Put BL2 just below BL32. * Put BL2 just below BL32.
......
...@@ -145,6 +145,10 @@ uint32_t arm_get_spsr_for_bl32_entry(void); ...@@ -145,6 +145,10 @@ uint32_t arm_get_spsr_for_bl32_entry(void);
uint32_t arm_get_spsr_for_bl33_entry(void); uint32_t arm_get_spsr_for_bl33_entry(void);
int arm_bl2_handle_post_image_load(unsigned int image_id); int arm_bl2_handle_post_image_load(unsigned int image_id);
/* BL2 at EL3 functions */
void arm_bl2_el3_early_platform_setup(void);
void arm_bl2_el3_plat_arch_setup(void);
/* BL2U utility functions */ /* BL2U utility functions */
void arm_bl2u_early_platform_setup(struct meminfo *mem_layout, void arm_bl2u_early_platform_setup(struct meminfo *mem_layout,
void *plat_info); void *plat_info);
......
...@@ -235,6 +235,21 @@ void bl2_plat_get_bl32_meminfo(struct meminfo *mem_info); ...@@ -235,6 +235,21 @@ void bl2_plat_get_bl32_meminfo(struct meminfo *mem_info);
* Optional BL2 functions (may be overridden) * Optional BL2 functions (may be overridden)
******************************************************************************/ ******************************************************************************/
/*******************************************************************************
* Mandatory BL2 at EL3 functions: Must be implemented if BL2_AT_EL3 image is
* supported
******************************************************************************/
void bl2_el3_early_platform_setup(u_register_t arg0, u_register_t arg1,
u_register_t arg2, u_register_t arg3);
void bl2_el3_plat_arch_setup(void);
/*******************************************************************************
* Optional BL2 at EL3 functions (may be overridden)
******************************************************************************/
void bl2_el3_plat_prepare_exit(void);
/******************************************************************************* /*******************************************************************************
* Mandatory BL2U functions. * Mandatory BL2U functions.
******************************************************************************/ ******************************************************************************/
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include <cpu_data.h> #include <cpu_data.h>
#include <cpu_macros.S> #include <cpu_macros.S>
#if defined(IMAGE_BL1) || defined(IMAGE_BL32) #if defined(IMAGE_BL1) || defined(IMAGE_BL32) || (defined(IMAGE_BL2) && BL2_AT_EL3)
/* /*
* The reset handler common to all platforms. After a matching * The reset handler common to all platforms. After a matching
* cpu_ops structure entry is found, the correponding reset_handler * cpu_ops structure entry is found, the correponding reset_handler
...@@ -42,7 +42,7 @@ func reset_handler ...@@ -42,7 +42,7 @@ func reset_handler
bx lr bx lr
endfunc reset_handler endfunc reset_handler
#endif /* IMAGE_BL1 || IMAGE_BL32 */ #endif
#ifdef IMAGE_BL32 /* The power down core and cluster is needed only in BL32 */ #ifdef IMAGE_BL32 /* The power down core and cluster is needed only in BL32 */
/* /*
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include <arch.h> #include <arch.h>
#include <asm_macros.S> #include <asm_macros.S>
#include <assert_macros.S> #include <assert_macros.S>
#ifdef IMAGE_BL31 #if defined(IMAGE_BL31) || (defined(IMAGE_BL2) && BL2_AT_EL3)
#include <cpu_data.h> #include <cpu_data.h>
#endif #endif
#include <cpu_macros.S> #include <cpu_macros.S>
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include <errata_report.h> #include <errata_report.h>
/* Reset fn is needed in BL at reset vector */ /* Reset fn is needed in BL at reset vector */
#if defined(IMAGE_BL1) || defined(IMAGE_BL31) #if defined(IMAGE_BL1) || defined(IMAGE_BL31) || (defined(IMAGE_BL2) && BL2_AT_EL3)
/* /*
* The reset handler common to all platforms. After a matching * The reset handler common to all platforms. After a matching
* cpu_ops structure entry is found, the correponding reset_handler * cpu_ops structure entry is found, the correponding reset_handler
...@@ -47,7 +47,7 @@ func reset_handler ...@@ -47,7 +47,7 @@ func reset_handler
ret ret
endfunc reset_handler endfunc reset_handler
#endif /* IMAGE_BL1 || IMAGE_BL31 */ #endif
#ifdef IMAGE_BL31 /* The power down core and cluster is needed only in BL31 */ #ifdef IMAGE_BL31 /* The power down core and cluster is needed only in BL31 */
/* /*
......
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
# define BL_STRING "BL31" # define BL_STRING "BL31"
#elif defined(AARCH32) && defined(IMAGE_BL32) #elif defined(AARCH32) && defined(IMAGE_BL32)
# define BL_STRING "BL32" # define BL_STRING "BL32"
#elif defined(IMAGE_BL2) && BL2_AT_EL3
# define BL_STRING "BL2"
#else #else
# error This image should not be printing errata status # error This image should not be printing errata status
#endif #endif
......
...@@ -27,6 +27,9 @@ ARM_GIC_ARCH := 2 ...@@ -27,6 +27,9 @@ ARM_GIC_ARCH := 2
# Base commit to perform code check on # Base commit to perform code check on
BASE_COMMIT := origin/master BASE_COMMIT := origin/master
# Execute BL2 at EL3
BL2_AT_EL3 := 0
# By default, consider that the platform may release several CPUs out of reset. # By default, consider that the platform may release several CPUs out of reset.
# The platform Makefile is free to override this value. # The platform Makefile is free to override this value.
COLD_BOOT_SINGLE_CPU := 0 COLD_BOOT_SINGLE_CPU := 0
......
...@@ -64,7 +64,9 @@ $(if ${NON_TRUSTED_WORLD_KEY},$(eval $(call CERT_ADD_CMD_OPT,${NON_TRUSTED_WORLD ...@@ -64,7 +64,9 @@ $(if ${NON_TRUSTED_WORLD_KEY},$(eval $(call CERT_ADD_CMD_OPT,${NON_TRUSTED_WORLD
$(if ${BL2},$(eval $(call CERT_ADD_CMD_OPT,${BL2},--tb-fw,true)),\ $(if ${BL2},$(eval $(call CERT_ADD_CMD_OPT,${BL2},--tb-fw,true)),\
$(eval $(call CERT_ADD_CMD_OPT,$(call IMG_BIN,2),--tb-fw,true))) $(eval $(call CERT_ADD_CMD_OPT,$(call IMG_BIN,2),--tb-fw,true)))
$(eval $(call CERT_ADD_CMD_OPT,${BUILD_PLAT}/tb_fw.crt,--tb-fw-cert)) $(eval $(call CERT_ADD_CMD_OPT,${BUILD_PLAT}/tb_fw.crt,--tb-fw-cert))
ifeq (${BL2_AT_EL3}, 0)
$(eval $(call FIP_ADD_PAYLOAD,${BUILD_PLAT}/tb_fw.crt,--tb-fw-cert)) $(eval $(call FIP_ADD_PAYLOAD,${BUILD_PLAT}/tb_fw.crt,--tb-fw-cert))
endif
# Add the SCP_BL2 CoT (key cert + img cert + image) # Add the SCP_BL2 CoT (key cert + img cert + image)
ifneq (${SCP_BL2},) ifneq (${SCP_BL2},)
......
/*
* Copyright (c) 2017, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <plat_arm.h>
#include "fvp_private.h"
void bl2_el3_early_platform_setup(u_register_t arg0 __unused,
u_register_t arg1 __unused,
u_register_t arg2 __unused,
u_register_t arg3 __unused)
{
arm_bl2_el3_early_platform_setup();
/* Initialize the platform config for future decision making */
fvp_config_setup();
/*
* Initialize Interconnect for this cluster during cold boot.
* No need for locks as no other CPU is active.
*/
fvp_interconnect_init();
/*
* Enable coherency in Interconnect for the primary CPU's cluster.
*/
fvp_interconnect_enable();
}
...@@ -126,6 +126,13 @@ BL2_SOURCES += drivers/io/io_semihosting.c \ ...@@ -126,6 +126,13 @@ BL2_SOURCES += drivers/io/io_semihosting.c \
plat/arm/board/fvp/fvp_trusted_boot.c \ plat/arm/board/fvp/fvp_trusted_boot.c \
${FVP_SECURITY_SOURCES} ${FVP_SECURITY_SOURCES}
ifeq (${BL2_AT_EL3},1)
BL2_SOURCES += plat/arm/board/fvp/${ARCH}/fvp_helpers.S \
plat/arm/board/fvp/fvp_bl2_el3_setup.c \
${FVP_CPU_LIBS} \
${FVP_INTERCONNECT_SOURCES}
endif
ifeq (${FVP_USE_SP804_TIMER},1) ifeq (${FVP_USE_SP804_TIMER},1)
BL2_SOURCES += drivers/arm/sp804/sp804_delay_timer.c BL2_SOURCES += drivers/arm/sp804/sp804_delay_timer.c
endif endif
...@@ -165,5 +172,9 @@ endif ...@@ -165,5 +172,9 @@ endif
# Add support for platform supplied linker script for BL31 build # Add support for platform supplied linker script for BL31 build
$(eval $(call add_define,PLAT_EXTRA_LD_SCRIPT)) $(eval $(call add_define,PLAT_EXTRA_LD_SCRIPT))
ifneq (${BL2_AT_EL3}, 0)
override BL1_SOURCES =
endif
include plat/arm/board/common/board_common.mk include plat/arm/board/common/board_common.mk
include plat/arm/common/arm_common.mk include plat/arm/common/arm_common.mk
/*
* Copyright (c) 2017, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <console.h>
#include <generic_delay_timer.h>
#include <plat_arm.h>
#include <platform.h>
#pragma weak bl2_el3_early_platform_setup
#pragma weak bl2_el3_plat_arch_setup
#pragma weak bl2_el3_plat_prepare_exit
static meminfo_t bl2_el3_tzram_layout;
/*
* Perform arm specific early platform setup. At this moment we only initialize
* the console and the memory layout.
*/
void arm_bl2_el3_early_platform_setup(void)
{
/* Initialize the console to provide early debug support */
console_init(PLAT_ARM_BOOT_UART_BASE, PLAT_ARM_BOOT_UART_CLK_IN_HZ,
ARM_CONSOLE_BAUDRATE);
/*
* Allow BL2 to see the whole Trusted RAM. This is determined
* statically since we cannot rely on BL1 passing this information
* in the BL2_AT_EL3 case.
*/
bl2_el3_tzram_layout.total_base = ARM_BL_RAM_BASE;
bl2_el3_tzram_layout.total_size = ARM_BL_RAM_SIZE;
/* Initialise the IO layer and register platform IO devices */
plat_arm_io_setup();
}
void bl2_el3_early_platform_setup(u_register_t arg0 __unused,
u_register_t arg1 __unused,
u_register_t arg2 __unused,
u_register_t arg3 __unused)
{
arm_bl2_el3_early_platform_setup();
/*
* Initialize Interconnect for this cluster during cold boot.
* No need for locks as no other CPU is active.
*/
plat_arm_interconnect_init();
/*
* Enable Interconnect coherency for the primary CPU's cluster.
*/
plat_arm_interconnect_enter_coherency();
generic_delay_timer_init();
}
/*******************************************************************************
* Perform the very early platform specific architectural setup here. At the
* moment this is only initializes the mmu in a quick and dirty way.
******************************************************************************/
void arm_bl2_el3_plat_arch_setup(void)
{
arm_setup_page_tables(bl2_el3_tzram_layout.total_base,
bl2_el3_tzram_layout.total_size,
BL_CODE_BASE,
BL_CODE_END,
BL_RO_DATA_BASE,
BL_RO_DATA_END
#if USE_COHERENT_MEM
, BL_COHERENT_RAM_BASE,
BL_COHERENT_RAM_END
#endif
);
#ifdef AARCH32
enable_mmu_secure(0);
#else
enable_mmu_el3(0);
#endif
}
void bl2_el3_plat_arch_setup(void)
{
arm_bl2_el3_plat_arch_setup();
}
void bl2_el3_plat_prepare_exit(void)
{
}
...@@ -150,6 +150,11 @@ BL2_SOURCES += drivers/delay_timer/delay_timer.c \ ...@@ -150,6 +150,11 @@ BL2_SOURCES += drivers/delay_timer/delay_timer.c \
drivers/io/io_storage.c \ drivers/io/io_storage.c \
plat/arm/common/arm_bl2_setup.c \ plat/arm/common/arm_bl2_setup.c \
plat/arm/common/arm_io_storage.c plat/arm/common/arm_io_storage.c
ifeq (${BL2_AT_EL3},1)
BL2_SOURCES += plat/arm/common/arm_bl2_el3_setup.c
endif
ifeq (${LOAD_IMAGE_V2},1) ifeq (${LOAD_IMAGE_V2},1)
# Because BL1/BL2 execute in AArch64 mode but BL32 in AArch32 we need to use # Because BL1/BL2 execute in AArch64 mode but BL32 in AArch32 we need to use
# the AArch32 descriptors. # the AArch32 descriptors.
......
/*
* Copyright (c) 2017, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <arch_helpers.h>
#include <assert.h>
#include <bl_common.h>
#include <debug.h>
#include <errno.h>
#include <platform_def.h>
/*
* The following platform functions are weakly defined. They
* are default implementations that allow BL2 to compile in
* absence of real definitions. The Platforms may override
* with more complex definitions.
*/
#pragma weak bl2_el3_plat_prepare_exit
void bl2_el3_plat_prepare_exit(void)
{
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment