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