-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcrt0.cpp
50 lines (40 loc) · 1.17 KB
/
crt0.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2007 - 2023.
// Copyright Amine Chalandi 2023.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Generic Cortex-M startup code.
#include <mcal_cpu.h>
namespace crt
{
void init_ram();
void init_ctors();
}
extern "C" void __my_startup() __attribute__((used, noinline));
void __my_startup()
{
// Load the stack pointer.
// The stack pointer is automatically loaded from
// the base position of the interrupt vector table.
// So we do nothing here.
// Oscillator initialization.
mcal::cpu::init();
// Initialize statics from ROM to RAM.
// Zero-clear default-initialized static RAM.
crt::init_ram();
//mcal::wdg::secure::trigger();
// Call all ctor initializations.
crt::init_ctors();
//mcal::wdg::secure::trigger();
// Jump to main (and never return).
asm volatile("ldr r3, =main");
asm volatile("blx r3");
// Catch an unexpected return from main.
for(;;)
{
// Replace with a loud error if desired.
;
}
}