Removed symbols and renamed sections.

Added bsp_start_memcpy(). Documentation. Changes for external ROM start.
This commit is contained in:
Thomas Doerfler
2009-09-18 08:06:32 +00:00
parent ba938b8d7d
commit 091705c07f
5 changed files with 166 additions and 105 deletions

View File

@@ -1,3 +1,10 @@
2009-09-15 Sebastian Huber <sebastian.huber@embedded-brains.de>
* shared/include/linker-symbols.h, shared/startup/linkcmds.base:
Removed symbols and renamed sections.
* shared/include/start.h, shared/start/start.S: Added
bsp_start_memcpy(). Documentation. Changes for external ROM start.
2009-07-15 Sebastian Huber <sebastian.huber@embedded-brains.de> 2009-07-15 Sebastian Huber <sebastian.huber@embedded-brains.de>
* shared/irq/irq_asm.S, shared/startup/linkcmds.rom: Removed files. * shared/irq/irq_asm.S, shared/startup/linkcmds.rom: Removed files.

View File

@@ -1,6 +1,8 @@
/** /**
* @file * @file
* *
* @ingroup bsp_linker
*
* @brief Symbols defined in linker command base file. * @brief Symbols defined in linker command base file.
*/ */
@@ -20,20 +22,22 @@
#ifndef LIBBSP_ARM_SHARED_LINKER_SYMBOLS_H #ifndef LIBBSP_ARM_SHARED_LINKER_SYMBOLS_H
#define LIBBSP_ARM_SHARED_LINKER_SYMBOLS_H #define LIBBSP_ARM_SHARED_LINKER_SYMBOLS_H
/**
* @defgroup bsp_linker Linker Support
*
* @ingroup bsp_kit
*
* @brief Linker support.
*
* @{
*/
#ifndef ASM #ifndef ASM
#define LINKER_SYMBOL(sym) extern char sym []; #define LINKER_SYMBOL(sym) extern char sym [];
#else #else
#define LINKER_SYMBOL(sym) .extern sym #define LINKER_SYMBOL(sym) .extern sym
#endif #endif
LINKER_SYMBOL(bsp_region_text_begin)
LINKER_SYMBOL(bsp_region_text_end)
LINKER_SYMBOL(bsp_region_text_size)
LINKER_SYMBOL(bsp_region_data_begin)
LINKER_SYMBOL(bsp_region_data_end)
LINKER_SYMBOL(bsp_region_data_size)
LINKER_SYMBOL(bsp_stack_irq_begin) LINKER_SYMBOL(bsp_stack_irq_begin)
LINKER_SYMBOL(bsp_stack_irq_end) LINKER_SYMBOL(bsp_stack_irq_end)
LINKER_SYMBOL(bsp_stack_irq_size) LINKER_SYMBOL(bsp_stack_irq_size)
@@ -94,4 +98,6 @@ LINKER_SYMBOL(bsp_section_stack_begin)
LINKER_SYMBOL(bsp_section_stack_end) LINKER_SYMBOL(bsp_section_stack_end)
LINKER_SYMBOL(bsp_section_stack_size) LINKER_SYMBOL(bsp_section_stack_size)
/** @} */
#endif /* LIBBSP_ARM_SHARED_LINKER_SYMBOLS_H */ #endif /* LIBBSP_ARM_SHARED_LINKER_SYMBOLS_H */

View File

@@ -1,54 +1,74 @@
/** /**
* @file * @file
* *
* @brief Start entry functions. * @ingroup bsp_start
*
* @brief System low level start.
*/ */
/* /*
* Copyright (c) 2008 * Copyright (c) 2008, 2009
* Embedded Brains GmbH * embedded brains GmbH
* Obere Lagerstr. 30 * Obere Lagerstr. 30
* D-82178 Puchheim * D-82178 Puchheim
* Germany * Germany
* rtems@embedded-brains.de * <rtems@embedded-brains.de>
* *
* The license and distribution terms for this file may be found in the file * The license and distribution terms for this file may be
* LICENSE in this distribution or at http://www.rtems.com/license/LICENSE. * found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*/ */
#ifndef LIBBSP_ARM_SHARED_START_H #ifndef LIBBSP_ARM_SHARED_START_H
#define LIBBSP_ARM_SHARED_START_H #define LIBBSP_ARM_SHARED_START_H
#ifndef ASM #include <stddef.h>
/** /**
* @brief System start entry. * @defgroup bsp_start System Start
*/
void start( void);
/**
* @brief Start entry hook 0.
* *
* This hook will be called from the start entry code after all modes and * @ingroup bsp_kit
* stack pointers are initialized but before the copying of the exception
* vectors.
*/
void bsp_start_hook_0( void);
/**
* @brief Start entry hook 1.
* *
* This hook will be called from the start entry code after copying of the * @brief System low level start.
* exception vectors but before the call to boot card. *
* @{
*/ */
void bsp_start_hook_1( void);
#else /**
* @brief System start entry.
*/
void start(void);
.extern bsp_start_hook_0 /**
* @brief Start entry hook 0.
*
* This hook will be called from the start entry code after all modes and
* stack pointers are initialized but before the copying of the exception
* vectors.
*/
void bsp_start_hook_0(void);
.extern bsp_start_hook_1 /**
* @brief Start entry hook 1.
*
* This hook will be called from the start entry code after copying of the
* exception vectors but before the call to boot_card().
*/
void bsp_start_hook_1(void);
#endif /**
* @brief Similar to standard memcpy().
*
* The memory areas must be word aligned. Copy code will be executed from the
* stack. If @a dest equals @a src nothing will be copied.
*/
void bsp_start_memcpy(int *dest, const int *src, size_t n);
/**
* @brief ARM entry point to bsp_start_memcpy().
*/
void bsp_start_memcpy_arm(int *dest, const int *src, size_t n);
/** @} */
#endif /* LIBBSP_ARM_SHARED_START_H */ #endif /* LIBBSP_ARM_SHARED_START_H */

