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