romboot.S revision 1.6 1 1.6 shin /* $NetBSD: romboot.S,v 1.6 2002/02/16 05:26:02 shin Exp $ */
2 1.1 shin
3 1.1 shin /*-
4 1.6 shin * Copyright (c) 2001, 2002 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.6 shin #define MIPS_KSEG0_START 0x80000000
69 1.1 shin #define MIPS_KSEG1_START 0xa0000000
70 1.6 shin #define KSEG1_KSEG0_DIFF (MIPS_KSEG1_START - MIPS_KSEG0_START)
71 1.4 uch #define KERNEL_LOADADDR 0x80001000
72 1.6 shin #define MAX_KERNEL_SIZE (1024*1024*6) # 6MB
73 1.6 shin #define MAX_DCACHE_SIZE (1024*32) # 32KB
74 1.1 shin
75 1.1 shin .text
76 1.1 shin .set noreorder
77 1.1 shin .globl _start
78 1.1 shin _start:
79 1.1 shin bal 1f # ra = ROM address + 8
80 1.1 shin nop
81 1.6 shin 1: subu a0, ra, 8 # a0 = ROM address(kseg1)
82 1.6 shin subu a0, KSEG1_KSEG0_DIFF # convert to kseg0 address
83 1.1 shin move s0, a0 # keep it in s0
84 1.1 shin la t0, _etext
85 1.1 shin la t1, _ftext
86 1.1 shin subu t0, t1 # t0 = size of boot loader
87 1.1 shin addu a0, t0 # a0 = kernel address in ROM
88 1.1 shin li a1, KERNEL_LOADADDR
89 1.6 shin li t2, MAX_KERNEL_SIZE # max kernel size = 6MB - boot
90 1.1 shin subu t2, t0
91 1.1 shin addu t2, a1 # kernel end address
92 1.6 shin la t9, 2f
93 1.6 shin addu t9, s0
94 1.6 shin jr t9 # jump to cached address
95 1.6 shin nop
96 1.1 shin 2:
97 1.1 shin lw v0, 0(a0)
98 1.1 shin sw v0, 0(a1)
99 1.1 shin addu a0, 4
100 1.1 shin bltu a1, t2, 2b
101 1.1 shin addu a1, 4 # BDSLOT
102 1.6 shin
103 1.6 shin /* purge data cache */
104 1.6 shin li v0, MAX_DCACHE_SIZE
105 1.6 shin 3: lw zero, 0(a1)
106 1.6 shin addu a1, 4
107 1.6 shin bnez v0, 3b
108 1.6 shin subu v0, 4 # BDSLOT
109 1.1 shin
110 1.5 shin li sp, KERNEL_LOADADDR # initialize stack pointer
111 1.1 shin li a0, 1 # argc = 1
112 1.1 shin addu a1, sp, -16 # argv
113 1.1 shin la t0, argv0
114 1.1 shin addu t0, s0
115 1.1 shin sw t0, 0(a1) # argv[0] = "netbsd"
116 1.1 shin sw zero, 4(a1) # argv[1] = NULL
117 1.1 shin la a2, bootinfo
118 1.1 shin addu a2, s0
119 1.1 shin move a3, zero
120 1.1 shin li t9, KERNEL_LOADADDR
121 1.1 shin jr t9
122 1.1 shin nop
123 1.1 shin
124 1.1 shin argv0: .asciiz "netbsd"
125 1.1 shin
126 1.1 shin bootinfo:
127 1.1 shin .word 34 # len
128 1.1 shin .word 0x13536135 # magic
129 1.1 shin .word 0 # fb_addr
130 1.1 shin .word 0, 0 # fb_line_bytes, fb_width, fb_height, fb_type
131 1.1 shin .word 2 # BI_CNUSE_SERIAL
132 1.1 shin .word 0x04104500 # VR4122
133 1.1 shin .word 0x03810200 # LASER5 L-BOARD
134 1.1 shin /*
135 1.1 shin * kernel binary image begins here.
136 1.1 shin */
137