This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new cc0ee12092 arch/arm/samv7: add ARCH_RAMVECTORS support
cc0ee12092 is described below

commit cc0ee120929b132c07262a243417ce6152e4deed
Author: Petro Karashchenko <petro.karashche...@gmail.com>
AuthorDate: Sat Dec 17 00:29:44 2022 +0200

    arch/arm/samv7: add ARCH_RAMVECTORS support
    
    Signed-off-by: Petro Karashchenko <petro.karashche...@gmail.com>
---
 arch/arm/src/samv7/sam_irq.c                      | 13 +++++++++++--
 boards/arm/samv7/common/scripts/flash.ld.template |  8 +++++++-
 boards/arm/samv7/common/scripts/kernel-space.ld   |  8 +++++++-
 3 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/arch/arm/src/samv7/sam_irq.c b/arch/arm/src/samv7/sam_irq.c
index af9cfcde8f..0ee4aff8b5 100644
--- a/arch/arm/src/samv7/sam_irq.c
+++ b/arch/arm/src/samv7/sam_irq.c
@@ -34,7 +34,9 @@
 #include <arch/armv7-m/nvicpri.h>
 
 #include "nvic.h"
-#include "ram_vectors.h"
+#ifdef CONFIG_ARCH_RAMVECTORS
+#  include "ram_vectors.h"
+#endif
 #include "arm_internal.h"
 
 #ifdef CONFIG_SAMV7_GPIO_IRQ
@@ -81,7 +83,7 @@ static void sam_dumpnvic(const char *msg, int irq)
 
   irqinfo("NVIC (%s, irq=%d):\n", msg, irq);
   irqinfo("  INTCTRL:    %08x VECTAB:  %08x\n",
-        getreg32(NVIC_INTCTRL), getreg32(NVIC_VECTAB));
+          getreg32(NVIC_INTCTRL), getreg32(NVIC_VECTAB));
 #if 0
   irqinfo("  SYSH ENABLE MEMFAULT: %08x BUSFAULT: %08x USGFAULT: %08x "
           "SYSTICK: %08x\n",
@@ -359,6 +361,13 @@ void up_irqinitialize(void)
    */
 
   arm_ramvec_initialize();
+
+  /* At this moment both I- and D-Caches have been already enabled in
+   * __start so we need to flush RAM vectors table to memory.
+   */
+
+  up_clean_dcache((uintptr_t)g_ram_vectors,
+                  (uintptr_t)g_ram_vectors + sizeof(g_ram_vectors));
 #endif
 
   /* Set all interrupts (and exceptions) to the default priority */
diff --git a/boards/arm/samv7/common/scripts/flash.ld.template 
b/boards/arm/samv7/common/scripts/flash.ld.template
index 3f9fc22b72..f78d044d1f 100644
--- a/boards/arm/samv7/common/scripts/flash.ld.template
+++ b/boards/arm/samv7/common/scripts/flash.ld.template
@@ -88,6 +88,12 @@ SECTIONS
 
     _eronly = ABSOLUTE(.);
 
+    /* The RAM vector table (if present) should lie at the beginning of SRAM */
+
+    .ram_vectors : {
+        *(.ram_vectors)
+    } > sram
+
     .data : {
         _sdata = ABSOLUTE(.);
         *(.data .data.*)
@@ -97,7 +103,7 @@ SECTIONS
         _edata = ABSOLUTE(.);
     } > sram AT > flash
 
-    .ramfunc ALIGN(4): {
+    .ramfunc : ALIGN(4) {
         _sramfuncs = ABSOLUTE(.);
         *(.ramfunc  .ramfunc.*)
         _eramfuncs = ABSOLUTE(.);
diff --git a/boards/arm/samv7/common/scripts/kernel-space.ld 
b/boards/arm/samv7/common/scripts/kernel-space.ld
index 6830bd512a..f5fa217a27 100644
--- a/boards/arm/samv7/common/scripts/kernel-space.ld
+++ b/boards/arm/samv7/common/scripts/kernel-space.ld
@@ -63,6 +63,12 @@ SECTIONS
 
     _eronly = ABSOLUTE(.);
 
+    /* The RAM vector table (if present) should lie at the beginning of SRAM */
+
+    .ram_vectors : {
+        *(.ram_vectors)
+    } > ksram
+
     .data : {
         _sdata = ABSOLUTE(.);
         *(.data .data.*)
@@ -72,7 +78,7 @@ SECTIONS
         _edata = ABSOLUTE(.);
     } > ksram AT > kflash
 
-    .ramfunc ALIGN(4): {
+    .ramfunc : ALIGN(4) {
         _sramfuncs = ABSOLUTE(.);
         *(.ramfunc  .ramfunc.*)
         _eramfuncs = ABSOLUTE(.);

Reply via email to