Index: c/src/lib/libbsp/arm/ChangeLog
===================================================================
--- c/src/lib/libbsp/arm/ChangeLog	(revision d922dab19246c2c1c093d39d4204da796e644e48)
+++ c/src/lib/libbsp/arm/ChangeLog	(revision 4c622e5f4a24f0675840a0463780b03a4d897c1e)
@@ -1,2 +1,10 @@
+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>
 
Index: c/src/lib/libbsp/arm/shared/include/linker-symbols.h
===================================================================
--- c/src/lib/libbsp/arm/shared/include/linker-symbols.h	(revision d922dab19246c2c1c093d39d4204da796e644e48)
+++ c/src/lib/libbsp/arm/shared/include/linker-symbols.h	(revision 4c622e5f4a24f0675840a0463780b03a4d897c1e)
@@ -117,4 +117,8 @@
 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")))
 
Index: c/src/lib/libbsp/arm/shared/include/start.h
===================================================================
--- c/src/lib/libbsp/arm/shared/include/start.h	(revision d922dab19246c2c1c093d39d4204da796e644e48)
+++ c/src/lib/libbsp/arm/shared/include/start.h	(revision 4c622e5f4a24f0675840a0463780b03a4d897c1e)
@@ -8,10 +8,11 @@
 
 /*
- * 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
@@ -78,4 +79,9 @@
 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);
+
 /** @} */
 
Index: c/src/lib/libbsp/arm/shared/start/start.S
===================================================================
--- c/src/lib/libbsp/arm/shared/start/start.S	(revision d922dab19246c2c1c093d39d4204da796e644e48)
+++ c/src/lib/libbsp/arm/shared/start/start.S	(revision 4c622e5f4a24f0675840a0463780b03a4d897c1e)
@@ -6,13 +6,15 @@
 
 /*
- * 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.
  */
 
@@ -22,21 +24,25 @@
 	
 #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
-
-/* Global symbols */
-
-.globl _start
-.globl bsp_start_memcpy
-
-.section ".bsp_start_text", "ax"
-
-.arm
+	/* External symbols */
+	.extern	bsp_reset
+	.extern	boot_card
+	.extern	bsp_start_hook_0
+	.extern	bsp_start_hook_1
+
+	/* 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
+
+	.section	".bsp_start_text", "ax"
+
+#if defined(ARM_MULTILIB_ARCH_V4)
+
+	.arm
 
 /*
@@ -45,5 +51,5 @@
  */
 
-vector_block:
+bsp_start_vector_table_begin:
 
 	ldr	pc, handler_addr_reset
@@ -94,4 +100,6 @@
 
 	.word	reset
+
+bsp_start_vector_table_end:
 
 /* Start entry */
@@ -170,5 +178,5 @@
 
 	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}
@@ -199,63 +207,57 @@
 	b	twiddle
 
-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, bsp_start_memcpy_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
-
-bsp_start_memcpy_begin:
-
-	/* 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
+#elif defined(ARM_MULTILIB_ARCH_V7M)
+
+	.syntax	unified
+
+	.extern	bsp_stack_main_end
+
+	.thumb
+
+bsp_start_vector_table_begin:
+
+	.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
+
+bsp_start_vector_table_end:
+
+	.thumb_func
+
+_start:
+
+	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
Index: c/src/lib/libbsp/arm/shared/startup/bsp-start-copy-sections.c
===================================================================
--- c/src/lib/libbsp/arm/shared/startup/bsp-start-copy-sections.c	(revision 4c622e5f4a24f0675840a0463780b03a4d897c1e)
+++ c/src/lib/libbsp/arm/shared/startup/bsp-start-copy-sections.c	(revision 4c622e5f4a24f0675840a0463780b03a4d897c1e)
@@ -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();
+}
Index: c/src/lib/libbsp/arm/shared/startup/bsp-start-memcpy.S
===================================================================
--- c/src/lib/libbsp/arm/shared/startup/bsp-start-memcpy.S	(revision 4c622e5f4a24f0675840a0463780b03a4d897c1e)
+++ c/src/lib/libbsp/arm/shared/startup/bsp-start-memcpy.S	(revision 4c622e5f4a24f0675840a0463780b03a4d897c1e)
@@ -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) */
