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
 
36
.section .initcode,"ax",%progbits
37
.global _start
38
_start:
85 theseven 39
	ldr	r0, =0x00450878
40
	mcr	p15, 0, r0,c1,c0,0
10 theseven 41
	ldr	r0, =_sramsource
42
	ldr	r1, =_sramstart
43
	ldr	r2, =_sramend
44
.copysram:
45
	cmp	r2, r1
46
	ldrhi	r3, [r0], #4
47
	strhi	r3, [r1], #4
48
	bhi	.copysram
49
	ldr	r0, =_sdramsource
50
	ldr	r1, =_sdramstart
51
	ldr	r2, =_sdramend
52
.copysdram:
53
	cmp	r2, r1
54
	ldrhi	r3, [r0], #4
55
	strhi	r3, [r1], #4
56
	bhi	.copysdram
57
	ldr	r0, =_initbssstart
58
	ldr	r1, =_initbssend
59
	mov	r2, #0
60
.clearinitbss:
61
	cmp	r1, r0
62
	strhi	r2, [r0], #4
63
	bhi	.clearinitbss
64
	ldr	r0, =_ibssstart
65
	ldr	r1, =_ibssend
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
	mov	r0, #0
82
	mcr	p15, 0, r0,c7,c5,0
85 theseven 83
	add	r1, r1, #0x00c00000
84
	add	r2, r1, #0x00001000
85
	add	r3, r1, #0x00002000
86
	sub	r4, r0, #1
87
	str	r4, [r1,#0x14]
88
	str	r4, [r2,#0x14]
89
	str	r4, [r1,#0xf00]
90
	str	r4, [r2,#0xf00]
91
	str	r4, [r3,#0x08]
92
	str	r4, [r3,#0x0c]
93
	str	r0, [r1,#0x14]
94
	str	r0, [r2,#0x14]
95
	mov	r0, #0
96
	ldr	r1, =0x3c500000
97
	str	r0, [r1,#0x48]
98
	str	r0, [r1,#0x4c]
10 theseven 99
	msr	cpsr_c, #0xd2
100
	ldr	sp, =_irqstackend
101
	msr	cpsr_c, #0xd7
102
	ldr	sp, =_abortstackend
103
	msr	cpsr_c, #0xdb
104
	ldr	sp, =_abortstackend
85 theseven 105
	msr	cpsr_c, #0x1f
10 theseven 106
	ldr	sp, =_initstackend
107
	bl	init
85 theseven 108
	bl	context_switch
14 theseven 109
	mov	r0, #0
110
idleloop:
111
	mcr	p15, 0, r0,c7,c0,4
112
	b	idleloop
10 theseven 113
.ltorg
114
 
115
 
116
.section .icode, "ax", %progbits
117
.align 2
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
202
.global read_42nsec_timer
203
.type read_42nsec_timer, %function
204
read_42nsec_timer:
205
	ldr	r0, val_3c700000
206
	ldr	r1, [r0,#0x80]
207
	ldr	r0, [r0,#0x84]
208
	bx	lr
209
.size read_42nsec_timer, .-read_42nsec_timer
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