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
115
idleloop:
116
	mcr	p15, 0, r0,c7,c0,4
117
	b	idleloop
10 theseven 118
.ltorg
119
 
120
 
121
.section .icode, "ax", %progbits
122
.align 2
123
.global reset
124
.global hang
125
.type reset, %function
126
.type hang, %function
127
reset:
128
	msr	cpsr_c, #0xd3
129
	mov	r0, #0x100000
130
	mov	r1, #0x3c800000
131
	str	r0, [r1]
132
hang:
85 theseven 133
	msr	cpsr_c, #0xd3
134
	mcr	p15, 0, r0,c7,c0,4
10 theseven 135
	b	hang
136
.size reset, .-reset
137
.size hang, .-hang
138
 
139
.type reset_handler, %function
140
reset_handler:
85 theseven 141
	mov	r0, #0
142
	adr	r1, reset_text
10 theseven 143
	b	panic
144
reset_text:
145
	.ascii	"Hit reset vector!\0"
146
.size reset_handler, .-reset_handler
147
 
148
.type undef_instr_handler, %function
149
undef_instr_handler:
85 theseven 150
	mov	r0, #0
151
	adr	r1, undef_instr_text
152
	sub	r2, lr, #4
10 theseven 153
	b	panicf
154
.size undef_instr_handler, .-undef_instr_handler
155
 
156
.type prefetch_abort_handler, %function
157
prefetch_abort_handler:
85 theseven 158
	mov	r0, #0
159
	adr	r1, prefetch_abort_text
160
	sub	r2, lr, #4
10 theseven 161
	b	panicf
162
.size prefetch_abort_handler, .-prefetch_abort_handler
163
 
164
.type data_abort_handler, %function
165
data_abort_handler:
85 theseven 166
	mov	r0, #0
167
	adr	r1, data_abort_text
168
	sub	r2, lr, #4
10 theseven 169
	b	panicf
170
.size data_abort_handler, .-data_abort_handler
171
 
172
.type reserved_handler, %function
173
reserved_handler:
85 theseven 174
	mov	r0, #0
175
	adr	r1, reserved_text
10 theseven 176
	b	panic
177
.size reserved_handler, .-reserved_handler
178
 
179
.type fiq_handler, %function
180
fiq_handler:
85 theseven 181
	mov	r0, #2
182
	adr	r1, fiq_text
10 theseven 183
	b	panic
184
.size fiq_handler, .-fiq_handler
185
 
186
undef_instr_text:
187
	.ascii	"Undefined instruction at %08X!\0"
188
 
189
prefetch_abort_text:
190
	.ascii	"Prefetch abort at %08X!\0"
191
 
192
data_abort_text:
193
	.ascii	"Data abort at %08X!\0"
194
 
195
reserved_text:
196
	.ascii	"Hit reserved exception handler!\0"
197
 
198
fiq_text:
199
	.ascii	"Unhandled FIQ!\0"
200
 
201
syscall_text:
202
	.ascii	"Unhandled syscall!\0"
85 theseven 203
 
204
 
205
.section .icode.usec_timer, "ax", %progbits
206
.align 2
207
.global read_42nsec_timer
208
.type read_42nsec_timer, %function
209
read_42nsec_timer:
210
	ldr	r0, val_3c700000
211
	ldr	r1, [r0,#0x80]
212
	ldr	r0, [r0,#0x84]
213
	bx	lr
214
.size read_42nsec_timer, .-read_42nsec_timer
215
 
216
.global read_usec_timer
217
.type read_usec_timer, %function
218
read_usec_timer:
219
	ldr	r0, val_3c700000
220
	ldr	r1, [r0,#0x80]
221
	ldr	r0, [r0,#0x84]
222
	mov	r0, r0,lsr#5
223
	orr	r0, r0, r1,lsl#27
224
	add	r0, r0, r0,asr#2
225
	add	r0, r0, r0,asr#6
226
	bx	lr
227
.size read_usec_timer, .-read_usec_timer
228
 
229
val_3c700000:
230
	.word	0x3c700000