From 48026bb824fd2d9cfb00ecd040db6ef3a416bae9 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Fri, 22 Jan 2021 21:43:36 -0500 Subject: upload initial port --- .../common/startup/ARMCMx-SB/compilers/GCC/crt0.S | 190 +++++++++++++++++++++ .../startup/ARMCMx-SB/compilers/GCC/ld/rules.ld | 11 ++ .../ARMCMx-SB/compilers/GCC/ld/rules_code.ld | 80 +++++++++ .../ARMCMx-SB/compilers/GCC/ld/rules_data.ld | 43 +++++ .../ARMCMx-SB/compilers/GCC/ld/rules_memory.ld | 27 +++ .../ARMCMx-SB/compilers/GCC/ld/rules_stacks.ld | 27 +++ .../startup/ARMCMx-SB/compilers/GCC/mk/startup.mk | 14 ++ 7 files changed, 392 insertions(+) create mode 100644 ChibiOS_20.3.2/os/common/startup/ARMCMx-SB/compilers/GCC/crt0.S create mode 100644 ChibiOS_20.3.2/os/common/startup/ARMCMx-SB/compilers/GCC/ld/rules.ld create mode 100644 ChibiOS_20.3.2/os/common/startup/ARMCMx-SB/compilers/GCC/ld/rules_code.ld create mode 100644 ChibiOS_20.3.2/os/common/startup/ARMCMx-SB/compilers/GCC/ld/rules_data.ld create mode 100644 ChibiOS_20.3.2/os/common/startup/ARMCMx-SB/compilers/GCC/ld/rules_memory.ld create mode 100644 ChibiOS_20.3.2/os/common/startup/ARMCMx-SB/compilers/GCC/ld/rules_stacks.ld create mode 100644 ChibiOS_20.3.2/os/common/startup/ARMCMx-SB/compilers/GCC/mk/startup.mk (limited to 'ChibiOS_20.3.2/os/common/startup/ARMCMx-SB/compilers') diff --git a/ChibiOS_20.3.2/os/common/startup/ARMCMx-SB/compilers/GCC/crt0.S b/ChibiOS_20.3.2/os/common/startup/ARMCMx-SB/compilers/GCC/crt0.S new file mode 100644 index 0000000..dcb0e42 --- /dev/null +++ b/ChibiOS_20.3.2/os/common/startup/ARMCMx-SB/compilers/GCC/crt0.S @@ -0,0 +1,190 @@ +/* + ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/** + * @file crt0.S + * @brief Generic ARMv7-M sandbox startup file for ChibiOS. + * + * @addtogroup ARMCMx_GCC_STARTUP_V7M_SB + * @{ + */ + +/*===========================================================================*/ +/* 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__) + + .syntax unified + .cpu cortex-m3 + + .thumb + + .section .sandbox, "ax" + .align 4 + .globl _sandbox +_sandbox: .long 0xFE9154C0 + .long 0x0C4519EF + .long 16 + .long 0 + b _crt0_entry + + .text +/* + * CRT0 entry point. + */ + .align 2 + .thumb_func + .global _crt0_entry +_crt0_entry: + + /* PSP stack pointers initialization.*/ + ldr r0, =__user_psp_end__ + msr PSP, r0 + +#if CRT0_INIT_STACKS == TRUE + /* User process Stack initialization. Note, it assumes that the + stack size is a multiple of 4 so the linker file must + ensure this.*/ + ldr r0, =CRT0_STACKS_FILL_PATTERN + ldr r1, =__user_psp_base__ + ldr r2, =__user_psp_end__ +upsloop: + cmp r1, r2 + itt lo + strlo r0, [r1], #4 + blo upsloop +#endif /* CRT0_INIT_STACKS == TRUE */ + +#if CRT0_INIT_DATA == TRUE + /* Data initialization. Note, it assumes that the DATA size + is a multiple of 4 so the linker file must ensure this.*/ + ldr r1, =__textdata_base__ + ldr r2, =__data_base__ + ldr r3, =__data_end__ +dloop: + cmp r2, r3 + ittt lo + ldrlo r0, [r1], #4 + strlo r0, [r2], #4 + blo dloop +#endif /* CRT0_INIT_DATA == TRUE */ + +#if CRT0_INIT_BSS == TRUE + /* BSS initialization. Note, it assumes that the DATA size + is a multiple of 4 so the linker file must ensure this.*/ + movs r0, #0 + ldr r1, =__bss_base__ + ldr r2, =__bss_end__ +bloop: + cmp r1, r2 + itt lo + strlo r0, [r1], #4 + blo bloop +#endif /* CRT0_INIT_BSS == TRUE */ + +#if CRT0_CALL_CONSTRUCTORS == TRUE + /* Constructors invocation.*/ + ldr r4, =__init_array_base__ + ldr r5, =__init_array_end__ +initloop: + cmp r4, r5 + bge endinitloop + ldr r1, [r4], #4 + blx r1 + b initloop +endinitloop: +#endif /* CRT0_CALL_CONSTRUCTORS == TRUE */ + + /* Main program invocation, r0 contains the returned value.*/ + bl main + +#if CRT0_CALL_DESTRUCTORS == TRUE + /* Destructors invocation.*/ + ldr r4, =__fini_array_base__ + ldr r5, =__fini_array_end__ +finiloop: + cmp r4, r5 + bge endfiniloop + ldr r1, [r4], #4 + blx r1 + b finiloop +endfiniloop: +#endif /* CRT0_CALL_DESTRUCTORS == TRUE */ + +.exitloop: b .exitloop + +#endif /* !defined(__DOXYGEN__) */ + +/** @} */ diff --git a/ChibiOS_20.3.2/os/common/startup/ARMCMx-SB/compilers/GCC/ld/rules.ld b/ChibiOS_20.3.2/os/common/startup/ARMCMx-SB/compilers/GCC/ld/rules.ld new file mode 100644 index 0000000..8ca9a47 --- /dev/null +++ b/ChibiOS_20.3.2/os/common/startup/ARMCMx-SB/compilers/GCC/ld/rules.ld @@ -0,0 +1,11 @@ +/* Stack rules inclusion.*/ +INCLUDE rules_stacks.ld + +/* Code rules inclusion.*/ +INCLUDE rules_code.ld + +/* Data rules inclusion.*/ +INCLUDE rules_data.ld + +/* Memory rules inclusion.*/ +INCLUDE rules_memory.ld diff --git a/ChibiOS_20.3.2/os/common/startup/ARMCMx-SB/compilers/GCC/ld/rules_code.ld b/ChibiOS_20.3.2/os/common/startup/ARMCMx-SB/compilers/GCC/ld/rules_code.ld new file mode 100644 index 0000000..6568410 --- /dev/null +++ b/ChibiOS_20.3.2/os/common/startup/ARMCMx-SB/compilers/GCC/ld/rules_code.ld @@ -0,0 +1,80 @@ +/* + ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +ENTRY(_crt0_entry) + +SECTIONS +{ + .sandbox : ALIGN(16) + { + KEEP(*(.sandbox)) + } > CODE_SPACE + + .xtors : ALIGN(4) + { + __init_array_base__ = .; + KEEP(*(SORT(.init_array.*))) + KEEP(*(.init_array)) + __init_array_end__ = .; + __fini_array_base__ = .; + KEEP(*(.fini_array)) + KEEP(*(SORT(.fini_array.*))) + __fini_array_end__ = .; + } > CODE_SPACE + + .text : ALIGN_WITH_INPUT + { + __text_base__ = .; + *(.text) + *(.text.*) + *(.glue_7t) + *(.glue_7) + *(.gcc*) + __text_end__ = .; + } > CODE_SPACE + + .rodata : ALIGN(4) + { + __rodata_base__ = .; + *(.rodata) + *(.rodata.*) + . = ALIGN(4); + __rodata_end__ = .; + } > CODE_SPACE + + .ARM.extab : + { + *(.ARM.extab* .gnu.linkonce.armextab.*) + } > CODE_SPACE + + .ARM.exidx : { + __exidx_base__ = .; + __exidx_start = .; + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + __exidx_end__ = .; + __exidx_end = .; + } > CODE_SPACE + + .eh_frame_hdr : + { + *(.eh_frame_hdr) + } > CODE_SPACE + + .eh_frame : ONLY_IF_RO + { + *(.eh_frame) + } > CODE_SPACE +} diff --git a/ChibiOS_20.3.2/os/common/startup/ARMCMx-SB/compilers/GCC/ld/rules_data.ld b/ChibiOS_20.3.2/os/common/startup/ARMCMx-SB/compilers/GCC/ld/rules_data.ld new file mode 100644 index 0000000..6d474ea --- /dev/null +++ b/ChibiOS_20.3.2/os/common/startup/ARMCMx-SB/compilers/GCC/ld/rules_data.ld @@ -0,0 +1,43 @@ +/* + ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +SECTIONS +{ + .data : ALIGN(4) + { + PROVIDE(_textdata = LOADADDR(.data)); + PROVIDE(_data = .); + __textdata_base__ = LOADADDR(.data); + __data_base__ = .; + *(.data) + *(.data.*) + *(.ramtext) + . = ALIGN(4); + PROVIDE(_edata = .); + __data_end__ = .; + } > DATA_SPACE + + .bss (NOLOAD) : ALIGN(4) + { + __bss_base__ = .; + *(.bss) + *(.bss.*) + *(COMMON) + . = ALIGN(4); + __bss_end__ = .; + PROVIDE(end = .); + } > DATA_SPACE +} diff --git a/ChibiOS_20.3.2/os/common/startup/ARMCMx-SB/compilers/GCC/ld/rules_memory.ld b/ChibiOS_20.3.2/os/common/startup/ARMCMx-SB/compilers/GCC/ld/rules_memory.ld new file mode 100644 index 0000000..8cf4585 --- /dev/null +++ b/ChibiOS_20.3.2/os/common/startup/ARMCMx-SB/compilers/GCC/ld/rules_memory.ld @@ -0,0 +1,27 @@ +/* + ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +SECTIONS +{ + /* The default heap uses the (statically) unused part of a RAM section.*/ + .heap (NOLOAD) : + { + . = ALIGN(8); + __heap_base__ = .; + . = ORIGIN(DATA_SPACE) + LENGTH(DATA_SPACE); + __heap_end__ = .; + } > DATA_SPACE +} diff --git a/ChibiOS_20.3.2/os/common/startup/ARMCMx-SB/compilers/GCC/ld/rules_stacks.ld b/ChibiOS_20.3.2/os/common/startup/ARMCMx-SB/compilers/GCC/ld/rules_stacks.ld new file mode 100644 index 0000000..a377ffe --- /dev/null +++ b/ChibiOS_20.3.2/os/common/startup/ARMCMx-SB/compilers/GCC/ld/rules_stacks.ld @@ -0,0 +1,27 @@ +/* + ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +SECTIONS +{ + .upsp (NOLOAD) : + { + . = ALIGN(8); + __user_psp_base__ = .; + . += __process_stack_size__; + . = ALIGN(8); + __user_psp_end__ = .; + } > DATA_SPACE +} diff --git a/ChibiOS_20.3.2/os/common/startup/ARMCMx-SB/compilers/GCC/mk/startup.mk b/ChibiOS_20.3.2/os/common/startup/ARMCMx-SB/compilers/GCC/mk/startup.mk new file mode 100644 index 0000000..22e67cd --- /dev/null +++ b/ChibiOS_20.3.2/os/common/startup/ARMCMx-SB/compilers/GCC/mk/startup.mk @@ -0,0 +1,14 @@ +# List of the ChibiOS generic sandbox startup files. +STARTUPSRC = + +STARTUPASM = $(CHIBIOS)/os/common/startup/ARMCMx-SB/compilers/GCC/crt0.S + +STARTUPINC = $(CHIBIOS)/os/common/portability/GCC \ + $(CHIBIOS)/os/common/startup/ARMCMx-SB/compilers/GCC + +STARTUPLD = $(CHIBIOS)/os/common/startup/ARMCMx-SB/compilers/GCC/ld + +# Shared variables +ALLXASMSRC += $(STARTUPASM) +ALLCSRC += $(STARTUPSRC) +ALLINC += $(STARTUPINC) -- cgit v1.2.3