11.3Stsutsui/* $NetBSD: fdboot.S,v 1.3 2022/06/26 14:14:46 tsutsui Exp $ */ 21.1She 31.1She/* 41.1She * Copyright (c) 1995 Waldi Ravens. 51.1She * All rights reserved. 61.1She * 71.1She * Redistribution and use in source and binary forms, with or without 81.1She * modification, are permitted provided that the following conditions 91.1She * are met: 101.1She * 1. Redistributions of source code must retain the above copyright 111.1She * notice, this list of conditions and the following disclaimer. 121.1She * 2. Redistributions in binary form must reproduce the above copyright 131.1She * notice, this list of conditions and the following disclaimer in the 141.1She * documentation and/or other materials provided with the distribution. 151.1She * 3. All advertising materials mentioning features or use of this software 161.1She * must display the following acknowledgement: 171.1She * This product includes software developed by Waldi Ravens. 181.1She * 4. The name of the author may not be used to endorse or promote products 191.1She * derived from this software without specific prior written permission 201.1She * 211.1She * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 221.1She * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 231.1She * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 241.1She * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 251.1She * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 261.1She * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 271.1She * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 281.1She * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 291.1She * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 301.1She * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 311.1She */ 321.1She 331.1She#include "xxboot.h" 341.1She 351.1She .globl _start, main, fill 361.1She 371.1She .text 381.1She 391.1She_start: bras main 401.1She/* 411.1She * Fake gemdos-fs bootsector, to keep TOS away. 421.1She */ 431.1She .ascii "NetBSD" | oem 441.1She .byte 0,0,0 | serial 451.1She .word 0 | bps 461.1She .byte 0 | spc 471.1She .word 0 | res 481.1She .byte 0 | fat 491.1She .word 0 | ndirs 501.1She .word 0 | sec 511.1She .byte 0 | media 521.1She .word 0 | spf 531.1She .word 0 | spt 541.1She .word 0 | side 551.1She .word 0 | hid 561.1She .even 571.1She/* 581.1She * ROM loader does not save any register! 591.1She */ 601.1Shemain: movml %d1-%d7/%a0-%a6,%sp@- 611.1She 621.1She lea %pc@(m_bot),%a3 631.1She movl _membot:w,%d3 641.1She lea MAXBOT,%a6 651.1She cmpl %a6,%d3 661.1She bhis exit | membot > MAXBOT 671.1She 681.1She lea %pc@(m_top),%a3 691.1She movl _memtop:w,%d3 701.1She cmpl #MINTOP,%d3 711.1She blts exit | memtop < MINTOP 721.1She 731.1She andw #-4,%d3 741.1She movl %d3,%a0 751.1She movl %sp,%a0@- 761.1She movl %a0,%sp | set new stack 771.1She/* 781.1She * Determine the number of sectors per cylinder. 791.1She */ 801.1She movq #0,%d3 811.1She0: movl %a6,%a3 | buffer 821.1She movq #1,%d0 | count 831.1She movq #0,%d1 | side 841.1She movl %d1,%d2 | track 851.1She addw %d0,%d3 | sector 861.1She bsr rds0 871.1She beqs 0b 881.1She subqw #1,%d3 891.1She addw %d3,%d3 901.1She lea %pc@(secpercyl),%a0 911.1She movw %d3,%a0@ 921.1She/* 931.1She * Load secondary boot loader and disklabel. 941.1She */ 951.1She movq #NSEC,%d5 | # of sectors 961.1She movq #1,%d4 | first sector 971.1She movl %a6,%a3 | load address 981.1She bsr rds1 991.1She lea %pc@(m_rds),%a3 1001.1She bnes 0f | I/O error 1011.1She/* 1021.1She * int bootxx(readsector, disklabel, autoboot) 1031.1She */ 1041.1She clrl %sp@- | no autoboot 1051.1She pea %a6@(LBLST-MAXBOT) | disklabel 1061.1She pea %pc@(rds2) | readsector 1071.1She jsr %a6@(BXXST-MAXBOT) 1081.1She lea %pc@(m_sbl),%a3 | NetBSD not booted 1091.1She lea %sp@(12),%sp 1101.1She0: movl %sp@,%sp | restore BIOS stack 1111.1She movl %d0,%d3 1121.1She 1131.1Sheexit: bsrs puts | display error 1141.1She lea %pc@(m_key),%a3 1151.1She bsrs puts | wait for key 1161.1She0: movml %sp@+,%d1-%d7/%a0-%a6 1171.1She movq #0,%d0 1181.1She rts 1191.1She/* 1201.1She * puts (in: a3, d3) 1211.1She */ 1221.1She0: cmpw #35,%d0 | '#' 1231.1She bnes 1f 1241.1She bsrs puti 1251.1She bras puts 1261.1She1: cmpw #64,%d0 | '@' 1271.1She bnes 2f 1281.1She movw #2,%sp@- 1291.1She movw #Bconin,%sp@- 1301.1She trap #BIOS 1311.1She addql #4,%sp 1321.1She bras puts 1331.1She2: bsrs putc 1341.1Sheputs: movq #0,%d0 1351.1She movb %a3@+,%d0 1361.1She bnes 0b 1371.1She rts 1381.1She 1391.1Sheputi: swap %d3 1401.1She bsrs 0f 1411.1She swap %d3 1421.1She0: rorw #8,%d3 1431.1She bsrs 1f 1441.1She rorw #8,%d3 1451.1She1: rorb #4,%d3 1461.1She bsrs 2f 1471.1She rorb #4,%d3 1481.1She2: movw %d3,%d0 1491.1She andw #15,%d0 1501.1She addw #48,%d0 1511.1She cmpw #58,%d0 1521.1She bcss putc 1531.1She addw #39,%d0 1541.1Sheputc: movw %d0,%sp@- 1551.1She movw #2,%sp@- 1561.1She movw #Bconout,%sp@- 1571.1She trap #BIOS 1581.1She addql #6,%sp 1591.1She rts 1601.1She/* 1611.1She * int readsec (void *buffer, u_int offset, u_int count); 1621.1She */ 1631.1Sherds2: movml %d2-%d5/%a2-%a3,%sp@- 1641.1She movl %sp@(28),%a3 | buffer 1651.1She movl %sp@(32),%d4 | offset 1661.1She movl %sp@(36),%d5 | count 1671.1She bsrs rds1 1681.1She movml %sp@+,%d2-%d5/%a2-%a3 1691.1She rts 1701.1She 1711.1Sherds1: bsrs 1f 1721.1She bnes 0f 1731.1She tstl %d5 1741.1She bnes rds1 1751.1She0: rts 1761.1She 1771.1She1: movq #0,%d0 1781.1She movw %pc@(secpercyl),%d0 1791.1She movl %d4,%d3 1801.1She divuw %d0,%d3 1811.1She movw %d3,%d2 | track 1821.1She clrw %d3 1831.1She swap %d3 1841.1She lsrw #1,%d0 1851.1She divuw %d0,%d3 1861.1She movw %d3,%d1 | side 1871.1She swap %d3 1881.1She subw %d3,%d0 1891.1She addqw #1,%d3 | sector 1901.1She cmpl %d0,%d5 1911.1She bccs rds0 1921.1She movw %d5,%d0 1931.1She 1941.1Sherds0: movw %d0,%sp@- | count 1951.1She movw %d1,%sp@- | side 1961.1She movw %d2,%sp@- | track 1971.1She movw %d3,%sp@- | sector 1981.1She movw _bootdev:w,%sp@- | device 1991.1She clrl %sp@- | filler 2001.1She movl %a3,%sp@- | buffer 2011.1She addl %d0,%d4 2021.1She subl %d0,%d5 2031.1She lsll #8,%d0 2041.1She addl %d0,%d0 2051.1She addl %d0,%a3 2061.1She movw #Floprd,%sp@- 2071.1She trap #XBIOS 2081.1She lea %sp@(20),%sp 2091.1She tstl %d0 2101.1She rts 2111.1She 2121.1Shesecpercyl: 2131.1She .word 0 2141.1She 2151.1Shem_bot: .asciz "fdboot: membot == 0x#\r\n" 2161.1Shem_top: .asciz "fdboot: memtop == 0x#\r\n" 2171.1Shem_sbl: .asciz "fdboot: bootxx => 0x#\r\n" 2181.1Shem_rds: .asciz "fdboot: Floprd => 0x#\r\n" 2191.1Shem_key: .asciz "\007\r\npress any key... @\r\n" 2201.1She 2211.1Shefill: .space 22 | 510-(fill-start) 2221.1She .word 0 | checksum 2231.1Sheend: 224