diff --git a/bsps/aarch64/a53/start/bspstarthooks.c b/bsps/aarch64/a53/start/bspstarthooks.c index 20d3bc6e70..8f17fa1710 100644 --- a/bsps/aarch64/a53/start/bspstarthooks.c +++ b/bsps/aarch64/a53/start/bspstarthooks.c @@ -37,10 +37,12 @@ #include #include +#ifdef BSP_START_ENABLE_EL3_START_SUPPORT BSP_START_TEXT_SECTION void bsp_start_hook_0(void) { /* Do nothing */ } +#endif BSP_START_TEXT_SECTION void bsp_start_hook_1(void) { diff --git a/bsps/aarch64/a72/start/bspstarthooks.c b/bsps/aarch64/a72/start/bspstarthooks.c index 20d3bc6e70..8f17fa1710 100644 --- a/bsps/aarch64/a72/start/bspstarthooks.c +++ b/bsps/aarch64/a72/start/bspstarthooks.c @@ -37,10 +37,12 @@ #include #include +#ifdef BSP_START_ENABLE_EL3_START_SUPPORT BSP_START_TEXT_SECTION void bsp_start_hook_0(void) { /* Do nothing */ } +#endif BSP_START_TEXT_SECTION void bsp_start_hook_1(void) { diff --git a/bsps/aarch64/raspberrypi/start/bspstarthooks.c b/bsps/aarch64/raspberrypi/start/bspstarthooks.c index fe0fe77c09..985a3d4f4a 100644 --- a/bsps/aarch64/raspberrypi/start/bspstarthooks.c +++ b/bsps/aarch64/raspberrypi/start/bspstarthooks.c @@ -39,10 +39,12 @@ #include #include +#ifdef BSP_START_ENABLE_EL3_START_SUPPORT BSP_START_TEXT_SECTION void bsp_start_hook_0(void) { /* Do nothing */ } +#endif BSP_START_TEXT_SECTION void bsp_start_hook_1(void) { @@ -50,4 +52,4 @@ BSP_START_TEXT_SECTION void bsp_start_hook_1(void) bsp_start_copy_sections(); raspberrypi_4_setup_mmu_and_cache(); bsp_start_clear_bss(); -} \ No newline at end of file +} diff --git a/bsps/aarch64/shared/start/start.S b/bsps/aarch64/shared/start/start.S index d778d7f183..f3038c81cd 100644 --- a/bsps/aarch64/shared/start/start.S +++ b/bsps/aarch64/shared/start/start.S @@ -137,13 +137,18 @@ _start: #endif msr SCTLR_EL1, x0 +#if defined(BSP_START_ENABLE_EL2_START_SUPPORT) || \ + defined(BSP_START_ENABLE_EL3_START_SUPPORT) mrs x0, CurrentEL cmp x0, #(1<<2) - b.eq _el1_start - cmp x0, #(2<<2) - b.eq _el2_start + b.eq .L_el1_start +#endif -_el3_start: +#if defined(BSP_START_ENABLE_EL3_START_SUPPORT) + cmp x0, #(2<<2) + b.eq .L_el2_start + +.L_el3_start: /* * Before leaving the Secure World, we need to initialize the GIC. We * do that here in an early stack context in EL3. This will NOT work @@ -189,11 +194,14 @@ _el3_start: msr SPSR_EL3, x0 /* Set EL2 entry point */ - adr x0, _el2_start + adr x0, .L_el2_start msr ELR_EL3, x0 eret +#endif -_el2_start: +#if defined(BSP_START_ENABLE_EL2_START_SUPPORT) || \ + defined(BSP_START_ENABLE_EL3_START_SUPPORT) +.L_el2_start: /* Drop from EL2 to EL1 */ /* Configure HCR_EL2 */ @@ -212,11 +220,12 @@ _el2_start: msr SPSR_EL2, x0 /* Set EL1 entry point */ - adr x0, _el1_start + adr x0, .L_el1_start msr ELR_EL2, x0 eret -_el1_start: +.L_el1_start: +#endif #ifdef RTEMS_SMP bl _AArch64_Get_current_processor_for_system_start diff --git a/bsps/aarch64/xilinx-versal/start/bspstarthooks.c b/bsps/aarch64/xilinx-versal/start/bspstarthooks.c index 71d161125b..2b207a8961 100644 --- a/bsps/aarch64/xilinx-versal/start/bspstarthooks.c +++ b/bsps/aarch64/xilinx-versal/start/bspstarthooks.c @@ -38,10 +38,12 @@ #include #include +#ifdef BSP_START_ENABLE_EL3_START_SUPPORT BSP_START_TEXT_SECTION void bsp_start_hook_0(void) { bsp_interrupt_facility_initialize(); } +#endif BSP_START_TEXT_SECTION void bsp_start_hook_1(void) { diff --git a/bsps/aarch64/xilinx-zynqmp/start/bspstarthooks.c b/bsps/aarch64/xilinx-zynqmp/start/bspstarthooks.c index 14f2bcc280..aa24c49fa4 100644 --- a/bsps/aarch64/xilinx-zynqmp/start/bspstarthooks.c +++ b/bsps/aarch64/xilinx-zynqmp/start/bspstarthooks.c @@ -45,10 +45,12 @@ #include #endif +#ifdef BSP_START_ENABLE_EL3_START_SUPPORT BSP_START_TEXT_SECTION void bsp_start_hook_0( void ) { /* do nothing */ } +#endif BSP_START_TEXT_SECTION void bsp_start_hook_1( void ) { diff --git a/spec/build/bsps/aarch64/optstartel2.yml b/spec/build/bsps/aarch64/optstartel2.yml new file mode 100644 index 0000000000..83572da61d --- /dev/null +++ b/spec/build/bsps/aarch64/optstartel2.yml @@ -0,0 +1,18 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +actions: +- get-boolean: null +- define-condition: null +build-type: option +copyrights: +- Copyright (C) 2024 embedded brains GmbH & Co. KG +default: +- enabled-by: true + value: true +description: | + If this option is defined, then starting the system in exception level 2 + (EL2) is supported. +enabled-by: true +format: '{}' +links: [] +name: BSP_START_ENABLE_EL2_START_SUPPORT +type: build diff --git a/spec/build/bsps/aarch64/optstartel3.yml b/spec/build/bsps/aarch64/optstartel3.yml new file mode 100644 index 0000000000..e426c2a4db --- /dev/null +++ b/spec/build/bsps/aarch64/optstartel3.yml @@ -0,0 +1,20 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +actions: +- get-boolean: null +- define-condition: null +build-type: option +copyrights: +- Copyright (C) 2024 embedded brains GmbH & Co. KG +default: +- enabled-by: bsps/aarch64/xilinx-zynqmp + value: false +- enabled-by: true + value: true +description: | + If this option is defined, then starting the system in exception level 3 + (EL3) is supported. +enabled-by: true +format: '{}' +links: [] +name: BSP_START_ENABLE_EL3_START_SUPPORT +type: build diff --git a/spec/build/bsps/aarch64/start.yml b/spec/build/bsps/aarch64/start.yml index 9a80f73243..aa251733a1 100644 --- a/spec/build/bsps/aarch64/start.yml +++ b/spec/build/bsps/aarch64/start.yml @@ -7,7 +7,11 @@ cppflags: [] enabled-by: true includes: [] install-path: ${BSP_LIBDIR} -links: [] +links: +- role: build-dependency + uid: optstartel2 +- role: build-dependency + uid: optstartel3 source: - bsps/aarch64/shared/start/start.S target: start.o