BSD 4_3_Net_2 release
[unix-history] / usr / src / sys / hp300 / stand / srt0.c
index 3423f32..2608d4b 100644 (file)
@@ -7,11 +7,37 @@
  * the Systems Programming Group of the University of Utah Computer
  * Science Department.
  *
  * the Systems Programming Group of the University of Utah Computer
  * Science Department.
  *
- * %sccs.include.redist.c%
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
  *
  *
- * from: Utah $Hdr: srt0.c 1.8 88/12/03$
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
  *
  *
- *     @(#)srt0.c      7.2 (Berkeley) %G%
+ * from: Utah $Hdr: srt0.c 1.12 91/04/25$
+ *
+ *     @(#)srt0.c      7.4 (Berkeley) 5/7/91
  */
 
 /*
  */
 
 /*
        .globl  _edata
        .globl  _main
        .globl  _configure
        .globl  _edata
        .globl  _main
        .globl  _configure
-       .globl  _openfirst
+       .globl  _bootdev
+       .globl  _firstopen
        .globl  __rtt
        .globl  __rtt
-       .globl  _lowram,_howto,_devtype,_internalhpib
+       .globl  _lowram,_howto,_devtype,_internalhpib,_machineid
 
        STACK =    0xfffff000   | below the ROM page
        BOOTTYPE = 0xfffffdc0
 
        STACK =    0xfffff000   | below the ROM page
        BOOTTYPE = 0xfffffdc0
        BUSERR =   0xfffffffc
        MAXADDR =  0xfffff000
        NBPG =     4096
        BUSERR =   0xfffffffc
        MAXADDR =  0xfffff000
        NBPG =     4096
+       MMUCMD =   0x005f400c   | MMU command/status register
 
        .data
 
        .data
-_lowram:
+_bootdev:
+       .long   0
+_devtype:
        .long   0
 _howto:
        .long   0
        .long   0
 _howto:
        .long   0
-_devtype:
+_lowram:
+       .long   0
+_machineid:
        .long   0
 
        .text
        .long   0
 
        .text
@@ -57,9 +89,59 @@ vecloop:
        dbf     d0,vecloop      | go til done
        movl    #NMIRESET,a0    | NMI keyboard reset addr
        movl    #nmi,a0@        | catch in reset routine
        dbf     d0,vecloop      | go til done
        movl    #NMIRESET,a0    | NMI keyboard reset addr
        movl    #nmi,a0@        | catch in reset routine
+/*
+ * Determine our CPU type and look for internal HP-IB
+ * (really only care about detecting 320 (no DIO-II) right now).
+ */
+       lea     _machineid,a0
+       movl    #0x808,d0
+       movc    d0,cacr         | clear and disable on-chip cache(s)
+       movl    #0x200,d0       | data freeze bit
+       movc    d0,cacr         |   only exists on 68030
+       movc    cacr,d0         | read it back
+       tstl    d0              | zero?
+       jeq     is68020         | yes, we have 68020
+       movl    #0x808,d0
+       movc    d0,cacr         | clear data freeze bit again
+       movl    #0x80,MMUCMD    | set magic cookie
+       movl    MMUCMD,d0       | read it back
+       btst    #7,d0           | cookie still on?
+       jeq     not370          | no, 360 or 375
+       movl    #4,a0@          | consider a 370 for now
+       movl    #0,MMUCMD       | clear magic cookie
+       movl    MMUCMD,d0       | read it back
+       btst    #7,d0           | still on?
+       jeq     ihpibcheck      | no, a 370
+       movl    #5,a0@          | yes, must be a 340
+       jra     ihpibcheck
+not370:
+       movl    #3,a0@          | type is at least a 360
+       movl    #0,MMUCMD       | clear magic cookie2
+       movl    MMUCMD,d0       | read it back
+       btst    #16,d0          | still on?
+       jeq     ihpibcheck      | no, a 360
+       movl    #6,a0@          | yes, must be a 345/375/400
+       jra     ihpibcheck
+is68020:
+       movl    #1,a0@          | consider a 330 for now
+       movl    #1,MMUCMD       | a 68020, write HP MMU location
+       movl    MMUCMD,d0       | read it back
+       btst    #0,d0           | zero?
+       jeq     ihpibcheck      | yes, a 330
+       movl    #0,a0@          | no, consider a 320 for now
+       movl    #0x80,MMUCMD    | set magic cookie
+       movl    MMUCMD,d0       | read it back
+       btst    #7,d0           | cookie still on?
+       jeq     ihpibcheck      | no, just a 320
+       movl    #2,a0@          | yes, a 350
+ihpibcheck:
+       movl    #0,MMUCMD       | make sure MMU is off
        btst    #5,SYSFLAG      | do we have an internal HP-IB?
        jeq     boottype        | yes, continue
        clrl    _internalhpib   | no, clear the internal address
        btst    #5,SYSFLAG      | do we have an internal HP-IB?
        jeq     boottype        | yes, continue
        clrl    _internalhpib   | no, clear the internal address
+/*
+ * If this is a reboot, extract howto/devtype stored by kernel
+ */
 boottype:
        cmpw    #12,BOOTTYPE    | is this a reboot (REQ_REBOOT)?
        jne     notreboot       | no, skip
 boottype:
        cmpw    #12,BOOTTYPE    | is this a reboot (REQ_REBOOT)?
        jne     notreboot       | no, skip
@@ -104,7 +186,7 @@ clr:
        cmpl    a2,a3           | done?
        bne     clr             | no, keep going
        jsr     _configure      | configure critical devices
        cmpl    a2,a3           | done?
        bne     clr             | no, keep going
        jsr     _configure      | configure critical devices
-       movl    #1,_openfirst   | mark this as the first open
+       movl    #1,_firstopen   | mark this as the first open
        jsr     _main           | lets go
 __rtt:
        movl    #3,_howto       | restarts get RB_SINGLE|RB_ASKNAME
        jsr     _main           | lets go
 __rtt:
        movl    #3,_howto       | restarts get RB_SINGLE|RB_ASKNAME