Annotation of sys/arch/vax/boot/xxboot/start.S, Revision 1.1
1.1 ! nbrk 1: /* $OpenBSD: start.S,v 1.2 2003/11/07 10:16:45 jmc Exp $ */
! 2: /* $NetBSD: start.S,v 1.1 2002/02/24 01:04:26 matt Exp $ */
! 3: /*
! 4: * Copyright (c) 1995 Ludd, University of Lule}, Sweden.
! 5: * All rights reserved.
! 6: *
! 7: * This code is derived from software contributed to Ludd by
! 8: * Bertram Barth.
! 9: *
! 10: * Redistribution and use in source and binary forms, with or without
! 11: * modification, are permitted provided that the following conditions
! 12: * are met:
! 13: * 1. Redistributions of source code must retain the above copyright
! 14: * notice, this list of conditions and the following disclaimer.
! 15: * 2. Redistributions in binary form must reproduce the above copyright
! 16: * notice, this list of conditions and the following disclaimer in the
! 17: * documentation and/or other materials provided with the distribution.
! 18: * 3. All advertising materials mentioning features or use of this software
! 19: * must display the following acknowledgement:
! 20: * This product includes software developed at Ludd, University of
! 21: * Lule}, Sweden and its contributors.
! 22: * 4. The name of the author may not be used to endorse or promote products
! 23: * derived from this software without specific prior written permission
! 24: *
! 25: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
! 26: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
! 27: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
! 28: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
! 29: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
! 30: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
! 31: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
! 32: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
! 33: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
! 34: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
! 35: */
! 36:
! 37: /* All bugs are subject to removal without further notice */
! 38:
! 39:
! 40: #define _LOCORE
! 41:
! 42: #include "sys/disklabel.h"
! 43:
! 44: #include "../include/mtpr.h"
! 45: #include "../include/asm.h"
! 46:
! 47: _C_LABEL(_start):
! 48: _C_LABEL(start):
! 49: .globl _C_LABEL(start) # this is the symbolic name for the start
! 50: .globl _C_LABEL(_start) # of code to be relocated. We can use this
! 51: # to get the actual/real address (pc-rel)
! 52: # or to get the relocated address (abs).
! 53:
! 54: .org 0x00 # uVAX booted from TK50 starts here
! 55: brb from_0x00 # continue behind dispatch-block
! 56:
! 57: .org 0x02 # information used by uVAX-ROM
! 58: .byte 0xff # offset in words to identification area
! 59: .byte 1 # this byte must be 1
! 60: .word 0 # logical block number (word swapped)
! 61: .word 0 # of the secondary image
! 62:
! 63: .org 0x08 #
! 64: brb from_0x08 # skip ...
! 65:
! 66: .org 0x0C # 11/750 & 8200 starts here
! 67: movzbl $1,_C_LABEL(from)# We booted from "old" rom.
! 68: brw cont_750
! 69:
! 70:
! 71: from_0x00: # uVAX from TK50
! 72: brw start_uvax # all uVAXen continue there
! 73:
! 74: from_0x08: # Any machine from VMB
! 75: movzbl $4,_C_LABEL(from) # Booted from full VMB
! 76: brw start_vmb
! 77:
! 78: # the complete area reserved for label
! 79: # must be empty (i.e. filled with zeroes).
! 80: # disklabel(8) checks that before installing
! 81: # the bootblocks over existing label.
! 82:
! 83: .org LABELOFFSET
! 84: .globl _C_LABEL(romlabel)
! 85: _C_LABEL(romlabel):
! 86: .long 0
! 87:
! 88: .org LABELOFFSET + d_end_
! 89: start_vmb:
! 90: /*
! 91: * Read in block 1-15.
! 92: */
! 93: movl 52(r11), r7 # load iovec/bqo into %r7
! 94: addl3 (r7), r7, r6 # load qio into %r6
! 95: pushl r11 # base of rpb
! 96: pushl $0 # virtual-flag
! 97: pushl $33 # read-logical-block
! 98: pushl $1 # lbn to start reading
! 99: pushl $7680 # number of bytes to read
! 100: pushab start_uvax # buffer-address
! 101: calls $6, (r6) # call the qio-routine
! 102: brw start_uvax
! 103:
! 104: /*
! 105: * Parameter block for uVAX boot.
! 106: */
! 107: #define VOLINFO 0 /* 1=single-sided 81=double-sided volumes */
! 108: #define SISIZE 16 /* size in blocks of secondary image */
! 109: #define SILOAD 0 /* load offset (usually 0) from the default */
! 110: #define SIOFF 0x260 /* byte offset into secondary image */
! 111:
! 112: .org 0x1fe
! 113: .byte 0x18 # must be 0x18
! 114: .byte 0x00 # must be 0x00 (MBZ)
! 115: .byte 0x00 # any value
! 116: .byte 0xFF - (0x18 + 0x00 + 0x00)
! 117: /* 4th byte holds 1s' complement of sum of previous 3 bytes */
! 118:
! 119: .byte 0x00 # must be 0x00 (MBZ)
! 120: .byte VOLINFO
! 121: .byte 0x00 # any value
! 122: .byte 0x00 # any value
! 123:
! 124: .long SISIZE # size in blocks of secondary image
! 125: .long SILOAD # load offset (usually 0)
! 126: .long SIOFF # byte offset into secondary image
! 127: .long (SISIZE + SILOAD + SIOFF) # sum of previous 3
! 128:
! 129:
! 130: .align 2
! 131: .globl _C_LABEL(from)
! 132: _C_LABEL(from):
! 133: .long 0
! 134:
! 135: /*
! 136: * After bootblock (LBN0) has been loaded into the first page
! 137: * of good memory by 11/750's ROM-code (transfer address
! 138: * of bootblock-code is: base of good memory + 0x0C) registers
! 139: * are initialized as:
! 140: * R0: type of boot-device
! 141: * 0: Massbus device
! 142: * 1: RK06/RK07
! 143: * 2: RL02
! 144: * 17: UDA50
! 145: * 35: TK50
! 146: * 64: TU58
! 147: * R1: (UBA) address of UNIBUS I/O-page
! 148: * (MBA) address of boot device's adapter
! 149: * R2: (UBA) address of the boot device's CSR
! 150: * (MBA) controller number of boot device
! 151: * R6: address of driver subroutine in ROM
! 152: *
! 153: * cont_750 reads in LBN1-15 for further execution.
! 154: */
! 155: cont_750:
! 156: movl $_C_LABEL(start), sp # move stack to avoid clobbering the code
! 157: pushr $0x131 # save clobbered registers
! 158: clrl r4 # %r4 == # of blocks transferred
! 159: movab _C_LABEL(start),r5 # %r5 have base address for next transfer
! 160: pushl r5 # ...on stack also (Why?)
! 161: 1: incl r4 # increment block count
! 162: movl r4,r8 # LBN is in %r8 for rom routine
! 163: addl2 $0x200,r5 # Increase address for next read
! 164: cmpl $16,r4 # read 15 blocks?
! 165: beql 2f # Yep
! 166: movl r5,(sp) # move address to stack also
! 167: jsb (r6) # read 512 bytes
! 168: blbs r0,1b # jump if read succeeded
! 169: halt # otherwise die...
! 170: 2: tstl (sp)+ # remove boring arg from stack
! 171: popr $0x131 # restore clobbered registers
! 172: brw start_all # Ok, continue...
! 173:
! 174: /* uVAX main entry is at the start of the second disk block. This is
! 175: * needed for multi-arch CD booting where multiple architecture need
! 176: * to shove stuff in boot block 0.
! 177: */
! 178: .org 0x260 # uVAX booted from disk starts here
! 179:
! 180: start_uvax:
! 181: movzbl $2,_C_LABEL(from) # Booted from subset-VMB
! 182: brb start_all
! 183:
! 184: /*
! 185: * start_all: stack already at RELOC, we save registers, move ourself
! 186: * to RELOC and loads boot.
! 187: */
! 188: start_all:
! 189: movl $_C_LABEL(start), sp # move stack to a better
! 190: pushr $0x1fff # save all regs, used later.
! 191:
! 192: subl3 $_C_LABEL(start), $_C_LABEL(edata), r0
! 193: # get size of text+data (w/o bss)
! 194: moval _C_LABEL(start), r1 # get actual base-address of code
! 195: subl3 $_C_LABEL(start), $_C_LABEL(end), r2
! 196: # get complete size (incl. bss)
! 197: movl $_C_LABEL(start), r3 # get relocated base-address of code
! 198: movc5 r0, (r1), $0, r2, (r3) # copy code to new location
! 199:
! 200: movpsl -(sp)
! 201: movl $relocated, -(sp) # return-address on top of stack
! 202: rei # can be replaced with new address
! 203: relocated: # now relocation is done !!!
! 204: movl sp, _C_LABEL(bootregs)
! 205: calls $0, _C_LABEL(Xmain) # call Xmain (gcc workaround)which is
! 206: halt # not intended to return ...
! 207:
! 208: /*
! 209: * hoppabort() is called when jumping to the newly loaded program.
! 210: */
! 211: ENTRY(hoppabort, 0)
! 212: movl 4(ap),r6
! 213: movl _C_LABEL(rpb),r11
! 214: mnegl $1,ap # Hack to figure out boot device.
! 215: movpsl -(sp)
! 216: pushab 2(r6)
! 217: mnegl $1,_C_LABEL(vax_load_failure)
! 218: rei
! 219: # calls $0,(r6)
! 220: halt
! 221:
! 222: ENTRY(unit_init, R6|R7|R8|R9|R10|R11)
! 223: mfpr $17,r7 # Wanted bu KDB
! 224: movl 4(ap),r0 # init routine address
! 225: movl 8(ap),r9 # RPB in %r9
! 226: movl 12(ap),r1 # VMB argument list
! 227: callg (r1),(r0)
! 228: ret
! 229:
! 230: # A bunch of functions unwanted in boot blocks.
! 231: ENTRY(getchar, 0)
! 232: halt
! 233:
! 234: #ifndef USE_PRINTF
! 235: ENTRY(putchar, 0)
! 236: ret
! 237:
! 238: #endif
! 239:
! 240: ENTRY(panic, 0)
! 241: halt
CVSweb