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