romboot.S revision 1.2 1 /* $NetBSD: romboot.S,v 1.2 2002/01/03 11:22:17 shin Exp $ */
2
3 /*-
4 * Copyright (c) 2001 Takao Shinohara.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29 /*
30 * simple boot loader for ROM
31 *
32 * supported platform: LASER5 L-Router(L-Board)
33 */
34
35 #define zero $0
36 #define AT $at
37 #define v0 $2
38 #define v1 $3
39 #define a0 $4
40 #define a1 $5
41 #define a2 $6
42 #define a3 $7
43 #define t0 $8
44 #define t1 $9
45 #define t2 $10
46 #define t3 $11
47 #define t4 $12
48 #define t5 $13
49 #define t6 $14
50 #define t7 $15
51 #define s0 $16
52 #define s1 $17
53 #define s2 $18
54 #define s3 $19
55 #define s4 $20
56 #define s5 $21
57 #define s6 $22
58 #define s7 $23
59 #define t8 $24
60 #define t9 $25
61 #define k0 $26
62 #define k1 $27
63 #define gp $28
64 #define sp $29
65 #define s8 $30
66 #define ra $31
67
68 #define MIPS_KSEG1_START 0xa0000000
69 #define KERNEL_LOADADDR 0x80030000
70
71 .text
72 .set noreorder
73 .globl _start
74 _start:
75 bal 1f # ra = ROM address + 8
76 nop
77 1: subu a0, ra, 8 # a0 = ROM address
78 move s0, a0 # keep it in s0
79 la t0, _etext
80 la t1, _ftext
81 subu t0, t1 # t0 = size of boot loader
82 addu a0, t0 # a0 = kernel address in ROM
83 li a1, KERNEL_LOADADDR
84 li t2, (1024*1024*3) # max kernel size = 3MB - boot
85 subu t2, t0
86 addu t2, a1 # kernel end address
87 or a1, MIPS_KSEG1_START # convert to kseg1 addr
88 or t2, MIPS_KSEG1_START # convert to kseg1 addr
89 2:
90 lw v0, 0(a0)
91 sw v0, 0(a1)
92 addu a0, 4
93 bltu a1, t2, 2b
94 addu a1, 4 # BDSLOT
95
96 li a0, 1 # argc = 1
97 addu a1, sp, -16 # argv
98 la t0, argv0
99 addu t0, s0
100 sw t0, 0(a1) # argv[0] = "netbsd"
101 sw zero, 4(a1) # argv[1] = NULL
102 la a2, bootinfo
103 addu a2, s0
104 move a3, zero
105 li t9, KERNEL_LOADADDR
106 jr t9
107 nop
108
109 argv0: .asciiz "netbsd"
110
111 bootinfo:
112 .word 34 # len
113 .word 0x13536135 # magic
114 .word 0 # fb_addr
115 .word 0, 0 # fb_line_bytes, fb_width, fb_height, fb_type
116 .word 2 # BI_CNUSE_SERIAL
117 .word 0x04104500 # VR4122
118 .word 0x03810200 # LASER5 L-BOARD
119 /*
120 * kernel binary image begins here.
121 */
122