git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2883 35acf78f-673a-0410-8e92-d51de3d6d3f4

master
gdisirio 2011-04-17 13:55:31 +00:00
parent aeed6d78c1
commit 6a57dd25e0
4 changed files with 85 additions and 66 deletions

View File

@ -38,11 +38,32 @@ __ram_end__ = __ram_start__ + __ram_size__;
SECTIONS
{
. = 0;
_text = .;
startup : ALIGN(16) SUBALIGN(16)
{
KEEP(*(vectors))
} > flash
constructors : ALIGN(4) SUBALIGN(4)
{
PROVIDE(__init_array_start = .);
KEEP(*(SORT(.init_array.*)))
KEEP(*(.init_array))
PROVIDE(__init_array_end = .);
} > flash
destructors : ALIGN(4) SUBALIGN(4)
{
PROVIDE(__fini_array_start = .);
KEEP(*(.fini_array))
KEEP(*(SORT(.fini_array.*)))
PROVIDE(__fini_array_end = .);
} > flash
.text : ALIGN(16) SUBALIGN(16)
{
_text = .;
KEEP(*(vectors))
*(.text.startup.*)
*(.text)
*(.text.*)
*(.rodata)
@ -52,31 +73,26 @@ SECTIONS
*(.gcc*)
} > flash
.ctors :
.ARM.extab :
{
PROVIDE(_ctors_start_ = .);
KEEP(*(SORT(.ctors.*)))
KEEP(*(.ctors))
PROVIDE(_ctors_end_ = .);
*(.ARM.extab* .gnu.linkonce.armextab.*)
} > flash
.dtors :
.ARM.exidx : {
PROVIDE(__exidx_start = .);
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
PROVIDE(__exidx_end = .);
} > flash
.eh_frame_hdr :
{
PROVIDE(_dtors_start_ = .);
KEEP(*(SORT(.dtors.*)))
KEEP(*(.dtors))
PROVIDE(_dtors_end_ = .);
*(.eh_frame_hdr)
} > flash
.ARM.extab : {*(.ARM.extab* .gnu.linkonce.armextab.*)}
__exidx_start = .;
.ARM.exidx : {*(.ARM.exidx* .gnu.linkonce.armexidx.*)} > flash
__exidx_end = .;
.eh_frame_hdr : {*(.eh_frame_hdr)}
.eh_frame : ONLY_IF_RO {*(.eh_frame)}
.eh_frame : ONLY_IF_RO
{
*(.eh_frame)
} > flash
. = ALIGN(4);
_etext = .;
@ -84,26 +100,26 @@ SECTIONS
.data :
{
_data = .;
PROVIDE(_data = .);
*(.data)
. = ALIGN(4);
*(.data.*)
. = ALIGN(4);
*(.ramtext)
. = ALIGN(4);
_edata = .;
PROVIDE(_edata = .);
} > ram AT > flash
.bss :
{
_bss_start = .;
PROVIDE(_bss_start = .);
*(.bss)
. = ALIGN(4);
*(.bss.*)
. = ALIGN(4);
*(COMMON)
. = ALIGN(4);
_bss_end = .;
PROVIDE(_bss_end = .);
} > ram
}

View File

@ -1,10 +1,11 @@
# List of the ChibiOS/RT Cortex-M3 STM32 port files.
PORTSRC = $(CHIBIOS)/os/ports/GCC/ARMCMx/STM32/vectors.c \
PORTSRC = $(CHIBIOS)/os/ports/GCC/ARMCMx/crt0.c \
$(CHIBIOS)/os/ports/GCC/ARMCMx/STM32/vectors.c \
${CHIBIOS}/os/ports/GCC/ARMCMx/chcore.c \
${CHIBIOS}/os/ports/GCC/ARMCMx/chcore_v7m.c \
${CHIBIOS}/os/ports/GCC/ARMCMx/nvic.c
PORTASM = ${CHIBIOS}/os/ports/GCC/ARMCMx/crt0_v7m.s
PORTASM =
PORTINC = ${CHIBIOS}/os/ports/GCC/ARMCMx \
${CHIBIOS}/os/ports/GCC/ARMCMx/STM32

View File

