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
437 theseven 65
	mov	r2, #0
273 theseven 66
.clearibss:
67
	cmp	r1, r0
68
	strhi	r2, [r0], #4
69
	bhi	.clearibss
70
	ldr	r0, =_bssstart
71
	ldr	r1, =_bssend
72
.clearbss:
73
	cmp	r1, r0
74
	strhi	r2, [r0], #4
75
	bhi	.clearbss
76
	ldr	r1, =0x38200000
77
	ldr	r0, [r1]
78
	orr	r0, r0, #1
79
	bic	r0, r0, #0x10000
80
	str	r0, [r1]
81
.cleancache:
82
	mrc	p15, 0, r15,c7,c10,3
83
	bne	.cleancache
84
	mov	r0, #0
85
	mcr	p15, 0, r0,c7,c10,4
86
	mcr	p15, 0, r0,c7,c5,0
87
	ldr	r1, =0x38200000
88
	ldr	r0, [r1]
89
	orr	r0, r0, #1
90
	bic	r0, r0, #0x10000
91
	str	r0, [r1]
92
	mov	r0, #0
93
	mcr	p15, 0, r0,c7,c5,0
94
	add	r1, r1, #0x00c00000
95
	add	r2, r1, #0x00001000
96
	add	r3, r1, #0x00002000
97
	sub	r4, r0, #1
98
	str	r4, [r1,#0x14]
99
	str	r4, [r2,#0x14]
100
	str	r4, [r1,#0xf00]
101
	str	r4, [r2,#0xf00]
102
	str	r4, [r3,#0x08]
103
	str	r4, [r3,#0x0c]
104
	str	r0, [r1,#0x14]
105
	str	r0, [r2,#0x14]
106
	msr	cpsr_c, #0xd2
107
	ldr	sp, =_irqstackend
108
	msr	cpsr_c, #0xd7
109
	ldr	sp, =_abortstackend
110
	msr	cpsr_c, #0xdb
111
	ldr	sp, =_abortstackend
112
	msr	cpsr_c, #0x1f
436 theseven 113
	ldr	sp, =_abortstackend
273 theseven 114
	bl	init
115
	bl	context_switch
116
	mov	r0, #0
117
	ldr	pc, =idleloop
118
.ltorg
119
 
120
 
121
.section .icode, "ax", %progbits
122
.align 2
123
idleloop:
124
	mcr	p15, 0, r0,c7,c0,4
125
	b	idleloop
126
 
127
.global reset
128
.global hang
129
.type reset, %function
130
.type hang, %function
131
reset:
132
	msr	cpsr_c, #0xd3
133
	mov	r0, #0x100000
134
	mov	r1, #0x3c800000
135
	str	r0, [r1]
136
hang:
137
	msr	cpsr_c, #0xd3
283 theseven 138
	mov	r0, #0
273 theseven 139
	mcr	p15, 0, r0,c7,c0,4
140
	b	hang
141
.size reset, .-reset
142
.size hang, .-hang
143
 
144
.type reset_handler, %function
145
reset_handler:
146
	mov	r0, #0
147
	adr	r1, reset_text
148
	b	panic
149
reset_text:
150
	.ascii	"Hit reset vector!\0"
151
.size reset_handler, .-reset_handler
152
 
153
.type undef_instr_handler, %function
154
undef_instr_handler:
155
	mov	r0, #0
156
	adr	r1, undef_instr_text
157
	sub	r2, lr, #4
158
	b	panicf
159
.size undef_instr_handler, .-undef_instr_handler
160
 
161
.type prefetch_abort_handler, %function
162
prefetch_abort_handler:
163
	mov	r0, #0
164
	adr	r1, prefetch_abort_text
165
	sub	r2, lr, #4
166
	b	panicf
167
.size prefetch_abort_handler, .-prefetch_abort_handler
168
 
169
.type data_abort_handler, %function
170
data_abort_handler:
171
	mov	r0, #0
172
	adr	r1, data_abort_text
173
	sub	r2, lr, #4
174
	b	panicf
175
.size data_abort_handler, .-data_abort_handler
176
 
177
.type reserved_handler, %function
178
reserved_handler:
179
	mov	r0, #0
180
	adr	r1, reserved_text
181
	b	panic
182
.size reserved_handler, .-reserved_handler
183
 
184
.type fiq_handler, %function
185
fiq_handler:
186
	mov	r0, #2
187
	adr	r1, fiq_text
188
	b	panic
189
.size fiq_handler, .-fiq_handler
190
 
191
undef_instr_text:
192
	.ascii	"Undefined instruction at %08X!\0"
193
 
194
prefetch_abort_text:
195
	.ascii	"Prefetch abort at %08X!\0"
196
 
197
data_abort_text:
198
	.ascii	"Data abort at %08X!\0"
199
 
200
reserved_text:
201
	.ascii	"Hit reserved exception handler!\0"
202
 
203
fiq_text:
204
	.ascii	"Unhandled FIQ!\0"
205
 
206
syscall_text:
207
	.ascii	"Unhandled syscall!\0"
208
 
209
 
210
.section .icode.usec_timer, "ax", %progbits
211
.align 2
212
.global read_native_timer
213
.type read_native_timer, %function
214
read_native_timer:
215
	ldr	r0, val_3c700000
216
	ldr	r1, [r0,#0xb4]
217
	mov	r0, #0
218
	bx	lr
219
.size read_native_timer, .-read_native_timer
220
 
221
.global read_usec_timer
222
.type read_usec_timer, %function
223
read_usec_timer:
224
	ldr	r0, val_3c700000
225
	ldr	r0, [r0,#0xb4]
226
	bx	lr
227
.size read_usec_timer, .-read_usec_timer
228
 
229
val_3c700000:
230
	.word	0x3c700000