diff options
author | Giovanni Di Sirio <gdisirio@gmail.com> | 2015-06-19 09:49:29 +0000 |
---|---|---|
committer | Giovanni Di Sirio <gdisirio@gmail.com> | 2015-06-19 09:49:29 +0000 |
commit | d0bd017d3b0737d7e7c9e26464817dddd4ddafdb (patch) | |
tree | 7556314a089cc2199faa29689cac3b7ff34ad83a /os/common | |
parent | 048acf5bdfa3bde321f12104e4bd24a50a95738f (diff) | |
download | ChibiOS-d0bd017d3b0737d7e7c9e26464817dddd4ddafdb.tar.gz ChibiOS-d0bd017d3b0737d7e7c9e26464817dddd4ddafdb.tar.bz2 ChibiOS-d0bd017d3b0737d7e7c9e26464817dddd4ddafdb.zip |
New PPC startup file.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8048 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/common')
-rw-r--r-- | os/common/ports/e200/compilers/GCC/crt0.s | 201 |
1 files changed, 162 insertions, 39 deletions
diff --git a/os/common/ports/e200/compilers/GCC/crt0.s b/os/common/ports/e200/compilers/GCC/crt0.s index daa0e1124..e6161bdd2 100644 --- a/os/common/ports/e200/compilers/GCC/crt0.s +++ b/os/common/ports/e200/compilers/GCC/crt0.s @@ -19,12 +19,74 @@ /**
* @file PPC/crt0.s
- * @brief Generic PowerPC startup file for ChibiOS/RT.
+ * @brief Generic PowerPC startup file for ChibiOS.
*
* @addtogroup PPC_CORE
* @{
*/
+/*===========================================================================*/
+/* Module constants. */
+/*===========================================================================*/
+
+#if !defined(FALSE) || defined(__DOXYGEN__)
+#define FALSE 0
+#endif
+
+#if !defined(TRUE) || defined(__DOXYGEN__)
+#define TRUE 1
+#endif
+
+/*===========================================================================*/
+/* Module pre-compile time settings. */
+/*===========================================================================*/
+
+/**
+ * @brief Stack segments initialization switch.
+ */
+#if !defined(CRT0_STACKS_FILL_PATTERN) || defined(__DOXYGEN__)
+#define CRT0_STACKS_FILL_PATTERN 0x55555555
+#endif
+
+/**
+ * @brief Stack segments initialization switch.
+ */
+#if !defined(CRT0_INIT_STACKS) || defined(__DOXYGEN__)
+#define CRT0_INIT_STACKS TRUE
+#endif
+
+/**
+ * @brief DATA segment initialization switch.
+ */
+#if !defined(CRT0_INIT_DATA) || defined(__DOXYGEN__)
+#define CRT0_INIT_DATA TRUE
+#endif
+
+/**
+ * @brief BSS segment initialization switch.
+ */
+#if !defined(CRT0_INIT_BSS) || defined(__DOXYGEN__)
+#define CRT0_INIT_BSS TRUE
+#endif
+
+/**
+ * @brief Constructors invocation switch.
+ */
+#if !defined(CRT0_CALL_CONSTRUCTORS) || defined(__DOXYGEN__)
+#define CRT0_CALL_CONSTRUCTORS TRUE
+#endif
+
+/**
+ * @brief Destructors invocation switch.
+ */
+#if !defined(CRT0_CALL_DESTRUCTORS) || defined(__DOXYGEN__)
+#define CRT0_CALL_DESTRUCTORS TRUE
+#endif
+
+/*===========================================================================*/
+/* Code section. */
+/*===========================================================================*/
+
#if !defined(__DOXYGEN__)
.section .crt0, "ax"
@@ -32,27 +94,58 @@ .globl _boot_address
.type _boot_address, @function
_boot_address:
- /*
- * Stack setup.
- */
+ /* Stack setup.*/
lis %r1, __process_stack_end__@h
ori %r1, %r1, __process_stack_end__@l
li %r0, 0
stwu %r0, -8(%r1)
- /*
- * Small sections registers initialization.
- */
+
+ /* Small sections registers initialization.*/
lis %r2, __sdata2_start__@h
ori %r2, %r2, __sdata2_start__@l
lis %r13, __sdata_start__@h
ori %r13, %r13, __sdata_start__@l
- /*
- * Early initialization.
- */
+
+ /* Early initialization.*/
bl __early_init
- /*
- * BSS clearing.
- */
+
+#if CRT0_INIT_STACKS == TRUE
+ /* Stacks fill pattern.*/
+ lis %r7, CRT0_STACKS_FILL_PATTERN@h
+ ori %r7, %r7, CRT0_STACKS_FILL_PATTERN@l
+
+ /* IRQ Stack initialization. Note, the architecture does not use this
+ stack, the size is usually zero. An OS can have special SW handling
+ and require this. A 4 bytes alignment is assmend and required.*/
+ lis %r4, __irq_stack_base__@h
+ ori %r4, %r4, __irq_stack_base__@l
+ lis %r5, __irq_stack_end__@h
+ ori %r5, %r5, __irq_stack_end__@l
+.irqsloop:
+ cmpl cr0, %r4, %r5
+ bge cr0, .irqsend
+ stw %r7, 0(%r4)
+ addi %r4, %r4, 4
+ b .irqsloop
+.irqsend:
+
+ /* Process Stack initialization. Note, does not overwrite the already
+ written EABI frame. A 4 bytes alignment is assmend and required.*/
+ lis %r4, __process_stack_base__@h
+ ori %r4, %r4, __process_stack_base__@l
+ lis %r5, (__process_stack_end__ - 8)@h
+ ori %r5, %r5, (__process_stack_end__ - 8)@l
+.prcsloop:
+ cmpl cr0, %r4, %r5
+ bge cr0, .prcsend
+ stw %r7, 0(%r4)
+ addi %r4, %r4, 4
+ b .prcsloop
+.prcsend:
+#endif
+
+#if CRT0_INIT_BSS == TRUE
+ /* BSS clearing.*/
lis %r4, __bss_start__@h
ori %r4, %r4, __bss_start__@l
lis %r5, __bss_end__@h
@@ -65,9 +158,10 @@ _boot_address: addi %r4, %r4, 4
b .bssloop
.bssend:
- /*
- * DATA initialization.
- */
+#endif
+
+#if CRT0_INIT_DATA == TRUE
+ /* DATA initialization.*/
lis %r4, __romdata_start__@h
ori %r4, %r4, __romdata_start__@l
lis %r5, __data_start__@h
@@ -83,37 +177,66 @@ _boot_address: addi %r5, %r5, 4
b .dataloop
.dataend:
- /*
- * Late initialization.
- */
+#endif
+
+ /* Late initialization.*/
bl __late_init
- /*
- * Main program invocation.
- */
+
+#if CRT0_CALL_CONSTRUCTORS == TRUE
+ /* Constructors invocation.*/
+ lis %r4, __init_array_start@h
+ ori %r4, %r4, __init_array_start@l
+ lis %r5, __init_array_end@h
+ ori %r5, %r5, __init_array_end@l
+.iniloop:
+ cmplw %cr0, %r4, %r5
+ bge %cr0, .iniend
+ lwz %r6, 0(%r4)
+ mtctr %r6
+ addi %r4, %r4, 4
+ bctrl
+ b .iniloop
+.iniend:
+#endif
+
+ /* Main program invocation.*/
bl main
- b _main_exit_handler
-
- /*
- * Default main exit code, infinite loop.
- */
- .weak _main_exit_handler
- .globl _main_exit_handler
- .type _main_exit_handler, @function
-_main_exit_handler:
- b _main_exit_handler
-
- /*
- * Default early initialization code, none.
- */
+
+#if CRT0_CALL_DESTRUCTORS == TRUE
+ /* Destructors invocation.*/
+ lis %r4, __fini_array_start@h
+ ori %r4, %r4, __fini_array_start@l
+ lis %r5, __fini_array_end@h
+ ori %r5, %r5, __fini_array_end@l
+.finiloop:
+ cmplw %cr0, %r4, %r5
+ bge %cr0, .finiend
+ lwz %r6, 0(%r4)
+ mtctr %r6
+ addi %r4, %r4, 4
+ bctrl
+ b .finiloop
+.finiend:
+#endif
+
+ /* Branching to the defined exit handler.*/
+ b __default_exit
+
+ /* Default main exit code, infinite loop.*/
+ .weak __default_exit
+ .globl __default_exit
+ .type __default_exit, @function
+__default_exit:
+ b __default_exit
+
+ /* Default early initialization code, none.*/
.weak __early_init
.globl __early_init
.type __early_init, @function
__early_init:
blr
- /*
- * Default late initialization code, none.
- */
+ /* Default late initialization code, none.*/
.weak __late_init
.globl __late_init
.type __late_init, @function
|