Subversion Repositories freemyipod

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 theseven 1
@
2
@
3
@    Copyright 2010 TheSeven
4
@
5
@
6
@    This file is part of emBIOS.
7
@
8
@    emBIOS is free software: you can redistribute it and/or
9
@    modify it under the terms of the GNU General Public License as
10
@    published by the Free Software Foundation, either version 2 of the
11
@    License, or (at your option) any later version.
12
@
13
@    emBIOS is distributed in the hope that it will be useful,
14
@    but WITHOUT ANY WARRANTY; without even the implied warranty of
15
@    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
@    See the GNU General Public License for more details.
17
@
18
@    You should have received a copy of the GNU General Public License
19
@    along with emBIOS.  If not, see <http://www.gnu.org/licenses/>.
20
@
21
@
22
 
23
 
24
.section .intvect,"ax",%progbits
25
	ldr pc, =reset_handler
26
	ldr pc, =undef_instr_handler
27
	ldr pc, =syscall_handler
28
	ldr pc, =prefetch_abort_handler
29
	ldr pc, =data_abort_handler
30
	ldr pc, =reserved_handler
31
	ldr pc, =irq_handler
32
	ldr pc, =fiq_handler
33
.ltorg
34
 
35
 
36
.section .initcode,"ax",%progbits
37
.global _start
38
_start:
39
	ldr	r0, =_sramsource
40
	ldr	r1, =_sramstart
41
	ldr	r2, =_sramend
42
.copysram:
43
	cmp	r2, r1
44
	ldrhi	r3, [r0], #4
45
	strhi	r3, [r1], #4
46
	bhi	.copysram
47
	ldr	r0, =_sdramsource
48
	ldr	r1, =_sdramstart
49
	ldr	r2, =_sdramend
50
.copysdram:
51
	cmp	r2, r1
52
	ldrhi	r3, [r0], #4
53
	strhi	r3, [r1], #4
54
	bhi	.copysdram
55
	ldr	r0, =_initbssstart
56
	ldr	r1, =_initbssend
57
	mov	r2, #0
58
.clearinitbss:
59
	cmp	r1, r0
60
	strhi	r2, [r0], #4
61
	bhi	.clearinitbss
62
	ldr	r0, =_ibssstart
63
	ldr	r1, =_ibssend
64
.clearibss:
65
	cmp	r1, r0
66
	strhi	r2, [r0], #4
67
	bhi	.clearibss
68
	ldr	r0, =_bssstart
69
	ldr	r1, =_bssend
70
.clearbss:
71
	cmp	r1, r0
72
	strhi	r2, [r0], #4
73
	bhi	.clearbss
74
	ldr	r1, =0x38200000
75
	ldr	r0, [r1]
76
	orr	r0, r0, #1
77
	bic	r0, r0, #0x10000
78
	str	r0, [r1]
79
	mov	r0, #0
80
	mcr	p15, 0, r0,c7,c5,0
14 theseven 81
	mov	r1, #0x39c00000
