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