Anton Komlev | c88e2ac | 2024-09-12 16:46:39 +0100 | [diff] [blame^] | 1 | /* |
| 2 | * SPDX-License-Identifier: BSD-3-Clause |
| 3 | * SPDX-FileCopyrightText: Copyright The TrustedFirmware-M Contributors |
| 4 | */ |
| 5 | |
| 6 | #include "utilities.h" |
| 7 | |
| 8 | #if defined(__clang_major__) && defined(__GNUC__) |
| 9 | |
| 10 | /* |
| 11 | * We can not use CMSIS support for LLVM toolchain because it's incompatible |
| 12 | * with it. That's why we manunally implement the startup routine below. |
| 13 | */ |
| 14 | |
| 15 | typedef struct __copy_table { |
| 16 | uint32_t const *src; |
| 17 | uint32_t *dest; |
| 18 | uint32_t wlen; |
| 19 | } __copy_table_t; |
| 20 | |
| 21 | typedef struct __zero_table { |
| 22 | uint32_t *dest; |
| 23 | uint32_t wlen; |
| 24 | } __zero_table_t; |
| 25 | |
| 26 | extern const __copy_table_t __copy_table_start__; |
| 27 | extern const __copy_table_t __copy_table_end__; |
| 28 | extern const __zero_table_t __zero_table_start__; |
| 29 | extern const __zero_table_t __zero_table_end__; |
| 30 | |
| 31 | extern int main(int argc, char **argv); |
| 32 | |
| 33 | void _start(void) |
| 34 | { |
| 35 | for (__copy_table_t const *pTable = &__copy_table_start__; pTable < &__copy_table_end__; ++pTable) { |
| 36 | for (uint32_t i = 0u; i < pTable->wlen; ++i) { |
| 37 | pTable->dest[i] = pTable->src[i]; |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | for (__zero_table_t const *pTable = &__zero_table_start__; pTable < &__zero_table_end__; ++pTable) { |
| 42 | for (uint32_t i = 0u; i < pTable->wlen; ++i) { |
| 43 | pTable->dest[i] = 0u; |
| 44 | } |
| 45 | } |
| 46 | main(0, NULL); |
| 47 | while (1) |
| 48 | ; |
| 49 | } |
| 50 | #else |
| 51 | #error This startup file shall be used in LLVM toolchain only. |
| 52 | #endif |