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