Home | History | Annotate | Line # | Download | only in bootxx
      1  1.2  nonaka /*	$NetBSD: bootxx.S,v 1.2 2012/01/21 19:44:30 nonaka Exp $	*/
      2  1.1     uwe 
      3  1.1     uwe /*-
      4  1.2  nonaka  * Copyright (C) 2005 NONAKA Kimihiro <nonaka (at) netbsd.org>
      5  1.1     uwe  * All rights reserved.
      6  1.1     uwe  *
      7  1.1     uwe  * Redistribution and use in source and binary forms, with or without
      8  1.1     uwe  * modification, are permitted provided that the following conditions
      9  1.1     uwe  * are met:
     10  1.1     uwe  * 1. Redistributions of source code must retain the above copyright
     11  1.1     uwe  *    notice, this list of conditions and the following disclaimer.
     12  1.1     uwe  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.1     uwe  *    notice, this list of conditions and the following disclaimer in the
     14  1.1     uwe  *    documentation and/or other materials provided with the distribution.
     15  1.1     uwe  *
     16  1.2  nonaka  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     17  1.2  nonaka  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     18  1.2  nonaka  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     19  1.2  nonaka  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     20  1.2  nonaka  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     21  1.2  nonaka  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     22  1.2  nonaka  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     23  1.2  nonaka  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     24  1.2  nonaka  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     25  1.2  nonaka  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     26  1.1     uwe  */
     27  1.1     uwe 
     28  1.1     uwe #include <machine/asm.h>
     29  1.1     uwe #include <sys/bootblock.h>
     30  1.1     uwe 
     31  1.1     uwe ENTRY(bootxx_start)
     32  1.1     uwe 	bra	bootxx_start1
     33  1.1     uwe 	 nop
     34  1.1     uwe 	.balign 4
     35  1.1     uwe ENTRY(bootxx_magic)
     36  1.1     uwe 	.long	LANDISK_BOOT_MAGIC_1
     37  1.1     uwe boot_params:
     38  1.1     uwe 	.long	1f - boot_params
     39  1.1     uwe #include <boot_params.S>
     40  1.1     uwe 
     41  1.1     uwe 	. = bootxx_start + 0x80
     42  1.1     uwe bootxx_start1:
     43  1.1     uwe 	mov.l	.L._end, r0		/* zero bss */
     44  1.1     uwe 	mov.l	.L.__bss_start, r1
     45  1.1     uwe 	sub	r1, r0
     46  1.1     uwe 	shlr2	r0			/* _end and __bss_start are aligned */
     47  1.1     uwe 	mov	#0, r2
     48  1.1     uwe 1:	mov.l	r2, @r1
     49  1.1     uwe 	dt	r0
     50  1.1     uwe 	bf/s	1b
     51  1.1     uwe 	 add	#4, r1
     52  1.1     uwe 
     53  1.1     uwe 	mov.l	.L.2nd_loadaddr, r15	/* new stack pointer */
     54  1.1     uwe 	mov.l	r4, @-r15
     55  1.1     uwe 	mov.l	.L.boot1, r0
     56  1.1     uwe 	jsr	@r0
     57  1.1     uwe 	 mov	r15, r4
     58  1.1     uwe 
     59  1.1     uwe 	tst	r0, r0
     60  1.1     uwe 	bf/s	boot_fail
     61  1.1     uwe 	 mov.l	@r15+, r5		/* pass boot sector to boot */
     62  1.1     uwe 
     63  1.1     uwe 	/* flush cache */
     64  1.1     uwe 	mov	#0, r4
     65  1.1     uwe 	mov	#6, r0
     66  1.1     uwe 	trapa	#0x3f
     67  1.1     uwe 
     68  1.1     uwe 	mov.l	.L.2nd_loadaddr, r0
     69  1.1     uwe 	mov.l	.L.boot_params, r4
     70  1.1     uwe 	jmp	@r0
     71  1.1     uwe 	 nop
     72  1.1     uwe 
     73  1.1     uwe boot_fail:
     74  1.1     uwe 	mov	r0, r1
     75  1.1     uwe 	mova	.L.errtxt, r0
     76  1.1     uwe 	mov	r0, r4
     77  1.1     uwe 	mov	#32, r0
     78  1.1     uwe 	trapa	#0x3f
     79  1.1     uwe 	mov	r1, r4
     80  1.1     uwe 	mov	#32, r0
     81  1.1     uwe 	trapa	#0x3f
     82  1.1     uwe 	mova	.L.crlf, r0
     83  1.1     uwe 	mov	r0, r4
     84  1.1     uwe 	mov	#32, r0
     85  1.1     uwe 	trapa	#0x3f
     86  1.1     uwe 99:	bra	99b
     87  1.1     uwe 	 nop
     88  1.1     uwe 
     89  1.1     uwe 
     90  1.1     uwe 	.align	2
     91  1.1     uwe .L._end:
     92  1.1     uwe 	.long	_end
     93  1.1     uwe .L.__bss_start:
     94  1.1     uwe 	.long	__bss_start
     95  1.1     uwe .L.boot1:
     96  1.1     uwe 	.long	_C_LABEL(boot1)
     97  1.1     uwe .L.2nd_loadaddr:
     98  1.1     uwe 	.long	SECONDARY_LOAD_ADDRESS
     99  1.1     uwe .L.boot_params:
    100  1.1     uwe 	.long	boot_params
    101  1.1     uwe 
    102  1.1     uwe 	.align	2
    103  1.1     uwe .L.errtxt:	.asciz	"Error: "
    104  1.1     uwe 	.align	2
    105  1.1     uwe .L.crlf:	.asciz	"\r\n"
    106  1.1     uwe 
    107  1.1     uwe 
    108  1.1     uwe 	/*
    109  1.1     uwe 	 * Vector the fs calls through here so we can support multiple
    110  1.1     uwe 	 * file system types with one copy of the library code and
    111  1.1     uwe 	 * multiple copies of this file.
    112  1.1     uwe 	 */
    113  1.1     uwe ENTRY(xxfs_open)
    114  1.1     uwe 	mov.l	1f, r0
    115  1.1     uwe 	jmp	@r0
    116  1.1     uwe 	 nop
    117  1.1     uwe 	.align	2
    118  1.1     uwe 1:	.long	_C_LABEL(XXfs_open)
    119  1.1     uwe 
    120  1.1     uwe ENTRY(xxfs_close)
    121  1.1     uwe 	mov.l	1f, r0
    122  1.1     uwe 	jmp	@r0
    123  1.1     uwe 	 nop
    124  1.1     uwe 	.align	2
    125  1.1     uwe 1:	.long	_C_LABEL(XXfs_close)
    126  1.1     uwe 
    127  1.1     uwe ENTRY(xxfs_read)
    128  1.1     uwe 	mov.l	1f, r0
    129  1.1     uwe 	jmp	@r0
    130  1.1     uwe 	 nop
    131  1.1     uwe 	.align	2
    132  1.1     uwe 1:	.long	_C_LABEL(XXfs_read)
    133  1.1     uwe 
    134  1.1     uwe ENTRY(xxfs_stat)
    135  1.1     uwe 	mov.l	1f, r0
    136  1.1     uwe 	jmp	@r0
    137  1.1     uwe 	 nop
    138  1.1     uwe 	.align	2
    139  1.1     uwe 1:	.long	_C_LABEL(XXfs_stat)
    140  1.1     uwe 
    141  1.1     uwe 
    142  1.1     uwe 
    143  1.1     uwe /*
    144  1.1     uwe  * int readsects(int dev, uint32_t lba, void *buf, size_t size);
    145  1.1     uwe  */
    146  1.1     uwe ENTRY(readsects)
    147  1.1     uwe 	mov	#2, r0
    148  1.1     uwe 	trapa	#0x3f
    149  1.1     uwe 	rts
    150  1.1     uwe 	 nop
    151  1.1     uwe argerror:
    152  1.1     uwe 	rts
    153  1.1     uwe 	 mov	#-1, r0
    154  1.1     uwe 
    155  1.1     uwe /*
    156  1.1     uwe  * void putstr(const char *str);
    157  1.1     uwe  */
    158  1.1     uwe ENTRY(putstr)
    159  1.1     uwe 	mov	#32, r0
    160  1.1     uwe 	trapa	#0x3f
    161  1.1     uwe 	rts
    162  1.1     uwe 	 nop
    163