This repository has been archived by the owner on Jan 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
crt0.s
154 lines (140 loc) · 3.01 KB
/
crt0.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
.global _start
.global _followup
.global branch
.global _available_start
.global _available_end
.macro mww A,B
ldr r0, =\B
ldr r1, =\A
str r0,[r1]
.endm
_start:
/* Initialization of openocd */
# SVC32 mode
ldr r0, =0x800000d3
msr cpsr, r0
# WTCON : disable watchdog
mww 0x01d30000 0
# INTMSK
mww 0x01e0000c 0x03fffeff
# INTCON
mww 0x01e00000 0x5
# LOCKTIME
mww 0x01d8000c 0xf0
# PLLCON
mww 0x01d80000 0x0003a031
# CLKCON
mww 0x01d80004 0x00007ff8
# PCONA
mww 0x01d20000 0x000003ff
# PDATB
mww 0x01d2000c 0x7cf
# PCONB
mww 0x01d20008 0x07ff
# PDATC
mww 0x01d20014 0x0100
# PCONC
mww 0x01d20010 0xfff5ff54
# PUPC
mww 0x01d20018 0x00000000
# PCOND
mww 0x01d2001c 0x0000aaaa
# PUPD
mww 0x01d20024 0x00000000
# PCONE
mww 0x01d20028 0x00021569
# PDATE
mww 0x01d2002c 0x00000000
# PUPE
mww 0x01d20030 0x00000000
# PCONF
mww 0x01d20034 0x24900a
# PUPF
mww 0x01d2003c 0x00000000
# PCONG
mww 0x01d20040 0xff3c
# PUPG
mww 0x01d20048 0x00000000
# SPUCR
mww 0x01d2004c 0x6
# INTMSK
mww 0x01e0000c 0x03fffeff
# INTCON
mww 0x01e00000 0x05
# INTMOD
mww 0x01e00008 0x0
# EXTINT
mww 0x01d20050 0x00040440
# SDRAM init
mww 0x1c80000 0x01001102
mww 0x1c80004 0x00007ff4
mww 0x1c80008 0x00000a40
mww 0x1c8000C 0x00001480
mww 0x1c80010 0x00007ffc
mww 0x1c80014 0x00007ffc
mww 0x1c80018 0x00000c40
mww 0x1c8001C 0x00018004
mww 0x1c80020 0x00000a40
mww 0x1c80024 0x008603fb
mww 0x1c80028 0x00000010
mww 0x1c8002C 0x00000020
mww 0x1c80030 0x00000020
/* Set up the stack pointer */
ldr r0, =_ram_end
ldr r1, [r0]
mov sp, r1
/* Zeroes up the BSS section */
ldr r0, =_bss_start
ldr r0, [r0]
ldr r1, =_bss_end
ldr r1, [r1]
mov r2, #0
_loop_zero_bss:
cmp r0, r1
beq _paste_data
str r2, [r0]
add r0, r0, #4
bne _loop_zero_bss
/* Pastes the data section to the start of ram */
_paste_data:
ldr r0, =_data_start
ldr r0, [r0]
ldr r1, =_data_end
ldr r1, [r1]
ldr r3, =_ram_start
ldr r3, [r3]
_loop_paste_data:
cmp r0, r1
beq _back_to_main
ldr r2, [r0]
str r2, [r3]
add r0, r0, #4
add r3, r3, #4
bne _loop_paste_data
_back_to_main:
/* Launch main with no args */
mov r0, #0 /* no argc */
mov r1, #0 /* no argv */
bl main /* Should return */
.word 0xDEEEDEEE /* Set a soft break point */
bl end
end:
b end
branch:
mov pc, r0
_data_start:
.word _sdata
_data_end:
.word _edata
_ram_start:
.word _ram_debut
_ram_end:
.word _stack_start
_bss_start:
.word _sbss
_bss_end:
.word _ebss
_available_start:
.word _free_space_start
_available_end:
.word _free_space_end