Home | History | Annotate | Line # | Download | only in ahdi-sdb00t
      1 /*	$NetBSD: sdb00t.ahdi.S,v 1.3 2022/06/26 14:14:46 tsutsui Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1995 Waldi Ravens
      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  * 3. All advertising materials mentioning features or use of this software
     16  *    must display the following acknowledgement:
     17  *        This product includes software developed by Waldi Ravens.
     18  * 4. The name of the author may not be used to endorse or promote products
     19  *    derived from this software without specific prior written permission
     20  *
     21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     22  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     24  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     26  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     30  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31  */
     32 
     33 #include "xxboot.h"
     34 
     35 	.globl	_start, main, fill
     36 
     37 	.text
     38 
     39 _start:	bras	main
     40 	bra	rds0
     41 
     42 main:	bclr	#2,(_drvbits+3):w
     43 	clrl	pun_ptr:w
     44 	movml	%d3/%d5,%sp@-
     45 	movw	#-1,%sp@-
     46 	movw	#Kbshift,%sp@-
     47 	trap	#BIOS
     48 	addql	#4,%sp
     49 	btst	#3,%d0			| Alternate?
     50 	bnes	exit
     51 	movq	#3,%d0
     52 	lea	%pc@(p0_dsc),%a0
     53 	cmpl	#0x444d4172,%d3		| SCSI bootdev?
     54 	beqs	0f
     55 	movq	#-1,%d4			| no, ACSI
     56 	movq	#0,%d5
     57 0:	movb	%d5,%d1			| NVRAM bootpref
     58 	bnes	1f
     59 
     60 	| The Hades bios does not provide a bootprev. In case
     61 	| of doubt, we fetch it ourselves.
     62  	moveml	%d0-%d2/%a0-%a2,%sp@-
     63  	pea	bpref
     64  	movw	#1, %sp@-
     65  	movw	#1, %sp@-
     66  	movw	#0, %sp@-
     67  	movw	#NVMaccess, %sp@-
     68  	trap	#XBIOS
     69  	lea	%sp@(12),%sp
     70  	moveml	%sp@+,%d0-%d2/%a0-%a2
     71  	movb	bpref:w,%d1
     72 	bnes	1f
     73 	movq	#-8,%d1	 		| bootpref = any
     74 
     75 1:	movb	%a0@,%d2			| bootflags
     76 	btst	#0,%d2
     77 	beqs	2f
     78 	andb	%d1,%d2
     79 	bnes	boot
     80 2:	lea	%a0@(12),%a0
     81 	dbra	%d0,1b
     82 
     83 exit:	movml	%sp@+,%d3/%d5
     84 tostst:	clrw	_bootdev:w
     85 	movl	_sysbase:w,%a0
     86 	movl	%a0@(24),%d0
     87 	swap	%d0
     88 	cmpl	#0x19870422,%d0		| old TOS?
     89 	bccs	0f			| no
     90 	movw	#0xe0,%d7
     91 0:	rts
     92 
     93 boot:	movl	%a0@(4),%d6
     94 	movq	#1,%d5
     95 	lea	%pc@(end),%a4
     96 	bsrs	rds0
     97 	tstw	%d0
     98 	bnes	exit
     99 	movl	%a4,%a0
    100 	movw	#0xff,%d0
    101 	movq	#0,%d1
    102 0:	addw	%a0@+,%d1
    103 	dbra	%d0,0b
    104 	cmpw	#0x1234,%d1
    105 	bnes	exit
    106 	lea	%pc@(rds0),%a3
    107 	lea	%pc@(tostst),%a5
    108 	movml	%sp@+,%d3/%d5
    109 	jmp	%a4@			| start bootsector code
    110 /*
    111  * in:  d4/d7 (target) d5 (count), d6 (offset), a4 (buffer)
    112  * out: d0 (<= 0)
    113  * mod: d0, d1, d2, a0, a1, a5, a6
    114  */
    115 rds0:	tstl	%d4
    116 	bmis	0f
    117 	movw	%d4,%sp@-			| device
    118 	pea	%a4@			| buffer
    119 	movw	%d5,%sp@-			| count
    120 	movl	%d6,%sp@-			| offset
    121 	movw	#DMAread,%sp@-
    122 	trap	#XBIOS
    123 	lea	%sp@(14),%sp
    124 	rts
    125 
    126 0:	st	flock:w
    127 	movl	_hz_200:w,%d0
    128 	addql	#2,%d0
    129 1:	cmpl	_hz_200:w,%d0
    130 	bccs	1b
    131 	movml	%d6/%a4,%sp@-
    132 	lea	dmahi:w,%a6
    133 	movb	%sp@(7),%a6@(4)
    134 	movb	%sp@(6),%a6@(2)
    135 	movb	%sp@(5),%a6@
    136 	lea	%pc@(r0com),%a6
    137 	movb	%sp@(1),%a6@(1)
    138 	movb	%sp@(2),%a6@(5)
    139 	movb	%sp@(3),%a6@(9)
    140 	movb	%d5,%a6@(13)
    141 	addql	#8,%sp
    142 	lea	dmodus:w,%a6
    143 	lea	daccess:w,%a5
    144 	movw	#0x198,%a6@
    145 	movw	#0x098,%a6@
    146 	movw	%d5,%a5@
    147 	movw	#0x88,%a6@
    148 	movq	#0,%d0
    149 	movb	%d7,%d0
    150 	orb	#0x08,%d0
    151 	swap	%d0
    152 	movw	#0x8a,%d0
    153 	bsrs	shake
    154 	lea	%pc@(r0com),%a0
    155 	movq	#3,%d2
    156 2:	movl	%a0@+,%d0
    157 	bsrs	shake
    158 	dbra	%d2,2b
    159 	movq	#0x0a,%d0
    160 	movl	%d0,%a5@
    161 	movl	#0x190,%d1
    162 	bsrs	wait
    163 	movw	#0x8a,%a6@
    164 	movw	%a5@,%d0
    165 	andw	#0xff,%d0
    166 	beqs	0f
    167 r0err:	movq	#-1,%d0
    168 0:	movw	#0x80,%a6@
    169 	clrb	flock:w
    170 r0ret:	rts
    171 
    172 shake:	movl	%d0,%a5@
    173 	movq	#0x0a,%d1
    174 wait:	addl	_hz_200:w,%d1
    175 0:	btst	#5,gpip:w
    176 	beqs	r0ret
    177 	cmpl	_hz_200:w,%d1
    178 	bccs	0b
    179 	addql	#4,%sp
    180 	bras	r0err
    181 
    182 r0com:	.long	0x0000008a
    183 	.long	0x0000008a
    184 	.long	0x0000008a
    185 	.long	0x0001008a
    186 bpref:	.word	0
    187 
    188 fill:	.space	16
    189 
    190 	.ascii	"NetBSD"
    191 hd_siz:	.long	0
    192 p0_dsc:	.long	0, 0, 0
    193 p1_dsc:	.long	0, 0, 0
    194 p2_dsc:	.long	0, 0, 0
    195 p3_dsc:	.long	0, 0, 0
    196 bsl_st:	.long	0
    197 bsl_sz:	.long	0
    198 	.word	0
    199 end:
    200