Home | History | Annotate | Line # | Download | only in bootxx
bootxx.S revision 1.1
      1 /*	$NetBSD: bootxx.S,v 1.1 2006/09/01 21:26:19 uwe Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 2005 NONAKA Kimihiro
      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 #include <machine/asm.h>
     30 #include <sys/bootblock.h>
     31 
     32 ENTRY(bootxx_start)
     33 	bra	bootxx_start1
     34 	 nop
     35 	.balign 4
     36 ENTRY(bootxx_magic)
     37 	.long	LANDISK_BOOT_MAGIC_1
     38 boot_params:
     39 	.long	1f - boot_params
     40 #include <boot_params.S>
     41 
     42 	. = bootxx_start + 0x80
     43 bootxx_start1:
     44 	mov.l	.L._end, r0		/* zero bss */
     45 	mov.l	.L.__bss_start, r1
     46 	sub	r1, r0
     47 	shlr2	r0			/* _end and __bss_start are aligned */
     48 	mov	#0, r2
     49 1:	mov.l	r2, @r1
     50 	dt	r0
     51 	bf/s	1b
     52 	 add	#4, r1
     53 
     54 	mov.l	.L.2nd_loadaddr, r15	/* new stack pointer */
     55 	mov.l	r4, @-r15
     56 	mov.l	.L.boot1, r0
     57 	jsr	@r0
     58 	 mov	r15, r4
     59 
     60 	tst	r0, r0
     61 	bf/s	boot_fail
     62 	 mov.l	@r15+, r5		/* pass boot sector to boot */
     63 
     64 	/* flush cache */
     65 	mov	#0, r4
     66 	mov	#6, r0
     67 	trapa	#0x3f
     68 
     69 	mov.l	.L.2nd_loadaddr, r0
     70 	mov.l	.L.boot_params, r4
     71 	jmp	@r0
     72 	 nop
     73 
     74 boot_fail:
     75 	mov	r0, r1
     76 	mova	.L.errtxt, r0
     77 	mov	r0, r4
     78 	mov	#32, r0
     79 	trapa	#0x3f
     80 	mov	r1, r4
     81 	mov	#32, r0
     82 	trapa	#0x3f
     83 	mova	.L.crlf, r0
     84 	mov	r0, r4
     85 	mov	#32, r0
     86 	trapa	#0x3f
     87 99:	bra	99b
     88 	 nop
     89 
     90 
     91 	.align	2
     92 .L._end:
     93 	.long	_end
     94 .L.__bss_start:
     95 	.long	__bss_start
     96 .L.boot1:
     97 	.long	_C_LABEL(boot1)
     98 .L.2nd_loadaddr:
     99 	.long	SECONDARY_LOAD_ADDRESS
    100 .L.boot_params:
    101 	.long	boot_params
    102 
    103 	.align	2
    104 .L.errtxt:	.asciz	"Error: "
    105 	.align	2
    106 .L.crlf:	.asciz	"\r\n"
    107 
    108 
    109 	/*
    110 	 * Vector the fs calls through here so we can support multiple
    111 	 * file system types with one copy of the library code and
    112 	 * multiple copies of this file.
    113 	 */
    114 ENTRY(xxfs_open)
    115 	mov.l	1f, r0
    116 	jmp	@r0
    117 	 nop
    118 	.align	2
    119 1:	.long	_C_LABEL(XXfs_open)
    120 
    121 ENTRY(xxfs_close)
    122 	mov.l	1f, r0
    123 	jmp	@r0
    124 	 nop
    125 	.align	2
    126 1:	.long	_C_LABEL(XXfs_close)
    127 
    128 ENTRY(xxfs_read)
    129 	mov.l	1f, r0
    130 	jmp	@r0
    131 	 nop
    132 	.align	2
    133 1:	.long	_C_LABEL(XXfs_read)
    134 
    135 ENTRY(xxfs_stat)
    136 	mov.l	1f, r0
    137 	jmp	@r0
    138 	 nop
    139 	.align	2
    140 1:	.long	_C_LABEL(XXfs_stat)
    141 
    142 
    143 
    144 /*
    145  * int readsects(int dev, uint32_t lba, void *buf, size_t size);
    146  */
    147 ENTRY(readsects)
    148 	mov	#2, r0
    149 	trapa	#0x3f
    150 	rts
    151 	 nop
    152 argerror:
    153 	rts
    154 	 mov	#-1, r0
    155 
    156 /*
    157  * void putstr(const char *str);
    158  */
    159 ENTRY(putstr)
    160 	mov	#32, r0
    161 	trapa	#0x3f
    162 	rts
    163 	 nop
    164