1 1.3 tsutsui /* $NetBSD: xxboot.ahdi.S,v 1.3 2022/06/26 14:14:46 tsutsui Exp $ */ 2 1.1 he 3 1.1 he /* 4 1.1 he * Copyright (c) 1995 Waldi Ravens. 5 1.1 he * All rights reserved. 6 1.1 he * 7 1.1 he * Redistribution and use in source and binary forms, with or without 8 1.1 he * modification, are permitted provided that the following conditions 9 1.1 he * are met: 10 1.1 he * 1. Redistributions of source code must retain the above copyright 11 1.1 he * notice, this list of conditions and the following disclaimer. 12 1.1 he * 2. Redistributions in binary form must reproduce the above copyright 13 1.1 he * notice, this list of conditions and the following disclaimer in the 14 1.1 he * documentation and/or other materials provided with the distribution. 15 1.1 he * 3. All advertising materials mentioning features or use of this software 16 1.1 he * must display the following acknowledgement: 17 1.1 he * This product includes software developed by Waldi Ravens. 18 1.1 he * 4. The name of the author may not be used to endorse or promote products 19 1.1 he * derived from this software without specific prior written permission 20 1.1 he * 21 1.1 he * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 22 1.1 he * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23 1.1 he * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 24 1.1 he * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 25 1.1 he * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 26 1.1 he * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 1.1 he * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 1.1 he * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 1.1 he * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30 1.1 he * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 1.1 he */ 32 1.1 he 33 1.1 he #include "xxboot.h" 34 1.1 he 35 1.1 he .globl _start, main, fill 36 1.1 he 37 1.1 he .text 38 1.1 he 39 1.1 he _start: bras main 40 1.1 he /* 41 1.1 he * Fake gemdos-fs bootsector, to keep TOS away. 42 1.1 he */ 43 1.1 he .ascii "NetBSD" | oem 44 1.1 he .byte 0,0,0 | serial 45 1.1 he .word 0 | bps 46 1.1 he .byte 0 | spc 47 1.1 he .word 0 | res 48 1.1 he .byte 0 | fat 49 1.1 he .word 0 | ndirs 50 1.1 he .word 0 | sec 51 1.1 he .byte 0 | media 52 1.1 he .word 0 | spf 53 1.1 he .word 0 | spt 54 1.1 he .word 0 | side 55 1.1 he .word 0 | hid 56 1.1 he .even 57 1.1 he /* 58 1.1 he * AHDI rootsector code passes: 59 1.1 he * d3: SCSI/IDE <-> ACSI flag d4: SCSI/IDE target (or -1) 60 1.1 he * d5: boot preference d6: offset of boot block 61 1.1 he * d7: ACSI target a3: pointer to readsector() 62 1.1 he * a4: pointer to `start' a5: pointer to back-to-ROM 63 1.1 he */ 64 1.1 he main: movml %d3-%d7/%a3-%a5,%sp@- 65 1.1 he lea %pc@(regsav),%a0 66 1.1 he movl %sp,%a0@ 67 1.1 he 68 1.1 he movw #-1,%sp@- 69 1.1 he movw #Kbshift,%sp@- 70 1.1 he trap #BIOS 71 1.1 he addql #4,%sp 72 1.1 he subql #1,%d0 73 1.1 he movl %d0,%a5 | autoboot flag 74 1.1 he 75 1.1 he lea %pc@(m_bot),%a6 76 1.1 he movl _membot:w,%d3 77 1.1 he lea MAXBOT,%a4 78 1.1 he cmpl %a4,%d3 79 1.1 he bhis exit | membot > MAXBOT 80 1.1 he 81 1.1 he lea %pc@(m_top),%a6 82 1.1 he movl _memtop:w,%d3 83 1.1 he cmpl #MINTOP,%d3 84 1.1 he blts exit | memtop < MINTOP 85 1.1 he 86 1.1 he andw #-4,%d3 87 1.1 he movl %d3,%a0 88 1.1 he movl %sp,%a0@- 89 1.1 he movl %a0,%sp | set new stack 90 1.1 he /* 91 1.1 he * Load secondary boot loader and disklabel. 92 1.1 he */ 93 1.1 he movml %a4/%a5,%sp@- 94 1.1 he movq #NSEC,%d3 | # of sectors 95 1.1 he addql #1,%d6 | first sector 96 1.1 he bsr rds1 97 1.1 he lea %pc@(m_rds),%a6 98 1.1 he movml %sp@+,%a4/%a5 99 1.1 he bnes 0f | I/O error 100 1.1 he /* 101 1.1 he * int bootxx(readsector, disklabel, autoboot) 102 1.1 he */ 103 1.1 he pea %a5@ | autoboot 104 1.1 he pea %a4@(LBLST-MAXBOT) | disklabel 105 1.1 he pea %pc@(rds2) | readsector 106 1.1 he jsr %a4@(BXXST-MAXBOT) 107 1.1 he lea %pc@(m_sbl),%a6 | NetBSD not booted 108 1.1 he lea %sp@(12),%sp 109 1.1 he 110 1.1 he 0: movl %sp@,%sp | restore BIOS stack 111 1.1 he movl %d0,%d3 112 1.1 he bmis exit 113 1.1 he movml %sp@+,%d3-%d7/%a3-%a5 114 1.1 he movl %d0,%d5 | new boot preference 115 1.1 he jmp %a4@(-0x200) 116 1.1 he 117 1.1 he exit: bsrs puts | display error 118 1.1 he lea %pc@(m_key),%a6 119 1.1 he bsrs puts | wait for key 120 1.1 he movml %sp@+,%d3-%d7/%a3-%a5 121 1.1 he jmp %a5@ 122 1.1 he 123 1.1 he /* 124 1.1 he * puts (in: a6, d3) 125 1.1 he */ 126 1.1 he 0: cmpw #35,%d0 | '#' 127 1.1 he bnes 1f 128 1.1 he bsrs puti 129 1.1 he bras puts 130 1.1 he 1: cmpw #64,%d0 | '@' 131 1.1 he bnes 2f 132 1.1 he movw #2,%sp@- 133 1.1 he movw #Bconin,%sp@- 134 1.1 he trap #BIOS 135 1.1 he addql #4,%sp 136 1.1 he bras puts 137 1.1 he 2: bsrs putc 138 1.1 he puts: movq #0,%d0 139 1.1 he movb %a6@+,%d0 140 1.1 he bnes 0b 141 1.1 he rts 142 1.1 he 143 1.1 he puti: swap %d3 144 1.1 he bsrs 0f 145 1.1 he swap %d3 146 1.1 he 0: rorw #8,%d3 147 1.1 he bsrs 1f 148 1.1 he rorw #8,%d3 149 1.1 he 1: rorb #4,%d3 150 1.1 he bsrs 2f 151 1.1 he rorb #4,%d3 152 1.1 he 2: movw %d3,%d0 153 1.1 he andw #15,%d0 154 1.1 he addw #48,%d0 155 1.1 he cmpw #58,%d0 156 1.1 he bcss putc 157 1.1 he addw #39,%d0 158 1.1 he putc: movw %d0,%sp@- 159 1.1 he movw #2,%sp@- 160 1.1 he movw #Bconout,%sp@- 161 1.1 he trap #BIOS 162 1.1 he addql #6,%sp 163 1.1 he rts 164 1.1 he /* 165 1.1 he * int readsec (void *buffer, u_int offset, u_int count); 166 1.1 he */ 167 1.1 he rds2: movml %d2-%d7/%a2-%a6,%sp@- 168 1.1 he movl %pc@(regsav),%a0 169 1.1 he movml %a0@,%d3-%d7/%a3-%a5 170 1.1 he movl %sp@(48),%a4 | buffer 171 1.1 he movl %sp@(52),%d6 | offset 172 1.1 he movl %sp@(56),%d3 | count 173 1.1 he bsrs rds1 174 1.1 he movml %sp@+,%d2-%d7/%a2-%a6 175 1.1 he rts 176 1.1 he 177 1.1 he rds1: movl #255,%d5 178 1.1 he cmpl %d5,%d3 179 1.1 he bccs 0f 180 1.1 he movl %d3,%d5 181 1.1 he 0: jsr %a3@ 182 1.1 he tstl %d0 183 1.1 he bnes 1f 184 1.1 he addl #(255*512),%a4 185 1.1 he addl %d5,%d6 186 1.1 he subl %d5,%d3 187 1.1 he bnes rds1 188 1.1 he 1: rts 189 1.1 he 190 1.1 he m_bot: .asciz "xxboot: membot == 0x#\r\n" 191 1.1 he m_top: .asciz "xxboot: memtop == 0x#\r\n" 192 1.1 he m_sbl: .asciz "xxboot: bootxx => 0x#\r\n" 193 1.1 he m_rds: .asciz "xxboot: Floprd => 0x#\r\n" 194 1.1 he m_key: .asciz "\007\r\npress any key... @\r\n" 195 1.1 he 196 1.1 he regsav: .long 0 197 1.1 he 198 1.1 he fill: .space 54 | 510-(fill-start) 199 1.1 he .word 0 | checksum 200 1.1 he end: 201