Subversion Repositories freemyipod

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
10 theseven 1
@
2
@
3
@    Copyright 2010 TheSeven
4
@
5
@
427 farthen 6
@    This file is part of emCORE.
10 theseven 7
@
427 farthen 8
@    emCORE is free software: you can redistribute it and/or
10 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,
10 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/>.
10 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
 
98 theseven 36
.section .inithead,"ax",%progbits
37
.global __start
38
__start:
39
	b	_start
40
 
10 theseven 41
.section .initcode,"ax",%progbits
42
.global _start
43
_start:
85 theseven 44
	ldr	r0, =0x00450878
45
	mcr	p15, 0, r0,c1,c0,0
10 theseven 46
	ldr	r0, =_sramsource
47
	ldr	r1, =_sramstart
48
	ldr	r2, =_sramend
49
.copysram:
50
	cmp	r2, r1
51
	ldrhi	r3, [r0], #4
52
	strhi	r3, [r1], #4
53
	bhi	.copysram
54
	ldr	r0, =_sdramsource
55
	ldr	r1, =_sdramstart
56
	ldr	r2, =_sdramend
57
.copysdram:
58
	cmp	r2, r1
59
	ldrhi	r3, [r0], #4
60
	strhi	r3, [r1], #4
61
	bhi	.copysdram
62
	ldr	r0, =_ibssstart
63
	ldr	r1, =_ibssend
437 theseven 64
	mov	r2, #0
10 theseven 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
	mov	r0, #0
81
	mcr	p15, 0, r0,c7,c5,0
85 theseven 82
	add	r1, r1, #0x00c00000
83
	add	r2, r1, #0x00001000
84
	add	r3, r1, #0x00002000
85
	sub	r4, r0, #1
86
	str	r4, [r1,#0x14]
87
	str	r4, [r2,#0x14]
88
	str	r4, [r1,#0xf00]
89
	str	r4, [r2,#0xf00]
90
	str	r4, [r3,#0x08]
91
	str	r4, [r3,#0x0c]
92
	str	r0, [r1,#0x14]
93
	str	r0, [r2,#0x14]
94
	mov	r0, #0
95
	ldr	r1, =0x3c500000
96
	str	r0, [r1,#0x48]
97
	str	r0, [r1,#0x4c]
10 theseven 98
	msr	cpsr_c, #0xd2
99
	ldr	sp, =_irqstackend
100
	msr	cpsr_c, #0xd7
101
	ldr	sp, =_abortstackend
102
	msr	cpsr_c, #0xdb
103
	ldr	sp, =_abortstackend
85 theseven 104
	msr	cpsr_c, #0x1f
436 theseven 105
	ldr	sp, =_abortstackend
10 theseven 106
	bl	init
593 theseven 107
	bl	yield
14 theseven 108
	mov	r0, #0
99 theseven 109
	ldr	pc, =idleloop
10 theseven 110
.ltorg
111
 
112
 
113
.section .icode, "ax", %progbits
114
.align 2
99 theseven 115
idleloop:
116
	mcr	p15, 0, r0,c7,c0,4
117
	b	idleloop
118
 
10 theseven 119
.global reset
120
.global hang
121
.type reset, %function
122
.type hang, %function
123
reset:
124
	msr	cpsr_c, #0xd3
125
	mov	r0, #0x100000
126
	mov	r1, #0x3c800000
127
	str	r0, [r1]
128
hang:
85 theseven 129
	msr	cpsr_c, #0xd3
130
	mcr	p15, 0, r0,c7,c0,4
10 theseven 131
	b	hang
132
.size reset, .-reset
133
.size hang, .-hang
134
 
135
.type reset_handler, %function
136
reset_handler:
85 theseven 137
	mov	r0, #0
138
	adr	r1, reset_text
10 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:
85 theseven 146
	mov	r0, #0
147
	adr	r1, undef_instr_text
148
	sub	r2, lr, #4
10 theseven 149
	b	panicf
150
.size undef_instr_handler, .-undef_instr_handler
151
 
152
.type prefetch_abort_handler, %function
153
prefetch_abort_handler:
85 theseven 154
	mov	r0, #0
155
	adr	r1, prefetch_abort_text
156
	sub	r2, lr, #4
10 theseven 157
	b	panicf
158
.size prefetch_abort_handler, .-prefetch_abort_handler
159
 
160
.type data_abort_handler, %function
161
data_abort_handler:
85 theseven 162
	mov	r0, #0
163
	adr	r1, data_abort_text
164
	sub	r2, lr, #4
10 theseven 165
	b	panicf
166
.size data_abort_handler, .-data_abort_handler
167
 
168
.type reserved_handler, %function
169
reserved_handler:
85 theseven 170
	mov	r0, #0
171
	adr	r1, reserved_text
10 theseven 172
	b	panic
173
.size reserved_handler, .-reserved_handler
174
 
175
.type fiq_handler, %function
176
fiq_handler:
85 theseven 177
	mov	r0, #2
178
	adr	r1, fiq_text
10 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"
85 theseven 199
 
200
 
201
.section .icode.usec_timer, "ax", %progbits
202
.align 2
111 theseven 203
.global read_native_timer
204
.type read_native_timer, %function
205
read_native_timer:
85 theseven 206
	ldr	r0, val_3c700000
207
	ldr	r1, [r0,#0x80]
208
	ldr	r0, [r0,#0x84]
209
	bx	lr
111 theseven 210
.size read_native_timer, .-read_native_timer
85 theseven 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
	mov	r0, r0,lsr#5
219
	orr	r0, r0, r1,lsl#27
220
	add	r0, r0, r0,asr#2
221
	add	r0, r0, r0,asr#6
222
	bx	lr
223
.size read_usec_timer, .-read_usec_timer
224
 
225
val_3c700000:
226
	.word	0x3c700000