View File

@@ -16,18 +16,22 @@
* LICENSE in this distribution or at http://www.rtems.com/license/LICENSE. * LICENSE in this distribution or at http://www.rtems.com/license/LICENSE.
*/ */
#include <rtems/asm.h>
#include <bspopts.h>
#include <bsp/linker-symbols.h> #include <bsp/linker-symbols.h>
#include <bsp/start.h>
/* External symbols */ /* External symbols */
.extern bsp_reset .extern bsp_reset
.extern boot_card .extern boot_card
.extern bsp_start_hook_0
.extern bsp_start_hook_1
/* Global symbols */ /* Global symbols */
.globl start .globl start
.globl SWI_Handler .globl bsp_start_memcpy
/* Program Status Register definitions */ /* Program Status Register definitions */
@@ -42,8 +46,9 @@
.equ PSR_F, 0x40 .equ PSR_F, 0x40
.equ PSR_T, 0x20 .equ PSR_T, 0x20
.section ".bsp_start", "ax"
.arm .arm
.section ".bsp_start", "x"
/* /*
* This is the exception vector table and the pointers to the default * This is the exception vector table and the pointers to the default
@@ -66,7 +71,11 @@ vector_block:
handler_addr_reset: handler_addr_reset:
#ifdef BSP_START_RESET_VECTOR
.word BSP_START_RESET_VECTOR
#else
.word start .word start
#endif
handler_addr_undef: handler_addr_undef:
@@ -140,18 +149,19 @@ start:
/* Stay in SVC mode */ /* Stay in SVC mode */
/* Brach to start hook 0 */ /*
#ifdef __thumb__ * Branch to start hook 0.
ldr r3, =bsp_start_hook_0 *
mov lr, pc * This code up to the start hook 0 may run with an address offset so
bx r3 * it must be position independent. After the start hook 0 it is
.thumb * assumed that the code can run at its intended position. The link
bx pc * register will be loaded with the absolute address.
nop */
.arm
#else ldr lr, =bsp_start_hook_0_done
bl bsp_start_hook_0 b bsp_start_hook_0
#endif
bsp_start_hook_0_done:
/* /*
* Initialize the exception vectors. This includes the exceptions * Initialize the exception vectors. This includes the exceptions
@@ -165,21 +175,10 @@ start:
ldmia r1!, {r2-r9} ldmia r1!, {r2-r9}
stmia r0!, {r2-r9} stmia r0!, {r2-r9}
/* Brach to start hook 1 */ /* Branch to start hook 1 */
#ifdef __thumb__
ldr r3, =bsp_start_hook_1
mov lr, pc
bx r3
.thumb
bx pc
nop
.arm
#else
bl bsp_start_hook_1 bl bsp_start_hook_1
#endif
/* Branch to boot card */
/* Brach to boot card */
mov r0, #0 mov r0, #0
#ifdef __thumb__ #ifdef __thumb__
ldr r3, =boot_card ldr r3, =boot_card
@@ -208,8 +207,48 @@ start:
/* Spin forever */ /* Spin forever */
SWI_Handler:
twiddle: twiddle:
b twiddle b twiddle
DEFINE_FUNCTION_ARM(bsp_start_memcpy)
/* Return if dest == src */
cmp r0, r1
bxeq lr
/* Return if length is zero */
mov r3, #0
cmp r3, r2
bxeq lr
/* 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
bx ip
/* Restore stack and non-volatile registers */
add sp, sp, #24
pop {r4-r8, lr}
/* Return */
bx lr
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
bx lr

View File

@@ -1,6 +1,8 @@
/** /**
* @file * @file
* *
* @ingroup bsp_linker
*
* @brief Linker command base file. * @brief Linker command base file.
*/ */
@@ -30,14 +32,6 @@ bsp_section_align = 32;
bsp_stack_align = 4; bsp_stack_align = 4;
bsp_region_text_begin = ORIGIN (REGION_TEXT);
bsp_region_text_size = LENGTH (REGION_TEXT);
bsp_region_text_end = bsp_region_text_begin + bsp_region_text_size;
bsp_region_data_begin = ORIGIN (REGION_DATA);
bsp_region_data_size = LENGTH (REGION_DATA);
bsp_region_data_end = bsp_region_data_begin + bsp_region_data_size;
/* /*
* BSP: Symbols that may be defined externally * BSP: Symbols that may be defined externally
*/ */
@@ -138,11 +132,6 @@ SECTIONS {
*/ */
bsp_section_text_begin = .; bsp_section_text_begin = .;
/*
* BSP: System startup entry
*/
KEEP (*(.bsp_start))
/* /*
* BSP: Moved into .text from .init * BSP: Moved into .text from .init
*/ */
@@ -290,7 +279,7 @@ SECTIONS {
.fast : { .fast : {
bsp_section_fast_begin = .; bsp_section_fast_begin = .;
*(.fast) *(.bsp_fast)
. = ALIGN (bsp_section_align); . = ALIGN (bsp_section_align);