* 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.
This commit is contained in:
Sebastian Huber
2011-11-08 10:18:19 +00:00
parent d922dab192
commit 4c622e5f4a
6 changed files with 314 additions and 79 deletions
+8
View File
@@ -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.
@@ -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")))
+12 -6
View File
@@ -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
+75 -73
View File
@@ -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 */
/* External symbols */
.extern bsp_reset
.extern boot_card
.extern bsp_start_hook_0
.extern bsp_start_hook_1
.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
/* Global symbols */
.section ".bsp_start_text", "ax"
.globl _start
.globl bsp_start_memcpy
#if defined(ARM_MULTILIB_ARCH_V4)
.section ".bsp_start_text", "ax"
.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
@@ -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();
}
@@ -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) */