aboutsummaryrefslogtreecommitdiff
path: root/init-m-test9.S
blob: 634929444a07735b714b1f63d12167257e3dee3f (plain)
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
.thumb
.syntax unified

.section .text.start
.global _boot_reset
.align 7
_boot_reset:
.word _main_stack_top
.word _start /* reset */
.word _vec_stuck
.word _vec_stuck
.word _vec_stuck
.word _vec_stuck
.word _vec_stuck
.word _vec_stuck
.word _vec_stuck
.word _vec_stuck
.word _vec_stuck
.word _vec_stuck
.word _vec_stuck
.word _vec_stuck
.word _vec_stuck
.word _vec_stuck

.section .text

.global _start
.thumb_func
_start:
  ldr r3, =early_state

  mov r0, lr
  str r0, [r3], #4

  mrs r0, XPSR
  str r0, [r3], #4

  mrs r0, PRIMASK
  str r0, [r3], #4

  mrs r0, FAULTMASK
  str r0, [r3], #4

  mrs r0, BASEPRI
  str r0, [r3], #4

  mrs r0, CONTROL
  str r0, [r3], #4

  mrs r0, MSP
  str r0, [r3], #4

  mrs r0, PSP
  str r0, [r3], #4

  ldr r2, =0xe000e000

  ldr r0, [r2, #0xd00] /* CPUID */
  str r0, [r3], #4

  ldr r0, [r2, #0xd04] /* ICSR */
  str r0, [r3], #4

  ldr r0, [r2, #0xd08] /* VTOR */
  str r0, [r3], #4

  ldr r0, [r2, #0xd0c] /* AIRCR */
  str r0, [r3], #4

  ldr r0, [r2, #0xd10] /* SCR */
  str r0, [r3], #4

  ldr r0, [r2, #0xd14] /* CCR */
  str r0, [r3], #4

  ldr r0, [r2, #0xd18] /* SHPR1 */
  str r0, [r3], #4
  ldr r0, [r2, #0xd1c] /* SHPR2 */
  str r0, [r3], #4
  ldr r0, [r2, #0xd20] /* SHPR3 */
  str r0, [r3], #4

  ldr r0, [r2, #0xd24] /* SHCSR */
  str r0, [r3], #4

  ldr r0, [r2, #0x10] /* SYST_CSR */
  str r0, [r3], #4

  ldr r0, [r2, #0x4] /* ICTR */
  str r0, [r3], #4

  ldr r0, [r2, #0xd90] /* MPU_TYPE */
  str r0, [r3], #4

  ldr r0, [r2, #0xd94] /* MPU_CTRL */
  str r0, [r3], #4

  ldr r0, =0xdeadbeaf
  str r0, [r3], #4

  blx board_setup
  blx main
  /* fall through to abort() */

.global abort
.thumb_func
abort:
  ldr sp, =_main_stack_top

  ldr r0, =0x05fa0004 /* reset request */
  ldr r1, =0xe000ed0c /* AIRCR */
  str r0, [r1]
  dsb

_stuck:
  b _stuck

.thumb_func
_vec_stuck:
  mov r0, #'S'
  ldr r1, =0x4000c000
  str r0, [r1]
  bl abort

.section .bss
.align 4

.global _main_stack_bot
_main_stack_bot:
.skip 0x400
.global _main_stack_top
_main_stack_top: