aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--demos/SPC5/RT-SPC560P-EVB/.cproject4
-rw-r--r--os/common/ports/e200/compilers/GCC/crt0.s201
2 files changed, 164 insertions, 41 deletions
diff --git a/demos/SPC5/RT-SPC560P-EVB/.cproject b/demos/SPC5/RT-SPC560P-EVB/.cproject
index 3405a3597..9573eb3e8 100644
--- a/demos/SPC5/RT-SPC560P-EVB/.cproject
+++ b/demos/SPC5/RT-SPC560P-EVB/.cproject
@@ -39,7 +39,7 @@
</cconfiguration>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
- <project id="RT-SPC560B-EVB.null.2129661677" name="RT-SPC560B-EVB"/>
+ <project id="RT-SPC560P-EVB.null.2129661677" name="RT-SPC560P-EVB"/>
</storageModule>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
@@ -50,7 +50,7 @@
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
<storageModule moduleId="refreshScope" versionNumber="2">
<configuration configurationName="Default">
- <resource resourceType="PROJECT" workspacePath="/RT-SPC560B-EVB"/>
+ <resource resourceType="PROJECT" workspacePath="/RT-SPC560P-EVB"/>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
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