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
 
98 theseven 36
.section .inithead,"ax",%progbits
37
.global __start
38
__start:
39
	b	_start
40
 
2 theseven 41
.section .initcode,"ax",%progbits
42
.global _start
43
_start:
44
	ldr	r0, =_sramsource
45
	ldr	r1, =_sramstart
46
	ldr	r2, =_sramend
47
.copysram:
48
	cmp	r2, r1
49
	ldrhi	r3, [r0], #4
50
	strhi	r3, [r1], #4
51
	bhi	.copysram
52
	ldr	r0, =_sdramsource
53
	ldr	r1, =_sdramstart
54
	ldr	r2, =_sdramend
55
.copysdram:
56
	cmp	r2, r1
57
	ldrhi	r3, [r0], #4
58
	strhi	r3, [r1], #4
59
	bhi	.copysdram
60
	ldr	r0, =_initbssstart
61
	ldr	r1, =_initbssend
62
	mov	r2, #0
63
.clearinitbss:
64
	cmp	r1, r0
65
	strhi	r2, [r0], #4
66
	bhi	.clearinitbss
67
	ldr	r0, =_ibssstart
68
	ldr	r1, =_ibssend
69
.clearibss:
70
	cmp	r1, r0
71
	strhi	r2, [r0], #4
72
	bhi	.clearibss
73
	ldr	r0, =_bssstart
74
	ldr	r1, =_bssend
75
.clearbss:
76
	cmp	r1, r0
77
	strhi	r2, [r0], #4
78
	bhi	.clearbss
79
	ldr	r1, =0x38200000
80
	ldr	r0, [r1]
81
	orr	r0, r0, #1
82
	bic	r0, r0, #0x10000
83
	str	r0, [r1]
84
	mov	r0, #0
85
	mcr	p15, 0, r0,c7,c5,0
14 theseven 86
	mov	r1, #0x39c00000
