fdboot.S revision 1.1
11.1She/* $NetBSD: fdboot.S,v 1.1 2003/10/28 11:35:00 he 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#ifdef __ELF__ 361.1She .globl _start, main, fill 371.1She 381.1She .text 391.1She 401.1She_start: bras main 411.1She#else 421.1She .globl start, main, fill 431.1She 441.1She .text 451.1She 461.1Shestart: bras main 471.1She#endif 481.1She/* 491.1She * Fake gemdos-fs bootsector, to keep TOS away. 501.1She */ 511.1She .ascii "NetBSD" | oem 521.1She .byte 0,0,0 | serial 531.1She .word 0 | bps 541.1She .byte 0 | spc 551.1She .word 0 | res 561.1She .byte 0 | fat 571.1She .word 0 | ndirs 581.1She .word 0 | sec 591.1She .byte 0 | media 601.1She .word 0 | spf 611.1She .word 0 | spt 621.1She .word 0 | side 631.1She .word 0 | hid 641.1She .even 651.1She/* 661.1She * ROM loader does not save any register! 671.1She */ 681.1Shemain: movml %d1-%d7/%a0-%a6,%sp@- 691.1She 701.1She lea %pc@(m_bot),%a3 711.1She movl _membot:w,%d3 721.1She lea MAXBOT,%a6 731.1She cmpl %a6,%d3 741.1She bhis exit | membot > MAXBOT 751.1She 761.1She lea %pc@(m_top),%a3 771.1She movl _memtop:w,%d3 781.1She cmpl #MINTOP,%d3 791.1She blts exit | memtop < MINTOP 801.1She 811.1She andw #-4,%d3 821.1She movl %d3,%a0 831.1She movl %sp,%a0@- 841.1She movl %a0,%sp | set new stack 851.1She/* 861.1She * Determine the number of sectors per cylinder. 871.1She */ 881.1She movq #0,%d3 891.1She0: movl %a6,%a3 | buffer 901.1She movq #1,%d0 | count 911.1She movq #0,%d1 | side 921.1She movl %d1,%d2 | track 931.1She addw %d0,%d3 | sector 941.1She bsr rds0 951.1She beqs 0b 961.1She subqw #1,%d3 971.1She addw %d3,%d3 981.1She lea %pc@(secpercyl),%a0 991.1She movw %d3,%a0@ 1001.1She/* 1011.1She * Load secondary boot loader and disklabel. 1021.1She */ 1031.1She movq #NSEC,%d5 | # of sectors 1041.1She movq #1,%d4 | first sector 1051.1She movl %a6,%a3 | load address 1061.1She bsr rds1 1071.1She lea %pc@(m_rds),%a3 1081.1She bnes 0f | I/O error 1091.1She/* 1101.1She * int bootxx(readsector, disklabel, autoboot) 1111.1She */ 1121.1She clrl %sp@- | no autoboot 1131.1She pea %a6@(LBLST-MAXBOT) | disklabel 1141.1She pea %pc@(rds2) | readsector 1151.1She jsr %a6@(BXXST-MAXBOT) 1161.1She lea %pc@(m_sbl),%a3 | NetBSD not booted 1171.1She lea %sp@(12),%sp 1181.1She0: movl %sp@,%sp | restore BIOS stack 1191.1She movl %d0,%d3 1201.1She 1211.1Sheexit: bsrs puts | display error 1221.1She lea %pc@(m_key),%a3 1231.1She bsrs puts | wait for key 1241.1She0: movml %sp@+,%d1-%d7/%a0-%a6 1251.1She movq #0,%d0 1261.1She rts 1271.1She/* 1281.1She * puts (in: a3, d3) 1291.1She */ 1301.1She0: cmpw #35,%d0 | '#' 1311.1She bnes 1f 1321.1She bsrs puti 1331.1She bras puts 1341.1She1: cmpw #64,%d0 | '@' 1351.1She bnes 2f 1361.1She movw #2,%sp@- 1371.1She movw #Bconin,%sp@- 1381.1She trap #BIOS 1391.1She addql #4,%sp 1401.1She bras puts 1411.1She2: bsrs putc 1421.1Sheputs: movq #0,%d0 1431.1She movb %a3@+,%d0 1441.1She bnes 0b 1451.1She rts 1461.1She 1471.1Sheputi: swap %d3 1481.1She bsrs 0f 1491.1She swap %d3 1501.1She0: rorw #8,%d3 1511.1She bsrs 1f 1521.1She rorw #8,%d3 1531.1She1: rorb #4,%d3 1541.1She bsrs 2f 1551.1She rorb #4,%d3 1561.1She2: movw %d3,%d0 1571.1She andw #15,%d0 1581.1She addw #48,%d0 1591.1She cmpw #58,%d0 1601.1She bcss putc 1611.1She addw #39,%d0 1621.1Sheputc: movw %d0,%sp@- 1631.1She movw #2,%sp@- 1641.1She movw #Bconout,%sp@- 1651.1She trap #BIOS 1661.1She addql #6,%sp 1671.1She rts 1681.1She/* 1691.1She * int readsec (void *buffer, u_int offset, u_int count); 1701.1She */ 1711.1Sherds2: movml %d2-%d5/%a2-%a3,%sp@- 1721.1She movl %sp@(28),%a3 | buffer 1731.1She movl %sp@(32),%d4 | offset 1741.1She movl %sp@(36),%d5 | count 1751.1She bsrs rds1 1761.1She movml %sp@+,%d2-%d5/%a2-%a3 1771.1She rts 1781.1She 1791.1Sherds1: bsrs 1f 1801.1She bnes 0f 1811.1She tstl %d5 1821.1She bnes rds1 1831.1She0: rts 1841.1She 1851.1She1: movq #0,%d0 1861.1She movw %pc@(secpercyl),%d0 1871.1She movl %d4,%d3 1881.1She divuw %d0,%d3 1891.1She movw %d3,%d2 | track 1901.1She clrw %d3 1911.1She swap %d3 1921.1She lsrw #1,%d0 1931.1She divuw %d0,%d3 1941.1She movw %d3,%d1 | side 1951.1She swap %d3 1961.1She subw %d3,%d0 1971.1She addqw #1,%d3 | sector 1981.1She cmpl %d0,%d5 1991.1She bccs rds0 2001.1She movw %d5,%d0 2011.1She 2021.1Sherds0: movw %d0,%sp@- | count 2031.1She movw %d1,%sp@- | side 2041.1She movw %d2,%sp@- | track 2051.1She movw %d3,%sp@- | sector 2061.1She movw _bootdev:w,%sp@- | device 2071.1She clrl %sp@- | filler 2081.1She movl %a3,%sp@- | buffer 2091.1She addl %d0,%d4 2101.1She subl %d0,%d5 2111.1She lsll #8,%d0 2121.1She addl %d0,%d0 2131.1She addl %d0,%a3 2141.1She movw #Floprd,%sp@- 2151.1She trap #XBIOS 2161.1She lea %sp@(20),%sp 2171.1She tstl %d0 2181.1She rts 2191.1She 2201.1Shesecpercyl: 2211.1She .word 0 2221.1She 2231.1Shem_bot: .asciz "fdboot: membot == 0x#\r\n" 2241.1Shem_top: .asciz "fdboot: memtop == 0x#\r\n" 2251.1Shem_sbl: .asciz "fdboot: bootxx => 0x#\r\n" 2261.1Shem_rds: .asciz "fdboot: Floprd => 0x#\r\n" 2271.1Shem_key: .asciz "\007\r\npress any key... @\r\n" 2281.1She 2291.1Shefill: .space 22 | 510-(fill-start) 2301.1She .word 0 | checksum 2311.1Sheend: 232