-
Notifications
You must be signed in to change notification settings - Fork 7
/
boot.S
73 lines (61 loc) · 1.07 KB
/
boot.S
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
.cpu cortex-m3
.syntax unified
.code 16
.section .start
.word _stack_top
.word start + 1
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0x4e65576f
.text
#define UART_SR_TXE (1 << 7)
#define UART_SR (0x00)
#define UART_DR (0x04)
#define UART1 0x40011000
#define UART2 0x40004400
#define UART3 0x40004800
#define UARTDBG UART3
#define RCC 0x40023800
#define RCC_APB1ENR (RCC + 0x40)
#define RCC_APB1ENR_UART3 (1 << 18)
start:
@ relocate .data to RAM
ldr r0, =_data_vma
ldr r1, =_data_lma
ldr r2, =_data_size
lsr r2, r2, #2
1: cmp r2, #0
it eq
beq 2f
ldr r3, [r1], #4
str r3, [r0], #4
add r2, r2, -1
b 1b
2:
@ zero out bss
ldr r0, =_bss
ldr r2, =_bss_size
lsr r2, r2, #2
mov r3, #0
1: cmp r2, #0
it eq
beq 2f
str r3, [r0], #4
add r2, r2, -1
b 1b
2:
@ set up the stack
ldr sp, =_stack_top
blx main
@@@ XXX: FIRST ORDER OF BUSINESS MUST BE TO SET UP THE WATCHDOG
@@@ TIMER, and to check for a button press to crash back into PRF!
@@@ Let's try NOT to brick any watches, if we can avoid it.
1: wfi
b 1b
.bss
_stack_bottom:
.skip 4096
_stack_top: