Subversion Repositories freemyipod

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
273 theseven 1
@
2
@
3
@    Copyright 2010 TheSeven
4
@
5
@
427 farthen 6
@    This file is part of emCORE.
273 theseven 7
@
427 farthen 8
@    emCORE is free software: you can redistribute it and/or
273 theseven 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
@
427 farthen 13
@    emCORE is distributed in the hope that it will be useful,
273 theseven 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
427 farthen 19
@    along with emCORE.  If not, see <http://www.gnu.org/licenses/>.
273 theseven 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 .inithead,"ax",%progbits
37
.global __start
38
__start:
39
	b	_start
40
 
41
.section .initcode,"ax",%progbits
42
.global _start
43
_start:
44
	mrc	p15, 0, r0,c1,c0
312 theseven 45
	orr	r0, r0, #5
273 theseven 46
	mcr	p15, 0, r0,c1,c0
47
	ldr	r0, =_sramsource
48
	ldr	r1, =_sramstart
49
	ldr	r2, =_sramend
50
.copysram:
51
	cmp	r2, r1
52
	ldrhi	r3, [r0], #4
53
	strhi	r3, [r1], #4
54
	bhi	.copysram
55
	ldr	r0, =_sdramsource
56
	ldr	r1, =_sdramstart
57
	ldr	r2, =_sdramend
58
.copysdram:
59
	cmp	r2, r1
60
	ldrhi	r3, [r0], #4
61
	strhi	r3, [r1], #4
62
	bhi	.copysdram
63
	ldr	r0, =_ibssstart
64
	ldr	r1, =_ibssend
65
.clearibss:
66
	cmp	r1, r0
67
	strhi	r2, [r0], #4
68
	bhi	.clearibss
69
	ldr	r0, =_bssstart
70
	ldr	r1, =_bssend
71
.clearbss:
72
	cmp	r1, r0
73
	strhi	r2, [r0], #4
74
	bhi	.clearbss
75
	ldr	r1, =0x38200000
76
	ldr	r0, [r1]
77
	orr	r0, r0, #1
78
	bic	r0, r0, #0x10000
79
	str	r0, [r1]
80
.cleancache:
81
	mrc	p15, 0, r15,c7,c10,3
82
	bne	.cleancache
83
	mov	r0, #0
84
	mcr	p15, 0, r0,c7,c10,4
85
	mcr	p15, 0, r0,c7,c5,0
86
	ldr	r1, =0x38200000
87
	ldr	r0, [r1]
88
	orr	r0, r0, #1
89
	bic	r0, r0, #0x10000
90
	str	r0, [r1]
91
	mov	r0, #0
92
	mcr	p15, 0, r0,c7,c5,0
93
	add	r1, r1, #0x00c00000
94
	add	r2, r1, #0x00001000
95
	add	r3, r1, #0x00002000
96
	sub	r4, r0, #1
97
	str	r4, [r1,#0x14]
98
	str	r4, [r2,#0x14]
99
	str	r4, [r1,#0xf00]
100
	str	r4, [r2,#0xf00]
101
	str	r4, [r3,#0x08]
102
	str	r4, [r3,#0x0c]
103
	str	r0, [r1,#0x14]
104
	str	r0, [r2,#0x14]
105
	msr	cpsr_c, #0xd2
106
	ldr	sp, =_irqstackend
107
	msr	cpsr_c, #0xd7
108
	ldr	sp, =_abortstackend
109
	msr	cpsr_c, #0xdb
110
	ldr	sp, =_abortstackend
111
	msr	cpsr_c, #0x1f
436 theseven 112
	ldr	sp, =_abortstackend
273 theseven 113
	bl	init
114
	bl	context_switch
115
	mov	r0, #0
116
	ldr	pc, =idleloop
117
.ltorg
118
 
119
 
120
.section .icode, "ax", %progbits
121
.align 2
122
idleloop:
123
	mcr	p15, 0, r0,c7,c0,4
124
	b	idleloop
125
 
126
.global reset
127
.global hang
128
.type reset, %function
129
.type hang, %function
130
reset:
131
	msr	cpsr_c, #0xd3
132
	mov	r0, #0x100000
133
	mov	r1, #0x3c800000
134
	str	r0, [r1]
135
hang:
136
	msr	cpsr_c, #0xd3
283 theseven 137
	mov	r0, #0
273 theseven 138
	mcr	p15, 0, r0,c7,c0,4
139
	b	hang
140
.size reset, .-reset
141
.size hang, .-hang
142
 
143
.type reset_handler, %function
144
reset_handler:
145
	mov	r0, #0
146
	adr	r1, reset_text
147
	b	panic
148
reset_text:
149
	.ascii	"Hit reset vector!\0"
150
.size reset_handler, .-reset_handler
151
 
152
.type undef_instr_handler, %function
153
undef_instr_handler:
154
	mov	r0, #0
155
	adr	r1, undef_instr_text
156
	sub	r2, lr, #4
157
	b	panicf
158
.size undef_instr_handler, .-undef_instr_handler
159
 
160
.type prefetch_abort_handler, %function
161
prefetch_abort_handler:
162
	mov	r0, #0
163
	adr	r1, prefetch_abort_text
164
	sub	r2, lr, #4
165
	b	panicf
166
.size prefetch_abort_handler, .-prefetch_abort_handler
167
 
168
.type data_abort_handler, %function
169
data_abort_handler:
170
	mov	r0, #0
171
	adr	r1, data_abort_text
172
	sub	r2, lr, #4
173
	b	panicf
174
.size data_abort_handler, .-data_abort_handler
175
 
176
.type reserved_handler, %function
177
reserved_handler:
178
	mov	r0, #0
179
	adr	r1, reserved_text
180
	b	panic
181
.size reserved_handler, .-reserved_handler
182
 
183
.type fiq_handler, %function
184
fiq_handler:
185
	mov	r0, #2
186
	adr	r1, fiq_text
187
	b	panic
188
.size fiq_handler, .-fiq_handler
189
 
190
undef_instr_text:
191
	.ascii	"Undefined instruction at %08X!\0"
192
 
193
prefetch_abort_text:
194
	.ascii	"Prefetch abort at %08X!\0"
195
 
196
data_abort_text:
197
	.ascii	"Data abort at %08X!\0"
198
 
199
reserved_text:
200
	.ascii	"Hit reserved exception handler!\0"
201
 
202
fiq_text:
203
	.ascii	"Unhandled FIQ!\0"
204
 
205
syscall_text:
206
	.ascii	"Unhandled syscall!\0"
207
 
208
 
209
.section .icode.usec_timer, "ax", %progbits
210
.align 2
211
.global read_native_timer
212
.type read_native_timer, %function
213
read_native_timer:
214
	ldr	r0, val_3c700000
215
	ldr	r1, [r0,#0xb4]
216
	mov	r0, #0
217
	bx	lr
218
.size read_native_timer, .-read_native_timer
219
 
220
.global read_usec_timer
221
.type read_usec_timer, %function
222
read_usec_timer:
223
	ldr	r0, val_3c700000
224
	ldr	r0, [r0,#0xb4]
225
	bx	lr
226
.size read_usec_timer, .-read_usec_timer
227
 
228
val_3c700000:
229
	.word	0x3c700000