1 /* $NetBSD: fdboot.S,v 1.1.4.3 2004/09/21 13:14:19 skrll Exp $ */
4 * Copyright (c) 1995 Waldi Ravens.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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
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.
36 .globl _start, main, fill
42 .globl start, main, fill
49 * Fake gemdos-fs bootsector, to keep TOS away.
66 * ROM loader does not save any register!
68 main: movml %d1-%d7/%a0-%a6,%sp@-
74 bhis exit | membot > MAXBOT
79 blts exit | memtop < MINTOP
84 movl %a0,%sp | set new stack
86 * Determine the number of sectors per cylinder.
89 0: movl %a6,%a3 | buffer
98 lea %pc@(secpercyl),%a0
101 * Load secondary boot loader and disklabel.
103 movq #NSEC,%d5 | # of sectors
104 movq #1,%d4 | first sector
105 movl %a6,%a3 | load address
110 * int bootxx(readsector, disklabel, autoboot)
112 clrl %sp@- | no autoboot
113 pea %a6@(LBLST-MAXBOT) | disklabel
114 pea %pc@(rds2) | readsector
115 jsr %a6@(BXXST-MAXBOT)
116 lea %pc@(m_sbl),%a3 | NetBSD not booted
118 0: movl %sp@,%sp | restore BIOS stack
121 exit: bsrs puts | display error
123 bsrs puts | wait for key
124 0: movml %sp@+,%d1-%d7/%a0-%a6
130 0: cmpw #35,%d0 | '#'
134 1: cmpw #64,%d0 | '@'
169 * int readsec (void *buffer, u_int offset, u_int count);
171 rds2: movml %d2-%d5/%a2-%a3,%sp@-
172 movl %sp@(28),%a3 | buffer
173 movl %sp@(32),%d4 | offset
174 movl %sp@(36),%d5 | count
176 movml %sp@+,%d2-%d5/%a2-%a3
186 movw %pc@(secpercyl),%d0
197 addqw #1,%d3 | sector
202 rds0: movw %d0,%sp@- | count
203 movw %d1,%sp@- | side
204 movw %d2,%sp@- | track
205 movw %d3,%sp@- | sector
206 movw _bootdev:w,%sp@- | device
208 movl %a3,%sp@- | buffer
223 m_bot: .asciz "fdboot: membot == 0x#\r\n"
224 m_top: .asciz "fdboot: memtop == 0x#\r\n"
225 m_sbl: .asciz "fdboot: bootxx => 0x#\r\n"
226 m_rds: .asciz "fdboot: Floprd => 0x#\r\n"
227 m_key: .asciz "\007\r\npress any key... @\r\n"
229 fill: .space 22 | 510-(fill-start)