Project

General

Profile

Statistics
| Branch: | Revision:

scoutos / prex-0.9.0 / bsp / boot / arm / gba / head.S @ 03e9c04a

History | View | Annotate | Download (4.1 KB)

1 03e9c04a Brad Neuman
/*-
2
 * Copyright (c) 2005, Kohsuke Ohtani
3
 * All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer in the
12
 *    documentation and/or other materials provided with the distribution.
13
 * 3. Neither the name of the author nor the names of any co-contributors
14
 *    may be used to endorse or promote products derived from this software
15
 *    without specific prior written permission.
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27
 * SUCH DAMAGE.
28
 */
29
30
/*
31
 * head.S - low level platform support
32
 *
33
 * This file contains the code from crt0.S which is released under
34
 * public domain by Jeff Frohwein.
35
 */
36
37
/*-
38
 * Memory usage:
39
 *
40
 * 0x02000000 - 0x0203ffff : EWRAM (256K)
41
 * 0x03000000 - 0x03007fff : IWRAM (32K)
42
 * 0x04000000 - 0x040003ff : I/O Register (1K)
43
 * 0x05000000 - 0x050003ff : Palette RAM (1K)
44
 * 0x06000000 - 0x06017fff : VRAM (96K)
45
 *
46
 * Note:
47
 * 0x03007f00 - 0x03007fff is reserved by GBA BIOS.
48
 */
49
50
#include <conf/config.h>
51
#include <machine/memory.h>
52
#include <machine/syspage.h>
53
54
#define ENTRY(x) .global x; .align; x##:
55
56
	.section ".text","ax"
57
	.code 32
58
/*
59
 * Loader start point
60
 */
61
ENTRY(boot_entry)
62
	b	rom_header_end
63
64
	/*
65
	 * GBA ROM header
66
	 */
67
68
	/* Nintendo Logo Character Data (8000004h) */
69
	.fill	156,1,0
70
71
	/* Game Title (80000A0h) */
72
	.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
73
	.byte	0x00,0x00,0x00,0x00
74
75
	/* Game Code (80000ACh) */
76
	.byte	0x00,0x00,0x00,0x00
77
78
	/* Maker Code (80000B0h) */
79
	.byte	0x30,0x31
80
81
	/* Fixed Value (80000B2h) */
82
	.byte	0x96
83
84
	/* Main Unit Code (80000B3h) */
85
	.byte	0x00
86
87
	/* Device Type (80000B4h) */
88
	.byte	0x00
89
90
	/* Unused Data (7Byte) (80000B5h) */
91
	.byte	0x00,0x00,0x00,0x00,0x00,0x00,0x00
92
93
	/* Software Version No (80000BCh) */
94
	.byte	0x00
95
96
	/* Complement Check (80000BDh) */
97
	.byte	0xf0
98
99
	/* Checksum (80000BEh) */
100
	.byte	0x00,0x00
101
102
	.align
103
	.code 32
104
105
rom_header_end:
106
	b	start_vector
107
108
	.global __boot_method, __slave_number
109
110
__boot_method:
111
	.byte	0	/* boot method (0=ROM boot, 3=Multiplay boot) */
112
__slave_number:
113
	.byte	0	/* slave # (1=slave#1, 2=slave#2, 3=slave#3) */
114
115
	.byte	0
116
	.byte	0
117
	.word	0
118
	.word	0
119
	.word	0
120
	.word	0
121
	.word	0
122
	.word	0
123
124
	.align
125
	.code 32
126
stack_top:	.word	(BOOTSTKTOP - KERNBASE)
127
128
start_vector:
129
	mov	r0, #0xd3		/* Enter SVC mode, Disable IRQ,FIQ */
130
	msr	cpsr_c, r0
131
	ldr	sp, stack_top
132
133
	adr	r0, thumb_mode + 1
134
	bx	r0
135
	.code 16
136
thumb_mode:
137
138
/*
139
 * Relocate the loader code
140
 */
141
	mov	r3, #0x40
142
	lsl	r3, r3, #7  /* r3 = 0x2000 (8K) */
143
	mov	r2, #3
144
	lsl	r2, r2, #24 /* r2 = 0x3000000 */
145
	lsl	r1, r3, #14 /* r1 = 0x8000000 */
146
147
copy_loop:
148
	ldmia	r1!, {r0}
149
	stmia	r2!, {r0}
150
	sub	r3, r3, #4
151
	bne	copy_loop
152
153
	ldr	r0, =main
154
	bx	r0		/* Change to ARM mode */
155
156
	.code 32
157
158
#if defined(DEBUG) && defined(CONFIG_DIAG_VBA)
159
/*
160
 * Put one character to Visual Boy Advance (VBA) emulator console.
161
 *
162
 * Important:
163
 * This BIOS call is not supported by actual GBA BIOS. So, you must
164
 * disable this function when you run it on actual GBA H/W.
165
 * Otherwise, it will hang.
166
 */
167
putbuf:
168
	.long	0
169
170
ENTRY(vba_putc)
171
	ldr	r1, =putbuf
172
	str	r0, [r1]
173
	mov	r0, r1
174
	swi	$0xff0000
175
	mov	pc, lr
176
#endif
177
178
	.section .tail,"ax"
179
dummy:
180
	.byte	0xff
181
182
.end