Annotation of sys/arch/hp300/stand/uboot/srt0.S, Revision 1.1
1.1 ! nbrk 1: /* $OpenBSD: srt0.S,v 1.6 2006/08/17 06:31:10 miod Exp $ */
! 2: /* $NetBSD: srt0.S,v 1.4 1997/05/12 07:56:00 thorpej Exp $ */
! 3:
! 4: /*
! 5: * Copyright (c) 1988 University of Utah.
! 6: * Copyright (c) 1982, 1990, 1993
! 7: * The Regents of the University of California. All rights reserved.
! 8: *
! 9: * This code is derived from software contributed to Berkeley by
! 10: * the Systems Programming Group of the University of Utah Computer
! 11: * Science Department.
! 12: *
! 13: * Redistribution and use in source and binary forms, with or without
! 14: * modification, are permitted provided that the following conditions
! 15: * are met:
! 16: * 1. Redistributions of source code must retain the above copyright
! 17: * notice, this list of conditions and the following disclaimer.
! 18: * 2. Redistributions in binary form must reproduce the above copyright
! 19: * notice, this list of conditions and the following disclaimer in the
! 20: * documentation and/or other materials provided with the distribution.
! 21: * 3. Neither the name of the University nor the names of its contributors
! 22: * may be used to endorse or promote products derived from this software
! 23: * without specific prior written permission.
! 24: *
! 25: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
! 26: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
! 27: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
! 28: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
! 29: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
! 30: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
! 31: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
! 32: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
! 33: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
! 34: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
! 35: * SUCH DAMAGE.
! 36: *
! 37: * from: Utah $Hdr: srt0.c 1.18 92/12/21$
! 38: *
! 39: * @(#)srt0.c 8.1 (Berkeley) 6/10/93
! 40: */
! 41:
! 42: /*
! 43: * Startup code for standalone system
! 44: */
! 45:
! 46: #include <machine/asm.h>
! 47: #include <machine/hp300spu.h>
! 48:
! 49: STACK = 0xfffff000 | below the ROM page
! 50: BOOTTYPE = 0xfffffdc0
! 51: LOWRAM = 0xfffffdce
! 52: SYSFLAG = 0xfffffed2 | system flags
! 53: MSUS = 0xfffffedc | MSUS (?) structure
! 54: VECTORS = 0xfffffee0 | beginning of jump vectors
! 55: NMIRESET = 0xffffff9c | reset vector
! 56: BUSERR = 0xfffffffc
! 57: MAXADDR = 0xfffff000
! 58: NBPG = 4096
! 59: MMUCMD = 0x005f400c | MMU command/status register
! 60:
! 61: .data
! 62: GLOBAL(bootdev)
! 63: .long 0
! 64: GLOBAL(howto)
! 65: .long 0
! 66: GLOBAL(lowram)
! 67: .long 0
! 68: GLOBAL(machineid)
! 69: .long 0
! 70: GLOBAL(mmuid)
! 71: .long 0
! 72:
! 73: .text
! 74: ASENTRY_NOPROFILE(begin)
! 75: movl #STACK,sp
! 76: moveq #47,d0 | # of vectors - 1
! 77: movl #VECTORS+2,a0 | addr part of first vector
! 78: 1:
! 79: movl #_ASM_LABEL(__trap),a0@ | make it direct to __trap
! 80: addql #6,a0 | move to next vector addr
! 81: dbf d0,1b | go til done
! 82: movl #NMIRESET,a0 | NMI keyboard reset addr
! 83: movl #nmi,a0@ | catch in reset routine
! 84:
! 85: /*
! 86: * Determine our SPU type and look for internal HP-IB
! 87: */
! 88: lea _C_LABEL(machineid),a0
! 89: movl #0x808,d0
! 90: movc d0,cacr | clear and disable on-chip cache(s)
! 91: movl #0x200,d0 | data freeze bit
! 92: movc d0,cacr | only exists on 68030
! 93: movc cacr,d0 | read it back
! 94: tstl d0 | zero?
! 95: jeq not68030 | yes, we have 68020/68040
! 96:
! 97: /*
! 98: * 68030 models
! 99: */
! 100:
! 101: movl #0x808,d0
! 102: movc d0,cacr | clear data freeze bit again
! 103: movl #0x80,MMUCMD | set magic cookie
! 104: movl MMUCMD,d0 | read it back
! 105: btst #7,d0 | cookie still on?
! 106: jeq not370 | no, 360 or 375
! 107: movl #HP_370,a0@ | consider a 370 for now
! 108: movl #0,MMUCMD | clear magic cookie
! 109: movl MMUCMD,d0 | read it back
! 110: btst #7,d0 | still on?
! 111: jeq ihpibcheck | no, a 370
! 112: movl #HP_340,a0@ | yes, must be a 340
! 113: jra ihpibcheck
! 114:
! 115: not370:
! 116: movl #HP_360,a0@ | type is at least a 360
! 117: movl #0,MMUCMD | clear magic cookie2
! 118: movl MMUCMD,d0 | read it back
! 119: btst #16,d0 | still on?
! 120: jeq ihpibcheck | no, a 360 or a 362
! 121: lsrl #MMUID_SHIFT,d0 | save MMU ID
! 122: andl #MMUID_MASK,d0
! 123: movl d0,_C_LABEL(mmuid) | save mmuid
! 124: cmpb #MMUID_345,d0 | are we a 345?
! 125: jeq isa345
! 126: cmpb #MMUID_375,d0 | how about a 375?
! 127: jeq isa375
! 128: movl #HP_400,a0@ | must be a 400
! 129: jra ihpibcheck
! 130: isa345:
! 131: movl #HP_345,a0@
! 132: jra ihpibcheck
! 133: isa375:
! 134: movl #HP_375,a0@
! 135: jra ihpibcheck
! 136:
! 137: /*
! 138: * End of 68030 section
! 139: */
! 140:
! 141: not68030:
! 142: bset #31,d0 | data cache enable bit
! 143: movc d0,cacr | only exists on 68040
! 144: movc cacr,d0 | read it back
! 145: tstl d0 | zero?
! 146: beq is68020 | yes, we have 68020
! 147: moveq #0,d0 | now turn it back off
! 148: movec d0,cacr | before we access any data
! 149:
! 150: /*
! 151: * 68040 models
! 152: */
! 153:
! 154: .long 0x4e7b0004 | movc d0,itt0
! 155: .long 0x4e7b0005 | movc d0,itt1
! 156: .long 0x4e7b0006 | movc d0,dtt0
! 157: .long 0x4e7b0007 | movc d0,dtt1
! 158: .word 0xf4d8 | cinva bc
! 159: movl MMUCMD,d0 | get MMU ID
! 160: lsrl #MMUID_SHIFT,d0
! 161: andl #MMUID_MASK,d0
! 162: movl d0,_C_LABEL(mmuid) | save mmuid
! 163: cmpb #MMUID_425_T,d0 | are we a 425t?
! 164: jeq isa425
! 165: cmpb #MMUID_425_S,d0 | how about 425s?
! 166: jeq isa425
! 167: cmpb #MMUID_425_E,d0 | or maybe a 425e?
! 168: jeq isa425
! 169: cmpb #MMUID_433_T,d0 | or a 433t?
! 170: jeq isa433
! 171: cmpb #MMUID_433_S,d0 | maybe a 433s?
! 172: jeq isa433
! 173: cmpb #MMUID_385,d0 | then a 385?
! 174: jeq isa385
! 175: cmpb #MMUID_382,d0 | last chance...
! 176: jeq isa382
! 177: movl #HP_380,a0@ | guess we are a 380
! 178: jra ihpibcheck
! 179: isa425:
! 180: movl #HP_425,a0@
! 181: jra ihpibcheck
! 182: isa433:
! 183: movl #HP_433,a0@
! 184: jra ihpibcheck
! 185: isa385:
! 186: movl #HP_385,a0@
! 187: jra ihpibcheck
! 188: isa382:
! 189: movl #HP_382,a0@
! 190: jra ihpibcheck
! 191:
! 192: /*
! 193: * End 68040 section
! 194: */
! 195:
! 196: /*
! 197: * 68020 models
! 198: */
! 199:
! 200: is68020:
! 201: movl #HP_330,a0@ | consider a 330 for now
! 202: movl #1,MMUCMD | a 68020, write HP MMU location
! 203: movl MMUCMD,d0 | read it back
! 204: btst #0,d0 | zero?
! 205: jeq ihpibcheck | yes, a 330
! 206: movl #HP_320,a0@ | no, consider a 320 for now
! 207: movl #0x80,MMUCMD | set magic cookie
! 208: movl MMUCMD,d0 | read it back
! 209: btst #7,d0 | cookie still on?
! 210: jeq ihpibcheck | no, just a 320
! 211: movl #HP_350,a0@ | yes, a 350
! 212:
! 213: /*
! 214: * End 68020 section
! 215: */
! 216:
! 217: ihpibcheck:
! 218: movl #0,MMUCMD | make sure MMU is off
! 219: btst #5,SYSFLAG | do we have an internal HP-IB?
! 220: jeq boottype | yes, continue
! 221: clrl _C_LABEL(internalhpib) | no, clear the internal address
! 222: /*
! 223: * If this is a reboot, extract howto/bootdev stored by kernel
! 224: */
! 225: boottype:
! 226: cmpw #12,BOOTTYPE | is this a reboot (REQ_REBOOT)?
! 227: jne notreboot | no, skip
! 228: lea MAXADDR,a0 | find last page
! 229: movl a0@+,d7 | and extract howto, bootdev
! 230: movl a0@+,d6 | from where doboot() left them
! 231: jra boot1
! 232: /*
! 233: * At this point we do not know which logical device the MSUS select
! 234: * code refers to so we cannot construct bootdev. So we just punt
! 235: * and let configure() construct it.
! 236: */
! 237: notreboot:
! 238: moveq #0,d6 | make sure bootdev is invalid
! 239: cmpw #18,BOOTTYPE | does the user want to interact?
! 240: jeq askme | yes, go to it
! 241: moveq #0,d7 | default to RB_AUTOBOOT
! 242: jra boot1
! 243: askme:
! 244: moveq #3,d7 | default to RB_SINGLE|RB_ASKNAME
! 245: boot1:
! 246: movl d6,_C_LABEL(bootdev) | save bootdev and howto
! 247: movl d7,_C_LABEL(howto) | globally so all can access
! 248: movl LOWRAM,d0 | read lowram value from bootrom
! 249: /*
! 250: * Must preserve the scratch area for the BOOT ROM.
! 251: * Round up to the next 8k boundary.
! 252: */
! 253: addl #((2*NBPG)-1),d0
! 254: andl #-(2*NBPG),d0
! 255: movl d0,_C_LABEL(lowram) | stash that value
! 256: start:
! 257: movl #_C_LABEL(edata),a2 | start of BSS
! 258: movl #_C_LABEL(end),a3 | end
! 259: 1:
! 260: clrb a2@+ | clear BSS
! 261: cmpl a2,a3 | done?
! 262: bne 1b | no, keep going
! 263: jsr _C_LABEL(configure) | configure critical devices
! 264: jsr _C_LABEL(main) | lets go
! 265: GLOBAL(_rtt)
! 266: movl #3,_C_LABEL(howto) | restarts get RB_SINGLE|RB_ASKNAME
! 267: jmp start
! 268:
! 269: /*
! 270: * probe a location and see if it causes a bus error
! 271: */
! 272: ENTRY_NOPROFILE(badaddr)
! 273: movl BUSERR,_C_LABEL(_bsave) | save ROM bus error handler address
! 274: movl sp,_C_LABEL(_ssave) | and current stack pointer
! 275: movl #catchbad,BUSERR | plug in our handler
! 276: movl sp@(4),a0 | address to probe
! 277: movw a0@,d1 | do it
! 278: movl _C_LABEL(_bsave),BUSERR | if we got here, it did not fault
! 279: clrl d0 | return that this was not a bad addr
! 280: rts
! 281:
! 282: catchbad:
! 283: movl _C_LABEL(_bsave),BUSERR | got a bus error, so restore
! 284: | old handler
! 285: movl _C_LABEL(_ssave),sp | manually restore stack
! 286: moveq #1,d0 | indicate that we got a fault
! 287: rts | return to caller of badaddr()
! 288:
! 289: .data
! 290: GLOBAL(_bsave)
! 291: .long 0
! 292:
! 293: GLOBAL(_ssave)
! 294: .long 0
! 295:
! 296: ASENTRY_NOPROFILE(__trap)
! 297: moveml #0xFFFF,sp@- | save registers
! 298: movl sp,sp@- | push pointer to frame
! 299: jsr _C_LABEL(trap) | call C routine to deal with it
! 300: tstl d0
! 301: jeq Lstop
! 302: addql #4,sp
! 303: moveml sp@+,#0x7FFF
! 304: addql #8,sp
! 305: rte
! 306: Lstop:
! 307: stop #0x2700 | stop cold
! 308:
! 309: ASENTRY_NOPROFILE(nmi)
! 310: movw #18,BOOTTYPE | mark as system switch
! 311: jsr _C_LABEL(kbdnmi) | clear the interrupt, and
! 312: | reset the system
! 313: stop #0 | SCREEEECH!
! 314:
! 315: ENTRY_NOPROFILE(call_req_reboot)
! 316: jmp 0x1A4 | call ROM reboot function
! 317: rts | XXX: just in case?
! 318:
! 319: ENTRY_NOPROFILE(romout)
! 320: movl sp@(4),d0 | line number
! 321: movl sp@(8),a0 | string
! 322: jsr 0x150 | do it
! 323: rts
CVSweb