summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2020-12-18 10:11:51 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2020-12-23 09:19:17 +0100
commit272534eb725f2486b7a32b39d998202a101bd36e (patch)
tree1cd2ae81d871698e49093fb0ec2488d88e0593d9
parentarm: Add support for Arm PMSAv8-32 (diff)
downloadrtems-272534eb725f2486b7a32b39d998202a101bd36e.tar.bz2
bsps/arm: Set VBAR in start.S
Set the VBAR to the vector table in the start section before bsp_start_hook_0() is called to earlier handle exceptions in RTEMS. Set the VBAR to the normal vector table in start.S for the main processor. Secondary processors set it in bsp_start_hook_0(). Update #4202.
-rw-r--r--bsps/arm/beagle/start/bspstarthooks.c4
-rw-r--r--bsps/arm/headers.am1
-rw-r--r--bsps/arm/imx/start/bspstarthooks.c1
-rw-r--r--bsps/arm/include/bsp/arm-a8core-start.h55
-rw-r--r--bsps/arm/include/bsp/arm-a9mpcore-start.h28
-rw-r--r--bsps/arm/raspberrypi/start/bspsmp_init.c3
-rw-r--r--bsps/arm/raspberrypi/start/bspstarthooks.c3
-rw-r--r--bsps/arm/shared/start/start.S28
-rw-r--r--bsps/arm/xen/start/bspstarthooks.c2
-rw-r--r--bsps/arm/xilinx-zynqmp/start/bspstarthooks.c2
-rw-r--r--spec/build/bsps/arm/grp.yml1
11 files changed, 34 insertions, 94 deletions
diff --git a/bsps/arm/beagle/start/bspstarthooks.c b/bsps/arm/beagle/start/bspstarthooks.c
index 2efa3042a8..38f2903d4d 100644
--- a/bsps/arm/beagle/start/bspstarthooks.c
+++ b/bsps/arm/beagle/start/bspstarthooks.c
@@ -15,9 +15,6 @@
#include <bsp.h>
#include <bsp/start.h>
#include <bsp/arm-cp15-start.h>
-#include <bsp/arm-a8core-start.h>
-
-#include <bsp/uart-output-char.h>
BSP_START_TEXT_SECTION void bsp_start_hook_0(void)
{
@@ -25,7 +22,6 @@ BSP_START_TEXT_SECTION void bsp_start_hook_0(void)
BSP_START_TEXT_SECTION void bsp_start_hook_1(void)
{
- arm_a8core_start_hook_1();
bsp_start_copy_sections();
beagle_setup_mmu_and_cache();
bsp_start_clear_bss();
diff --git a/bsps/arm/headers.am b/bsps/arm/headers.am
index a4d6dfa09e..92af7e1059 100644
--- a/bsps/arm/headers.am
+++ b/bsps/arm/headers.am
@@ -10,7 +10,6 @@ include_HEADERS += ../../../../../bsps/arm/include/uart.h
include_bspdir = $(includedir)/bsp
include_bsp_HEADERS =
-include_bsp_HEADERS += ../../../../../bsps/arm/include/bsp/arm-a8core-start.h
include_bsp_HEADERS += ../../../../../bsps/arm/include/bsp/arm-a9mpcore-clock.h
include_bsp_HEADERS += ../../../../../bsps/arm/include/bsp/arm-a9mpcore-irq.h
include_bsp_HEADERS += ../../../../../bsps/arm/include/bsp/arm-a9mpcore-regs.h
diff --git a/bsps/arm/imx/start/bspstarthooks.c b/bsps/arm/imx/start/bspstarthooks.c
index d35374e360..f2ea7b4863 100644
--- a/bsps/arm/imx/start/bspstarthooks.c
+++ b/bsps/arm/imx/start/bspstarthooks.c
@@ -102,7 +102,6 @@ BSP_START_TEXT_SECTION void bsp_start_hook_0(void)
BSP_START_TEXT_SECTION void bsp_start_hook_1(void)
{
- arm_a9mpcore_start_set_vector_base();
bsp_start_copy_sections();
setup_mmu_and_cache();
bsp_start_clear_bss();
diff --git a/bsps/arm/include/bsp/arm-a8core-start.h b/bsps/arm/include/bsp/arm-a8core-start.h
deleted file mode 100644
index d9b7274018..0000000000
--- a/bsps/arm/include/bsp/arm-a8core-start.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * @file
- *
- * @ingroup RTEMSBSPsARMShared
- *
- * @brief A8CORE_START Support
- */
-
-/*
- * Copyright (c) 2014 Chris Johns <chrisj@rtems.org>. All rights reserved.
- *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.org/license/LICENSE.
- */
-
-#ifndef LIBBSP_ARM_SHARED_ARM_A8CORE_START_H
-#define LIBBSP_ARM_SHARED_ARM_A8CORE_START_H
-
-#include <libcpu/arm-cp15.h>
-
-#include <bsp.h>
-#include <bsp/start.h>
-#include <bsp/arm-errata.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-BSP_START_TEXT_SECTION static inline void arm_a8core_start_set_vector_base(void)
-{
- /*
- * Do not use bsp_vector_table_begin == 0, since this will get optimized away.
- */
- if (bsp_vector_table_end != bsp_vector_table_size) {
- uint32_t ctrl;
-
- arm_cp15_set_vector_base_address(bsp_vector_table_begin);
-
- ctrl = arm_cp15_get_control();
- ctrl &= ~ARM_CP15_CTRL_V;
- arm_cp15_set_control(ctrl);
- }
-}
-
-BSP_START_TEXT_SECTION static inline void arm_a8core_start_hook_1(void)
-{
- arm_a8core_start_set_vector_base();
-}
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* LIBBSP_ARM_SHARED_ARM_A8CORE_START_H */
diff --git a/bsps/arm/include/bsp/arm-a9mpcore-start.h b/bsps/arm/include/bsp/arm-a9mpcore-start.h
index 5f870acec7..f377745c56 100644
--- a/bsps/arm/include/bsp/arm-a9mpcore-start.h
+++ b/bsps/arm/include/bsp/arm-a9mpcore-start.h
@@ -30,6 +30,7 @@
#include <bsp.h>
#include <bsp/start.h>
#include <bsp/arm-a9mpcore-regs.h>
+#include <bsp/arm-cp15-start.h>
#include <bsp/arm-errata.h>
#include <dev/irq/arm-gic-irq.h>
@@ -37,27 +38,6 @@
extern "C" {
#endif /* __cplusplus */
-BSP_START_TEXT_SECTION static inline void
-arm_a9mpcore_start_set_vector_base(void)
-{
- /*
- * Do not use bsp_vector_table_begin == 0, since this will get optimized away.
- */
- if (bsp_vector_table_end != bsp_vector_table_size) {
- uint32_t ctrl;
-
- /*
- * For now we assume that every Cortex-A9 MPCore has the Security Extensions.
- * Later it might be necessary to evaluate the ID_PFR1 register.
- */
- arm_cp15_set_vector_base_address(bsp_vector_table_begin);
-
- ctrl = arm_cp15_get_control();
- ctrl &= ~ARM_CP15_CTRL_V;
- arm_cp15_set_control(ctrl);
- }
-}
-
BSP_START_TEXT_SECTION static inline void arm_a9mpcore_start_scu_invalidate(
volatile a9mpcore_scu *scu,
uint32_t cpu_id,
@@ -88,10 +68,11 @@ arm_a9mpcore_start_on_secondary_processor(void)
{
uint32_t ctrl;
- arm_a9mpcore_start_set_vector_base();
-
arm_gic_irq_initialize_secondary_cpu();
+ /* Change the VBAR from the start to the normal vector table */
+ arm_cp15_set_vector_base_address(bsp_vector_table_begin);
+
ctrl = arm_cp15_start_setup_mmu_and_cache(
0,
ARM_CP15_CTRL_AFE | ARM_CP15_CTRL_Z
@@ -194,7 +175,6 @@ BSP_START_TEXT_SECTION static inline void arm_a9mpcore_start_global_timer(void)
BSP_START_TEXT_SECTION static inline void arm_a9mpcore_start_hook_1(void)
{
arm_a9mpcore_start_global_timer();
- arm_a9mpcore_start_set_vector_base();
}
#ifdef __cplusplus
diff --git a/bsps/arm/raspberrypi/start/bspsmp_init.c b/bsps/arm/raspberrypi/start/bspsmp_init.c
index a8c79e9f7c..a4dd470287 100644
--- a/bsps/arm/raspberrypi/start/bspsmp_init.c
+++ b/bsps/arm/raspberrypi/start/bspsmp_init.c
@@ -55,6 +55,9 @@ void rpi_start_rtems_on_secondary_processor(void)
{
uint32_t ctrl;
+ /* Change the VBAR from the start to the normal vector table */
+ arm_cp15_set_vector_base_address(bsp_vector_table_begin);
+
ctrl = arm_cp15_start_setup_mmu_and_cache(
0,
ARM_CP15_CTRL_AFE | ARM_CP15_CTRL_Z
diff --git a/bsps/arm/raspberrypi/start/bspstarthooks.c b/bsps/arm/raspberrypi/start/bspstarthooks.c
index eb6546db1c..c46c4f5cbf 100644
--- a/bsps/arm/raspberrypi/start/bspstarthooks.c
+++ b/bsps/arm/raspberrypi/start/bspstarthooks.c
@@ -117,9 +117,6 @@ void BSP_START_TEXT_SECTION bsp_start_hook_0(void)
/* Clear Translation Table Base Control Register */
arm_cp15_set_translation_table_base_control_register(0);
- /* Clear Secure or Non-secure Vector Base Address Register */
- arm_cp15_set_vector_base_address(bsp_vector_table_begin);
-
#ifdef RTEMS_SMP
if (cpu_index_self == 0) {
rpi_ipi_initialize();
diff --git a/bsps/arm/shared/start/start.S b/bsps/arm/shared/start/start.S
index 93590c1c36..9ebc2818e5 100644
--- a/bsps/arm/shared/start/start.S
+++ b/bsps/arm/shared/start/start.S
@@ -377,6 +377,20 @@ _start:
#endif /* ARM_MULTILIB_VFP */
+#if (__ARM_ARCH >= 7 && __ARM_ARCH_PROFILE == 'A') || __ARM_ARCH >= 8
+ /*
+ * Set VBAR to the vector table in the start section and make sure
+ * SCTLR[V] is cleared. Afterwards, exceptions are handled by RTEMS.
+ */
+ ldr r0, =bsp_start_vector_table_begin
+ dsb
+ mcr p15, 0, r0, c12, c0, 0
+ mrc p15, 0, r0, c1, c0, 0
+ bic r1, r0, #0x2000
+ mcr p15, 0, r1, c1, c0, 0
+ isb
+#endif
+
/*
* Invoke the start hook 0.
*
@@ -414,7 +428,7 @@ bsp_start_hook_0_done:
stmdb sp!, {r4, r5, r6}
ldr r0, =bsp_vector_table_begin
- adr r1, bsp_start_vector_table_begin
+ ldr r1, =bsp_start_vector_table_begin
cmp r0, r1
beq .Lvector_table_copy_done
ldmia r1!, {r2-r9}
@@ -424,6 +438,18 @@ bsp_start_hook_0_done:
.Lvector_table_copy_done:
+#if (__ARM_ARCH >= 7 && __ARM_ARCH_PROFILE == 'A') || __ARM_ARCH >= 8
+ /*
+ * This code path is only executed by the primary processor. Set the
+ * VBAR to the normal vector table. For secondary processors, this is
+ * done by bsp_start_hook_0().
+ */
+ ldr r0, =bsp_vector_table_begin
+ dsb
+ mcr p15, 0, r0, c12, c0, 0
+ isb
+#endif
+
ldmia sp!, {r0, r1, r2}
SWITCH_FROM_ARM_TO_THUMB r3
diff --git a/bsps/arm/xen/start/bspstarthooks.c b/bsps/arm/xen/start/bspstarthooks.c
index 120535c60f..a9e1fbbfb1 100644
--- a/bsps/arm/xen/start/bspstarthooks.c
+++ b/bsps/arm/xen/start/bspstarthooks.c
@@ -28,7 +28,6 @@
#include <bsp.h>
#include <bsp/start.h>
-#include <bsp/arm-a9mpcore-start.h>
BSP_START_TEXT_SECTION void bsp_start_hook_0(void)
{
@@ -37,7 +36,6 @@ BSP_START_TEXT_SECTION void bsp_start_hook_0(void)
BSP_START_TEXT_SECTION void bsp_start_hook_1(void)
{
- arm_a9mpcore_start_set_vector_base();
bsp_start_copy_sections();
bsp_xen_setup_mmu_and_cache();
bsp_start_clear_bss();
diff --git a/bsps/arm/xilinx-zynqmp/start/bspstarthooks.c b/bsps/arm/xilinx-zynqmp/start/bspstarthooks.c
index 3a40a70d81..9ab8d965f3 100644
--- a/bsps/arm/xilinx-zynqmp/start/bspstarthooks.c
+++ b/bsps/arm/xilinx-zynqmp/start/bspstarthooks.c
@@ -35,7 +35,6 @@
#include <bsp.h>
#include <bsp/start.h>
#include <bsp/arm-cp15-start.h>
-#include <bsp/arm-a9mpcore-start.h>
BSP_START_TEXT_SECTION void bsp_start_hook_0(void)
{
@@ -80,7 +79,6 @@ BSP_START_TEXT_SECTION void bsp_start_hook_0(void)
BSP_START_TEXT_SECTION void bsp_start_hook_1(void)
{
- arm_a9mpcore_start_set_vector_base();
bsp_start_copy_sections();
zynqmp_setup_mmu_and_cache();
bsp_start_clear_bss();
diff --git a/spec/build/bsps/arm/grp.yml b/spec/build/bsps/arm/grp.yml
index 8d2aba12ca..408288044f 100644
--- a/spec/build/bsps/arm/grp.yml
+++ b/spec/build/bsps/arm/grp.yml
@@ -15,7 +15,6 @@ install:
- bsps/arm/include/uart.h
- destination: ${BSP_INCLUDEDIR}/bsp
source:
- - bsps/arm/include/bsp/arm-a8core-start.h
- bsps/arm/include/bsp/arm-a9mpcore-clock.h
- bsps/arm/include/bsp/arm-a9mpcore-irq.h
- bsps/arm/include/bsp/arm-a9mpcore-regs.h