-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentry.S
109 lines (92 loc) · 2.7 KB
/
entry.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
/* entry.S - exception, interrupt and syscall entry point */
/* Copyright (C) 2013 Goswin von Brederlow <[email protected]>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
.section ".text"
.balign 32
.globl exception_table
exception_table:
ldr pc, addr_exception_reset
ldr pc, addr_exception_undefined
ldr pc, addr_exception_syscall
ldr pc, addr_exception_prefetch_abort
ldr pc, addr_exception_data_abort
ldr pc, addr_exception_reserved
ldr pc, addr_exception_irq
ldr pc, addr_exception_fiq
addr_exception_reset: .word exception_reset
addr_exception_undefined: .word exception_undefined
addr_exception_syscall: .word exception_syscall
addr_exception_prefetch_abort: .word exception_prefetch_abort
addr_exception_data_abort: .word exception_data_abort
addr_exception_reserved: .word exception_reserved
addr_exception_irq: .word exception_irq
addr_exception_fiq: .word exception_fiq
// Mapping between virtual and physical memory
#define PHYS_TO_VIRT 0xC0000000
.macro save, offset
// Adjust LR and save it
sub lr, #\offset
stmdb sp!,{lr}
// save all registers
stmdb sp,{r0-r14}^
sub sp, #60
mov r0, sp
.endm
.macro restore
// restore all registers and return
ldmia sp,{r0-r14}^
add sp, #60
ldmia sp!,{pc}^
.endm
.balign 4
.globl exception_reset
exception_reset:
save 4
bl exception_reset_handler
// no way to return from reset
// restore
b abort
.globl exception_undefined
exception_undefined:
save 4
bl exception_undefined_handler
b abort
.globl exception_syscall
exception_syscall:
save 0
bl exception_syscall_handler
b abort
.globl exception_prefetch_abort
exception_prefetch_abort:
save 4
bl exception_prefetch_abort_handler
b abort
.globl exception_data_abort
exception_data_abort:
save 8
bl exception_data_abort_handler
b abort
.globl exception_reserved
exception_reserved:
b abort
.globl exception_irq
exception_irq:
save 4
bl exception_irq_handler
restore
.globl exception_fiq
exception_fiq:
save 4
bl exception_fiq_handler
b abort