blob: 583307250cc992a6b90d384943a78acbf70ee587 [file] [log] [blame]
Anton Komlevc88e2ac2024-09-12 16:46:39 +01001/*
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
15typedef struct __copy_table {
16 uint32_t const *src;
17 uint32_t *dest;
18 uint32_t wlen;
19} __copy_table_t;
20
21typedef struct __zero_table {
22 uint32_t *dest;
23 uint32_t wlen;
24} __zero_table_t;
25
26extern const __copy_table_t __copy_table_start__;
27extern const __copy_table_t __copy_table_end__;
28extern const __zero_table_t __zero_table_start__;
29extern const __zero_table_t __zero_table_end__;
30
31extern int main(int argc, char **argv);
32
33void _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