141488Smckusick /* 241488Smckusick * Copyright (c) 1988 University of Utah. 341488Smckusick * Copyright (c) 1982, 1990 The Regents of the University of California. 441488Smckusick * All rights reserved. 541488Smckusick * 641488Smckusick * This code is derived from software contributed to Berkeley by 741488Smckusick * the Systems Programming Group of the University of Utah Computer 841488Smckusick * Science Department. 941488Smckusick * 1041488Smckusick * %sccs.include.redist.c% 1141488Smckusick * 1241488Smckusick * from: Utah $Hdr: srt0.c 1.8 88/12/03$ 1341488Smckusick * 14*42378Smckusick * @(#)srt0.c 7.2 (Berkeley) 05/25/90 1541488Smckusick */ 1641488Smckusick 1741488Smckusick /* 1841488Smckusick * Startup code for standalone system 1941488Smckusick */ 2041488Smckusick 2141488Smckusick .globl begin 2241488Smckusick .globl _end 2341488Smckusick .globl _edata 2441488Smckusick .globl _main 2541488Smckusick .globl _configure 2641488Smckusick .globl _openfirst 2741488Smckusick .globl __rtt 28*42378Smckusick .globl _lowram,_howto,_devtype,_internalhpib 2941488Smckusick 3041488Smckusick STACK = 0xfffff000 | below the ROM page 3141488Smckusick BOOTTYPE = 0xfffffdc0 3241488Smckusick LOWRAM = 0xfffffdce 33*42378Smckusick SYSFLAG = 0xfffffed2 | system flags 3441488Smckusick MSUS = 0xfffffedc | MSUS (?) structure 3541488Smckusick VECTORS = 0xfffffee0 | beginning of jump vectors 3641488Smckusick NMIRESET = 0xffffff9c | reset vector 3741488Smckusick BUSERR = 0xfffffffc 3841488Smckusick MAXADDR = 0xfffff000 3941488Smckusick NBPG = 4096 4041488Smckusick 4141488Smckusick .data 4241488Smckusick _lowram: 4341488Smckusick .long 0 4441488Smckusick _howto: 4541488Smckusick .long 0 4641488Smckusick _devtype: 4741488Smckusick .long 0 4841488Smckusick 4941488Smckusick .text 5041488Smckusick begin: 5141488Smckusick movl #STACK,sp 5241488Smckusick moveq #47,d0 | # of vectors - 1 5341488Smckusick movl #VECTORS+2,a0 | addr part of first vector 5441488Smckusick vecloop: 5541488Smckusick movl #trap,a0@ | make it direct to trap 5641488Smckusick addql #6,a0 | move to next vector addr 5741488Smckusick dbf d0,vecloop | go til done 5841488Smckusick movl #NMIRESET,a0 | NMI keyboard reset addr 5941488Smckusick movl #nmi,a0@ | catch in reset routine 60*42378Smckusick btst #5,SYSFLAG | do we have an internal HP-IB? 61*42378Smckusick jeq boottype | yes, continue 62*42378Smckusick clrl _internalhpib | no, clear the internal address 63*42378Smckusick boottype: 6441488Smckusick cmpw #12,BOOTTYPE | is this a reboot (REQ_REBOOT)? 6541488Smckusick jne notreboot | no, skip 6641488Smckusick movl #MAXADDR,a0 | find last page 6741488Smckusick movl a0@+,d7 | and extract howto, devtype 6841488Smckusick movl a0@+,d6 | from where doboot() left them 6941488Smckusick jra boot1 7041488Smckusick /* 7141488Smckusick * At this point we do not know which logical hpib the given select 7241488Smckusick * code refers to. So we just put the select code in the adaptor field 7341488Smckusick * where hpibinit() can replace it with the logical hpib number. 7441488Smckusick * Note that this may clobber the B_DEVMAGIC field but that isn't set 7541488Smckusick * til later anyway. 7641488Smckusick */ 7741488Smckusick notreboot: 7841488Smckusick cmpw #18,BOOTTYPE | does the user want to interact? 7941488Smckusick jeq askme | yes, go to it 8041488Smckusick movl MSUS,d1 | no, get rom info 8141488Smckusick movw d1,d6 | MSUS comes with SC in upper, unit in lower 8241488Smckusick swap d6 | put in place 8341488Smckusick movw #2,d6 | assume 'a' partition of rd disk 8441488Smckusick moveq #0,d7 | default to RB_AUTOBOOT 8541488Smckusick jra boot1 8641488Smckusick askme: 8741488Smckusick moveq #7,d6 | default to HP-IB at sc7 8841488Smckusick lslw #8,d6 | position as adaptor number 8941488Smckusick swap d6 | put in place (note implied unit 0) 9041488Smckusick movw #2,d6 | assume 'a' partition of rd disk 9141488Smckusick moveq #3,d7 | default to RB_SINGLE|RB_ASKNAME 9241488Smckusick boot1: 9341488Smckusick movl d6,_devtype | save devtype and howto 9441488Smckusick movl d7,_howto | globally so all can access 9541488Smckusick movl LOWRAM,d0 | read lowram value from bootrom 9641488Smckusick addl #NBPG,d0 | must preserve this for bootrom to reboot 9741488Smckusick andl #0xfffff000,d0 | round to next page 9841488Smckusick movl d0,_lowram | stash that value 9941488Smckusick start: 10041488Smckusick movl #_edata,a2 | start of BSS 10141488Smckusick movl #_end,a3 | end 10241488Smckusick clr: 10341488Smckusick clrb a2@+ | clear BSS 10441488Smckusick cmpl a2,a3 | done? 10541488Smckusick bne clr | no, keep going 10641488Smckusick jsr _configure | configure critical devices 10741488Smckusick movl #1,_openfirst | mark this as the first open 10841488Smckusick jsr _main | lets go 10941488Smckusick __rtt: 11041488Smckusick movl #3,_howto | restarts get RB_SINGLE|RB_ASKNAME 11141488Smckusick jmp start 11241488Smckusick 11341488Smckusick /* 11441488Smckusick * probe a location and see if it causes a bus error 11541488Smckusick */ 11641488Smckusick .globl _badaddr 11741488Smckusick _badaddr: 11841488Smckusick movl BUSERR,__bsave | save ROM bus error handler address 11941488Smckusick movl sp,__ssave | and current stack pointer 12041488Smckusick movl #catchbad,BUSERR| plug in our handler 12141488Smckusick movl sp@(4),a0 | address to probe 12241488Smckusick movw a0@,d1 | do it 12341488Smckusick movl __bsave,BUSERR | if we got here, it didn't fault 12441488Smckusick clrl d0 | return that this was not a bad addr 12541488Smckusick rts 12641488Smckusick 12741488Smckusick catchbad: 12841488Smckusick movl __bsave,BUSERR | got a bus error, so restore old handler 12941488Smckusick movl __ssave,sp | manually restore stack 13041488Smckusick moveq #1,d0 | indicate that we got a fault 13141488Smckusick rts | return to caller of badaddr() 13241488Smckusick 13341488Smckusick __bsave: 13441488Smckusick .long 0 13541488Smckusick __ssave: 13641488Smckusick .long 0 13741488Smckusick 13841488Smckusick .globl _trap 13941488Smckusick trap: 14041488Smckusick moveml #0xFFFF,sp@- | save registers 14141488Smckusick movl sp,sp@- | push pointer to frame 14241488Smckusick jsr _trap | call C routine to deal with it 14341488Smckusick stop #0x2700 | stop cold 14441488Smckusick 14541488Smckusick nmi: 14641488Smckusick movw #18,BOOTTYPE | mark as system switch 14741488Smckusick jsr _kbdnmi | clear the interrupt 14841488Smckusick jra begin | start over 14941488Smckusick 15041488Smckusick #ifdef ROMPRF 15141488Smckusick .globl _romout 15241488Smckusick _romout: 15341488Smckusick movl sp@(4),d0 | line number 15441488Smckusick movl sp@(8),a0 | string 15541488Smckusick jsr 0x150 | do it 15641488Smckusick rts 15741488Smckusick #endif 158