summaryrefslogtreecommitdiff
path: root/sys/arch/hp300/stand
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1995-10-18 08:53:40 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1995-10-18 08:53:40 +0000
commitd6583bb2a13f329cf0332ef2570eb8bb8fc0e39c (patch)
treeece253b876159b39c620e62b6c9b1174642e070e /sys/arch/hp300/stand
initial import of NetBSD tree
Diffstat (limited to 'sys/arch/hp300/stand')
-rw-r--r--sys/arch/hp300/stand/Makefile175
-rw-r--r--sys/arch/hp300/stand/autoconf.c249
-rw-r--r--sys/arch/hp300/stand/boot.c101
-rw-r--r--sys/arch/hp300/stand/clock.c151
-rw-r--r--sys/arch/hp300/stand/conf.c154
-rw-r--r--sys/arch/hp300/stand/cons.c126
-rw-r--r--sys/arch/hp300/stand/consdefs.h62
-rw-r--r--sys/arch/hp300/stand/ct.c288
-rw-r--r--sys/arch/hp300/stand/dca.c151
-rw-r--r--sys/arch/hp300/stand/dcm.c172
-rw-r--r--sys/arch/hp300/stand/devopen.c210
-rw-r--r--sys/arch/hp300/stand/fhpib.c192
-rw-r--r--sys/arch/hp300/stand/hil.c262
-rw-r--r--sys/arch/hp300/stand/hpib.c155
-rw-r--r--sys/arch/hp300/stand/hpibvar.h61
-rw-r--r--sys/arch/hp300/stand/if_le.c669
-rw-r--r--sys/arch/hp300/stand/installboot.sh26
-rw-r--r--sys/arch/hp300/stand/ite.c314
-rw-r--r--sys/arch/hp300/stand/ite_dv.c254
-rw-r--r--sys/arch/hp300/stand/ite_gb.c199
-rw-r--r--sys/arch/hp300/stand/ite_hy.c368
-rw-r--r--sys/arch/hp300/stand/ite_rb.c196
-rw-r--r--sys/arch/hp300/stand/ite_subr.c145
-rw-r--r--sys/arch/hp300/stand/ite_tc.c181
-rw-r--r--sys/arch/hp300/stand/libsa/Makefile36
-rw-r--r--sys/arch/hp300/stand/libsa/Makefile.inc23
-rw-r--r--sys/arch/hp300/stand/machdep.c157
-rw-r--r--sys/arch/hp300/stand/mkboot.c334
-rw-r--r--sys/arch/hp300/stand/netboot.c162
-rw-r--r--sys/arch/hp300/stand/netio.c242
-rw-r--r--sys/arch/hp300/stand/nhpib.c205
-rw-r--r--sys/arch/hp300/stand/pboot.c161
-rw-r--r--sys/arch/hp300/stand/prf.c75
-rw-r--r--sys/arch/hp300/stand/rd.c409
-rw-r--r--sys/arch/hp300/stand/rominfo.h68
-rw-r--r--sys/arch/hp300/stand/samachdep.h79
-rw-r--r--sys/arch/hp300/stand/scsi.c459
-rw-r--r--sys/arch/hp300/stand/scsivar.h51
-rw-r--r--sys/arch/hp300/stand/sd.c256
-rw-r--r--sys/arch/hp300/stand/srt0.s263
-rw-r--r--sys/arch/hp300/stand/sys_inst.c589
-rw-r--r--sys/arch/hp300/stand/tgets.c92
-rw-r--r--sys/arch/hp300/stand/volhdr.h81
43 files changed, 8603 insertions, 0 deletions
diff --git a/sys/arch/hp300/stand/Makefile b/sys/arch/hp300/stand/Makefile
new file mode 100644
index 00000000000..1f5776a17b4
--- /dev/null
+++ b/sys/arch/hp300/stand/Makefile
@@ -0,0 +1,175 @@
+# $NetBSD: Makefile,v 1.18 1995/09/23 17:40:54 thorpej Exp $
+
+# @(#)Makefile 8.1 (Berkeley) 6/10/93
+
+NOPROG= noprog
+NOMAN= noman
+
+SUBDIR= libsa
+
+# RELOC=FFF00000 allows for boot prog up to FF000 (1044480) bytes long
+RELOC= FFF00000
+
+CONS= -DDCACONSOLE -DITECONSOLE -DDCMCONSOLE
+DEFS= -DSTANDALONE -DCOMPAT_NOLABEL ${CONS} -Dhp300 # -DROMPRF
+#DEFS+= -DNETIF_DEBUG -DRPC_DEBUG -DNFS_DEBUG -DRARP_DEBUG -DNET_DEBUG
+#DEFS+= -DLE_DEBUG
+CFLAGS= -O3 ${INCPATH} ${DEFS}
+
+SRCS= autoconf.c cons.c devopen.c machdep.c prf.c
+OBJS= ${SRCS:N*.h:R:S/$/.o/g}
+DSRCS= ct.c dca.c dcm.c fhpib.c hil.c hpib.c if_le.c \
+ ite.c ite_dv.c ite_gb.c ite_rb.c ite_subr.c ite_tc.c ite_hy.c \
+ nhpib.c rd.c scsi.c sd.c
+DOBJS= ${DSRCS:N*.h:R:S/$/.o/g}
+
+S= ${.CURDIR}/../../..
+
+.PATH: ${S}/arch/${MACHINE_ARCH}/${MACHINE_ARCH}
+.PATH: ${S}/stand
+
+INCPATH=-I${.CURDIR} -I${.CURDIR}/../.. -I${S} -I${S}/lib/libsa
+### find out what to use for libkern
+KERNREL=
+.include "$S/lib/libkern/Makefile.inc"
+LIBKERN= ${KERNLIB}
+
+.include "${.CURDIR}/libsa/Makefile.inc"
+LIBSA= ${SA_LIB}
+
+LIBS= ${OBJS} libdrive.a ${LIBSA} ${LIBKERN}
+
+BOOTS= pboot netboot sys_inst dboot dcopy tboot tcopy cat #ls
+ALL= ${BOOTS} mkboot installboot
+
+all: ${ALL}
+
+${BOOTS}: ${LIBS}
+
+libdrive.a: ${DOBJS}
+ rm -f $@
+ ${AR} cq $@ ${DOBJS}
+ ${RANLIB} $@
+
+# depend on DEFS
+
+devopen.o machdep.o srt0.o: Makefile
+cons.o dca.o hil.o: Makefile
+ite.o ite_subr.o ite_dv.o ite_gb.o ite_hy.o ite_rb.o ite_tc.o: Makefile
+
+# startups
+
+srt0.o: ${.CURDIR}/srt0.s
+ ${CC} ${INCPATH} ${DEFS} -c ${.CURDIR}/srt0.s
+
+tpsrt0.o: ${.CURDIR}/srt0.s
+ ${CC} ${INCPATH} ${DEFS} -DTP -c ${.CURDIR}/srt0.s -o $@
+
+# new boot
+pboot: srt0.o pboot.o tgets.o conf.o ${LIBS}
+ ${LD} -N -T ${RELOC} -e begin srt0.o pboot.o tgets.o conf.o ${LIBS} -o $@
+ @size $@
+ @echo $@ total size should not exceed 1044480 bytes
+
+ls: srt0.o ls.o conf.o ${LIBS}
+ ${LD} -N -T ${RELOC} -e begin srt0.o ls.o conf.o ${LIBS} -o $@
+ @size $@
+ @echo $@ total size should not exceed 1044480 bytes
+
+cat: srt0.o cat.o conf.o ${LIBS}
+ ${LD} -N -T ${RELOC} -e begin srt0.o cat.o conf.o ${LIBS} -o $@
+ @size $@
+ @echo $@ total size should not exceed 1044480 bytes
+
+# installation
+sys_inst: srt0.o sys_inst.o clock.o instconf.o inst_netio.o tgets.o ${LIBS}
+ ${LD} -N -T ${RELOC} -e begin srt0.o sys_inst.o clock.o instconf.o inst_netio.o tgets.o ${LIBS} -o $@
+ @size $@
+ @echo $@ total size should not exceed 1044480 bytes
+
+instconf.o: ${.CURDIR}/conf.c
+ ${CC} ${CFLAGS} -DSYS_INST -c ${.CURDIR}/conf.c -o $@
+
+inst_netio.o: ${.CURDIR}/netio.c
+ ${CC} ${CFLAGS} -DSYS_INST -c ${.CURDIR}/netio.c -o $@
+
+# bootable from network
+
+netboot: srt0.o netboot.o clock.o netconf.o netio.o tgets.o ${LIBS}
+ ${LD} -N -T ${RELOC} -e begin srt0.o netboot.o clock.o netconf.o netio.o tgets.o ${LIBS} -o $@
+ @size $@
+ @echo $@ total size should not exceed 1044480 bytes
+
+netconf.o: ${.CURDIR}/conf.c
+ ${CC} ${CFLAGS} -DNETBOOT -c ${.CURDIR}/conf.c -o $@
+
+# bootable from tape
+
+tboot: srt0.o tboot.o conf.o ${LIBS}
+ ${LD} -N -T ${RELOC} -e begin srt0.o tboot.o conf.o ${LIBS} -o $@
+ @size $@
+ @echo $@ total size should not exceed 1044480 bytes
+
+tboot.o: ${.CURDIR}/boot.c
+ ${CC} ${CFLAGS} -DJUSTASK -c ${.CURDIR}/boot.c -o $@
+
+tcopy: tpsrt0.o copy.o conf.o ${LIBS}
+ ${LD} -N -T ${RELOC} -e begin tpsrt0.o copy.o conf.o ${LIBS} -o $@
+ @size $@
+ @echo $@ total size should not exceed 1044480 bytes
+
+# bootable from floppy or real disks
+
+dboot: srt0.o boot.o tapeconf.o ${LIBS}
+ ${LD} -N -T ${RELOC} -e begin srt0.o boot.o tapeconf.o ${LIBS} -o $@
+ @size $@
+ @echo $@ text+data size should not exceed 57344 bytes
+ @echo $@ total size should not exceed 1044480 bytes
+
+tapeconf.o: ${.CURDIR}/conf.c
+ ${CC} ${CFLAGS} -DTAPEBOOT -c ${.CURDIR}/conf.c -o $@
+
+dcopy: srt0.o copy.o conf.o ${LIBS}
+ ${LD} -N -T ${RELOC} -e begin srt0.o copy.o conf.o ${LIBS} -o $@
+
+mkboot: ${.CURDIR}/mkboot.c
+ ${CC} ${CFLAGS} ${.CURDIR}/mkboot.c -o $@
+
+installboot: ${.CURDIR}/installboot.sh
+ @rm -f installboot
+ cp -p ${.CURDIR}/installboot.sh installboot
+
+# utilities
+
+clean::
+ rm -f *.o *.exe *.i errs make.out
+ rm -f a.out pboot cat ls tboot tcopy
+ rm -f boot[a-z]? boot[a-wyz][a-z].c conf[a-wyz][a-z].c
+ rm -f core sboot
+ rm -f libdrive.a mkboot dboot dcopy installboot *.lif
+
+install: mkboot installboot ${ALL}
+ ./mkboot pboot netbsdboot.lif
+ ./mkboot netboot netboot.lif
+ ./mkboot sys_inst sys_inst.lif
+ ./mkboot dboot diskboot.lif
+ ./mkboot tboot tcopy tapeboot.lif
+ install -c -o bin -g bin -m 555 installboot ${DESTDIR}/usr/mdec
+ install -c -o bin -g bin -m 444 netbsdboot.lif ${DESTDIR}/usr/mdec/rdboot
+ rm -f ${DESTDIR}/usr/mdec/bootrd
+ ln ${DESTDIR}/usr/mdec/rdboot ${DESTDIR}/usr/mdec/bootrd
+ rm -f ${DESTDIR}/usr/mdec/sdboot
+ ln ${DESTDIR}/usr/mdec/rdboot ${DESTDIR}/usr/mdec/sdboot
+ rm -f ${DESTDIR}/usr/mdec/bootsd
+ ln ${DESTDIR}/usr/mdec/sdboot ${DESTDIR}/usr/mdec/bootsd
+ install -d -m 755 -o bin -g bin ${DESTDIR}/usr/mdec/rbootd
+ install -c -o bin -g bin -m 444 netboot.lif ${DESTDIR}/usr/mdec/rbootd/SYS_NBOOT
+ install -c -o bin -g bin -m 444 sys_inst.lif ${DESTDIR}/usr/mdec/rbootd/SYS_INST
+ install -c -o bin -g bin -m 644 tapeboot.lif ${DESTDIR}/usr/mdec/bootct
+# install -o bin -g bin -m 755 -d ${DESTDIR}/sys/hpdist/tp
+# install -o bin -g bin -m 444 netbsdboot.lif ${DESTDIR}/sys/hpdist/tp
+# install -o bin -g bin -m 444 tapeboot.lif ${DESTDIR}/sys/hpdist/tp
+# install -o bin -g bin -m 444 diskboot.lif ${DESTDIR}/sys/hpdist/tp
+
+.include <bsd.prog.mk>
+.include <bsd.subdir.mk>
diff --git a/sys/arch/hp300/stand/autoconf.c b/sys/arch/hp300/stand/autoconf.c
new file mode 100644
index 00000000000..17f3c20107c
--- /dev/null
+++ b/sys/arch/hp300/stand/autoconf.c
@@ -0,0 +1,249 @@
+/* $NetBSD: autoconf.c,v 1.9 1995/08/05 16:47:34 thorpej Exp $ */
+
+/*
+ * Copyright (c) 1988 University of Utah.
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * from: Utah Hdr: autoconf.c 1.16 92/05/29
+ *
+ * @(#)autoconf.c 8.1 (Berkeley) 6/10/93
+ */
+
+#include <sys/param.h>
+#include <sys/reboot.h>
+
+#include <hp300/stand/samachdep.h>
+#include <hp300/stand/rominfo.h>
+
+#include <hp300/dev/device.h>
+#include <hp300/dev/grfvar.h>
+#include <hp300/dev/grfreg.h>
+
+/*
+ * Mapping of ROM MSUS types to BSD major device numbers
+ * WARNING: major numbers must match bdevsw indices in hp300/conf.c.
+ */
+char rom2mdev[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0-13: none */
+ 4, /* 14: SCSI disk */
+ 0, /* 15: none */
+ 2, /* 16: CS/80 device on HPIB */
+ 2, /* 17: CS/80 device on HPIB */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 18-31: none */
+};
+
+struct hp_hw sc_table[MAXCTLRS];
+int cpuspeed;
+
+extern int internalhpib;
+
+#if 0
+printrominfo()
+{
+ struct rominfo *rp = (struct rominfo *)ROMADDR;
+
+ printf("boottype %x, name %s, lowram %x, sysflag %x\n",
+ rp->boottype, rp->name, rp->lowram, rp->sysflag&0xff);
+ printf("rambase %x, ndrives %x, sysflag2 %x, msus %x\n",
+ rp->rambase, rp->ndrives, rp->sysflag2&0xff, rp->msus);
+}
+#endif
+
+configure()
+{
+ u_long msustobdev();
+
+ switch (machineid) {
+ case HP_320:
+ case HP_330:
+ case HP_340:
+ cpuspeed = MHZ_16;
+ break;
+ case HP_350:
+ case HP_360:
+ cpuspeed = MHZ_25;
+ break;
+ case HP_370:
+ cpuspeed = MHZ_33;
+ break;
+ case HP_375:
+ cpuspeed = MHZ_50;
+ break;
+ case HP_380:
+ cpuspeed = MHZ_25 * 2; /* XXX */
+ break;
+ case HP_433:
+ cpuspeed = MHZ_33 * 2; /* XXX */
+ break;
+ default: /* assume the fastest (largest delay value) */
+ cpuspeed = MHZ_50;
+ break;
+ }
+ find_devs();
+ cninit();
+#if 0
+ printrominfo();
+#endif
+ hpibinit();
+ scsiinit();
+ if ((bootdev & B_MAGICMASK) != B_DEVMAGIC)
+ bootdev = msustobdev();
+}
+
+/*
+ * Convert HP MSUS to a valid bootdev layout:
+ * TYPE comes from MSUS device type as mapped by rom2mdev
+ * PARTITION is set to 0 ('a')
+ * UNIT comes from MSUS unit (almost always 0)
+ * CONTROLLER comes from MSUS primary address
+ * ADAPTER comes from SCSI/HPIB driver logical unit number
+ * (passed back via unused hw_pa field)
+ */
+u_long
+msustobdev()
+{
+ struct rominfo *rp = (struct rominfo *) ROMADDR;
+ u_long bdev = 0;
+ register struct hp_hw *hw;
+ int sc;
+
+ sc = (rp->msus >> 8) & 0xFF;
+ for (hw = sc_table; hw < &sc_table[MAXCTLRS]; hw++)
+ if (hw->hw_sc == sc)
+ break;
+ bdev |= rom2mdev[(rp->msus >> 24) & 0x1F] << B_TYPESHIFT;
+ bdev |= 0 << B_PARTITIONSHIFT;
+ bdev |= ((rp->msus >> 16) & 0xFF) << B_UNITSHIFT;
+ bdev |= (rp->msus & 0xFF) << B_CONTROLLERSHIFT;
+ bdev |= (int)hw->hw_pa << B_ADAPTORSHIFT;
+ bdev |= B_DEVMAGIC;
+#if 0
+ printf("msus %x -> bdev %x\n", rp->msus, bdev);
+#endif
+ return (bdev);
+}
+
+sctoaddr(sc)
+ int sc;
+{
+ if (sc == -1)
+ return(GRFIADDR);
+ if (sc == 7 && internalhpib)
+ return(internalhpib);
+ if (sc < 32)
+ return(DIOBASE + sc * DIOCSIZE);
+ if (sc >= 132)
+ return(DIOIIBASE + (sc - 132) * DIOIICSIZE);
+ return(sc);
+}
+
+/*
+ * Probe all DIO select codes (0 - 32), the internal display address,
+ * and DIO-II select codes (132 - 256).
+ *
+ * Note that we only care about displays, SCSIs and HP-IBs.
+ */
+find_devs()
+{
+ short sc, sctop;
+ u_char *id_reg;
+ register caddr_t addr;
+ register struct hp_hw *hw;
+
+ hw = sc_table;
+ sctop = machineid == HP_320 ? 32 : 256;
+ for (sc = -1; sc < sctop; sc++) {
+ if (sc >= 32 && sc < 132)
+ continue;
+ addr = (caddr_t) sctoaddr(sc);
+ if (badaddr(addr))
+ continue;
+
+ id_reg = (u_char *) addr;
+ hw->hw_pa = 0; /* XXX used to pass back LUN from driver */
+ if (sc >= 132)
+ hw->hw_size = (id_reg[0x101] + 1) * 0x100000;
+ else
+ hw->hw_size = DIOCSIZE;
+ hw->hw_kva = addr;
+ hw->hw_id = id_reg[1];
+ hw->hw_sc = sc;
+
+ /*
+ * Not all internal HP-IBs respond rationally to id requests
+ * so we just go by the "internal HPIB" indicator in SYSFLAG.
+ */
+ if (sc == 7 && internalhpib) {
+ hw->hw_type = C_HPIB;
+ hw++;
+ continue;
+ }
+
+ switch (hw->hw_id) {
+ case 5: /* 98642A */
+ case 5+128: /* 98642A remote */
+ hw->hw_type = D_COMMDCM;
+ break;
+ case 8: /* 98625B */
+ case 128: /* 98624A */
+ hw->hw_type = C_HPIB;
+ break;
+ case 57: /* Displays */
+ hw->hw_type = D_BITMAP;
+ hw->hw_secid = id_reg[0x15];
+ switch (hw->hw_secid) {
+ case 4: /* renaissance */
+ case 8: /* davinci */
+ sc++; /* occupy 2 select codes */
+ break;
+ }
+ break;
+ case 9:
+ hw->hw_type = D_KEYBOARD;
+ break;
+ case 7:
+ case 7+32:
+ case 7+64:
+ case 7+96:
+ hw->hw_type = C_SCSI;
+ break;
+ default: /* who cares */
+ hw->hw_type = D_MISC;
+ break;
+ }
+ hw++;
+ }
+}
diff --git a/sys/arch/hp300/stand/boot.c b/sys/arch/hp300/stand/boot.c
new file mode 100644
index 00000000000..7ddb6efb8fe
--- /dev/null
+++ b/sys/arch/hp300/stand/boot.c
@@ -0,0 +1,101 @@
+/* $NetBSD: boot.c,v 1.6 1995/02/21 09:06:13 mycroft Exp $ */
+
+/*-
+ * Copyright (c) 1982, 1986, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * @(#)boot.c 8.1 (Berkeley) 6/10/93
+ */
+
+#include <sys/param.h>
+#include <sys/reboot.h>
+#include <a.out.h>
+#include "stand.h"
+
+/*
+ * Boot program... bits in `howto' determine whether boot stops to
+ * ask for system name. Boot device is derived from ROM provided
+ * information.
+ */
+
+char line[100];
+
+extern u_int opendev;
+extern char *lowram;
+extern int noconsole;
+extern int howto, bootdev;
+
+main()
+{
+ int retry, type;
+
+ printf("%s CPU\nBoot\n", getmachineid());
+#ifdef JUSTASK
+ howto = RB_ASKNAME|RB_SINGLE;
+#else
+ if ((howto & RB_ASKNAME) == 0) {
+ type = (bootdev >> B_TYPESHIFT) & B_TYPEMASK;
+ if ((unsigned)type < ndevs && devsw[type].dv_name)
+ strcpy(line, "/netbsd");
+ else
+ howto |= RB_SINGLE|RB_ASKNAME;
+ }
+#endif
+ for (retry = 0;;) {
+ if (!noconsole && (howto & RB_ASKNAME)) {
+ printf(": ");
+ gets(line);
+ if (line[0] == 0) {
+ strcpy(line, "/netbsd");
+ printf(": %s\n", line);
+ }
+ } else
+ printf(": %s\n", line);
+ exec(line, lowram, howto);
+ printf("boot: %s\n", strerror(errno));
+ howto |= RB_SINGLE|RB_ASKNAME;
+ }
+}
+
+void
+machdep_start(entry, howto, loadaddr, ssym, esym)
+ char *entry;
+ int howto;
+ char *loadaddr;
+ char *ssym, *esym;
+{
+
+ asm("movl %0,d7" : : "m" (howto));
+ asm("movl %0,d6" : : "m" (opendev));
+ asm("movl %0,a5" : : "a" (loadaddr));
+ asm("movl %0,a4" : : "a" (esym));
+ (*((int (*)())entry))();
+}
diff --git a/sys/arch/hp300/stand/clock.c b/sys/arch/hp300/stand/clock.c
new file mode 100644
index 00000000000..f637c66244a
--- /dev/null
+++ b/sys/arch/hp300/stand/clock.c
@@ -0,0 +1,151 @@
+/* $NetBSD: clock.c,v 1.3 1995/02/20 00:12:09 mycroft Exp $ */
+
+/*
+ * Copyright (c) 1988 University of Utah.
+ * Copyright (c) 1982, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * from: Utah $Hdr: clock.c 1.18 91/01/21$
+ *
+ * @(#)clock.c 8.2 (Berkeley) 1/12/94
+ */
+
+#include <sys/param.h>
+#include "samachdep.h"
+#include <hp300/dev/hilreg.h>
+#include <hp300/hp300/clockreg.h>
+
+static int month_days[12] = {
+ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
+};
+
+u_char bbc_registers[13];
+u_char read_bbc_reg();
+struct hil_dev *bbcaddr = BBCADDR;
+
+getsecs()
+{
+ static int bbcinited = 0;
+ u_long timbuf = 0;
+
+ if (!bbc_to_gmt(&timbuf) && !bbcinited)
+ printf("WARNING: bad date in battery clock\n");
+ bbcinited = 1;
+
+ /* Battery clock does not store usec's, so forget about it. */
+ return(timbuf);
+}
+
+
+bbc_to_gmt(timbuf)
+ u_long *timbuf;
+{
+ register int i;
+ register u_long tmp;
+ int year, month, day, hour, min, sec;
+
+ read_bbc();
+
+ sec = bbc_to_decimal(1, 0);
+ min = bbc_to_decimal(3, 2);
+
+ /*
+ * Hours are different for some reason. Makes no sense really.
+ */
+ hour = ((bbc_registers[5] & 0x03) * 10) + bbc_registers[4];
+ day = bbc_to_decimal(8, 7);
+ month = bbc_to_decimal(10, 9);
+ year = bbc_to_decimal(12, 11) + 1900;
+
+ range_test(hour, 0, 23);
+ range_test(day, 1, 31);
+ range_test(month, 1, 12);
+ range_test(year, STARTOFTIME, 2000);
+
+ tmp = 0;
+
+ for (i = STARTOFTIME; i < year; i++)
+ tmp += days_in_year(i);
+ if (leapyear(year) && month > FEBRUARY)
+ tmp++;
+
+ for (i = 1; i < month; i++)
+ tmp += days_in_month(i);
+
+ tmp += (day - 1);
+ tmp = ((tmp * 24 + hour) * 60 + min) * 60 + sec;
+
+ *timbuf = tmp;
+ return(1);
+}
+
+read_bbc()
+{
+ register int i, read_okay;
+
+ read_okay = 0;
+ while (!read_okay) {
+ read_okay = 1;
+ for (i = 0; i <= NUM_BBC_REGS; i++)
+ bbc_registers[i] = read_bbc_reg(i);
+ for (i = 0; i <= NUM_BBC_REGS; i++)
+ if (bbc_registers[i] != read_bbc_reg(i))
+ read_okay = 0;
+ }
+}
+
+u_char
+read_bbc_reg(reg)
+ int reg;
+{
+ u_char data = reg;
+
+ if (bbcaddr) {
+#if 0
+ send_hil_cmd(bbcaddr, BBC_SET_REG, &data, 1, NULL);
+ send_hil_cmd(bbcaddr, BBC_READ_REG, NULL, 0, &data);
+#else
+ HILWAIT(bbcaddr);
+ bbcaddr->hil_cmd = BBC_SET_REG;
+ HILWAIT(bbcaddr);
+ bbcaddr->hil_data = data;
+ HILWAIT(bbcaddr);
+ bbcaddr->hil_cmd = BBC_READ_REG;
+ HILDATAWAIT(bbcaddr);
+ data = bbcaddr->hil_data;
+#endif
+ }
+ return(data);
+}
diff --git a/sys/arch/hp300/stand/conf.c b/sys/arch/hp300/stand/conf.c
new file mode 100644
index 00000000000..6e8fb07a7df
--- /dev/null
+++ b/sys/arch/hp300/stand/conf.c
@@ -0,0 +1,154 @@
+/* $NetBSD: conf.c,v 1.10 1995/09/23 17:28:11 thorpej Exp $ */
+
+/*
+ * Copyright (c) 1982, 1986, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * @(#)conf.c 8.1 (Berkeley) 6/10/93
+ */
+
+#include <sys/param.h>
+
+#include "stand.h"
+
+#if defined(NETBOOT) || defined(SYS_INST)
+#include <sys/socket.h>
+#include <net/if.h>
+#include <netinet/in.h>
+#include <netinet/if_ether.h>
+#include <netinet/in_systm.h>
+
+#include "nfs.h"
+
+#endif /* NETBOOT || SYS_INST */
+
+#ifndef NETBOOT
+#include "ufs.h"
+#endif /* ! NETBOOT */
+
+int debug = 0; /* XXX */
+
+/*
+ * Device configuration
+ */
+#if defined(NETBOOT) || defined(SYS_INST)
+int netstrategy __P((void *, int, daddr_t, size_t, void *, size_t *));
+int netopen __P((struct open_file *, ...));
+int netclose __P((struct open_file *));
+#define netioctl noioctl
+#endif /* NETBOOT || SYS_INST */
+
+#ifndef NETBOOT
+/* XXX: no support for tapes in SYS_INST yet. */
+#ifdef TAPEBOOT
+int ctstrategy __P((void *, int, daddr_t, size_t, void *, size_t *));
+int ctopen __P((struct open_file *, ...));
+int ctclose __P((struct open_file *));
+#else
+#define ctstrategy \
+ (int (*) __P((void *, int, daddr_t, size_t, void *, size_t *)))nullsys
+#define ctopen (int (*) __P((struct open_file *, ...)))nodev
+#define ctclose (int (*) __P((struct open_file *)))nullsys
+#endif /* TAPEBOOT */
+
+#define ctioctl noioctl
+
+int rdstrategy __P((void *, int, daddr_t, size_t, void *, size_t *));
+int rdopen __P((struct open_file *, ...));
+int rdclose __P((struct open_file *));
+#define rdioctl noioctl
+
+int sdstrategy __P((void *, int, daddr_t, size_t, void *, size_t *));
+int sdopen __P((struct open_file *, ...));
+int sdclose __P((struct open_file *));
+#define sdioctl noioctl
+
+#define xxstrategy \
+ (int (*) __P((void *, int, daddr_t, size_t, void *, size_t *)))nullsys
+#define xxopen (int (*) __P((struct open_file *, ...)))nodev
+#define xxclose (int (*) __P((struct open_file *)))nullsys
+
+#endif /* ! NETBOOT */
+
+struct devsw devsw[] = {
+#ifdef NETBOOT
+ { "le", netstrategy, netopen, netclose, netioctl }, /*0*/
+#else
+ { "ct", ctstrategy, ctopen, ctclose, ctioctl }, /*0*/
+ { "??", xxstrategy, xxopen, xxclose, noioctl }, /*1*/
+ { "rd", rdstrategy, rdopen, rdclose, rdioctl }, /*2*/
+ { "??", xxstrategy, xxopen, xxclose, noioctl }, /*3*/
+ { "sd", sdstrategy, sdopen, sdclose, sdioctl }, /*4*/
+#ifdef SYS_INST
+ { "le", netstrategy, netopen, netclose, netioctl },
+#endif /* SYS_INST */
+#endif /* NETBOOT */
+};
+int ndevs = (sizeof(devsw)/sizeof(devsw[0]));
+
+/*
+ * Filesystem configuration
+ */
+struct fs_ops file_system[] = {
+#ifndef NETBOOT
+ { ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek, ufs_stat },
+#endif /* ! NETBOOT */
+#if defined(NETBOOT) || defined(SYS_INST)
+ { nfs_open, nfs_close, nfs_read, nfs_write, nfs_seek, nfs_stat },
+#endif /* NETBOOT || SYS_INST */
+};
+
+int nfsys = (sizeof(file_system) / sizeof(file_system[0]));
+
+#if defined(NETBOOT) || defined(SYS_INST)
+extern struct netif_driver le_driver;
+
+struct netif_driver *netif_drivers[] = {
+ &le_driver,
+};
+int n_netif_drivers = sizeof(netif_drivers)/sizeof(netif_drivers[0]);
+#endif /* NETBOOT */
+
+/*
+ * Inititalize controllers
+ *
+ * XXX this should be a table
+ */
+void ctlrinit()
+{
+#if defined(NETBOOT) || defined(SYS_INST)
+ leinit();
+#endif /* NETBOOT || SYS_INST */
+#ifndef NETBOOT
+ hpibinit();
+ scsiinit();
+#endif /* ! NETBOOT */
+}
diff --git a/sys/arch/hp300/stand/cons.c b/sys/arch/hp300/stand/cons.c
new file mode 100644
index 00000000000..f35f1c2f1c4
--- /dev/null
+++ b/sys/arch/hp300/stand/cons.c
@@ -0,0 +1,126 @@
+/* $NetBSD: cons.c,v 1.9 1995/10/04 06:54:42 thorpej Exp $ */
+
+/*
+ * Copyright (c) 1988 University of Utah.
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * from: Utah Hdr: cons.c 1.7 92/02/28
+ *
+ * @(#)cons.c 8.1 (Berkeley) 6/10/93
+ */
+
+#include <sys/param.h>
+#include <dev/cons.h>
+
+#include <hp300/stand/consdefs.h>
+#include <hp300/stand/samachdep.h>
+
+struct consdev constab[] = {
+#ifdef ITECONSOLE
+ { iteprobe, iteinit, itegetchar, iteputchar },
+#endif
+#ifdef DCACONSOLE
+ { dcaprobe, dcainit, dcagetchar, dcaputchar },
+#endif
+#ifdef DCMCONSOLE
+ { dcmprobe, dcminit, dcmgetchar, dcmputchar },
+#endif
+ { 0 },
+};
+
+int curcons_scode; /* select code of device currently being probed */
+int cons_scode; /* final select code of console device */
+
+struct consdev *cn_tab;
+int noconsole;
+
+void
+cninit()
+{
+ register struct consdev *cp;
+
+ cn_tab = NULL;
+ noconsole = 1;
+ cons_scode = 256; /* larger than last valid select code */
+ for (cp = constab; cp->cn_probe; cp++) {
+ (*cp->cn_probe)(cp);
+ if (cp->cn_pri > CN_DEAD &&
+ (cn_tab == NULL || cp->cn_pri > cn_tab->cn_pri)) {
+ cn_tab = cp;
+ cons_scode = curcons_scode;
+ }
+ }
+ if (cn_tab) {
+ (*cn_tab->cn_init)(cn_tab);
+ noconsole = 0;
+#if 0
+ printf("console: ");
+ if (cons_scode == -1)
+ printf("internal grf\n");
+ else
+ printf("scode %d\n", cons_scode);
+#endif
+ }
+}
+
+int
+cngetc()
+{
+
+ /* Note: the dev_t arguments are not used! */
+ if (cn_tab)
+ return((*cn_tab->cn_getc)(0));
+ return(0);
+}
+
+int
+cnputc(c)
+ int c;
+{
+
+ /* Note: the dev_t arguments are not used! */
+#ifdef ROMPRF
+ extern int userom;
+
+ if (userom)
+ romputchar(c);
+ else
+#endif
+ if (cn_tab)
+ (*cn_tab->cn_putc)(0, c);
+
+ return (0);
+}
diff --git a/sys/arch/hp300/stand/consdefs.h b/sys/arch/hp300/stand/consdefs.h
new file mode 100644
index 00000000000..8a71e257345
--- /dev/null
+++ b/sys/arch/hp300/stand/consdefs.h
@@ -0,0 +1,62 @@
+/* $NetBSD: consdefs.h,v 1.3 1995/10/04 06:54:43 thorpej Exp $ */
+
+/*
+ * Copyright (c) 1982, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * 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.
+ *
+ * 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.
+ */
+
+/*
+ * Glue for determining console select code.
+ */
+extern int curcons_scode;
+extern int cons_scode;
+
+/*
+ * Console routine prototypes.
+ */
+#ifdef ITECONSOLE
+void iteprobe __P((struct consdev *));
+void iteinit __P((struct consdev *));
+int itegetchar __P((dev_t));
+void iteputchar __P((dev_t, int));
+#endif
+#ifdef DCACONSOLE
+void dcaprobe __P((struct consdev *));
+void dcainit __P((struct consdev *));
+int dcagetchar __P((dev_t));
+void dcaputchar __P((dev_t, int));
+#endif
+#ifdef DCMCONSOLE
+void dcmprobe __P((struct consdev *));
+void dcminit __P((struct consdev *));
+int dcmgetchar __P((dev_t));
+void dcmputchar __P((dev_t, int));
+#endif
diff --git a/sys/arch/hp300/stand/ct.c b/sys/arch/hp300/stand/ct.c
new file mode 100644
index 00000000000..ff9a6f3de1c
--- /dev/null
+++ b/sys/arch/hp300/stand/ct.c
@@ -0,0 +1,288 @@
+/* $NetBSD: ct.c,v 1.7 1995/09/23 17:17:03 thorpej Exp $ */
+
+/*
+ * Copyright (c) 1982, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * @(#)ct.c 8.1 (Berkeley) 7/15/93
+ */
+
+/*
+ * CS80 tape driver
+ */
+#include <sys/param.h>
+
+#include <hp300/dev/ctreg.h>
+
+#include "stand.h"
+#include "samachdep.h"
+
+struct ct_iocmd ct_ioc;
+struct ct_rscmd ct_rsc;
+struct ct_stat ct_stat;
+struct ct_ssmcmd ct_ssmc;
+
+struct ct_softc {
+ int sc_ctlr;
+ int sc_unit;
+ char sc_retry;
+ char sc_alive;
+ short sc_punit;
+ int sc_blkno;
+} ct_softc[NHPIB][NCT];
+
+#define CTRETRY 5
+#define MTFSF 10
+#define MTREW 11
+
+struct ctinfo {
+ short hwid;
+ short punit;
+} ctinfo[] = {
+ CT7946ID, 1,
+ CT7912PID, 1,
+ CT7914PID, 1,
+ CT9144ID, 0,
+ CT9145ID, 0,
+};
+int nctinfo = sizeof(ctinfo) / sizeof(ctinfo[0]);
+
+ctinit(ctlr, unit)
+ register int ctlr, unit;
+{
+ register struct ct_softc *rs = &ct_softc[ctlr][unit];
+ u_char stat;
+ register int type;
+
+ if (hpibrecv(ctlr, unit, C_QSTAT, &stat, 1) != 1 || stat)
+ return (0);
+ if (ctident(ctlr, unit) < 0)
+ return (0);
+ ct_ssmc.unit = C_SUNIT(rs->sc_punit);
+ ct_ssmc.cmd = C_SSM;
+ ct_ssmc.fefm = FEF_MASK;
+ ct_ssmc.refm = REF_MASK;
+ ct_ssmc.aefm = AEF_MASK;
+ ct_ssmc.iefm = IEF_MASK;
+ hpibsend(ctlr, unit, C_CMD, &ct_ssmc, sizeof(ct_ssmc));
+ hpibswait(ctlr, unit);
+ hpibrecv(ctlr, unit, C_QSTAT, &stat, 1);
+ rs->sc_alive = 1;
+ return (1);
+}
+
+ctident(ctlr, unit)
+ int ctlr, unit;
+{
+ struct ct_describe desc;
+ u_char stat, cmd[3];
+ char name[7];
+ int id, i;
+
+ id = hpibid(ctlr, unit);
+ if ((id & 0x200) == 0)
+ return(-1);
+ for (i = 0; i < nctinfo; i++)
+ if (id == ctinfo[i].hwid)
+ break;
+ if (i == nctinfo)
+ return(-1);
+ ct_softc[ctlr][unit].sc_punit = ctinfo[i].punit;
+ id = i;
+
+ /*
+ * Collect device description.
+ * Right now we only need this to differentiate 7945 from 7946.
+ * Note that we always issue the describe command to unit 0.
+ */
+ cmd[0] = C_SUNIT(0);
+ cmd[1] = C_SVOL(0);
+ cmd[2] = C_DESC;
+ hpibsend(ctlr, unit, C_CMD, cmd, sizeof(cmd));
+ hpibrecv(ctlr, unit, C_EXEC, &desc, 37);
+ hpibrecv(ctlr, unit, C_QSTAT, &stat, sizeof(stat));
+ bzero(name, sizeof(name));
+ if (!stat) {
+ register int n = desc.d_name;
+ for (i = 5; i >= 0; i--) {
+ name[i] = (n & 0xf) + '0';
+ n >>= 4;
+ }
+ }
+ switch (ctinfo[id].hwid) {
+ case CT7946ID:
+ if (bcmp(name, "079450", 6) == 0)
+ id = -1; /* not really a 7946 */
+ break;
+ default:
+ break;
+ }
+ return(id);
+}
+
+ctopen(f, ctlr, unit, part)
+ struct open_file *f;
+ int ctlr, unit, part;
+{
+ register struct ct_softc *rs;
+ register int skip;
+
+ if (ctlr >= NHPIB || hpibalive(ctlr) == 0)
+ return(EADAPT);
+ if (unit >= NCT)
+ return(ECTLR);
+ rs = &ct_softc[ctlr][unit];
+ rs->sc_unit = unit;
+ rs->sc_ctlr = ctlr;
+ if (rs->sc_alive == 0)
+ if (ctinit(ctlr, unit) == 0)
+ return(ENXIO);
+ f->f_devdata = (void *)rs;
+ ctstrategy(f, MTREW);
+ skip = part;
+ while (skip--)
+ ctstrategy(f, MTFSF);
+ return(0);
+}
+
+ctclose(f)
+ struct open_file *f;
+{
+ ctstrategy(f, MTREW);
+}
+
+char io_buf[MAXBSIZE];
+
+ctstrategy(rs, func, dblk, size, v_buf, rsize)
+ register struct ct_softc *rs;
+ int func;
+ daddr_t dblk;
+ size_t size;
+ void *v_buf;
+ size_t *rsize;
+{
+ char *buf = v_buf;
+ register int ctlr = rs->sc_ctlr;
+ register int unit = rs->sc_unit;
+ char stat;
+
+ if (size == 0 && (func == F_READ || func == F_WRITE))
+ return(0);
+
+ rs->sc_retry = 0;
+ ct_ioc.unit = C_SUNIT(rs->sc_punit);
+ ct_ioc.saddr = C_SADDR;
+ ct_ioc.nop2 = C_NOP;
+ ct_ioc.slen = C_SLEN;
+ ct_ioc.nop3 = C_NOP;
+top:
+ if (func == F_READ) {
+ ct_ioc.cmd = C_READ;
+ ct_ioc.addr = rs->sc_blkno;
+ ct_ioc.len = size;
+ }
+ else if (func == F_WRITE) {
+ ct_ioc.cmd = C_WRITE;
+ ct_ioc.addr = rs->sc_blkno;
+ ct_ioc.len = size;
+ }
+ else if (func == MTFSF) {
+ ct_ioc.cmd = C_READ;
+ ct_ioc.addr = rs->sc_blkno;
+ ct_ioc.len = size = MAXBSIZE;
+ buf = io_buf;
+ }
+ else {
+ ct_ioc.cmd = C_READ;
+ ct_ioc.addr = 0;
+ ct_ioc.len = 0;
+ rs->sc_blkno = 0;
+ size = 0;
+ }
+retry:
+ hpibsend(ctlr, unit, C_CMD, &ct_ioc, sizeof(ct_ioc));
+ if (func != MTREW) {
+ hpibswait(ctlr, unit);
+ hpibgo(ctlr, unit, C_EXEC, buf, size,
+ func != F_WRITE ? F_READ : F_WRITE);
+ hpibswait(ctlr, unit);
+ } else {
+ while (hpibswait(ctlr, unit) < 0)
+ ;
+ }
+ hpibrecv(ctlr, unit, C_QSTAT, &stat, 1);
+ if (stat) {
+ stat = cterror(ctlr, unit);
+ if (stat == 0)
+ return (-1);
+ if (stat == 2)
+ return (0);
+ if (++rs->sc_retry > CTRETRY)
+ return (-1);
+ goto retry;
+ }
+ rs->sc_blkno += CTBTOK(size);
+ if (func == MTFSF)
+ goto top;
+ *rsize = size;
+
+ return(0);
+}
+
+cterror(ctlr, unit)
+ register int ctlr, unit;
+{
+ register struct ct_softc *rs = &ct_softc[ctlr][unit];
+ char stat;
+
+ ct_rsc.unit = C_SUNIT(rs->sc_punit);
+ ct_rsc.cmd = C_STATUS;
+ hpibsend(ctlr, unit, C_CMD, &ct_rsc, sizeof(ct_rsc));
+ hpibrecv(ctlr, unit, C_EXEC, &ct_stat, sizeof(ct_stat));
+ hpibrecv(ctlr, unit, C_QSTAT, &stat, 1);
+ if (stat) {
+ printf("ct%d: request status fail %d\n", unit, stat);
+ return(0);
+ }
+ if (ct_stat.c_aef & AEF_EOF) {
+ /* 9145 drives don't increment block number at EOF */
+ if ((ct_stat.c_blk - rs->sc_blkno) == 0)
+ rs->sc_blkno++;
+ else
+ rs->sc_blkno = ct_stat.c_blk;
+ return (2);
+ }
+ printf("ct%d err: vu 0x%x, pend 0x%x, bn%d", unit,
+ ct_stat.c_vu, ct_stat.c_pend, ct_stat.c_blk);
+ printf(", R 0x%x F 0x%x A 0x%x I 0x%x\n", ct_stat.c_ref,
+ ct_stat.c_fef, ct_stat.c_aef, ct_stat.c_ief);
+ return (1);
+}
diff --git a/sys/arch/hp300/stand/dca.c b/sys/arch/hp300/stand/dca.c
new file mode 100644
index 00000000000..9253d141bcc
--- /dev/null
+++ b/sys/arch/hp300/stand/dca.c
@@ -0,0 +1,151 @@
+/* $NetBSD: dca.c,v 1.8 1995/10/04 06:54:44 thorpej Exp $ */
+
+/*
+ * Copyright (c) 1988 University of Utah.
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * @(#)dca.c 8.1 (Berkeley) 6/10/93
+ */
+
+#ifdef DCACONSOLE
+#include <sys/param.h>
+#include <dev/cons.h>
+
+#include <hp300/dev/dcareg.h>
+#include <hp300/stand/consdefs.h>
+#include <hp300/stand/samachdep.h>
+
+/* If not using 4.4 devs */
+#ifndef dca_reset
+#define dca_id dca_irid
+#define dca_reset dca_id
+#endif
+
+struct dcadevice *dcacnaddr = 0;
+
+void
+dcaprobe(cp)
+ struct consdev *cp;
+{
+ register struct dcadevice *dca;
+
+ dcacnaddr = (struct dcadevice *) sctoaddr(CONSCODE);
+ if (badaddr((char *)dcacnaddr)) {
+ cp->cn_pri = CN_DEAD;
+ return;
+ }
+#ifdef FORCEDCACONSOLE
+ cp->cn_pri = CN_REMOTE;
+#else
+ dca = dcacnaddr;
+ switch (dca->dca_id) {
+ case DCAID0:
+ case DCAID1:
+ cp->cn_pri = CN_NORMAL;
+ break;
+ case DCAREMID0:
+ case DCAREMID1:
+ cp->cn_pri = CN_REMOTE;
+ break;
+ default:
+ cp->cn_pri = CN_DEAD;
+ break;
+ }
+
+#endif
+ curcons_scode = CONSCODE;
+}
+
+void
+dcainit(cp)
+ struct consdev *cp;
+{
+ register struct dcadevice *dca = dcacnaddr;
+
+ dca->dca_reset = 0xFF;
+ DELAY(100);
+ dca->dca_ic = 0;
+ dca->dca_cfcr = CFCR_DLAB;
+ dca->dca_data = DCABRD(9600) & 0xFF;
+ dca->dca_ier = DCABRD(9600) >> 8;
+ dca->dca_cfcr = CFCR_8BITS;
+}
+
+/* ARGSUSED */
+#ifndef SMALL
+int
+dcagetchar(dev)
+ dev_t dev;
+{
+ register struct dcadevice *dca = dcacnaddr;
+ short stat;
+ int c;
+
+ if (((stat = dca->dca_lsr) & LSR_RXRDY) == 0)
+ return(0);
+ c = dca->dca_data;
+ return(c);
+}
+#else
+int
+dcagetchar(dev)
+ dev_t dev;
+{
+ return(0);
+}
+#endif
+
+/* ARGSUSED */
+void
+dcaputchar(dev, c)
+ dev_t dev;
+ register int c;
+{
+ register struct dcadevice *dca = dcacnaddr;
+ register int timo;
+ short stat;
+
+ /* wait a reasonable time for the transmitter to come ready */
+ timo = 50000;
+ while (((stat = dca->dca_lsr) & LSR_TXRDY) == 0 && --timo)
+ ;
+ dca->dca_data = c;
+ /* wait for this transmission to complete */
+ timo = 1000000;
+ while (((stat = dca->dca_lsr) & LSR_TXRDY) == 0 && --timo)
+ ;
+}
+#endif
diff --git a/sys/arch/hp300/stand/dcm.c b/sys/arch/hp300/stand/dcm.c
new file mode 100644
index 00000000000..936db32224d
--- /dev/null
+++ b/sys/arch/hp300/stand/dcm.c
@@ -0,0 +1,172 @@
+/* $NetBSD: dcm.c,v 1.8 1995/10/04 06:54:45 thorpej Exp $ */
+
+/*
+ * Copyright (c) 1988 University of Utah.
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * @(#)dcm.c 8.1 (Berkeley) 6/10/93
+ */
+
+#ifdef DCMCONSOLE
+#include <sys/param.h>
+#include <dev/cons.h>
+
+#include <hp300/dev/device.h>
+#include <hp300/dev/dcmreg.h>
+#include <hp300/stand/consdefs.h>
+#include <hp300/stand/samachdep.h>
+
+struct dcmdevice *dcmcnaddr = NULL;
+
+void
+dcmprobe(cp)
+ struct consdev *cp;
+{
+ extern struct hp_hw sc_table[];
+ register struct hp_hw *hw;
+ register struct dcmdevice *dcm;
+
+ for (hw = sc_table; hw < &sc_table[MAXCTLRS]; hw++)
+ if (HW_ISDEV(hw, D_COMMDCM) && !badaddr((caddr_t)hw->hw_kva))
+ break;
+ if (!HW_ISDEV(hw, D_COMMDCM)) {
+ cp->cn_pri = CN_DEAD;
+ return;
+ }
+ dcmcnaddr = (struct dcmdevice *) hw->hw_kva;
+
+ dcm = dcmcnaddr;
+ switch (dcm->dcm_rsid) {
+ case DCMID:
+ cp->cn_pri = CN_NORMAL;
+ break;
+ case DCMID|DCMCON:
+ cp->cn_pri = CN_REMOTE;
+ break;
+ default:
+ cp->cn_pri = CN_DEAD;
+ break;
+ }
+
+ curcons_scode = hw->hw_sc;
+}
+
+void
+dcminit(cp)
+ struct consdev *cp;
+{
+ register struct dcmdevice *dcm = dcmcnaddr;
+ register int port = CONUNIT;
+
+ dcm->dcm_ic = IC_ID;
+ while (dcm->dcm_thead[port].ptr != dcm->dcm_ttail[port].ptr)
+ ;
+ dcm->dcm_data[port].dcm_baud = BR_9600;
+ dcm->dcm_data[port].dcm_conf = LC_8BITS | LC_1STOP;
+ SEM_LOCK(dcm);
+ dcm->dcm_cmdtab[port].dcm_data |= CT_CON;
+ dcm->dcm_cr |= (1 << port);
+ SEM_UNLOCK(dcm);
+ DELAY(15000);
+}
+
+/* ARGSUSED */
+#ifndef SMALL
+int
+dcmgetchar(dev)
+ dev_t dev;
+{
+ register struct dcmdevice *dcm = dcmcnaddr;
+ register struct dcmrfifo *fifo;
+ register struct dcmpreg *pp;
+ register unsigned head;
+ int c, stat, port;
+
+ port = CONUNIT;
+ pp = dcm_preg(dcm, port);
+ head = pp->r_head & RX_MASK;
+ if (head == (pp->r_tail & RX_MASK))
+ return(0);
+ fifo = &dcm->dcm_rfifos[3-port][head>>1];
+ c = fifo->data_char;
+ stat = fifo->data_stat;
+ pp->r_head = (head + 2) & RX_MASK;
+ SEM_LOCK(dcm);
+ stat = dcm->dcm_iir;
+ SEM_UNLOCK(dcm);
+ return(c);
+}
+#else
+int
+dcmgetchar(dev)
+ dev_t dev;
+{
+ return(0);
+}
+#endif
+
+/* ARGSUSED */
+void
+dcmputchar(dev, c)
+ dev_t dev;
+ register int c;
+{
+ register struct dcmdevice *dcm = dcmcnaddr;
+ register struct dcmpreg *pp;
+ register int timo;
+ unsigned tail;
+ int port, stat;
+
+ port = CONUNIT;
+ pp = dcm_preg(dcm, port);
+ tail = pp->t_tail & TX_MASK;
+ timo = 50000;
+ while (tail != (pp->t_head & TX_MASK) && --timo)
+ ;
+ dcm->dcm_tfifos[3-port][tail].data_char = c;
+ pp->t_tail = tail = (tail + 1) & TX_MASK;
+ SEM_LOCK(dcm);
+ dcm->dcm_cmdtab[port].dcm_data |= CT_TX;
+ dcm->dcm_cr |= (1 << port);
+ SEM_UNLOCK(dcm);
+ timo = 1000000;
+ while (tail != (pp->t_head & TX_MASK) && --timo)
+ ;
+ SEM_LOCK(dcm);
+ stat = dcm->dcm_iir;
+ SEM_UNLOCK(dcm);
+}
+#endif
diff --git a/sys/arch/hp300/stand/devopen.c b/sys/arch/hp300/stand/devopen.c
new file mode 100644
index 00000000000..fe22240ed69
--- /dev/null
+++ b/sys/arch/hp300/stand/devopen.c
@@ -0,0 +1,210 @@
+/* $NetBSD: devopen.c,v 1.5 1995/08/05 16:47:41 thorpej Exp $ */
+
+/*-
+ * Copyright (c) 1993 John Brezak
+ * All rights reserved.
+ *
+ * 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. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR `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 AUTHOR 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.
+ */
+
+#include <sys/param.h>
+#include <sys/reboot.h>
+
+#include "stand.h"
+#include "samachdep.h"
+
+u_int opendev;
+
+#define ispart(c) ((c) >= 'a' && (c) <= 'h')
+
+atoi(char *cp)
+{
+ int val = 0;
+ while(isdigit(*cp))
+ val = val * 10 + (*cp++ - '0');
+ return(val);
+}
+
+usage()
+{
+ printf("\
+Usage: device(adaptor, controller, drive, partition)file\n\
+ <device><unit><partitionletter>:file\n\
+");
+}
+
+devlookup(d, len)
+ const char *d;
+ int len;
+{
+ struct devsw *dp = devsw;
+ int i;
+
+ for (i = 0; i < ndevs; i++, dp++)
+ if (dp->dv_name && strncmp(dp->dv_name, d, len) == 0)
+ return(i);
+
+ printf("No such device - Configured devices are:\n");
+ for (dp = devsw, i = 0; i < ndevs; i++, dp++)
+ if (dp->dv_name)
+ printf(" %s", dp->dv_name);
+ printf("\n");
+ errno = ENODEV;
+ return(-1);
+}
+
+/*
+ * Parse a device spec in one of two forms.
+ *
+ * dev(adapt, ctlr, unit, part)file
+ * [A-Za-z]*[0-9]*[A-Za-z]:file
+ * dev unit part
+ */
+devparse(fname, dev, adapt, ctlr, unit, part, file)
+ const char *fname;
+ int *dev, *adapt, *ctlr, *unit, *part;
+ char **file;
+{
+ int *argp, i;
+ char *s, *args[4];
+
+ /* get device name and make lower case */
+ for (s = (char *)fname; *s && *s != '/' && *s != ':' && *s != '('; s++)
+ if (isupper(*s)) *s = tolower(*s);
+
+ /* first form */
+ if (*s == '(') {
+ /* lookup device and get index */
+ if ((*dev = devlookup(fname, s - fname)) < 0)
+ goto baddev;
+
+ /* tokenize device ident */
+ args[0] = ++s;
+ for (args[0] = s, i = 1; *s && *s != ')'; s++) {
+ if (*s == ',')
+ args[i++] = ++s;
+ }
+ switch(i) {
+ case 4:
+ *adapt = atoi(args[0]);
+ *ctlr = atoi(args[1]);
+ *unit = atoi(args[2]);
+ *part = atoi(args[3]);
+ break;
+ case 3:
+ *ctlr = atoi(args[0]);
+ *unit = atoi(args[1]);
+ *part = atoi(args[2]);
+ break;
+ case 2:
+ *unit = atoi(args[0]);
+ *part = atoi(args[1]);
+ break;
+ case 1:
+ *part = atoi(args[0]);
+ break;
+ case 0:
+ break;
+ }
+ *file = ++s;
+ }
+
+ /* second form */
+ else if (*s == ':') {
+ int unit;
+
+ /* isolate device */
+ for (s = (char *)fname; *s != ':' && !isdigit(*s); s++);
+
+ /* lookup device and get index */
+ if ((*dev = devlookup(fname, s - fname)) < 0)
+ goto baddev;
+
+ /* isolate unit */
+ if ((unit = atoi(s)) > 255)
+ goto bad;
+ *adapt = unit / 8;
+ *ctlr = unit % 8;
+ for (; isdigit(*s); s++);
+
+ /* translate partition */
+ if (!ispart(*s))
+ goto bad;
+
+ *part = *s++ - 'a';
+ if (*s != ':')
+ goto bad;
+ *file = ++s;
+ }
+
+ /* no device present */
+ else
+ *file = (char *)fname;
+
+ /* return the remaining unparsed part as the file to boot */
+ return(0);
+
+ bad:
+ usage();
+
+ baddev:
+ return(-1);
+}
+
+
+devopen(f, fname, file)
+ struct open_file *f;
+ const char *fname;
+ char **file;
+{
+ int n, error;
+ int dev, adapt, ctlr, unit, part;
+ struct devsw *dp = &devsw[0];
+
+ dev = B_TYPE(bootdev);
+ adapt = B_ADAPTOR(bootdev);
+ ctlr = B_CONTROLLER(bootdev);
+ unit = B_UNIT(bootdev);
+ part = B_PARTITION(bootdev);
+
+ if (error = devparse(fname, &dev, &adapt, &ctlr, &unit, &part, file))
+ return(error);
+
+ dp = &devsw[dev];
+
+ if (!dp->dv_open)
+ return(ENODEV);
+
+ opendev = MAKEBOOTDEV(dev, adapt, ctlr, unit, part);
+
+ f->f_dev = dp;
+
+ if ((error = (*dp->dv_open)(f, adapt, ctlr, part)) == 0)
+ return(0);
+
+ printf("%s(%d,%d,%d,%d): %s\n", devsw[dev].dv_name,
+ adapt, ctlr, unit, part, strerror(error));
+
+ return(error);
+}
diff --git a/sys/arch/hp300/stand/fhpib.c b/sys/arch/hp300/stand/fhpib.c
new file mode 100644
index 00000000000..c20071c0ceb
--- /dev/null
+++ b/sys/arch/hp300/stand/fhpib.c
@@ -0,0 +1,192 @@
+/* $NetBSD: fhpib.c,v 1.5 1995/08/05 16:47:42 thorpej Exp $ */
+
+/*
+ * Copyright (c) 1982, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * @(#)fhpib.c 8.1 (Berkeley) 6/10/93
+ */
+
+/*
+ * 98625A/B HPIB driver
+ */
+
+#include <sys/param.h>
+#include <hp300/dev/fhpibreg.h>
+#include <hp300/stand/hpibvar.h>
+#include <hp300/stand/samachdep.h>
+
+fhpibinit(unit)
+ register int unit;
+{
+ register struct hpib_softc *hs = &hpib_softc[unit];
+ register struct fhpibdevice *hd = (struct fhpibdevice *)hs->sc_addr;
+
+ if (hd->hpib_cid != HPIBC)
+ return(0);
+ hs->sc_type = HPIBC;
+ hs->sc_ba = HPIBC_BA;
+ fhpibreset(unit);
+ return(1);
+}
+
+fhpibreset(unit)
+{
+ register struct hpib_softc *hs = &hpib_softc[unit];
+ register struct fhpibdevice *hd;
+
+ hd = (struct fhpibdevice *)hs->sc_addr;
+ hd->hpib_cid = 0xFF;
+ DELAY(100);
+ hd->hpib_cmd = CT_8BIT;
+ hd->hpib_ar = AR_ARONC;
+ hd->hpib_cmd |= CT_IFC;
+ hd->hpib_cmd |= CT_INITFIFO;
+ DELAY(100);
+ hd->hpib_cmd &= ~CT_IFC;
+ hd->hpib_cmd |= CT_REN;
+ hd->hpib_stat = ST_ATN;
+ hd->hpib_data = C_DCL;
+ DELAY(100000);
+}
+
+fhpibsend(unit, slave, sec, buf, cnt)
+ register char *buf;
+ register int cnt;
+{
+ register struct hpib_softc *hs = &hpib_softc[unit];
+ register struct fhpibdevice *hd;
+ int origcnt = cnt;
+
+ hd = (struct fhpibdevice *)hs->sc_addr;
+ hd->hpib_stat = 0;
+ hd->hpib_imask = IM_IDLE | IM_ROOM;
+ fhpibwait(hd, IM_IDLE);
+ hd->hpib_stat = ST_ATN;
+ hd->hpib_data = C_UNL;
+ hd->hpib_data = C_TAG + hs->sc_ba;
+ hd->hpib_data = C_LAG + slave;
+ if (sec != -1)
+ hd->hpib_data = C_SCG + sec;
+ fhpibwait(hd, IM_IDLE);
+ hd->hpib_stat = ST_WRITE;
+ if (cnt) {
+ while (--cnt) {
+ hd->hpib_data = *buf++;
+ if (fhpibwait(hd, IM_ROOM) < 0)
+ break;
+ }
+ hd->hpib_stat = ST_EOI;
+ hd->hpib_data = *buf;
+ if (fhpibwait(hd, IM_ROOM) < 0)
+ cnt++;
+ hd->hpib_stat = ST_ATN;
+ /* XXX: HP-UX claims bug with CS80 transparent messages */
+ if (sec == 0x12)
+ DELAY(150);
+ hd->hpib_data = C_UNL;
+ fhpibwait(hd, IM_IDLE);
+ }
+ hd->hpib_imask = 0;
+ return(origcnt - cnt);
+}
+
+fhpibrecv(unit, slave, sec, buf, cnt)
+ register char *buf;
+ register int cnt;
+{
+ register struct hpib_softc *hs = &hpib_softc[unit];
+ register struct fhpibdevice *hd;
+ int origcnt = cnt;
+
+ hd = (struct fhpibdevice *)hs->sc_addr;
+ hd->hpib_stat = 0;
+ hd->hpib_imask = IM_IDLE | IM_ROOM | IM_BYTE;
+ fhpibwait(hd, IM_IDLE);
+ hd->hpib_stat = ST_ATN;
+ hd->hpib_data = C_UNL;
+ hd->hpib_data = C_LAG + hs->sc_ba;
+ hd->hpib_data = C_TAG + slave;
+ if (sec != -1)
+ hd->hpib_data = C_SCG + sec;
+ fhpibwait(hd, IM_IDLE);
+ hd->hpib_stat = ST_READ0;
+ hd->hpib_data = 0;
+ if (cnt) {
+ while (--cnt >= 0) {
+ if (fhpibwait(hd, IM_BYTE) < 0)
+ break;
+ *buf++ = hd->hpib_data;
+ }
+ cnt++;
+ fhpibwait(hd, IM_ROOM);
+ hd->hpib_stat = ST_ATN;
+ hd->hpib_data = (slave == 31) ? C_UNA : C_UNT;
+ fhpibwait(hd, IM_IDLE);
+ }
+ hd->hpib_imask = 0;
+ return(origcnt - cnt);
+}
+
+fhpibppoll(unit)
+ register int unit;
+{
+ register struct hpib_softc *hs = &hpib_softc[unit];
+ register struct fhpibdevice *hd;
+ register int ppoll;
+
+ hd = (struct fhpibdevice *)hs->sc_addr;
+ hd->hpib_stat = 0;
+ hd->hpib_psense = 0;
+ hd->hpib_pmask = 0xFF;
+ hd->hpib_imask = IM_PPRESP | IM_PABORT;
+ DELAY(25);
+ hd->hpib_intr = IM_PABORT;
+ ppoll = hd->hpib_data;
+ if (hd->hpib_intr & IM_PABORT)
+ ppoll = 0;
+ hd->hpib_imask = 0;
+ hd->hpib_pmask = 0;
+ hd->hpib_stat = ST_IENAB;
+ return(ppoll);
+}
+
+fhpibwait(hd, x)
+ register struct fhpibdevice *hd;
+{
+ register int timo = 100000;
+
+ while ((hd->hpib_intr & x) == 0 && --timo)
+ ;
+ if (timo == 0)
+ return(-1);
+ return(0);
+}
diff --git a/sys/arch/hp300/stand/hil.c b/sys/arch/hp300/stand/hil.c
new file mode 100644
index 00000000000..f5473c05acd
--- /dev/null
+++ b/sys/arch/hp300/stand/hil.c
@@ -0,0 +1,262 @@
+/* $NetBSD: hil.c,v 1.5 1994/10/26 07:27:19 cgd Exp $ */
+
+/*
+ * Copyright (c) 1988 University of Utah.
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * from: Utah Hdr: hil.c 1.1 89/08/22
+ *
+ * @(#)hil.c 8.1 (Berkeley) 6/10/93
+ */
+
+/*
+ * Keyboard routines for the standalone ITE.
+ */
+#include "samachdep.h"
+
+#ifdef ITECONSOLE
+
+#include <sys/param.h>
+#include <hp300/dev/hilreg.h>
+#include <hp300/dev/kbdmap.h>
+#include <hp300/dev/itevar.h>
+
+#ifndef SMALL
+
+/*
+ * HIL cooked keyboard keymaps.
+ * Supports only unshifted, shifted and control keys.
+ */
+char us_keymap[] = {
+ NULL, '`', '\\', ESC, NULL, DEL, NULL, NULL,
+ '\n', '\t', NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, '\n', NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, '\t', NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, '\b', NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ ESC, '\r', NULL, '\n', '0', '.', ',', '+',
+ '1', '2', '3', '-', '4', '5', '6', '*',
+ '7', '8', '9', '/', 'E', '(', ')', '^',
+ '1', '2', '3', '4', '5', '6', '7', '8',
+ '9', '0', '-', '=', '[', ']', ';', '\'',
+ ',', '.', '/', '\040', 'o', 'p', 'k', 'l',
+ 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i',
+ 'a', 's', 'd', 'f', 'g', 'h', 'j', 'm',
+ 'z', 'x', 'c', 'v', 'b', 'n', NULL, NULL
+};
+
+char us_shiftmap[] = {
+ NULL, '~', '|', DEL, NULL, DEL, NULL, NULL,
+ '\n', '\t', NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, '\n', NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, '\t', NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, DEL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ ESC, '\r', NULL, '\n', '0', '.', ',', '+',
+ '1', '2', '3', '-', '4', '5', '6', '*',
+ '7', '8', '9', '/', '`', '|', '\\', '~',
+ '!', '@', '#', '$', '%', '^', '&', '*',
+ '(', ')', '_', '+', '{', '}', ':', '\"',
+ '<', '>', '?', '\040', 'O', 'P', 'K', 'L',
+ 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I',
+ 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'M',
+ 'Z', 'X', 'C', 'V', 'B', 'N', NULL, NULL
+};
+
+char us_ctrlmap[] = {
+ NULL, '`', '\034', ESC, NULL, DEL, NULL, NULL,
+ '\n', '\t', NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, '\n', NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, '\t', NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, '\b', NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ ESC, '\r', NULL, '\n', '0', '.', ',', '+',
+ '1', '2', '3', '-', '4', '5', '6', '*',
+ '7', '8', '9', '/', 'E', '(', ')', '\036',
+ '1', '2', '3', '4', '5', '6', '7', '8',
+ '9', '0', '-', '=', '\033', '\035', ';', '\'',
+ ',', '.', '/', '\040', '\017', '\020', '\013', '\014',
+ '\021', '\027', '\005', '\022', '\024', '\031', '\025', '\011',
+ '\001', '\023', '\004', '\006', '\007', '\010', '\012', '\015',
+ '\032', '\030', '\003', '\026', '\002', '\016', NULL, NULL
+};
+
+#ifdef UK_KEYBOARD
+char uk_keymap[] = {
+ NULL, '`', '<', ESC, NULL, DEL, NULL, NULL,
+ '\n', '\t', NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, '\n', NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, '\t', NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, '\b', NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ ESC, '\r', NULL, '\n', '0', '.', ',', '+',
+ '1', '2', '3', '-', '4', '5', '6', '*',
+ '7', '8', '9', '/', 'E', '(', ')', '^',
+ '1', '2', '3', '4', '5', '6', '7', '8',
+ '9', '0', '+', '\'', '[', ']', '*', '\\',
+ ',', '.', '-', '\040', 'o', 'p', 'k', 'l',
+ 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i',
+ 'a', 's', 'd', 'f', 'g', 'h', 'j', 'm',
+ 'z', 'x', 'c', 'v', 'b', 'n', NULL, NULL
+};
+
+char uk_shiftmap[] = {
+ NULL, '~', '>', DEL, NULL, DEL, NULL, NULL,
+ '\n', '\t', NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, '\n', NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, '\t', NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, DEL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ ESC, '\r', NULL, '\n', '0', '.', ',', '+',
+ '1', '2', '3', '-', '4', '5', '6', '*',
+ '7', '8', '9', '/', '`', '|', '\\', '~',
+ '!', '\"', '#', '$', '%', '&', '^', '(',
+ ')', '=', '?', '/', '{', '}', '@', '|',
+ ';', ':', '_', '\040', 'O', 'P', 'K', 'L',
+ 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I',
+ 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'M',
+ 'Z', 'X', 'C', 'V', 'B', 'N', NULL, NULL
+};
+
+char uk_ctrlmap[] = {
+ NULL, '`', '<', ESC, NULL, DEL, NULL, NULL,
+ '\n', '\t', NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, '\n', NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, '\t', NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, '\b', NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ ESC, '\r', NULL, '\n', '0', '.', ',', '+',
+ '1', '2', '3', '-', '4', '5', '6', '*',
+ '7', '8', '9', '/', 'E', '(', ')', '\036',
+ '1', '2', '3', '4', '5', '6', '7', '8',
+ '9', '0', '+', '\'', '\033', '\035', '*', '\034',
+ ',', '.', '/', '\040', '\017', '\020', '\013', '\014',
+ '\021', '\027', '\005', '\022', '\024', '\031', '\025', '\011',
+ '\001', '\023', '\004', '\006', '\007', '\010', '\012', '\015',
+ '\032', '\030', '\003', '\026', '\002', '\016', NULL, NULL
+};
+#endif
+
+/*
+ * The keyboard map table.
+ * Lookup is by hardware returned language code.
+ */
+struct kbdmap kbd_map[] = {
+ KBD_US, NULL,
+ us_keymap, us_shiftmap, us_ctrlmap, NULL, NULL,
+
+#ifdef UK_KEYBOARD
+ KBD_UK, NULL,
+ uk_keymap, uk_shiftmap, uk_ctrlmap, NULL, NULL,
+#endif
+
+ 0, NULL,
+ NULL, NULL, NULL, NULL, NULL,
+};
+
+char *kbd_keymap = us_keymap;
+char *kbd_shiftmap = us_shiftmap;
+char *kbd_ctrlmap = us_ctrlmap;
+
+kbdgetc()
+{
+ register int status, c;
+ register struct hil_dev *hiladdr = HILADDR;
+
+ status = hiladdr->hil_stat;
+ if ((status & HIL_DATA_RDY) == 0)
+ return(0);
+ c = hiladdr->hil_data;
+ switch ((status>>KBD_SSHIFT) & KBD_SMASK) {
+ case KBD_SHIFT:
+ c = kbd_shiftmap[c & KBD_CHARMASK];
+ break;
+ case KBD_CTRL:
+ c = kbd_ctrlmap[c & KBD_CHARMASK];
+ break;
+ case KBD_KEY:
+ c = kbd_keymap[c & KBD_CHARMASK];
+ break;
+ default:
+ c = 0;
+ break;
+ }
+ return(c);
+}
+#endif
+
+kbdnmi()
+{
+ register struct hil_dev *hiladdr = HILADDR;
+
+ HILWAIT(hiladdr);
+ hiladdr->hil_cmd = HIL_CNMT;
+ HILWAIT(hiladdr);
+ hiladdr->hil_cmd = HIL_CNMT;
+ HILWAIT(hiladdr);
+ printf("\nboot interrupted\n");
+}
+
+kbdinit()
+{
+ register struct hil_dev *hiladdr = HILADDR;
+ register struct kbdmap *km;
+ u_char lang;
+
+ HILWAIT(hiladdr);
+ hiladdr->hil_cmd = HIL_SETARR;
+ HILWAIT(hiladdr);
+ hiladdr->hil_data = ar_format(KBD_ARR);
+ HILWAIT(hiladdr);
+ hiladdr->hil_cmd = HIL_READKBDLANG;
+ HILDATAWAIT(hiladdr);
+ lang = hiladdr->hil_data;
+ for (km = kbd_map; km->kbd_code; km++)
+ if (km->kbd_code == lang) {
+ kbd_keymap = km->kbd_keymap;
+ kbd_shiftmap = km->kbd_shiftmap;
+ kbd_ctrlmap = km->kbd_ctrlmap;
+ }
+ HILWAIT(hiladdr);
+ hiladdr->hil_cmd = HIL_INTON;
+}
+#endif
diff --git a/sys/arch/hp300/stand/hpib.c b/sys/arch/hp300/stand/hpib.c
new file mode 100644
index 00000000000..451f970f0cf
--- /dev/null
+++ b/sys/arch/hp300/stand/hpib.c
@@ -0,0 +1,155 @@
+/* $NetBSD: hpib.c,v 1.4 1994/10/26 07:27:21 cgd Exp $ */
+
+/*
+ * Copyright (c) 1982, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * @(#)hpib.c 8.1 (Berkeley) 6/10/93
+ */
+
+/*
+ * HPIB driver
+ */
+#include <sys/param.h>
+#include <sys/reboot.h>
+#include <hp300/dev/device.h>
+
+#include "hpibvar.h"
+
+#include "stand.h"
+#include "samachdep.h"
+
+int internalhpib = IIOV(0x478000);
+int fhpibppoll(), nhpibppoll();
+
+struct hpib_softc hpib_softc[NHPIB];
+
+hpibinit()
+{
+ extern struct hp_hw sc_table[];
+ register struct hp_hw *hw;
+ register struct hpib_softc *hs;
+ register int i, addr;
+
+ i = 0;
+ for (hw = sc_table; i < NHPIB && hw < &sc_table[MAXCTLRS]; hw++) {
+ if (!HW_ISHPIB(hw))
+ continue;
+ hs = &hpib_softc[i];
+ hs->sc_addr = hw->hw_kva;
+ if (nhpibinit(i) == 0)
+ if (fhpibinit(i) == 0)
+ continue;
+ if (howto & RB_ASKNAME)
+ printf("hpib%d at sc%d\n", i, hw->hw_sc);
+ hw->hw_pa = (caddr_t) i; /* XXX for autoconfig */
+ hs->sc_alive = 1;
+ i++;
+ }
+}
+
+hpibalive(unit)
+ register int unit;
+{
+ if (unit >= NHPIB || hpib_softc[unit].sc_alive == 0)
+ return (0);
+ return (1);
+}
+
+hpibid(unit, slave)
+ int unit, slave;
+{
+ short id;
+ int rv;
+
+ if (hpib_softc[unit].sc_type == HPIBC)
+ rv = fhpibrecv(unit, 31, slave, &id, 2);
+ else
+ rv = nhpibrecv(unit, 31, slave, &id, 2);
+ if (rv != 2)
+ return (0);
+ return (id);
+}
+
+hpibsend(unit, slave, sec, buf, cnt)
+ int unit, slave;
+ char *buf;
+ int cnt;
+{
+ if (hpib_softc[unit].sc_type == HPIBC)
+ return (fhpibsend(unit, slave, sec, buf, cnt));
+ return (nhpibsend(unit, slave, sec, buf, cnt));
+}
+
+hpibrecv(unit, slave, sec, buf, cnt)
+ int unit, slave;
+ char *buf;
+ int cnt;
+{
+ if (hpib_softc[unit].sc_type == HPIBC)
+ return (fhpibrecv(unit, slave, sec, buf, cnt));
+ return (nhpibrecv(unit, slave, sec, buf, cnt));
+}
+
+hpibswait(unit, slave)
+ register int unit, slave;
+{
+ register int timo = 1000000;
+ register int (*poll)();
+
+ slave = 0x80 >> slave;
+ if (hpib_softc[unit].sc_type == HPIBC)
+ poll = fhpibppoll;
+ else
+ poll = nhpibppoll;
+ while (((*poll)(unit) & slave) == 0)
+ if (--timo == 0)
+ break;
+ if (timo == 0)
+ return (-1);
+ return (0);
+}
+
+hpibgo(unit, slave, sec, addr, count, flag)
+ int unit, slave;
+ char *addr;
+{
+ if (hpib_softc[unit].sc_type == HPIBC)
+ if (flag == F_READ)
+ fhpibrecv(unit, slave, sec, addr, count);
+ else
+ fhpibsend(unit, slave, sec, addr, count);
+ else
+ if (flag == F_READ)
+ nhpibrecv(unit, slave, sec, addr, count);
+ else
+ nhpibsend(unit, slave, sec, addr, count);
+}
diff --git a/sys/arch/hp300/stand/hpibvar.h b/sys/arch/hp300/stand/hpibvar.h
new file mode 100644
index 00000000000..3f1f66517dd
--- /dev/null
+++ b/sys/arch/hp300/stand/hpibvar.h
@@ -0,0 +1,61 @@
+/* $NetBSD: hpibvar.h,v 1.4 1994/10/26 07:27:24 cgd Exp $ */
+
+/*
+ * Copyright (c) 1982, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * @(#)hpibvar.h 8.1 (Berkeley) 6/10/93
+ */
+
+#define HPIBA 32
+#define HPIBB 1
+#define HPIBC 8
+#define HPIBA_BA 21
+#define HPIBC_BA 30
+
+#define CSA_BA 0x1F
+
+#define C_DCL 20
+#define C_LAG 32
+#define C_UNL 63
+#define C_TAG 64
+#define C_UNA 94
+#define C_UNT 95
+#define C_SCG 96
+
+struct hpib_softc {
+ char sc_alive;
+ char sc_type;
+ int sc_ba;
+ char *sc_addr;
+};
+
+extern struct hpib_softc hpib_softc[];
diff --git a/sys/arch/hp300/stand/if_le.c b/sys/arch/hp300/stand/if_le.c
new file mode 100644
index 00000000000..26ed93fd473
--- /dev/null
+++ b/sys/arch/hp300/stand/if_le.c
@@ -0,0 +1,669 @@
+/* $NetBSD: if_le.c,v 1.6 1995/09/02 05:04:18 thorpej Exp $ */
+
+/*
+ * Copyright (c) 1993 Adam Glass
+ * All rights reserved.
+ *
+ * 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 Adam Glass.
+ * 4. The name of the Author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY Adam Glass ``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.
+ */
+
+#include <sys/param.h>
+#include <sys/types.h>
+
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
+
+#include <lib/libsa/netif.h>
+
+#include <hp300/dev/device.h>
+#include <hp300/dev/if_lereg.h>
+
+#include "samachdep.h"
+
+#ifndef NLE
+#define NLE 1
+#endif
+
+#ifdef LE_DEBUG
+int le_debug = 0;
+#endif
+
+#define ETHER_MIN_LEN 64
+#define ETHER_MAX_LEN 1518
+#define ETHER_ADDR_LEN 6
+
+int le_probe();
+int le_match();
+void le_init();
+int le_get();
+int le_put();
+void le_end();
+
+struct le_sel {
+ int le_id;
+ int le_regs;
+ int le_mem;
+ int le_nvram;
+ int le_heat;
+ int le_bonus;
+} le0conf[] = {
+/* offsets for: ID REGS MEM NVRAM le_heat le_bonus*/
+{ 0, 0x4000, 0x8000, 0xC008, 1, 10 }
+};
+
+extern struct netif_stats le_stats[];
+
+struct netif_dif le_ifs[] = {
+/* dif_unit dif_nsel dif_stats dif_private */
+{ 0, NENTS(le0conf), &le_stats[0], le0conf, },
+};
+
+struct netif_stats le_stats[NENTS(le_ifs)];
+
+struct netif_driver le_driver = {
+ "le", /* netif_bname */
+ le_match, /* netif_match */
+ le_probe, /* netif_probe */
+ le_init, /* netif_init */
+ le_get, /* netif_get */
+ le_put, /* netif_put */
+ le_end, /* netif_end */
+ le_ifs, /* netif_ifs */
+ NENTS(le_ifs) /* netif_nifs */
+};
+
+struct le_softc {
+ struct lereg0 *sc_r0; /* DIO registers */
+ struct lereg1 *sc_r1; /* LANCE registers */
+ void *sc_mem;
+ struct init_block *sc_init;
+ struct mds *sc_rd, *sc_td;
+ u_char *sc_rbuf, *sc_tbuf;
+ int sc_next_rd, sc_next_td;
+ u_char sc_addr[ETHER_ADDR_LEN];
+} le_softc[NLE];
+
+static inline void
+lewrcsr(sc, port, val)
+ struct le_softc *sc;
+ register u_short port;
+ register u_short val;
+{
+ register struct lereg0 *ler0 = sc->sc_r0;
+ register struct lereg1 *ler1 = sc->sc_r1;
+
+ do {
+ ler1->ler1_rap = port;
+ } while ((ler0->ler0_status & LE_ACK) == 0);
+ do {
+ ler1->ler1_rdp = val;
+ } while ((ler0->ler0_status & LE_ACK) == 0);
+}
+
+static inline u_short
+lerdcsr(sc, port)
+ struct le_softc *sc;
+ register u_short port;
+{
+ register struct lereg0 *ler0 = sc->sc_r0;
+ register struct lereg1 *ler1 = sc->sc_r1;
+ register u_short val;
+
+ do {
+ ler1->ler1_rap = port;
+ } while ((ler0->ler0_status & LE_ACK) == 0);
+ do {
+ val = ler1->ler1_rdp;
+ } while ((ler0->ler0_status & LE_ACK) == 0);
+ return (val);
+}
+
+leinit()
+{
+ extern struct hp_hw sc_table[];
+ register struct hp_hw *hw;
+ struct le_softc *sc;
+ struct le_sel *sels;
+ register int i, n;
+ char *cp;
+
+ i = 0;
+
+ for (hw = sc_table; i < NLE && hw < &sc_table[MAXCTLRS]; hw++) {
+#ifdef LE_DEBUG
+ if (le_debug)
+ printf("found type %x\n", hw->hw_type);
+#endif
+
+#if 0
+ if (!HW_ISDEV(hw, D_LAN))
+ continue;
+#endif
+
+ sels = (struct le_sel *)le_ifs[i].dif_private;
+
+ sc = &le_softc[i];
+ sc->sc_r0 = (struct lereg0 *)(sels->le_id + (int)hw->hw_kva);
+
+ if (sc->sc_r0->ler0_id != LEID)
+ continue;
+
+ sc->sc_r1 = (struct lereg1 *)(sels->le_regs + (int)hw->hw_kva);
+ sc->sc_mem = (struct lereg2 *)(sels->le_mem + (int)hw->hw_kva);
+
+#ifdef LE_DEBUG
+ if (le_debug)
+ printf("le%d: DIO=%x regs=%x mem=%x\n",
+ i, sc->sc_r0, sc->sc_r1, sc->sc_mem);
+#endif
+
+ /*
+ * Read the ethernet address off the board, one nibble at a time.
+ */
+ cp = (char *)(sels->le_nvram + (int)hw->hw_kva);
+ for (n = 0; n < sizeof(sc->sc_addr); n++) {
+ sc->sc_addr[n] = (*++cp & 0xF) << 4;
+ cp++;
+ sc->sc_addr[n] |= *++cp & 0xF;
+ cp++;
+ }
+#ifdef LE_DEBUG
+ if (le_debug)
+ printf("le%d at sc%d physical address %s\n",
+ i, hw->hw_sc, ether_sprintf(sc->sc_addr));
+#endif
+ hw->hw_pa = (caddr_t) i; /* XXX for autoconfig */
+ i++;
+ }
+}
+
+int
+le_match(nif, machdep_hint)
+ struct netif *nif;
+ void *machdep_hint;
+{
+ struct le_sel *sels;
+ char *name = machdep_hint;
+ int rv = 0;
+
+ if (nif->nif_sel < le_ifs[nif->nif_unit].dif_nsel) {
+ sels = (struct le_sel *)le_ifs[nif->nif_unit].dif_private;
+ rv = sels[nif->nif_sel].le_heat;
+ if (name && !strncmp(le_driver.netif_bname, name, 2))
+ rv += sels[nif->nif_sel].le_bonus;
+ }
+#ifdef LE_DEBUG
+ if (le_debug)
+ printf("le%d: sel %d --> %d\n", nif->nif_unit, nif->nif_sel,
+ rv);
+#endif
+ return rv;
+}
+
+le_probe(nif, machdep_hint)
+ struct netif *nif;
+ void *machdep_hint;
+{
+ char *cp;
+ int i;
+
+ /* the set unit is the current unit */
+#ifdef LE_DEBUG
+ if (le_debug)
+ printf("le%d.%d: le_probe called\n", nif->nif_unit, nif->nif_sel);
+#endif
+ /* XXX reset controller */
+ return 0;
+}
+
+#ifdef MEM_SUMMARY
+void le_mem_summary(unit)
+{
+ struct lereg1 *ler1 = le_softc.sc_r1;
+ struct lereg2 *ler2 = le_softc.sc_r2;
+ register int i;
+
+ printf("le%d: ler1 = %x\n", unit, ler1);
+ printf("le%d: ler2 = %x\n", unit, ler2);
+
+#if 0
+ ler1->ler1_rap = LE_CSR0;
+ ler1->ler1_rdp = LE_STOP;
+ printf("le%d: csr0 = %x\n", unit, ler1->ler1_rdp);
+ ler1->ler1_rap = LE_CSR1;
+ printf("le%d: csr1 = %x\n", unit, ler1->ler1_rdp);
+ ler1->ler1_rap = LE_CSR2;
+ printf("le%d: csr2 = %x\n", unit, ler1->ler1_rdp);
+ ler1->ler1_rap = LE_CSR3;
+ printf("le%d: csr3 = %x\n", unit, ler1->ler1_rdp);
+#endif
+ printf("le%d: ladrf[0] = %x\n", unit, ler2->ler2_ladrf[0]);
+ printf("le%d: ladrf[1] = %x\n", unit, ler2->ler2_ladrf[1]);
+ printf("le%d: ler2_rdra = %x\n", unit, ler2->ler2_rdra);
+ printf("le%d: ler2_rlen = %x\n", unit, ler2->ler2_rlen);
+ printf("le%d: ler2_tdra = %x\n", unit, ler2->ler2_tdra);
+ printf("le%d: ler2_tlen = %x\n", unit, ler2->ler2_tlen);
+
+ for (i = 0; i < LERBUF; i++) {
+ printf("le%d: ler2_rmd[%d].rmd0 (ladr) = %x\n", unit, i,
+ ler2->ler2_rmd[i].rmd0);
+ printf("le%d: ler2_rmd[%d].rmd1 = %x\n", unit, i,
+ ler2->ler2_rmd[i].rmd1);
+ printf("le%d: ler2_rmd[%d].rmd2 (-bcnt) = %x\n", unit, i,
+ ler2->ler2_rmd[i].rmd2);
+ printf("le%d: ler2_rmd[%d].rmd3 (mcnt) = %x\n", unit, i,
+ ler2->ler2_rmd[i].rmd3);
+ printf("le%d: ler2_rbuf[%d] addr = %x\n", unit, i,
+ &ler2->ler2_rbuf[i]);
+ }
+ for (i = 0; i < LETBUF; i++) {
+ printf("le%d: ler2_tmd[%d].tmd0 = %x\n", unit, i,
+ ler2->ler2_tmd[i].tmd0);
+ printf("le%d: ler2_tmd[%d].tmd1 = %x\n", unit, i,
+ ler2->ler2_tmd[i].tmd1);
+ printf("le%d: ler2_tmd[%d].tmd2 (bcnt) = %x\n", unit, i,
+ ler2->ler2_tmd[i].tmd2);
+ printf("le%d: ler2_tmd[%d].tmd3 = %x\n", unit, i,
+ ler2->ler2_tmd[i].tmd3);
+ printf("le%d: ler2_tbuf[%d] addr = %x\n", unit, i,
+ &ler2->ler2_tbuf[i]);
+ }
+}
+#else
+#define le_mem_summary(u)
+#endif
+
+void
+le_error(unit, str, stat)
+ int unit;
+ char *str;
+ u_short stat;
+{
+
+ if (stat & LE_BABL)
+ panic("le%d: been babbling, found by '%s'\n", unit, str);
+ if (stat & LE_CERR)
+ le_stats[unit].collision_error++;
+ if (stat & LE_MISS)
+ le_stats[unit].missed++;
+ if (stat & LE_MERR) {
+ printf("le%d: memory error in '%s'\n", unit, str);
+ le_mem_summary(unit);
+ panic("bye");
+ }
+}
+
+#define LANCE_ADDR(sc, a) \
+ ((u_long)(a) - (u_long)sc->sc_mem)
+
+/* LANCE initialization block set up. */
+void
+lememinit(sc)
+ register struct le_softc *sc;
+{
+ int i;
+ void *mem;
+ u_long a;
+
+ /*
+ * At this point we assume that the memory allocated to the Lance is
+ * quadword aligned. If it isn't then the initialisation is going
+ * fail later on.
+ */
+ mem = sc->sc_mem;
+
+ sc->sc_init = mem;
+ sc->sc_init->mode = LE_NORMAL;
+ for (i = 0; i < ETHER_ADDR_LEN; i++)
+ sc->sc_init->padr[i] = sc->sc_addr[i^1];
+ sc->sc_init->ladrf[0] = sc->sc_init->ladrf[1] = 0;
+ mem += sizeof(struct init_block);
+
+ sc->sc_rd = mem;
+ a = LANCE_ADDR(sc, mem);
+ sc->sc_init->rdra = a;
+ sc->sc_init->rlen = ((a >> 16) & 0xff) | (RLEN << 13);
+ mem += NRBUF * sizeof(struct mds);
+
+ sc->sc_td = mem;
+ a = LANCE_ADDR(sc, mem);
+ sc->sc_init->tdra = a;
+ sc->sc_init->tlen = ((a >> 16) & 0xff) | (TLEN << 13);
+ mem += NTBUF * sizeof(struct mds);
+
+ /*
+ * Set up receive ring descriptors.
+ */
+ sc->sc_rbuf = mem;
+ for (i = 0; i < NRBUF; i++) {
+ a = LANCE_ADDR(sc, mem);
+ sc->sc_rd[i].addr = a;
+ sc->sc_rd[i].flags = ((a >> 16) & 0xff) | LE_OWN;
+ sc->sc_rd[i].bcnt = -BUFSIZE;
+ sc->sc_rd[i].mcnt = 0;
+ mem += BUFSIZE;
+ }
+
+ /*
+ * Set up transmit ring descriptors.
+ */
+ sc->sc_tbuf = mem;
+ for (i = 0; i < NTBUF; i++) {
+ a = LANCE_ADDR(sc, mem);
+ sc->sc_td[i].addr = a;
+ sc->sc_td[i].flags = ((a >> 16) & 0xff);
+ sc->sc_td[i].bcnt = 0xf000;
+ sc->sc_td[i].mcnt = 0;
+ mem += BUFSIZE;
+ }
+}
+
+void
+le_reset(unit, myea)
+ int unit;
+ u_char *myea;
+{
+ struct le_softc *sc = &le_softc[unit];
+ u_long a;
+ int timo = 100000, stat, i;
+
+#ifdef LE_DEBUG
+ if (le_debug) {
+ printf("le%d: le_reset called\n", unit);
+ printf(" r0=%x, r1=%x, mem=%x, addr=%x:%x:%x:%x:%x:%x\n",
+ sc->sc_r0, sc->sc_r1, sc->sc_mem,
+ sc->sc_addr[0], sc->sc_addr[1], sc->sc_addr[2],
+ sc->sc_addr[3], sc->sc_addr[4], sc->sc_addr[5]);
+ }
+#endif
+ lewrcsr(sc, 0, LE_STOP);
+ for (timo = 1000; timo; timo--);
+
+ sc->sc_next_rd = sc->sc_next_td = 0;
+
+ /* Set up LANCE init block. */
+ lememinit(sc);
+
+ if (myea)
+ bcopy(sc->sc_addr, myea, ETHER_ADDR_LEN);
+
+ /* Turn on byte swapping. */
+ lewrcsr(sc, 3, LE_BSWP);
+
+ /* Give LANCE the physical address of its init block. */
+ a = LANCE_ADDR(sc, sc->sc_init);
+ lewrcsr(sc, 1, a);
+ lewrcsr(sc, 2, (a >> 16) & 0xff);
+
+#ifdef LE_DEBUG
+ if (le_debug)
+ printf("le%d: before init\n", unit);
+#endif
+
+ /* Try to initialize the LANCE. */
+ lewrcsr(sc, 0, LE_INIT);
+
+ /* Wait for initialization to finish. */
+ for (timo = 100000; timo; timo--)
+ if (lerdcsr(sc, 0) & LE_IDON)
+ break;
+
+ if (lerdcsr(sc, 0) & LE_IDON) {
+ /* Start the LANCE. */
+ lewrcsr(sc, 0, LE_INEA | LE_STRT | LE_IDON);
+ } else
+ printf("le%d: card failed to initialize\n", unit);
+
+#ifdef LE_DEBUG
+ if (le_debug)
+ printf("le%d: after init\n", unit);
+#endif
+
+ le_mem_summary(unit);
+}
+
+int
+le_poll(desc, pkt, len)
+ struct iodesc *desc;
+ void *pkt;
+ int len;
+{
+ struct netif *nif = desc->io_netif;
+ int unit = /*nif->nif_unit*/0;
+ struct le_softc *sc = &le_softc[unit];
+ volatile struct lereg0 *ler0 = sc->sc_r0;
+ volatile struct lereg1 *ler1 = sc->sc_r1;
+ int length;
+ volatile struct mds *cdm;
+ register int stat;
+
+#ifdef LE_DEBUG
+ if (/*le_debug*/0)
+ printf("le%d: le_poll called. next_rd=%d\n", unit, sc->sc_next_rd);
+#endif
+ stat = lerdcsr(sc, 0);
+ lewrcsr(sc, 0, stat & (LE_BABL | LE_MISS | LE_MERR | LE_RINT));
+ cdm = &sc->sc_rd[sc->sc_next_rd];
+ if (cdm->flags & LE_OWN)
+ return 0;
+#ifdef LE_DEBUG
+ if (le_debug) {
+ printf("next_rd %d\n", sc->sc_next_rd);
+ printf("cdm->flags %x\n", cdm->flags);
+ printf("cdm->bcnt %x, cdm->mcnt %x\n", cdm->bcnt, cdm->mcnt);
+ printf("cdm->rbuf msg %d buf %d\n", cdm->mcnt, -cdm->bcnt );
+ }
+#endif
+ if (stat & (LE_BABL | LE_CERR | LE_MISS | LE_MERR))
+ le_error(unit, "le_poll", stat);
+ if (cdm->flags & (LE_FRAM | LE_OFLO | LE_CRC | LE_RBUFF)) {
+ printf("le%d_poll: rmd status 0x%x\n", unit, cdm->flags);
+ length = 0;
+ goto cleanup;
+ }
+ if ((cdm->flags & (LE_STP|LE_ENP)) != (LE_STP|LE_ENP))
+ panic("le_poll: chained packet\n");
+
+ length = cdm->mcnt;
+#ifdef LE_DEBUG
+ if (le_debug)
+ printf("le_poll: length %d\n", length);
+#endif
+ if (length >= BUFSIZE) {
+ length = 0;
+ panic("csr0 when bad things happen: %x\n", stat);
+ goto cleanup;
+ }
+ if (!length)
+ goto cleanup;
+ length -= 4;
+ if (length > 0)
+ bcopy(sc->sc_rbuf + (BUFSIZE * sc->sc_next_rd), pkt, length);
+
+cleanup:
+ cdm->mcnt = 0;
+ cdm->flags |= LE_OWN;
+ if (++sc->sc_next_rd >= NRBUF)
+ sc->sc_next_rd = 0;
+#ifdef LE_DEBUG
+ if (le_debug)
+ printf("new next_rd %d\n", sc->sc_next_rd);
+#endif
+
+ return length;
+}
+
+int
+le_put(desc, pkt, len)
+ struct iodesc *desc;
+ void *pkt;
+ int len;
+{
+ struct netif *nif = desc->io_netif;
+ int unit = /*nif->nif_unit*/0;
+ struct le_softc *sc = &le_softc[unit];
+ volatile struct lereg0 *ler0 = sc->sc_r0;
+ volatile struct lereg1 *ler1 = sc->sc_r1;
+ volatile struct mds *cdm;
+ int timo, i, stat;
+
+ le_put_loop:
+ timo = 100000;
+
+#ifdef LE_DEBUG
+ if (le_debug)
+ printf("le%d: le_put called. next_td=%d\n", unit, sc->sc_next_td);
+#endif
+ stat = lerdcsr(sc, 0);
+ lewrcsr(sc, 0, stat & (LE_BABL | LE_MISS | LE_MERR | LE_TINT));
+ if (stat & (LE_BABL | LE_CERR | LE_MISS | LE_MERR))
+ le_error(unit, "le_put(way before xmit)", stat);
+ cdm = &sc->sc_td[sc->sc_next_td];
+ i = 0;
+#if 0
+ while (cdm->flags & LE_OWN) {
+ if ((i % 100) == 0)
+ printf("le%d: output buffer busy - flags=%x\n",
+ unit, cdm->flags);
+ if (i++ > 500) break;
+ }
+ if (cdm->flags & LE_OWN)
+ getchar();
+#else
+ while (cdm->flags & LE_OWN);
+#endif
+ bcopy(pkt, sc->sc_tbuf + (BUFSIZE * sc->sc_next_td), len);
+ if (len < ETHER_MIN_LEN)
+ cdm->bcnt = -ETHER_MIN_LEN;
+ else
+ cdm->bcnt = -len;
+ cdm->mcnt = 0;
+ cdm->flags |= LE_OWN | LE_STP | LE_ENP;
+ stat = lerdcsr(sc, 0);
+ if (stat & (LE_BABL | LE_CERR | LE_MISS | LE_MERR))
+ le_error(unit, "le_put(before xmit)", stat);
+ lewrcsr(sc, 0, LE_TDMD);
+ stat = lerdcsr(sc, 0);
+ if (stat & (LE_BABL | LE_CERR | LE_MISS | LE_MERR))
+ le_error(unit, "le_put(after xmit)", stat);
+ do {
+ if (--timo == 0) {
+ printf("le%d: transmit timeout, stat = 0x%x\n",
+ unit, stat);
+ if (stat & LE_SERR)
+ le_error(unit, "le_put(timeout)", stat);
+ if (stat & LE_INIT) {
+ printf("le%d: reset and retry packet\n");
+ lewrcsr(sc, 0, LE_TINT); /* sanity */
+ le_init();
+ goto le_put_loop;
+ }
+ break;
+ }
+ stat = lerdcsr(sc, 0);
+ } while ((stat & LE_TINT) == 0);
+ lewrcsr(sc, 0, LE_TINT);
+ if (stat & (LE_BABL |/* LE_CERR |*/ LE_MISS | LE_MERR)) {
+ printf("le_put: xmit error, buf %d\n", sc->sc_next_td);
+ le_error(unit, "le_put(xmit error)", stat);
+ }
+ if (++sc->sc_next_td >= NTBUF)
+ sc->sc_next_td = 0;
+ if (cdm->flags & LE_DEF)
+ le_stats[unit].deferred++;
+ if (cdm->flags & LE_ONE)
+ le_stats[unit].collisions++;
+ if (cdm->flags & LE_MORE)
+ le_stats[unit].collisions+=2;
+ if (cdm->flags & LE_ERR) {
+ printf("le%d: transmit error, error = 0x%x\n", unit,
+ cdm->mcnt);
+ return -1;
+ }
+#ifdef LE_DEBUG
+ if (le_debug) {
+ printf("le%d: le_put() successful: sent %d\n", unit, len);
+ printf("le%d: le_put(): flags: %x mcnt: %x\n", unit,
+ (unsigned int) cdm->flags,
+ (unsigned int) cdm->mcnt);
+ }
+#endif
+ return len;
+}
+
+
+int
+le_get(desc, pkt, len, timeout)
+ struct iodesc *desc;
+ void *pkt;
+ int len;
+ time_t timeout;
+{
+ time_t t;
+ int cc;
+
+ t = getsecs();
+ cc = 0;
+ while (((getsecs() - t) < timeout) && !cc) {
+ cc = le_poll(desc, pkt, len);
+ }
+ return cc;
+}
+
+void
+le_init(desc, machdep_hint)
+ struct iodesc *desc;
+ void *machdep_hint;
+{
+ struct netif *nif = desc->io_netif;
+ int unit = nif->nif_unit;
+
+ /* Get machine's common ethernet interface. This is done in leinit() */
+ /* machdep_common_ether(myea); */
+ leinit();
+
+#ifdef LE_DEBUG
+ if (le_debug)
+ printf("le%d: le_init called\n", unit);
+#endif
+ unit = 0;
+ le_reset(unit, desc->myea);
+}
+
+void
+le_end(nif)
+ struct netif *nif;
+{
+ int unit = nif->nif_unit;
+
+#ifdef LE_DEBUG
+ if (le_debug)
+ printf("le%d: le_end called\n", unit);
+#endif
+
+ lewrcsr(&le_softc[unit], 0, LE_STOP);
+}
diff --git a/sys/arch/hp300/stand/installboot.sh b/sys/arch/hp300/stand/installboot.sh
new file mode 100644
index 00000000000..a5605dfa416
--- /dev/null
+++ b/sys/arch/hp300/stand/installboot.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+# $NetBSD: installboot.sh,v 1.2 1994/10/26 07:27:26 cgd Exp $
+
+# compatibility with old installboot program
+#
+# @(#)installboot.sh 8.1 (Berkeley) 6/10/93
+#
+if [ $# != 2 ]
+then
+ echo "Usage: installboot bootprog device"
+ exit 1
+fi
+if [ ! -f $1 ]
+then
+ echo "Usage: installboot bootprog device"
+ echo "${1}: bootprog must be a regular file"
+ exit 1
+fi
+if [ ! -c $2 ]
+then
+ echo "Usage: installboot bootprog device"
+ echo "${2}: device must be a char special file"
+ exit 1
+fi
+/sbin/disklabel -B -b $1 $2
+exit $?
diff --git a/sys/arch/hp300/stand/ite.c b/sys/arch/hp300/stand/ite.c
new file mode 100644
index 00000000000..b8390e4c0f5
--- /dev/null
+++ b/sys/arch/hp300/stand/ite.c
@@ -0,0 +1,314 @@
+/* $NetBSD: ite.c,v 1.10 1995/10/04 06:54:47 thorpej Exp $ */
+
+/*
+ * Copyright (c) 1988 University of Utah.
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * from: Utah $Hdr: ite.c 1.24 93/06/25$
+ *
+ * @(#)ite.c 8.1 (Berkeley) 7/8/93
+ */
+
+/*
+ * Standalone Internal Terminal Emulator (CRT and keyboard)
+ */
+
+#ifdef ITECONSOLE
+
+#include <sys/param.h>
+#include <dev/cons.h>
+#include <hp300/dev/device.h>
+#include <hp300/dev/itevar.h>
+#include <hp300/dev/grfreg.h>
+#include <hp300/stand/consdefs.h>
+#include <hp300/stand/samachdep.h>
+
+extern int nodev();
+extern u_char ite_readbyte();
+extern int ite_writeglyph();
+
+extern int topcat_init(), topcat_putc();
+extern int topcat_clear(), topcat_cursor(), topcat_scroll();
+extern int gbox_init(), gbox_clear();
+extern int gbox_putc(), gbox_cursor(), gbox_scroll();
+extern int rbox_init(), rbox_clear();
+extern int rbox_putc(), rbox_cursor(), rbox_scroll();
+extern int dvbox_init(), dvbox_clear();
+extern int dvbox_putc(), dvbox_cursor(), dvbox_scroll();
+extern int hyper_init(), hyper_clear();
+extern int hyper_putc(), hyper_cursor(), hyper_scroll();
+
+struct itesw itesw[] = {
+ GID_TOPCAT,
+ topcat_init, nodev, topcat_clear, topcat_putc,
+ topcat_cursor, topcat_scroll, ite_readbyte, ite_writeglyph,
+ GID_GATORBOX,
+ gbox_init, nodev, gbox_clear, gbox_putc,
+ gbox_cursor, gbox_scroll, ite_readbyte, ite_writeglyph,
+ GID_RENAISSANCE,
+ rbox_init, nodev, rbox_clear, rbox_putc,
+ rbox_cursor, rbox_scroll, ite_readbyte, ite_writeglyph,
+ GID_LRCATSEYE,
+ topcat_init, nodev, topcat_clear, topcat_putc,
+ topcat_cursor, topcat_scroll, ite_readbyte, ite_writeglyph,
+ GID_HRCCATSEYE,
+ topcat_init, nodev, topcat_clear, topcat_putc,
+ topcat_cursor, topcat_scroll, ite_readbyte, ite_writeglyph,
+ GID_HRMCATSEYE,
+ topcat_init, nodev, topcat_clear, topcat_putc,
+ topcat_cursor, topcat_scroll, ite_readbyte, ite_writeglyph,
+ GID_DAVINCI,
+ dvbox_init, nodev, dvbox_clear, dvbox_putc,
+ dvbox_cursor, dvbox_scroll, ite_readbyte, ite_writeglyph,
+ GID_HYPERION,
+ hyper_init, nodev, hyper_clear, hyper_putc,
+ hyper_cursor, hyper_scroll, ite_readbyte, ite_writeglyph,
+};
+int nitesw = sizeof(itesw) / sizeof(itesw[0]);
+
+/* these guys need to be in initialized data */
+int itecons = -1;
+struct ite_softc ite_softc[NITE] = { 0 };
+int ite_scode[NITE] = { 0 };
+
+/*
+ * Locate all bitmapped displays
+ */
+iteconfig()
+{
+ extern struct hp_hw sc_table[];
+ int dtype, fboff, i;
+ struct hp_hw *hw;
+ struct grfreg *gr;
+ struct ite_softc *ip;
+
+ i = 0;
+ for (hw = sc_table; hw < &sc_table[MAXCTLRS]; hw++) {
+ if (!HW_ISDEV(hw, D_BITMAP))
+ continue;
+ gr = (struct grfreg *) hw->hw_kva;
+ /* XXX: redundent but safe */
+ if (badaddr((caddr_t)gr) || gr->gr_id != GRFHWID)
+ continue;
+ for (dtype = 0; dtype < nitesw; dtype++)
+ if (itesw[dtype].ite_hwid == gr->gr_id2)
+ break;
+ if (dtype == nitesw)
+ continue;
+ if (i >= NITE)
+ break;
+ ite_scode[i] = hw->hw_sc;
+ ip = &ite_softc[i];
+ ip->isw = &itesw[dtype];
+ ip->regbase = (caddr_t) gr;
+ fboff = (gr->gr_fbomsb << 8) | gr->gr_fbolsb;
+ ip->fbbase = (caddr_t) (*((u_char *)ip->regbase+fboff) << 16);
+ /* DIO II: FB offset is relative to select code space */
+ if (ip->regbase >= (caddr_t)DIOIIBASE)
+ ip->fbbase += (int)ip->regbase;
+ ip->fbwidth = gr->gr_fbwidth_h << 8 | gr->gr_fbwidth_l;
+ ip->fbheight = gr->gr_fbheight_h << 8 | gr->gr_fbheight_l;
+ ip->dwidth = gr->gr_dwidth_h << 8 | gr->gr_dwidth_l;
+ ip->dheight = gr->gr_dheight_h << 8 | gr->gr_dheight_l;
+ /*
+ * XXX some displays (e.g. the davinci) appear
+ * to return a display height greater than the
+ * returned FB height. Guess we should go back
+ * to getting the display dimensions from the
+ * fontrom...
+ */
+ if (ip->dwidth > ip->fbwidth)
+ ip->dwidth = ip->fbwidth;
+ if (ip->dheight > ip->fbheight)
+ ip->dheight = ip->fbheight;
+ ip->flags = ITE_ALIVE|ITE_CONSOLE;
+ i++;
+ }
+}
+
+#ifdef CONSDEBUG
+/*
+ * Allows us to cycle through all possible consoles (NITE ites and serial port)
+ * by using SHIFT-RESET on the keyboard.
+ */
+int whichconsole = -1;
+#endif
+
+void
+iteprobe(cp)
+ struct consdev *cp;
+{
+ register int ite;
+ register struct ite_softc *ip;
+ int unit, pri;
+
+#ifdef CONSDEBUG
+ whichconsole = ++whichconsole % (NITE+1);
+#endif
+
+ if (itecons != -1)
+ return;
+
+ iteconfig();
+ unit = -1;
+ pri = CN_DEAD;
+ for (ite = 0; ite < NITE; ite++) {
+#ifdef CONSDEBUG
+ if (ite < whichconsole)
+ continue;
+#endif
+ ip = &ite_softc[ite];
+ if ((ip->flags & (ITE_ALIVE|ITE_CONSOLE))
+ != (ITE_ALIVE|ITE_CONSOLE))
+ continue;
+ if ((int)ip->regbase == GRFIADDR) {
+ pri = CN_INTERNAL;
+ unit = ite;
+ } else if (unit < 0) {
+ pri = CN_NORMAL;
+ unit = ite;
+ }
+ }
+ curcons_scode = ite_scode[unit];
+ cp->cn_dev = unit;
+ cp->cn_pri = pri;
+}
+
+void
+iteinit(cp)
+ struct consdev *cp;
+{
+ int ite = cp->cn_dev;
+ struct ite_softc *ip;
+
+ if (itecons != -1)
+ return;
+
+ ip = &ite_softc[ite];
+
+ ip->curx = 0;
+ ip->cury = 0;
+ ip->cursorx = 0;
+ ip->cursory = 0;
+
+ (*ip->isw->ite_init)(ip);
+ (*ip->isw->ite_cursor)(ip, DRAW_CURSOR);
+
+ itecons = ite;
+ kbdinit();
+}
+
+/* ARGSUSED */
+void
+iteputchar(dev, c)
+ dev_t dev;
+ register int c;
+{
+ register struct ite_softc *ip = &ite_softc[itecons];
+ register struct itesw *sp = ip->isw;
+
+ c &= 0x7F;
+ switch (c) {
+
+ case '\n':
+ if (++ip->cury == ip->rows) {
+ ip->cury--;
+ (*sp->ite_scroll)(ip, 1, 0, 1, SCROLL_UP);
+ ite_clrtoeol(ip, sp, ip->cury, 0);
+ }
+ else
+ (*sp->ite_cursor)(ip, MOVE_CURSOR);
+ break;
+
+ case '\r':
+ ip->curx = 0;
+ (*sp->ite_cursor)(ip, MOVE_CURSOR);
+ break;
+
+ case '\b':
+ if (--ip->curx < 0)
+ ip->curx = 0;
+ else
+ (*sp->ite_cursor)(ip, MOVE_CURSOR);
+ break;
+
+ default:
+ if (c < ' ' || c == 0177)
+ break;
+ (*sp->ite_putc)(ip, c, ip->cury, ip->curx, ATTR_NOR);
+ (*sp->ite_cursor)(ip, DRAW_CURSOR);
+ itecheckwrap(ip, sp);
+ break;
+ }
+}
+
+itecheckwrap(ip, sp)
+ register struct ite_softc *ip;
+ register struct itesw *sp;
+{
+ if (++ip->curx == ip->cols) {
+ ip->curx = 0;
+ if (++ip->cury == ip->rows) {
+ --ip->cury;
+ (*sp->ite_scroll)(ip, 1, 0, 1, SCROLL_UP);
+ ite_clrtoeol(ip, sp, ip->cury, 0);
+ return;
+ }
+ }
+ (*sp->ite_cursor)(ip, MOVE_CURSOR);
+}
+
+ite_clrtoeol(ip, sp, y, x)
+ register struct ite_softc *ip;
+ register struct itesw *sp;
+ register int y, x;
+{
+ (*sp->ite_clear)(ip, y, x, 1, ip->cols - x);
+ (*sp->ite_cursor)(ip, DRAW_CURSOR);
+}
+
+/* ARGSUSED */
+int
+itegetchar(dev)
+ dev_t dev;
+{
+#ifdef SMALL
+ return (0);
+#else
+ return (kbdgetc());
+#endif
+}
+#endif
diff --git a/sys/arch/hp300/stand/ite_dv.c b/sys/arch/hp300/stand/ite_dv.c
new file mode 100644
index 00000000000..b636a2e7549
--- /dev/null
+++ b/sys/arch/hp300/stand/ite_dv.c
@@ -0,0 +1,254 @@
+/* $NetBSD: ite_dv.c,v 1.7 1994/10/26 07:27:31 cgd Exp $ */
+
+/*
+ * Copyright (c) 1988 University of Utah.
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * from: Utah $Hdr: ite_dv.c 1.2 92/01/20$
+ *
+ * @(#)ite_dv.c 8.1 (Berkeley) 6/10/93
+ */
+
+#include <hp300/stand/samachdep.h>
+
+#ifdef ITECONSOLE
+
+#include <sys/param.h>
+#include <hp300/dev/itevar.h>
+#include <hp300/dev/itereg.h>
+#include <hp300/dev/grf_dvreg.h>
+
+#define REGBASE ((struct dvboxfb *)(ip->regbase))
+#define WINDOWMOVER dvbox_windowmove
+
+dvbox_init(ip)
+ struct ite_softc *ip;
+{
+ int i;
+
+ dv_reset(ip->regbase);
+ DELAY(4000);
+
+ /*
+ * Turn on frame buffer, turn on overlay planes, set replacement
+ * rule, enable top overlay plane writes for ite, disable all frame
+ * buffer planes, set byte per pixel, and display frame buffer 0.
+ * Lastly, turn on the box.
+ */
+ REGBASE->interrupt = 0x04;
+ REGBASE->drive = 0x10;
+ REGBASE->rep_rule = RR_COPY << 4 | RR_COPY;
+ REGBASE->opwen = 0x01;
+ REGBASE->fbwen = 0x0;
+ REGBASE->fold = 0x01;
+ REGBASE->vdrive = 0x0;
+ REGBASE->dispen = 0x01;
+
+ /*
+ * Video enable top overlay plane.
+ */
+ REGBASE->opvenp = 0x01;
+ REGBASE->opvens = 0x01;
+
+ /*
+ * Make sure that overlay planes override frame buffer planes.
+ */
+ REGBASE->ovly0p = 0x0;
+ REGBASE->ovly0s = 0x0;
+ REGBASE->ovly1p = 0x0;
+ REGBASE->ovly1s = 0x0;
+ REGBASE->fv_trig = 0x1;
+ DELAY(400);
+
+ /*
+ * Setup the overlay colormaps. Need to set the 0,1 (black/white)
+ * color for both banks.
+ */
+
+ for (i = 0; i <= 1; i++) {
+ REGBASE->cmapbank = i;
+ REGBASE->rgb[0].red = 0x00;
+ REGBASE->rgb[0].green = 0x00;
+ REGBASE->rgb[0].blue = 0x00;
+ REGBASE->rgb[1].red = 0xFF;
+ REGBASE->rgb[1].green = 0xFF;
+ REGBASE->rgb[1].blue = 0xFF;
+ }
+ REGBASE->cmapbank = 0;
+
+ db_waitbusy(ip->regbase);
+
+ ite_fontinfo(ip);
+ ite_fontinit(ip);
+
+ /*
+ * Clear the (visible) framebuffer.
+ */
+ dvbox_windowmove(ip, 0, 0, 0, 0, ip->dheight, ip->dwidth, RR_CLEAR);
+ db_waitbusy(ip->regbase);
+
+ /*
+ * Stash the inverted cursor.
+ */
+ dvbox_windowmove(ip, charY(ip, ' '), charX(ip, ' '),
+ ip->cblanky, ip->cblankx, ip->ftheight,
+ ip->ftwidth, RR_COPYINVERTED);
+ db_waitbusy(ip->regbase);
+}
+
+dvbox_putc(ip, c, dy, dx, mode)
+ register struct ite_softc *ip;
+ register int dy, dx;
+ int c, mode;
+{
+ dvbox_windowmove(ip, charY(ip, c), charX(ip, c),
+ dy * ip->ftheight, dx * ip->ftwidth,
+ ip->ftheight, ip->ftwidth, RR_COPY);
+}
+
+dvbox_cursor(ip, flag)
+ register struct ite_softc *ip;
+ register int flag;
+{
+ if (flag == DRAW_CURSOR)
+ draw_cursor(ip)
+ else if (flag == MOVE_CURSOR) {
+ erase_cursor(ip)
+ draw_cursor(ip)
+ }
+ else
+ erase_cursor(ip)
+}
+
+dvbox_clear(ip, sy, sx, h, w)
+ struct ite_softc *ip;
+ register int sy, sx, h, w;
+{
+ dvbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
+ sy * ip->ftheight, sx * ip->ftwidth,
+ h * ip->ftheight, w * ip->ftwidth,
+ RR_CLEAR);
+}
+
+dvbox_scroll(ip, sy, sx, count, dir)
+ register struct ite_softc *ip;
+ register int sy, count;
+ int dir, sx;
+{
+ register int dy = sy - count;
+ register int height = ip->rows - sy;
+
+ dvbox_cursor(ip, ERASE_CURSOR);
+
+ dvbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
+ dy * ip->ftheight, sx * ip->ftwidth,
+ height * ip->ftheight,
+ ip->cols * ip->ftwidth, RR_COPY);
+}
+
+dvbox_windowmove(ip, sy, sx, dy, dx, h, w, func)
+ struct ite_softc *ip;
+ int sy, sx, dy, dx, h, w, func;
+{
+ register struct dvboxfb *dp = REGBASE;
+ if (h == 0 || w == 0)
+ return;
+
+ db_waitbusy(ip->regbase);
+ dp->rep_rule = func << 4 | func;
+ dp->source_y = sy;
+ dp->source_x = sx;
+ dp->dest_y = dy;
+ dp->dest_x = dx;
+ dp->wheight = h;
+ dp->wwidth = w;
+ dp->wmove = 1;
+}
+
+dv_reset(dbp)
+ register struct dvboxfb *dbp;
+{
+ dbp->reset = 0x80;
+ DELAY(400);
+
+ dbp->interrupt = 0x04;
+ dbp->en_scan = 0x01;
+ dbp->fbwen = ~0;
+ dbp->opwen = ~0;
+ dbp->fold = 0x01;
+ dbp->drive = 0x01;
+ dbp->rep_rule = 0x33;
+ dbp->alt_rr = 0x33;
+ dbp->zrr = 0x33;
+
+ dbp->fbvenp = 0xFF;
+ dbp->dispen = 0x01;
+ dbp->fbvens = 0x0;
+ dbp->fv_trig = 0x01;
+ DELAY(400);
+ dbp->vdrive = 0x0;
+ dbp->zconfig = 0x0;
+
+ while (dbp->wbusy & 0x01)
+ DELAY(400);
+
+ /*
+ * Start of missing ROM code.
+ */
+ dbp->cmapbank = 0;
+
+ dbp->red0 = 0;
+ dbp->red1 = 0;
+ dbp->green0 = 0;
+ dbp->green1 = 0;
+ dbp->blue0 = 0;
+ dbp->blue1 = 0;
+
+ dbp->panxh = 0;
+ dbp->panxl = 0;
+ dbp->panyh = 0;
+ dbp->panyl = 0;
+ dbp->zoom = 0;
+ dbp->cdwidth = 0x50;
+ dbp->chstart = 0x52;
+ dbp->cvwidth = 0x22;
+ dbp->pz_trig = 1;
+ /*
+ * End of missing ROM code.
+ */
+}
+
+#endif
diff --git a/sys/arch/hp300/stand/ite_gb.c b/sys/arch/hp300/stand/ite_gb.c
new file mode 100644
index 00000000000..9a4f7dcce2e
--- /dev/null
+++ b/sys/arch/hp300/stand/ite_gb.c
@@ -0,0 +1,199 @@
+/* $NetBSD: ite_gb.c,v 1.7 1994/10/26 07:27:33 cgd Exp $ */
+
+/*
+ * Copyright (c) 1988 University of Utah.
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * from: Utah $Hdr: ite_gb.c 1.9 92/01/20$
+ *
+ * @(#)ite_gb.c 8.1 (Berkeley) 6/10/93
+ */
+
+#include <hp300/stand/samachdep.h>
+
+#ifdef ITECONSOLE
+
+#include <sys/param.h>
+
+#include <hp300/dev/itevar.h>
+#include <hp300/dev/itereg.h>
+#include <hp300/dev/grf_gbreg.h>
+
+#define REGBASE ((struct gboxfb *)(ip->regbase))
+#define WINDOWMOVER gbox_windowmove
+
+gbox_init(ip)
+ register struct ite_softc *ip;
+{
+ REGBASE->write_protect = 0x0;
+ REGBASE->interrupt = 0x4;
+ REGBASE->rep_rule = RR_COPY;
+ REGBASE->blink1 = 0xff;
+ REGBASE->blink2 = 0xff;
+ REGBASE->sec_interrupt = 0x01;
+
+ /*
+ * Set up the color map entries. We use three entries in the
+ * color map. The first, is for black, the second is for
+ * white, and the very last entry is for the inverted cursor.
+ */
+ REGBASE->creg_select = 0x00;
+ REGBASE->cmap_red = 0x00;
+ REGBASE->cmap_grn = 0x00;
+ REGBASE->cmap_blu = 0x00;
+ REGBASE->cmap_write = 0x00;
+ gbcm_waitbusy(ip->regbase);
+
+ REGBASE->creg_select = 0x01;
+ REGBASE->cmap_red = 0xFF;
+ REGBASE->cmap_grn = 0xFF;
+ REGBASE->cmap_blu = 0xFF;
+ REGBASE->cmap_write = 0x01;
+ gbcm_waitbusy(ip->regbase);
+
+ REGBASE->creg_select = 0xFF;
+ REGBASE->cmap_red = 0xFF;
+ REGBASE->cmap_grn = 0xFF;
+ REGBASE->cmap_blu = 0xFF;
+ REGBASE->cmap_write = 0x01;
+ gbcm_waitbusy(ip->regbase);
+
+ ite_fontinfo(ip);
+ ite_fontinit(ip);
+
+ /*
+ * Clear the display. This used to be before the font unpacking
+ * but it crashes. Figure it out later.
+ */
+ gbox_windowmove(ip, 0, 0, 0, 0, ip->dheight, ip->dwidth, RR_CLEAR);
+ tile_mover_waitbusy(ip->regbase);
+
+ /*
+ * Stash the inverted cursor.
+ */
+ gbox_windowmove(ip, charY(ip, ' '), charX(ip, ' '),
+ ip->cblanky, ip->cblankx, ip->ftheight,
+ ip->ftwidth, RR_COPYINVERTED);
+}
+
+gbox_putc(ip, c, dy, dx, mode)
+ register struct ite_softc *ip;
+ register int dy, dx;
+ int c, mode;
+{
+ gbox_windowmove(ip, charY(ip, c), charX(ip, c),
+ dy * ip->ftheight, dx * ip->ftwidth,
+ ip->ftheight, ip->ftwidth, RR_COPY);
+}
+
+gbox_cursor(ip, flag)
+ register struct ite_softc *ip;
+ register int flag;
+{
+ if (flag == DRAW_CURSOR)
+ draw_cursor(ip)
+ else if (flag == MOVE_CURSOR) {
+ erase_cursor(ip)
+ draw_cursor(ip)
+ }
+ else
+ erase_cursor(ip)
+}
+
+gbox_clear(ip, sy, sx, h, w)
+ struct ite_softc *ip;
+ register int sy, sx, h, w;
+{
+ gbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
+ sy * ip->ftheight, sx * ip->ftwidth,
+ h * ip->ftheight, w * ip->ftwidth,
+ RR_CLEAR);
+}
+
+#define gbox_blockmove(ip, sy, sx, dy, dx, h, w) \
+ gbox_windowmove((ip), \
+ (sy) * ip->ftheight, \
+ (sx) * ip->ftwidth, \
+ (dy) * ip->ftheight, \
+ (dx) * ip->ftwidth, \
+ (h) * ip->ftheight, \
+ (w) * ip->ftwidth, \
+ RR_COPY)
+
+gbox_scroll(ip, sy, sx, count, dir)
+ register struct ite_softc *ip;
+ register int sy;
+ int dir, sx, count;
+{
+ register int height, dy, i;
+
+ tile_mover_waitbusy(ip->regbase);
+ REGBASE->write_protect = 0x0;
+
+ gbox_cursor(ip, ERASE_CURSOR);
+
+ dy = sy - count;
+ height = ip->rows - sy;
+ for (i = 0; i < height; i++)
+ gbox_blockmove(ip, sy + i, sx, dy + i, 0, 1, ip->cols);
+}
+
+gbox_windowmove(ip, sy, sx, dy, dx, h, w, mask)
+ register struct ite_softc *ip;
+ int sy, sx, dy, dx, mask;
+ register int h, w;
+{
+ register int src, dest;
+
+ src = (sy * 1024) + sx; /* upper left corner in pixels */
+ dest = (dy * 1024) + dx;
+
+ tile_mover_waitbusy(ip->regbase);
+ REGBASE->width = -(w / 4);
+ REGBASE->height = -(h / 4);
+ if (src < dest)
+ REGBASE->rep_rule = MOVE_DOWN_RIGHT|mask;
+ else {
+ REGBASE->rep_rule = MOVE_UP_LEFT|mask;
+ /*
+ * Adjust to top of lower right tile of the block.
+ */
+ src = src + ((h - 4) * 1024) + (w - 4);
+ dest= dest + ((h - 4) * 1024) + (w - 4);
+ }
+ FBBASE[dest] = FBBASE[src];
+}
+#endif
diff --git a/sys/arch/hp300/stand/ite_hy.c b/sys/arch/hp300/stand/ite_hy.c
new file mode 100644
index 00000000000..5823df0296b
--- /dev/null
+++ b/sys/arch/hp300/stand/ite_hy.c
@@ -0,0 +1,368 @@
+/* $NetBSD: ite_hy.c,v 1.2 1994/10/26 07:27:34 cgd Exp $ */
+
+/*
+ * Copyright (c) 1988 University of Utah.
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department and Mark Davies of the Department of Computer
+ * Science, Victoria University of Wellington, New Zealand.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * from: Utah $Hdr: ite_hy.c 1.1 92/01/22$
+ *
+ * @(#)ite_hy.c 8.1 (Berkeley) 6/10/93
+ */
+
+#include <hp300/stand/samachdep.h>
+
+#ifdef ITECONSOLE
+#include <sys/param.h>
+
+#include <hp300/dev/itevar.h>
+#include <hp300/dev/itereg.h>
+#include <hp300/dev/grf_hyreg.h>
+
+#define REGBASE ((struct hyboxfb *)(ip->regbase))
+#define WINDOWMOVER hyper_windowmove
+
+#undef charX
+#define charX(ip,c) \
+ (((c) % (ip)->cpl) * ((((ip)->ftwidth + 7) / 8) * 8) + (ip)->fontx)
+
+hyper_init(ip)
+ register struct ite_softc *ip;
+{
+ int width;
+
+ ite_fontinfo(ip);
+ width = ((ip->ftwidth + 7) / 8) * 8;
+ ip->cpl = (ip->fbwidth - ip->dwidth) / width;
+ ip->cblanky = ip->fonty + ((128 / ip->cpl) +1) * ip->ftheight;
+
+ REGBASE->nblank = 0x05;
+
+ /*
+ * Clear the framebuffer on all planes.
+ */
+ hyper_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR);
+
+ hyper_ite_fontinit(ip);
+
+ /*
+ * Stash the inverted cursor.
+ */
+ hyper_windowmove(ip, charY(ip, ' '), charX(ip, ' '),
+ ip->cblanky, ip->cblankx, ip->ftheight,
+ ip->ftwidth, RR_COPYINVERTED);
+}
+
+hyper_ite_fontinit(ip)
+ register struct ite_softc *ip;
+{
+ register u_char *fbmem, *dp;
+ int c, l, b;
+ int stride, width;
+
+ dp = (u_char *)(getword(ip, getword(ip, FONTROM) + FONTADDR) +
+ ip->regbase) + FONTDATA;
+ stride = ip->fbwidth >> 3;
+ width = (ip->ftwidth + 7) / 8;
+
+ for (c = 0; c < 128; c++) {
+ fbmem = (u_char *) FBBASE +
+ (ip->fonty + (c / ip->cpl) * ip->ftheight) *
+ stride;
+ fbmem += (ip->fontx >> 3) + (c % ip->cpl) * width;
+ for (l = 0; l < ip->ftheight; l++) {
+ for (b = 0; b < width; b++) {
+ *fbmem++ = *dp;
+ dp += 2;
+ }
+ fbmem -= width;
+ fbmem += stride;
+ }
+ }
+}
+
+hyper_putc(ip, c, dy, dx, mode)
+ register struct ite_softc *ip;
+ register int dy, dx;
+ int c, mode;
+{
+ hyper_windowmove(ip, charY(ip, c), charX(ip, c),
+ dy * ip->ftheight, dx * ip->ftwidth,
+ ip->ftheight, ip->ftwidth, RR_COPY);
+}
+
+hyper_cursor(ip, flag)
+ register struct ite_softc *ip;
+ int flag;
+{
+ switch (flag) {
+ case MOVE_CURSOR:
+ erase_cursor(ip);
+ /* fall through ... */
+ case DRAW_CURSOR:
+ draw_cursor(ip);
+ break;
+ default:
+ erase_cursor(ip);
+ break;
+ }
+}
+
+hyper_clear(ip, sy, sx, h, w)
+ struct ite_softc *ip;
+ register int sy, sx, h, w;
+{
+ hyper_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
+ sy * ip->ftheight, sx * ip->ftwidth,
+ h * ip->ftheight, w * ip->ftwidth,
+ RR_CLEAR);
+}
+
+hyper_scroll(ip, sy, sx, count, dir)
+ register struct ite_softc *ip;
+ register int sy, count;
+ int dir, sx;
+{
+ register int dy = sy - count;
+ register int height = ip->rows - sy;
+
+ hyper_cursor(ip, ERASE_CURSOR);
+
+ hyper_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
+ dy * ip->ftheight, sx * ip->ftwidth,
+ height * ip->ftheight,
+ ip->cols * ip->ftwidth, RR_COPY);
+}
+
+#include <hp300/dev/maskbits.h>
+
+/* NOTE:
+ * the first element in starttab could be 0xffffffff. making it 0
+ * lets us deal with a full first word in the middle loop, rather
+ * than having to do the multiple reads and masks that we'd
+ * have to do if we thought it was partial.
+ */
+int starttab[32] =
+ {
+ 0x00000000,
+ 0x7FFFFFFF,
+ 0x3FFFFFFF,
+ 0x1FFFFFFF,
+ 0x0FFFFFFF,
+ 0x07FFFFFF,
+ 0x03FFFFFF,
+ 0x01FFFFFF,
+ 0x00FFFFFF,
+ 0x007FFFFF,
+ 0x003FFFFF,
+ 0x001FFFFF,
+ 0x000FFFFF,
+ 0x0007FFFF,
+ 0x0003FFFF,
+ 0x0001FFFF,
+ 0x0000FFFF,
+ 0x00007FFF,
+ 0x00003FFF,
+ 0x00001FFF,
+ 0x00000FFF,
+ 0x000007FF,
+ 0x000003FF,
+ 0x000001FF,
+ 0x000000FF,
+ 0x0000007F,
+ 0x0000003F,
+ 0x0000001F,
+ 0x0000000F,
+ 0x00000007,
+ 0x00000003,
+ 0x00000001
+ };
+
+int endtab[32] =
+ {
+ 0x00000000,
+ 0x80000000,
+ 0xC0000000,
+ 0xE0000000,
+ 0xF0000000,
+ 0xF8000000,
+ 0xFC000000,
+ 0xFE000000,
+ 0xFF000000,
+ 0xFF800000,
+ 0xFFC00000,
+ 0xFFE00000,
+ 0xFFF00000,
+ 0xFFF80000,
+ 0xFFFC0000,
+ 0xFFFE0000,
+ 0xFFFF0000,
+ 0xFFFF8000,
+ 0xFFFFC000,
+ 0xFFFFE000,
+ 0xFFFFF000,
+ 0xFFFFF800,
+ 0xFFFFFC00,
+ 0xFFFFFE00,
+ 0xFFFFFF00,
+ 0xFFFFFF80,
+ 0xFFFFFFC0,
+ 0xFFFFFFE0,
+ 0xFFFFFFF0,
+ 0xFFFFFFF8,
+ 0xFFFFFFFC,
+ 0xFFFFFFFE
+ };
+
+hyper_windowmove(ip, sy, sx, dy, dx, h, w, func)
+ struct ite_softc *ip;
+ int sy, sx, dy, dx, h, w, func;
+{
+ unsigned int *psrcBase, *pdstBase;
+ /* start of src and dst bitmaps */
+ int width; /* add to get to same position in next line */
+
+ unsigned int *psrcLine, *pdstLine;
+ /* pointers to line with current src and dst */
+ register unsigned int *psrc; /* pointer to current src longword */
+ register unsigned int *pdst; /* pointer to current dst longword */
+
+ /* following used for looping through a line */
+ unsigned int startmask, endmask; /* masks for writing ends of dst */
+ int nlMiddle; /* whole longwords in dst */
+ register int nl; /* temp copy of nlMiddle */
+ register unsigned int tmpSrc;
+ /* place to store full source word */
+ register int xoffSrc; /* offset (>= 0, < 32) from which to
+ fetch whole longwords fetched
+ in src */
+ int nstart; /* number of ragged bits at start of dst */
+ int nend; /* number of ragged bits at end of dst */
+ int srcStartOver; /* pulling nstart bits from src
+ overflows into the next word? */
+
+ if (h == 0 || w == 0)
+ return;
+
+ width = ip->fbwidth >> 5;
+ psrcLine = ((unsigned int *) ip->fbbase) + (sy * width);
+ pdstLine = ((unsigned int *) ip->fbbase) + (dy * width);
+
+ /* x direction doesn't matter for < 1 longword */
+ if (w <= 32)
+ {
+ int srcBit, dstBit; /* bit offset of src and dst */
+
+ pdstLine += (dx >> 5);
+ psrcLine += (sx >> 5);
+ psrc = psrcLine;
+ pdst = pdstLine;
+
+ srcBit = sx & 0x1f;
+ dstBit = dx & 0x1f;
+
+ while(h--)
+ {
+ getandputrop(psrc, srcBit, dstBit, w, pdst, func)
+ pdst += width;
+ psrc += width;
+ }
+ }
+ else
+ {
+ maskbits(dx, w, startmask, endmask, nlMiddle)
+ if (startmask)
+ nstart = 32 - (dx & 0x1f);
+ else
+ nstart = 0;
+ if (endmask)
+ nend = (dx + w) & 0x1f;
+ else
+ nend = 0;
+
+ xoffSrc = ((sx & 0x1f) + nstart) & 0x1f;
+ srcStartOver = ((sx & 0x1f) + nstart) > 31;
+
+ pdstLine += (dx >> 5);
+ psrcLine += (sx >> 5);
+
+ while (h--)
+ {
+ psrc = psrcLine;
+ pdst = pdstLine;
+
+ if (startmask)
+ {
+ getandputrop(psrc, (sx & 0x1f),
+ (dx & 0x1f), nstart, pdst, func)
+ pdst++;
+ if (srcStartOver)
+ psrc++;
+ }
+
+ /* special case for aligned operations */
+ if (xoffSrc == 0)
+ {
+ nl = nlMiddle;
+ while (nl--)
+ {
+ DoRop (*pdst, func, *psrc++, *pdst);
+ pdst++;
+ }
+ }
+ else
+ {
+ nl = nlMiddle + 1;
+ while (--nl)
+ {
+ getunalignedword (psrc, xoffSrc, tmpSrc)
+ DoRop (*pdst, func, tmpSrc, *pdst);
+ pdst++;
+ psrc++;
+ }
+ }
+
+ if (endmask)
+ {
+ getandputrop0(psrc, xoffSrc, nend, pdst, func);
+ }
+
+ pdstLine += width;
+ psrcLine += width;
+ }
+ }
+}
+#endif
diff --git a/sys/arch/hp300/stand/ite_rb.c b/sys/arch/hp300/stand/ite_rb.c
new file mode 100644
index 00000000000..a2390cc54a0
--- /dev/null
+++ b/sys/arch/hp300/stand/ite_rb.c
@@ -0,0 +1,196 @@
+/* $NetBSD: ite_rb.c,v 1.7 1994/10/26 07:27:37 cgd Exp $ */
+
+/*
+ * Copyright (c) 1988 University of Utah.
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * from: Utah $Hdr: ite_rb.c 1.6 92/01/20$
+ *
+ * @(#)ite_rb.c 8.1 (Berkeley) 6/10/93
+ */
+
+#include <hp300/stand/samachdep.h>
+
+#ifdef ITECONSOLE
+
+#include <sys/param.h>
+#include <hp300/dev/itevar.h>
+#include <hp300/dev/itereg.h>
+
+#include <hp300/dev/grf_rbreg.h>
+
+#define REGBASE ((struct rboxfb *)(ip->regbase))
+#define WINDOWMOVER rbox_windowmove
+
+rbox_init(ip)
+ struct ite_softc *ip;
+{
+ int i;
+
+ rb_waitbusy(ip->regbase);
+ DELAY(3000);
+
+ REGBASE->interrupt = 0x04;
+ REGBASE->display_enable = 0x01;
+ REGBASE->video_enable = 0x01;
+ REGBASE->drive = 0x01;
+ REGBASE->vdrive = 0x0;
+
+ ite_fontinfo(ip);
+
+ REGBASE->opwen = 0xFF;
+
+ /*
+ * Clear the framebuffer.
+ */
+ rbox_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR);
+ rb_waitbusy(ip->regbase);
+
+ for(i = 0; i < 16; i++) {
+ *(ip->regbase + 0x63c3 + i*4) = 0x0;
+ *(ip->regbase + 0x6403 + i*4) = 0x0;
+ *(ip->regbase + 0x6803 + i*4) = 0x0;
+ *(ip->regbase + 0x6c03 + i*4) = 0x0;
+ *(ip->regbase + 0x73c3 + i*4) = 0x0;
+ *(ip->regbase + 0x7403 + i*4) = 0x0;
+ *(ip->regbase + 0x7803 + i*4) = 0x0;
+ *(ip->regbase + 0x7c03 + i*4) = 0x0;
+ }
+
+ REGBASE->rep_rule = 0x33;
+
+ /*
+ * I cannot figure out how to make the blink planes stop. So, we
+ * must set both colormaps so that when the planes blink, and
+ * the secondary colormap is active, we still get text.
+ */
+ CM1RED[0x00].value = 0x00;
+ CM1GRN[0x00].value = 0x00;
+ CM1BLU[0x00].value = 0x00;
+ CM1RED[0x01].value = 0xFF;
+ CM1GRN[0x01].value = 0xFF;
+ CM1BLU[0x01].value = 0xFF;
+
+ CM2RED[0x00].value = 0x00;
+ CM2GRN[0x00].value = 0x00;
+ CM2BLU[0x00].value = 0x00;
+ CM2RED[0x01].value = 0xFF;
+ CM2GRN[0x01].value = 0xFF;
+ CM2BLU[0x01].value = 0xFF;
+
+ REGBASE->blink = 0x00;
+ REGBASE->write_enable = 0x01;
+ REGBASE->opwen = 0x00;
+
+ ite_fontinit(ip);
+
+ /*
+ * Stash the inverted cursor.
+ */
+ rbox_windowmove(ip, charY(ip, ' '), charX(ip, ' '),
+ ip->cblanky, ip->cblankx, ip->ftheight,
+ ip->ftwidth, RR_COPYINVERTED);
+}
+
+rbox_putc(ip, c, dy, dx, mode)
+ register struct ite_softc *ip;
+ register int dy, dx;
+ int c, mode;
+{
+ rbox_windowmove(ip, charY(ip, c), charX(ip, c),
+ dy * ip->ftheight, dx * ip->ftwidth,
+ ip->ftheight, ip->ftwidth, RR_COPY);
+}
+
+rbox_cursor(ip, flag)
+ register struct ite_softc *ip;
+ register int flag;
+{
+ if (flag == DRAW_CURSOR)
+ draw_cursor(ip)
+ else if (flag == MOVE_CURSOR) {
+ erase_cursor(ip)
+ draw_cursor(ip)
+ }
+ else
+ erase_cursor(ip)
+}
+
+rbox_clear(ip, sy, sx, h, w)
+ struct ite_softc *ip;
+ register int sy, sx, h, w;
+{
+ rbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
+ sy * ip->ftheight, sx * ip->ftwidth,
+ h * ip->ftheight, w * ip->ftwidth,
+ RR_CLEAR);
+}
+
+rbox_scroll(ip, sy, sx, count, dir)
+ register struct ite_softc *ip;
+ register int sy, count;
+ int dir, sx;
+{
+ register int dy = sy - count;
+ register int height = ip->rows - sy;
+
+ rbox_cursor(ip, ERASE_CURSOR);
+
+ rbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
+ dy * ip->ftheight, sx * ip->ftwidth,
+ height * ip->ftheight,
+ ip->cols * ip->ftwidth, RR_COPY);
+}
+
+rbox_windowmove(ip, sy, sx, dy, dx, h, w, func)
+ struct ite_softc *ip;
+ int sy, sx, dy, dx, h, w, func;
+{
+ register struct rboxfb *rp = REGBASE;
+ if (h == 0 || w == 0)
+ return;
+
+ rb_waitbusy(ip->regbase);
+ rp->rep_rule = func << 4 | func;
+ rp->source_y = sy;
+ rp->source_x = sx;
+ rp->dest_y = dy;
+ rp->dest_x = dx;
+ rp->wheight = h;
+ rp->wwidth = w;
+ rp->wmove = 1;
+}
+#endif
diff --git a/sys/arch/hp300/stand/ite_subr.c b/sys/arch/hp300/stand/ite_subr.c
new file mode 100644
index 00000000000..4a7ceca585e
--- /dev/null
+++ b/sys/arch/hp300/stand/ite_subr.c
@@ -0,0 +1,145 @@
+/* $NetBSD: ite_subr.c,v 1.7 1994/10/26 07:27:39 cgd Exp $ */
+
+/*
+ * Copyright (c) 1988 University of Utah.
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * from: Utah $Hdr: ite_subr.c 1.2 92/01/20$
+ *
+ * @(#)ite_subr.c 8.1 (Berkeley) 6/10/93
+ */
+
+#include <hp300/stand/samachdep.h>
+
+#ifdef ITECONSOLE
+
+#include <sys/param.h>
+#include <hp300/dev/itevar.h>
+#include <hp300/dev/itereg.h>
+
+ite_fontinfo(ip)
+ struct ite_softc *ip;
+{
+ u_long fontaddr = getword(ip, getword(ip, FONTROM) + FONTADDR);
+
+ ip->ftheight = getbyte(ip, fontaddr + FONTHEIGHT);
+ ip->ftwidth = getbyte(ip, fontaddr + FONTWIDTH);
+ ip->rows = ip->dheight / ip->ftheight;
+ ip->cols = ip->dwidth / ip->ftwidth;
+
+ if (ip->fbwidth > ip->dwidth) {
+ /*
+ * Stuff goes to right of display.
+ */
+ ip->fontx = ip->dwidth;
+ ip->fonty = 0;
+ ip->cpl = (ip->fbwidth - ip->dwidth) / ip->ftwidth;
+ ip->cblankx = ip->dwidth;
+ ip->cblanky = ip->fonty + ((128 / ip->cpl) +1) * ip->ftheight;
+ }
+ else {
+ /*
+ * Stuff goes below the display.
+ */
+ ip->fontx = 0;
+ ip->fonty = ip->dheight;
+ ip->cpl = ip->fbwidth / ip->ftwidth;
+ ip->cblankx = 0;
+ ip->cblanky = ip->fonty + ((128 / ip->cpl) + 1) * ip->ftheight;
+ }
+}
+
+ite_fontinit(ip)
+ register struct ite_softc *ip;
+{
+ int bytewidth = (((ip->ftwidth - 1) / 8) + 1);
+ int glyphsize = bytewidth * ip->ftheight;
+ u_char fontbuf[500];
+ u_char *dp, *fbmem;
+ int c, i, romp;
+
+ romp = getword(ip, getword(ip, FONTROM) + FONTADDR) + FONTDATA;
+ for (c = 0; c < 128; c++) {
+ fbmem = (u_char *)
+ (FBBASE +
+ (ip->fonty + (c / ip->cpl) * ip->ftheight) * ip->fbwidth +
+ (ip->fontx + (c % ip->cpl) * ip->ftwidth));
+ dp = fontbuf;
+ for (i = 0; i < glyphsize; i++) {
+ *dp++ = getbyte(ip, romp);
+ romp += 2;
+ }
+ writeglyph(ip, fbmem, fontbuf);
+ }
+}
+
+/*
+ * Display independent versions of the readbyte and writeglyph routines.
+ */
+u_char
+ite_readbyte(ip, disp)
+ struct ite_softc *ip;
+ int disp;
+{
+ return((u_char) *(((u_char *)ip->regbase) + disp));
+}
+
+ite_writeglyph(ip, fbmem, glyphp)
+ register struct ite_softc *ip;
+ register u_char *fbmem, *glyphp;
+{
+ register int bn;
+ int c, l, b;
+
+ for (l = 0; l < ip->ftheight; l++) {
+ bn = 7;
+ for (b = 0; b < ip->ftwidth; b++) {
+ if ((1 << bn) & *glyphp)
+ *fbmem++ = 1;
+ else
+ *fbmem++ = 0;
+ if (--bn < 0) {
+ bn = 7;
+ glyphp++;
+ }
+ }
+ if (bn < 7)
+ glyphp++;
+ fbmem -= ip->ftwidth;
+ fbmem += ip->fbwidth;
+ }
+}
+#endif
diff --git a/sys/arch/hp300/stand/ite_tc.c b/sys/arch/hp300/stand/ite_tc.c
new file mode 100644
index 00000000000..cf0ea58df44
--- /dev/null
+++ b/sys/arch/hp300/stand/ite_tc.c
@@ -0,0 +1,181 @@
+/* $NetBSD: ite_tc.c,v 1.7 1994/10/26 07:27:41 cgd Exp $ */
+
+/*
+ * Copyright (c) 1988 University of Utah.
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * from: Utah $Hdr: ite_tc.c 1.11 92/01/20$
+ *
+ * @(#)ite_tc.c 8.1 (Berkeley) 6/10/93
+ */
+
+#include <hp300/stand/samachdep.h>
+
+#ifdef ITECONSOLE
+
+#include <sys/param.h>
+#include <hp300/dev/itevar.h>
+#include <hp300/dev/itereg.h>
+#include <hp300/dev/grfreg.h>
+#include <hp300/dev/grf_tcreg.h>
+
+#define REGBASE ((struct tcboxfb *)(ip->regbase))
+#define WINDOWMOVER topcat_windowmove
+
+topcat_init(ip)
+ register struct ite_softc *ip;
+{
+
+ /*
+ * Catseye looks a lot like a topcat, but not completely.
+ * So, we set some bits to make it work.
+ */
+ if (REGBASE->fbid != GID_TOPCAT) {
+ while ((REGBASE->catseye_status & 1))
+ ;
+ REGBASE->catseye_status = 0x0;
+ REGBASE->vb_select = 0x0;
+ REGBASE->tcntrl = 0x0;
+ REGBASE->acntrl = 0x0;
+ REGBASE->pncntrl = 0x0;
+ REGBASE->rug_cmdstat = 0x90;
+ }
+
+ /*
+ * Determine the number of planes by writing to the first frame
+ * buffer display location, then reading it back.
+ */
+ REGBASE->wen = ~0;
+ REGBASE->fben = ~0;
+ REGBASE->prr = RR_COPY;
+ *FBBASE = 0xFF;
+ ip->planemask = *FBBASE;
+
+ /*
+ * Enable reading/writing of all the planes.
+ */
+ REGBASE->fben = ip->planemask;
+ REGBASE->wen = ip->planemask;
+ REGBASE->ren = ip->planemask;
+ REGBASE->prr = RR_COPY;
+
+ ite_fontinfo(ip);
+
+ /*
+ * Clear the framebuffer on all planes.
+ */
+ topcat_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR);
+ tc_waitbusy(ip->regbase, ip->planemask);
+
+ ite_fontinit(ip);
+
+ /*
+ * Stash the inverted cursor.
+ */
+ topcat_windowmove(ip, charY(ip, ' '), charX(ip, ' '),
+ ip->cblanky, ip->cblankx, ip->ftheight,
+ ip->ftwidth, RR_COPYINVERTED);
+}
+
+topcat_putc(ip, c, dy, dx, mode)
+ register struct ite_softc *ip;
+ register int dy, dx;
+ int c, mode;
+{
+ topcat_windowmove(ip, charY(ip, c), charX(ip, c),
+ dy * ip->ftheight, dx * ip->ftwidth,
+ ip->ftheight, ip->ftwidth, RR_COPY);
+}
+
+topcat_cursor(ip, flag)
+ register struct ite_softc *ip;
+ register int flag;
+{
+ if (flag == DRAW_CURSOR)
+ draw_cursor(ip)
+ else if (flag == MOVE_CURSOR) {
+ erase_cursor(ip)
+ draw_cursor(ip)
+ }
+ else
+ erase_cursor(ip)
+}
+
+topcat_clear(ip, sy, sx, h, w)
+ struct ite_softc *ip;
+ register int sy, sx, h, w;
+{
+ topcat_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
+ sy * ip->ftheight, sx * ip->ftwidth,
+ h * ip->ftheight, w * ip->ftwidth,
+ RR_CLEAR);
+}
+
+topcat_scroll(ip, sy, sx, count, dir)
+ register struct ite_softc *ip;
+ register int sy, count;
+ int dir, sx;
+{
+ register int dy = sy - count;
+ register int height = ip->rows - sy;
+
+ topcat_cursor(ip, ERASE_CURSOR);
+
+ topcat_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth,
+ dy * ip->ftheight, sx * ip->ftwidth,
+ height * ip->ftheight,
+ ip->cols * ip->ftwidth, RR_COPY);
+}
+
+topcat_windowmove(ip, sy, sx, dy, dx, h, w, func)
+ struct ite_softc *ip;
+ int sy, sx, dy, dx, h, w, func;
+{
+ register struct tcboxfb *rp = REGBASE;
+
+ if (h == 0 || w == 0)
+ return;
+ tc_waitbusy(ip->regbase, ip->planemask);
+ rp->wmrr = func;
+ rp->source_y = sy;
+ rp->source_x = sx;
+ rp->dest_y = dy;
+ rp->dest_x = dx;
+ rp->wheight = h;
+ rp->wwidth = w;
+ rp->wmove = ip->planemask;
+}
+#endif
diff --git a/sys/arch/hp300/stand/libsa/Makefile b/sys/arch/hp300/stand/libsa/Makefile
new file mode 100644
index 00000000000..749a869c1ff
--- /dev/null
+++ b/sys/arch/hp300/stand/libsa/Makefile
@@ -0,0 +1,36 @@
+# $NetBSD: Makefile,v 1.2 1995/09/02 05:04:25 thorpej Exp $
+
+LIB= sa
+
+.PATH: ${.CURDIR}/../../../../lib/libsa
+
+# Don't need these now...
+# DEBUGFLAGS=-DNETIF_DEBUG -DRPC_DEBUG -DNFS_DEBUG -DRARP_DEBUG -DNET_DEBUG
+
+CFLAGS+=-DSTANDALONE -DCOMPAT_UFS ${DEBUGFLAGS}
+CFLAGS+=-I${.CURDIR}/../../../.. -I${.CURDIR}/../../../../lib/libsa
+
+# stand routines
+SRCS= alloc.c bcopy.c exit.c exec.c getfile.c gets.c globals.c \
+ printf.c strerror.c
+
+# io routines
+SRCS+= close.c dev.c disklabel.c ioctl.c lseek.c open.c read.c \
+ stat.c write.c
+
+# network routines
+SRCS+= arp.c ether.c in_cksum.c net.c netif.c rpc.c
+
+# network info services
+SRCS+= bootp.c bootparam.c rarp.c
+
+# boot filesystems
+SRCS+= ufs.c nfs.c
+
+NOPROFILE=
+NOPIC=
+OBJMACHINE=
+
+install:
+
+.include <bsd.lib.mk>
diff --git a/sys/arch/hp300/stand/libsa/Makefile.inc b/sys/arch/hp300/stand/libsa/Makefile.inc
new file mode 100644
index 00000000000..868438109ff
--- /dev/null
+++ b/sys/arch/hp300/stand/libsa/Makefile.inc
@@ -0,0 +1,23 @@
+# $NetBSD: Makefile.inc,v 1.1 1995/08/04 07:55:50 thorpej Exp $
+
+# NOTE: $S must correspond to the top of the 'sys' tree
+
+SA_DIR= $S/arch/hp300/stand/libsa
+
+.if exists($(SA_DIR)/obj.${MACHINE})
+SA_LIBDIR= $(SA_DIR)/obj.${MACHINE}
+.else
+SA_LIBDIR= $(SA_DIR)
+.endif
+
+SA_LIB= $(SA_LIBDIR)/libsa.a
+
+$(SA_LIB): .NOTMAIN __always_make_sa_lib
+ @echo making sure the stand-alone library is up to date...
+ @(cd $(SA_DIR) ; make)
+
+clean:: .NOTMAIN __always_make_sa_lib
+ @echo cleaning the stand-alone library objects
+ @(cd $(SA_DIR) ; make clean)
+
+__always_make_sa_lib: .NOTMAIN
diff --git a/sys/arch/hp300/stand/machdep.c b/sys/arch/hp300/stand/machdep.c
new file mode 100644
index 00000000000..b7b7efbe921
--- /dev/null
+++ b/sys/arch/hp300/stand/machdep.c
@@ -0,0 +1,157 @@
+/* $NetBSD: machdep.c,v 1.5 1994/10/26 07:27:43 cgd Exp $ */
+
+/*
+ * Copyright (c) 1988 University of Utah.
+ * Copyright (c) 1982, 1986, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * from: Utah $Hdr: machdep.c 1.10 92/06/18
+ *
+ * @(#)machdep.c 8.1 (Berkeley) 6/10/93
+ */
+
+#include <sys/param.h>
+#include "samachdep.h"
+
+char *
+getmachineid()
+{
+ extern int machineid;
+ char *cp;
+
+ switch (machineid) {
+ case HP_320:
+ cp = "320"; break;
+ case HP_330:
+ cp = "318/319/330"; break;
+ case HP_340:
+ cp = "340"; break;
+ case HP_350:
+ cp = "350"; break;
+ case HP_360:
+ cp = "360"; break;
+ case HP_370:
+ cp = "370"; break;
+ case HP_375:
+ cp = "345/375/400"; break;
+ case HP_380:
+ cp = "380/425"; break;
+ case HP_433:
+ cp = "433"; break;
+ default:
+ cp = "???"; break;
+ }
+ return(cp);
+}
+
+#ifdef ROMPRF
+int userom;
+#endif
+
+struct trapframe {
+ int dregs[8];
+ int aregs[8];
+ int whoknows;
+ short sr;
+ int pc;
+ short frame;
+};
+
+trap(fp)
+ struct trapframe *fp;
+{
+ static int intrap = 0;
+
+ if (intrap)
+ return(0);
+ intrap = 1;
+#ifdef ROMPRF
+ userom = 1;
+#endif
+ printf("Got unexpected trap: format=%x vector=%x ps=%x pc=%x\n",
+ (fp->frame>>12)&0xF, fp->frame&0xFFF, fp->sr, fp->pc);
+ printf("dregs: %x %x %x %x %x %x %x %x\n",
+ fp->dregs[0], fp->dregs[1], fp->dregs[2], fp->dregs[3],
+ fp->dregs[4], fp->dregs[5], fp->dregs[6], fp->dregs[7]);
+ printf("aregs: %x %x %x %x %x %x %x %x\n",
+ fp->aregs[0], fp->aregs[1], fp->aregs[2], fp->aregs[3],
+ fp->aregs[4], fp->aregs[5], fp->aregs[6], fp->aregs[7]);
+#ifdef ROMPRF
+ userom = 0;
+#endif
+ intrap = 0;
+ return(0);
+}
+
+#ifdef ROMPRF
+#define ROWS 46
+#define COLS 128
+
+romputchar(c)
+ register int c;
+{
+ static char buf[COLS];
+ static int col = 0, row = 0;
+ register int i;
+
+ switch (c) {
+ case '\0':
+ break;
+ case '\r':
+ break; /* ignore */
+ case '\n':
+ for (i = col; i < COLS-1; i++)
+ buf[i] = ' ';
+ buf[i] = '\0';
+ romout(row, buf);
+ col = 0;
+ if (++row == ROWS)
+ row = 0;
+ break;
+
+ case '\t':
+ do {
+ romputchar(' ');
+ } while (col & 7);
+ break;
+
+ default:
+ buf[col] = c;
+ if (++col == COLS-1)
+ romputchar('\n');
+ break;
+ }
+}
+#endif
diff --git a/sys/arch/hp300/stand/mkboot.c b/sys/arch/hp300/stand/mkboot.c
new file mode 100644
index 00000000000..e1258dd1e05
--- /dev/null
+++ b/sys/arch/hp300/stand/mkboot.c
@@ -0,0 +1,334 @@
+/*
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * @(#)mkboot.c 8.1 (Berkeley) 7/15/93
+ */
+
+#ifndef lint
+static char copyright[] =
+"@(#) Copyright (c) 1990, 1993\n\
+ The Regents of the University of California. All rights reserved.\n";
+#endif /* not lint */
+
+#ifndef lint
+#ifdef notdef
+static char sccsid[] = "@(#)mkboot.c 7.2 (Berkeley) 12/16/90";
+#endif
+static char rcsid[] = "$NetBSD: mkboot.c,v 1.5 1994/10/26 07:27:45 cgd Exp $";
+#endif /* not lint */
+
+#include <sys/param.h>
+#include <sys/file.h>
+#include <a.out.h>
+
+#include "volhdr.h"
+
+#include <stdio.h>
+#include <ctype.h>
+
+#define LIF_NUMDIR 8
+
+#define LIF_VOLSTART 0
+#define LIF_VOLSIZE sizeof(struct lifvol)
+#define LIF_DIRSTART 512
+#define LIF_DIRSIZE (LIF_NUMDIR * sizeof(struct lifdir))
+#define LIF_FILESTART 8192
+
+#define btolifs(b) (((b) + (SECTSIZE - 1)) / SECTSIZE)
+#define lifstob(s) ((s) * SECTSIZE)
+
+int lpflag;
+int loadpoint;
+struct load ld;
+struct lifvol lifv;
+struct lifdir lifd[LIF_NUMDIR];
+struct exec ex;
+char buf[10240];
+
+/*
+ * Old Format:
+ * sector 0: LIF volume header (40 bytes)
+ * sector 1: <unused>
+ * sector 2: LIF directory (8 x 32 == 256 bytes)
+ * sector 3-: LIF file 0, LIF file 1, etc.
+ * where sectors are 256 bytes.
+ *
+ * New Format:
+ * sector 0: LIF volume header (40 bytes)
+ * sector 1: <unused>
+ * sector 2: LIF directory (8 x 32 == 256 bytes)
+ * sector 3: <unused>
+ * sector 4-31: disklabel (~300 bytes right now)
+ * sector 32-: LIF file 0, LIF file 1, etc.
+ */
+main(argc, argv)
+ char **argv;
+{
+ int ac;
+ char **av;
+ int from1, from2, from3, to;
+ register int n;
+ char *n1, *n2, *n3, *lifname();
+
+ ac = --argc;
+ av = ++argv;
+ if (ac == 0)
+ usage();
+ if (!strcmp(av[0], "-l")) {
+ av++;
+ ac--;
+ if (ac == 0)
+ usage();
+ sscanf(av[0], "0x%x", &loadpoint);
+ lpflag++;
+ av++;
+ ac--;
+ }
+ if (ac == 0)
+ usage();
+ from1 = open(av[0], O_RDONLY, 0);
+ if (from1 < 0) {
+ perror("open");
+ exit(1);
+ }
+ n1 = av[0];
+ av++;
+ ac--;
+ if (ac == 0)
+ usage();
+ if (ac > 1) {
+ from2 = open(av[0], O_RDONLY, 0);
+ if (from2 < 0) {
+ perror("open");
+ exit(1);
+ }
+ n2 = av[0];
+ av++;
+ ac--;
+ if (ac > 1) {
+ from3 = open(av[0], O_RDONLY, 0);
+ if (from3 < 0) {
+ perror("open");
+ exit(1);
+ }
+ n3 = av[0];
+ av++;
+ ac--;
+ } else
+ from3 = -1;
+ } else
+ from2 = from3 = -1;
+ to = open(av[0], O_WRONLY | O_TRUNC | O_CREAT, 0644);
+ if (to < 0) {
+ perror("open");
+ exit(1);
+ }
+ /* clear possibly unused directory entries */
+ strncpy(lifd[1].dir_name, " ", 10);
+ lifd[1].dir_type = -1;
+ lifd[1].dir_addr = 0;
+ lifd[1].dir_length = 0;
+ lifd[1].dir_flag = 0xFF;
+ lifd[1].dir_exec = 0;
+ lifd[7] = lifd[6] = lifd[5] = lifd[4] = lifd[3] = lifd[2] = lifd[1];
+ /* record volume info */
+ lifv.vol_id = VOL_ID;
+ strncpy(lifv.vol_label, "BOOT43", 6);
+ lifv.vol_addr = btolifs(LIF_DIRSTART);
+ lifv.vol_oct = VOL_OCT;
+ lifv.vol_dirsize = btolifs(LIF_DIRSIZE);
+ lifv.vol_version = 1;
+ /* output bootfile one */
+ lseek(to, LIF_FILESTART, 0);
+ putfile(from1, to);
+ n = btolifs(ld.count + sizeof(ld));
+ strcpy(lifd[0].dir_name, lifname(n1));
+ lifd[0].dir_type = DIR_TYPE;
+ lifd[0].dir_addr = btolifs(LIF_FILESTART);
+ lifd[0].dir_length = n;
+ bcddate(from1, lifd[0].dir_toc);
+ lifd[0].dir_flag = DIR_FLAG;
+ lifd[0].dir_exec = lpflag? loadpoint + ex.a_entry : ex.a_entry;
+ lifv.vol_length = lifd[0].dir_addr + lifd[0].dir_length;
+ /* if there is an optional second boot program, output it */
+ if (from2 >= 0) {
+ lseek(to, LIF_FILESTART+lifstob(n), 0);
+ putfile(from2, to);
+ n = btolifs(ld.count + sizeof(ld));
+ strcpy(lifd[1].dir_name, lifname(n2));
+ lifd[1].dir_type = DIR_TYPE;
+ lifd[1].dir_addr = lifv.vol_length;
+ lifd[1].dir_length = n;
+ bcddate(from2, lifd[1].dir_toc);
+ lifd[1].dir_flag = DIR_FLAG;
+ lifd[1].dir_exec = lpflag? loadpoint + ex.a_entry : ex.a_entry;
+ lifv.vol_length = lifd[1].dir_addr + lifd[1].dir_length;
+ }
+ /* ditto for three */
+ if (from3 >= 0) {
+ lseek(to, LIF_FILESTART+lifstob(lifd[0].dir_length+n), 0);
+ putfile(from3, to);
+ n = btolifs(ld.count + sizeof(ld));
+ strcpy(lifd[2].dir_name, lifname(n3));
+ lifd[2].dir_type = DIR_TYPE;
+ lifd[2].dir_addr = lifv.vol_length;
+ lifd[2].dir_length = n;
+ bcddate(from3, lifd[2].dir_toc);
+ lifd[2].dir_flag = DIR_FLAG;
+ lifd[2].dir_exec = lpflag? loadpoint + ex.a_entry : ex.a_entry;
+ lifv.vol_length = lifd[2].dir_addr + lifd[2].dir_length;
+ }
+ /* output volume/directory header info */
+ lseek(to, LIF_VOLSTART, 0);
+ write(to, &lifv, LIF_VOLSIZE);
+ lseek(to, LIF_DIRSTART, 0);
+ write(to, lifd, LIF_DIRSIZE);
+ exit(0);
+}
+
+putfile(from, to)
+{
+ register int n, tcnt, dcnt;
+
+ n = read(from, &ex, sizeof(ex));
+ if (n != sizeof(ex)) {
+ fprintf(stderr, "error reading file header\n");
+ exit(1);
+ }
+ if (N_GETMAGIC(ex) == OMAGIC) {
+ tcnt = ex.a_text;
+ dcnt = ex.a_data;
+ }
+ else if (N_GETMAGIC(ex) == NMAGIC) {
+ tcnt = (ex.a_text + PGOFSET) & ~PGOFSET;
+ dcnt = ex.a_data;
+ }
+ else {
+ fprintf(stderr, "bad magic number\n");
+ exit(1);
+ }
+ ld.address = lpflag ? loadpoint : ex.a_entry;
+ ld.count = tcnt + dcnt;
+ write(to, &ld, sizeof(ld));
+ while (tcnt) {
+ n = sizeof(buf);
+ if (n > tcnt)
+ n = tcnt;
+ n = read(from, buf, n);
+ if (n < 0) {
+ perror("read");
+ exit(1);
+ }
+ if (n == 0) {
+ fprintf(stderr, "short read\n");
+ exit(1);
+ }
+ if (write(to, buf, n) < 0) {
+ perror("write");
+ exit(1);
+ }
+ tcnt -= n;
+ }
+ while (dcnt) {
+ n = sizeof(buf);
+ if (n > dcnt)
+ n = dcnt;
+ n = read(from, buf, n);
+ if (n < 0) {
+ perror("read");
+ exit(1);
+ }
+ if (n == 0) {
+ fprintf(stderr, "short read\n");
+ exit(1);
+ }
+ if (write(to, buf, n) < 0) {
+ perror("write");
+ exit(1);
+ }
+ dcnt -= n;
+ }
+}
+
+usage()
+{
+ fprintf(stderr,
+ "usage: mkboot [-l loadpoint] prog1 [ prog2 ] outfile\n");
+ exit(1);
+}
+
+char *
+lifname(str)
+ char *str;
+{
+ static char lname[10] = "SYS_XXXXX";
+ register int i;
+
+ for (i = 4; i < 9; i++) {
+ if (islower(*str))
+ lname[i] = toupper(*str);
+ else if (isalnum(*str) || *str == '_')
+ lname[i] = *str;
+ else
+ break;
+ str++;
+ }
+ for ( ; i < 10; i++)
+ lname[i] = '\0';
+ return(lname);
+}
+
+#include <sys/stat.h>
+#include <time.h> /* XXX */
+
+bcddate(fd, toc)
+ int fd;
+ char *toc;
+{
+ struct stat statb;
+ struct tm *tm;
+
+ fstat(fd, &statb);
+ tm = localtime(&statb.st_ctime);
+ *toc = ((tm->tm_mon+1) / 10) << 4;
+ *toc++ |= (tm->tm_mon+1) % 10;
+ *toc = (tm->tm_mday / 10) << 4;
+ *toc++ |= tm->tm_mday % 10;
+ *toc = (tm->tm_year / 10) << 4;
+ *toc++ |= tm->tm_year % 10;
+ *toc = (tm->tm_hour / 10) << 4;
+ *toc++ |= tm->tm_hour % 10;
+ *toc = (tm->tm_min / 10) << 4;
+ *toc++ |= tm->tm_min % 10;
+ *toc = (tm->tm_sec / 10) << 4;
+ *toc |= tm->tm_sec % 10;
+}
diff --git a/sys/arch/hp300/stand/netboot.c b/sys/arch/hp300/stand/netboot.c
new file mode 100644
index 00000000000..34e9aee755b
--- /dev/null
+++ b/sys/arch/hp300/stand/netboot.c
@@ -0,0 +1,162 @@
+/* $NetBSD: netboot.c,v 1.10 1995/10/04 07:24:32 thorpej Exp $ */
+
+/*-
+ * Copyright (c) 1982, 1986, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * @(#)boot.c 8.1 (Berkeley) 6/10/93
+ */
+
+#include <sys/param.h>
+#include <sys/reboot.h>
+#include <a.out.h>
+#include "stand.h"
+#include "samachdep.h"
+
+/*
+ * Boot program... bits in `howto' determine whether boot stops to
+ * ask for system name. Boot device is derived from ROM provided
+ * information.
+ */
+
+char line[100];
+
+extern u_int opendev;
+extern char *lowram;
+extern int noconsole;
+extern int cons_scode;
+
+char *name;
+char *names[] = {
+ "netbsd", "onetbsd", "netbsd.old",
+};
+#define NUMNAMES (sizeof(names)/sizeof(char *))
+
+static int bdev, badapt, bctlr, bunit, bpart;
+
+main()
+{
+ int currname = 0;
+
+ /*
+ * XXX: different versions of the HP boot rom seem to report
+ * different things, so we have to compensate.
+ */
+ bootdev = MAKEBOOTDEV(0, 0, 0, 0, 0);
+
+ printf("\n>> NetBSD NETWORK BOOT HP9000/%s CPU\n",
+ getmachineid());
+ printf(">> $NetBSD: netboot.c,v 1.10 1995/10/04 07:24:32 thorpej Exp $\n");
+ printf(">> Enter \"reset\" to reset system.\n");
+
+ bdev = B_TYPE(bootdev);
+ badapt = B_ADAPTOR(bootdev);
+ bctlr = B_CONTROLLER(bootdev);
+ bunit = B_UNIT(bootdev);
+ bpart = B_PARTITION(bootdev);
+
+ for (;;) {
+ name = names[currname++];
+ if (currname == NUMNAMES)
+ currname = 0;
+
+ if (!noconsole) {
+ howto = 0;
+ getbootname(&howto);
+ } else
+ printf(": %s\n", name);
+
+ exec(name, lowram, howto);
+ printf("boot: %s\n", strerror(errno));
+ }
+}
+
+getbootname(howto)
+ int *howto;
+{
+ char c, *ptr = line;
+
+ printf("Boot: [%s][-s][-a][-d] :- ", name);
+
+ if (tgets(line)) {
+ if (strcmp(line, "reset") == 0) {
+ call_req_reboot(); /* reset machine */
+ printf("panic: can't reboot, halting\n");
+ asm("stop #0x2700");
+ }
+
+ while (c = *ptr) {
+ while (c == ' ')
+ c = *++ptr;
+ if (!c)
+ return;
+ if (c == '-')
+ while ((c = *++ptr) && c != ' ')
+ switch (c) {
+ case 'a':
+ *howto |= RB_ASKNAME;
+ continue;
+ case 's':
+ *howto |= RB_SINGLE;
+ continue;
+ case 'd':
+ *howto |= RB_KDB;
+ continue;
+ case 'b':
+ *howto |= RB_HALT;
+ continue;
+ }
+ else {
+ name = ptr;
+ while ((c = *++ptr) && c != ' ');
+ if (c)
+ *ptr++ = 0;
+ }
+ }
+ } else
+ printf("\n");
+}
+
+void
+machdep_start(entry, howto, loadaddr, ssym, esym)
+ char *entry;
+ int howto;
+ char *loadaddr;
+ char *ssym, *esym;
+{
+
+ asm("movl %0,d7" : : "m" (howto));
+ asm("movl #0,d6"); /* tell setroot we've netbooted */
+ asm("movl %0,d5" : : "m" (cons_scode));
+ asm("movl %0,a5" : : "a" (loadaddr));
+ asm("movl %0,a4" : : "a" (esym));
+ (*((int (*)())entry))();
+}
diff --git a/sys/arch/hp300/stand/netio.c b/sys/arch/hp300/stand/netio.c
new file mode 100644
index 00000000000..f655eeeb1b4
--- /dev/null
+++ b/sys/arch/hp300/stand/netio.c
@@ -0,0 +1,242 @@
+/* $NetBSD: netio.c,v 1.2 1995/09/23 17:31:10 thorpej Exp $ */
+
+/*
+ * Copyright (c) 1995 Jason R. Thorpe
+ * Copyright (c) 1995 Gordon W. Ross
+ * All rights reserved.
+ *
+ * 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. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ * 4. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Gordon W. Ross
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ */
+
+/*
+ * This module implements a "raw device" interface suitable for
+ * use by the stand-alone I/O library NFS code. This interface
+ * does not support any "block" access, and exists only for the
+ * purpose of initializing the network interface, getting boot
+ * parameters, and performing the NFS mount.
+ *
+ * At open time, this does:
+ *
+ * find interface - netif_open()
+ * RARP for IP address - rarp_getipaddress()
+ * RPC/bootparams - callrpc(d, RPC_BOOTPARAMS, ...)
+ * RPC/mountd - nfs_mount(sock, ip, path)
+ *
+ * the root file handle from mountd is saved in a global
+ * for use by the NFS open code (NFS/lookup).
+ */
+
+#include <sys/param.h>
+#include <sys/socket.h>
+#include <net/if.h>
+#include <netinet/in.h>
+#include <netinet/if_ether.h>
+#include <netinet/in_systm.h>
+
+#include "stand.h"
+#include "net.h"
+#include "netif.h"
+#include "bootparam.h"
+#include "nfs.h"
+
+extern int nfs_root_node[]; /* XXX - get from nfs_mount() */
+
+struct in_addr myip, rootip, gateip;
+n_long netmask;
+char rootpath[FNAME_SIZE];
+
+int netdev_sock = -1;
+static int open_count;
+
+#ifdef SYS_INST
+static char input_line[100];
+#endif
+
+/* Why be any different? */
+#define SUN_BOOTPARAMS
+
+/*
+ * Called by devopen after it sets f->f_dev to our devsw entry.
+ * This opens the low-level device and sets f->f_devdata.
+ */
+int
+netopen(f, devname)
+ struct open_file *f;
+ char *devname; /* Device part of file name (or NULL). */
+{
+ int error = 0;
+
+ /* On first open, do netif open, mount, etc. */
+ if (open_count == 0) {
+ /* Find network interface. */
+ if ((netdev_sock = netif_open(devname)) < 0)
+ return (error=ENXIO);
+ if ((error = netmountroot(f, devname)) != 0)
+ return (error);
+ }
+ open_count++;
+ f->f_devdata = nfs_root_node;
+ return (error);
+}
+
+int
+netclose(f)
+ struct open_file *f;
+{
+ /* On last close, do netif close, etc. */
+ if (open_count > 0)
+ if (--open_count == 0)
+ netif_close(netdev_sock);
+ f->f_devdata = NULL;
+}
+
+int
+netioctl()
+{
+ return EIO;
+}
+
+int
+netstrategy()
+{
+ return EIO;
+}
+
+int
+netmountroot(f, devname)
+ struct open_file *f;
+ char *devname; /* Device part of file name (or NULL). */
+{
+ int error;
+#ifdef SYS_INST
+ struct iodesc *d;
+#endif
+
+#ifdef DEBUG
+ printf("netmountroot: %s\n", devname);
+#endif
+
+#ifdef SYS_INST
+ get_my_ip:
+ printf("My IP address? ");
+ bzero(input_line, sizeof(input_line));
+ gets(input_line);
+ if ((myip.s_addr = inet_addr(input_line)) == htonl(INADDR_NONE)) {
+ printf("invalid IP address: %s\n", input_line);
+ goto get_my_ip;
+ }
+
+ get_my_netmask:
+ printf("My netmask? ");
+ bzero(input_line, sizeof(input_line));
+ gets(input_line);
+ if ((netmask = inet_addr(input_line)) == htonl(INADDR_NONE)) {
+ printf("invalid netmask: %s\n", input_line);
+ goto get_my_netmask;
+ }
+
+ get_my_gateway:
+ printf("My gateway? ");
+ bzero(input_line, sizeof(input_line));
+ gets(input_line);
+ if ((gateip.s_addr = inet_addr(input_line)) == htonl(INADDR_NONE)) {
+ printf("invalid IP address: %s\n", input_line);
+ goto get_my_gateway;
+ }
+
+ get_server_ip:
+ printf("Server IP address? ");
+ bzero(input_line, sizeof(input_line));
+ gets(input_line);
+ if ((rootip.s_addr = inet_addr(input_line)) == htonl(INADDR_NONE)) {
+ printf("invalid IP address: %s\n", input_line);
+ goto get_server_ip;
+ }
+
+ get_server_path:
+ printf("Server path? ");
+ bzero(rootpath, sizeof(rootpath));
+ gets(rootpath);
+ if (rootpath[0] == '\0' || rootpath[0] == '\n')
+ goto get_server_path;
+
+ if ((d = socktodesc(netdev_sock)) == NULL)
+ return (EMFILE);
+
+ d->myip = myip;
+
+#else /* SYS_INST */
+ /*
+ * Get info for NFS boot: our IP address, our hostname,
+ * server IP address, and our root path on the server.
+ * There are two ways to do this: The old, Sun way,
+ * and the more modern, BOOTP way. (RFC951, RFC1048)
+ */
+
+#ifdef SUN_BOOTPARAMS
+ /* Get boot info using RARP and Sun bootparams. */
+
+ /* Get our IP address. (rarp.c) */
+ if (rarp_getipaddress(netdev_sock) == -1)
+ return (errno);
+
+ printf("boot: client IP address: %s\n", inet_ntoa(myip));
+
+ /* Get our hostname, server IP address. */
+ if (bp_whoami(netdev_sock))
+ return (errno);
+
+ printf("boot: client name: %s\n", hostname);
+
+ /* Get the root pathname. */
+ if (bp_getfile(netdev_sock, "root", &rootip, rootpath))
+ return (errno);
+
+#else
+
+ /* Get boot info using BOOTP way. (RFC951, RFC1048) */
+ bootp(netdev_sock);
+
+ printf("Using IP address: %s\n", inet_ntoa(myip));
+
+ printf("myip: %s (%s)", hostname, inet_ntoa(myip));
+ if (gateip)
+ printf(", gateip: %s", inet_ntoa(gateip));
+ if (mask)
+ printf(", mask: %s", intoa(netmask));
+ printf("\n");
+
+#endif /* SUN_BOOTPARAMS */
+
+ printf("root addr=%s path=%s\n", inet_ntoa(rootip), rootpath);
+
+#endif /* SYS_INST */
+
+ /* Get the NFS file handle (mount). */
+ error = nfs_mount(netdev_sock, rootip, rootpath);
+
+ return (error);
+}
diff --git a/sys/arch/hp300/stand/nhpib.c b/sys/arch/hp300/stand/nhpib.c
new file mode 100644
index 00000000000..9b536bb3ce3
--- /dev/null
+++ b/sys/arch/hp300/stand/nhpib.c
@@ -0,0 +1,205 @@
+/* $NetBSD: nhpib.c,v 1.5 1995/08/05 16:47:46 thorpej Exp $ */
+
+/*
+ * Copyright (c) 1982, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * @(#)nhpib.c 8.1 (Berkeley) 6/10/93
+ */
+
+/*
+ * Internal/98624 HPIB driver
+ */
+
+#include <sys/param.h>
+#include <hp300/dev/nhpibreg.h>
+#include <hp300/stand/hpibvar.h>
+#include <hp300/stand/samachdep.h>
+
+nhpibinit(unit)
+{
+ register struct hpib_softc *hs = &hpib_softc[unit];
+ register struct nhpibdevice *hd = (struct nhpibdevice *)hs->sc_addr;
+ extern int internalhpib;
+
+ if ((int)hd == internalhpib) {
+ hs->sc_type = HPIBA;
+ hs->sc_ba = HPIBA_BA;
+ }
+ else if (hd->hpib_cid == HPIBB) {
+ hs->sc_type = HPIBB;
+ hs->sc_ba = hd->hpib_csa & CSA_BA;
+ }
+ else
+ return(0);
+ nhpibreset(unit);
+ return(1);
+}
+
+nhpibreset(unit)
+{
+ register struct hpib_softc *hs = &hpib_softc[unit];
+ register struct nhpibdevice *hd;
+
+ hd = (struct nhpibdevice *)hs->sc_addr;
+ hd->hpib_acr = AUX_SSWRST;
+ hd->hpib_ar = hs->sc_ba;
+ hd->hpib_lim = 0;
+ hd->hpib_mim = 0;
+ hd->hpib_acr = AUX_CDAI;
+ hd->hpib_acr = AUX_CSHDW;
+ hd->hpib_acr = AUX_SSTD1;
+ hd->hpib_acr = AUX_SVSTD1;
+ hd->hpib_acr = AUX_CPP;
+ hd->hpib_acr = AUX_CHDFA;
+ hd->hpib_acr = AUX_CHDFE;
+ hd->hpib_acr = AUX_RHDF;
+ hd->hpib_acr = AUX_CSWRST;
+ hd->hpib_acr = AUX_TCA;
+ hd->hpib_acr = AUX_CSRE;
+ hd->hpib_acr = AUX_SSIC;
+ DELAY(100);
+ hd->hpib_acr = AUX_CSIC;
+ hd->hpib_acr = AUX_SSRE;
+ hd->hpib_data = C_DCL;
+ DELAY(100000);
+}
+
+nhpibsend(unit, slave, sec, buf, cnt)
+ register char *buf;
+ register int cnt;
+{
+ register struct hpib_softc *hs = &hpib_softc[unit];
+ register struct nhpibdevice *hd;
+ register int origcnt = cnt;
+
+ hd = (struct nhpibdevice *)hs->sc_addr;
+ hd->hpib_acr = AUX_TCA;
+ hd->hpib_data = C_UNL;
+ nhpibowait(hd);
+ hd->hpib_data = C_TAG + hs->sc_ba;
+ hd->hpib_acr = AUX_STON;
+ nhpibowait(hd);
+ hd->hpib_data = C_LAG + slave;
+ nhpibowait(hd);
+ if (sec != -1) {
+ hd->hpib_data = C_SCG + sec;
+ nhpibowait(hd);
+ }
+ hd->hpib_acr = AUX_GTS;
+ if (cnt) {
+ while (--cnt) {
+ hd->hpib_data = *buf++;
+ if (nhpibowait(hd) < 0)
+ break;
+ }
+ hd->hpib_acr = AUX_EOI;
+ hd->hpib_data = *buf;
+ if (nhpibowait(hd) < 0)
+ cnt++;
+ hd->hpib_acr = AUX_TCA;
+ }
+ return(origcnt - cnt);
+}
+
+nhpibrecv(unit, slave, sec, buf, cnt)
+ register char *buf;
+ register int cnt;
+{
+ register struct hpib_softc *hs = &hpib_softc[unit];
+ register struct nhpibdevice *hd;
+ register int origcnt = cnt;
+
+ hd = (struct nhpibdevice *)hs->sc_addr;
+ hd->hpib_acr = AUX_TCA;
+ hd->hpib_data = C_UNL;
+ nhpibowait(hd);
+ hd->hpib_data = C_LAG + hs->sc_ba;
+ hd->hpib_acr = AUX_SLON;
+ nhpibowait(hd);
+ hd->hpib_data = C_TAG + slave;
+ nhpibowait(hd);
+ if (sec != -1) {
+ hd->hpib_data = C_SCG + sec;
+ nhpibowait(hd);
+ }
+ hd->hpib_acr = AUX_RHDF;
+ hd->hpib_acr = AUX_GTS;
+ if (cnt) {
+ while (--cnt >= 0) {
+ if (nhpibiwait(hd) < 0)
+ break;
+ *buf++ = hd->hpib_data;
+ }
+ cnt++;
+ hd->hpib_acr = AUX_TCA;
+ }
+ return(origcnt - cnt);
+}
+
+nhpibppoll(unit)
+ register int unit;
+{
+ register struct hpib_softc *hs = &hpib_softc[unit];
+ register struct nhpibdevice *hd;
+ register int ppoll;
+
+ hd = (struct nhpibdevice *)hs->sc_addr;
+ hd->hpib_acr = AUX_SPP;
+ DELAY(25);
+ ppoll = hd->hpib_cpt;
+ hd->hpib_acr = AUX_CPP;
+ return(ppoll);
+}
+
+nhpibowait(hd)
+ register struct nhpibdevice *hd;
+{
+ register int timo = 100000;
+
+ while ((hd->hpib_mis & MIS_BO) == 0 && --timo)
+ ;
+ if (timo == 0)
+ return(-1);
+ return(0);
+}
+
+nhpibiwait(hd)
+ register struct nhpibdevice *hd;
+{
+ register int timo = 100000;
+
+ while ((hd->hpib_mis & MIS_BI) == 0 && --timo)
+ ;
+ if (timo == 0)
+ return(-1);
+ return(0);
+}
diff --git a/sys/arch/hp300/stand/pboot.c b/sys/arch/hp300/stand/pboot.c
new file mode 100644
index 00000000000..34407c14bef
--- /dev/null
+++ b/sys/arch/hp300/stand/pboot.c
@@ -0,0 +1,161 @@
+/* $NetBSD: pboot.c,v 1.10 1995/10/04 07:24:31 thorpej Exp $ */
+
+/*-
+ * Copyright (c) 1982, 1986, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * @(#)boot.c 8.1 (Berkeley) 6/10/93
+ */
+
+#include <sys/param.h>
+#include <sys/reboot.h>
+#include <a.out.h>
+#include "stand.h"
+#include "samachdep.h"
+
+/*
+ * Boot program... bits in `howto' determine whether boot stops to
+ * ask for system name. Boot device is derived from ROM provided
+ * information.
+ */
+
+char line[100];
+
+extern u_int opendev;
+extern char *lowram;
+extern int noconsole;
+extern int cons_scode;
+
+char *name;
+char *names[] = {
+ "/netbsd", "/onetbsd", "/netbsd.old",
+};
+#define NUMNAMES (sizeof(names)/sizeof(char *))
+
+static int bdev, badapt, bctlr, bunit, bpart;
+
+main()
+{
+ int currname = 0;
+
+ printf("\n>> NetBSD BOOT HP9000/%s CPU\n",
+ getmachineid());
+ printf(">> $NetBSD: pboot.c,v 1.10 1995/10/04 07:24:31 thorpej Exp $\n");
+ printf(">> Enter \"reset\" to reset system.\n");
+
+ bdev = B_TYPE(bootdev);
+ badapt = B_ADAPTOR(bootdev);
+ bctlr = B_CONTROLLER(bootdev);
+ bunit = B_UNIT(bootdev);
+ bpart = B_PARTITION(bootdev);
+
+ for (;;) {
+ name = names[currname++];
+ if (currname == NUMNAMES)
+ currname = 0;
+
+ if (!noconsole) {
+ howto = 0;
+ getbootdev(&howto);
+ } else
+ printf(": %s\n", name);
+
+#if 0
+ printf("Booting %s%d%c:%s @ 0x%x\n",
+ devsw[dev].dv_name, ctlr + (8 * adapt), 'a' + part, name, x.a_entry);
+#endif
+
+ exec(name, lowram, howto);
+ printf("boot: %s\n", strerror(errno));
+ }
+}
+
+getbootdev(howto)
+ int *howto;
+{
+ char c, *ptr = line;
+
+ printf("Boot: [[[%s%d%c:]%s][-s][-a][-d]] :- ",
+ devsw[bdev].dv_name, bctlr + (8 * badapt), 'a' + bpart, name);
+
+ if (tgets(line)) {
+ if (strcmp(line, "reset") == 0) {
+ call_req_reboot(); /* reset machine */
+ printf("panic: can't reboot, halting\n");
+ asm("stop #0x2700");
+ }
+ while (c = *ptr) {
+ while (c == ' ')
+ c = *++ptr;
+ if (!c)
+ return;
+ if (c == '-')
+ while ((c = *++ptr) && c != ' ')
+ switch (c) {
+ case 'a':
+ *howto |= RB_ASKNAME;
+ continue;
+ case 's':
+ *howto |= RB_SINGLE;
+ continue;
+ case 'd':
+ *howto |= RB_KDB;
+ continue;
+ case 'b':
+ *howto |= RB_HALT;
+ continue;
+ }
+ else {
+ name = ptr;
+ while ((c = *++ptr) && c != ' ');
+ if (c)
+ *ptr++ = 0;
+ }
+ }
+ } else
+ printf("\n");
+}
+
+void
+machdep_start(entry, howto, loadaddr, ssym, esym)
+ char *entry;
+ int howto;
+ char *loadaddr;
+ char *ssym, *esym;
+{
+
+ asm("movl %0,d7" : : "m" (howto));
+ asm("movl %0,d6" : : "m" (opendev));
+ asm("movl %0,d5" : : "m" (cons_scode));
+ asm("movl %0,a5" : : "a" (loadaddr));
+ asm("movl %0,a4" : : "a" (esym));
+ (*((int (*)())entry))();
+}
diff --git a/sys/arch/hp300/stand/prf.c b/sys/arch/hp300/stand/prf.c
new file mode 100644
index 00000000000..21929f78cb2
--- /dev/null
+++ b/sys/arch/hp300/stand/prf.c
@@ -0,0 +1,75 @@
+/* $NetBSD: prf.c,v 1.5 1994/10/26 07:27:50 cgd Exp $ */
+
+/*
+ * Copyright (c) 1982, 1986, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * @(#)prf.c 8.1 (Berkeley) 6/10/93
+ */
+
+getchar()
+{
+ register int c;
+
+ while((c = cngetc()) == 0)
+ ;
+ if (c == '\r')
+ c = '\n';
+ else if (c == ('c'&037)) {
+ panic("^C");
+ /* NOTREACHED */
+ }
+ return(c);
+}
+
+tgetchar()
+{
+ register int c;
+
+ if ((c = cngetc()) == 0)
+ return(0);
+
+ if (c == '\r')
+ c = '\n';
+ else if (c == ('c'&037)) {
+ panic("^C");
+ /* NOTREACHED */
+ }
+ return(c);
+}
+
+putchar(c)
+ register int c;
+{
+ cnputc(c);
+ if (c == '\n')
+ cnputc('\r');
+}
diff --git a/sys/arch/hp300/stand/rd.c b/sys/arch/hp300/stand/rd.c
new file mode 100644
index 00000000000..e1680a8ebb5
--- /dev/null
+++ b/sys/arch/hp300/stand/rd.c
@@ -0,0 +1,409 @@
+/* $NetBSD: rd.c,v 1.10 1995/09/23 17:19:59 thorpej Exp $ */
+
+/*
+ * Copyright (c) 1988 University of Utah.
+ * Copyright (c) 1982, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * from: Utah Hdr: rd.c 1.20 92/12/21
+ *
+ * @(#)rd.c 8.1 (Berkeley) 7/15/93
+ */
+
+/*
+ * CS80/SS80 disk driver
+ */
+#include <sys/param.h>
+#include <sys/disklabel.h>
+#include "stand.h"
+#include "samachdep.h"
+
+#include <hp300/dev/rdreg.h>
+
+struct rd_iocmd rd_ioc;
+struct rd_rscmd rd_rsc;
+struct rd_stat rd_stat;
+struct rd_ssmcmd rd_ssmc;
+
+struct disklabel rdlabel;
+
+struct rdminilabel {
+ u_short npart;
+ u_long offset[MAXPARTITIONS];
+};
+
+struct rd_softc {
+ int sc_ctlr;
+ int sc_unit;
+ int sc_part;
+ char sc_retry;
+ char sc_alive;
+ short sc_type;
+ struct rdminilabel sc_pinfo;
+} rd_softc[NHPIB][NRD];
+
+#define RDRETRY 5
+
+struct rdidentinfo {
+ short ri_hwid;
+ short ri_maxunum;
+ int ri_nblocks;
+} rdidentinfo[] = {
+ { RD7946AID, 0, 108416 },
+ { RD9134DID, 1, 29088 },
+ { RD9134LID, 1, 1232 },
+ { RD7912PID, 0, 128128 },
+ { RD7914PID, 0, 258048 },
+ { RD7958AID, 0, 255276 },
+ { RD7957AID, 0, 159544 },
+ { RD7933HID, 0, 789958 },
+ { RD9134LID, 1, 77840 },
+ { RD7936HID, 0, 600978 },
+ { RD7937HID, 0, 1116102 },
+ { RD7914CTID, 0, 258048 },
+ { RD7946AID, 0, 108416 },
+ { RD9134LID, 1, 1232 },
+ { RD7957BID, 0, 159894 },
+ { RD7958BID, 0, 297108 },
+ { RD7959BID, 0, 594216 },
+ { RD2200AID, 0, 654948 },
+ { RD2203AID, 0, 1309896 }
+};
+int numrdidentinfo = sizeof(rdidentinfo) / sizeof(rdidentinfo[0]);
+
+rdinit(ctlr, unit)
+ int ctlr, unit;
+{
+ register struct rd_softc *rs = &rd_softc[ctlr][unit];
+ u_char stat;
+
+ rs->sc_type = rdident(ctlr, unit);
+ if (rs->sc_type < 0)
+ return (0);
+ rs->sc_alive = 1;
+ return (1);
+}
+
+rdreset(ctlr, unit)
+ register int ctlr, unit;
+{
+ u_char stat;
+
+ rd_ssmc.c_unit = C_SUNIT(0);
+ rd_ssmc.c_cmd = C_SSM;
+ rd_ssmc.c_refm = REF_MASK;
+ rd_ssmc.c_fefm = FEF_MASK;
+ rd_ssmc.c_aefm = AEF_MASK;
+ rd_ssmc.c_iefm = IEF_MASK;
+ hpibsend(ctlr, unit, C_CMD, &rd_ssmc, sizeof(rd_ssmc));
+ hpibswait(ctlr, unit);
+ hpibrecv(ctlr, unit, C_QSTAT, &stat, 1);
+}
+
+rdident(ctlr, unit)
+ register int ctlr, unit;
+{
+ struct rd_describe desc;
+ u_char stat, cmd[3];
+ char name[7];
+ register int id, i;
+
+ id = hpibid(ctlr, unit);
+ if ((id & 0x200) == 0)
+ return(-1);
+ for (i = 0; i < numrdidentinfo; i++)
+ if (id == rdidentinfo[i].ri_hwid)
+ break;
+ if (i == numrdidentinfo)
+ return(-1);
+ id = i;
+ rdreset(ctlr, unit);
+ cmd[0] = C_SUNIT(0);
+ cmd[1] = C_SVOL(0);
+ cmd[2] = C_DESC;
+ hpibsend(ctlr, unit, C_CMD, cmd, sizeof(cmd));
+ hpibrecv(ctlr, unit, C_EXEC, &desc, 37);
+ hpibrecv(ctlr, unit, C_QSTAT, &stat, sizeof(stat));
+ bzero(name, sizeof(name));
+ if (!stat) {
+ register int n = desc.d_name;
+ for (i = 5; i >= 0; i--) {
+ name[i] = (n & 0xf) + '0';
+ n >>= 4;
+ }
+ }
+ /*
+ * Take care of a couple of anomolies:
+ * 1. 7945A and 7946A both return same HW id
+ * 2. 9122S and 9134D both return same HW id
+ * 3. 9122D and 9134L both return same HW id
+ */
+ switch (rdidentinfo[id].ri_hwid) {
+ case RD7946AID:
+ if (bcmp(name, "079450", 6) == 0)
+ id = RD7945A;
+ else
+ id = RD7946A;
+ break;
+
+ case RD9134LID:
+ if (bcmp(name, "091340", 6) == 0)
+ id = RD9134L;
+ else
+ id = RD9122D;
+ break;
+
+ case RD9134DID:
+ if (bcmp(name, "091220", 6) == 0)
+ id = RD9122S;
+ else
+ id = RD9134D;
+ break;
+ }
+ return(id);
+}
+
+#ifdef COMPAT_NOLABEL
+int rdcyloff[][8] = {
+ { 1, 143, 0, 143, 0, 0, 323, 503, }, /* 7945A */
+ { 1, 167, 0, 0, 0, 0, 0, 0, }, /* 9134D */
+ { 0, 0, 0, 0, 0, 0, 0, 0, }, /* 9122S */
+ { 0, 71, 0, 221, 292, 542, 221, 0, }, /* 7912P */
+ { 1, 72, 0, 72, 362, 802, 252, 362, }, /* 7914P */
+ { 1, 28, 0, 140, 167, 444, 140, 721, }, /* 7933H */
+ { 1, 200, 0, 200, 0, 0, 450, 600, }, /* 9134L */
+ { 1, 105, 0, 105, 380, 736, 265, 380, }, /* 7957A */
+ { 1, 65, 0, 65, 257, 657, 193, 257, }, /* 7958A */
+ { 1, 128, 0, 128, 518, 918, 388, 518, }, /* 7957B */
+ { 1, 44, 0, 44, 174, 496, 131, 174, }, /* 7958B */
+ { 1, 44, 0, 44, 218, 1022,174, 218, }, /* 7959B */
+ { 1, 37, 0, 37, 183, 857, 147, 183, }, /* 2200A */
+ { 1, 19, 0, 94, 112, 450, 94, 788, }, /* 2203A */
+ { 1, 20, 0, 98, 117, 256, 98, 397, }, /* 7936H */
+ { 1, 11, 0, 53, 63, 217, 53, 371, }, /* 7937H */
+};
+
+struct rdcompatinfo {
+ int nbpc;
+ int *cyloff;
+} rdcompatinfo[] = {
+ NRD7945ABPT*NRD7945ATRK, rdcyloff[0],
+ NRD9134DBPT*NRD9134DTRK, rdcyloff[1],
+ NRD9122SBPT*NRD9122STRK, rdcyloff[2],
+ NRD7912PBPT*NRD7912PTRK, rdcyloff[3],
+ NRD7914PBPT*NRD7914PTRK, rdcyloff[4],
+ NRD7958ABPT*NRD7958ATRK, rdcyloff[8],
+ NRD7957ABPT*NRD7957ATRK, rdcyloff[7],
+ NRD7933HBPT*NRD7933HTRK, rdcyloff[5],
+ NRD9134LBPT*NRD9134LTRK, rdcyloff[6],
+ NRD7936HBPT*NRD7936HTRK, rdcyloff[14],
+ NRD7937HBPT*NRD7937HTRK, rdcyloff[15],
+ NRD7914PBPT*NRD7914PTRK, rdcyloff[4],
+ NRD7945ABPT*NRD7945ATRK, rdcyloff[0],
+ NRD9122SBPT*NRD9122STRK, rdcyloff[2],
+ NRD7957BBPT*NRD7957BTRK, rdcyloff[9],
+ NRD7958BBPT*NRD7958BTRK, rdcyloff[10],
+ NRD7959BBPT*NRD7959BTRK, rdcyloff[11],
+ NRD2200ABPT*NRD2200ATRK, rdcyloff[12],
+ NRD2203ABPT*NRD2203ATRK, rdcyloff[13],
+};
+int nrdcompatinfo = sizeof(rdcompatinfo) / sizeof(rdcompatinfo[0]);
+#endif
+
+char io_buf[MAXBSIZE];
+
+rdgetinfo(rs)
+ register struct rd_softc *rs;
+{
+ register struct rdminilabel *pi = &rs->sc_pinfo;
+ register struct disklabel *lp = &rdlabel;
+ char *msg, *getdisklabel();
+ int rdstrategy(), err;
+ size_t i;
+
+ bzero((caddr_t)lp, sizeof *lp);
+ lp->d_secsize = DEV_BSIZE;
+ if (err = rdstrategy(rs, F_READ,
+ LABELSECTOR,
+ lp->d_secsize ? lp->d_secsize : DEV_BSIZE,
+ io_buf, &i) < 0) {
+ printf("rdgetinfo: rdstrategy error %d\n", err);
+ return(0);
+ }
+
+ msg = getdisklabel(io_buf, lp);
+ if (msg) {
+ printf("rd(%d,%d,%d): WARNING: %s, ",
+ rs->sc_ctlr, rs->sc_unit, rs->sc_part, msg);
+#ifdef COMPAT_NOLABEL
+ {
+ register struct rdcompatinfo *ci;
+
+ printf("using old default partitioning\n");
+ ci = &rdcompatinfo[rs->sc_type];
+ pi->npart = 8;
+ for (i = 0; i < pi->npart; i++)
+ pi->offset[i] = ci->cyloff[i] * ci->nbpc;
+ }
+#else
+ printf("defining `c' partition as entire disk\n");
+ pi->npart = 3;
+ pi->offset[0] = pi->offset[1] = -1;
+ pi->offset[2] = 0;
+#endif
+ } else {
+ pi->npart = lp->d_npartitions;
+ for (i = 0; i < pi->npart; i++)
+ pi->offset[i] = lp->d_partitions[i].p_size == 0 ?
+ -1 : lp->d_partitions[i].p_offset;
+ }
+ return(1);
+}
+
+rdopen(f, ctlr, unit, part)
+ struct open_file *f;
+ int ctlr, unit, part;
+{
+ register struct rd_softc *rs;
+ struct rdinfo *ri;
+
+ if (ctlr >= NHPIB || hpibalive(ctlr) == 0)
+ return (EADAPT);
+ if (unit >= NRD)
+ return (ECTLR);
+ rs = &rd_softc[ctlr][unit];
+ rs->sc_part = part;
+ rs->sc_unit = unit;
+ rs->sc_ctlr = ctlr;
+ if (rs->sc_alive == 0) {
+ if (rdinit(ctlr, unit) == 0)
+ return (ENXIO);
+ if (rdgetinfo(rs) == 0)
+ return (ERDLAB);
+ }
+ if (part >= rs->sc_pinfo.npart || rs->sc_pinfo.offset[part] == -1)
+ return (EPART);
+ f->f_devdata = (void *)rs;
+ return (0);
+}
+
+rdclose(f)
+ struct open_file *f;
+{
+ struct rd_softc *rs = f->f_devdata;
+
+ /*
+ * Mark the disk `not alive' so that the disklabel
+ * will be re-loaded at next open.
+ */
+ bzero(rs, sizeof(struct rd_softc));
+ f->f_devdata = NULL;
+
+ return (0);
+}
+
+rdstrategy(devdata, func, dblk, size, v_buf, rsize)
+ void *devdata;
+ int func;
+ daddr_t dblk;
+ size_t size;
+ void *v_buf;
+ size_t *rsize;
+{
+ char *buf = v_buf;
+ struct rd_softc *rs = devdata;
+ register int ctlr = rs->sc_ctlr;
+ register int unit = rs->sc_unit;
+ daddr_t blk = (dblk + rs->sc_pinfo.offset[rs->sc_part]);
+ char stat;
+
+ if (size == 0)
+ return(0);
+
+ rs->sc_retry = 0;
+ rd_ioc.c_unit = C_SUNIT(0);
+ rd_ioc.c_volume = C_SVOL(0);
+ rd_ioc.c_saddr = C_SADDR;
+ rd_ioc.c_hiaddr = 0;
+ rd_ioc.c_addr = RDBTOS(blk);
+ rd_ioc.c_nop2 = C_NOP;
+ rd_ioc.c_slen = C_SLEN;
+ rd_ioc.c_len = size;
+ rd_ioc.c_cmd = func == F_READ ? C_READ : C_WRITE;
+retry:
+ hpibsend(ctlr, unit, C_CMD, &rd_ioc.c_unit, sizeof(rd_ioc)-2);
+ hpibswait(ctlr, unit);
+ hpibgo(ctlr, unit, C_EXEC, buf, size, func);
+ hpibswait(ctlr, unit);
+ hpibrecv(ctlr, unit, C_QSTAT, &stat, 1);
+ if (stat) {
+ if (rderror(ctlr, unit, rs->sc_part) == 0)
+ return(-1);
+ if (++rs->sc_retry > RDRETRY)
+ return(-1);
+ goto retry;
+ }
+ *rsize = size;
+
+ return(0);
+}
+
+rderror(ctlr, unit, part)
+ register int ctlr, unit;
+ int part;
+{
+ register struct rd_softc *rd = &rd_softc[ctlr][unit];
+ char stat;
+
+ rd_rsc.c_unit = C_SUNIT(0);
+ rd_rsc.c_sram = C_SRAM;
+ rd_rsc.c_ram = C_RAM;
+ rd_rsc.c_cmd = C_STATUS;
+ hpibsend(ctlr, unit, C_CMD, &rd_rsc, sizeof(rd_rsc));
+ hpibrecv(ctlr, unit, C_EXEC, &rd_stat, sizeof(rd_stat));
+ hpibrecv(ctlr, unit, C_QSTAT, &stat, 1);
+ if (stat) {
+ printf("rd(%d,%d,0,%d): request status fail %d\n",
+ ctlr, unit, part, stat);
+ return(0);
+ }
+ printf("rd(%d,%d,0,%d) err: vu 0x%x",
+ ctlr, unit, part, rd_stat.c_vu);
+ if ((rd_stat.c_aef & AEF_UD) || (rd_stat.c_ief & (IEF_MD|IEF_RD)))
+ printf(", block %d", rd_stat.c_blk);
+ printf(", R0x%x F0x%x A0x%x I0x%x\n",
+ rd_stat.c_ref, rd_stat.c_fef, rd_stat.c_aef, rd_stat.c_ief);
+ return(1);
+}
diff --git a/sys/arch/hp300/stand/rominfo.h b/sys/arch/hp300/stand/rominfo.h
new file mode 100644
index 00000000000..389e8ed2cb7
--- /dev/null
+++ b/sys/arch/hp300/stand/rominfo.h
@@ -0,0 +1,68 @@
+/* $NetBSD: rominfo.h,v 1.5 1994/10/26 07:27:53 cgd Exp $ */
+
+/*
+ * Copyright (c) 1988 University of Utah.
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * from: Utah $Hdr: rominfo.h 1.2 88/05/24$
+ *
+ * @(#)rominfo.h 8.1 (Berkeley) 6/10/93
+ */
+
+#define ROMADDR 0xFFFFF000
+
+struct jmpvec {
+ short op; /* jmp instruction */
+ long addr; /* address */
+};
+
+struct rominfo {
+ char p1[0xDC0];
+ short boottype; /* ?? (FFFFFDC0) */
+ char name[10]; /* HP system name, e.g. SYSHPUX (FFFFFDC2) */
+ short p2; /* ?? (FFFFFDCC) */
+ long lowram; /* lowest useable RAM location (FFFFFDCE) */
+ char p3[0x100]; /* ?? (FFFFFDD2) */
+ char sysflag; /* HP system flags (FFFFFED2) */
+ char p4; /* ?? (FFFFFED3) */
+ long rambase; /* physaddr of lowest RAM (FFFFFED4) */
+ char ndrives; /* number of drives (FFFFFED8) */
+ char p5; /* ?? (FFFFFED9) */
+ char sysflag2; /* more system flags (FFFFFEDA) */
+ char p6; /* ?? (FFFFFEDB) */
+ long msus; /* ?? (FFFFFEDC) */
+ struct jmpvec jvec[48]; /* jump vectors (FFFFFEE0) */
+};
diff --git a/sys/arch/hp300/stand/samachdep.h b/sys/arch/hp300/stand/samachdep.h
new file mode 100644
index 00000000000..192d2b4241a
--- /dev/null
+++ b/sys/arch/hp300/stand/samachdep.h
@@ -0,0 +1,79 @@
+/* $NetBSD: samachdep.h,v 1.5 1995/08/05 16:47:50 thorpej Exp $ */
+
+/*
+ * Copyright (c) 1982, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * @(#)samachdep.h 8.1 (Berkeley) 6/10/93
+ */
+
+#define NHPIB 4
+#define NSCSI 2
+#define NRD 8
+#define NCT 8
+#define NSD 8
+
+#define NITE 4
+
+/* from cpu.h */
+#define IIOV(x) (x)
+#define DIOBASE (0x600000)
+#define DIOCSIZE (0x10000)
+#define DIOIIBASE (0x01000000)
+#define DIOIICSIZE (0x00400000)
+
+#define HP_320 0 /* 16Mhz 68020+HP MMU+16K external cache */
+#define HP_330 1 /* 16Mhz 68020+68851 MMU */
+#define HP_350 2 /* 25Mhz 68020+HP MMU+32K external cache */
+#define HP_360 3 /* 25Mhz 68030 */
+#define HP_370 4 /* 33Mhz 68030+64K external cache */
+#define HP_340 5 /* 16Mhz 68030 */
+#define HP_375 6 /* 50Mhz 68030+32K external cache */
+#define HP_380 7 /* 25Mhz 68040 */
+#define HP_433 8 /* 33Mhz 68040 */
+
+#define MHZ_8 1
+#define MHZ_16 2
+#define MHZ_25 3
+#define MHZ_33 4
+#define MHZ_50 6
+
+extern int cpuspeed, machineid;
+extern int howto;
+extern unsigned int bootdev;
+extern char *getmachineid();
+
+#define DELAY(n) { register int N = cpuspeed * (n); while (--N > 0); }
+
+/* bogon grfinfo structure to keep grf_softc happy */
+struct grfinfo {
+ int grf_foo;
+};
diff --git a/sys/arch/hp300/stand/scsi.c b/sys/arch/hp300/stand/scsi.c
new file mode 100644
index 00000000000..0aa7c2e5401
--- /dev/null
+++ b/sys/arch/hp300/stand/scsi.c
@@ -0,0 +1,459 @@
+/* $NetBSD: scsi.c,v 1.5 1994/10/26 07:27:56 cgd Exp $ */
+
+/*
+ * Copyright (c) 1988 University of Utah.
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Van Jacobson of Lawrence Berkeley Laboratory and the Systems
+ * Programming Group of the University of Utah Computer Science Department.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * from: Utah $Hdr: scsi.c 1.3 90/01/27$
+ *
+ * @(#)scsi.c 8.1 (Berkeley) 6/10/93
+ */
+
+/*
+ * SCSI bus driver for standalone programs.
+ */
+
+#include <sys/param.h>
+#include <sys/reboot.h>
+#include <hp300/dev/device.h>
+#define _IOCTL_
+#include <hp300/dev/scsireg.h>
+#include "scsivar.h"
+
+#include "stand.h"
+#include "samachdep.h"
+
+struct scsi_softc scsi_softc[NSCSI];
+
+void scsireset();
+int scsi_cmd_wait = 50000; /* use the "real" driver init_wait value */
+int scsi_data_wait = 50000; /* use the "real" driver init_wait value */
+
+scsiinit()
+{
+ extern struct hp_hw sc_table[];
+ register struct hp_hw *hw;
+ register struct scsi_softc *hs;
+ register int i, addr;
+ static int waitset = 0;
+
+ i = 0;
+ for (hw = sc_table; i < NSCSI && hw < &sc_table[MAXCTLRS]; hw++) {
+ if (!HW_ISSCSI(hw))
+ continue;
+ hs = &scsi_softc[i];
+ hs->sc_addr = hw->hw_kva;
+ scsireset(i);
+ if (howto & RB_ASKNAME)
+ printf("scsi%d at sc%d\n", i, hw->hw_sc);
+ hw->hw_pa = (caddr_t) i; /* XXX for autoconfig */
+ hs->sc_alive = 1;
+ i++;
+ }
+ /*
+ * Adjust the wait values
+ */
+ if (!waitset) {
+ scsi_cmd_wait *= cpuspeed;
+ scsi_data_wait *= cpuspeed;
+ waitset = 1;
+ }
+}
+
+scsialive(unit)
+ register int unit;
+{
+ if (unit >= NSCSI || scsi_softc[unit].sc_alive == 0)
+ return (0);
+ return (1);
+}
+
+void
+scsireset(unit)
+ register int unit;
+{
+ volatile register struct scsidevice *hd;
+ register struct scsi_softc *hs;
+ u_int i;
+
+ hs = &scsi_softc[unit];
+ hd = (struct scsidevice *)hs->sc_addr;
+ hd->scsi_id = 0xFF;
+ DELAY(100);
+ /*
+ * Disable interrupts then reset the FUJI chip.
+ */
+ hd->scsi_csr = 0;
+ hd->scsi_sctl = SCTL_DISABLE | SCTL_CTRLRST;
+ hd->scsi_scmd = 0;
+ hd->scsi_tmod = 0;
+ hd->scsi_pctl = 0;
+ hd->scsi_temp = 0;
+ hd->scsi_tch = 0;
+ hd->scsi_tcm = 0;
+ hd->scsi_tcl = 0;
+ hd->scsi_ints = 0;
+
+ /*
+ * Configure the FUJI chip with its SCSI address, all
+ * interrupts enabled & appropriate parity.
+ */
+ i = (~hd->scsi_hconf) & 0x7;
+ hs->sc_scsi_addr = 1 << i;
+ hd->scsi_bdid = i;
+ if (hd->scsi_hconf & HCONF_PARITY)
+ hd->scsi_sctl = SCTL_DISABLE | SCTL_ABRT_ENAB |
+ SCTL_SEL_ENAB | SCTL_RESEL_ENAB |
+ SCTL_INTR_ENAB | SCTL_PARITY_ENAB;
+ else
+ hd->scsi_sctl = SCTL_DISABLE | SCTL_ABRT_ENAB |
+ SCTL_SEL_ENAB | SCTL_RESEL_ENAB |
+ SCTL_INTR_ENAB;
+ hd->scsi_sctl &=~ SCTL_DISABLE;
+}
+
+
+int
+scsiabort(hs, hd)
+ register struct scsi_softc *hs;
+ volatile register struct scsidevice *hd;
+{
+ printf("scsi%d error: scsiabort\n", hs - scsi_softc);
+
+ scsireset(hs - scsi_softc);
+ DELAY(1000000);
+}
+
+static int
+issue_select(hd, target, our_addr)
+ volatile register struct scsidevice *hd;
+ u_char target, our_addr;
+{
+ if (hd->scsi_ssts & (SSTS_INITIATOR|SSTS_TARGET|SSTS_BUSY))
+ return (1);
+
+ if (hd->scsi_ints & INTS_DISCON)
+ hd->scsi_ints = INTS_DISCON;
+
+ hd->scsi_pctl = 0;
+ hd->scsi_temp = (1 << target) | our_addr;
+ /* select timeout is hardcoded to 2ms */
+ hd->scsi_tch = 0;
+ hd->scsi_tcm = 32;
+ hd->scsi_tcl = 4;
+
+ hd->scsi_scmd = SCMD_SELECT;
+ return (0);
+}
+
+static int
+wait_for_select(hd)
+ volatile register struct scsidevice *hd;
+{
+ register int wait;
+ u_char ints;
+
+ wait = scsi_data_wait;
+ while ((ints = hd->scsi_ints) == 0) {
+ if (--wait < 0)
+ return (1);
+ DELAY(1);
+ }
+ hd->scsi_ints = ints;
+ return (!(hd->scsi_ssts & SSTS_INITIATOR));
+}
+
+static int
+ixfer_start(hd, len, phase, wait)
+ volatile register struct scsidevice *hd;
+ int len;
+ u_char phase;
+ register int wait;
+{
+
+ hd->scsi_tch = len >> 16;
+ hd->scsi_tcm = len >> 8;
+ hd->scsi_tcl = len;
+ hd->scsi_pctl = phase;
+ hd->scsi_tmod = 0; /*XXX*/
+ hd->scsi_scmd = SCMD_XFR | SCMD_PROG_XFR;
+
+ /* wait for xfer to start or svc_req interrupt */
+ while ((hd->scsi_ssts & SSTS_BUSY) == 0) {
+ if (hd->scsi_ints || --wait < 0)
+ return (0);
+ DELAY(1);
+ }
+ return (1);
+}
+
+static int
+ixfer_out(hd, len, buf)
+ volatile register struct scsidevice *hd;
+ int len;
+ register u_char *buf;
+{
+ register int wait = scsi_data_wait;
+
+ for (; len > 0; --len) {
+ while (hd->scsi_ssts & SSTS_DREG_FULL) {
+ if (hd->scsi_ints || --wait < 0)
+ return (len);
+ DELAY(1);
+ }
+ hd->scsi_dreg = *buf++;
+ }
+ return (0);
+}
+
+static int
+ixfer_in(hd, len, buf)
+ volatile register struct scsidevice *hd;
+ int len;
+ register u_char *buf;
+{
+ register int wait = scsi_data_wait;
+
+ for (; len > 0; --len) {
+ while (hd->scsi_ssts & SSTS_DREG_EMPTY) {
+ if (hd->scsi_ints || --wait < 0) {
+ while (! (hd->scsi_ssts & SSTS_DREG_EMPTY)) {
+ *buf++ = hd->scsi_dreg;
+ --len;
+ }
+ return (len);
+ }
+ DELAY(1);
+ }
+ *buf++ = hd->scsi_dreg;
+ }
+ return (len);
+}
+
+static int
+scsiicmd(hs, target, cbuf, clen, buf, len, xferphase)
+ struct scsi_softc *hs;
+ int target;
+ u_char *cbuf;
+ int clen;
+ u_char *buf;
+ int len;
+ u_char xferphase;
+{
+ volatile register struct scsidevice *hd =
+ (struct scsidevice *)hs->sc_addr;
+ u_char phase, ints;
+ register int wait;
+
+ /* select the SCSI bus (it's an error if bus isn't free) */
+ if (issue_select(hd, target, hs->sc_scsi_addr))
+ return (-2);
+ if (wait_for_select(hd))
+ return (-2);
+ /*
+ * Wait for a phase change (or error) then let the device
+ * sequence us through the various SCSI phases.
+ */
+ hs->sc_stat = -1;
+ phase = CMD_PHASE;
+ while (1) {
+ wait = scsi_cmd_wait;
+ switch (phase) {
+
+ case CMD_PHASE:
+ if (ixfer_start(hd, clen, phase, wait))
+ if (ixfer_out(hd, clen, cbuf))
+ goto abort;
+ phase = xferphase;
+ break;
+
+ case DATA_IN_PHASE:
+ if (len <= 0)
+ goto abort;
+ wait = scsi_data_wait;
+ if (ixfer_start(hd, len, phase, wait) ||
+ !(hd->scsi_ssts & SSTS_DREG_EMPTY))
+ ixfer_in(hd, len, buf);
+ phase = STATUS_PHASE;
+ break;
+
+ case DATA_OUT_PHASE:
+ if (len <= 0)
+ goto abort;
+ wait = scsi_data_wait;
+ if (ixfer_start(hd, len, phase, wait))
+ if (ixfer_out(hd, len, buf))
+ goto abort;
+ phase = STATUS_PHASE;
+ break;
+
+ case STATUS_PHASE:
+ wait = scsi_data_wait;
+ if (ixfer_start(hd, sizeof(hs->sc_stat), phase, wait) ||
+ !(hd->scsi_ssts & SSTS_DREG_EMPTY))
+ ixfer_in(hd, sizeof(hs->sc_stat), &hs->sc_stat);
+ phase = MESG_IN_PHASE;
+ break;
+
+ case MESG_IN_PHASE:
+ if (ixfer_start(hd, sizeof(hs->sc_msg), phase, wait) ||
+ !(hd->scsi_ssts & SSTS_DREG_EMPTY)) {
+ ixfer_in(hd, sizeof(hs->sc_msg), &hs->sc_msg);
+ hd->scsi_scmd = SCMD_RST_ACK;
+ }
+ phase = BUS_FREE_PHASE;
+ break;
+
+ case BUS_FREE_PHASE:
+ goto out;
+
+ default:
+ printf("scsi%d: unexpected scsi phase %d\n",
+ hs - scsi_softc, phase);
+ goto abort;
+ }
+#ifdef SLOWSCSI
+ /*
+ * XXX we have wierd transient problems with booting from
+ * slow scsi disks on fast machines. I have never been
+ * able to pin the problem down, but a large delay here
+ * seems to always work.
+ */
+ DELAY(1000);
+#endif
+ /* wait for last command to complete */
+ while ((ints = hd->scsi_ints) == 0) {
+ if (--wait < 0)
+ goto abort;
+ DELAY(1);
+ }
+ hd->scsi_ints = ints;
+ if (ints & INTS_SRV_REQ)
+ phase = hd->scsi_psns & PHASE;
+ else if (ints & INTS_DISCON)
+ goto out;
+ else if ((ints & INTS_CMD_DONE) == 0)
+ goto abort;
+ }
+abort:
+ scsiabort(hs, hd);
+out:
+ return (hs->sc_stat);
+}
+
+int
+scsi_test_unit_rdy(ctlr, slave)
+ int ctlr, slave;
+{
+ register struct scsi_softc *hs = &scsi_softc[ctlr];
+ static struct scsi_cdb6 cdb = { CMD_TEST_UNIT_READY };
+
+ return (scsiicmd(hs, slave, &cdb, sizeof(cdb), (u_char *)0, 0,
+ STATUS_PHASE));
+}
+
+int
+scsi_request_sense(ctlr, slave, buf, len)
+ int ctlr, slave;
+ u_char *buf;
+ unsigned len;
+{
+ register struct scsi_softc *hs = &scsi_softc[ctlr];
+ static struct scsi_cdb6 cdb = { CMD_REQUEST_SENSE };
+
+ cdb.len = len;
+ return (scsiicmd(hs, slave, &cdb, sizeof(cdb), buf, len,
+ DATA_IN_PHASE));
+}
+
+int
+scsi_read_capacity(ctlr, slave, buf, len)
+ int ctlr, slave;
+ u_char *buf;
+ unsigned len;
+{
+ register struct scsi_softc *hs = &scsi_softc[ctlr];
+ static struct scsi_cdb10 cdb = { CMD_READ_CAPACITY };
+
+ return (scsiicmd(hs, slave, &cdb, sizeof(cdb), buf, len,
+ DATA_IN_PHASE));
+}
+
+int
+scsi_tt_read(ctlr, slave, buf, len, blk, nblk)
+ int ctlr, slave;
+ u_char *buf;
+ u_int len;
+ daddr_t blk;
+ u_int nblk;
+{
+ register struct scsi_softc *hs = &scsi_softc[ctlr];
+ struct scsi_cdb10 cdb;
+
+ bzero(&cdb, sizeof(cdb));
+ cdb.cmd = CMD_READ_EXT;
+ cdb.lbah = blk >> 24;
+ cdb.lbahm = blk >> 16;
+ cdb.lbalm = blk >> 8;
+ cdb.lbal = blk;
+ cdb.lenh = nblk >> (8 + DEV_BSHIFT);
+ cdb.lenl = nblk >> DEV_BSHIFT;
+ return (scsiicmd(hs, slave, &cdb, sizeof(cdb), buf, len,
+ DATA_IN_PHASE));
+}
+
+int
+scsi_tt_write(ctlr, slave, buf, len, blk, nblk)
+ int ctlr, slave;
+ u_char *buf;
+ u_int len;
+ daddr_t blk;
+ u_int nblk;
+{
+ register struct scsi_softc *hs = &scsi_softc[ctlr];
+ struct scsi_cdb10 cdb;
+
+ bzero(&cdb, sizeof(cdb));
+ cdb.cmd = CMD_WRITE_EXT;
+ cdb.lbah = blk >> 24;
+ cdb.lbahm = blk >> 16;
+ cdb.lbalm = blk >> 8;
+ cdb.lbal = blk;
+ cdb.lenh = nblk >> (8 + DEV_BSHIFT);
+ cdb.lenl = nblk >> DEV_BSHIFT;
+ return (scsiicmd(hs, slave, &cdb, sizeof(cdb), buf, len,
+ DATA_OUT_PHASE));
+}
diff --git a/sys/arch/hp300/stand/scsivar.h b/sys/arch/hp300/stand/scsivar.h
new file mode 100644
index 00000000000..a80d5b3d4a5
--- /dev/null
+++ b/sys/arch/hp300/stand/scsivar.h
@@ -0,0 +1,51 @@
+/* $NetBSD: scsivar.h,v 1.4 1994/10/26 07:27:58 cgd Exp $ */
+
+/*
+ * Copyright (c) 1982, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Van Jacobson of Lawrence Berkeley Laboratory and the Systems
+ * Programming Group of the University of Utah Computer Science Department.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * @(#)scsivar.h 8.1 (Berkeley) 6/10/93
+ */
+
+struct scsi_softc {
+ int sc_ba;
+ char *sc_addr;
+ char sc_alive;
+ char sc_scsi_addr;
+ char sc_stat;
+ char sc_msg[7];
+};
+
+extern struct scsi_softc scsi_softc[];
diff --git a/sys/arch/hp300/stand/sd.c b/sys/arch/hp300/stand/sd.c
new file mode 100644
index 00000000000..766a16719ce
--- /dev/null
+++ b/sys/arch/hp300/stand/sd.c
@@ -0,0 +1,256 @@
+/* $NetBSD: sd.c,v 1.8 1995/09/23 17:19:58 thorpej Exp $ */
+
+/*
+ * Copyright (c) 1988 University of Utah.
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Van Jacobson of Lawrence Berkeley Laboratory and the Systems
+ * Programming Group of the University of Utah Computer Science Department.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * from: Utah $Hdr: sd.c 1.9 92/12/21$
+ *
+ * @(#)sd.c 8.1 (Berkeley) 6/10/93
+ */
+
+/*
+ * SCSI CCS disk driver
+ */
+
+#include <sys/param.h>
+#include <sys/disklabel.h>
+#include "stand.h"
+#include "samachdep.h"
+
+#define _IOCTL_
+#include <hp300/dev/scsireg.h>
+
+struct disklabel sdlabel;
+
+struct sdminilabel {
+ u_short npart;
+ u_long offset[MAXPARTITIONS];
+};
+
+struct sd_softc {
+ int sc_ctlr;
+ int sc_unit;
+ int sc_part;
+ char sc_retry;
+ char sc_alive;
+ short sc_blkshift;
+ struct sdminilabel sc_pinfo;
+} sd_softc[NSCSI][NSD];
+
+#define SDRETRY 2
+
+sdinit(ctlr, unit)
+ int ctlr, unit;
+{
+ register struct sd_softc *ss = &sd_softc[ctlr][unit];
+ u_char stat;
+ int capbuf[2];
+
+ stat = scsi_test_unit_rdy(ctlr, unit);
+ if (stat) {
+ /* drive may be doing RTZ - wait a bit */
+ if (stat == STS_CHECKCOND) {
+ DELAY(1000000);
+ stat = scsi_test_unit_rdy(ctlr, unit);
+ }
+ if (stat) {
+ printf("sd(%d,%d,0,0): init failed (stat=%x)\n",
+ ctlr, unit, stat);
+ return (0);
+ }
+ }
+ /*
+ * try to get the drive block size.
+ */
+ capbuf[0] = 0;
+ capbuf[1] = 0;
+ stat = scsi_read_capacity(ctlr, unit,
+ (u_char *)capbuf, sizeof(capbuf));
+ if (stat == 0) {
+ if (capbuf[1] > DEV_BSIZE)
+ for (; capbuf[1] > DEV_BSIZE; capbuf[1] >>= 1)
+ ++ss->sc_blkshift;
+ }
+ ss->sc_alive = 1;
+ return (1);
+}
+
+sdreset(ctlr, unit)
+ int ctlr, unit;
+{
+}
+
+#ifdef COMPAT_NOLABEL
+struct sdminilabel defaultpinfo = {
+ 8,
+ { 1024, 17408, 0, 17408, 115712, 218112, 82944, 115712 }
+};
+#endif
+
+char io_buf[MAXBSIZE];
+
+sdgetinfo(ss)
+ register struct sd_softc *ss;
+{
+ register struct sdminilabel *pi = &ss->sc_pinfo;
+ register struct disklabel *lp = &sdlabel;
+ char *msg, *getdisklabel();
+ int sdstrategy(), err;
+ size_t i;
+
+ bzero((caddr_t)lp, sizeof *lp);
+ lp->d_secsize = (DEV_BSIZE << ss->sc_blkshift);
+
+ if (err = sdstrategy(ss, F_READ,
+ LABELSECTOR,
+ lp->d_secsize ? lp->d_secsize : DEV_BSIZE,
+ io_buf, &i) < 0) {
+ printf("sdgetinfo: sdstrategy error %d\n", err);
+ return(0);
+ }
+
+ msg = getdisklabel(io_buf, lp);
+ if (msg) {
+ printf("sd(%d,%d,%d): WARNING: %s, ",
+ ss->sc_ctlr, ss->sc_unit, ss->sc_part, msg);
+#ifdef COMPAT_NOLABEL
+ printf("using old default partitioning\n");
+ *pi = defaultpinfo;
+#else
+ printf("defining `c' partition as entire disk\n");
+ pi->npart = 3;
+ pi->offset[0] = pi->offset[1] = -1;
+ pi->offset[2] = 0;
+#endif
+ } else {
+ pi->npart = lp->d_npartitions;
+ for (i = 0; i < pi->npart; i++)
+ pi->offset[i] = lp->d_partitions[i].p_size == 0 ?
+ -1 : lp->d_partitions[i].p_offset;
+ }
+ return(1);
+}
+
+sdopen(f, ctlr, unit, part)
+ struct open_file *f;
+ int ctlr, unit, part;
+{
+ register struct sd_softc *ss;
+
+#ifdef SD_DEBUG
+ if (debug)
+ printf("sdopen: ctlr=%d unit=%d part=%d\n",
+ ctlr, unit, part);
+#endif
+
+ if (ctlr >= NSCSI || scsialive(ctlr) == 0)
+ return (EADAPT);
+ if (unit >= NSD)
+ return (ECTLR);
+ ss = &sd_softc[ctlr][unit];
+ ss->sc_part = part;
+ ss->sc_unit = unit;
+ ss->sc_ctlr = ctlr;
+ if (ss->sc_alive == 0) {
+ if (sdinit(ctlr, unit) == 0)
+ return (ENXIO);
+ if (sdgetinfo(ss) == 0)
+ return (ERDLAB);
+ }
+ if (part >= ss->sc_pinfo.npart || ss->sc_pinfo.offset[part] == -1)
+ return (EPART);
+ f->f_devdata = (void *)ss;
+ return (0);
+}
+
+sdclose(f)
+ struct open_file *f;
+{
+ struct sd_softc *ss = f->f_devdata;
+
+ /*
+ * Mark the disk `not alive' so that the disklabel
+ * will be re-loaded at next open.
+ */
+ bzero(ss, sizeof(sd_softc));
+ f->f_devdata = NULL;
+
+ return (0);
+}
+
+sdstrategy(ss, func, dblk, size, v_buf, rsize)
+ register struct sd_softc *ss;
+ int func;
+ daddr_t dblk;
+ size_t size;
+ void *v_buf;
+ size_t *rsize;
+{
+ char *buf = v_buf;
+ register int ctlr = ss->sc_ctlr;
+ register int unit = ss->sc_unit;
+ daddr_t blk = (dblk + ss->sc_pinfo.offset[ss->sc_part])>> ss->sc_blkshift;
+ u_int nblk = size >> ss->sc_blkshift;
+ char stat;
+
+ if (size == 0)
+ return(0);
+
+ ss->sc_retry = 0;
+
+#ifdef SD_DEBUG
+ if (debug)
+ printf("sdstrategy(%d,%d): size=%d blk=%d nblk=%d\n",
+ ctlr, unit, size, blk, nblk);
+#endif
+
+retry:
+ if (func == F_READ)
+ stat = scsi_tt_read(ctlr, unit, buf, size, blk, nblk);
+ else
+ stat = scsi_tt_write(ctlr, unit, buf, size, blk, nblk);
+ if (stat) {
+ printf("sd(%d,%d,%d): block=%x, error=0x%x\n",
+ ctlr, unit, ss->sc_part, blk, stat);
+ if (++ss->sc_retry > SDRETRY)
+ return(EIO);
+ goto retry;
+ }
+ *rsize = size;
+
+ return(0);
+}
diff --git a/sys/arch/hp300/stand/srt0.s b/sys/arch/hp300/stand/srt0.s
new file mode 100644
index 00000000000..d5a800eecbf
--- /dev/null
+++ b/sys/arch/hp300/stand/srt0.s
@@ -0,0 +1,263 @@
+/* $NetBSD: srt0.s,v 1.3 1995/09/02 05:04:23 thorpej Exp $ */
+
+/*
+ * Copyright (c) 1988 University of Utah.
+ * Copyright (c) 1982, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * from: Utah $Hdr: srt0.c 1.18 92/12/21$
+ *
+ * @(#)srt0.c 8.1 (Berkeley) 6/10/93
+ */
+
+/*
+ * Startup code for standalone system
+ */
+
+ .globl begin
+ .globl _end
+ .globl _edata
+ .globl _main
+ .globl _configure
+ .globl __rtt
+ .globl _bootdev,_howto,_lowram,_machineid
+ .globl _internalhpib
+
+ STACK = 0xfffff000 | below the ROM page
+ BOOTTYPE = 0xfffffdc0
+ LOWRAM = 0xfffffdce
+ SYSFLAG = 0xfffffed2 | system flags
+ MSUS = 0xfffffedc | MSUS (?) structure
+ VECTORS = 0xfffffee0 | beginning of jump vectors
+ NMIRESET = 0xffffff9c | reset vector
+ BUSERR = 0xfffffffc
+ MAXADDR = 0xfffff000
+ NBPG = 4096
+ MMUCMD = 0x005f400c | MMU command/status register
+
+ .data
+_bootdev:
+ .long 0
+_howto:
+ .long 0
+_lowram:
+ .long 0
+_machineid:
+ .long 0
+
+ .text
+begin:
+ movl #STACK,sp
+ moveq #47,d0 | # of vectors - 1
+ movl #VECTORS+2,a0 | addr part of first vector
+vecloop:
+ movl #trap,a0@ | make it direct to trap
+ addql #6,a0 | move to next vector addr
+ 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 not68030 | yes, we have 68020/68040
+ 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
+not68030:
+ bset #31,d0 | data cache enable bit
+ movc d0,cacr | only exists on 68040
+ movc cacr,d0 | read it back
+ tstl d0 | zero?
+ beq is68020 | yes, we have 68020
+ moveq #0,d0 | now turn it back off
+ movec d0,cacr | before we access any data
+ .long 0x4e7b0004 | movc d0,itt0
+ .long 0x4e7b0005 | movc d0,itt1
+ .long 0x4e7b0006 | movc d0,dtt0
+ .long 0x4e7b0007 | movc d0,dtt1
+ .word 0xf4d8 | cinva bc
+ movl MMUCMD,d0 | get MMU register
+ lsrl #8,d0 | get apparent ID
+ cmpb #6,d0 | id == 6?
+ jeq is33mhz | yes, we have a 433s
+ movl #7,a0@ | no, we have a 380/425t
+ jra ihpibcheck
+is33mhz:
+ movl #8,a0@ | 433s (XXX 425s returns same ID, ugh!)
+ 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
+/*
+ * If this is a reboot, extract howto/bootdev stored by kernel
+ */
+boottype:
+ cmpw #12,BOOTTYPE | is this a reboot (REQ_REBOOT)?
+ jne notreboot | no, skip
+ lea MAXADDR,a0 | find last page
+ movl a0@+,d7 | and extract howto, bootdev
+ movl a0@+,d6 | from where doboot() left them
+ jra boot1
+/*
+ * At this point we do not know which logical device the MSUS select
+ * code refers to so we cannot construct bootdev. So we just punt
+ * and let configure() construct it.
+ */
+notreboot:
+ moveq #0,d6 | make sure bootdev is invalid
+ cmpw #18,BOOTTYPE | does the user want to interact?
+ jeq askme | yes, go to it
+ moveq #0,d7 | default to RB_AUTOBOOT
+ jra boot1
+askme:
+ moveq #3,d7 | default to RB_SINGLE|RB_ASKNAME
+boot1:
+ movl d6,_bootdev | save bootdev and howto
+ movl d7,_howto | globally so all can access
+ movl LOWRAM,d0 | read lowram value from bootrom
+ addl #NBPG,d0 | must preserve this for bootrom to reboot
+ andl #0xfffff000,d0 | round to next page
+ movl d0,_lowram | stash that value
+start:
+ movl #_edata,a2 | start of BSS
+ movl #_end,a3 | end
+clr:
+ clrb a2@+ | clear BSS
+ cmpl a2,a3 | done?
+ bne clr | no, keep going
+ jsr _configure | configure critical devices
+ jsr _main | lets go
+__rtt:
+ movl #3,_howto | restarts get RB_SINGLE|RB_ASKNAME
+ jmp start
+
+/*
+ * probe a location and see if it causes a bus error
+ */
+ .globl _badaddr
+_badaddr:
+ movl BUSERR,__bsave | save ROM bus error handler address
+ movl sp,__ssave | and current stack pointer
+ movl #catchbad,BUSERR| plug in our handler
+ movl sp@(4),a0 | address to probe
+ movw a0@,d1 | do it
+ movl __bsave,BUSERR | if we got here, it did not fault
+ clrl d0 | return that this was not a bad addr
+ rts
+
+catchbad:
+ movl __bsave,BUSERR | got a bus error, so restore old handler
+ movl __ssave,sp | manually restore stack
+ moveq #1,d0 | indicate that we got a fault
+ rts | return to caller of badaddr()
+
+__bsave:
+ .long 0
+__ssave:
+ .long 0
+
+ .globl _trap
+trap:
+ moveml #0xFFFF,sp@- | save registers
+ movl sp,sp@- | push pointer to frame
+ jsr _trap | call C routine to deal with it
+ tstl d0
+ jeq Lstop
+ addql #4,sp
+ moveml sp@+,#0x7FFF
+ addql #8,sp
+ rte
+Lstop:
+ stop #0x2700 | stop cold
+
+nmi:
+ movw #18,BOOTTYPE | mark as system switch
+ jsr _kbdnmi | clear the interrupt
+ jra begin | start over
+
+ .globl _call_req_reboot
+_call_req_reboot:
+ jmp 0x1A4 | call ROM reboot function
+ rts | XXX: just in case?
+
+#ifdef ROMPRF
+ .globl _romout
+_romout:
+ movl sp@(4),d0 | line number
+ movl sp@(8),a0 | string
+ jsr 0x150 | do it
+ rts
+#endif
diff --git a/sys/arch/hp300/stand/sys_inst.c b/sys/arch/hp300/stand/sys_inst.c
new file mode 100644
index 00000000000..bd98f8dee67
--- /dev/null
+++ b/sys/arch/hp300/stand/sys_inst.c
@@ -0,0 +1,589 @@
+/* $NetBSD: sys_inst.c,v 1.3 1995/10/04 07:24:33 thorpej Exp $ */
+
+/*
+ * Copyright (c) 1995 Jason R. Thorpe.
+ * All rights reserved.
+ *
+ * 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 for the NetBSD Project
+ * by Jason R. Thorpe.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * Portions of this program are inspired by (and have borrowed code from)
+ * the `editlabel' program that accompanies NetBSD/vax, which carries
+ * the following notice:
+ *
+ * Copyright (c) 1995 Ludd, University of Lule}, Sweden.
+ * All rights reserved.
+ *
+ * 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 at Ludd, University of
+ * Lule}, Sweden and its contributors.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ */
+
+#define DKTYPENAMES
+
+#include <sys/param.h>
+#include <sys/reboot.h>
+#include <sys/disklabel.h>
+#include <a.out.h>
+#include "stand.h"
+#include "samachdep.h"
+
+char line[100];
+
+extern u_int opendev;
+extern char *lowram;
+extern int noconsole;
+extern int cons_scode;
+
+char *kernel_name = "/netbsd";
+
+void dsklabel __P((void));
+void miniroot __P((void));
+void bootmini __P((void));
+void resetsys __P((void));
+void gethelp __P((void));
+int opendisk __P((char *, char *, int, char, int *));
+void disklabel_edit __P((struct disklabel *));
+void disklabel_show __P((struct disklabel *));
+int disklabel_write __P((char *, int, struct open_file *));
+
+struct inst_command {
+ char *ic_cmd; /* command name */
+ char *ic_desc; /* command description */
+ void (*ic_func) __P((void)); /* handling function */
+} inst_commands[] = {
+ { "disklabel", "place partition map on disk", dsklabel },
+ { "miniroot", "place miniroot on disk", miniroot },
+ { "boot", "boot from miniroot", bootmini },
+ { "reset", "reset the system", resetsys },
+ { "help", "display command list", gethelp },
+};
+#define NCMDS (sizeof(inst_commands) / sizeof(inst_commands[0]))
+
+main()
+{
+ int i, currname = 0;
+
+ printf("\n>> NetBSD INSTALLATION HP9000/%s CPU\n",
+ getmachineid());
+ printf(">> $NetBSD: sys_inst.c,v 1.3 1995/10/04 07:24:33 thorpej Exp $\n");
+ gethelp();
+
+ for (;;) {
+ printf("sys_inst> ");
+ bzero(line, sizeof(line));
+ gets(line);
+ if (line[0] == '\n' || line[0] == '\0')
+ continue;
+
+ for (i = 0; i < NCMDS; ++i)
+ if (strcmp(line, inst_commands[i].ic_cmd) == 0) {
+ (*inst_commands[i].ic_func)();
+ break;
+ }
+
+
+ if (i == NCMDS)
+ printf("unknown command: %s\n", line);
+ }
+}
+
+void
+gethelp()
+{
+ int i;
+
+ printf(">> Available commands:\n");
+ for (i = 0; i < NCMDS; ++i)
+ printf(">> %s - %s\n", inst_commands[i].ic_cmd,
+ inst_commands[i].ic_desc);
+}
+
+/*
+ * Do all the steps necessary to place a disklabel on a disk.
+ * Note, this assumes 512 byte sectors.
+ */
+void
+dsklabel()
+{
+ struct disklabel *lp;
+ struct open_file *disk_ofp;
+ int dfd, error;
+ size_t xfersize;
+ char block[DEV_BSIZE], diskname[64];
+ extern struct open_file files[];
+
+ printf("
+You will be asked several questions about your disk, most of which
+require prior knowledge of the disk's geometry. There is no easy way
+for the system to provide this information for you. If you do not have
+this information, please consult your disk's manual or another
+informative source.\n\n");
+
+ /* Error message printed by opendisk() */
+ if (opendisk("Disk to label?", diskname, sizeof(diskname),
+ ('a' + RAW_PART), &dfd))
+ return;
+
+ disk_ofp = &files[dfd];
+
+ bzero(block, sizeof(block));
+ if (error = (*disk_ofp->f_dev->dv_strategy)(disk_ofp->f_devdata,
+ F_READ, LABELSECTOR, sizeof(block), block, &xfersize)) {
+ printf("cannot read disk %s, errno = %d\n", diskname, error);
+ return;
+ }
+
+ printf("Sucessfully read %d bytes from %s\n", xfersize, diskname);
+
+ lp = (struct disklabel *)((void *)(&block[LABELOFFSET]));
+
+ disklabel_loop:
+ bzero(line, sizeof(line));
+ printf("(z)ap, (e)dit, (s)how, (w)rite, (d)one > ");
+ gets(line);
+ if (line[0] == '\n' || line[0] == '\0')
+ goto disklabel_loop;
+
+ switch (line[0]) {
+ case 'z':
+ case 'Z': {
+ char zap[DEV_BSIZE];
+ bzero(zap, sizeof(zap));
+ (void)(*disk_ofp->f_dev->dv_strategy)(disk_ofp->f_devdata,
+ F_WRITE, LABELSECTOR, sizeof(zap), zap, &xfersize);
+ }
+ goto out;
+ /* NOTREACHED */
+
+ case 'e':
+ case 'E':
+ disklabel_edit(lp);
+ break;
+
+ case 's':
+ case 'S':
+ disklabel_show(lp);
+ break;
+
+ case 'w':
+ case 'W':
+ /*
+ * Error message will be displayed by disklabel_write()
+ */
+ if (disklabel_write(block, sizeof(block), disk_ofp))
+ goto out;
+ else
+ printf("Sucessfully wrote label to %s\n", diskname);
+ break;
+
+ case 'd':
+ case 'D':
+ goto out;
+ /* NOTREACHED */
+
+ default:
+ printf("unkown command: %s\n", line);
+ }
+
+ goto disklabel_loop;
+ /* NOTREACHED */
+
+ out:
+ /*
+ * Close disk. Marks disk `not alive' so that partition
+ * information will be reloaded upon next open.
+ */
+ (void)close(dfd);
+}
+
+#define GETNUM(out, num) \
+ printf((out), (num)); \
+ bzero(line, sizeof(line)); \
+ gets(line); \
+ if (line[0]) \
+ (num) = atoi(line);
+
+#define GETNUM2(out, num1, num2) \
+ printf((out), (num1), (num2)); \
+ bzero(line, sizeof(line)); \
+ gets(line); \
+ if (line[0]) \
+ (num2) = atoi(line);
+
+#define GETSTR(out, str) \
+ printf((out), (str)); \
+ bzero(line, sizeof(line)); \
+ gets(line); \
+ if (line[0]) \
+ strcpy((str), line);
+
+#define FLAGS(out, flag) \
+ printf((out), lp->d_flags & (flag) ? 'y' : 'n'); \
+ bzero(line, sizeof(line)); \
+ gets(line); \
+ if (line[0] == 'y' || line[0] == 'Y') \
+ lp->d_flags |= (flag); \
+ else \
+ lp->d_flags &= ~(flag);
+
+void
+disklabel_edit(lp)
+ struct disklabel *lp;
+{
+ int i;
+
+ printf("Select disk type. Valid types:\n");
+ for (i = 0; i < DKMAXTYPES; i++)
+ printf("%d %s\n", i, dktypenames[i]);
+ printf("\n");
+
+ GETNUM("Disk type (number)? [%d] ", lp->d_type);
+ GETSTR("Disk model name? [%s] ", lp->d_typename);
+ GETSTR("Disk pack name? [%s] ", lp->d_packname);
+ FLAGS("Bad sectoring? [%c] ", D_BADSECT);
+ FLAGS("Ecc? [%c] ", D_ECC);
+ FLAGS("Removable? [%c] ", D_REMOVABLE);
+
+ printf("\n");
+
+ GETNUM("Interleave? [%d] ", lp->d_interleave);
+ GETNUM("Rpm? [%d] ", lp->d_rpm);
+ GETNUM("Trackskew? [%d] ", lp->d_trackskew);
+ GETNUM("Cylinderskew? [%d] ", lp->d_cylskew);
+ GETNUM("Headswitch? [%d] ", lp->d_headswitch);
+ GETNUM("Track-to-track? [%d] ", lp->d_trkseek);
+ GETNUM("Drivedata 0? [%d] ", lp->d_drivedata[0]);
+ GETNUM("Drivedata 1? [%d] ", lp->d_drivedata[1]);
+ GETNUM("Drivedata 2? [%d] ", lp->d_drivedata[2]);
+ GETNUM("Drivedata 3? [%d] ", lp->d_drivedata[3]);
+ GETNUM("Drivedata 4? [%d] ", lp->d_drivedata[4]);
+
+ printf("\n");
+
+ GETNUM("Bytes/sector? [%d] ", lp->d_secsize);
+ GETNUM("Sectors/track? [%d] ", lp->d_nsectors);
+ GETNUM("Tracks/cylinder? [%d] ", lp->d_ntracks);
+ GETNUM("Sectors/cylinder? [%d] ", lp->d_secpercyl);
+ GETNUM("Cylinders? [%d] ", lp->d_ncylinders);
+
+ printf("
+Enter partition table. Note, sizes and offsets are in sectors.\n\n");
+
+ lp->d_npartitions = MAXPARTITIONS;
+ for (i = 0; i < lp->d_npartitions; ++i) {
+ GETNUM2("%c partition: offset? [%d] ", ('a' + i),
+ lp->d_partitions[i].p_offset);
+ GETNUM(" size? [%d] ", lp->d_partitions[i].p_size);
+ }
+
+ /* Perform magic. */
+ lp->d_magic = lp->d_magic2 = DISKMAGIC;
+
+ /* Calculate disklabel checksum. */
+ lp->d_checksum = 0;
+ lp->d_checksum = dkcksum(lp);
+}
+
+void
+disklabel_show(lp)
+ struct disklabel *lp;
+{
+ int i, npart;
+ struct partition *pp;
+
+ /*
+ * Check for valid disklabel.
+ */
+ if (lp->d_magic != DISKMAGIC || lp->d_magic2 != DISKMAGIC) {
+ printf("No disklabel to show.\n");
+ return;
+ }
+
+ if (lp->d_npartitions > MAXPARTITIONS || dkcksum(lp) != 0) {
+ printf("Corrupted disklabel.\n");
+ return;
+ }
+
+ printf("\ndisk type %d (%s), %s: %s%s%s\n", lp->d_type,
+ lp->d_type < DKMAXTYPES ? dktypenames[lp->d_type] :
+ dktypenames[0], lp->d_typename,
+ (lp->d_flags & D_REMOVABLE) ? " removable" : "",
+ (lp->d_flags & D_ECC) ? " ecc" : "",
+ (lp->d_flags & D_BADSECT) ? " badsect" : "");
+
+ printf("interleave %d, rpm %d, trackskew %d, cylinderskew %d\n",
+ lp->d_interleave, lp->d_rpm, lp->d_trackskew, lp->d_cylskew);
+
+ printf("headswitch %d, track-to-track %d, drivedata: %d %d %d %d %d\n",
+ lp->d_headswitch, lp->d_trkseek, lp->d_drivedata[0],
+ lp->d_drivedata[1], lp->d_drivedata[2], lp->d_drivedata[3],
+ lp->d_drivedata[4]);
+
+ printf("\nbytes/sector: %d\n", lp->d_secsize);
+ printf("sectors/track: %d\n", lp->d_nsectors);
+ printf("tracks/cylinder: %d\n", lp->d_ntracks);
+ printf("sectors/cylinder: %d\n", lp->d_secpercyl);
+ printf("cylinders: %d\n", lp->d_ncylinders);
+
+ printf("\n%d partitions:\n", lp->d_npartitions);
+ printf(" size offset\n");
+ pp = lp->d_partitions;
+ for (i = 0; i < lp->d_npartitions; i++) {
+ printf("%c: %d, %d\n", 97 + i, lp->d_partitions[i].p_size,
+ lp->d_partitions[i].p_offset);
+ }
+ printf("\n");
+}
+
+int
+disklabel_write(block, len, ofp)
+ char *block;
+ int len;
+ struct open_file *ofp;
+{
+ int error = 0;
+ size_t xfersize;
+
+ if (error = (*ofp->f_dev->dv_strategy)(ofp->f_devdata, F_WRITE,
+ LABELSECTOR, len, block, &xfersize))
+ printf("cannot write disklabel, errno = %d\n", error);
+
+ return (error);
+}
+
+int
+opendisk(question, diskname, len, partition, fdp)
+ char *question, *diskname;
+ int len;
+ char partition;
+ int *fdp;
+{
+ char fulldiskname[64], *filename;
+ int i, error = 0;
+
+ getdiskname:
+ printf("%s ", question);
+ bzero(diskname, len);
+ bzero(fulldiskname, sizeof(fulldiskname));
+ gets(diskname);
+ if (diskname[0] == '\n' || diskname[0] == '\0')
+ goto getdiskname;
+
+ /*
+ * devopen() is picky. Make sure it gets the sort of string it
+ * wants.
+ */
+ bcopy(diskname, fulldiskname,
+ len < sizeof(fulldiskname) ? len : sizeof(fulldiskname));
+ for (i = 0; fulldiskname[i + 1] != '\0'; ++i)
+ /* Nothing. */ ;
+ if (fulldiskname[i] < '0' || fulldiskname[i] > '9') {
+ printf("invalid disk name %s\n", diskname);
+ goto getdiskname;
+ }
+ fulldiskname[++i] = partition; fulldiskname[++i] = ':';
+
+ /*
+ * We always open for writing.
+ */
+ if ((*fdp = open(fulldiskname, 1)) < 0)
+ printf("cannot open %s\n", diskname);
+
+ return (errno);
+}
+
+/*
+ * Copy a miniroot image from an NFS server or tape to the `b' partition
+ * of the specified disk. Note, this assumes 512 byte sectors.
+ */
+void
+miniroot()
+{
+ int sfd, dfd, i, nblks;
+ char diskname[64], minirootname[128];
+ char block[DEV_BSIZE];
+ struct stat st;
+ size_t xfersize;
+ struct open_file *disk_ofp;
+ extern struct open_file files[];
+
+ /* Error message printed by opendisk() */
+ if (opendisk("Disk for miniroot?", diskname, sizeof(diskname),
+ 'b', &dfd))
+ return;
+
+ disk_ofp = &files[dfd];
+
+ /*
+ * XXX We only support NFS for now.
+ */
+ getsource:
+ printf("Source? (N)FS, (t)ape, (d)one > ");
+ bzero(line, sizeof(line));
+ gets(line);
+ if (line[0] == '\0')
+ goto getsource;
+
+ switch (line[0]) {
+ case 'n':
+ case 'N':
+ name_of_miniroot:
+ printf("Name of miniroot file? ");
+ bzero(line, sizeof(line));
+ bzero(minirootname, sizeof(minirootname));
+ gets(line);
+ if (line[0] == '\0')
+ goto name_of_miniroot;
+ (void)strcat(minirootname, "le0a:");
+ (void)strcat(minirootname, line);
+ if ((sfd = open(minirootname, 0)) < 0) {
+ printf("can't open %s\n", line);
+ return;
+ }
+ break;
+
+ case 't':
+ case 'T':
+ printf("Sorry, no tape support yet.\n");
+ return;
+
+ case 'd':
+ case 'D':
+ return;
+
+ default:
+ printf("Unknown source: %s\n", line);
+ goto getsource;
+ }
+
+ /*
+ * Have file descriptor, will copy.
+ */
+ if (fstat(sfd, &st) < 0) {
+ printf("can't stat %s\n", line);
+ goto done;
+ }
+
+ nblks = (int)(st.st_size / sizeof(block));
+ printf("Copying %d blocks from %s to %s\n", nblks, line, diskname);
+
+ for (i = 0; i < nblks; ++i) {
+ if (read(sfd, block, sizeof(block)) != sizeof(block)) {
+ printf("Short read, errno = %d\n", errno);
+ goto done;
+ }
+ if ((*disk_ofp->f_dev->dv_strategy)(disk_ofp->f_devdata,
+ F_WRITE, i, sizeof(block), block, &xfersize) ||
+ xfersize != sizeof(block)) {
+ printf("Bad write, errno = %d\n", errno);
+ goto done;
+ }
+ }
+
+ printf("Successfully copied miniroot image.\n");
+ done:
+ close(sfd);
+ close(dfd);
+}
+
+/*
+ * Boot the kernel from the miniroot image into single-user.
+ */
+void
+bootmini()
+{
+ char diskname[64], bootname[64];
+ int i;
+
+ getdiskname:
+ printf("Disk to boot from? ");
+ bzero(diskname, sizeof(diskname));
+ bzero(bootname, sizeof(bootname));
+ gets(diskname);
+ if (diskname[0] == '\n' || diskname[0] == '\0')
+ goto getdiskname;
+
+ /*
+ * devopen() is picky. Make sure it gets the sort of string it
+ * wants.
+ */
+ (void)strcat(bootname, diskname);
+ for (i = 0; bootname[i + 1] != '\0'; ++i)
+ /* Nothing. */ ;
+ if (bootname[i] < '0' || bootname[i] > '9') {
+ printf("invalid disk name %s\n", diskname);
+ goto getdiskname;
+ }
+ bootname[++i] = 'b'; bootname[++i] = ':';
+ (void)strcat(bootname, kernel_name);
+
+ howto = RB_SINGLE; /* _Always_ */
+
+ printf("booting: %s -s\n", bootname);
+ exec(bootname, lowram, howto);
+ printf("boot: %s\n", strerror(errno));
+}
+
+/*
+ * Reset the system.
+ */
+void
+resetsys()
+{
+
+ call_req_reboot();
+ printf("panic: can't reboot, halting\n");
+ asm("stop #0x2700");
+}
+
+void
+machdep_start(entry, howto, loadaddr, ssym, esym)
+ char *entry;
+ int howto;
+ char *loadaddr;
+ char *ssym, *esym;
+{
+
+ asm("movl %0,d7" : : "m" (howto));
+ asm("movl %0,d6" : : "m" (opendev));
+ asm("movl %0,d5" : : "m" (cons_scode));
+ asm("movl %0,a5" : : "a" (loadaddr));
+ asm("movl %0,a4" : : "a" (esym));
+ (*((int (*)())entry))();
+}
diff --git a/sys/arch/hp300/stand/tgets.c b/sys/arch/hp300/stand/tgets.c
new file mode 100644
index 00000000000..1a814f0aa27
--- /dev/null
+++ b/sys/arch/hp300/stand/tgets.c
@@ -0,0 +1,92 @@
+/* $NetBSD: tgets.c,v 1.4 1994/10/26 07:28:05 cgd Exp $ */
+
+/*-
+ * Copyright (c) 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * @(#)gets.c 8.1 (Berkeley) 6/11/93
+ */
+
+int
+tgets(buf)
+ char *buf;
+{
+ register int c;
+ int i;
+ register char *lp = buf;
+
+ for (i = 240000; i > 0; i--) {
+ c = tgetchar() & 0177;
+ if (c) {
+ for (;;) {
+ switch (c) {
+ case '\n':
+ case '\r':
+ *lp = '\0';
+ putchar('\n');
+ return (1);
+ case '\b':
+ case '\177':
+ if (lp > buf) {
+ lp--;
+ putchar('\b');
+ putchar(' ');
+ putchar('\b');
+ }
+ break;
+ case '#':
+ if (lp > buf)
+ --lp;
+ break;
+ case 'r'&037: {
+ register char *p;
+
+ putchar('\n');
+ for (p = buf; p < lp; ++p)
+ putchar(*p);
+ break;
+ }
+ case '@':
+ case 'u'&037:
+ case 'w'&037:
+ lp = buf;
+ putchar('\n');
+ break;
+ default:
+ *lp++ = c;
+ putchar(c);
+ }
+ c = getchar() & 0177;
+ }
+ }
+ }
+ return (0);
+}
diff --git a/sys/arch/hp300/stand/volhdr.h b/sys/arch/hp300/stand/volhdr.h
new file mode 100644
index 00000000000..7f30df058aa
--- /dev/null
+++ b/sys/arch/hp300/stand/volhdr.h
@@ -0,0 +1,81 @@
+/* $NetBSD: volhdr.h,v 1.4 1994/10/26 07:28:08 cgd Exp $ */
+
+/*
+ * Copyright (c) 1988 University of Utah.
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * @(#)volhdr.h 8.1 (Berkeley) 6/10/93
+ */
+
+/*
+ * vohldr.h: volume header for "LIF" format volumes
+ */
+
+struct lifvol {
+ short vol_id;
+ char vol_label[6];
+ int vol_addr;
+ short vol_oct;
+ short vol_dummy;
+ int vol_dirsize;
+ short vol_version;
+ short vol_zero;
+ int vol_huh1;
+ int vol_huh2;
+ int vol_length;
+};
+
+struct lifdir {
+ char dir_name[10];
+ short dir_type;
+ int dir_addr;
+ int dir_length;
+ char dir_toc[6];
+ short dir_flag;
+ int dir_exec;
+};
+
+/* load header for boot rom */
+struct load {
+ int address;
+ int count;
+};
+
+#define VOL_ID -32768
+#define VOL_OCT 4096
+#define DIR_TYPE -5822
+#define DIR_FLAG 0x8001 /* dont ask me! */
+#define SECTSIZE 256