@ -27,6 +27,12 @@
#include "chtypes.h"
#define FALSE 0
#define TRUE (!FALSE)
typedef void (*funcp_t)(void);
typedef funcp_t * funcpp_t;
/**
* @brief Control special register initialization value.
* @details The system is setup to run in privileged mode using the PSP
@ -124,36 +130,33 @@ extern uint32_t _bss_end;
* @brief Constructors table start.
* @pre The symbol must be aligned to a 32 bits boundary.
*/
extern void __init_array_start(void);
extern funcp_t __init_array_start;
/**
* @brief Constructors table end.
* @pre The symbol must be aligned to a 32 bits boundary.
*/
extern void __init_array_end(void);
extern funcp_t __init_array_end;
/**
* @brief Destructors table start.
* @pre The symbol must be aligned to a 32 bits boundary.
*/
extern void __fini_array_start(void);
extern funcp_t __fini_array_start;
/**
* @brief Destructors table end.
* @pre The symbol must be aligned to a 32 bits boundary.
*/
extern void __fini_array_end(void);
extern funcp_t __fini_array_end;
/**
* @brief Application @p main() function.
*
* @param[in] argc Number of arguments, always zero.
* @param[in] argv Pointer to an array of arguments, always @p NULL.
*/
extern void main(int argc, char **argv);
extern void main(void);
/**
* @brief Default initialization hook 0.
* @brief Early initialization.
* @details This hook is invoked immediately after the stack initialization
* and before the DATA and BSS segments initialization. The
* default behavior is to do nothing.
@ -162,19 +165,19 @@ extern void main(int argc, char **argv);
#if !defined(__DOXYGEN__)
__attribute__((weak))
#endif
void hwinit0(void) {}
void __early_init(void) {}
/**
* @brief Default initialization hook 1.
* @details This hook is invoked immediately after the DATA and BSS segments
* initialization and before entering the @p main() function. The
* @brief Late initialization.
* @details This hook is invoked after the DATA and BSS segments
* initialization and before any static constructor. The
* default behavior is to do nothing.
* @note This function is a weak symbol.
*/
#if !defined(__DOXYGEN__)
__attribute__((weak))
#endif
void hwinit1(void) {}
void __late_init(void) {}
/**
* @brief Default @p main() function exit handler.
@ -183,9 +186,9 @@ void hwinit1(void) {}
* @note This function is a weak symbol.
*/
#if !defined(__DOXYGEN__)
__attribute__((weak, naked))
__attribute__((weak, noreturn))
#endif
void _main_exit_handler(void) {
void _default_exit(void) {
while (1)
;
}
@ -194,24 +197,24 @@ void _main_exit_handler(void) {
* @brief Reset vector.
*/
#if !defined(__DOXYGEN__)
__attribute__((naked))
__attribute__((noreturn))
#endif
void ResetHandler(void) {
uint32_t sz, ctl;
uint32_t psp, ctl;
/* Process Stack initialization, it is allocated below the main stack. The
main stack is assumed to be allocated starting from @p __ram_end__
extending downward.*/
asm volatile ("cpsid i");
sz = SYMVAL(__ram_end__) - SYMVAL(__main_stack_size__);
asm volatile ("msr PSP, %0" : : "r" (sz));
psp = SYMVAL(__ram_end__) - SYMVAL(__main_stack_size__);
asm volatile ("msr PSP, %0" : : "r" (psp));
ctl = CRT0_CONTROL_INIT;
asm volatile ("msr CONTROL, %0" : : "r" (ctl));
asm volatile ("isb");
/* Initialization hook 0 invocation.*/
hwinit0();
/* Early initialization hook invocation.*/
__early_init();
#if CRT0_INIT_DATA
/* DATA segment initialization.*/
@ -236,40 +239,36 @@ void ResetHandler(void) {
}
#endif
/* Initialization hook 1 invocation.*/
hwinit1();
/* Late initialization hook invocation.*/
__late_init();
#if CRT0_CALL_CONSTRUCTORS
/* Constructors invocation.*/
{
void (*dpp)(void);
dpp = &__init_array_start;
while (dpp < &__init_array_end) {
(*dpp)();
dpp++;
funcpp_t fpp = &__init_array_start;
while (fpp < &__init_array_end) {
(*fpp)();
fpp++;
}
}
#endif
/* Invoking application main() function.*/
main(0, 0);
main();
#if CRT0_CALL_DESTRUCTORS
/* Destructors invocation.*/
{
void (*dpp)(void);
dpp = &__fini_array_start;
while (dpp < &__fini_array_end) {
(*dpp)();
dpp++;
funcpp_t fpp = &__fini_array_start;
while (fpp < &__fini_array_end) {
(*fpp)();
fpp++;
}
}
#endif
/* Invoking the main() exit handler.*/
asm volatile ("b _main_exit_handler");
/* Invoking the exit handler.*/
_default_exit();
}
/** @} */

View File

@ -77,6 +77,9 @@
to 2.2.4).
- FIX: Fixed spurious characters generated by Serial over USB driver (bug
3276379).
- NEW: New unified GCC startup file for Cortex-Mx processors, it is written
in C instead of asm and supports constructors/destructors. Improved the
Cortex-Mx linker scripts in all the GCC demos.
- NEW: Now it is possible to share DMA channels in the STM32 HAL thanks
to a centralized manager. Channels are allocated when the driver is
started and released when it is stopped.