87
	str	r0, [r1,#4]
88
	str	r0, [r1,#8]
89
	str	r0, [r1,#0x38]
90
	str	r0, [r1,#0x20]
91
	sub	r0, r0, #1
92
	str	r0, [r1]
93
	str	r0, [r1,#0x10]
94
	str	r0, [r1,#0x1c]
2 theseven 95
	msr	cpsr_c, #0xd2
96
	ldr	sp, =_irqstackend
97
	msr	cpsr_c, #0xd7
98
	ldr	sp, =_abortstackend
99
	msr	cpsr_c, #0xdb
100
	ldr	sp, =_abortstackend
43 theseven 101
	msr	cpsr_c, #0x1f
2 theseven 102
	ldr	sp, =_initstackend
103
	bl	init
15 theseven 104
	bl	context_switch
14 theseven 105
	mov	r0, #0
106
idleloop:
107
	mcr	p15, 0, r0,c7,c0,4
108
	b	idleloop
2 theseven 109
.ltorg
110
 
111
 
112
.section .icode, "ax", %progbits
113
.align 2
114
.global reset
115
.global hang
116
.type reset, %function
117
.type hang, %function
118
reset:
119
	msr	cpsr_c, #0xd3
120
	mov	r0, #0x110000
121
	add	r0, r0, #0xff
122
	add	r1, r0, #0xa00
123
	mov	r2, #0x3c800000
124
	str	r1, [r2]
125
	mov	r1, #0xff0
126
	str	r1, [r2,#4]
127
	str	r0, [r2]
128
hang:
15 theseven 129
	msr	cpsr_c, #0xd3
130
	mcr	p15, 0, r0,c7,c0,4
2 theseven 131
	b	hang
132
.size reset, .-reset
133
.size hang, .-hang
134
 
135
.type reset_handler, %function
136
reset_handler:
43 theseven 137
	mov	r0, #0
138
	adr	r1, reset_text
2 theseven 139
	b	panic
140
reset_text:
141
	.ascii	"Hit reset vector!\0"
142
.size reset_handler, .-reset_handler
143
 
144
.type undef_instr_handler, %function
145
undef_instr_handler:
43 theseven 146
	mov	r0, #0
147
	adr	r1, undef_instr_text
148
	sub	r2, lr, #4
2 theseven 149
	b	panicf
150
.size undef_instr_handler, .-undef_instr_handler
151
 
152
.type prefetch_abort_handler, %function
153
prefetch_abort_handler:
43 theseven 154
	mov	r0, #0
155
	adr	r1, prefetch_abort_text
156
	sub	r2, lr, #4
2 theseven 157
	b	panicf
158
.size prefetch_abort_handler, .-prefetch_abort_handler
159
 
160
.type data_abort_handler, %function
161
data_abort_handler:
43 theseven 162
	mov	r0, #0
163
	adr	r1, data_abort_text
164
	sub	r2, lr, #4
2 theseven 165
	b	panicf
166
.size data_abort_handler, .-data_abort_handler
167
 
168
.type reserved_handler, %function
169
reserved_handler:
43 theseven 170
	mov	r0, #0
171
	adr	r1, reserved_text
2 theseven 172
	b	panic
173
.size reserved_handler, .-reserved_handler
174
 
175
.type fiq_handler, %function
176
fiq_handler:
43 theseven 177
	mov	r0, #2
178
	adr	r1, fiq_text
2 theseven 179
	b	panic
180
.size fiq_handler, .-fiq_handler
181
 
182
undef_instr_text:
183
	.ascii	"Undefined instruction at %08X!\0"
184
 
185
prefetch_abort_text:
186
	.ascii	"Prefetch abort at %08X!\0"
187
 
188
data_abort_text:
189
	.ascii	"Data abort at %08X!\0"
190
 
191
reserved_text:
192
	.ascii	"Hit reserved exception handler!\0"
193
 
194
fiq_text:
195
	.ascii	"Unhandled FIQ!\0"
196
 
197
syscall_text:
198
	.ascii	"Unhandled syscall!\0"
15 theseven 199
 
200
 
201
.section .icode.usec_timer, "ax", %progbits
202
.align 2
203
.global read_5usec_timer
204
.type read_5usec_timer, %function
205
read_5usec_timer:
206
	ldr	r0, val_3c700000
207
	ldr	r1, [r0,#0x80]
208
	ldr	r0, [r0,#0x84]
209
	bx	lr
210
.size read_5usec_timer, .-read_5usec_timer
211
 
212
.global read_usec_timer
213
.type read_usec_timer, %function
214
read_usec_timer:
215
	ldr	r0, val_3c700000
216
	ldr	r1, [r0,#0x80]
217
	ldr	r0, [r0,#0x84]
218
	add	r0, r0, r0,lsl#2
219
	bx	lr
220
.size read_usec_timer, .-read_usec_timer
221
 
222
val_3c700000:
223
	.word	0x3c700000
95 theseven 224
 
225
 
226
.section .text.control_nor_cache, "ax", %progbits
227
.align 2
228
.global control_nor_cache
229
.type control_nor_cache, %function
230
control_nor_cache:
231
	mrc	p15, 0, r3,c1,c0
232
	bic	r1, r3, #1
233
	mcr	p15, 0, r1,c1,c0
234
	mov	r1, #0
235
	mcr	p15, 0, r1,c7,c5
236
cnc_flushcache_loop:
237
	mcr	p15, 0, r1,c7,c14,2
238
	add	r2, r1, #0x10
239
	mcr	p15, 0, r2,c7,c14,2
240
	add	r2, r2, #0x10
241
	mcr	p15, 0, r2,c7,c14,2
242
	add	r2, r2, #0x10
243
	mcr	p15, 0, r2,c7,c14,2
244
	adds	r1, r1, #0x04000000
245
	bne	cnc_flushcache_loop
246
	mcr	p15, 0, r1,c7,c10,4
247
	ands	r0, r0, r0
248
	mrc	p15, 0, r1,c2,c0, 1
249
	biceq	r1, r1, #0x10
250
	orrne	r1, r1, #0x10
251
	mcr	p15, 0, r1,c2,c0, 1
252
	mrc	p15, 0, r1,c2,c0, 0
253
	biceq	r1, r1, #0x10
254
	orrne	r1, r1, #0x10
255
	mcr	p15, 0, r1,c2,c0, 0
256
	mrc	p15, 0, r1,c3,c0, 0
257
	biceq	r1, r1, #0x10
258
	orrne	r1, r1, #0x10
259
	mcr	p15, 0, r1,c3,c0, 0
260
	mcr	p15, 0, r3,c1,c0
261
	mov	pc, lr
262
.size control_nor_cache, .-control_nor_cache