82
	str	r0, [r1,#4]
83
	str	r0, [r1,#8]
84
	str	r0, [r1,#0x38]
85
	str	r0, [r1,#0x20]
86
	sub	r0, r0, #1
87
	str	r0, [r1]
88
	str	r0, [r1,#0x10]
89
	str	r0, [r1,#0x1c]
2 theseven 90
	msr	cpsr_c, #0xd2
91
	ldr	sp, =_irqstackend
92
	msr	cpsr_c, #0xd7
93
	ldr	sp, =_abortstackend
94
	msr	cpsr_c, #0xdb
95
	ldr	sp, =_abortstackend
43 theseven 96
	msr	cpsr_c, #0x1f
2 theseven 97
	ldr	sp, =_initstackend
98
	bl	init
15 theseven 99
	bl	context_switch
14 theseven 100
	mov	r0, #0
101
idleloop:
102
	mcr	p15, 0, r0,c7,c0,4
103
	b	idleloop
2 theseven 104
.ltorg
105
 
106
 
107
.section .icode, "ax", %progbits
108
.align 2
109
.global reset
110
.global hang
111
.type reset, %function
112
.type hang, %function
113
reset:
114
	msr	cpsr_c, #0xd3
115
	mov	r0, #0x110000
116
	add	r0, r0, #0xff
117
	add	r1, r0, #0xa00
118
	mov	r2, #0x3c800000
119
	str	r1, [r2]
120
	mov	r1, #0xff0
121
	str	r1, [r2,#4]
122
	str	r0, [r2]
123
hang:
15 theseven 124
	msr	cpsr_c, #0xd3
125
	mcr	p15, 0, r0,c7,c0,4
2 theseven 126
	b	hang
127
.size reset, .-reset
128
.size hang, .-hang
129
 
130
.type reset_handler, %function
131
reset_handler:
43 theseven 132
	mov	r0, #0
133
	adr	r1, reset_text
2 theseven 134
	b	panic
135
reset_text:
136
	.ascii	"Hit reset vector!\0"
137
.size reset_handler, .-reset_handler
138
 
139
.type undef_instr_handler, %function
140
undef_instr_handler:
43 theseven 141
	mov	r0, #0
142
	adr	r1, undef_instr_text
143
	sub	r2, lr, #4
2 theseven 144
	b	panicf
145
.size undef_instr_handler, .-undef_instr_handler
146
 
147
.type prefetch_abort_handler, %function
148
prefetch_abort_handler:
43 theseven 149
	mov	r0, #0
150
	adr	r1, prefetch_abort_text
151
	sub	r2, lr, #4
2 theseven 152
	b	panicf
153
.size prefetch_abort_handler, .-prefetch_abort_handler
154
 
155
.type data_abort_handler, %function
156
data_abort_handler:
43 theseven 157
	mov	r0, #0
158
	adr	r1, data_abort_text
159
	sub	r2, lr, #4
2 theseven 160
	b	panicf
161
.size data_abort_handler, .-data_abort_handler
162
 
163
.type reserved_handler, %function
164
reserved_handler:
43 theseven 165
	mov	r0, #0
166
	adr	r1, reserved_text
2 theseven 167
	b	panic
168
.size reserved_handler, .-reserved_handler
169
 
170
.type fiq_handler, %function
171
fiq_handler:
43 theseven 172
	mov	r0, #2
173
	adr	r1, fiq_text
2 theseven 174
	b	panic
175
.size fiq_handler, .-fiq_handler
176
 
177
undef_instr_text:
178
	.ascii	"Undefined instruction at %08X!\0"
179
 
180
prefetch_abort_text:
181
	.ascii	"Prefetch abort at %08X!\0"
182
 
183
data_abort_text:
184
	.ascii	"Data abort at %08X!\0"
185
 
186
reserved_text:
187
	.ascii	"Hit reserved exception handler!\0"
188
 
189
fiq_text:
190
	.ascii	"Unhandled FIQ!\0"
191
 
192
syscall_text:
193
	.ascii	"Unhandled syscall!\0"
15 theseven 194
 
195
 
196
.section .icode.usec_timer, "ax", %progbits
197
.align 2
198
.global read_5usec_timer
199
.type read_5usec_timer, %function
200
read_5usec_timer:
201
	ldr	r0, val_3c700000
202
	ldr	r1, [r0,#0x80]
203
	ldr	r0, [r0,#0x84]
204
	bx	lr
205
.size read_5usec_timer, .-read_5usec_timer
206
 
207
.global read_usec_timer
208
.type read_usec_timer, %function
209
read_usec_timer:
210
	ldr	r0, val_3c700000
211
	ldr	r1, [r0,#0x80]
212
	ldr	r0, [r0,#0x84]
213
	add	r0, r0, r0,lsl#2
214
	bx	lr
215
.size read_usec_timer, .-read_usec_timer
216
 
217
val_3c700000:
218
	.word	0x3c700000