simple boot loader for ROM
supported platform: LASER5 L-Router(L-Board)
This commit is contained in:
parent
490f777a1f
commit
896f0cde82
19
sys/arch/hpcmips/stand/romboot/Makefile
Normal file
19
sys/arch/hpcmips/stand/romboot/Makefile
Normal file
@ -0,0 +1,19 @@
|
||||
# $NetBSD: Makefile,v 1.1 2001/12/23 13:27:56 shin Exp $
|
||||
|
||||
CC?= ${CROSSDIR}cc
|
||||
AS?= ${CROSSDIR}as
|
||||
LD?= ${CROSSDIR}ld
|
||||
OBJCOPY?= ${CROSSDIR}objcopy
|
||||
|
||||
AFLAGS+= -x assembler-with-cpp -traditional-cpp
|
||||
|
||||
all: romboot.bin
|
||||
|
||||
clean:
|
||||
rm -f romboot.bin romboot romboot.o
|
||||
|
||||
romboot: romboot.o
|
||||
$(LD) -o $@ -N -T romboot.ldscript -Ttext 0 -e _start $?
|
||||
|
||||
romboot.bin: romboot
|
||||
$(OBJCOPY) --remove-section=.reginfo -O binary $? $@
|
121
sys/arch/hpcmips/stand/romboot/romboot.S
Normal file
121
sys/arch/hpcmips/stand/romboot/romboot.S
Normal file
@ -0,0 +1,121 @@
|
||||
/* $NetBSD* */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 Takao Shinohara.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* simple boot loader for ROM
|
||||
*
|
||||
* supported platform: LASER5 L-Router(L-Board)
|
||||
*/
|
||||
|
||||
#define zero $0
|
||||
#define AT $at
|
||||
#define v0 $2
|
||||
#define v1 $3
|
||||
#define a0 $4
|
||||
#define a1 $5
|
||||
#define a2 $6
|
||||
#define a3 $7
|
||||
#define t0 $8
|
||||
#define t1 $9
|
||||
#define t2 $10
|
||||
#define t3 $11
|
||||
#define t4 $12
|
||||
#define t5 $13
|
||||
#define t6 $14
|
||||
#define t7 $15
|
||||
#define s0 $16
|
||||
#define s1 $17
|
||||
#define s2 $18
|
||||
#define s3 $19
|
||||
#define s4 $20
|
||||
#define s5 $21
|
||||
#define s6 $22
|
||||
#define s7 $23
|
||||
#define t8 $24
|
||||
#define t9 $25
|
||||
#define k0 $26
|
||||
#define k1 $27
|
||||
#define gp $28
|
||||
#define sp $29
|
||||
#define s8 $30
|
||||
#define ra $31
|
||||
|
||||
#define MIPS_KSEG1_START 0xa0000000
|
||||
#define KERNEL_LOADADDR 0x80030000
|
||||
|
||||
.text
|
||||
.set noreorder
|
||||
.globl _start
|
||||
_start:
|
||||
bal 1f # ra = ROM address + 8
|
||||
nop
|
||||
1: subu a0, ra, 8 # a0 = ROM address
|
||||
move s0, a0 # keep it in s0
|
||||
la t0, _etext
|
||||
la t1, _ftext
|
||||
subu t0, t1 # t0 = size of boot loader
|
||||
addu a0, t0 # a0 = kernel address in ROM
|
||||
li a1, KERNEL_LOADADDR
|
||||
li t2, (1024*1024*3) # max kernel size = 3MB - boot
|
||||
subu t2, t0
|
||||
addu t2, a1 # kernel end address
|
||||
or a1, MIPS_KSEG1_START # convert to kseg1 addr
|
||||
or t2, MIPS_KSEG1_START # convert to kseg1 addr
|
||||
2:
|
||||
lw v0, 0(a0)
|
||||
sw v0, 0(a1)
|
||||
addu a0, 4
|
||||
bltu a1, t2, 2b
|
||||
addu a1, 4 # BDSLOT
|
||||
|
||||
li a0, 1 # argc = 1
|
||||
addu a1, sp, -16 # argv
|
||||
la t0, argv0
|
||||
addu t0, s0
|
||||
sw t0, 0(a1) # argv[0] = "netbsd"
|
||||
sw zero, 4(a1) # argv[1] = NULL
|
||||
la a2, bootinfo
|
||||
addu a2, s0
|
||||
move a3, zero
|
||||
li t9, KERNEL_LOADADDR
|
||||
jr t9
|
||||
nop
|
||||
|
||||
argv0: .asciiz "netbsd"
|
||||
|
||||
bootinfo:
|
||||
.word 34 # len
|
||||
.word 0x13536135 # magic
|
||||
.word 0 # fb_addr
|
||||
.word 0, 0 # fb_line_bytes, fb_width, fb_height, fb_type
|
||||
.word 2 # BI_CNUSE_SERIAL
|
||||
.word 0x04104500 # VR4122
|
||||
.word 0x03810200 # LASER5 L-BOARD
|
||||
/*
|
||||
* kernel binary image begins here.
|
||||
*/
|
11
sys/arch/hpcmips/stand/romboot/romboot.ldscript
Normal file
11
sys/arch/hpcmips/stand/romboot/romboot.ldscript
Normal file
@ -0,0 +1,11 @@
|
||||
OUTPUT_ARCH(mips)
|
||||
ENTRY(_start)
|
||||
SECTIONS
|
||||
{
|
||||
.text :
|
||||
{
|
||||
_ftext = . ;
|
||||
*(.text)
|
||||
_etext = .;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user