[rtems commit] m68k/mcf5235: GCC 4.9.2 generates invalid code for Init5235.

Chris Johns chrisj at rtems.org
Mon Dec 1 03:57:01 UTC 2014


Module:    rtems
Branch:    master
Commit:    dd309b10544bfceda968ac847ad34c3d90ca8281
Changeset: http://git.rtems.org/rtems/commit/?id=dd309b10544bfceda968ac847ad34c3d90ca8281

Author:    Chris Johns <chrisj at rtems.org>
Date:      Mon Dec  1 14:55:23 2014 +1100

m68k/mcf5235: GCC 4.9.2 generates invalid code for Init5235.

Move the vector table copy out of the Init5235 source to avoid
stipping the GCC bug.

Fixes #2204.

---

 c/src/lib/libbsp/m68k/mcf5235/Makefile.am           |  3 ++-
 c/src/lib/libbsp/m68k/mcf5235/startup/copyvectors.c | 19 +++++++++++++++++++
 c/src/lib/libbsp/m68k/mcf5235/startup/init5235.c    | 17 +++++------------
 3 files changed, 26 insertions(+), 13 deletions(-)

diff --git a/c/src/lib/libbsp/m68k/mcf5235/Makefile.am b/c/src/lib/libbsp/m68k/mcf5235/Makefile.am
index 403b47f..f24d830 100644
--- a/c/src/lib/libbsp/m68k/mcf5235/Makefile.am
+++ b/c/src/lib/libbsp/m68k/mcf5235/Makefile.am
@@ -32,7 +32,8 @@ libbsp_a_SOURCES += ../../shared/bspclean.c ../../shared/bsppredriverhook.c \
     startup/bspgetcpuclockspeed.c ../../shared/bsppretaskinghook.c \
     ../../shared/bspgetworkarea.c startup/init5235.c startup/bspstart.c \
     ../../shared/bootcard.c ../../shared/sbrk.c ../../shared/setvec.c \
-    ../../shared/gnatinstallhandler.c ../../shared/bspinit.c
+    ../../shared/gnatinstallhandler.c ../../shared/bspinit.c \
+    startup/copyvectors.c
 # clock
 libbsp_a_SOURCES += clock/clock.c ../../../shared/clockdrv_shell.h
 # console
diff --git a/c/src/lib/libbsp/m68k/mcf5235/startup/copyvectors.c b/c/src/lib/libbsp/m68k/mcf5235/startup/copyvectors.c
new file mode 100644
index 0000000..2c54c31
--- /dev/null
+++ b/c/src/lib/libbsp/m68k/mcf5235/startup/copyvectors.c
@@ -0,0 +1,19 @@
+/*
+ * Move the copy out of the Init5235 file because gcc is broken.
+ */
+
+#include <stdint.h>
+
+void CopyVectors(const uint32_t* old, uint32_t* new);
+
+void CopyVectors(const uint32_t* old, uint32_t* new)
+{
+    int v = 0;
+    while (v < 256)
+    {
+        *new = *old;
+        ++v;
+        ++new;
+        ++old;
+    }
+}
diff --git a/c/src/lib/libbsp/m68k/mcf5235/startup/init5235.c b/c/src/lib/libbsp/m68k/mcf5235/startup/init5235.c
index 7d8ee23..5066941 100644
--- a/c/src/lib/libbsp/m68k/mcf5235/startup/init5235.c
+++ b/c/src/lib/libbsp/m68k/mcf5235/startup/init5235.c
@@ -9,9 +9,7 @@
 
 #include <rtems.h>
 #include <bsp.h>
-#define m68k_set_cacr(_cacr) __asm__ volatile ("movec %0,%%cacr" : : "d" (_cacr))
-#define m68k_set_acr0(_acr0) __asm__ volatile ("movec %0,%%acr0" : : "d" (_acr0))
-#define m68k_set_acr1(_acr1) __asm__ volatile ("movec %0,%%acr1" : : "d" (_acr1))
+
 #define MM_SDRAM_BASE		(0x00000000)
 
 /*
@@ -26,6 +24,8 @@ extern uint32_t MCF5235_BSP_START_FROM_FLASH;
 extern void CopyDataClearBSSAndStart (void);
 extern void INTERRUPT_VECTOR(void);
 
+extern void CopyVectors(const uint32_t* old, uint32_t* new);
+
 void Init5235 (void)
 {
     int x;
@@ -77,15 +77,7 @@ void Init5235 (void)
     } /* we have finished setting up the sdram */
 
     /* Copy the interrupt vector table to address 0x0 in SDRAM */
-    {
-        uint32_t *inttab = (uint32_t *)&INTERRUPT_VECTOR;
-        uint32_t *intvec = (uint32_t *)0x0;
-        register int i;
-        for (i = 0; i < 256; i++)
-        {
-            *(intvec++) = *(inttab++);
-        }
-    }
+    CopyVectors((const uint32_t *)&INTERRUPT_VECTOR, (uint32_t*)0);
 
     m68k_set_vbr(0);
 
@@ -93,4 +85,5 @@ void Init5235 (void)
      * Copy data, clear BSS and call boot_card()
      */
     CopyDataClearBSSAndStart ();
+
 }




More information about the vc mailing list