summaryrefslogtreecommitdiffstats
path: root/c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2011-11-08 10:18:19 +0000
committerSebastian Huber <sebastian.huber@embedded-brains.de>2011-11-08 10:18:19 +0000
commit4c622e5f4a24f0675840a0463780b03a4d897c1e (patch)
tree98e5a90ad2ec8af0704d98a6e45282f30c8026b3 /c
parent2011-11-08 Sebastian Huber <sebastian.huber@embedded-brains.de> (diff)
downloadrtems-4c622e5f4a24f0675840a0463780b03a4d897c1e.tar.bz2
2011-11-08 Sebastian Huber <sebastian.huber@embedded-brains.de>
* shared/startup/bsp-start-copy-sections.c, shared/startup/bsp-start-memcpy.S: New files. * shared/include/start.h: Declare bsp_start_copy_sections(). * shared/start/start.S, shared/include/linker-symbols.h: Moved content. Support for ARMv7-M.
Diffstat (limited to 'c')
-rw-r--r--c/src/lib/libbsp/arm/ChangeLog8
-rw-r--r--c/src/lib/libbsp/arm/shared/include/linker-symbols.h4
-rw-r--r--c/src/lib/libbsp/arm/shared/include/start.h18
-rw-r--r--c/src/lib/libbsp/arm/shared/start/start.S148
-rw-r--r--c/src/lib/libbsp/arm/shared/startup/bsp-start-copy-sections.c68
-rw-r--r--c/src/lib/libbsp/arm/shared/startup/bsp-start-memcpy.S147
6 files changed, 314 insertions, 79 deletions
diff --git a/c/src/lib/libbsp/arm/ChangeLog b/c/src/lib/libbsp/arm/ChangeLog
index 38648a6e37..b4b73daebc 100644
--- a/c/src/lib/libbsp/arm/ChangeLog
+++ b/c/src/lib/libbsp/arm/ChangeLog
@@ -1,3 +1,11 @@
+2011-11-08 Sebastian Huber <sebastian.huber@embedded-brains.de>
+
+ * shared/startup/bsp-start-copy-sections.c,
+ shared/startup/bsp-start-memcpy.S: New files.
+ * shared/include/start.h: Declare bsp_start_copy_sections().
+ * shared/start/start.S, shared/include/linker-symbols.h: Moved
+ content. Support for ARMv7-M.
+
2011-09-24 Sebastian Huber <sebastian.huber@embedded-brains.de>
* acinclude.m4: Added lm3s69xx BSP.
diff --git a/c/src/lib/libbsp/arm/shared/include/linker-symbols.h b/c/src/lib/libbsp/arm/shared/include/linker-symbols.h
index 2108fbd08b..3048175e7c 100644
--- a/c/src/lib/libbsp/arm/shared/include/linker-symbols.h
+++ b/c/src/lib/libbsp/arm/shared/include/linker-symbols.h
@@ -116,6 +116,10 @@ LINKER_SYMBOL(bsp_vector_table_begin)
LINKER_SYMBOL(bsp_vector_table_end)
LINKER_SYMBOL(bsp_vector_table_size)
+LINKER_SYMBOL(bsp_start_vector_table_begin)
+LINKER_SYMBOL(bsp_start_vector_table_end)
+LINKER_SYMBOL(bsp_start_vector_table_size)
+
#define BSP_FAST_TEXT_SECTION __attribute__((section(".bsp_fast_text")))
#define BSP_FAST_DATA_SECTION __attribute__((section(".bsp_fast_data")))
diff --git a/c/src/lib/libbsp/arm/shared/include/start.h b/c/src/lib/libbsp/arm/shared/include/start.h
index 801a7e3b41..764239129d 100644
--- a/c/src/lib/libbsp/arm/shared/include/start.h
+++ b/c/src/lib/libbsp/arm/shared/include/start.h
@@ -7,12 +7,13 @@
*/
/*
- * Copyright (c) 2008, 2009
- * embedded brains GmbH
- * Obere Lagerstr. 30
- * D-82178 Puchheim
- * Germany
- * <rtems@embedded-brains.de>
+ * Copyright (c) 2008-2011 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Obere Lagerstr. 30
+ * 82178 Puchheim
+ * Germany
+ * <rtems@embedded-brains.de>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
@@ -77,6 +78,11 @@ void bsp_start_memcpy(int *dest, const int *src, size_t n);
*/
void bsp_start_memcpy_arm(int *dest, const int *src, size_t n);
+/**
+ * @brief Copies all standard sections from the load to the runtime area.
+ */
+void bsp_start_copy_sections(void);
+
/** @} */
#ifdef __cplusplus
diff --git a/c/src/lib/libbsp/arm/shared/start/start.S b/c/src/lib/libbsp/arm/shared/start/start.S
index c8e03277aa..2167adc8b5 100644
--- a/c/src/lib/libbsp/arm/shared/start/start.S
+++ b/c/src/lib/libbsp/arm/shared/start/start.S
@@ -5,15 +5,17 @@
*/
/*
- * Copyright (c) 2008
- * Embedded Brains GmbH
- * Obere Lagerstr. 30
- * D-82178 Puchheim
- * Germany
- * rtems@embedded-brains.de
+ * Copyright (c) 2008-2011 embedded brains GmbH. 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.com/license/LICENSE.
+ * embedded brains GmbH
+ * Obere Lagerstr. 30
+ * 82178 Puchheim
+ * Germany
+ * <rtems@embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
*/
#include <rtems/asm.h>
@@ -21,30 +23,34 @@
#include <rtems/score/cpu.h>
#include <bspopts.h>
+#include <bsp/irq.h>
#include <bsp/linker-symbols.h>
-/* External symbols */
-
-.extern bsp_reset
-.extern boot_card
-.extern bsp_start_hook_0
-.extern bsp_start_hook_1
+ /* External symbols */
+ .extern bsp_reset
+ .extern boot_card
+ .extern bsp_start_hook_0
+ .extern bsp_start_hook_1
-/* Global symbols */
+ /* Global symbols */
+ .globl _start
+ .globl bsp_start_vector_table_begin
+ .globl bsp_start_vector_table_end
+ .globl bsp_start_vector_table_size
+ .globl bsp_vector_table_size
-.globl _start
-.globl bsp_start_memcpy
+ .section ".bsp_start_text", "ax"
-.section ".bsp_start_text", "ax"
+#if defined(ARM_MULTILIB_ARCH_V4)
-.arm
+ .arm
/*
* This is the exception vector table and the pointers to the default
* exceptions handlers.
*/
-vector_block:
+bsp_start_vector_table_begin:
ldr pc, handler_addr_reset
ldr pc, handler_addr_undef
@@ -94,6 +100,8 @@ handler_addr_fiq:
.word reset
+bsp_start_vector_table_end:
+
/* Start entry */
_start:
@@ -169,7 +177,7 @@ bsp_start_hook_0_done:
*/
ldr r0, =bsp_vector_table_begin
- adr r1, vector_block
+ adr r1, bsp_start_vector_table_begin
ldmia r1!, {r2-r9}
stmia r0!, {r2-r9}
ldmia r1!, {r2-r9}
@@ -198,64 +206,58 @@ reset:
SWITCH_FROM_ARM_TO_THUMB r0
b twiddle
-DEFINE_FUNCTION_ARM(bsp_start_memcpy)
+#elif defined(ARM_MULTILIB_ARCH_V7M)
- /* Return if dest == src */
- cmp r0, r1
-#ifdef __thumb__
- bxeq lr
-#else
- moveq pc, lr
-#endif
+ .syntax unified
- /* Return if length is zero */
- mov r3, #0
- cmp r3, r2
-#ifdef __thumb__
- bxeq lr
-#else
- moveq pc, lr
-#endif
+ .extern bsp_stack_main_end
- /* Save non-volatile registers */
- push {r4-r8, lr}
+ .thumb
- /* Copy worker routine to stack */
- adr ip, bsp_start_memcpy_begin
- ldm ip, {r3-r8}
- push {r3-r8}
+bsp_start_vector_table_begin:
- /* Execute worker routine */
- mov r3, #0
- mov ip, sp
- mov lr, pc
-#ifdef __thumb__
- bx ip
-#else
- mov pc, ip
-#endif
+ .word bsp_stack_main_end
+ .word _start /* Reset */
+ .word bsp_reset /* NMI */
+ .word bsp_reset /* Hard Fault */
+ .word bsp_reset /* MPU Fault */
+ .word bsp_reset /* Bus Fault */
+ .word bsp_reset /* Usage Fault */
+ .word bsp_reset /* Reserved */
+ .word bsp_reset /* Reserved */
+ .word bsp_reset /* Reserved */
+ .word bsp_reset /* Reserved */
+ .word bsp_reset /* SVC */
+ .word bsp_reset /* Debug Monitor */
+ .word bsp_reset /* Reserved */
+ .word bsp_reset /* PendSV */
+ .word bsp_reset /* SysTick */
+ .rept BSP_INTERRUPT_VECTOR_MAX + 1
+ .word bsp_reset /* IRQ */
+ .endr
- /* Restore stack and non-volatile registers */
- add sp, sp, #24
- pop {r4-r8, lr}
+bsp_start_vector_table_end:
- /* Return */
-#ifdef __thumb__
- bx lr
-#else
- mov pc, lr
-#endif
+ .thumb_func
-bsp_start_memcpy_begin:
+_start:
- /* Worker routine */
- ldr ip, [r1, r3]
- str ip, [r0, r3]
- add r3, r3, #4
- cmp r3, r2
- bcc bsp_start_memcpy_begin
-#ifdef __thumb__
- bx lr
-#else
- mov pc, lr
-#endif
+ ldr sp, =bsp_stack_main_end
+ ldr lr, =bsp_start_hook_0_done + 1
+ b bsp_start_hook_0
+
+bsp_start_hook_0_done:
+
+ bl bsp_start_hook_1
+ movs r0, #0
+ bl boot_card
+
+twiddle:
+
+ bl bsp_reset
+ b twiddle
+
+#endif /* defined(ARM_MULTILIB_ARCH_V7M) */
+
+ .set bsp_start_vector_table_size, bsp_start_vector_table_end - bsp_start_vector_table_begin
+ .set bsp_vector_table_size, bsp_start_vector_table_size
diff --git a/c/src/lib/libbsp/arm/shared/startup/bsp-start-copy-sections.c b/c/src/lib/libbsp/arm/shared/startup/bsp-start-copy-sections.c
new file mode 100644
index 0000000000..b7eb1f99a5
--- /dev/null
+++ b/c/src/lib/libbsp/arm/shared/startup/bsp-start-copy-sections.c
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2008-2011 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Obere Lagerstr. 30
+ * 82178 Puchheim
+ * Germany
+ * <rtems@embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#include <bsp/start.h>
+#include <bsp/linker-symbols.h>
+
+static void BSP_START_TEXT_SECTION bsp_start_clear_bss(void)
+{
+ const int *end = (const int *) bsp_section_bss_end;
+ int *out = (int *) bsp_section_bss_begin;
+
+ /* Clear BSS */
+ while (out != end) {
+ *out = 0;
+ ++out;
+ }
+}
+
+void BSP_START_TEXT_SECTION bsp_start_copy_sections(void)
+{
+ /* Copy .text section */
+ bsp_start_memcpy(
+ (int *) bsp_section_text_begin,
+ (const int *) bsp_section_text_load_begin,
+ (size_t) bsp_section_text_size
+ );
+
+ /* Copy .rodata section */
+ bsp_start_memcpy(
+ (int *) bsp_section_rodata_begin,
+ (const int *) bsp_section_rodata_load_begin,
+ (size_t) bsp_section_rodata_size
+ );
+
+ /* Copy .data section */
+ bsp_start_memcpy(
+ (int *) bsp_section_data_begin,
+ (const int *) bsp_section_data_load_begin,
+ (size_t) bsp_section_data_size
+ );
+
+ /* Copy .fast_text section */
+ bsp_start_memcpy(
+ (int *) bsp_section_fast_text_begin,
+ (const int *) bsp_section_fast_text_load_begin,
+ (size_t) bsp_section_fast_text_size
+ );
+
+ /* Copy .fast_data section */
+ bsp_start_memcpy(
+ (int *) bsp_section_fast_data_begin,
+ (const int *) bsp_section_fast_data_load_begin,
+ (size_t) bsp_section_fast_data_size
+ );
+
+ bsp_start_clear_bss();
+}
diff --git a/c/src/lib/libbsp/arm/shared/startup/bsp-start-memcpy.S b/c/src/lib/libbsp/arm/shared/startup/bsp-start-memcpy.S
new file mode 100644
index 0000000000..40a5abf305
--- /dev/null
+++ b/c/src/lib/libbsp/arm/shared/startup/bsp-start-memcpy.S
@@ -0,0 +1,147 @@
+/**
+ * @file
+ *
+ * @brief bsp_start_memcpy() implementation.
+ */
+
+/*
+ * Copyright (c) 2008-2011 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Obere Lagerstr. 30
+ * 82178 Puchheim
+ * Germany
+ * <rtems@embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#include <rtems/asm.h>
+#include <rtems/system.h>
+#include <rtems/score/cpu.h>
+
+ .section ".bsp_start_text", "ax"
+
+#if defined(ARM_MULTILIB_ARCH_V4)
+
+DEFINE_FUNCTION_ARM(bsp_start_memcpy)
+
+ /* Return if dest == src */
+ cmp r0, r1
+#ifdef __thumb__
+ bxeq lr
+#else
+ moveq pc, lr
+#endif
+
+ /* Return if length is zero */
+ mov r3, #0
+ cmp r3, r2
+#ifdef __thumb__
+ bxeq lr
+#else
+ moveq pc, lr
+#endif
+
+ /* Save non-volatile registers */
+ push {r4-r8, lr}
+
+ /* Copy worker routine to stack */
+ adr ip, worker_begin
+ ldm ip, {r3-r8}
+ push {r3-r8}
+
+ /* Execute worker routine */
+ mov r3, #0
+ mov ip, sp
+ mov lr, pc
+#ifdef __thumb__
+ bx ip
+#else
+ mov pc, ip
+#endif
+
+ /* Restore stack and non-volatile registers */
+ add sp, sp, #24
+ pop {r4-r8, lr}
+
+ /* Return */
+#ifdef __thumb__
+ bx lr
+#else
+ mov pc, lr
+#endif
+
+worker_begin:
+
+ /* Worker routine */
+ ldr ip, [r1, r3]
+ str ip, [r0, r3]
+ add r3, r3, #4
+ cmp r3, r2
+ bcc worker_begin
+#ifdef __thumb__
+ bx lr
+#else
+ mov pc, lr
+#endif
+
+#elif defined(ARM_MULTILIB_ARCH_V7M)
+
+ .syntax unified
+
+ .align 2
+ .globl bsp_start_memcpy
+ .thumb
+ .thumb_func
+ .type bsp_start_memcpy, %function
+
+bsp_start_memcpy:
+
+ /* Return if dest == src */
+ cmp r0, r1
+ beq return
+
+ /* Return if length is zero */
+ movs r3, #0
+ cmp r3, r2
+ beq return
+
+ /* Save non-volatile registers */
+ push {r4-r7, lr}
+
+ /* Copy worker routine to stack */
+ adr r3, worker_begin
+ ldm r3, {r4-r7}
+ push {r4-r7}
+
+ /* Execute worker routine */
+ add r3, sp, #1
+ adds r2, r2, #3
+ bic r2, r2, #3
+ adds r2, r2, r1
+ blx r3
+
+ /* Restore stack and non-volatile registers */
+ add sp, sp, #16
+ pop {r4-r7, lr}
+
+return:
+
+ /* Return */
+ bx lr
+
+ .align 2
+
+worker_begin:
+
+ /* Worker routine */
+ ldr r3, [r1], #4
+ cmp r2, r1
+ str r3, [r0], #4
+ bne worker_begin
+ bx lr
+
+#endif /* defined(ARM_MULTILIB_ARCH_V7M) */