From 97e83d727b4d8c753bf7497b8a6ce4748ceaf4e8 Mon Sep 17 00:00:00 2001 From: mickey Date: Thu, 25 Apr 1996 06:36:19 +0000 Subject: [PATCH] sync w/ Net 960424 --- sys/arch/hp300/conf/GENERIC | 3 +- sys/arch/hp300/conf/Makefile.hp300 | 175 +++--- sys/arch/hp300/conf/files.hp300.oldconf | 9 +- sys/arch/hp300/dev/ac.c | 11 +- sys/arch/hp300/dev/ct.c | 11 +- sys/arch/hp300/dev/ctreg.h | 11 +- sys/arch/hp300/dev/dca.c | 168 +++--- sys/arch/hp300/dev/dcareg.h | 6 +- sys/arch/hp300/dev/dcm.c | 210 ++++---- sys/arch/hp300/dev/dcmreg.h | 9 +- sys/arch/hp300/dev/device.h | 4 +- sys/arch/hp300/dev/dma.c | 12 +- sys/arch/hp300/dev/fhpib.c | 18 +- sys/arch/hp300/dev/grf.c | 129 +++-- sys/arch/hp300/dev/grf_conf.c | 87 +-- sys/arch/hp300/dev/grf_dv.c | 478 +++++++++++++++-- sys/arch/hp300/dev/grf_gb.c | 462 ++++++++++++++-- sys/arch/hp300/dev/grf_hy.c | 682 ++++++++++++++++++++++-- sys/arch/hp300/dev/grf_machdep.c | 133 ++--- sys/arch/hp300/dev/grf_rb.c | 469 ++++++++++++++-- sys/arch/hp300/dev/grf_tc.c | 551 +++++++++++++++++-- sys/arch/hp300/dev/grfvar.h | 36 +- sys/arch/hp300/dev/hil.c | 22 +- sys/arch/hp300/dev/hpib.c | 19 +- sys/arch/hp300/dev/hpibvar.h | 32 +- sys/arch/hp300/dev/if_le.c | 32 +- sys/arch/hp300/dev/ite.c | 317 +++++------ sys/arch/hp300/dev/ite_dv.c | 262 --------- sys/arch/hp300/dev/ite_gb.c | 246 --------- sys/arch/hp300/dev/ite_hy.c | 471 ---------------- sys/arch/hp300/dev/ite_rb.c | 261 --------- sys/arch/hp300/dev/ite_subr.c | 15 +- sys/arch/hp300/dev/ite_tc.c | 270 ---------- sys/arch/hp300/dev/itevar.h | 53 +- sys/arch/hp300/dev/mt.c | 28 +- sys/arch/hp300/dev/nhpib.c | 18 +- sys/arch/hp300/dev/ppi.c | 3 +- sys/arch/hp300/dev/rd.c | 12 +- sys/arch/hp300/dev/rdreg.h | 11 +- sys/arch/hp300/dev/scsi.c | 26 +- sys/arch/hp300/dev/sd.c | 10 +- sys/arch/hp300/dev/st.c | 11 +- sys/arch/hp300/hp300/Locore.c | 36 +- sys/arch/hp300/hp300/autoconf.c | 161 +++++- sys/arch/hp300/hp300/conf.c | 45 +- sys/arch/hp300/hp300/disksubr.c | 27 +- sys/arch/hp300/hp300/genassym.c | 8 +- sys/arch/hp300/hp300/hpux_machdep.c | 2 +- sys/arch/hp300/hp300/isr.h | 77 ++- sys/arch/hp300/hp300/locore.s | 99 ++-- sys/arch/hp300/hp300/machdep.c | 128 ++--- sys/arch/hp300/hp300/vectors.s | 14 +- sys/arch/hp300/hp300/vm_machdep.c | 12 +- sys/arch/hp300/include/hpux_machdep.h | 40 +- sys/arch/hp300/include/param.h | 4 +- sys/arch/hp300/stand/dca.c | 8 +- sys/arch/hp300/stand/dcm.c | 10 +- sys/arch/hp300/stand/ite.c | 101 ++-- sys/arch/hp300/stand/ite_dv.c | 25 +- sys/arch/hp300/stand/ite_gb.c | 25 +- sys/arch/hp300/stand/ite_hy.c | 29 +- sys/arch/hp300/stand/ite_rb.c | 25 +- sys/arch/hp300/stand/ite_subr.c | 13 +- sys/arch/hp300/stand/ite_tc.c | 25 +- 64 files changed, 3814 insertions(+), 2893 deletions(-) diff --git a/sys/arch/hp300/conf/GENERIC b/sys/arch/hp300/conf/GENERIC index f0d3f172a40..b0c61cc733d 100644 --- a/sys/arch/hp300/conf/GENERIC +++ b/sys/arch/hp300/conf/GENERIC @@ -1,4 +1,4 @@ -# $NetBSD: GENERIC,v 1.8 1995/12/29 17:12:48 thorpej Exp $ +# $NetBSD: GENERIC,v 1.9 1996/02/24 00:54:53 thorpej Exp $ # # Generic kernel - one size fits all. # @@ -55,6 +55,7 @@ options FPSP # floating point interface for 68040 options USELEDS # make the lights twinkle options COMPAT_NOLABEL # defaults for unlabeled disks #options PANICBUTTON # two fast s on HIL dump kernel +#options CONSCODE="9" # force console at this select code # # HP-UX binary compatibility. diff --git a/sys/arch/hp300/conf/Makefile.hp300 b/sys/arch/hp300/conf/Makefile.hp300 index 066f6bc6200..36cfc3ce640 100644 --- a/sys/arch/hp300/conf/Makefile.hp300 +++ b/sys/arch/hp300/conf/Makefile.hp300 @@ -1,7 +1,6 @@ -# $NetBSD: Makefile.hp300,v 1.28 1995/10/22 06:05:21 thorpej Exp $ +# $OpenBSD: Makefile.hp300,v 1.6 1996/04/25 06:36:20 mickey Exp $ +# $NetBSD: Makefile.hp300,v 1.38 1996/03/01 17:03:17 scottr Exp $ -# @(#)Makefile.hp300 8.2 (Berkeley) 1/23/94 -# # Makefile for NetBSD # # This makefile is constructed from a machine description: @@ -9,7 +8,7 @@ # Most changes should be made in the machine description # /sys/arch/hp300/conf/``machineid'' # after which you should do -# config machineid +# config machineid # Machine generic makefile changes should be made in # /sys/arch/hp300/conf/Makefile.hp300 # after which config should be rerun for all machines of that type. @@ -20,23 +19,25 @@ # -DTRACE compile in kernel tracing hooks # -DQUOTA compile in file system quotas +# DEBUG is set to -g if debugging. +# PROF is set to -pg if profiling. -# DEBUG is set to -g by config if debugging is requested (config -g). -# PROF is set to -pg by config if profiling is requested (config -p). -AS= as ${DEBUG} -AWK= awk -CC= cc ${DEBUG} -CPP= cpp -LD= ld -TOUCH= touch -f -c +AS?= as +CC?= cc +CPP?= cpp +LD?= ld +STRIP?= strip -d +TOUCH?= touch -f -c # source tree is located via $S relative to the compilation directory S= ../../../.. HP300= ../.. -INCLUDES= -I. -I$S/arch -I$S -I$S/sys -COPTS= ${INCLUDES} ${IDENT} -D_KERNEL -Dmc68020 -Dhp300 -DFPCOPROC -CFLAGS= -O6 -Werror ${COPTS} +INCLUDES= -I. -I$S/arch -I$S +CPPFLAGS= ${INCLUDES} ${IDENT} -D_KERNEL -Dmc68020 -Dhp300 -DFPCOPROC +CFLAGS= ${DEBUG} -O2 -Werror -msoft-float +AFLAGS= -x assembler-with-cpp -traditional-cpp -D_LOCORE +LINKFLAGS= -n -Ttext 0 -e start ### find out what to use for libkern .include "$S/lib/libkern/Makefile.inc" @@ -62,111 +63,119 @@ LIBCOMPAT= ${COMPATLIB_PROF} # capitalized (e.g. C for a .c file), and CONFIG_DEP is _C if the file # is marked as config-dependent. -NORMAL_C= ${CC} -c ${CFLAGS} ${PROF} $< -NORMAL_C_C= ${CC} -c ${CFLAGS} ${PROF} ${PARAM} $< - -DRIVER_C= ${CC} -c ${CFLAGS} ${PROF} $< -DRIVER_C_C= ${CC} -c ${CFLAGS} ${PROF} ${PARAM} $< +NORMAL_C= ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $< +NORMAL_C_C= ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} ${PARAM} -c $< -PROFILE_C= ${CC} -S -c ${COPTS} $<; \ - sed -e s/_mcount/mcount/ -e s/subrmcount/subr_mcount/ <$*.s | \ - ${AS} -o $@; \ - rm -f $*.s +DRIVER_C= ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $< +DRIVER_C_C= ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} ${PARAM} -c $< -NORMAL_S= ${CPP} ${COPTS} $< | ${AS} -o $@ -NORMAL_S_C= ${CPP} ${COPTS} ${PARAM} $< | ${AS} -o $@ +NORMAL_S= ${CC} ${AFLAGS} ${CPPFLAGS} -c $< +NORMAL_S_C= ${CC} ${AFLAGS} ${CPPFLAGS} ${PARAM} -c $< %OBJS %CFILES +#%SFILES + # load lines for config "xxx" will be emitted as: # xxx: ${SYSTEM_DEP} swapxxx.o # ${SYSTEM_LD_HEAD} # ${SYSTEM_LD} swapxxx.o # ${SYSTEM_LD_TAIL} -SYSTEM_OBJ= locore.o ${FPSP} ${OBJS} param.o ioconf.o \ - ${LIBKERN} ${LIBCOMPAT} +SYSTEM_OBJ= locore.o ${FPSP} \ + param.o ioconf.o ${OBJS} ${LIBKERN} ${LIBCOMPAT} SYSTEM_DEP= Makefile ${SYSTEM_OBJ} -SYSTEM_LD_HEAD= rm -f $@ -SYSTEM_LD= -@if [ X${DEBUG} = X-g ]; \ - then strip=-X; \ - else strip=-x; \ - fi; \ - echo ${LD} $$strip -n -T 0 -o $@ -e start '$${SYSTEM_OBJ}' vers.o; \ - ${LD} $$strip -n -T 0 -o $@ -e start ${SYSTEM_OBJ} vers.o -SYSTEM_LD_TAIL= @size $@; chmod 755 $@; \ - [ X${DEBUG} = X-g ] && { \ +SYSTEM_LD_HEAD= @rm -f $@ +SYSTEM_LD= @echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \ + ${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o +SYSTEM_LD_TAIL= @size $@; chmod 755 $@ + +DEBUG?= +.if ${DEBUG} == "-g" +LINKFLAGS+= -X +SYSTEM_LD_TAIL+=; \ echo cp $@ $@.gdb; rm -f $@.gdb; cp $@ $@.gdb; \ - echo strip -d $@; strip -d $@; } || true + echo ${STRIP} $@; ${STRIP} $@ +.else +LINKFLAGS+= -x +.endif %LOAD -vers.o: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP} - sh $S/conf/newvers.sh - ${CC} ${CFLAGS} -c vers.c +assym.h: genassym + ./genassym >assym.h -clean:: - rm -f eddep *netbsd netbsd.gdb tags *.o locore.i \ - [a-z]*.s [Ee]rrs linterrs makelinks genassym +genassym: genassym.o + ${CC} -o $@ genassym.o -lint: /tmp param.c - @lint -hbxn -DGENERIC -Dvolatile= ${COPTS} ${PARAM} -UKGDB \ - ${HP300}/hp300/Locore.c ${CFILES} ${HP300}/hp300/swapgeneric.c \ - ioconf.c param.c | \ - grep -v 'struct/union .* never defined' | \ - grep -v 'possible pointer alignment problem' +genassym.o: ${HP300}/hp300/genassym.c + ${NORMAL_C_C} -locore.o: assym.s ${HP300}/hp300/vectors.s ${HP300}/hp300/locore.s -locore.o: ${HP300}/include/trap.h ${HP300}/include/psl.h ${HP300}/include/pte.h -locore.o: ${HP300}/include/cpu.h - ${CPP} -DLOCORE ${COPTS} ${HP300}/hp300/locore.s | ${AS} -o locore.o +param.c: $S/conf/param.c + rm -f param.c + cp $S/conf/param.c . -# the following is necessary because autoconf.o depends on #if GENERIC -autoconf.o: Makefile +param.o: param.c Makefile + ${NORMAL_C_C} -# the following are necessary because the files depend on the types of -# hp cpu's included in the system configuration -machdep.o sys_machdep.o pmap.o pmap_bootstrap.o trap.o dma.o: Makefile +ioconf.o: ioconf.c + ${NORMAL_C} -# depend on network or filesystem configuration -uipc_domain.o uipc_proto.o vfs_conf.o locore.o: Makefile -if_tun.o if_loop.o if_ethersubr.o: Makefile -in_proto.o: Makefile +vers.o: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP} + sh $S/conf/newvers.sh + ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c -# depend on maxusers -assym.s: Makefile -assym.s: genassym - ./genassym >assym.s +clean:: + rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \ + [Ee]rrs linterrs makelinks genassym genassym.o assym.h -genassym: ${HP300}/hp300/genassym.c Makefile - ${CC} ${INCLUDES} ${IDENT} ${PARAM} -Dmc68020 -Dhp300 -o genassym \ - ${HP300}/hp300/genassym.c +lint: + @lint -hbxncez -DGENERIC -Dvolatile= ${CPPFLAGS} ${PARAM} -UKGDB \ + ${HP300}/hp300/Locore.c ${CFILES} ${HP300}/hp300/swapgeneric.c \ + ioconf.c param.c | \ + grep -v 'static function .* unused' -depend: assym.s param.c - mkdep ${COPTS} ${CFILES} ioconf.c param.c - mkdep -a -p ${INCLUDES} ${IDENT} ${PARAM} ${HP300}/hp300/genassym.c +tags: + @echo "see $S/kern/Makefile for tags" links: egrep '#if' ${CFILES} | sed -f $S/conf/defines | \ sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \ sort -u | comm -23 - dontlink | \ - sed 's,../.*/\(.*.o\),rm -f \1;ln -s ../GENERIC/\1 \1,' > makelinks + sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks sh makelinks && rm -f dontlink -tags: - @echo "see $S/kern/Makefile for tags" +SRCS= ${HP300}/hp300/locore.s \ + param.c ioconf.c ${CFILES} ${SFILES} +depend: .depend +.depend: ${SRCS} assym.h param.c + mkdep ${AFLAGS} ${CPPFLAGS} ${HP300}/hp300/locore.s + mkdep -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES} + -if test -n "${SFILES}"; then \ + mkdep -a ${AFLAGS} ${CPPFLAGS} ${SFILES}; \ + fi + mkdep -a ${CFLAGS} ${CPPFLAGS} ${PARAM} ${HP300}/hp300/genassym.c + + +# depend on root or device configuration +autoconf.o conf.o: Makefile + +# depend on network or filesystem configuration +uipc_domain.o uipc_proto.o vfs_conf.o: Makefile +if_tun.o if_loop.o if_ethersubr.o: Makefile +in_proto.o: Makefile -ioconf.o: ioconf.c - ${CC} -c ${CFLAGS} ioconf.c +# depend on maxusers +genassym.o machdep.o: Makefile -param.c: $S/conf/param.c - rm -f param.c - cp $S/conf/param.c . +# depend on CPU configuration +dma.o genassym.o hpux_machdep.o locore.o machdep.o pmap.o pmap_boostrap.o sys_machdep.o trap.o: Makefile -param.o: param.c Makefile - ${CC} -c ${CFLAGS} ${PARAM} param.c + +locore.o: ${HP300}/hp300/locore.s assym.h + ${NORMAL_S} %RULES diff --git a/sys/arch/hp300/conf/files.hp300.oldconf b/sys/arch/hp300/conf/files.hp300.oldconf index cb1837f91c8..a393f505edd 100644 --- a/sys/arch/hp300/conf/files.hp300.oldconf +++ b/sys/arch/hp300/conf/files.hp300.oldconf @@ -1,4 +1,4 @@ -# $NetBSD: files.hp300.oldconf,v 1.22 1996/01/08 03:27:36 thorpej Exp $ +# $NetBSD: files.hp300.oldconf,v 1.25 1996/02/24 00:54:55 thorpej Exp $ # arch/hp300/hp300/autoconf.c standard arch/hp300/hp300/clock.c standard @@ -7,6 +7,7 @@ arch/hp300/hp300/dkbad.c standard arch/hp300/hp300/kgdb_glue.c optional kgdb compile-with "${NORMAL_C} -fno-defer-pop" arch/hp300/hp300/kgdb_stub.c optional kgdb arch/hp300/hp300/machdep.c standard config-dependent +arch/hp300/hp300/isr.c standard arch/hp300/hp300/mem.c standard arch/hp300/hp300/pmap.c standard arch/hp300/hp300/pmap_bootstrap.c standard @@ -21,11 +22,6 @@ arch/hp300/dev/grf_hy.c optional grf needs-count # XXX? d-d? arch/hp300/dev/grf_machdep.c optional grf arch/hp300/dev/grf_rb.c optional grf needs-count # XXX? d-d? arch/hp300/dev/grf_tc.c optional grf needs-count # XXX? d-d? -arch/hp300/dev/ite_dv.c optional ite needs-count # XXX? d-d? -arch/hp300/dev/ite_gb.c optional ite needs-count # XXX? d-d? -arch/hp300/dev/ite_hy.c optional ite needs-count # XXX? d-d? -arch/hp300/dev/ite_rb.c optional ite needs-count # XXX? d-d? -arch/hp300/dev/ite_tc.c optional ite needs-count # XXX? d-d? arch/hp300/dev/dcm.c optional dcm device-driver arch/hp300/dev/if_le.c optional le device-driver arch/hp300/dev/dma.c standard @@ -49,6 +45,7 @@ arch/hp300/dev/hil_keymaps.c standard arch/hp300/dev/ite.c optional ite needs-count # XXX? d-d? arch/hp300/dev/ite_subr.c optional ite needs-count # XXX? d-d? arch/m68k/m68k/copy.s standard +arch/m68k/m68k/db_memrw.c optional ddb dev/cons.c standard dev/cninit.c standard thisisfor_in_proto.c optional hy diff --git a/sys/arch/hp300/dev/ac.c b/sys/arch/hp300/dev/ac.c index 89e9241d213..c90eb0875ae 100644 --- a/sys/arch/hp300/dev/ac.c +++ b/sys/arch/hp300/dev/ac.c @@ -1,4 +1,4 @@ -/* $NetBSD: ac.c,v 1.3 1995/12/02 18:21:49 thorpej Exp $ */ +/* $NetBSD: ac.c,v 1.4 1996/02/14 02:43:54 thorpej Exp $ */ /* * Copyright (c) 1991 University of Utah. @@ -118,6 +118,7 @@ acattach(hd) (void)acident(sc, hd, 1); /* XXX Ick. */ + sc->sc_dq.dq_softc = sc; sc->sc_dq.dq_unit = unit; sc->sc_dq.dq_ctlr = hd->hp_ctlr; sc->sc_dq.dq_slave = hd->hp_slave; @@ -422,13 +423,15 @@ acgo(unit) } } -acintr(unit, stat) - int unit, stat; +acintr(arg, stat) + void *arg; + int stat; { - register struct ac_softc *sc = &ac_softc[unit]; + register struct ac_softc *sc = arg; register struct buf *bp = sc->sc_bp; u_char sensebuf[78]; struct scsi_xsense *sp; + int unit = sc->sc_hd->hp_unit; #ifdef DEBUG if (ac_debug & ACD_FOLLOW) diff --git a/sys/arch/hp300/dev/ct.c b/sys/arch/hp300/dev/ct.c index 06e30357198..374a66222af 100644 --- a/sys/arch/hp300/dev/ct.c +++ b/sys/arch/hp300/dev/ct.c @@ -1,4 +1,4 @@ -/* $NetBSD: ct.c,v 1.14 1996/01/23 00:28:09 scottr Exp $ */ +/* $NetBSD: ct.c,v 1.15 1996/02/14 02:44:02 thorpej Exp $ */ /* * Copyright (c) 1982, 1990, 1993 @@ -161,6 +161,7 @@ ctattach(hd) (void)ctident(sc, hd, 1); /* XXX Ick. */ ctreset(sc, hd); + sc->sc_dq.dq_softc = sc; sc->sc_dq.dq_ctlr = hd->hp_ctlr; sc->sc_dq.dq_unit = hd->hp_unit; sc->sc_dq.dq_slave = hd->hp_slave; @@ -635,12 +636,14 @@ cteof(sc, bp) #endif } -ctintr(unit) - register int unit; +int +ctintr(arg) + void *arg; { - register struct ct_softc *sc = &ct_softc[unit]; + register struct ct_softc *sc = arg; register struct buf *bp, *dp; u_char stat; + int unit = sc->sc_hd->hp_unit; bp = cttab[unit].b_actf; if (bp == NULL) { diff --git a/sys/arch/hp300/dev/ctreg.h b/sys/arch/hp300/dev/ctreg.h index a95d9fabc26..42b93735620 100644 --- a/sys/arch/hp300/dev/ctreg.h +++ b/sys/arch/hp300/dev/ctreg.h @@ -1,4 +1,4 @@ -/* $NetBSD: ctreg.h,v 1.5 1995/12/31 04:11:42 thorpej Exp $ */ +/* $NetBSD: ctreg.h,v 1.6 1996/02/09 18:00:35 scottr Exp $ */ /* * Copyright (c) 1982, 1990, 1993 @@ -165,14 +165,7 @@ struct ct_describe { #define C_SSM 0x3e #define C_WFM 0x49 #define C_UNLOAD 0x4a -/* - * XXX XXX XXX THIS IS SUPPOSED TO FIT IN A 1-BYTE SPACE?! - */ -#if 0 -#define C_REL 0x140 -#else -#define C_REL 0x40 /* what ended up happening */ -#endif +#define C_REL 0xc0 #define C_CMD 0x05 #define C_EXEC 0x0e diff --git a/sys/arch/hp300/dev/dca.c b/sys/arch/hp300/dev/dca.c index 7d5eecc6f5d..1eeaf465165 100644 --- a/sys/arch/hp300/dev/dca.c +++ b/sys/arch/hp300/dev/dca.c @@ -1,7 +1,7 @@ -/* $NetBSD: dca.c,v 1.19 1995/12/31 00:27:16 thorpej Exp $ */ +/* $NetBSD: dca.c,v 1.23 1996/03/03 16:48:52 thorpej Exp $ */ /* - * Copyright (c) 1995 Jason R. Thorpe. All rights reserved. + * Copyright (c) 1995, 1996 Jason R. Thorpe. All rights reserved. * Copyright (c) 1982, 1986, 1990, 1993 * The Regents of the University of California. All rights reserved. * @@ -62,6 +62,7 @@ #include #include +#include #include #include @@ -80,7 +81,6 @@ struct dca_softc { struct hp_device *sc_hd; /* device info */ struct dcadevice *sc_dca; /* pointer to hardware */ struct tty *sc_tty; /* our tty instance */ - struct isr sc_isr; /* interrupt handler */ int sc_oflows; /* overflow counter */ short sc_flags; /* state flags */ @@ -90,28 +90,22 @@ struct dca_softc { #define DCA_ACTIVE 0x0001 /* indicates live unit */ #define DCA_SOFTCAR 0x0002 /* indicates soft-carrier */ #define DCA_HASFIFO 0x0004 /* indicates unit has FIFO */ +#define DCA_ISCONSOLE 0x0008 /* indicates unit is console */ } dca_softc[NDCA]; void dcastart(); -int dcaparam(), dcaintr(); +int dcaparam(); +int dcaintr __P((void *)); int ndca = NDCA; int dcadefaultrate = TTYDEF_SPEED; int dcamajor; -int dcafastservice; /* - * Stuff for DCA console support. This could probably be done a little - * better. + * Stuff for DCA console support. */ static struct dcadevice *dca_cn = NULL; /* pointer to hardware */ -static int dca_lastcnpri = CN_DEAD; /* XXX last priority */ static int dcaconsinit; /* has been initialized */ -#ifdef DCACONSOLE -static int dcaconsole = DCACONSOLE; -#else -static int dcaconsole = -1; -#endif struct speedtab dcaspeedtab[] = { 0, 0, @@ -179,9 +173,17 @@ dcaattach(hd) struct dcadevice *dca = (struct dcadevice *)hd->hp_addr; struct dca_softc *sc = &dca_softc[unit]; - if (unit == dcaconsole) + if (hd->hp_args->hw_sc == conscode) { + sc->sc_flags |= DCA_ISCONSOLE; DELAY(100000); + /* + * We didn't know which unit this would be during + * the console probe, so we have to fixup cn_dev here. + */ + cn_tab->cn_dev = makedev(dcamajor, unit); + } + dca->dca_reset = 0xFF; DELAY(100); @@ -194,10 +196,8 @@ dcaattach(hd) sc->sc_dca = dca; /* Establish interrupt handler. */ - sc->sc_isr.isr_ipl = hd->hp_ipl; - sc->sc_isr.isr_arg = unit; - sc->sc_isr.isr_intr = dcaintr; - isrlink(&sc->sc_isr); + isrlink(dcaintr, sc, hd->hp_ipl, + (sc->sc_flags & DCA_HASFIFO) ? ISRPRI_TTY : ISRPRI_TTYNOBUF); sc->sc_flags |= DCA_ACTIVE; if (hd->hp_flags) @@ -210,7 +210,7 @@ dcaattach(hd) * Need to reset baud rate, etc. of next print so reset dcaconsinit. * Also make sure console is always "hardwired." */ - if (unit == dcaconsole) { + if (sc->sc_flags & DCA_ISCONSOLE) { dcaconsinit = 0; sc->sc_flags |= DCA_SOFTCAR; printf(": console, "); @@ -224,7 +224,7 @@ dcaattach(hd) #ifdef KGDB if (kgdb_dev == makedev(dcamajor, unit)) { - if (dcaconsole == unit) + if (sc->sc_flags & DCA_ISCONSOLE) kgdb_dev = NODEV; /* can't debug over console port */ else { dcainit(dca, kgdb_rate); @@ -335,13 +335,6 @@ dcaopen(dev, flag, mode, p) if (error == 0) error = (*linesw[tp->t_line].l_open)(dev, tp); - /* - * XXX hack to speed up unbuffered builtin port. - * If dca_fastservice is set, a level 5 interrupt - * will be directed to dcaintr first. - */ - if (error == 0 && unit == 0 && (sc->sc_flags & DCA_HASFIFO) == 0) - dcafastservice = 1; return (error); } @@ -361,9 +354,6 @@ dcaclose(dev, flag, mode, p) unit = DCAUNIT(dev); - if (unit == 0) - dcafastservice = 0; - sc = &dca_softc[unit]; dca = sc->sc_dca; tp = sc->sc_tty; @@ -433,10 +423,11 @@ dcatty(dev) } int -dcaintr(unit) - register int unit; +dcaintr(arg) + void *arg; { - struct dca_softc *sc = &dca_softc[unit]; + struct dca_softc *sc = arg; + int unit = sc->sc_hd->hp_unit; register struct dcadevice *dca = sc->sc_dca; register struct tty *tp = sc->sc_tty; register u_char code; @@ -665,7 +656,8 @@ dcaioctl(dev, cmd, data, flag, p) userbits = *(int *)data; - if ((userbits & TIOCFLAG_SOFTCAR) || (unit == dcaconsole)) + if ((userbits & TIOCFLAG_SOFTCAR) || + (sc->sc_flags & DCA_ISCONSOLE)) sc->sc_flags |= DCA_SOFTCAR; if (userbits & TIOCFLAG_CLOCAL) @@ -888,76 +880,96 @@ dcainit(dca, rate) * Following are all routines needed for DCA to act as console */ -void -dcacnprobe(cp) - struct consdev *cp; +int +dca_console_scan(scode, va, arg) + int scode; + caddr_t va; + void *arg; { - struct dcadevice *dca; - int unit; - - /* locate the major number */ - for (dcamajor = 0; dcamajor < nchrdev; dcamajor++) - if (cdevsw[dcamajor].d_open == dcaopen) - break; - - /* XXX: ick */ - unit = CONUNIT; - - dca = (struct dcadevice *)sctova(CONSCODE); - - /* make sure hardware exists */ - if (badaddr((short *)dca)) { - cp->cn_pri = CN_DEAD; - return; - } - - /* initialize required fields */ - cp->cn_dev = makedev(dcamajor, unit); + struct dcadevice *dca = (struct dcadevice *)va; + struct consdev *cp = arg; + u_char *dioiidev; + int force = 0, pri; switch (dca->dca_id) { case DCAID0: case DCAID1: - cp->cn_pri = CN_NORMAL; + pri = CN_NORMAL; break; + case DCAREMID0: case DCAREMID1: - cp->cn_pri = CN_REMOTE; + pri = CN_REMOTE; break; + default: - cp->cn_pri = CN_DEAD; - break; + return (0); } +#ifdef CONSCODE /* - * If dcaconsole is initialized, raise our priority. + * Raise our priority, if appropriate. */ - if (dcaconsole == unit) - cp->cn_pri = CN_REMOTE; + if (scode == CONSCODE) { + pri = CN_REMOTE; + force = conforced = 1; + } +#endif + + /* Only raise priority. */ + if (pri > cp->cn_pri) + cp->cn_pri = pri; /* * If our priority is higher than the currently-remembered - * DCA, stash our priority and address, for the benefit of - * dcacninit(). + * console, stash our priority, for the benefit of dcacninit(). */ - if (cp->cn_pri > dca_lastcnpri) { - dca_lastcnpri = cp->cn_pri; - dca_cn = dca; + if (((cn_tab == NULL) || (cp->cn_pri > cn_tab->cn_pri)) || force) { + cn_tab = cp; + if (scode >= 132) { + dioiidev = (u_char *)va; + return ((dioiidev[0x101] + 1) * 0x100000); + } + return (DIOCSIZE); } + return (0); +} + +void +dcacnprobe(cp) + struct consdev *cp; +{ + + /* locate the major number */ + for (dcamajor = 0; dcamajor < nchrdev; dcamajor++) + if (cdevsw[dcamajor].d_open == dcaopen) + break; + + /* initialize required fields */ + cp->cn_dev = makedev(dcamajor, 0); /* XXX */ + cp->cn_pri = CN_DEAD; + + /* Abort early if console is already forced. */ + if (conforced) + return; + + console_scan(dca_console_scan, cp); #ifdef KGDB + /* XXX this needs to be fixed. */ if (major(kgdb_dev) == 1) /* XXX */ kgdb_dev = makedev(dcamajor, minor(kgdb_dev)); #endif } +/* ARGSUSED */ void dcacninit(cp) struct consdev *cp; { - int unit = DCAUNIT(cp->cn_dev); + dca_cn = (struct dcadevice *)conaddr; dcainit(dca_cn, dcadefaultrate); - dcaconsole = unit; dcaconsinit = 1; } @@ -973,12 +985,6 @@ dcacngetc(dev) stat = dev; if (stat) return (0); #endif - /* - * NOTE: This assumes that DCAUNIT(dev) == dcaconsole. If - * it doesn't, well, you lose. (It's also extremely unlikely - * that will ever not be the case.) - */ - s = splhigh(); while (((stat = dca_cn->dca_lsr) & LSR_RXRDY) == 0) ; @@ -1005,12 +1011,6 @@ dcacnputc(dev, c) stat = dev; if (stat) return; #endif - /* - * NOTE: This assumes that DCAUNIT(dev) == dcaconsole. If - * it doesn't, well, you lose. (It's also extremely unlikely - * that will ever not be the case.) - */ - if (dcaconsinit == 0) { dcainit(dca_cn, dcadefaultrate); dcaconsinit = 1; diff --git a/sys/arch/hp300/dev/dcareg.h b/sys/arch/hp300/dev/dcareg.h index d6b76c6cf1a..b2ee8e5cef6 100644 --- a/sys/arch/hp300/dev/dcareg.h +++ b/sys/arch/hp300/dev/dcareg.h @@ -1,4 +1,4 @@ -/* $NetBSD: dcareg.h,v 1.5 1995/12/31 00:27:19 thorpej Exp $ */ +/* $NetBSD: dcareg.h,v 1.6 1996/02/24 00:55:02 thorpej Exp $ */ /* * Copyright (c) 1982, 1986, 1990, 1993 @@ -173,7 +173,3 @@ struct dcadevice { #define MSR_TERI 0x04 #define MSR_DDSR 0x02 #define MSR_DCTS 0x01 - -/* WARNING: Serial console is assumed to be at SC9 */ -#define CONSCODE (9) -#define CONUNIT (0) diff --git a/sys/arch/hp300/dev/dcm.c b/sys/arch/hp300/dev/dcm.c index 12202b9c4cf..b435a80ccb5 100644 --- a/sys/arch/hp300/dev/dcm.c +++ b/sys/arch/hp300/dev/dcm.c @@ -1,7 +1,7 @@ -/* $NetBSD: dcm.c,v 1.22 1995/12/31 00:27:21 thorpej Exp $ */ +/* $NetBSD: dcm.c,v 1.26 1996/03/03 16:48:54 thorpej Exp $ */ /* - * Copyright (c) 1995 Jason R. Thorpe. All rights reserved. + * Copyright (c) 1995, 1996 Jason R. Thorpe. All rights reserved. * Copyright (c) 1988 University of Utah. * Copyright (c) 1982, 1986, 1990, 1993 * The Regents of the University of California. All rights reserved. @@ -66,6 +66,7 @@ #include #include +#include #include #include @@ -78,7 +79,7 @@ #define DEFAULT_BAUD_RATE 9600 #endif -int dcmmatch(), dcmintr(), dcmparam(); +int dcmmatch(), dcmparam(); void dcmattach(), dcmstart(); struct driver dcmdriver = { dcmmatch, dcmattach, "dcm", @@ -130,11 +131,6 @@ struct dcmischeme { static struct dcmdevice *dcm_cn = NULL; /* pointer to hardware */ static int dcm_lastcnpri = CN_DEAD; /* XXX last priority */ static int dcmconsinit; /* has been initialized */ -#ifdef DCMCONSOLE -static int dcmconsole = DCMCONSOLE; -#else -static int dcmconsole = -1; -#endif int dcmdefaultrate = DEFAULT_BAUD_RATE; int dcmconbrdbusy = 0; @@ -232,7 +228,6 @@ struct dcm_softc { struct tty *sc_tty[NDCMPORT]; /* our tty instances */ struct modemreg *sc_modem[NDCMPORT]; /* modem control */ char sc_mcndlast[NDCMPORT]; /* XXX last modem status for port */ - struct isr sc_isr; /* interrupt handler */ short sc_softCAR; /* mask of ports with soft-carrier */ struct dcmischeme sc_scheme; /* interrupt scheme for board */ @@ -247,6 +242,7 @@ struct dcm_softc { * Bits for sc_flags */ #define DCM_ACTIVE 0x00000001 /* indicates board is alive */ +#define DCM_ISCONSOLE 0x00000002 /* indicates board is console */ #define DCM_STDDCE 0x00000010 /* re-map DCE to standard */ #define DCM_FLAGMASK (DCM_STDDCE) /* mask of valid bits in config flags */ @@ -256,6 +252,7 @@ struct dcm_softc { } dcm_softc[NDCM]; void dcminit __P((struct dcmdevice *, int, int)); +int dcmintr __P((void *)); int dcmmatch(hd) @@ -264,23 +261,13 @@ dcmmatch(hd) struct dcm_softc *sc = &dcm_softc[hd->hp_unit]; struct dcmdevice *dcm; int i, timo = 0; - int s, brd, isconsole, mbits; + int s, brd, mbits; dcm = (struct dcmdevice *)hd->hp_addr; if ((dcm->dcm_rsid & 0x1f) != DCMID) return (0); brd = hd->hp_unit; - isconsole = (brd == DCMBOARD(dcmconsole)); - - /* - * XXX selected console device (CONSUNIT) as determined by - * dcmcnprobe does not agree with logical numbering imposed - * by the config file (i.e. lowest address DCM is not unit - * CONSUNIT). Don't recognize this card. - */ - if (isconsole && (dcm != sc->sc_dcm)) - return (0); sc->sc_hd = hd; hd->hp_ipl = DCMIPL(dcm->dcm_ic); @@ -303,7 +290,7 @@ dcmmatch(hd) return (0); DELAY(50000) /* XXX why is this needed ???? */ if (dcm->dcm_stcon != ST_OK) { - if (!isconsole) + if (hd->hp_args->hw_sc != conscode) printf("dcm%d: self test failed: %x\n", brd, dcm->dcm_stcon); return (0); @@ -321,12 +308,21 @@ dcmattach(hd) struct dcm_softc *sc = &dcm_softc[hd->hp_unit]; struct dcmdevice *dcm; int i, timo = 0; - int s, brd, isconsole, mbits; + int s, brd, mbits; dcm = sc->sc_dcm = (struct dcmdevice *)hd->hp_addr; brd = hd->hp_unit; - isconsole = (brd == DCMBOARD(dcmconsole)); + if (hd->hp_args->hw_sc == conscode) { + sc->sc_flags |= DCM_ISCONSOLE; + + /* + * We didn't know which unit this would be during + * the console probe, so we have to fixup cn_dev here. + * Note that we always assume port 1 on the board. + */ + cn_tab->cn_dev = makedev(dcmmajor, (brd << 2) | DCMCONSPORT); + } /* Extract configuration info from flags. */ sc->sc_softCAR = (hd->hp_flags & DCM_SOFTCAR); @@ -336,10 +332,7 @@ dcmattach(hd) sc->sc_flags |= DCM_ACTIVE; /* Establish the interrupt handler. */ - sc->sc_isr.isr_ipl = hd->hp_ipl; - sc->sc_isr.isr_arg = brd; - sc->sc_isr.isr_intr = dcmintr; - isrlink(&sc->sc_isr); + isrlink(dcmintr, sc, hd->hp_ipl, ISRPRI_TTY); if (dcmistype == DIS_TIMER) dcmsetischeme(brd, DIS_RESET|DIS_TIMER); @@ -364,20 +357,20 @@ dcmattach(hd) dcm->dcm_ic = IC_IE; /* turn all interrupts on */ /* - * Need to reset baud rate, etc. of next print so reset dcmconsole. + * Need to reset baud rate, etc. of next print so reset dcmconsinit. * Also make sure console is always "hardwired" */ - if (isconsole) { + if (sc->sc_flags & DCM_ISCONSOLE) { dcmconsinit = 0; - sc->sc_softCAR |= (1 << DCMPORT(dcmconsole)); - printf(": console on port %d\n", DCMPORT(dcmconsole)); + sc->sc_softCAR |= (1 << DCMCONSPORT); + printf(": console on port %d\n", DCMCONSPORT); } else printf("\n"); #ifdef KGDB if (major(kgdb_dev) == dcmmajor && DCMBOARD(DCMUNIT(kgdb_dev)) == brd) { - if (dcmconsole == DCMUNIT(kgdb_dev)) + if (dcmconsole == DCMUNIT(kgdb_dev)) /* XXX fixme */ kgdb_dev = NODEV; /* can't debug over console port */ #ifndef KGDB_CHEAT /* @@ -600,12 +593,13 @@ dcmtty(dev) } int -dcmintr(brd) - register int brd; +dcmintr(arg) + void *arg; { - struct dcm_softc *sc = &dcm_softc[brd]; + struct dcm_softc *sc = arg; struct dcmdevice *dcm = sc->sc_dcm; struct dcmischeme *dis = &sc->sc_scheme; + int brd = sc->sc_hd->hp_unit; int code, i; int pcnd[4], mcode, mcnd[4]; @@ -971,8 +965,8 @@ dcmioctl(dev, cmd, data, flag, p) userbits = *(int *)data; if ((userbits & TIOCFLAG_SOFTCAR) || - ((board == DCMBOARD(dcmconsole)) && - (port == DCMPORT(dcmconsole)))) + ((sc->sc_flags & DCM_ISCONSOLE) && + (port == DCMCONSPORT))) sc->sc_softCAR |= (1 << port); if (userbits & TIOCFLAG_CLOCAL) @@ -1376,70 +1370,81 @@ dcminit(dcm, port, rate) * Following are all routines needed for DCM to act as console */ -void -dcmcnprobe(cp) - struct consdev *cp; +int +dcm_console_scan(scode, va, arg) + int scode; + caddr_t va; + void *arg; { - struct dcm_softc *sc; /* XXX thorpej */ - struct dcmdevice *dcm; - struct hp_hw *hw; - int unit; + struct dcmdevice *dcm = (struct dcmdevice *)va; + struct consdev *cp = arg; + u_char *dioiidev; + int force = 0, pri; - /* locate the major number */ - for (dcmmajor = 0; dcmmajor < nchrdev; dcmmajor++) - if (cdevsw[dcmmajor].d_open == dcmopen) - break; - - /* - * XXX FIX ME! - * Implicitly assigns the lowest select code DCM card found to be - * logical unit 0 (actually CONUNIT). If your config file does - * anything different, you're screwed. - */ - for (hw = sc_table; hw->hw_type; hw++) - if (HW_ISDEV(hw, D_COMMDCM) && !badaddr((short *)hw->hw_kva)) - break; - if (!HW_ISDEV(hw, D_COMMDCM)) { - cp->cn_pri = CN_DEAD; - return; - } - - unit = CONUNIT; - dcm = (struct dcmdevice *)hw->hw_kva; - - /* initialize required fields */ - cp->cn_dev = makedev(dcmmajor, unit); switch (dcm->dcm_rsid) { case DCMID: - cp->cn_pri = CN_NORMAL; + pri = CN_NORMAL; break; case DCMID|DCMCON: - cp->cn_pri = CN_REMOTE; + pri = CN_REMOTE; break; default: - cp->cn_pri = CN_DEAD; - return; + return (0); } +#ifdef CONSCODE /* - * If dcmconsole is initialized, raise our priority. + * Raise our priority, if appropriate. */ - if (dcmconsole == unit) - cp->cn_pri = CN_REMOTE; + if (scode == CONSCODE) { + pri = CN_REMOTE; + force = conforced = 1; + } +#endif + + /* Only raise priority. */ + if (pri > cp->cn_pri) + cp->cn_pri = pri; /* * If our priority is higher than the currently-remembered - * DCM, stash our priority and address, for the benefit of - * dcmcninit(). + * console, stash our priority, for the benefit of dcmcninit(). */ - if (cp->cn_pri > dcm_lastcnpri) { - dcm_lastcnpri = cp->cn_pri; - dcm_cn = dcm; + if (((cn_tab == NULL) || (cp->cn_pri > cn_tab->cn_pri)) || force) { + cn_tab = cp; + if (scode >= 132) { + dioiidev = (u_char *)va; + return ((dioiidev[0x101] + 1) * 0x100000); + } + return (DIOCSIZE); } + return (0); +} + +void +dcmcnprobe(cp) + struct consdev *cp; +{ + + /* locate the major number */ + for (dcmmajor = 0; dcmmajor < nchrdev; dcmmajor++) + if (cdevsw[dcmmajor].d_open == dcmopen) + break; + + /* initialize required fields */ + cp->cn_dev = makedev(dcmmajor, 0); /* XXX */ + cp->cn_pri = CN_DEAD; + + /* Abort early if console already forced. */ + if (conforced) + return; + + console_scan(dcm_console_scan, cp); #ifdef KGDB_CHEAT + /* XXX this needs to be fixed. */ /* * This doesn't currently work, at least not with ite consoles; * the console hasn't been initialized yet. @@ -1461,18 +1466,18 @@ dcmcnprobe(cp) #endif } +/* ARGSUSED */ void dcmcninit(cp) struct consdev *cp; { - int unit = DCMUNIT(cp->cn_dev); - int port = DCMPORT(unit); - dcminit(dcm_cn, port, dcmdefaultrate); + dcm_cn = (struct dcmdevice *)conaddr; + dcminit(dcm_cn, DCMCONSPORT, dcmdefaultrate); dcmconsinit = 1; - dcmconsole = DCMUNIT(cp->cn_dev); } +/* ARGSUSED */ int dcmcngetc(dev) dev_t dev; @@ -1480,22 +1485,13 @@ dcmcngetc(dev) struct dcmrfifo *fifo; struct dcmpreg *pp; u_int head; - int s, c, stat, unit, port; - - unit = DCMUNIT(dev); - port = DCMPORT(unit); - - /* - * NOTE: This assumes that unit == dcmconsole. If it doesn't, - * well, you lose. (It's also extremely unlikely that will ever - * not be the case.) - */ + int s, c, stat; - pp = dcm_preg(dcm_cn, port); + pp = dcm_preg(dcm_cn, DCMCONSPORT); s = splhigh(); head = pp->r_head & RX_MASK; - fifo = &dcm_cn->dcm_rfifos[3-port][head>>1]; + fifo = &dcm_cn->dcm_rfifos[3-DCMCONSPORT][head>>1]; while (head == (pp->r_tail & RX_MASK)) ; /* @@ -1517,6 +1513,7 @@ dcmcngetc(dev) /* * Console kernel output character routine. */ +/* ARGSUSED */ void dcmcnputc(dev, c) dev_t dev; @@ -1524,35 +1521,26 @@ dcmcnputc(dev, c) { struct dcmpreg *pp; unsigned tail; - int s, unit, port, stat; - - unit = DCMUNIT(dev); - port = DCMPORT(unit); - - /* - * NOTE: This assumes that unit == dcmconsole. If it doesn't, - * well, you lose. (It's also extremely unlikely that will ever - * not be the case.) - */ + int s, unit, stat; - pp = dcm_preg(dcm_cn, port); + pp = dcm_preg(dcm_cn, DCMCONSPORT); s = splhigh(); #ifdef KGDB if (dev != kgdb_dev) #endif if (dcmconsinit == 0) { - dcminit(dcm_cn, port, dcmdefaultrate); + dcminit(dcm_cn, DCMCONSPORT, dcmdefaultrate); dcmconsinit = 1; } tail = pp->t_tail & TX_MASK; while (tail != (pp->t_head & TX_MASK)) ; - dcm_cn->dcm_tfifos[3-port][tail].data_char = c; + dcm_cn->dcm_tfifos[3-DCMCONSPORT][tail].data_char = c; pp->t_tail = tail = (tail + 1) & TX_MASK; SEM_LOCK(dcm_cn); - dcm_cn->dcm_cmdtab[port].dcm_data |= CT_TX; - dcm_cn->dcm_cr |= (1 << port); + dcm_cn->dcm_cmdtab[DCMCONSPORT].dcm_data |= CT_TX; + dcm_cn->dcm_cr |= (1 << DCMCONSPORT); SEM_UNLOCK(dcm_cn); while (tail != (pp->t_head & TX_MASK)) ; diff --git a/sys/arch/hp300/dev/dcmreg.h b/sys/arch/hp300/dev/dcmreg.h index 5e2269bf445..d27cfbcf264 100644 --- a/sys/arch/hp300/dev/dcmreg.h +++ b/sys/arch/hp300/dev/dcmreg.h @@ -1,4 +1,4 @@ -/* $NetBSD: dcmreg.h,v 1.4 1994/10/26 07:23:37 cgd Exp $ */ +/* $NetBSD: dcmreg.h,v 1.5 1996/02/24 00:55:05 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -250,8 +250,7 @@ struct dcmpreg { #define RX_MASK 0xff /* - * WARNING: Serial console is assumed to be the lowest select-code card - * and that card must be logical unit 0 in the kernel. Also, CONUNIT must - * be 1, the port affected by the REMOTE/LOCAL switch. + * DCM console caveat: only port 1 is affected by the remote switch, and + * thus the only supported console port on a given DCM card. */ -#define CONUNIT (1) +#define DCMCONSPORT 1 diff --git a/sys/arch/hp300/dev/device.h b/sys/arch/hp300/dev/device.h index e1c87334a40..ca2861e45df 100644 --- a/sys/arch/hp300/dev/device.h +++ b/sys/arch/hp300/dev/device.h @@ -1,4 +1,4 @@ -/* $NetBSD: device.h,v 1.6 1995/12/02 18:21:54 thorpej Exp $ */ +/* $NetBSD: device.h,v 1.7 1996/02/14 02:44:14 thorpej Exp $ */ /* * Copyright (c) 1982, 1990, 1993 @@ -81,12 +81,14 @@ struct hp_device { char hp_xname[8]; }; +/* XXX This needs to die. */ struct devqueue { struct devqueue *dq_forw; struct devqueue *dq_back; int dq_ctlr; int dq_unit; int dq_slave; + void *dq_softc; struct driver *dq_driver; }; diff --git a/sys/arch/hp300/dev/dma.c b/sys/arch/hp300/dev/dma.c index cb22512d334..17820334441 100644 --- a/sys/arch/hp300/dev/dma.c +++ b/sys/arch/hp300/dev/dma.c @@ -1,4 +1,4 @@ -/* $NetBSD: dma.c,v 1.6 1995/12/02 02:46:45 thorpej Exp $ */ +/* $NetBSD: dma.c,v 1.7 1996/02/14 02:44:17 thorpej Exp $ */ /* * Copyright (c) 1995 Jason R. Thorpe. @@ -101,7 +101,7 @@ struct dma_softc { #define DMAF_NOINTR 0x04 struct devqueue dmachan[NDMACHAN + 1]; -int dmaintr(); +int dmaintr __P((void *)); #ifdef DEBUG int dmadebug = 0; @@ -180,6 +180,9 @@ dmainit() printf("%s: 98620%c, 2 channels, %d bit\n", sc->sc_xname, rev, (rev == 'B') ? 16 : 32); + + /* Establish the interrupt handler */ + isrlink(dmaintr, sc, DMAINTLVL, ISRPRI_BIO); } int @@ -442,9 +445,10 @@ dmastop(unit) } int -dmaintr() +dmaintr(arg) + void *arg; { - struct dma_softc *sc = &Dma_softc; + struct dma_softc *sc = arg; register struct dma_channel *dc; register int i, stat; int found = 0; diff --git a/sys/arch/hp300/dev/fhpib.c b/sys/arch/hp300/dev/fhpib.c index 53e85c7e5f9..a4a08f84984 100644 --- a/sys/arch/hp300/dev/fhpib.c +++ b/sys/arch/hp300/dev/fhpib.c @@ -1,4 +1,4 @@ -/* $NetBSD: fhpib.c,v 1.8 1995/12/02 18:21:56 thorpej Exp $ */ +/* $NetBSD: fhpib.c,v 1.9 1996/02/14 02:44:20 thorpej Exp $ */ /* * Copyright (c) 1982, 1990, 1993 @@ -86,7 +86,7 @@ int fhpibppoll __P((int)); void fhpibppwatch __P((void *)); void fhpibgo __P((int, int, int, void *, int, int, int)); void fhpibdone __P((int)); -int fhpibintr __P((int)); +int fhpibintr __P((void *)); /* * Our controller ops structure. @@ -422,7 +422,7 @@ fhpibdmadone(arg) hs->sc_flags &= ~(HPIBF_DONE|HPIBF_IO|HPIBF_READ|HPIBF_TIMO); dmafree(&hs->sc_dq); dq = hs->sc_sq.dq_forw; - (dq->dq_driver->d_intr)(dq->dq_unit); + (dq->dq_driver->d_intr)(dq->dq_softc); } (void) splx(s); } @@ -471,13 +471,13 @@ fhpibdone(unit) } int -fhpibintr(unit) - register int unit; +fhpibintr(arg) + void *arg; { - register struct hpib_softc *hs = &hpib_softc[unit]; + register struct hpib_softc *hs = arg; register struct fhpibdevice *hd; register struct devqueue *dq; - register int stat0; + register int stat0, unit = hs->sc_hc->hp_unit; hd = (struct fhpibdevice *)hs->sc_hc->hp_addr; stat0 = hd->hpib_ids; @@ -513,7 +513,7 @@ fhpibintr(unit) hd->hpib_imask = 0; hs->sc_flags &= ~(HPIBF_DONE|HPIBF_IO|HPIBF_READ|HPIBF_TIMO); dmafree(&hs->sc_dq); - (dq->dq_driver->d_intr)(dq->dq_unit); + (dq->dq_driver->d_intr)(dq->dq_softc); } else if (hs->sc_flags & HPIBF_PPOLL) { stat0 = hd->hpib_intr; #ifdef DEBUG @@ -542,7 +542,7 @@ fhpibintr(unit) } #endif hs->sc_flags &= ~HPIBF_PPOLL; - (dq->dq_driver->d_intr)(dq->dq_unit); + (dq->dq_driver->d_intr)(dq->dq_softc); } return(1); } diff --git a/sys/arch/hp300/dev/grf.c b/sys/arch/hp300/dev/grf.c index 9594ded7fe0..bc4c09a799c 100644 --- a/sys/arch/hp300/dev/grf.c +++ b/sys/arch/hp300/dev/grf.c @@ -1,4 +1,4 @@ -/* $NetBSD: grf.c,v 1.16 1995/11/28 08:14:30 thorpej Exp $ */ +/* $NetBSD: grf.c,v 1.17 1996/02/24 00:55:07 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -59,12 +59,13 @@ #include #include +#include +#include + #include #include #include -#include - #ifdef COMPAT_HPUX #include extern struct emul emul_hpux; @@ -78,13 +79,21 @@ extern struct emul emul_hpux; #include #include "ite.h" -#if NITE == 0 +#if NITE > 0 +#include +#else #define iteon(u,f) #define iteoff(u,f) -#endif +#endif /* NITE > 0 */ struct grf_softc grf_softc[NGRF]; +/* + * Frambuffer state information, statically allocated for benefit + * of the console. + */ +struct grf_data grf_cn; + #ifdef DEBUG int grfdebug = 0; #define GDB_DEVNO 0x01 @@ -94,23 +103,32 @@ int grfdebug = 0; #endif /*ARGSUSED*/ -grfopen(dev, flags) +grfopen(dev, flags, mode, p) dev_t dev; - int flags; + int flags, mode; + struct proc *p; { int unit = GRFUNIT(dev); - register struct grf_softc *gp = &grf_softc[unit]; + struct grf_softc *sc; + struct grf_data *gp; int error = 0; - if (unit >= NGRF || (gp->g_flags & GF_ALIVE) == 0) + if (unit >= NGRF) return(ENXIO); + + sc = &grf_softc[unit]; + gp = sc->sc_data; + + if ((gp->g_flags & GF_ALIVE) == 0) + return (ENXIO); + if ((gp->g_flags & (GF_OPEN|GF_EXCLUDE)) == (GF_OPEN|GF_EXCLUDE)) return(EBUSY); #ifdef COMPAT_HPUX /* * XXX: cannot handle both HPUX and BSD processes at the same time */ - if (curproc->p_emul == &emul_hpux) + if (p->p_emul == &emul_hpux) if (gp->g_flags & GF_BSDOPEN) return(EBUSY); else @@ -134,11 +152,23 @@ grfopen(dev, flags) } /*ARGSUSED*/ -grfclose(dev, flags) +grfclose(dev, flags, mode, p) dev_t dev; - int flags; + int flags, mode; + struct proc *p; { - register struct grf_softc *gp = &grf_softc[GRFUNIT(dev)]; + int unit = GRFUNIT(dev); + struct grf_softc *sc; + struct grf_data *gp; + + if (unit >= NGRF) + return(ENXIO); + + sc = &grf_softc[unit]; + gp = sc->sc_data; + + if ((gp->g_flags & GF_ALIVE) == 0) + return (ENXIO); (void) grfoff(dev); #ifdef COMPAT_HPUX @@ -155,8 +185,18 @@ grfioctl(dev, cmd, data, flag, p) caddr_t data; struct proc *p; { - register struct grf_softc *gp = &grf_softc[GRFUNIT(dev)]; - int error; + struct grf_softc *sc; + struct grf_data *gp; + int error, unit = GRFUNIT(dev); + + if (unit >= NGRF) + return(ENXIO); + + sc = &grf_softc[unit]; + gp = sc->sc_data; + + if ((gp->g_flags & GF_ALIVE) == 0) + return (ENXIO); #ifdef COMPAT_HPUX if (p->p_emul == &emul_hpux) @@ -211,44 +251,56 @@ grfmmap(dev, off, prot) return(grfaddr(&grf_softc[GRFUNIT(dev)], off)); } +int grfon(dev) - dev_t dev; + dev_t dev; /* XXX */ { int unit = GRFUNIT(dev); - struct grf_softc *gp = &grf_softc[unit]; + struct grf_softc *sc; + struct grf_data *gp; + + sc = &grf_softc[unit]; + gp = sc->sc_data; /* * XXX: iteoff call relies on devices being in same order * as ITEs and the fact that iteoff only uses the minor part * of the dev arg. */ - iteoff(unit, 3); + iteoff(sc->sc_ite->sc_data, 3); return((*gp->g_sw->gd_mode)(gp, (dev&GRFOVDEV) ? GM_GRFOVON : GM_GRFON, (caddr_t)0)); } +int grfoff(dev) - dev_t dev; + dev_t dev; /* XXX */ { int unit = GRFUNIT(dev); - struct grf_softc *gp = &grf_softc[unit]; + struct grf_softc *sc; + struct grf_data *gp; int error; + sc = &grf_softc[unit]; + gp = sc->sc_data; + (void) grfunmap(dev, (caddr_t)0, curproc); error = (*gp->g_sw->gd_mode)(gp, (dev&GRFOVDEV) ? GM_GRFOVOFF : GM_GRFOFF, (caddr_t)0); /* XXX: see comment for iteoff above */ - iteon(unit, 2); + (void) iteon(sc->sc_ite->sc_data, 2); return(error); } -grfaddr(gp, off) - struct grf_softc *gp; +int +grfaddr(sc, off) + struct grf_softc *sc; register int off; { - register struct grfinfo *gi = &gp->g_display; + struct grf_data *gp= sc->sc_data; + struct grfinfo *gi = &gp->g_display; /* control registers */ if (off >= 0 && off < gi->gd_regsize) @@ -275,7 +327,8 @@ hpuxgrfioctl(dev, cmd, data, flag, p) caddr_t data; struct proc *p; { - register struct grf_softc *gp = &grf_softc[GRFUNIT(dev)]; + struct grf_softc *sc = &grf_softc[GRFUNIT(dev)]; + struct grf_data *gp = sc->sc_data; int error; error = 0; @@ -372,8 +425,9 @@ hpuxgrfioctl(dev, cmd, data, flag, p) return(error); } +int grflock(gp, block) - register struct grf_softc *gp; + struct grf_data *gp; int block; { struct proc *p = curproc; /* XXX */ @@ -382,8 +436,8 @@ grflock(gp, block) #ifdef DEBUG if (grfdebug & GDB_LOCK) - printf("grflock(%d): dev %x flags %x lockpid %x\n", - p->p_pid, gp-grf_softc, gp->g_flags, + printf("grflock(%d): flags %x lockpid %x\n", + p->p_pid, gp->g_flags, gp->g_lockp ? gp->g_lockp->p_pid : -1); #endif if (gp->g_pid) { @@ -426,12 +480,12 @@ grflock(gp, block) } grfunlock(gp) - register struct grf_softc *gp; + struct grf_data *gp; { #ifdef DEBUG if (grfdebug & GDB_LOCK) - printf("grfunlock(%d): dev %x flags %x lockpid %d\n", - curproc->p_pid, gp-grf_softc, gp->g_flags, + printf("grfunlock(%d): flags %x lockpid %d\n", + curproc->p_pid, gp->g_flags, gp->g_lockp ? gp->g_lockp->p_pid : -1); #endif if (gp->g_lockp != curproc) @@ -465,7 +519,8 @@ grfdevno(dev) dev_t dev; { int unit = GRFUNIT(dev); - struct grf_softc *gp = &grf_softc[unit]; + struct grf_softc *sc = &grf_softc[unit]; + struct grf_data *gp = sc->sc_data; int newdev; if (unit >= NGRF || (gp->g_flags&GF_ALIVE) == 0) @@ -495,7 +550,8 @@ grfmap(dev, addrp, p) caddr_t *addrp; struct proc *p; { - struct grf_softc *gp = &grf_softc[GRFUNIT(dev)]; + struct grf_softc *sc = &grf_softc[GRFUNIT(dev)]; + struct grf_data *gp = sc->sc_data; int len, error; struct vnode vn; struct specinfo si; @@ -527,7 +583,8 @@ grfunmap(dev, addr, p) caddr_t addr; struct proc *p; { - struct grf_softc *gp = &grf_softc[GRFUNIT(dev)]; + struct grf_softc *sc = &grf_softc[GRFUNIT(dev)]; + struct grf_data *gp = sc->sc_data; vm_size_t size; int rv; @@ -578,7 +635,7 @@ iounmmap(dev, addr) * slot is available. */ grffindpid(gp) - struct grf_softc *gp; + struct grf_data *gp; { register short pid, *sp; register int i, limit; @@ -616,7 +673,7 @@ done: } grfrmpid(gp) - struct grf_softc *gp; + struct grf_data *gp; { register short pid, *sp; register int limit, i; diff --git a/sys/arch/hp300/dev/grf_conf.c b/sys/arch/hp300/dev/grf_conf.c index 10a2d3829e0..3bbafb6cc19 100644 --- a/sys/arch/hp300/dev/grf_conf.c +++ b/sys/arch/hp300/dev/grf_conf.c @@ -1,6 +1,7 @@ -/* $NetBSD: grf_conf.c,v 1.2 1994/10/26 07:23:48 cgd Exp $ */ +/* $NetBSD: grf_conf.c,v 1.3 1996/02/24 00:55:08 thorpej Exp $ */ /* + * Copyright (c) 1996 Jason R. Thorpe. All rights reserved. * Copyright (c) 1991 University of Utah. * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. @@ -50,73 +51,27 @@ #include -#include -#include +#include /* XXX */ #include -#include -extern int tc_init(), tc_mode(); -extern int gb_init(), gb_mode(); -extern int rb_init(), rb_mode(); -extern int dv_init(), dv_mode(); -extern int hy_init(), hy_mode(); +extern struct grfsw dvbox_grfsw; +extern struct grfsw gbox_grfsw; +extern struct grfsw hyper_grfsw; +extern struct grfsw rbox_grfsw; +extern struct grfsw topcat_grfsw; +extern struct grfsw lrcatseye_grfsw; +extern struct grfsw hrcatseye_grfsw; +extern struct grfsw hrmcatseye_grfsw; -struct grfsw grfsw[] = { - GID_TOPCAT, GRFBOBCAT, "topcat", tc_init, tc_mode, - GID_GATORBOX, GRFGATOR, "gatorbox", gb_init, gb_mode, - GID_RENAISSANCE,GRFRBOX, "renaissance", rb_init, rb_mode, - GID_LRCATSEYE, GRFCATSEYE, "lo-res catseye", tc_init, tc_mode, - GID_HRCCATSEYE, GRFCATSEYE, "hi-res catseye", tc_init, tc_mode, - GID_HRMCATSEYE, GRFCATSEYE, "hi-res catseye", tc_init, tc_mode, - GID_DAVINCI, GRFDAVINCI, "davinci", dv_init, dv_mode, - GID_HYPERION, GRFHYPERION, "hyperion", hy_init, hy_mode, +struct grfsw *grfsw[] = { + &topcat_grfsw, + &gbox_grfsw, + &rbox_grfsw, + &lrcatseye_grfsw, + &hrcatseye_grfsw, + &hrmcatseye_grfsw, + &dvbox_grfsw, + &hyper_grfsw, }; int ngrfsw = sizeof(grfsw) / sizeof(grfsw[0]); - -#include "ite.h" -#if NITE > 0 - -#include - -extern u_char ite_readbyte(); -extern int ite_writeglyph(); -extern int topcat_scroll(), topcat_init(), topcat_deinit(); -extern int topcat_clear(), topcat_putc(), topcat_cursor(); -extern int gbox_scroll(), gbox_init(), gbox_deinit(); -extern int gbox_clear(), gbox_putc(), gbox_cursor(); -extern int rbox_scroll(), rbox_init(), rbox_deinit(); -extern int rbox_clear(), rbox_putc(), rbox_cursor(); -extern int dvbox_scroll(), dvbox_init(), dvbox_deinit(); -extern int dvbox_clear(), dvbox_putc(), dvbox_cursor(); -extern int hyper_scroll(), hyper_init(), hyper_deinit(); -extern int hyper_clear(), hyper_putc(), hyper_cursor(); - -struct itesw itesw[] = { - GID_TOPCAT, - topcat_init, topcat_deinit, topcat_clear, topcat_putc, - topcat_cursor, topcat_scroll, ite_readbyte, ite_writeglyph, - GID_GATORBOX, - gbox_init, gbox_deinit, gbox_clear, gbox_putc, - gbox_cursor, gbox_scroll, ite_readbyte, ite_writeglyph, - GID_RENAISSANCE, - rbox_init, rbox_deinit, rbox_clear, rbox_putc, - rbox_cursor, rbox_scroll, ite_readbyte, ite_writeglyph, - GID_LRCATSEYE, - topcat_init, topcat_deinit, topcat_clear, topcat_putc, - topcat_cursor, topcat_scroll, ite_readbyte, ite_writeglyph, - GID_HRCCATSEYE, - topcat_init, topcat_deinit, topcat_clear, topcat_putc, - topcat_cursor, topcat_scroll, ite_readbyte, ite_writeglyph, - GID_HRMCATSEYE, - topcat_init, topcat_deinit, topcat_clear, topcat_putc, - topcat_cursor, topcat_scroll, ite_readbyte, ite_writeglyph, - GID_DAVINCI, - dvbox_init, dvbox_deinit, dvbox_clear, dvbox_putc, - dvbox_cursor, dvbox_scroll, ite_readbyte, ite_writeglyph, - GID_HYPERION, - hyper_init, hyper_deinit, hyper_clear, hyper_putc, - hyper_cursor, hyper_scroll, ite_readbyte, ite_writeglyph, -}; -int nitesw = sizeof(itesw) / sizeof(itesw[0]); -#endif -#endif +#endif /* NGRF > 0 */ diff --git a/sys/arch/hp300/dev/grf_dv.c b/sys/arch/hp300/dev/grf_dv.c index 9fdb700d4ae..ef1946fa244 100644 --- a/sys/arch/hp300/dev/grf_dv.c +++ b/sys/arch/hp300/dev/grf_dv.c @@ -1,6 +1,7 @@ -/* $NetBSD: grf_dv.c,v 1.4 1994/10/26 07:23:49 cgd Exp $ */ +/* $NetBSD: grf_dv.c,v 1.7 1996/03/03 16:48:56 thorpej Exp $ */ /* + * Copyright (c) 1996 Jason R. Thorpe. All rights reserved. * Copyright (c) 1988 University of Utah. * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. @@ -49,21 +50,63 @@ * Graphics routines for the DaVinci, HP98730/98731 Graphics system. */ #include +#include #include +#include +#include +#include +#include + +#include +#include + +#include #include #include +#include #include -#include +#include +#include + +#include "ite.h" + +int dv_init __P((struct grf_data *, int, caddr_t)); +int dv_mode __P((struct grf_data *, int, caddr_t)); +void dv_reset __P((struct dvboxfb *)); + +/* DaVinci grf switch */ +struct grfsw dvbox_grfsw = { + GID_DAVINCI, GRFDAVINCI, "davinci", dv_init, dv_mode +}; + +#if NITE > 0 +void dvbox_init __P((struct ite_data *)); +void dvbox_deinit __P((struct ite_data *)); +void dvbox_putc __P((struct ite_data *, int, int, int, int)); +void dvbox_cursor __P((struct ite_data *, int)); +void dvbox_clear __P((struct ite_data *, int, int, int, int)); +void dvbox_scroll __P((struct ite_data *, int, int, int, int)); +void dvbox_windowmove __P((struct ite_data *, int, int, int, int, + int, int, int)); + +/* DaVinci ite switch */ +struct itesw dvbox_itesw = { + dvbox_init, dvbox_deinit, dvbox_clear, dvbox_putc, + dvbox_cursor, dvbox_scroll, ite_readbyte, ite_writeglyph +}; +#endif /* NITE > 0 */ /* * Initialize hardware. * Must point g_display at a grfinfo structure describing the hardware. * Returns 0 if hardware not present, non-zero ow. */ -dv_init(gp, addr) - struct grf_softc *gp; +int +dv_init(gp, scode, addr) + struct grf_data *gp; + int scode; caddr_t addr; { register struct dvboxfb *dbp; @@ -71,48 +114,57 @@ dv_init(gp, addr) int fboff; extern caddr_t sctopa(), iomap(); - dbp = (struct dvboxfb *) addr; - if (ISIIOVA(addr)) - gi->gd_regaddr = (caddr_t) IIOP(addr); - else - gi->gd_regaddr = sctopa(vatosc(addr)); - gi->gd_regsize = 0x20000; - gi->gd_fbwidth = (dbp->fbwmsb << 8) | dbp->fbwlsb; - gi->gd_fbheight = (dbp->fbhmsb << 8) | dbp->fbhlsb; - gi->gd_fbsize = gi->gd_fbwidth * gi->gd_fbheight; - fboff = (dbp->fbomsb << 8) | dbp->fbolsb; - gi->gd_fbaddr = (caddr_t) (*((u_char *)addr + fboff) << 16); - if (gi->gd_regaddr >= (caddr_t)DIOIIBASE) { - /* - * For DIO II space the fbaddr just computed is the offset - * from the select code base (regaddr) of the framebuffer. - * Hence it is also implicitly the size of the register set. - */ - gi->gd_regsize = (int) gi->gd_fbaddr; - gi->gd_fbaddr += (int) gi->gd_regaddr; - gp->g_regkva = addr; - gp->g_fbkva = addr + gi->gd_regsize; - } else { - /* - * For DIO space we need to map the seperate framebuffer. - */ - gp->g_regkva = addr; - gp->g_fbkva = iomap(gi->gd_fbaddr, gi->gd_fbsize); - } - gi->gd_dwidth = (dbp->dwmsb << 8) | dbp->dwlsb; - gi->gd_dheight = (dbp->dwmsb << 8) | dbp->dwlsb; - gi->gd_planes = 0; /* ?? */ - gi->gd_colors = 256; + /* + * If the console has been initialized, and it was us, there's + * no need to repeat this. + */ + if (consinit_active || (scode != conscode)) { + dbp = (struct dvboxfb *) addr; + if (ISIIOVA(addr)) + gi->gd_regaddr = (caddr_t) IIOP(addr); + else + gi->gd_regaddr = sctopa(scode); + gi->gd_regsize = 0x20000; + gi->gd_fbwidth = (dbp->fbwmsb << 8) | dbp->fbwlsb; + gi->gd_fbheight = (dbp->fbhmsb << 8) | dbp->fbhlsb; + gi->gd_fbsize = gi->gd_fbwidth * gi->gd_fbheight; + fboff = (dbp->fbomsb << 8) | dbp->fbolsb; + gi->gd_fbaddr = (caddr_t) (*((u_char *)addr + fboff) << 16); + if (gi->gd_regaddr >= (caddr_t)DIOIIBASE) { + /* + * For DIO II space the fbaddr just computed is + * the offset from the select code base (regaddr) + * of the framebuffer. Hence it is also implicitly + * the size of the register set. + */ + gi->gd_regsize = (int) gi->gd_fbaddr; + gi->gd_fbaddr += (int) gi->gd_regaddr; + gp->g_regkva = addr; + gp->g_fbkva = addr + gi->gd_regsize; + } else { + /* + * For DIO space we need to map the seperate + * framebuffer. + */ + gp->g_regkva = addr; + gp->g_fbkva = iomap(gi->gd_fbaddr, gi->gd_fbsize); + } + gi->gd_dwidth = (dbp->dwmsb << 8) | dbp->dwlsb; + gi->gd_dheight = (dbp->dwmsb << 8) | dbp->dwlsb; + gi->gd_planes = 0; /* ?? */ + gi->gd_colors = 256; - dv_reset(dbp); + dv_reset(dbp); + } return(1); } /* * Magic code herein. */ +void dv_reset(dbp) - register struct dvboxfb *dbp; + struct dvboxfb *dbp; { dbp->reset = 0x80; DELAY(100); @@ -163,8 +215,9 @@ dv_reset(dbp) * Right now all we can do is grfon/grfoff. * Return a UNIX error number or 0 for success. */ +int dv_mode(gp, cmd, data) - register struct grf_softc *gp; + struct grf_data *gp; int cmd; caddr_t data; { @@ -246,4 +299,351 @@ dv_mode(gp, cmd, data) return(error); } +#if NITE > 0 + +/* + * DaVinci ite routines + */ + +#define REGBASE ((struct dvboxfb *)(ip->regbase)) +#define WINDOWMOVER dvbox_windowmove + +void +dvbox_init(ip) + register struct ite_data *ip; +{ + int i; + + /* XXX */ + if (ip->regbase == 0) { + struct grf_data *gp = ip->grf; + + ip->regbase = gp->g_regkva; + ip->fbbase = gp->g_fbkva; + ip->fbwidth = gp->g_display.gd_fbwidth; + ip->fbheight = gp->g_display.gd_fbheight; + ip->dwidth = gp->g_display.gd_dwidth; + ip->dheight = gp->g_display.gd_dheight; + /* + * 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; + } + + dv_reset((struct dvboxfb *)ip->regbase); + + /* + * 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(100); + + /* + * 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); +} + +void +dvbox_deinit(ip) + register struct ite_data *ip; +{ + dvbox_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR); + db_waitbusy(ip->regbase); + + ip->flags &= ~ITE_INITED; +} + +void +dvbox_putc(ip, c, dy, dx, mode) + struct ite_data *ip; + int dy, dx, c, mode; +{ + register int wrr = ((mode == ATTR_INV) ? RR_COPYINVERTED : RR_COPY); + + dvbox_windowmove(ip, charY(ip, c), charX(ip, c), + dy * ip->ftheight, dx * ip->ftwidth, + ip->ftheight, ip->ftwidth, wrr); +} + +void +dvbox_cursor(ip, flag) + struct ite_data *ip; + int flag; +{ + if (flag == DRAW_CURSOR) + draw_cursor(ip) + else if (flag == MOVE_CURSOR) { + erase_cursor(ip) + draw_cursor(ip) + } + else + erase_cursor(ip) +} + +void +dvbox_clear(ip, sy, sx, h, w) + struct ite_data *ip; + 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); +} + +void +dvbox_scroll(ip, sy, sx, count, dir) + struct ite_data *ip; + int sy, count, dir, sx; +{ + register int dy; + register int dx = sx; + register int height = 1; + register int width = ip->cols; + + if (dir == SCROLL_UP) { + dy = sy - count; + height = ip->rows - sy; + } + else if (dir == SCROLL_DOWN) { + dy = sy + count; + height = ip->rows - dy - 1; + } + else if (dir == SCROLL_RIGHT) { + dy = sy; + dx = sx + count; + width = ip->cols - dx; + } + else { + dy = sy; + dx = sx - count; + width = ip->cols - sx; + } + + dvbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth, + dy * ip->ftheight, dx * ip->ftwidth, + height * ip->ftheight, + width * ip->ftwidth, RR_COPY); +} + +void +dvbox_windowmove(ip, sy, sx, dy, dx, h, w, func) + struct ite_data *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; +} + +/* + * DaVinci console support + */ + +int +dvbox_console_scan(scode, va, arg) + int scode; + caddr_t va; + void *arg; +{ + struct grfreg *grf = (struct grfreg *)va; + struct consdev *cp = arg; + u_char *dioiidev; + int force = 0, pri; + + if ((grf->gr_id == GRFHWID) && (grf->gr_id2 == GID_DAVINCI)) { + pri = CN_NORMAL; + +#ifdef CONSCODE + /* + * Raise our priority, if appropriate. + */ + if (scode == CONSCODE) { + pri = CN_REMOTE; + force = conforced = 1; + } #endif + + /* Only raise priority. */ + if (pri > cp->cn_pri) + cp->cn_pri = pri; + + /* + * If our priority is higher than the currently-remembered + * console, stash our priority. + */ + if (((cn_tab == NULL) || (cp->cn_pri > cn_tab->cn_pri)) + || force) { + cn_tab = cp; + if (scode >= 132) { + dioiidev = (u_char *)va; + return ((dioiidev[0x101] + 1) * 0x100000); + } + return (DIOCSIZE); + } + } + return (0); +} + +void +dvboxcnprobe(cp) + struct consdev *cp; +{ + int maj; + caddr_t va; + struct grfreg *grf; + int force = 0; + + maj = ite_major(); + + /* initialize required fields */ + cp->cn_dev = makedev(maj, 0); /* XXX */ + cp->cn_pri = CN_DEAD; + + /* Abort early if console is already forced. */ + if (conforced) + return; + + /* Look for "internal" framebuffer. */ + va = (caddr_t)IIOV(GRFIADDR); + grf = (struct grfreg *)va; + if (!badaddr(va) && + ((grf->gr_id == GRFHWID) && (grf->gr_id2 == GID_DAVINCI))) { + cp->cn_pri = CN_INTERNAL; + +#ifdef CONSCODE + /* + * Raise our priority and save some work, if appropriate. + */ + if (CONSCODE == -1) { + cp->cn_pri = CN_REMOTE; + force = conforced = 1; + } +#endif + + /* + * If our priority is higher than the currently + * remembered console, stash our priority, and + * unmap whichever device might be currently mapped. + * Since we're internal, we set the saved size to 0 + * so they don't attempt to unmap our fixed VA later. + */ + if (((cn_tab == NULL) || (cp->cn_pri > cn_tab->cn_pri)) + || force) { + cn_tab = cp; + if (convasize) + iounmap(conaddr, convasize); + conscode = -1; + conaddr = va; + convasize = 0; + } + } + + console_scan(dvbox_console_scan, cp); +} + +void +dvboxcninit(cp) + struct consdev *cp; +{ + struct ite_data *ip = &ite_cn; + struct grf_data *gp = &grf_cn; + + /* + * Initialize the framebuffer hardware. + */ + (void)dv_init(gp, conscode, conaddr); + + /* + * Set up required grf data. + */ + gp->g_sw = &dvbox_grfsw; + gp->g_display.gd_id = gp->g_sw->gd_swid; + gp->g_flags = GF_ALIVE; + + /* + * Set up required ite data and initialize ite. + */ + ip->isw = &dvbox_itesw; + ip->grf = gp; + ip->flags = ITE_ALIVE|ITE_CONSOLE|ITE_ACTIVE|ITE_ISCONS; + ip->attrbuf = console_attributes; + iteinit(ip); + + kbd_ite = ip; /* XXX */ +} + +#endif /* NITE > 0 */ +#endif /* NGRF > 0 */ diff --git a/sys/arch/hp300/dev/grf_gb.c b/sys/arch/hp300/dev/grf_gb.c index ee9c0b0310d..a443c74693a 100644 --- a/sys/arch/hp300/dev/grf_gb.c +++ b/sys/arch/hp300/dev/grf_gb.c @@ -1,6 +1,7 @@ -/* $NetBSD: grf_gb.c,v 1.4 1994/10/26 07:23:52 cgd Exp $ */ +/* $NetBSD: grf_gb.c,v 1.7 1996/03/03 16:48:58 thorpej Exp $ */ /* + * Copyright (c) 1996 Jason R. Thorpe. All rights reserved. * Copyright (c) 1988 University of Utah. * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. @@ -53,13 +54,27 @@ * (as in 9837 Gator systems) */ #include +#include #include +#include +#include +#include +#include + +#include +#include + +#include #include #include +#include #include -#include +#include +#include + +#include "ite.h" #define CRTC_DATA_LENGTH 0x0e u_char crtc_init_data[CRTC_DATA_LENGTH] = { @@ -67,13 +82,41 @@ u_char crtc_init_data[CRTC_DATA_LENGTH] = { 0x30, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00 }; +int gb_init __P((struct grf_data *gp, int, caddr_t)); +int gb_mode __P((struct grf_data *gp, int, caddr_t)); +void gb_microcode __P((struct gboxfb *)); + +/* Gatorbox grf switch */ +struct grfsw gbox_grfsw = { + GID_GATORBOX, GRFGATOR, "gatorbox", gb_init, gb_mode +}; + +#if NITE > 0 +void gbox_init __P((struct ite_data *)); +void gbox_deinit __P((struct ite_data *)); +void gbox_putc __P((struct ite_data *, int, int, int, int)); +void gbox_cursor __P((struct ite_data *, int)); +void gbox_clear __P((struct ite_data *, int, int, int, int)); +void gbox_scroll __P((struct ite_data *, int, int, int, int)); +void gbox_windowmove __P((struct ite_data *, int, int, int, int, + int, int, int)); + +/* Gatorbox ite switch */ +struct itesw gbox_itesw = { + gbox_init, gbox_deinit, gbox_clear, gbox_putc, + gbox_cursor, gbox_scroll, ite_readbyte, ite_writeglyph +}; +#endif /* NITE > 0 */ + /* * Initialize hardware. * Must point g_display at a grfinfo structure describing the hardware. * Returns 0 if hardware not present, non-zero ow. */ -gb_init(gp, addr) - struct grf_softc *gp; +int +gb_init(gp, scode, addr) + struct grf_data *gp; + int scode; caddr_t addr; { register struct gboxfb *gbp; @@ -82,51 +125,58 @@ gb_init(gp, addr) int fboff; extern caddr_t sctopa(), iomap(); - gbp = (struct gboxfb *) addr; - if (ISIIOVA(addr)) - gi->gd_regaddr = (caddr_t) IIOP(addr); - else - gi->gd_regaddr = sctopa(vatosc(addr)); - gi->gd_regsize = 0x10000; - gi->gd_fbwidth = 1024; /* XXX */ - gi->gd_fbheight = 1024; /* XXX */ - gi->gd_fbsize = gi->gd_fbwidth * gi->gd_fbheight; - fboff = (gbp->fbomsb << 8) | gbp->fbolsb; - gi->gd_fbaddr = (caddr_t) (*((u_char *)addr + fboff) << 16); - gp->g_regkva = addr; - gp->g_fbkva = iomap(gi->gd_fbaddr, gi->gd_fbsize); - gi->gd_dwidth = 1024; /* XXX */ - gi->gd_dheight = 768; /* XXX */ - gi->gd_planes = 0; /* how do we do this? */ /* - * The minimal register info here is from the Gatorbox X driver. + * If the console has been initialized, and it was us, there's + * no need to repeat this. */ - fbp = (u_char *) gp->g_fbkva; - gbp->write_protect = 0; - gbp->interrupt = 4; /** fb_enable ? **/ - gbp->rep_rule = 3; /* GXcopy */ - gbp->blink1 = 0xff; - gbp->blink2 = 0xff; + if (consinit_active || (scode != conscode)) { + gbp = (struct gboxfb *) addr; + if (ISIIOVA(addr)) + gi->gd_regaddr = (caddr_t) IIOP(addr); + else + gi->gd_regaddr = sctopa(scode); + gi->gd_regsize = 0x10000; + gi->gd_fbwidth = 1024; /* XXX */ + gi->gd_fbheight = 1024; /* XXX */ + gi->gd_fbsize = gi->gd_fbwidth * gi->gd_fbheight; + fboff = (gbp->fbomsb << 8) | gbp->fbolsb; + gi->gd_fbaddr = (caddr_t) (*((u_char *)addr + fboff) << 16); + gp->g_regkva = addr; + gp->g_fbkva = iomap(gi->gd_fbaddr, gi->gd_fbsize); + gi->gd_dwidth = 1024; /* XXX */ + gi->gd_dheight = 768; /* XXX */ + gi->gd_planes = 0; /* how do we do this? */ + /* + * The minimal register info here is from the Gatorbox X driver. + */ + fbp = (u_char *) gp->g_fbkva; + gbp->write_protect = 0; + gbp->interrupt = 4; /** fb_enable ? **/ + gbp->rep_rule = 3; /* GXcopy */ + gbp->blink1 = 0xff; + gbp->blink2 = 0xff; - gb_microcode(gbp); + gb_microcode(gbp); - /* - * Find out how many colors are available by determining - * which planes are installed. That is, write all ones to - * a frame buffer location, see how many ones are read back. - */ - save = *fbp; - *fbp = 0xFF; - gi->gd_colors = *fbp + 1; - *fbp = save; + /* + * Find out how many colors are available by determining + * which planes are installed. That is, write all ones to + * a frame buffer location, see how many ones are read back. + */ + save = *fbp; + *fbp = 0xFF; + gi->gd_colors = *fbp + 1; + *fbp = save; + } return(1); } /* * Program the 6845. */ +void gb_microcode(gbp) - register struct gboxfb *gbp; + struct gboxfb *gbp; { register int i; @@ -141,15 +191,16 @@ gb_microcode(gbp) * Right now all we can do is grfon/grfoff. * Return a UNIX error number or 0 for success. */ +int gb_mode(gp, cmd, data) - register struct grf_softc *gp; + register struct grf_data *gp; int cmd; caddr_t data; { struct gboxfb *gbp; int error = 0; - gbp = (struct gboxfb *) gp->g_regkva; + gbp = (struct gboxfb *)gp->g_regkva; switch (cmd) { case GM_GRFON: gbp->sec_interrupt = 1; @@ -214,4 +265,335 @@ gb_mode(gp, cmd, data) return(error); } +#if NITE > 0 + +/* + * Gatorbox ite routines + */ + +#define REGBASE ((struct gboxfb *)(ip->regbase)) +#define WINDOWMOVER gbox_windowmove + +void +gbox_init(ip) + register struct ite_data *ip; +{ + /* XXX */ + if (ip->regbase == 0) { + struct grf_data *gp = ip->grf; + + ip->regbase = gp->g_regkva; + ip->fbbase = gp->g_fbkva; + ip->fbwidth = gp->g_display.gd_fbwidth; + ip->fbheight = gp->g_display.gd_fbheight; + ip->dwidth = gp->g_display.gd_dwidth; + ip->dheight = gp->g_display.gd_dheight; + } + + REGBASE->write_protect = 0x0; + REGBASE->interrupt = 0x4; + REGBASE->rep_rule = RR_COPY; + REGBASE->blink1 = 0xff; + REGBASE->blink2 = 0xff; + gb_microcode((struct gboxfb *)ip->regbase); + 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); +} + +void +gbox_deinit(ip) + struct ite_data *ip; +{ + gbox_windowmove(ip, 0, 0, 0, 0, ip->dheight, ip->dwidth, RR_CLEAR); + tile_mover_waitbusy(ip->regbase); + + ip->flags &= ~ITE_INITED; +} + +void +gbox_putc(ip, c, dy, dx, mode) + struct ite_data *ip; + int dy, dx; + int c, mode; +{ + register int wrr = ((mode == ATTR_INV) ? RR_COPYINVERTED : RR_COPY); + + gbox_windowmove(ip, charY(ip, c), charX(ip, c), + dy * ip->ftheight, dx * ip->ftwidth, + ip->ftheight, ip->ftwidth, wrr); +} + +void +gbox_cursor(ip, flag) + struct ite_data *ip; + int flag; +{ + if (flag == DRAW_CURSOR) + draw_cursor(ip) + else if (flag == MOVE_CURSOR) { + erase_cursor(ip) + draw_cursor(ip) + } + else + erase_cursor(ip) +} + +void +gbox_clear(ip, sy, sx, h, w) + struct ite_data *ip; + 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) + +void +gbox_scroll(ip, sy, sx, count, dir) + struct ite_data *ip; + int sy, dir, sx, count; +{ + register int height, dy, i; + + tile_mover_waitbusy(ip->regbase); + REGBASE->write_protect = 0x0; + + if (dir == SCROLL_UP) { + 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); + } + else if (dir == SCROLL_DOWN) { + dy = sy + count; + height = ip->rows - dy; + for (i = (height - 1); i >= 0; i--) + gbox_blockmove(ip, sy + i, sx, dy + i, 0, 1, ip->cols); + } + else if (dir == SCROLL_RIGHT) { + gbox_blockmove(ip, sy, sx, sy, sx + count, + 1, ip->cols - (sx + count)); + } + else { + gbox_blockmove(ip, sy, sx, sy, sx - count, + 1, ip->cols - sx); + } +} + +void +gbox_windowmove(ip, sy, sx, dy, dx, h, w, mask) + struct ite_data *ip; + int sy, sx, dy, dx, mask, 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]; +} + +/* + * Gatorbox console support + */ + +int +gbox_console_scan(scode, va, arg) + int scode; + caddr_t va; + void *arg; +{ + struct grfreg *grf = (struct grfreg *)va; + struct consdev *cp = arg; + u_char *dioiidev; + int force = 0, pri; + + if ((grf->gr_id == GRFHWID) && (grf->gr_id2 == GID_GATORBOX)) { + pri = CN_NORMAL; + +#ifdef CONSCODE + /* + * Raise our priority, if appropriate. + */ + if (scode == CONSCODE) { + pri = CN_REMOTE; + force = conforced = 1; + } #endif + + /* Only raise priority. */ + if (pri > cp->cn_pri) + cp->cn_pri = pri; + + /* + * If our priority is higher than the currently-remembered + * console, stash our priority. + */ + if (((cn_tab == NULL) || (cp->cn_pri > cn_tab->cn_pri)) + || force) { + cn_tab = cp; + if (scode >= 132) { + dioiidev = (u_char *)va; + return ((dioiidev[0x101] + 1) * 0x100000); + } + return (DIOCSIZE); + } + } + return (0); +} + +void +gboxcnprobe(cp) + struct consdev *cp; +{ + int maj; + caddr_t va; + struct grfreg *grf; + int force = 0; + + maj = ite_major(); + + /* initialize required fields */ + cp->cn_dev = makedev(maj, 0); /* XXX */ + cp->cn_pri = CN_DEAD; + + /* Abort early if console already forced. */ + if (conforced) + return; + + /* Look for "internal" framebuffer. */ + va = (caddr_t)IIOV(GRFIADDR); + grf = (struct grfreg *)va; + if (!badaddr(va) && + ((grf->gr_id == GRFHWID) && (grf->gr_id2 == GID_GATORBOX))) { + cp->cn_pri = CN_INTERNAL; + +#ifdef CONSCODE + /* + * Raise our priority and save some work, if appropriate. + */ + if (CONSCODE == -1) { + cp->cn_pri = CN_REMOTE; + force = conforced = 1; + } +#endif + + /* + * If our priority is higher than the currently + * remembered console, stash our priority, and + * unmap whichever device might be currently mapped. + * Since we're internal, we set the saved size to 0 + * so they don't attempt to unmap our fixed VA later. + */ + if (((cn_tab == NULL) || (cp->cn_pri > cn_tab->cn_pri)) + || force) { + cn_tab = cp; + if (convasize) + iounmap(conaddr, convasize); + conscode = -1; + conaddr = va; + convasize = 0; + } + } + + console_scan(gbox_console_scan, cp); +} + +void +gboxcninit(cp) + struct consdev *cp; +{ + struct ite_data *ip = &ite_cn; + struct grf_data *gp = &grf_cn; + + /* + * Initialize the framebuffer hardware. + */ + (void)gb_init(gp, conscode, conaddr); + + /* + * Set up required grf data. + */ + gp->g_sw = &gbox_grfsw; + gp->g_display.gd_id = gp->g_sw->gd_swid; + gp->g_flags = GF_ALIVE; + + /* + * Set up required ite data and initialize ite. + */ + ip->isw = &gbox_itesw; + ip->grf = gp; + ip->flags = ITE_ALIVE|ITE_CONSOLE|ITE_ACTIVE|ITE_ISCONS; + ip->attrbuf = console_attributes; + iteinit(ip); + + kbd_ite = ip; /* XXX */ +} + +#endif /* NITE > 0 */ +#endif /* NGRF > 0 */ diff --git a/sys/arch/hp300/dev/grf_hy.c b/sys/arch/hp300/dev/grf_hy.c index a394b737df1..9598a9d4da5 100644 --- a/sys/arch/hp300/dev/grf_hy.c +++ b/sys/arch/hp300/dev/grf_hy.c @@ -1,6 +1,7 @@ -/* $NetBSD: grf_hy.c,v 1.2 1994/10/26 07:23:55 cgd Exp $ */ +/* $NetBSD: grf_hy.c,v 1.5 1996/03/03 16:49:00 thorpej Exp $ */ /* + * Copyright (c) 1996 Jason R. Thorpe. All rights reserved. * Copyright (c) 1991 University of Utah. * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. @@ -50,23 +51,67 @@ * Graphics routines for HYPERION frame buffer */ #include +#include #include +#include +#include +#include +#include +#include + +#include +#include + +#include #include #include +#include #include -#include +#include +#include + +#include "ite.h" caddr_t badhyaddr = (caddr_t) -1; +int hy_init __P((struct grf_data *gp, int, caddr_t)); +int hy_mode __P((struct grf_data *gp, int, caddr_t)); +void hyper_ite_fontinit __P((struct ite_data *)); + +/* Hyperion grf switch */ +struct grfsw hyper_grfsw = { + GID_HYPERION, GRFHYPERION, "hyperion", hy_init, hy_mode +}; + +#if NITE > 0 +void hyper_init __P((struct ite_data *)); +void hyper_deinit __P((struct ite_data *)); +void hyper_int_fontinit __P((struct ite_data *)); +void hyper_putc __P((struct ite_data *, int, int, int, int)); +void hyper_cursor __P((struct ite_data *, int)); +void hyper_clear __P((struct ite_data *, int, int, int, int)); +void hyper_scroll __P((struct ite_data *, int, int, int, int)); +void hyper_windowmove __P((struct ite_data *, int, int, int, int, + int, int, int)); + +/* Hyperion ite switch */ +struct itesw hyper_itesw = { + hyper_init, hyper_deinit, hyper_clear, hyper_putc, + hyper_cursor, hyper_scroll, ite_readbyte, ite_writeglyph +}; +#endif /* NITE > 0 */ + /* * Initialize hardware. * Must fill in the grfinfo structure in g_softc. * Returns 0 if hardware not present, non-zero ow. */ -hy_init(gp, addr) - struct grf_softc *gp; +int +hy_init(gp, scode, addr) + struct grf_data *gp; + int scode; caddr_t addr; { register struct hyboxfb *hy = (struct hyboxfb *) addr; @@ -74,38 +119,45 @@ hy_init(gp, addr) int fboff; extern caddr_t sctopa(), iomap(); - if (ISIIOVA(addr)) - gi->gd_regaddr = (caddr_t) IIOP(addr); - else - gi->gd_regaddr = sctopa(vatosc(addr)); - gi->gd_regsize = 0x20000; - gi->gd_fbwidth = (hy->fbwmsb << 8) | hy->fbwlsb; - gi->gd_fbheight = (hy->fbhmsb << 8) | hy->fbhlsb; - gi->gd_fbsize = (gi->gd_fbwidth * gi->gd_fbheight) >> 3; - fboff = (hy->fbomsb << 8) | hy->fbolsb; - gi->gd_fbaddr = (caddr_t) (*((u_char *)addr + fboff) << 16); - if (gi->gd_regaddr >= (caddr_t)DIOIIBASE) { - /* - * For DIO II space the fbaddr just computed is the offset - * from the select code base (regaddr) of the framebuffer. - * Hence it is also implicitly the size of the register set. - */ - gi->gd_regsize = (int) gi->gd_fbaddr; - gi->gd_fbaddr += (int) gi->gd_regaddr; - gp->g_regkva = addr; - gp->g_fbkva = addr + gi->gd_regsize; - } else { - /* - * For DIO space we need to map the seperate framebuffer. - */ - gp->g_regkva = addr; - gp->g_fbkva = iomap(gi->gd_fbaddr, gi->gd_fbsize); + /* + * If the console has been initialized, and it was us, there's + * no need to repeat this. + */ + if (consinit_active || (scode != conscode)) { + if (ISIIOVA(addr)) + gi->gd_regaddr = (caddr_t) IIOP(addr); + else + gi->gd_regaddr = sctopa(scode); + gi->gd_regsize = 0x20000; + gi->gd_fbwidth = (hy->fbwmsb << 8) | hy->fbwlsb; + gi->gd_fbheight = (hy->fbhmsb << 8) | hy->fbhlsb; + gi->gd_fbsize = (gi->gd_fbwidth * gi->gd_fbheight) >> 3; + fboff = (hy->fbomsb << 8) | hy->fbolsb; + gi->gd_fbaddr = (caddr_t) (*((u_char *)addr + fboff) << 16); + if (gi->gd_regaddr >= (caddr_t)DIOIIBASE) { + /* + * For DIO II space the fbaddr just computed is + * the offset from the select code base (regaddr) + * of the framebuffer. Hence it is also implicitly + * the size of the register set. + */ + gi->gd_regsize = (int) gi->gd_fbaddr; + gi->gd_fbaddr += (int) gi->gd_regaddr; + gp->g_regkva = addr; + gp->g_fbkva = addr + gi->gd_regsize; + } else { + /* + * For DIO space we need to map the seperate + * framebuffer. + */ + gp->g_regkva = addr; + gp->g_fbkva = iomap(gi->gd_fbaddr, gi->gd_fbsize); + } + gi->gd_dwidth = (hy->dwmsb << 8) | hy->dwlsb; + gi->gd_dheight = (hy->dhmsb << 8) | hy->dhlsb; + gi->gd_planes = hy->num_planes; + gi->gd_colors = 1 << gi->gd_planes; } - gi->gd_dwidth = (hy->dwmsb << 8) | hy->dwlsb; - gi->gd_dheight = (hy->dhmsb << 8) | hy->dhlsb; - gi->gd_planes = hy->num_planes; - gi->gd_colors = 1 << gi->gd_planes; - return(1); } @@ -115,8 +167,9 @@ hy_init(gp, addr) * Return a UNIX error number or 0 for success. * Function may not be needed anymore. */ +int hy_mode(gp, cmd, data) - struct grf_softc *gp; + struct grf_data *gp; int cmd; caddr_t data; { @@ -182,4 +235,561 @@ hy_mode(gp, cmd, data) } return(error); } + +#if NITE > 0 + +/* + * Hyperion ite routines + */ + +#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) + +void +hyper_init(ip) + struct ite_data *ip; +{ + int width; + + /* XXX */ + if (ip->regbase == NULL) { + struct grf_data *gp = ip->grf; + + ip->regbase = gp->g_regkva; + ip->fbbase = gp->g_fbkva; + ip->fbwidth = gp->g_display.gd_fbwidth; + ip->fbheight = gp->g_display.gd_fbheight; + ip->dwidth = gp->g_display.gd_dwidth; + ip->dheight = gp->g_display.gd_dheight; + } + + 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; + + /* + * Clear the framebuffer on all planes. + */ + hyper_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR); + + hyper_ite_fontinit(ip); + + REGBASE->nblank = 0x05; + + /* + * Stash the inverted cursor. + */ + hyper_windowmove(ip, charY(ip, ' '), charX(ip, ' '), + ip->cblanky, ip->cblankx, ip->ftheight, + ip->ftwidth, RR_COPYINVERTED); +} + +void +hyper_deinit(ip) + struct ite_data *ip; +{ + hyper_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR); + + REGBASE->nblank = 0x05; + ip->flags &= ~ITE_INITED; +} + +void +hyper_ite_fontinit(ip) + struct ite_data *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; + } + } +} + +void +hyper_putc(ip, c, dy, dx, mode) + struct ite_data *ip; + int c, dy, dx, mode; +{ + int wmrr = ((mode == ATTR_INV) ? RR_COPYINVERTED : RR_COPY); + + hyper_windowmove(ip, charY(ip, c), charX(ip, c), + dy * ip->ftheight, dx * ip->ftwidth, + ip->ftheight, ip->ftwidth, wmrr); +} + +void +hyper_cursor(ip, flag) + struct ite_data *ip; + int flag; +{ + if (flag == DRAW_CURSOR) + draw_cursor(ip) + else if (flag == MOVE_CURSOR) { + erase_cursor(ip) + draw_cursor(ip) + } + else + erase_cursor(ip) +} + +void +hyper_clear(ip, sy, sx, h, w) + struct ite_data *ip; + 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); +} + +void +hyper_scroll(ip, sy, sx, count, dir) + struct ite_data *ip; + int sy, count, dir, sx; +{ + register int dy; + register int dx = sx; + register int height = 1; + register int width = ip->cols; + + if (dir == SCROLL_UP) { + dy = sy - count; + height = ip->rows - sy; + } + else if (dir == SCROLL_DOWN) { + dy = sy + count; + height = ip->rows - dy - 1; + } + else if (dir == SCROLL_RIGHT) { + dy = sy; + dx = sx + count; + width = ip->cols - dx; + } + else { + dy = sy; + dx = sx - count; + width = ip->cols - sx; + } + + hyper_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth, + dy * ip->ftheight, dx * ip->ftwidth, + height * ip->ftheight, + width * ip->ftwidth, RR_COPY); +} + +#include + +/* 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 + }; + +void +hyper_windowmove(ip, sy, sx, dy, dx, h, w, func) + struct ite_data *ip; + int sy, sx, dy, dx, h, w, func; +{ + 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; + + if (sy < dy) /* start at last scanline of rectangle */ + { + psrcLine = ((unsigned int *) ip->fbbase) + ((sy+h-1) * width); + pdstLine = ((unsigned int *) ip->fbbase) + ((dy+h-1) * width); + width = -width; + } + else /* start at first scanline */ + { + 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; + + if (sx >= dx) /* move left to right */ + { + 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; + } + } + else /* move right to left */ + { + pdstLine += (dx+w >> 5); + psrcLine += (sx+w >> 5); + /* if fetch of last partial bits from source crosses + a longword boundary, start at the previous longword + */ + if (xoffSrc + nend >= 32) + --psrcLine; + + while (h--) + { + psrc = psrcLine; + pdst = pdstLine; + + if (endmask) + { + getandputrop0(psrc, xoffSrc, nend, pdst, func); + } + + nl = nlMiddle + 1; + while (--nl) + { + --psrc; + --pdst; + getunalignedword(psrc, xoffSrc, tmpSrc) + DoRop(*pdst, func, tmpSrc, *pdst); + } + + if (startmask) + { + if (srcStartOver) + --psrc; + --pdst; + getandputrop(psrc, (sx & 0x1f), + (dx & 0x1f), nstart, pdst, func) + } + + pdstLine += width; + psrcLine += width; + } + } /* move right to left */ + } +} + +/* + * Hyperion console support + */ + +int +hyper_console_scan(scode, va, arg) + int scode; + caddr_t va; + void *arg; +{ + struct grfreg *grf = (struct grfreg *)va; + struct consdev *cp = arg; + u_char *dioiidev; + int force = 0, pri; + + if ((grf->gr_id == GRFHWID) && (grf->gr_id2 == GID_HYPERION)) { + pri = CN_NORMAL; + +#ifdef CONSCODE + /* + * Raise our prioity, if appropriate. + */ + if (scode == CONSCODE) { + pri = CN_REMOTE; + force = conforced = 1; + } #endif + + /* Only raise priority. */ + if (pri > cp->cn_pri) + cp->cn_pri = pri; + + /* + * If our priority is higher than the currently-remembered + * console, stash our priority. + */ + if (((cn_tab == NULL) || (cp->cn_pri > cn_tab->cn_pri)) + || force) { + cn_tab = cp; + if (scode >= 132) { + dioiidev = (u_char *)va; + return ((dioiidev[0x101] + 1) * 0x100000); + } + return (DIOCSIZE); + } + } + return (0); +} + +void +hypercnprobe(cp) + struct consdev *cp; +{ + int maj; + caddr_t va; + struct grfreg *grf; + int force = 0; + + maj = ite_major(); + + /* initialize required fields */ + cp->cn_dev = makedev(maj, 0); /* XXX */ + cp->cn_pri = CN_DEAD; + + /* Abort early if console is already forced. */ + if (conforced) + return; + + /* Look for "internal" framebuffer. */ + va = (caddr_t)IIOV(GRFIADDR); + grf = (struct grfreg *)va; + if (!badaddr(va) && + ((grf->gr_id == GRFHWID) && (grf->gr_id2 == GID_HYPERION))) { + cp->cn_pri = CN_INTERNAL; + +#ifdef CONSCODE + /* + * Raise our priority and save some work, if appropriate. + */ + if (CONSCODE == -1) { + cp->cn_pri = CN_REMOTE; + force = conforced = 1; + } +#endif + + /* + * If our priority is higher than the currently + * remembered console, stash our priority, and + * unmap whichever device might be currently mapped. + * Since we're internal, we set the saved size to 0 + * so they don't attempt to unmap our fixed VA later. + */ + if (((cn_tab == NULL) || (cp->cn_pri > cn_tab->cn_pri)) + || force) { + cn_tab = cp; + if (convasize) + iounmap(conaddr, convasize); + conscode = -1; + conaddr = va; + convasize = 0; + } + } + + console_scan(hyper_console_scan, cp); +} + +void +hypercninit(cp) + struct consdev *cp; +{ + struct ite_data *ip = &ite_cn; + struct grf_data *gp = &grf_cn; + + /* + * Initialize the framebuffer hardware. + */ + (void)hy_init(gp, conscode, conaddr); + + /* + * Set up required grf data. + */ + gp->g_sw = &hyper_grfsw; + gp->g_display.gd_id = gp->g_sw->gd_swid; + gp->g_flags = GF_ALIVE; + + /* + * Set up required ite data and initialize ite. + */ + ip->isw = &hyper_itesw; + ip->grf = gp; + ip->flags = ITE_ALIVE|ITE_CONSOLE|ITE_ACTIVE|ITE_ISCONS; + ip->attrbuf = console_attributes; + iteinit(ip); + + kbd_ite = ip; /* XXX */ +} + +#endif /* NITE > 0 */ +#endif /* NGRF > 0 */ diff --git a/sys/arch/hp300/dev/grf_machdep.c b/sys/arch/hp300/dev/grf_machdep.c index 9a97a65e38c..5792f6cc14d 100644 --- a/sys/arch/hp300/dev/grf_machdep.c +++ b/sys/arch/hp300/dev/grf_machdep.c @@ -1,6 +1,7 @@ -/* $NetBSD: grf_machdep.c,v 1.3 1995/12/02 18:21:58 thorpej Exp $ */ +/* $NetBSD: grf_machdep.c,v 1.4 1996/02/24 00:55:13 thorpej Exp $ */ /* + * Copyright (c) 1996 Jason R. Thorpe. All rights reserved. * Copyright (c) 1991 University of Utah. * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. @@ -51,83 +52,78 @@ #if NGRF > 0 #include +#include +#include + +#include #include #include #include #include +#include + +#include "ite.h" + int grfmatch(); void grfattach(); -struct driver grfdriver = { grfmatch, grfattach, "grf" }; -/* - * XXX called from ite console init routine. - * Does just what configure will do later but without printing anything. - */ -grfconfig() -{ - register caddr_t addr; - register struct hp_hw *hw; - register struct hp_device *hd, *nhd; +int grfinit __P((struct hp_device *, struct grf_data *, int)); - for (hw = sc_table; hw->hw_type; hw++) { - if (!HW_ISDEV(hw, D_BITMAP)) - continue; - /* - * Found one, now match up with a logical unit number - */ - nhd = NULL; - addr = hw->hw_kva; - for (hd = hp_dinit; hd->hp_driver; hd++) { - if (hd->hp_driver != &grfdriver || hd->hp_alive) - continue; - /* - * Wildcarded. If first, remember as possible match. - */ - if (hd->hp_addr == NULL) { - if (nhd == NULL) - nhd = hd; - continue; - } - /* - * Not wildcarded. - * If exact match done searching, else keep looking. - */ - if (sctova(hd->hp_addr) == addr) { - nhd = hd; - break; - } - } - /* - * Found a match, initialize - */ - if (nhd && grfinit(addr, nhd->hp_unit)) - nhd->hp_addr = addr; - } -} +struct driver grfdriver = { grfmatch, grfattach, "grf" }; -/* - * Normal init routine called by configure() code - */ int grfmatch(hd) struct hp_device *hd; { - struct grf_softc *gp = &grf_softc[hd->hp_unit]; + struct grf_softc *sc = &grf_softc[hd->hp_unit]; + int scode; - if ((gp->g_flags & GF_ALIVE) == 0 && - !grfinit(hd->hp_addr, hd->hp_unit)) + if (hd->hp_args->hw_pa == (caddr_t)GRFIADDR) /* XXX */ + scode = -1; + else + scode = hd->hp_args->hw_sc; + + if (scode == conscode) { + /* + * We've already been initialized. + */ + sc->sc_data = &grf_cn; + return (1); + } + + /* + * Allocate storage space for the grf_data. + */ + sc->sc_data = (struct grf_data *)malloc(sizeof(struct grf_data), + M_DEVBUF, M_NOWAIT); + if (sc->sc_data == NULL) { + printf("grfmatch: malloc for grf_data failed\n"); return (0); + } + bzero(sc->sc_data, sizeof(struct grf_data)); - return(1); + return (grfinit(hd, sc->sc_data, scode)); } void grfattach(hd) struct hp_device *hd; { - struct grf_softc *gp = &grf_softc[hd->hp_unit]; + struct grf_softc *sc = &grf_softc[hd->hp_unit]; + struct grf_data *gp = sc->sc_data; + int scode, isconsole; + + if (hd->hp_args->hw_pa == (caddr_t)GRFIADDR) /* XXX */ + scode = -1; + else + scode = hd->hp_args->hw_sc; + + if (scode == conscode) + isconsole = 1; + else + isconsole = 0; printf(": %d x %d ", gp->g_display.gd_dwidth, gp->g_display.gd_dheight); @@ -135,24 +131,37 @@ grfattach(hd) printf("monochrome"); else printf("%d color", gp->g_display.gd_colors); - printf(" %s display\n", gp->g_sw->gd_desc); + printf(" %s display", gp->g_sw->gd_desc); + if (isconsole) + printf(" (console)"); + printf("\n"); + +#if NITE > 0 + /* XXX hack */ + ite_attach_grf(hd->hp_unit, isconsole); +#endif /* NITE > 0 */ } -grfinit(addr, unit) - caddr_t addr; - int unit; +int +grfinit(hd, gp, scode) + struct hp_device *hd; + struct grf_data *gp; + int scode; { - struct grf_softc *gp = &grf_softc[unit]; register struct grfsw *gsw; struct grfreg *gr; + caddr_t addr = hd->hp_addr; + int i; gr = (struct grfreg *) addr; if (gr->gr_id != GRFHWID) return(0); - for (gsw = grfsw; gsw < &grfsw[ngrfsw]; gsw++) + for (i = 0; i < ngrfsw; ++i) { + gsw = grfsw[i]; if (gsw->gd_hwid == gr->gr_id2) break; - if (gsw < &grfsw[ngrfsw] && (*gsw->gd_init)(gp, addr)) { + } + if ((i < ngrfsw) && (*gsw->gd_init)(gp, scode, addr)) { gp->g_sw = gsw; gp->g_display.gd_id = gsw->gd_swid; gp->g_flags = GF_ALIVE; @@ -160,4 +169,4 @@ grfinit(addr, unit) } return(0); } -#endif +#endif /* NGRF > 0 */ diff --git a/sys/arch/hp300/dev/grf_rb.c b/sys/arch/hp300/dev/grf_rb.c index 964be4f7feb..d06d7d72f79 100644 --- a/sys/arch/hp300/dev/grf_rb.c +++ b/sys/arch/hp300/dev/grf_rb.c @@ -1,6 +1,7 @@ -/* $NetBSD: grf_rb.c,v 1.4 1994/10/26 07:24:01 cgd Exp $ */ +/* $NetBSD: grf_rb.c,v 1.7 1996/03/03 16:49:02 thorpej Exp $ */ /* + * Copyright (c) 1996 Jason R. Thorpe. All rights reserved. * Copyright (c) 1988 University of Utah. * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. @@ -49,21 +50,62 @@ * Graphics routines for the Renaissance, HP98720 Graphics system. */ #include +#include #include +#include +#include +#include +#include + +#include +#include + +#include #include #include +#include #include -#include +#include +#include + +#include "ite.h" + +int rb_init __P((struct grf_data *gp, int, caddr_t)); +int rb_mode __P((struct grf_data *gp, int, caddr_t)); + +/* Renaissance grf switch */ +struct grfsw rbox_grfsw = { + GID_RENAISSANCE, GRFRBOX, "renaissance", rb_init, rb_mode +}; + +#if NITE > 0 +void rbox_init __P((struct ite_data *)); +void rbox_deinit __P((struct ite_data *)); +void rbox_putc __P((struct ite_data *, int, int, int, int)); +void rbox_cursor __P((struct ite_data *, int)); +void rbox_clear __P((struct ite_data *, int, int, int, int)); +void rbox_scroll __P((struct ite_data *, int, int, int, int)); +void rbox_windowmove __P((struct ite_data *, int, int, int, int, + int, int, int)); + +/* Renaissance ite switch */ +struct itesw rbox_itesw = { + rbox_init, rbox_deinit, rbox_clear, rbox_putc, + rbox_cursor, rbox_scroll, ite_readbyte, ite_writeglyph +}; +#endif /* NITE > 0 */ /* * Initialize hardware. * Must point g_display at a grfinfo structure describing the hardware. * Returns 0 if hardware not present, non-zero ow. */ -rb_init(gp, addr) - struct grf_softc *gp; +int +rb_init(gp, scode, addr) + struct grf_data *gp; + int scode; caddr_t addr; { register struct rboxfb *rbp; @@ -71,38 +113,46 @@ rb_init(gp, addr) int fboff; extern caddr_t sctopa(), iomap(); - rbp = (struct rboxfb *) addr; - if (ISIIOVA(addr)) - gi->gd_regaddr = (caddr_t) IIOP(addr); - else - gi->gd_regaddr = sctopa(vatosc(addr)); - gi->gd_regsize = 0x20000; - gi->gd_fbwidth = (rbp->fbwmsb << 8) | rbp->fbwlsb; - gi->gd_fbheight = (rbp->fbhmsb << 8) | rbp->fbhlsb; - gi->gd_fbsize = gi->gd_fbwidth * gi->gd_fbheight; - fboff = (rbp->fbomsb << 8) | rbp->fbolsb; - gi->gd_fbaddr = (caddr_t) (*((u_char *)addr + fboff) << 16); - if (gi->gd_regaddr >= (caddr_t)DIOIIBASE) { - /* - * For DIO II space the fbaddr just computed is the offset - * from the select code base (regaddr) of the framebuffer. - * Hence it is also implicitly the size of the register set. - */ - gi->gd_regsize = (int) gi->gd_fbaddr; - gi->gd_fbaddr += (int) gi->gd_regaddr; - gp->g_regkva = addr; - gp->g_fbkva = addr + gi->gd_regsize; - } else { - /* - * For DIO space we need to map the seperate framebuffer. - */ - gp->g_regkva = addr; - gp->g_fbkva = iomap(gi->gd_fbaddr, gi->gd_fbsize); + /* + * If the console has been initialized, and it was us, there's + * no need to repeat this. + */ + if (consinit_active || (scode != conscode)) { + rbp = (struct rboxfb *) addr; + if (ISIIOVA(addr)) + gi->gd_regaddr = (caddr_t) IIOP(addr); + else + gi->gd_regaddr = sctopa(scode); + gi->gd_regsize = 0x20000; + gi->gd_fbwidth = (rbp->fbwmsb << 8) | rbp->fbwlsb; + gi->gd_fbheight = (rbp->fbhmsb << 8) | rbp->fbhlsb; + gi->gd_fbsize = gi->gd_fbwidth * gi->gd_fbheight; + fboff = (rbp->fbomsb << 8) | rbp->fbolsb; + gi->gd_fbaddr = (caddr_t) (*((u_char *)addr + fboff) << 16); + if (gi->gd_regaddr >= (caddr_t)DIOIIBASE) { + /* + * For DIO II space the fbaddr just computed is + * the offset from the select code base (regaddr) + * of the framebuffer. Hence it is also implicitly + * the size of the register set. + */ + gi->gd_regsize = (int) gi->gd_fbaddr; + gi->gd_fbaddr += (int) gi->gd_regaddr; + gp->g_regkva = addr; + gp->g_fbkva = addr + gi->gd_regsize; + } else { + /* + * For DIO space we need to map the seperate + * framebuffer. + */ + gp->g_regkva = addr; + gp->g_fbkva = iomap(gi->gd_fbaddr, gi->gd_fbsize); + } + gi->gd_dwidth = (rbp->dwmsb << 8) | rbp->dwlsb; + gi->gd_dheight = (rbp->dwmsb << 8) | rbp->dwlsb; + gi->gd_planes = 0; /* ?? */ + gi->gd_colors = 256; } - gi->gd_dwidth = (rbp->dwmsb << 8) | rbp->dwlsb; - gi->gd_dheight = (rbp->dwmsb << 8) | rbp->dwlsb; - gi->gd_planes = 0; /* ?? */ - gi->gd_colors = 256; return(1); } @@ -111,8 +161,9 @@ rb_init(gp, addr) * Right now all we can do is grfon/grfoff. * Return a UNIX error number or 0 for success. */ +int rb_mode(gp, cmd, data) - register struct grf_softc *gp; + register struct grf_data *gp; int cmd; caddr_t data; { @@ -196,4 +247,350 @@ rb_mode(gp, cmd, data) return(error); } +#if NITE > 0 + +/* + * Renaissance ite routines + */ + +#define REGBASE ((struct rboxfb *)(ip->regbase)) +#define WINDOWMOVER rbox_windowmove + +void +rbox_init(ip) + struct ite_data *ip; +{ + register int i; + + /* XXX */ + if (ip->regbase == 0) { + struct grf_data *gp = ip->grf; + + ip->regbase = gp->g_regkva; + ip->fbbase = gp->g_fbkva; + ip->fbwidth = gp->g_display.gd_fbwidth; + ip->fbheight = gp->g_display.gd_fbheight; + ip->dwidth = gp->g_display.gd_dwidth; + ip->dheight = gp->g_display.gd_dheight; + /* + * 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; + } + + rb_waitbusy(ip->regbase); + + REGBASE->reset = 0x39; + DELAY(1000); + + 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); +} + +void +rbox_deinit(ip) + struct ite_data *ip; +{ + rbox_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR); + rb_waitbusy(ip->regbase); + + ip->flags &= ~ITE_INITED; +} + +void +rbox_putc(ip, c, dy, dx, mode) + struct ite_data *ip; + int dy, dx, c, mode; +{ + register int wrr = ((mode == ATTR_INV) ? RR_COPYINVERTED : RR_COPY); + + rbox_windowmove(ip, charY(ip, c), charX(ip, c), + dy * ip->ftheight, dx * ip->ftwidth, + ip->ftheight, ip->ftwidth, wrr); +} + +void +rbox_cursor(ip, flag) + struct ite_data *ip; + int flag; +{ + if (flag == DRAW_CURSOR) + draw_cursor(ip) + else if (flag == MOVE_CURSOR) { + erase_cursor(ip) + draw_cursor(ip) + } + else + erase_cursor(ip) +} + +void +rbox_clear(ip, sy, sx, h, w) + struct ite_data *ip; + 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); +} + +void +rbox_scroll(ip, sy, sx, count, dir) + struct ite_data *ip; + int sy, count, dir, sx; +{ + register int dy; + register int dx = sx; + register int height = 1; + register int width = ip->cols; + + if (dir == SCROLL_UP) { + dy = sy - count; + height = ip->rows - sy; + } + else if (dir == SCROLL_DOWN) { + dy = sy + count; + height = ip->rows - dy - 1; + } + else if (dir == SCROLL_RIGHT) { + dy = sy; + dx = sx + count; + width = ip->cols - dx; + } + else { + dy = sy; + dx = sx - count; + width = ip->cols - sx; + } + + rbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth, + dy * ip->ftheight, dx * ip->ftwidth, + height * ip->ftheight, + width * ip->ftwidth, RR_COPY); +} + +void +rbox_windowmove(ip, sy, sx, dy, dx, h, w, func) + struct ite_data *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; +} + +/* + * Renaissance console support + */ + +int +rbox_console_scan(scode, va, arg) + int scode; + caddr_t va; + void *arg; +{ + struct grfreg *grf = (struct grfreg *)va; + struct consdev *cp = arg; + u_char *dioiidev; + int force = 0, pri; + + if ((grf->gr_id == GRFHWID) && (grf->gr_id2 == GID_RENAISSANCE)) { + pri = CN_NORMAL; + +#ifdef CONSCODE + /* + * Raise our priority, if appropriate. + */ + if (scode == CONSCODE) { + pri = CN_REMOTE; + force = conforced = 1; + } +#endif + + /* Only raise priority. */ + if (pri > cp->cn_pri) + cp->cn_pri = pri; + + /* + * If our priority is higher than the currently-remembered + * console, stash our priority. + */ + if (((cn_tab == NULL) || (cp->cn_pri > cn_tab->cn_pri)) + || force) { + cn_tab = cp; + if (scode >= 132) { + dioiidev = (u_char *)va; + return ((dioiidev[0x101] + 1) * 0x100000); + } + return (DIOCSIZE); + } + } + return (0); +} + +void +rboxcnprobe(cp) + struct consdev *cp; +{ + int maj; + caddr_t va; + struct grfreg *grf; + int force = 0; + + maj = ite_major(); + + /* initialize required fields */ + cp->cn_dev = makedev(maj, 0); /* XXX */ + cp->cn_pri = CN_DEAD; + + /* Abort early if console is already forced. */ + if (conforced) + return; + + /* Look for "internal" framebuffer. */ + va = (caddr_t)IIOV(GRFIADDR); + grf = (struct grfreg *)va; + if (!badaddr(va) && + ((grf->gr_id == GRFHWID) && (grf->gr_id2 == GID_RENAISSANCE))) { + cp->cn_pri = CN_INTERNAL; + +#ifdef CONSCODE + /* + * Raise our priority and save some work, if appropriate. + */ + if (CONSCODE == -1) { + cp->cn_pri = CN_REMOTE; + force = conforced = 1; + } #endif + + /* + * If our priority is higher than the currently + * remembered console, stash our priority, and + * unmap whichever device might be currently mapped. + * Since we're internal, we set the saved size to 0 + * so they don't attempt to unmap our fixed VA later. + */ + if (((cn_tab == NULL) || (cp->cn_pri > cn_tab->cn_pri)) + || force) { + cn_tab = cp; + if (convasize) + iounmap(conaddr, convasize); + conscode = -1; + conaddr = va; + convasize = 0; + } + } + + console_scan(rbox_console_scan, cp); +} + +void +rboxcninit(cp) + struct consdev *cp; +{ + struct ite_data *ip = &ite_cn; + struct grf_data *gp = &grf_cn; + + /* + * Initialize the framebuffer hardware. + */ + (void)rb_init(gp, conscode, conaddr); + + /* + * Set up required grf data. + */ + gp->g_sw = &rbox_grfsw; + gp->g_display.gd_id = gp->g_sw->gd_swid; + gp->g_flags = GF_ALIVE; + + /* + * Set up required ite data and initialize ite. + */ + ip->isw = &rbox_itesw; + ip->grf = gp; + ip->flags = ITE_ALIVE|ITE_CONSOLE|ITE_ACTIVE|ITE_ISCONS; + ip->attrbuf = console_attributes; + iteinit(ip); + + kbd_ite = ip; /* XXX */ +} + +#endif /* NITE > 0 */ +#endif /* NGRF > 0 */ diff --git a/sys/arch/hp300/dev/grf_tc.c b/sys/arch/hp300/dev/grf_tc.c index 1e580b13b00..fdde9bbaea4 100644 --- a/sys/arch/hp300/dev/grf_tc.c +++ b/sys/arch/hp300/dev/grf_tc.c @@ -1,6 +1,7 @@ -/* $NetBSD: grf_tc.c,v 1.4 1994/10/26 07:24:04 cgd Exp $ */ +/* $NetBSD: grf_tc.c,v 1.7 1996/03/03 16:49:04 thorpej Exp $ */ /* + * Copyright (c) 1996 Jason R. Thorpe. All rights reserved. * Copyright (c) 1988 University of Utah. * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. @@ -49,22 +50,77 @@ * Graphics routines for TOPCAT and CATSEYE frame buffers */ #include +#include #include +#include +#include +#include +#include + +#include +#include + +#include #include #include #include #include -#include +#include +#include + +#include "ite.h" + +int tc_init __P((struct grf_data *, int, caddr_t)); +int tc_mode __P((struct grf_data *, int, caddr_t)); + +/* Topcat (bobcat) grf switch */ +struct grfsw topcat_grfsw = { + GID_TOPCAT, GRFBOBCAT, "topcat", tc_init, tc_mode +}; + +/* Lo-res catseye grf switch */ +struct grfsw lrcatseye_grfsw = { + GID_LRCATSEYE, GRFCATSEYE, "lo-res catseye", tc_init, tc_mode +}; + +/* Hi-res catseye grf switch */ +struct grfsw hrcatseye_grfsw = { + GID_HRCCATSEYE, GRFCATSEYE, "hi-res catseye", tc_init, tc_mode +}; + +/* Hi-res monochrome catseye grf switch */ +struct grfsw hrmcatseye_grfsw = { + GID_HRMCATSEYE, GRFCATSEYE, "hi-res catseye", tc_init, tc_mode +}; + +#if NITE > 0 +void topcat_init __P((struct ite_data *)); +void topcat_deinit __P((struct ite_data *)); +void topcat_putc __P((struct ite_data *, int, int, int, int)); +void topcat_cursor __P((struct ite_data *, int)); +void topcat_clear __P((struct ite_data *, int, int, int, int)); +void topcat_scroll __P((struct ite_data *, int, int, int, int)); +void topcat_windowmove __P((struct ite_data *, int, int, int, int, + int, int, int)); + +/* Topcat/catseye ite switch */ +struct itesw topcat_itesw = { + topcat_init, topcat_deinit, topcat_clear, topcat_putc, + topcat_cursor, topcat_scroll, ite_readbyte, ite_writeglyph +}; +#endif /* NITE > 0 */ /* * Initialize hardware. * Must fill in the grfinfo structure in g_softc. * Returns 0 if hardware not present, non-zero ow. */ -tc_init(gp, addr) - struct grf_softc *gp; +int +tc_init(gp, scode, addr) + struct grf_data *gp; + int scode; caddr_t addr; { register struct tcboxfb *tp = (struct tcboxfb *) addr; @@ -72,48 +128,56 @@ tc_init(gp, addr) volatile u_char *fbp; u_char save; int fboff; - extern caddr_t sctopa(), iomap(); + extern caddr_t sctopa(); - if (ISIIOVA(addr)) - gi->gd_regaddr = (caddr_t) IIOP(addr); - else - gi->gd_regaddr = sctopa(vatosc(addr)); - gi->gd_regsize = 0x10000; - gi->gd_fbwidth = (tp->fbwmsb << 8) | tp->fbwlsb; - gi->gd_fbheight = (tp->fbhmsb << 8) | tp->fbhlsb; - gi->gd_fbsize = gi->gd_fbwidth * gi->gd_fbheight; - fboff = (tp->fbomsb << 8) | tp->fbolsb; - gi->gd_fbaddr = (caddr_t) (*((u_char *)addr + fboff) << 16); - if (gi->gd_regaddr >= (caddr_t)DIOIIBASE) { - /* - * For DIO II space the fbaddr just computed is the offset - * from the select code base (regaddr) of the framebuffer. - * Hence it is also implicitly the size of the register set. - */ - gi->gd_regsize = (int) gi->gd_fbaddr; - gi->gd_fbaddr += (int) gi->gd_regaddr; - gp->g_regkva = addr; - gp->g_fbkva = addr + gi->gd_regsize; - } else { - /* - * For DIO space we need to map the seperate framebuffer. - */ - gp->g_regkva = addr; - gp->g_fbkva = iomap(gi->gd_fbaddr, gi->gd_fbsize); - } - gi->gd_dwidth = (tp->dwmsb << 8) | tp->dwlsb; - gi->gd_dheight = (tp->dhmsb << 8) | tp->dhlsb; - gi->gd_planes = tp->num_planes; - gi->gd_colors = 1 << gi->gd_planes; - if (gi->gd_colors == 1) { - fbp = (u_char *) gp->g_fbkva; - tp->wen = ~0; - tp->prr = 0x3; - tp->fben = ~0; - save = *fbp; - *fbp = 0xFF; - gi->gd_colors = *fbp + 1; - *fbp = save; + /* + * If the console has been initialized, and it was us, there's + * no need to repeat this. + */ + if (consinit_active || (scode != conscode)) { + if (ISIIOVA(addr)) + gi->gd_regaddr = (caddr_t) IIOP(addr); + else + gi->gd_regaddr = sctopa(scode); + gi->gd_regsize = 0x10000; + gi->gd_fbwidth = (tp->fbwmsb << 8) | tp->fbwlsb; + gi->gd_fbheight = (tp->fbhmsb << 8) | tp->fbhlsb; + gi->gd_fbsize = gi->gd_fbwidth * gi->gd_fbheight; + fboff = (tp->fbomsb << 8) | tp->fbolsb; + gi->gd_fbaddr = (caddr_t) (*((u_char *)addr + fboff) << 16); + if (gi->gd_regaddr >= (caddr_t)DIOIIBASE) { + /* + * For DIO II space the fbaddr just computed is the + * offset from the select code base (regaddr) of the + * framebuffer. Hence it is also implicitly the + * size of the register set. + */ + gi->gd_regsize = (int) gi->gd_fbaddr; + gi->gd_fbaddr += (int) gi->gd_regaddr; + gp->g_regkva = addr; + gp->g_fbkva = addr + gi->gd_regsize; + } else { + /* + * For DIO space we need to map the seperate + * framebuffer. + */ + gp->g_regkva = addr; + gp->g_fbkva = iomap(gi->gd_fbaddr, gi->gd_fbsize); + } + gi->gd_dwidth = (tp->dwmsb << 8) | tp->dwlsb; + gi->gd_dheight = (tp->dhmsb << 8) | tp->dhlsb; + gi->gd_planes = tp->num_planes; + gi->gd_colors = 1 << gi->gd_planes; + if (gi->gd_colors == 1) { + fbp = (u_char *) gp->g_fbkva; + tp->wen = ~0; + tp->prr = 0x3; + tp->fben = ~0; + save = *fbp; + *fbp = 0xFF; + gi->gd_colors = *fbp + 1; + *fbp = save; + } } return(1); } @@ -125,8 +189,9 @@ tc_init(gp, addr) * Function may not be needed anymore. */ /*ARGSUSED*/ +int tc_mode(gp, cmd, data) - struct grf_softc *gp; + struct grf_data *gp; int cmd; caddr_t data; { @@ -216,4 +281,398 @@ tc_mode(gp, cmd, data) } return(error); } + +#if NITE > 0 + +/* + * Topcat/catseye ite routines + */ + +#define REGBASE ((struct tcboxfb *)(ip->regbase)) +#define WINDOWMOVER topcat_windowmove + +void +topcat_init(ip) + struct ite_data *ip; +{ + /* XXX */ + if (ip->regbase == NULL) { + struct grf_data *gp = ip->grf; + + ip->regbase = gp->g_regkva; + ip->fbbase = gp->g_fbkva; + ip->fbwidth = gp->g_display.gd_fbwidth; + ip->fbheight = gp->g_display.gd_fbheight; + ip->dwidth = gp->g_display.gd_dwidth; + ip->dheight = gp->g_display.gd_dheight; + } + + /* + * 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); + + /* + * Initialize color map for color displays + */ + if (ip->planemask != 1) { + tc_waitbusy(ip->regbase, ip->planemask); + REGBASE->nblank = 0x01; + + tccm_waitbusy(ip->regbase); + REGBASE->rdata = 0x0; + REGBASE->gdata = 0x0; + REGBASE->bdata = 0x0; + REGBASE->cindex = 0xFF; + REGBASE->strobe = 0xFF; + + DELAY(100); + tccm_waitbusy(ip->regbase); + REGBASE->rdata = 0x0; + REGBASE->gdata = 0x0; + REGBASE->bdata = 0x0; + REGBASE->cindex = 0x0; + + DELAY(100); + tccm_waitbusy(ip->regbase); + REGBASE->rdata = 0xFF; + REGBASE->gdata = 0xFF; + REGBASE->bdata = 0xFF; + REGBASE->cindex = 0xFE; + REGBASE->strobe = 0xFF; + + DELAY(100); + tccm_waitbusy(ip->regbase); + REGBASE->rdata = 0x0; + REGBASE->gdata = 0x0; + REGBASE->bdata = 0x0; + REGBASE->cindex = 0x0; + } + + /* + * Stash the inverted cursor. + */ + topcat_windowmove(ip, charY(ip, ' '), charX(ip, ' '), + ip->cblanky, ip->cblankx, ip->ftheight, + ip->ftwidth, RR_COPYINVERTED); +} + +void +topcat_deinit(ip) + struct ite_data *ip; +{ + topcat_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR); + tc_waitbusy(ip->regbase, ip->planemask); + + REGBASE->nblank = ~0; + ip->flags &= ~ITE_INITED; +} + +void +topcat_putc(ip, c, dy, dx, mode) + struct ite_data *ip; + int c, dy, dx, mode; +{ + int wmrr = ((mode == ATTR_INV) ? RR_COPYINVERTED : RR_COPY); + + topcat_windowmove(ip, charY(ip, c), charX(ip, c), + dy * ip->ftheight, dx * ip->ftwidth, + ip->ftheight, ip->ftwidth, wmrr); +} + +void +topcat_cursor(ip, flag) + struct ite_data *ip; + int flag; +{ + if (flag == DRAW_CURSOR) + draw_cursor(ip) + else if (flag == MOVE_CURSOR) { + erase_cursor(ip) + draw_cursor(ip) + } + else + erase_cursor(ip) +} + +void +topcat_clear(ip, sy, sx, h, w) + struct ite_data *ip; + 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); +} + +void +topcat_scroll(ip, sy, sx, count, dir) + struct ite_data *ip; + int sy, count, dir, sx; +{ + register int dy; + register int dx = sx; + register int height = 1; + register int width = ip->cols; + + if (dir == SCROLL_UP) { + dy = sy - count; + height = ip->rows - sy; + } + else if (dir == SCROLL_DOWN) { + dy = sy + count; + height = ip->rows - dy - 1; + } + else if (dir == SCROLL_RIGHT) { + dy = sy; + dx = sx + count; + width = ip->cols - dx; + } + else { + dy = sy; + dx = sx - count; + width = ip->cols - sx; + } + + topcat_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth, + dy * ip->ftheight, dx * ip->ftwidth, + height * ip->ftheight, + width * ip->ftwidth, RR_COPY); +} + +void +topcat_windowmove(ip, sy, sx, dy, dx, h, w, func) + struct ite_data *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; +} + +/* + * Topcat/catseye console support + */ + +int +topcat_console_scan(scode, va, arg) + int scode; + caddr_t va; + void *arg; +{ + struct grfreg *grf = (struct grfreg *)va; + struct consdev *cp = arg; + u_char *dioiidev; + int force = 0, pri; + + if (grf->gr_id != GRFHWID) + return (0); + + switch (grf->gr_id2) { + case GID_TOPCAT: + case GID_LRCATSEYE: + case GID_HRCCATSEYE: + case GID_HRMCATSEYE: + break; + + default: + return (0); + } + + pri = CN_NORMAL; + +#ifdef CONSCODE + /* + * Raise our priority, if appropriate. + */ + if (scode == CONSCODE) { + pri = CN_REMOTE; + force = conforced = 1; + } +#endif + + /* Only raise priority. */ + if (pri > cp->cn_pri) + cp->cn_pri = pri; + + /* + * If our priority is higher than the currently-remembered + * console, stash our priority. + */ + if (((cn_tab == NULL) || (cp->cn_pri > cn_tab->cn_pri)) || force) { + cn_tab = cp; + if (scode >= 132) { + dioiidev = (u_char *)va; + return ((dioiidev[0x101] + 1) * 0x100000); + } + return (DIOCSIZE); + } + return (0); +} + +void +topcatcnprobe(cp) + struct consdev *cp; +{ + int maj; + caddr_t va; + struct grfreg *grf; + int force = 0; + + maj = ite_major(); + + /* initialize required fields */ + cp->cn_dev = makedev(maj, 0); /* XXX */ + cp->cn_pri = CN_DEAD; + + /* Abort early if the console is already forced. */ + if (conforced) + return; + + /* Look for "internal" framebuffer. */ + va = (caddr_t)IIOV(GRFIADDR); + grf = (struct grfreg *)va; + if (!badaddr(va) && (grf->gr_id == GRFHWID)) { + switch (grf->gr_id2) { + case GID_TOPCAT: + case GID_LRCATSEYE: + case GID_HRCCATSEYE: + case GID_HRMCATSEYE: + cp->cn_pri = CN_INTERNAL; + +#ifdef CONSCODE + /* + * Raise our priority and save some work, + * if appropriate. + */ + if (CONSCODE == -1) { + cp->cn_pri = CN_REMOTE; + force = conforced = 1; + } #endif + + /* + * If our priority is higher than the currently + * remembered console, stash our priority, and unmap + * whichever device might be currently mapped. + * Since we're internal, we set the saved size to 0 + * so they don't attempt to unmap our fixed VA later. + */ + if (((cn_tab == NULL) || (cp->cn_pri > cn_tab->cn_pri)) + || force) { + cn_tab = cp; + if (convasize) + iounmap(conaddr, convasize); + conscode = -1; + conaddr = va; + convasize = 0; + } + } + } + + console_scan(topcat_console_scan, cp); +} + +void +topcatcninit(cp) + struct consdev *cp; +{ + struct ite_data *ip = &ite_cn; + struct grf_data *gp = &grf_cn; + struct grfreg *grf = (struct grfreg *)conaddr; + + /* + * Initialize the framebuffer hardware. + */ + (void)tc_init(gp, conscode, conaddr); + + /* + * Set up required grf data. + */ + switch (grf->gr_id2) { + case GID_TOPCAT: + gp->g_sw = &topcat_grfsw; + break; + + case GID_LRCATSEYE: + gp->g_sw = &lrcatseye_grfsw; + break; + + case GID_HRCCATSEYE: + gp->g_sw = &hrcatseye_grfsw; + break; + + case GID_HRMCATSEYE: + gp->g_sw = &hrmcatseye_grfsw; + break; + + default: + /* THIS SHOULD NEVER HAPPEN! */ + panic("topcat console: impossible!"); /* XXX won't see it */ + } + gp->g_display.gd_id = gp->g_sw->gd_swid; + gp->g_flags = GF_ALIVE; + + /* + * Set up required ite data and initialize ite. + */ + ip->isw = &topcat_itesw; + ip->grf = gp; + ip->flags = ITE_ALIVE|ITE_CONSOLE|ITE_ACTIVE|ITE_ISCONS; + ip->attrbuf = console_attributes; + iteinit(ip); + + kbd_ite = ip; /* XXX */ +} + +#endif /* NITE > 0 */ +#endif /* NGRF > 0 */ diff --git a/sys/arch/hp300/dev/grfvar.h b/sys/arch/hp300/dev/grfvar.h index 3bd6a12f173..f6f02a0158f 100644 --- a/sys/arch/hp300/dev/grfvar.h +++ b/sys/arch/hp300/dev/grfvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: grfvar.h,v 1.6 1995/03/28 18:16:06 jtc Exp $ */ +/* $NetBSD: grfvar.h,v 1.7 1996/02/24 00:55:18 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -49,19 +49,8 @@ struct grf_lockpage { }; #define gl_lockslot gl_locks[0] -/* - * Static configuration info for display types - */ -struct grfsw { - int gd_hwid; /* id returned by hardware */ - int gd_swid; /* id to be returned by software */ - char *gd_desc; /* description printed at config time */ - int (*gd_init)(); /* boot time init routine */ - int (*gd_mode)(); /* misc function routine */ -}; - /* per display info */ -struct grf_softc { +struct grf_data { int g_flags; /* software flags */ struct grfsw *g_sw; /* static configuration info */ caddr_t g_regkva; /* KVA of registers */ @@ -74,6 +63,24 @@ struct grf_softc { caddr_t g_data; /* device dependent data */ }; +/* + * Static configuration info for display types + */ +struct grfsw { + int gd_hwid; /* id returned by hardware */ + int gd_swid; /* id to be returned by software */ + char *gd_desc; /* description printed at config time */ + /* boot time init routine */ + int (*gd_init) __P((struct grf_data *, int, caddr_t)); + /* misc function routine */ + int (*gd_mode) __P((struct grf_data *, int, caddr_t)); +}; + +struct grf_softc { + struct grf_data *sc_data; /* display state information */ + struct ite_softc *sc_ite; /* pointer to ite; may be NULL */ +}; + /* flags */ #define GF_ALIVE 0x01 #define GF_OPEN 0x02 @@ -97,7 +104,8 @@ struct grf_softc { #define GRFUNIT(d) ((d) & 0x7) #ifdef _KERNEL +extern struct grf_data grf_cn; /* grf_data for console device */ extern struct grf_softc grf_softc[]; -extern struct grfsw grfsw[]; +extern struct grfsw *grfsw[]; extern int ngrfsw; #endif diff --git a/sys/arch/hp300/dev/hil.c b/sys/arch/hp300/dev/hil.c index f34def13cb6..3b41473254b 100644 --- a/sys/arch/hp300/dev/hil.c +++ b/sys/arch/hp300/dev/hil.c @@ -1,4 +1,4 @@ -/* $NetBSD: hil.c,v 1.21 1996/01/10 20:31:12 thorpej Exp $ */ +/* $NetBSD: hil.c,v 1.22 1996/02/14 02:44:24 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -164,6 +164,7 @@ hilopen(dev, flags, mode, p) register struct hil_softc *hilp = &hil_softc[HILLOOP(dev)]; register struct hilloopdev *dptr; u_char device = HILUNIT(dev); + int s; #ifdef DEBUG if (hildebug & HDB_FOLLOW) @@ -219,7 +220,7 @@ hilopen(dev, flags, mode, p) /* * Opened the keyboard, put in raw mode. */ - (void) splhil(); + s = splhil(); if (device == hilp->hl_kbddev) { u_char mask = 0; send_hil_cmd(hilp->hl_addr, HIL_WRITEKBDSADR, &mask, 1, NULL); @@ -229,7 +230,7 @@ hilopen(dev, flags, mode, p) printf("hilopen: keyboard %d raw\n", hilp->hl_kbddev); #endif } - (void) spl0(); + splx(s); return (0); } @@ -244,6 +245,7 @@ hilclose(dev, flags, mode, p) register int i; u_char device = HILUNIT(dev); char mask, lpctrl; + int s; extern struct emul emul_netbsd; #ifdef DEBUG @@ -266,13 +268,13 @@ hilclose(dev, flags, mode, p) (void) hilqfree(hilp, i, p); } else { mask = ~hildevmask(device); - (void) splhil(); + s = splhil(); for (i = 0; i < NHILQ; i++) if (hilp->hl_queue[i].hq_procp == p) { dptr->hd_qmask &= ~hilqmask(i); hilp->hl_queue[i].hq_devmask &= mask; } - (void) spl0(); + splx(s); } } /* @@ -283,7 +285,7 @@ hilclose(dev, flags, mode, p) /* * Set keyboard back to cooked mode when closed. */ - (void) splhil(); + s = splhil(); if (device && device == hilp->hl_kbddev) { mask = 1 << (hilp->hl_kbddev - 1); send_hil_cmd(hilp->hl_addr, HIL_WRITEKBDSADR, &mask, 1, NULL); @@ -309,7 +311,7 @@ hilclose(dev, flags, mode, p) #endif kbdenable(HILLOOP(dev)); } - (void) spl0(); + splx(s); return (0); } @@ -325,7 +327,7 @@ hilread(dev, uio) register int cc; u_char device = HILUNIT(dev); u_char buf[HILBUFSIZE]; - int error; + int error, s; #if 0 /* @@ -342,7 +344,7 @@ hilread(dev, uio) if ((dptr->hd_flags & HIL_READIN) == 0) return(ENODEV); - (void) splhil(); + s = splhil(); while (dptr->hd_queue.c_cc == 0) { if (dptr->hd_flags & HIL_NOBLOCK) { spl0(); @@ -354,7 +356,7 @@ hilread(dev, uio) return (error); } } - (void) spl0(); + splx(s); error = 0; while (uio->uio_resid > 0 && error == 0) { diff --git a/sys/arch/hp300/dev/hpib.c b/sys/arch/hp300/dev/hpib.c index c6819ddc5bd..d6da6ed7293 100644 --- a/sys/arch/hp300/dev/hpib.c +++ b/sys/arch/hp300/dev/hpib.c @@ -1,4 +1,4 @@ -/* $NetBSD: hpib.c,v 1.7 1995/12/02 18:22:01 thorpej Exp $ */ +/* $NetBSD: hpib.c,v 1.8 1996/02/14 02:44:28 thorpej Exp $ */ /* * Copyright (c) 1982, 1990, 1993 @@ -57,7 +57,7 @@ void hpibattach __P((struct hp_ctlr *)); void hpibstart __P((int)); void hpibgo __P((int, int, int, void *, int, int, int)); void hpibdone __P((int)); -int hpibintr __P((int)); +int hpibintr __P((void *)); struct driver hpibdriver = { hpibmatch, @@ -70,7 +70,6 @@ struct driver hpibdriver = { }; struct hpib_softc hpib_softc[NHPIB]; -struct isr hpib_isr[NHPIB]; extern int nhpibtype __P((struct hp_ctlr *)); /* XXX */ extern int fhpibtype __P((struct hp_ctlr *)); /* XXX */ @@ -112,6 +111,8 @@ hpibattach(hc) /* * Call the appropriate "attach" routine for this controller. * The type is set in the "type" routine. + * + * XXX This is, by the way, exactly backwards. */ switch (hs->sc_type) { case HPIBA: @@ -134,10 +135,7 @@ hpibattach(hc) hs->sc_sq.dq_forw = hs->sc_sq.dq_back = &hs->sc_sq; /* Establish the interrupt handler. */ - hpib_isr[hc->hp_unit].isr_intr = hpibintr; - hpib_isr[hc->hp_unit].isr_ipl = hc->hp_ipl; - hpib_isr[hc->hp_unit].isr_arg = hc->hp_unit; - isrlink(&hpib_isr[hc->hp_unit]); + isrlink(hpibintr, hs, hc->hp_ipl, ISRPRI_BIO); /* Reset the controller, display what we've seen, and we're done. */ hpibreset(hc->hp_unit); @@ -305,10 +303,11 @@ hpibdone(unit) } int -hpibintr(unit) - register int unit; +hpibintr(arg) + void *arg; { + struct hpib_softc *hs = arg; - return ((hpib_softc[unit].sc_controller->hpib_intr)(unit)); + return ((hs->sc_controller->hpib_intr)(arg)); } #endif /* NHPIB > 0 */ diff --git a/sys/arch/hp300/dev/hpibvar.h b/sys/arch/hp300/dev/hpibvar.h index 4a2a67d9718..3e1f6a3abed 100644 --- a/sys/arch/hp300/dev/hpibvar.h +++ b/sys/arch/hp300/dev/hpibvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: hpibvar.h,v 1.7 1995/11/19 17:57:18 thorpej Exp $ */ +/* $NetBSD: hpibvar.h,v 1.8 1996/02/14 02:44:31 thorpej Exp $ */ /* * Copyright (c) 1982, 1990, 1993 @@ -66,21 +66,6 @@ #define C_UNT_P 0xdf /* with odd parity */ #define C_SCG 0x60 /* Secondary group commands */ -/* - * Each of the HP-IB controller drivers fills in this structure, which - * is used by the indirect driver to call controller-specific functions. - */ -struct hpib_controller { - void (*hpib_reset) __P((int)); - int (*hpib_send) __P((int, int, int, void *, int)); - int (*hpib_recv) __P((int, int, int, void *, int)); - int (*hpib_ppoll) __P((int)); - void (*hpib_ppwatch) __P((void *)); - void (*hpib_go) __P((int, int, int, void *, int, int, int)); - void (*hpib_done) __P((int)); - int (*hpib_intr) __P((int)); -}; - struct hpib_softc { struct hp_ctlr *sc_hc; struct hpib_controller *sc_controller; @@ -95,6 +80,21 @@ struct hpib_softc { int sc_curcnt; }; +/* + * Each of the HP-IB controller drivers fills in this structure, which + * is used by the indirect driver to call controller-specific functions. + */ +struct hpib_controller { + void (*hpib_reset) __P((int)); + int (*hpib_send) __P((int, int, int, void *, int)); + int (*hpib_recv) __P((int, int, int, void *, int)); + int (*hpib_ppoll) __P((int)); + void (*hpib_ppwatch) __P((void *)); + void (*hpib_go) __P((int, int, int, void *, int, int, int)); + void (*hpib_done) __P((int)); + int (*hpib_intr) __P((void *)); +}; + /* sc_flags */ #define HPIBF_IO 0x1 #define HPIBF_DONE 0x2 diff --git a/sys/arch/hp300/dev/if_le.c b/sys/arch/hp300/dev/if_le.c index 40289c07273..a4978ec7d8e 100644 --- a/sys/arch/hp300/dev/if_le.c +++ b/sys/arch/hp300/dev/if_le.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_le.c,v 1.26 1996/01/02 21:56:21 thorpej Exp $ */ +/* $NetBSD: if_le.c,v 1.29 1996/04/22 02:30:45 christos Exp $ */ /*- * Copyright (c) 1995 Charles M. Hannum. All rights reserved. @@ -80,7 +80,7 @@ struct le_softc le_softc[NLE]; int lematch __P((struct hp_device *)); void leattach __P((struct hp_device *)); int leintr __P((void *)); -static int hp300_leintr __P((int)); /* machine-dependent wrapper */ +static int hp300_leintr __P((void *)); /* machine-dependent wrapper */ struct driver ledriver = { lematch, leattach, "le", @@ -89,6 +89,12 @@ struct driver ledriver = { /* offsets for: ID, REGS, MEM, NVRAM */ int lestd[] = { 0, 0x4000, 0x8000, 0xC008 }; +integrate void +lehwinit(sc) + struct le_softc *sc; +{ +} + integrate void lewrcsr(sc, port, val) struct le_softc *sc; @@ -179,27 +185,25 @@ leattach(hd) cp++; } - sc->sc_copytodesc = copytobuf_contig; - sc->sc_copyfromdesc = copyfrombuf_contig; - sc->sc_copytobuf = copytobuf_contig; - sc->sc_copyfrombuf = copyfrombuf_contig; - sc->sc_zerobuf = zerobuf_contig; + sc->sc_copytodesc = am7990_copytobuf_contig; + sc->sc_copyfromdesc = am7990_copyfrombuf_contig; + sc->sc_copytobuf = am7990_copytobuf_contig; + sc->sc_copyfrombuf = am7990_copyfrombuf_contig; + sc->sc_zerobuf = am7990_zerobuf_contig; sc->sc_arpcom.ac_if.if_name = ledriver.d_name; leconfig(sc); - sc->sc_isr.isr_intr = hp300_leintr; - sc->sc_isr.isr_arg = hd->hp_unit; - sc->sc_isr.isr_ipl = hd->hp_ipl; - isrlink(&sc->sc_isr); + /* Establish the interrupt handler. */ + isrlink(hp300_leintr, sc, hd->hp_ipl, ISRPRI_NET); ler0->ler0_status = LE_IE; } static int -hp300_leintr(unit) - int unit; +hp300_leintr(arg) + void *arg; { - struct le_softc *sc = LE_SOFTC(unit); + struct le_softc *sc = arg; u_int16_t isr; #ifdef USELEDS diff --git a/sys/arch/hp300/dev/ite.c b/sys/arch/hp300/dev/ite.c index bc1b738e7bb..150ea8dccc0 100644 --- a/sys/arch/hp300/dev/ite.c +++ b/sys/arch/hp300/dev/ite.c @@ -1,6 +1,7 @@ -/* $NetBSD: ite.c,v 1.28 1995/11/19 23:14:22 thorpej Exp $ */ +/* $NetBSD: ite.c,v 1.29 1996/02/24 00:55:20 thorpej Exp $ */ /* + * Copyright (c) 1996 Jason R. Thorpe. All rights reserved. * Copyright (c) 1988 University of Utah. * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. @@ -62,6 +63,10 @@ #include #include +#include + +#include + #include #include #include @@ -86,11 +91,25 @@ int iteburst = 64; int nite = NITE; -struct tty *ite_tty[NITE]; -struct ite_softc *kbd_ite = NULL; +struct ite_data *kbd_ite = NULL; struct ite_softc ite_softc[NITE]; -void itestart(); +/* + * Terminal emulator state information, statically allocated + * for the benefit of the console. + */ +struct ite_data ite_cn; + +void iteinit __P((struct ite_data *)); +void iteputchar __P((int, struct ite_data *)); +void itecheckwrap __P((struct ite_data *, struct itesw *)); +void ite_dchar __P((struct ite_data *, struct itesw *)); +void ite_ichar __P((struct ite_data *, struct itesw *)); +void ite_dline __P((struct ite_data *, struct itesw *)); +void ite_iline __P((struct ite_data *, struct itesw *)); +void ite_clrtoeol __P((struct ite_data *, struct itesw *, int, int)); +void ite_clrtoeos __P((struct ite_data *, struct itesw *)); +void itestart __P((struct tty *)); /* * Primary attribute buffer to be used by the first bitmapped console @@ -116,51 +135,96 @@ u_char console_attributes[0x2200]; * Dummy for pseudo-device config. */ /*ARGSUSED*/ +void iteattach(n) int n; { } +/* + * Allocate storage for ite data structures. + * XXX This is a kludge and will go away with new config. + */ +void +ite_attach_grf(unit, isconsole) + int unit, isconsole; +{ + struct ite_softc *ite = &ite_softc[unit]; + struct grf_softc *grf = &grf_softc[unit]; + + /* + * Check to see if our structure is pre-allocated. + */ + if (isconsole) { + ite->sc_data = &ite_cn; + + /* + * We didn't know which unit this would be during + * the console probe, so we have to fixup cn_dev here. + */ + cn_tab->cn_dev = makedev(ite_major(), unit); + } else { + ite->sc_data = + (struct ite_data *)malloc(sizeof(struct ite_data), + M_DEVBUF, M_NOWAIT); + if (ite->sc_data == NULL) { + printf("ite_attach_grf: malloc for ite_data failed\n"); + return; + } + bzero(ite->sc_data, sizeof(struct ite_data)); + } + + /* + * Cross-reference the ite and the grf. + */ + ite->sc_grf = grf; + grf->sc_ite = ite; + + printf("ite%d at grf%d: attached\n", unit, unit); +} + /* * Perform functions necessary to setup device as a terminal emulator. */ -iteon(dev, flag) - dev_t dev; +int +iteon(ip, flag) + struct ite_data *ip; int flag; { - int unit = ITEUNIT(dev); - struct tty *tp = ite_tty[unit]; - struct ite_softc *ip = &ite_softc[unit]; - if (unit < 0 || unit >= NITE || (ip->flags&ITE_ALIVE) == 0) + if ((ip->flags & ITE_ALIVE) == 0) return(ENXIO); + /* force ite active, overriding graphics mode */ if (flag & 1) { ip->flags |= ITE_ACTIVE; ip->flags &= ~(ITE_INGRF|ITE_INITED); } + /* leave graphics mode */ if (flag & 2) { ip->flags &= ~ITE_INGRF; if ((ip->flags & ITE_ACTIVE) == 0) return(0); } + ip->flags |= ITE_ACTIVE; if (ip->flags & ITE_INGRF) return(0); + if (kbd_ite == NULL || kbd_ite == ip) { kbd_ite = ip; - kbdenable(unit); + kbdenable(0); /* XXX */ } - iteinit(dev); + + iteinit(ip); return(0); } -iteinit(dev) - dev_t dev; +void +iteinit(ip) + struct ite_data *ip; { - int unit = ITEUNIT(dev); - struct ite_softc *ip = &ite_softc[unit]; if (ip->flags & ITE_INITED) return; @@ -190,11 +254,11 @@ iteinit(dev) * Deinit'ing the console every time leads to a very active * screen when processing /etc/rc. */ -iteoff(dev, flag) - dev_t dev; +void +iteoff(ip, flag) + struct ite_data *ip; int flag; { - register struct ite_softc *ip = &ite_softc[ITEUNIT(dev)]; if (flag & 2) { ip->flags |= ITE_INGRF; @@ -225,20 +289,21 @@ iteopen(dev, mode, devtype, p) struct proc *p; { int unit = ITEUNIT(dev); - register struct tty *tp; - register struct ite_softc *ip = &ite_softc[unit]; - register int error; + struct tty *tp; + struct ite_softc *sc = &ite_softc[unit]; + struct ite_data *ip = sc->sc_data; + int error; int first = 0; - if (!ite_tty[unit]) - tp = ite_tty[unit] = ttymalloc(); + if (ip->tty == NULL) + tp = ip->tty = ttymalloc(); else - tp = ite_tty[unit]; + tp = ip->tty; if ((tp->t_state&(TS_ISOPEN|TS_XCLUDE)) == (TS_ISOPEN|TS_XCLUDE) && p->p_ucred->cr_uid != 0) return (EBUSY); if ((ip->flags & ITE_ACTIVE) == 0) { - error = iteon(dev, 0); + error = iteon(ip, 0); if (error) return (error); first = 1; @@ -261,7 +326,7 @@ iteopen(dev, mode, devtype, p) tp->t_winsize.ws_row = ip->rows; tp->t_winsize.ws_col = ip->cols; } else if (first) - iteoff(dev, 0); + iteoff(ip, 0); return (error); } @@ -272,14 +337,16 @@ iteclose(dev, flag, mode, p) int flag, mode; struct proc *p; { - register struct tty *tp = ite_tty[ITEUNIT(dev)]; + struct ite_softc *sc = &ite_softc[ITEUNIT(dev)]; + struct ite_data *ip = sc->sc_data; + struct tty *tp = ip->tty; (*linesw[tp->t_line].l_close)(tp, flag); ttyclose(tp); - iteoff(dev, 0); + iteoff(ip, 0); #if 0 ttyfree(tp); - ite_tty[ITEUNIT(dev)] = (struct tty *)0; + ip->tty = (struct tty *)0; #endif return(0); } @@ -290,7 +357,8 @@ iteread(dev, uio, flag) struct uio *uio; int flag; { - register struct tty *tp = ite_tty[ITEUNIT(dev)]; + struct ite_softc *sc = &ite_softc[ITEUNIT(dev)]; + struct tty *tp = sc->sc_data->tty; return ((*linesw[tp->t_line].l_read)(tp, uio, flag)); } @@ -301,7 +369,8 @@ itewrite(dev, uio, flag) struct uio *uio; int flag; { - register struct tty *tp = ite_tty[ITEUNIT(dev)]; + struct ite_softc *sc = &ite_softc[ITEUNIT(dev)]; + struct tty *tp = sc->sc_data->tty; return ((*linesw[tp->t_line].l_write)(tp, uio, flag)); } @@ -310,8 +379,9 @@ struct tty * itetty(dev) dev_t dev; { + struct ite_softc *sc = &ite_softc[ITEUNIT(dev)]; - return (ite_tty[ITEUNIT(dev)]); + return (sc->sc_data->tty); } int @@ -322,7 +392,9 @@ iteioctl(dev, cmd, addr, flag, p) int flag; struct proc *p; { - register struct tty *tp = ite_tty[ITEUNIT(dev)]; + struct ite_softc *sc = &ite_softc[ITEUNIT(dev)]; + struct ite_data *ip = sc->sc_data; + struct tty *tp = ip->tty; int error; error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, addr, flag, p); @@ -340,7 +412,11 @@ itestart(tp) { register int cc, s; int hiwat = 0, hadcursor = 0; - struct ite_softc *ip; + struct ite_softc *sc; + struct ite_data *ip; + + sc = &ite_softc[ITEUNIT(tp->t_dev)]; + ip = sc->sc_data; /* * (Potentially) lower priority. We only need to protect ourselves @@ -365,7 +441,7 @@ itestart(tp) * Handle common (?) case */ if (cc == 1) { - iteputchar(getc(&tp->t_outq), tp->t_dev); + iteputchar(getc(&tp->t_outq), ip); } else if (cc) { /* * Limit the amount of output we do in one burst @@ -379,14 +455,13 @@ itestart(tp) * Turn off cursor while we output multiple characters. * Saves a lot of expensive window move operations. */ - ip = &ite_softc[ITEUNIT(tp->t_dev)]; if (ip->flags & ITE_CURSORON) { ite_erasecursor(ip, ip->isw); ip->flags &= ~ITE_CURSORON; hadcursor = 1; } while (--cc >= 0) - iteputchar(getc(&tp->t_outq), tp->t_dev); + iteputchar(getc(&tp->t_outq), ip); if (hadcursor) { ip->flags |= ITE_CURSORON; ite_drawcursor(ip, ip->isw); @@ -408,13 +483,14 @@ itestop(tp, flag) } +void itefilter(stat, c) - register char stat, c; + char stat, c; { static int capsmode = 0; static int metamode = 0; register char code, *str; - struct tty *kbd_tty = ite_tty[kbd_ite - ite_softc]; + struct tty *kbd_tty = kbd_ite->tty; if (kbd_tty == NULL) return; @@ -468,14 +544,13 @@ itefilter(stat, c) } } -iteputchar(c, dev) - register int c; - dev_t dev; +void +iteputchar(c, ip) + int c; + struct ite_data *ip; { - int unit = ITEUNIT(dev); - register struct ite_softc *ip = &ite_softc[unit]; - register struct itesw *sp = ip->isw; - register int n; + struct itesw *sp = ip->isw; + int n; if ((ip->flags & (ITE_ACTIVE|ITE_INGRF)) != ITE_ACTIVE) return; @@ -705,7 +780,7 @@ ignore: break; case '\t': - if (ip->curx < TABEND(unit)) { + if (ip->curx < TABEND(ip)) { n = TABSIZE - (ip->curx & (TABSIZE - 1)); ip->curx += n; ite_movecursor(ip, sp); @@ -715,7 +790,7 @@ ignore: case CTRL('G'): if (ip == kbd_ite) - kbdbell(unit); + kbdbell(0); /* XXX */ break; case ESC: @@ -738,9 +813,10 @@ ignore: } } +void itecheckwrap(ip, sp) - register struct ite_softc *ip; - register struct itesw *sp; + struct ite_data *ip; + struct itesw *sp; { if (++ip->curx == ip->cols) { ip->curx = 0; @@ -756,9 +832,10 @@ itecheckwrap(ip, sp) ite_movecursor(ip, sp); } +void ite_dchar(ip, sp) - register struct ite_softc *ip; - register struct itesw *sp; + struct ite_data *ip; + struct itesw *sp; { if (ip->curx < ip->cols - 1) { ite_erasecursor(ip, sp); @@ -771,9 +848,10 @@ ite_dchar(ip, sp) ite_drawcursor(ip, sp); } +void ite_ichar(ip, sp) - register struct ite_softc *ip; - register struct itesw *sp; + struct ite_data *ip; + struct itesw *sp; { if (ip->curx < ip->cols - 1) { ite_erasecursor(ip, sp); @@ -786,9 +864,10 @@ ite_ichar(ip, sp) ite_drawcursor(ip, sp); } +void ite_dline(ip, sp) - register struct ite_softc *ip; - register struct itesw *sp; + struct ite_data *ip; + struct itesw *sp; { if (ip->cury < ip->rows - 1) { ite_erasecursor(ip, sp); @@ -799,9 +878,10 @@ ite_dline(ip, sp) ite_clrtoeol(ip, sp, ip->rows - 1, 0); } +void ite_iline(ip, sp) - register struct ite_softc *ip; - register struct itesw *sp; + struct ite_data *ip; + struct itesw *sp; { if (ip->cury < ip->rows - 1) { ite_erasecursor(ip, sp); @@ -812,116 +892,48 @@ ite_iline(ip, sp) ite_clrtoeol(ip, sp, ip->cury, 0); } +void ite_clrtoeol(ip, sp, y, x) - register struct ite_softc *ip; - register struct itesw *sp; - register int y, x; + struct ite_data *ip; + struct itesw *sp; + int y, x; { (*sp->ite_clear)(ip, y, x, 1, ip->cols - x); attrclr(ip, y, x, 1, ip->cols - x); ite_drawcursor(ip, sp); } +void ite_clrtoeos(ip, sp) - register struct ite_softc *ip; - register struct itesw *sp; + struct ite_data *ip; + struct itesw *sp; { (*sp->ite_clear)(ip, ip->cury, 0, ip->rows - ip->cury, ip->cols); attrclr(ip, ip->cury, 0, ip->rows - ip->cury, ip->cols); ite_drawcursor(ip, sp); } -/* - * Console functions - */ -#include -#ifdef hp300 -#include -#endif - -#ifdef DEBUG -/* - * Minimum ITE number at which to start looking for a console. - * Setting to 0 will do normal search, 1 will skip first ITE device, - * NITE will skip ITEs and use serial port. - */ -int whichconsole = 0; -#endif - -void -itecnprobe(cp) - struct consdev *cp; +int +ite_major() { - register struct ite_softc *ip; - int i, sw, maj, unit, pri; + static int itemaj, initialized; - /* locate the major number */ - for (maj = 0; maj < nchrdev; maj++) - if (cdevsw[maj].d_open == iteopen) - break; - - /* urk! */ - grfconfig(); + /* Only compute once. */ + if (initialized) + return (itemaj); + initialized = 1; - /* check all the individual displays and find the best */ - unit = -1; - pri = CN_DEAD; - for (i = 0; i < NITE; i++) { - struct grf_softc *gp = &grf_softc[i]; - - ip = &ite_softc[i]; - if ((gp->g_flags & GF_ALIVE) == 0) - continue; - ip->flags = (ITE_ALIVE|ITE_CONSOLE); - - /* locate the proper switch table. */ - for (sw = 0; sw < nitesw; sw++) - if (itesw[sw].ite_hwid == gp->g_sw->gd_hwid) - break; - - if (sw == nitesw) - continue; -#ifdef DEBUG - if (i < whichconsole) - continue; -#endif - ip->isw = &itesw[sw]; - ip->grf = gp; -#ifdef hp300 - if ((int)gp->g_display.gd_regaddr == GRFIADDR) { - pri = CN_INTERNAL; - unit = i; - } else if (unit < 0) { - pri = CN_NORMAL; - unit = i; - } -#endif -#ifdef hp800 - /* XXX use the first one for now */ - if (unit < 0) { - pri = CN_INTERNAL; - unit = i; - } -#endif - } + /* locate the major number */ + for (itemaj = 0; itemaj < nchrdev; itemaj++) + if (cdevsw[itemaj].d_open == iteopen) - /* initialize required fields */ - cp->cn_dev = makedev(maj, unit); - cp->cn_pri = pri; + return (itemaj); } -void -itecninit(cp) - struct consdev *cp; -{ - int unit = ITEUNIT(cp->cn_dev); - struct ite_softc *ip = &ite_softc[unit]; - - ip->attrbuf = console_attributes; - iteinit(cp->cn_dev); - ip->flags |= (ITE_ACTIVE | ITE_ISCONS); - kbd_ite = ip; -} +/* + * Console functions. Console probes are done by the individual + * framebuffer drivers. + */ /*ARGSUSED*/ int @@ -949,19 +961,20 @@ itecngetc(dev) return(c); } +/* ARGSUSED */ void itecnputc(dev, c) dev_t dev; int c; { static int paniced = 0; - struct ite_softc *ip = &ite_softc[ITEUNIT(dev)]; + struct ite_data *ip = &ite_cn; if (panicstr && !paniced && (ip->flags & (ITE_ACTIVE|ITE_INGRF)) != ITE_ACTIVE) { - (void) iteon(dev, 3); + (void) iteon(ip, 3); paniced = 1; } - iteputchar(c, dev); + iteputchar(c, ip); } #endif diff --git a/sys/arch/hp300/dev/ite_dv.c b/sys/arch/hp300/dev/ite_dv.c index 7d4b1a023e9..e69de29bb2d 100644 --- a/sys/arch/hp300/dev/ite_dv.c +++ b/sys/arch/hp300/dev/ite_dv.c @@ -1,262 +0,0 @@ -/* $NetBSD: ite_dv.c,v 1.5 1994/10/26 07:24:28 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.10 93/06/25$ - * - * @(#)ite_dv.c 8.1 (Berkeley) 7/8/93 - */ - -#include "ite.h" -#if NITE > 0 - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -/* XXX */ -#include -#include - -#define REGBASE ((struct dvboxfb *)(ip->regbase)) -#define WINDOWMOVER dvbox_windowmove - -dvbox_init(ip) - register struct ite_softc *ip; -{ - int i; - - /* XXX */ - if (ip->regbase == 0) { - struct grf_softc *gp = ip->grf; - - ip->regbase = gp->g_regkva; - ip->fbbase = gp->g_fbkva; - ip->fbwidth = gp->g_display.gd_fbwidth; - ip->fbheight = gp->g_display.gd_fbheight; - ip->dwidth = gp->g_display.gd_dwidth; - ip->dheight = gp->g_display.gd_dheight; - /* - * 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; - } - - dv_reset(ip->regbase); - - /* - * 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(100); - - /* - * 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); -} - -dvbox_deinit(ip) - register struct ite_softc *ip; -{ - dvbox_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR); - db_waitbusy(ip->regbase); - - ip->flags &= ~ITE_INITED; -} - -dvbox_putc(ip, c, dy, dx, mode) - register struct ite_softc *ip; - register int dy, dx; - int c, mode; -{ - register int wrr = ((mode == ATTR_INV) ? RR_COPYINVERTED : RR_COPY); - - dvbox_windowmove(ip, charY(ip, c), charX(ip, c), - dy * ip->ftheight, dx * ip->ftwidth, - ip->ftheight, ip->ftwidth, wrr); -} - -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; - register int dx = sx; - register int height = 1; - register int width = ip->cols; - - if (dir == SCROLL_UP) { - dy = sy - count; - height = ip->rows - sy; - } - else if (dir == SCROLL_DOWN) { - dy = sy + count; - height = ip->rows - dy - 1; - } - else if (dir == SCROLL_RIGHT) { - dy = sy; - dx = sx + count; - width = ip->cols - dx; - } - else { - dy = sy; - dx = sx - count; - width = ip->cols - sx; - } - - dvbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth, - dy * ip->ftheight, dx * ip->ftwidth, - height * ip->ftheight, - width * 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; -} -#endif diff --git a/sys/arch/hp300/dev/ite_gb.c b/sys/arch/hp300/dev/ite_gb.c index 69ed47785f9..e69de29bb2d 100644 --- a/sys/arch/hp300/dev/ite_gb.c +++ b/sys/arch/hp300/dev/ite_gb.c @@ -1,246 +0,0 @@ -/* $NetBSD: ite_gb.c,v 1.5 1994/10/26 07:24:29 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.20 92/12/20$ - * - * @(#)ite_gb.c 8.1 (Berkeley) 6/10/93 - */ - -#include "ite.h" -#if NITE > 0 - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -/* XXX */ -#include -#include - -#define REGBASE ((struct gboxfb *)(ip->regbase)) -#define WINDOWMOVER gbox_windowmove - -gbox_init(ip) - register struct ite_softc *ip; -{ - /* XXX */ - if (ip->regbase == 0) { - struct grf_softc *gp = ip->grf; - - ip->regbase = gp->g_regkva; - ip->fbbase = gp->g_fbkva; - ip->fbwidth = gp->g_display.gd_fbwidth; - ip->fbheight = gp->g_display.gd_fbheight; - ip->dwidth = gp->g_display.gd_dwidth; - ip->dheight = gp->g_display.gd_dheight; - } - - REGBASE->write_protect = 0x0; - REGBASE->interrupt = 0x4; - REGBASE->rep_rule = RR_COPY; - REGBASE->blink1 = 0xff; - REGBASE->blink2 = 0xff; - gb_microcode(ip->regbase); - 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_deinit(ip) - struct ite_softc *ip; -{ - gbox_windowmove(ip, 0, 0, 0, 0, ip->dheight, ip->dwidth, RR_CLEAR); - tile_mover_waitbusy(ip->regbase); - - ip->flags &= ~ITE_INITED; -} - -gbox_putc(ip, c, dy, dx, mode) - register struct ite_softc *ip; - register int dy, dx; - int c, mode; -{ - register int wrr = ((mode == ATTR_INV) ? RR_COPYINVERTED : RR_COPY); - - gbox_windowmove(ip, charY(ip, c), charX(ip, c), - dy * ip->ftheight, dx * ip->ftwidth, - ip->ftheight, ip->ftwidth, wrr); -} - -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; - - if (dir == SCROLL_UP) { - 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); - } - else if (dir == SCROLL_DOWN) { - dy = sy + count; - height = ip->rows - dy; - for (i = (height - 1); i >= 0; i--) - gbox_blockmove(ip, sy + i, sx, dy + i, 0, 1, ip->cols); - } - else if (dir == SCROLL_RIGHT) { - gbox_blockmove(ip, sy, sx, sy, sx + count, - 1, ip->cols - (sx + count)); - } - else { - gbox_blockmove(ip, sy, sx, sy, sx - count, - 1, ip->cols - sx); - } -} - -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/dev/ite_hy.c b/sys/arch/hp300/dev/ite_hy.c index 3889c91adde..e69de29bb2d 100644 --- a/sys/arch/hp300/dev/ite_hy.c +++ b/sys/arch/hp300/dev/ite_hy.c @@ -1,471 +0,0 @@ -/* $NetBSD: ite_hy.c,v 1.2 1994/10/26 07:24:31 cgd Exp $ */ - -/* - * Copyright (c) 1991 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.2 92/12/20$ - * - * @(#)ite_hy.c 8.1 (Berkeley) 6/10/93 - */ - -#include "ite.h" -#if NITE > 0 - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -/* XXX */ -#include -#include - -#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; - - /* XXX */ - if (ip->regbase == NULL) { - struct grf_softc *gp = ip->grf; - - ip->regbase = gp->g_regkva; - ip->fbbase = gp->g_fbkva; - ip->fbwidth = gp->g_display.gd_fbwidth; - ip->fbheight = gp->g_display.gd_fbheight; - ip->dwidth = gp->g_display.gd_dwidth; - ip->dheight = gp->g_display.gd_dheight; - } - - 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; - - /* - * Clear the framebuffer on all planes. - */ - hyper_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR); - - hyper_ite_fontinit(ip); - - REGBASE->nblank = 0x05; - - /* - * Stash the inverted cursor. - */ - hyper_windowmove(ip, charY(ip, ' '), charX(ip, ' '), - ip->cblanky, ip->cblankx, ip->ftheight, - ip->ftwidth, RR_COPYINVERTED); -} - -hyper_deinit(ip) - register struct ite_softc *ip; -{ - hyper_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR); - - REGBASE->nblank = 0x05; - ip->flags &= ~ITE_INITED; -} - -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; - int c, dy, dx, mode; -{ - int wmrr = ((mode == ATTR_INV) ? RR_COPYINVERTED : RR_COPY); - - hyper_windowmove(ip, charY(ip, c), charX(ip, c), - dy * ip->ftheight, dx * ip->ftwidth, - ip->ftheight, ip->ftwidth, wmrr); -} - -hyper_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) -} - -hyper_clear(ip, sy, sx, h, w) - register 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; - register int dx = sx; - register int height = 1; - register int width = ip->cols; - - if (dir == SCROLL_UP) { - dy = sy - count; - height = ip->rows - sy; - } - else if (dir == SCROLL_DOWN) { - dy = sy + count; - height = ip->rows - dy - 1; - } - else if (dir == SCROLL_RIGHT) { - dy = sy; - dx = sx + count; - width = ip->cols - dx; - } - else { - dy = sy; - dx = sx - count; - width = ip->cols - sx; - } - - hyper_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth, - dy * ip->ftheight, dx * ip->ftwidth, - height * ip->ftheight, - width * ip->ftwidth, RR_COPY); -} - -#include - -/* 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; -{ - 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; - - if (sy < dy) /* start at last scanline of rectangle */ - { - psrcLine = ((unsigned int *) ip->fbbase) + ((sy+h-1) * width); - pdstLine = ((unsigned int *) ip->fbbase) + ((dy+h-1) * width); - width = -width; - } - else /* start at first scanline */ - { - 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; - - if (sx >= dx) /* move left to right */ - { - 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; - } - } - else /* move right to left */ - { - pdstLine += (dx+w >> 5); - psrcLine += (sx+w >> 5); - /* if fetch of last partial bits from source crosses - a longword boundary, start at the previous longword - */ - if (xoffSrc + nend >= 32) - --psrcLine; - - while (h--) - { - psrc = psrcLine; - pdst = pdstLine; - - if (endmask) - { - getandputrop0(psrc, xoffSrc, nend, pdst, func); - } - - nl = nlMiddle + 1; - while (--nl) - { - --psrc; - --pdst; - getunalignedword(psrc, xoffSrc, tmpSrc) - DoRop(*pdst, func, tmpSrc, *pdst); - } - - if (startmask) - { - if (srcStartOver) - --psrc; - --pdst; - getandputrop(psrc, (sx & 0x1f), - (dx & 0x1f), nstart, pdst, func) - } - - pdstLine += width; - psrcLine += width; - } - } /* move right to left */ - } -} -#endif diff --git a/sys/arch/hp300/dev/ite_rb.c b/sys/arch/hp300/dev/ite_rb.c index b07fdc26f67..e69de29bb2d 100644 --- a/sys/arch/hp300/dev/ite_rb.c +++ b/sys/arch/hp300/dev/ite_rb.c @@ -1,261 +0,0 @@ -/* $NetBSD: ite_rb.c,v 1.5 1994/10/26 07:24: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_rb.c 1.19 93/06/25$ - * - * @(#)ite_rb.c 8.1 (Berkeley) 7/8/93 - */ - -#include "ite.h" -#if NITE > 0 - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -/* XXX */ -#include -#include - -#define REGBASE ((struct rboxfb *)(ip->regbase)) -#define WINDOWMOVER rbox_windowmove - -rbox_init(ip) - struct ite_softc *ip; -{ - register int i; - - /* XXX */ - if (ip->regbase == 0) { - struct grf_softc *gp = ip->grf; - - ip->regbase = gp->g_regkva; - ip->fbbase = gp->g_fbkva; - ip->fbwidth = gp->g_display.gd_fbwidth; - ip->fbheight = gp->g_display.gd_fbheight; - ip->dwidth = gp->g_display.gd_dwidth; - ip->dheight = gp->g_display.gd_dheight; - /* - * 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; - } - - rb_waitbusy(ip->regbase); - - REGBASE->reset = 0x39; - DELAY(1000); - - 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_deinit(ip) - struct ite_softc *ip; -{ - rbox_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR); - rb_waitbusy(ip->regbase); - - ip->flags &= ~ITE_INITED; -} - -rbox_putc(ip, c, dy, dx, mode) - register struct ite_softc *ip; - register int dy, dx; - int c, mode; -{ - register int wrr = ((mode == ATTR_INV) ? RR_COPYINVERTED : RR_COPY); - - rbox_windowmove(ip, charY(ip, c), charX(ip, c), - dy * ip->ftheight, dx * ip->ftwidth, - ip->ftheight, ip->ftwidth, wrr); -} - -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; - register int dx = sx; - register int height = 1; - register int width = ip->cols; - - if (dir == SCROLL_UP) { - dy = sy - count; - height = ip->rows - sy; - } - else if (dir == SCROLL_DOWN) { - dy = sy + count; - height = ip->rows - dy - 1; - } - else if (dir == SCROLL_RIGHT) { - dy = sy; - dx = sx + count; - width = ip->cols - dx; - } - else { - dy = sy; - dx = sx - count; - width = ip->cols - sx; - } - - rbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth, - dy * ip->ftheight, dx * ip->ftwidth, - height * ip->ftheight, - width * 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/dev/ite_subr.c b/sys/arch/hp300/dev/ite_subr.c index 48c5dd5150c..dcf26adae6d 100644 --- a/sys/arch/hp300/dev/ite_subr.c +++ b/sys/arch/hp300/dev/ite_subr.c @@ -1,4 +1,4 @@ -/* $NetBSD: ite_subr.c,v 1.5 1994/10/26 07:24:35 cgd Exp $ */ +/* $NetBSD: ite_subr.c,v 1.6 1996/02/24 00:55:29 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -57,8 +57,9 @@ #include +void ite_fontinfo(ip) - struct ite_softc *ip; + struct ite_data *ip; { u_long fontaddr = getword(ip, getword(ip, FONTROM) + FONTADDR); @@ -89,8 +90,9 @@ ite_fontinfo(ip) } } +void ite_fontinit(ip) - register struct ite_softc *ip; + struct ite_data *ip; { int bytewidth = (((ip->ftwidth - 1) / 8) + 1); int glyphsize = bytewidth * ip->ftheight; @@ -118,15 +120,16 @@ ite_fontinit(ip) */ u_char ite_readbyte(ip, disp) - struct ite_softc *ip; + struct ite_data *ip; int disp; { return((u_char) *(((u_char *)ip->regbase) + disp)); } +void ite_writeglyph(ip, fbmem, glyphp) - register struct ite_softc *ip; - register u_char *fbmem, *glyphp; + struct ite_data *ip; + u_char *fbmem, *glyphp; { register int bn; int l, b; diff --git a/sys/arch/hp300/dev/ite_tc.c b/sys/arch/hp300/dev/ite_tc.c index b00f6031038..e69de29bb2d 100644 --- a/sys/arch/hp300/dev/ite_tc.c +++ b/sys/arch/hp300/dev/ite_tc.c @@ -1,270 +0,0 @@ -/* $NetBSD: ite_tc.c,v 1.5 1994/10/26 07:24: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_tc.c 1.27 92/12/20$ - * - * @(#)ite_tc.c 8.1 (Berkeley) 6/10/93 - */ - -#include "ite.h" -#if NITE > 0 - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -/* XXX */ -#include -#include - -#define REGBASE ((struct tcboxfb *)(ip->regbase)) -#define WINDOWMOVER topcat_windowmove - -topcat_init(ip) - register struct ite_softc *ip; -{ - /* XXX */ - if (ip->regbase == NULL) { - struct grf_softc *gp = ip->grf; - - ip->regbase = gp->g_regkva; - ip->fbbase = gp->g_fbkva; - ip->fbwidth = gp->g_display.gd_fbwidth; - ip->fbheight = gp->g_display.gd_fbheight; - ip->dwidth = gp->g_display.gd_dwidth; - ip->dheight = gp->g_display.gd_dheight; - } - - /* - * 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); - - /* - * Initialize color map for color displays - */ - if (ip->planemask != 1) { - tc_waitbusy(ip->regbase, ip->planemask); - REGBASE->nblank = 0x01; - - tccm_waitbusy(ip->regbase); - REGBASE->rdata = 0x0; - REGBASE->gdata = 0x0; - REGBASE->bdata = 0x0; - REGBASE->cindex = 0xFF; - REGBASE->strobe = 0xFF; - - DELAY(100); - tccm_waitbusy(ip->regbase); - REGBASE->rdata = 0x0; - REGBASE->gdata = 0x0; - REGBASE->bdata = 0x0; - REGBASE->cindex = 0x0; - - DELAY(100); - tccm_waitbusy(ip->regbase); - REGBASE->rdata = 0xFF; - REGBASE->gdata = 0xFF; - REGBASE->bdata = 0xFF; - REGBASE->cindex = 0xFE; - REGBASE->strobe = 0xFF; - - DELAY(100); - tccm_waitbusy(ip->regbase); - REGBASE->rdata = 0x0; - REGBASE->gdata = 0x0; - REGBASE->bdata = 0x0; - REGBASE->cindex = 0x0; - } - - /* - * Stash the inverted cursor. - */ - topcat_windowmove(ip, charY(ip, ' '), charX(ip, ' '), - ip->cblanky, ip->cblankx, ip->ftheight, - ip->ftwidth, RR_COPYINVERTED); -} - -topcat_deinit(ip) - register struct ite_softc *ip; -{ - topcat_windowmove(ip, 0, 0, 0, 0, ip->fbheight, ip->fbwidth, RR_CLEAR); - tc_waitbusy(ip->regbase, ip->planemask); - - REGBASE->nblank = ~0; - ip->flags &= ~ITE_INITED; -} - -topcat_putc(ip, c, dy, dx, mode) - register struct ite_softc *ip; - int c, dy, dx, mode; -{ - int wmrr = ((mode == ATTR_INV) ? RR_COPYINVERTED : RR_COPY); - - topcat_windowmove(ip, charY(ip, c), charX(ip, c), - dy * ip->ftheight, dx * ip->ftwidth, - ip->ftheight, ip->ftwidth, wmrr); -} - -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) - register 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; - register int dx = sx; - register int height = 1; - register int width = ip->cols; - - if (dir == SCROLL_UP) { - dy = sy - count; - height = ip->rows - sy; - } - else if (dir == SCROLL_DOWN) { - dy = sy + count; - height = ip->rows - dy - 1; - } - else if (dir == SCROLL_RIGHT) { - dy = sy; - dx = sx + count; - width = ip->cols - dx; - } - else { - dy = sy; - dx = sx - count; - width = ip->cols - sx; - } - - topcat_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth, - dy * ip->ftheight, dx * ip->ftwidth, - height * ip->ftheight, - width * 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/dev/itevar.h b/sys/arch/hp300/dev/itevar.h index 28b13d3064d..53e43760f17 100644 --- a/sys/arch/hp300/dev/itevar.h +++ b/sys/arch/hp300/dev/itevar.h @@ -1,4 +1,4 @@ -/* $NetBSD: itevar.h,v 1.8 1995/11/19 23:14:25 thorpej Exp $ */ +/* $NetBSD: itevar.h,v 1.9 1996/02/24 00:55:31 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -44,18 +44,6 @@ #define ITEUNIT(dev) minor(dev) -struct itesw { - int ite_hwid; /* Hardware id */ - int (*ite_init)(); - int (*ite_deinit)(); - int (*ite_clear)(); - int (*ite_putc)(); - int (*ite_cursor)(); - int (*ite_scroll)(); - u_char (*ite_readbyte)(); - int (*ite_writeglyph)(); -}; - #define getbyte(ip, offset) \ ((*(ip)->isw->ite_readbyte)(ip, offset)) @@ -65,10 +53,11 @@ struct itesw { #define writeglyph(ip, offset, fontbuf) \ ((*(ip)->isw->ite_writeglyph)((ip), (offset), (fontbuf))) -struct ite_softc { +struct ite_data { int flags; + struct tty *tty; struct itesw *isw; - struct grf_softc *grf; + struct grf_data *grf; caddr_t regbase, fbbase; short curx, cury; short cursorx, cursory; @@ -87,6 +76,22 @@ struct ite_softc { caddr_t devdata; /* display dependent data */ }; +struct itesw { + void (*ite_init) __P((struct ite_data *)); + void (*ite_deinit) __P((struct ite_data *)); + void (*ite_clear) __P((struct ite_data *, int, int, int, int)); + void (*ite_putc) __P((struct ite_data *, int, int, int, int)); + void (*ite_cursor) __P((struct ite_data *, int)); + void (*ite_scroll) __P((struct ite_data *, int, int, int, int)); + u_char (*ite_readbyte) __P((struct ite_data *, int)); + void (*ite_writeglyph) __P((struct ite_data *, u_char *, u_char *)); +}; + +struct ite_softc { + struct ite_data *sc_data; /* terminal state info */ + struct grf_softc *sc_grf; /* pointer to framebuffer */ +}; + /* Flags */ #define ITE_ALIVE 0x01 /* hardware exists */ #define ITE_INITED 0x02 /* device has been initialized */ @@ -180,10 +185,26 @@ struct ite_softc { #define KBD_EXT_RIGHT_UP 0x93 #define TABSIZE 8 -#define TABEND(u) (ite_tty[u]->t_winsize.ws_col - TABSIZE) +#define TABEND(ip) ((ip)->tty->t_winsize.ws_col - TABSIZE) #ifdef _KERNEL +extern struct ite_data ite_cn; /* ite_data for console device */ +extern struct ite_data *kbd_ite; /* XXX */ extern struct ite_softc ite_softc[]; extern struct itesw itesw[]; +extern u_char console_attributes[]; extern int nitesw; + +/* ite.c prototypes */ +void ite_attach_grf __P((int, int)); +int iteon __P((struct ite_data *, int)); +void iteoff __P((struct ite_data *, int)); +void itefilter __P((char, char)); +int ite_major __P((void)); + +/* ite_subr.c prototypes */ +void ite_fontinfo __P((struct ite_data *)); +void ite_fontinit __P((struct ite_data *)); +u_char ite_readbyte __P((struct ite_data *, int)); +void ite_writeglyph __P((struct ite_data *, u_char *, u_char *)); #endif diff --git a/sys/arch/hp300/dev/mt.c b/sys/arch/hp300/dev/mt.c index 49defe6daf2..7f4574b8eee 100644 --- a/sys/arch/hp300/dev/mt.c +++ b/sys/arch/hp300/dev/mt.c @@ -1,4 +1,4 @@ -/* $NetBSD: mt.c,v 1.2 1995/12/02 18:22:04 thorpej Exp $ */ +/* $NetBSD: mt.c,v 1.3 1996/02/14 02:44:40 thorpej Exp $ */ /* * Copyright (c) 1992, The University of Utah and @@ -144,6 +144,7 @@ mtattach(hd) sc->sc_hpibno = hpibno; sc->sc_slave = slave; sc->sc_flags = MTF_EXISTS; + sc->sc_dq.dq_softc = sc; sc->sc_dq.dq_ctlr = hpibno; sc->sc_dq.dq_unit = unit; sc->sc_dq.dq_slave = slave; @@ -453,13 +454,14 @@ mtustart(unit) { hpib_softc[unit].sc_flags &= ~HPIBF_PPOLL; } void -spl_mtintr(unit) - int unit; +spl_mtintr(arg) + void *arg; { + struct mt_softc *sc = arg; int s = splbio(); - hpibppclear(mt_softc[unit].sc_hpibno); - mtintr(unit); + hpibppclear(sc->sc_hpibno); + mtintr(sc); (void) splx(s); } @@ -608,7 +610,7 @@ mtstart(unit) log(LOG_ERR, "mt%d can't reset\n", unit); goto fatalerror; } - timeout(spl_mtintr, (void *)unit, 4 * hz); + timeout(spl_mtintr, (void *)sc, 4 * hz); hpibawait(sc->sc_hpibno, sc->sc_slave); return; @@ -695,12 +697,14 @@ mtgo(unit) bp->b_un.b_addr, bp->b_bcount, rw, rw != 0); } -mtintr(unit) - register int unit; +int +mtintr(arg) + void *arg; { - register struct mt_softc *sc = &mt_softc[unit]; + register struct mt_softc *sc = arg; register struct buf *bp, *dp; register int i; + int unit = sc->sc_hd->hp_unit; u_char cmdbuf[4]; bp = mttab[unit].b_actf; @@ -744,7 +748,7 @@ mtintr(unit) * to the request for DSJ. It's probably just "busy" figuring * it out and will know in a little bit... */ - timeout(spl_mtintr, (void *)unit, hz >> 5); + timeout(spl_mtintr, (void *)sc, hz >> 5); return; default: @@ -761,7 +765,7 @@ mtintr(unit) sc->sc_stat3, sc->sc_stat5); if ((bp->b_flags & B_CMD) && bp->b_cmd == MTRESET) - untimeout(spl_mtintr, (void *)unit); + untimeout(spl_mtintr, (void *)sc); if (sc->sc_stat3 & SR3_POWERUP) sc->sc_flags &= MTF_OPEN | MTF_EXISTS; goto error; @@ -813,7 +817,7 @@ mtintr(unit) sc->sc_flags |= MTF_HITBOF; } if (bp->b_cmd == MTRESET) { - untimeout(spl_mtintr, (void *)unit); + untimeout(spl_mtintr, (void *)sc); sc->sc_flags |= MTF_ALIVE; } } else { diff --git a/sys/arch/hp300/dev/nhpib.c b/sys/arch/hp300/dev/nhpib.c index f7864d20ecb..481419347fa 100644 --- a/sys/arch/hp300/dev/nhpib.c +++ b/sys/arch/hp300/dev/nhpib.c @@ -1,4 +1,4 @@ -/* $NetBSD: nhpib.c,v 1.8 1995/12/02 18:22:06 thorpej Exp $ */ +/* $NetBSD: nhpib.c,v 1.9 1996/02/14 02:44:45 thorpej Exp $ */ /* * Copyright (c) 1982, 1990, 1993 @@ -81,7 +81,7 @@ int nhpibppoll __P((int)); void nhpibppwatch __P((void *)); void nhpibgo __P((int, int, int, void *, int, int, int)); void nhpibdone __P((int)); -int nhpibintr __P((int)); +int nhpibintr __P((void *)); /* * Our controller ops structure. @@ -362,7 +362,7 @@ nhpibreadtimo(arg) hs->sc_flags &= ~(HPIBF_DONE|HPIBF_IO|HPIBF_READ|HPIBF_TIMO); dmafree(&hs->sc_dq); dq = hs->sc_sq.dq_forw; - (dq->dq_driver->d_intr)(dq->dq_unit); + (dq->dq_driver->d_intr)(dq->dq_softc); } (void) splx(s); } @@ -400,14 +400,14 @@ nhpibdone(unit) } int -nhpibintr(unit) - register int unit; +nhpibintr(arg) + void *arg; { - register struct hpib_softc *hs = &hpib_softc[unit]; + register struct hpib_softc *hs = arg; register struct nhpibdevice *hd; register struct devqueue *dq; register int stat0; - int stat1; + int stat1, unit = hs->sc_hc->hp_unit; #ifdef lint if (stat1 = unit) return(1); @@ -428,13 +428,13 @@ nhpibintr(unit) hd->hpib_acr = AUX_TCA; hs->sc_flags &= ~(HPIBF_DONE|HPIBF_IO|HPIBF_READ|HPIBF_TIMO); dmafree(&hs->sc_dq); - (dq->dq_driver->d_intr)(dq->dq_unit); + (dq->dq_driver->d_intr)(dq->dq_softc); } else if (hs->sc_flags & HPIBF_PPOLL) { hd->hpib_mim = 0; stat0 = nhpibppoll(unit); if (stat0 & (0x80 >> dq->dq_slave)) { hs->sc_flags &= ~HPIBF_PPOLL; - (dq->dq_driver->d_intr)(dq->dq_unit); + (dq->dq_driver->d_intr)(dq->dq_softc); } #ifdef DEBUG else diff --git a/sys/arch/hp300/dev/ppi.c b/sys/arch/hp300/dev/ppi.c index d34eb549453..9560cd4d93a 100644 --- a/sys/arch/hp300/dev/ppi.c +++ b/sys/arch/hp300/dev/ppi.c @@ -1,4 +1,4 @@ -/* $NetBSD: ppi.c,v 1.7 1995/12/02 18:22:08 thorpej Exp $ */ +/* $NetBSD: ppi.c,v 1.8 1996/02/14 02:44:49 thorpej Exp $ */ /* * Copyright (c) 1982, 1990, 1993 @@ -114,6 +114,7 @@ ppiattach(hd) printf("\n"); sc->sc_flags = PPIF_ALIVE; + sc->sc_dq.dq_softc = sc; sc->sc_dq.dq_ctlr = hd->hp_ctlr; sc->sc_dq.dq_unit = hd->hp_unit; sc->sc_dq.dq_slave = hd->hp_slave; diff --git a/sys/arch/hp300/dev/rd.c b/sys/arch/hp300/dev/rd.c index f1224094bf6..74dce8628c0 100644 --- a/sys/arch/hp300/dev/rd.c +++ b/sys/arch/hp300/dev/rd.c @@ -1,4 +1,4 @@ -/* $NetBSD: rd.c,v 1.18 1996/01/10 20:54:29 thorpej Exp $ */ +/* $NetBSD: rd.c,v 1.20 1996/02/14 02:44:54 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -253,8 +253,6 @@ rdmatch(hd) rs->sc_dkdev.dk_name = rs->sc_xname; disk_attach(&rs->sc_dkdev); - return (0); - return (1); } @@ -266,6 +264,7 @@ rdattach(hd) (void)rdident(rs, hd, 1); /* XXX Ick. */ + rs->sc_dq.dq_softc = rs; rs->sc_dq.dq_ctlr = hd->hp_ctlr; rs->sc_dq.dq_unit = hd->hp_unit; rs->sc_dq.dq_slave = hd->hp_slave; @@ -788,10 +787,11 @@ rdgo(unit) rs->sc_addr, rs->sc_resid, rw, rw != 0); } -rdintr(unit) - register int unit; +rdintr(arg) + void *arg; { - register struct rd_softc *rs = &rd_softc[unit]; + register struct rd_softc *rs = arg; + int unit = rs->sc_hd->hp_unit; register struct buf *bp = rdtab[unit].b_actf; register struct hp_device *hp = rs->sc_hd; u_char stat = 13; /* in case hpibrecv fails */ diff --git a/sys/arch/hp300/dev/rdreg.h b/sys/arch/hp300/dev/rdreg.h index 9057532a7b1..65cf20a4569 100644 --- a/sys/arch/hp300/dev/rdreg.h +++ b/sys/arch/hp300/dev/rdreg.h @@ -1,4 +1,4 @@ -/* $NetBSD: rdreg.h,v 1.6 1995/12/31 04:11:43 thorpej Exp $ */ +/* $NetBSD: rdreg.h,v 1.7 1996/02/09 18:00:37 scottr Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -270,14 +270,7 @@ struct rd_describe { #define C_SREL 0x3b #define C_SSM 0x3e #define C_SRAM 0x48 -/* - * XXX XXX XXX THIS IS SUPPOSED TO FIT IN A 1-BYTE SPACE?! - */ -#if 0 -#define C_REL 0x140 -#else -#define C_REL 0x40 /* what ended up happening */ -#endif +#define C_REL 0xc0 #define C_CMD 0x05 #define C_EXEC 0x0e diff --git a/sys/arch/hp300/dev/scsi.c b/sys/arch/hp300/dev/scsi.c index b61f563dd8d..8f21b3b9846 100644 --- a/sys/arch/hp300/dev/scsi.c +++ b/sys/arch/hp300/dev/scsi.c @@ -1,4 +1,4 @@ -/* $NetBSD: scsi.c,v 1.7 1995/12/02 18:22:12 thorpej Exp $ */ +/* $NetBSD: scsi.c,v 1.8 1996/02/14 02:44:59 thorpej Exp $ */ /* * Copyright (c) 1990, 1993 @@ -72,15 +72,15 @@ extern void isrlink(); extern void _insque(); extern void _remque(); -int scsimatch(), scsigo(), scsiintr(), scsixfer(); +int scsimatch(), scsigo(), scsixfer(); void scsiattach(), scsistart(), scsidone(), scsifree(), scsireset(); +int scsiintr __P((void *)); struct driver scsidriver = { scsimatch, scsiattach, "scsi", (int (*)())scsistart, scsigo, scsiintr, (int (*)())scsidone, }; struct scsi_softc scsi_softc[NSCSI]; -struct isr scsi_isr[NSCSI]; int scsi_cmd_wait = SCSI_CMD_WAIT; int scsi_data_wait = SCSI_DATA_WAIT; @@ -257,10 +257,11 @@ scsiattach(hc) hs->sc_dq.dq_unit = hc->hp_unit; hs->sc_dq.dq_driver = &scsidriver; hs->sc_sq.dq_forw = hs->sc_sq.dq_back = &hs->sc_sq; - scsi_isr[hc->hp_unit].isr_intr = scsiintr; - scsi_isr[hc->hp_unit].isr_ipl = hc->hp_ipl; - scsi_isr[hc->hp_unit].isr_arg = hc->hp_unit; - isrlink(&scsi_isr[hc->hp_unit]); + + /* Establish the interrupt handler. */ + isrlink(scsiintr, hs, hc->hp_ipl, ISRPRI_BIO); + + /* Reset the controller. */ scsireset(hc->hp_unit); /* @@ -1156,14 +1157,15 @@ scsidone(unit) } int -scsiintr(unit) - register int unit; +scsiintr(arg) + void *arg; { - register struct scsi_softc *hs = &scsi_softc[unit]; + register struct scsi_softc *hs = arg; volatile register struct scsidevice *hd = (struct scsidevice *)hs->sc_hc->hp_addr; register u_char ints; register struct devqueue *dq; + int unit = hs->sc_hc->hp_unit; if ((hd->scsi_csr & (CSR_IE|CSR_IR)) != (CSR_IE|CSR_IR)) return (0); @@ -1186,7 +1188,7 @@ scsiintr(unit) finishxfer(hs, hd, dq->dq_slave); hs->sc_flags &=~ (SCSI_IO|SCSI_HAVEDMA); dmafree(&hs->sc_dq); - (dq->dq_driver->d_intr)(dq->dq_unit, hs->sc_stat[0]); + (dq->dq_driver->d_intr)(dq->dq_softc, hs->sc_stat[0]); } else { /* Something unexpected happened -- deal with it. */ hd->scsi_ints = ints; @@ -1197,7 +1199,7 @@ scsiintr(unit) hs->sc_flags &=~ (SCSI_IO|SCSI_HAVEDMA); dmafree(&hs->sc_dq); dq = hs->sc_sq.dq_forw; - (dq->dq_driver->d_intr)(dq->dq_unit, -1); + (dq->dq_driver->d_intr)(dq->dq_softc, -1); } } return(1); diff --git a/sys/arch/hp300/dev/sd.c b/sys/arch/hp300/dev/sd.c index 9355625f981..6260683c6be 100644 --- a/sys/arch/hp300/dev/sd.c +++ b/sys/arch/hp300/dev/sd.c @@ -1,4 +1,4 @@ -/* $NetBSD: sd.c,v 1.21 1996/01/07 22:02:18 thorpej Exp $ */ +/* $NetBSD: sd.c,v 1.22 1996/02/14 02:45:05 thorpej Exp $ */ /* * Copyright (c) 1990, 1993 @@ -358,6 +358,7 @@ sdattach(hd) (void)sdident(sc, hd, 1); /* XXX Ick. */ + sc->sc_dq.dq_softc = sc; sc->sc_dq.dq_ctlr = hd->hp_ctlr; sc->sc_dq.dq_unit = hd->hp_unit; sc->sc_dq.dq_slave = hd->hp_slave; @@ -1025,11 +1026,12 @@ sdgo(unit) } void -sdintr(unit, stat) - register int unit; +sdintr(arg, stat) + void *arg; int stat; { - register struct sd_softc *sc = &sd_softc[unit]; + register struct sd_softc *sc = arg; + int unit = sc->sc_hd->hp_unit; register struct buf *bp = sdtab[unit].b_actf; register struct hp_device *hp = sc->sc_hd; int cond; diff --git a/sys/arch/hp300/dev/st.c b/sys/arch/hp300/dev/st.c index 69841b2f550..cf38400ab1e 100644 --- a/sys/arch/hp300/dev/st.c +++ b/sys/arch/hp300/dev/st.c @@ -1,4 +1,4 @@ -/* $NetBSD: st.c,v 1.13 1995/12/02 18:22:18 thorpej Exp $ */ +/* $NetBSD: st.c,v 1.14 1996/02/14 02:45:12 thorpej Exp $ */ /* * Copyright (c) 1990 University of Utah. @@ -250,6 +250,7 @@ stattach(hd) (void)stident(sc, hd, 1); /* XXX Ick. */ + sc->sc_dq.dq_softc = sc; sc->sc_dq.dq_ctlr = hd->hp_ctlr; sc->sc_dq.dq_unit = hd->hp_unit; sc->sc_dq.dq_slave = hd->hp_slave; @@ -988,10 +989,12 @@ stioctl(dev, cmd, data, flag, p) return(0); } -stintr(unit, stat) - int unit, stat; +stintr(arg, stat) + void *arg; + int stat; { - register struct st_softc *sc = &st_softc[unit]; + register struct st_softc *sc = arg; + int unit = sc->sc_hd->hp_unit; register struct st_xsense *xp = &st_xsense[unit]; register struct buf *bp = sttab[unit].b_actf; struct hp_device *hp = sc->sc_hd; diff --git a/sys/arch/hp300/hp300/Locore.c b/sys/arch/hp300/hp300/Locore.c index 291a9cac06e..6a991ce0b30 100644 --- a/sys/arch/hp300/hp300/Locore.c +++ b/sys/arch/hp300/hp300/Locore.c @@ -1,4 +1,4 @@ -/* $NetBSD: Locore.c,v 1.11 1995/09/10 19:42:17 thorpej Exp $ */ +/* $NetBSD: Locore.c,v 1.12 1996/02/02 18:05:55 mycroft Exp $ */ /* * Copyright (c) 1982, 1986, 1990 The Regents of the University of California. @@ -35,23 +35,23 @@ * @(#)Locore.c 7.4 (Berkeley) 5/7/91 */ -#include "../include/pte.h" -#include "../includecpu.h" - -#include "sys/param.h" -#include "sys/systm.h" -#include "sys/user.h" -#include "sys/vm.h" -#include "sys/ioctl.h" -#include "sys/tty.h" -#include "sys/proc.h" -#include "sys/buf.h" -#include "sys/msgbuf.h" -#include "sys/mbuf.h" -#include "sys/protosw.h" -#include "sys/domain.h" -#include "sys/map.h" -#include "sys/dkbad.h" +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /* * Pseudo file for lint to show what is used/defined in locore.s. diff --git a/sys/arch/hp300/hp300/autoconf.c b/sys/arch/hp300/hp300/autoconf.c index 3eeb98387f3..e63e8d14670 100644 --- a/sys/arch/hp300/hp300/autoconf.c +++ b/sys/arch/hp300/hp300/autoconf.c @@ -1,6 +1,7 @@ -/* $NetBSD: autoconf.c,v 1.14 1995/12/30 18:25:25 thorpej Exp $ */ +/* $NetBSD: autoconf.c,v 1.18 1996/04/07 18:21:08 thorpej Exp $ */ /* + * Copyright (c) 1996 Jason R. Thorpe. All rights reserved. * Copyright (c) 1988 University of Utah. * Copyright (c) 1982, 1986, 1990, 1993 * The Regents of the University of California. All rights reserved. @@ -59,10 +60,15 @@ #include #include +#include + +#include #include #include #include + #include + #include #include #include @@ -74,7 +80,6 @@ */ int cold; /* if 1, still working on cold-start */ int cpuspeed = 0; /* relative cpu speed -- can be patched */ -struct isr isrqueue[NISR]; struct hp_hw sc_table[MAXCTLRS]; /* XXX must be allocated statically because of early console init */ @@ -95,6 +100,12 @@ configure() register struct hp_hw *hw; int found; + /* + * Find out what hardware is attached to the machine. + * XXX goes away with new config. + */ + find_devs(); + /* * XXX: these should be consolidated into some kind of table */ @@ -646,6 +657,107 @@ same_hw_device(hw, hd) char notmappedmsg[] = "WARNING: no space to map IO card, ignored\n"; +/* + * Scan all select codes, passing the corresponding VA to (*func)(). + * (*func)() is a driver-specific routine that looks for the console + * hardware. + */ +void +console_scan(func, arg) + int (*func) __P((int, caddr_t, void *)); + void *arg; +{ + int size, scode, sctop; + caddr_t pa, va; + + /* + * Scan all select codes. Check each location for some + * hardware. If there's something there, call (*func)(). + */ + sctop = (machineid == HP_320) ? 32 : 256; + for (scode = 0; scode < sctop; ++scode) { + /* + * Abort mission if console has been forced. + */ + if (conforced) + return; + + /* + * Skip over the select code hole and + * the internal HP-IB controller. + */ + if (((scode >= 32) && (scode < 132)) || + ((scode == 7) && internalhpib)) + continue; + + /* Map current PA. */ + pa = sctopa(scode); + va = iomap(pa, NBPG); + if (va == 0) + continue; + + /* Check to see if hardware exists. */ + if (badaddr(va)) { + iounmap(va, NBPG); + continue; + } + + /* + * Hardware present, call callback. Driver returns + * size of region to map if console probe successful + * and worthwhile. + */ + size = (*func)(scode, va, arg); + iounmap(va, NBPG); + if (size) { + /* Free last mapping. */ + if (convasize) + iounmap(conaddr, convasize); + convasize = 0; + + /* Remap to correct size. */ + va = iomap(pa, size); + if (va == 0) + continue; + + /* Save this state for next time. */ + conscode = scode; + conaddr = va; + convasize = size; + } + } +} + +/* + * Special version of cninit(). Actually, crippled somewhat. + * This version lets the drivers assign cn_tab. + */ +void +hp300_cninit() +{ + struct consdev *cp; + extern struct consdev constab[]; + + cn_tab = NULL; + + /* + * Call all of the console probe functions. + */ + for (cp = constab; cp->cn_probe; cp++) + (*cp->cn_probe)(cp); + + /* + * No console, we can handle it. + */ + if (cn_tab == NULL) + return; + + /* + * Turn on the console. + */ + (*cn_tab->cn_init)(cn_tab); +} + /* * Scan the IO space looking for devices. */ @@ -654,14 +766,9 @@ find_devs() short sc; u_char *id_reg; register caddr_t addr; - register struct hp_hw *hw; + register struct hp_hw *hw = sc_table; int didmap, sctop; - /* - * Initialize IO resource map for iomap(). - */ - rminit(extiomap, (long)EIOMAPSIZE, (long)1, "extio", EIOMAPSIZE/16); - hw = sc_table; /* * Probe all select codes + internal display addr */ @@ -681,6 +788,14 @@ find_devs() hw->hw_pa = (caddr_t) 0x478000; addr = internalhpib = (caddr_t) IIOV(hw->hw_pa); didmap = 0; + } else if (sc == conscode) { + /* + * If this is the console, it's already been + * mapped, and the address is known. + */ + hw->hw_pa = sctopa(sc); + addr = conaddr; + didmap = 0; } else { hw->hw_pa = sctopa(sc); addr = iomap(hw->hw_pa, NBPG); @@ -920,6 +1035,7 @@ iomap(pa, size) return(kva); } +void iounmap(kva, size) caddr_t kva; int size; @@ -937,27 +1053,6 @@ iounmap(kva, size) rmfree(extiomap, btoc(size), ix); } -isrinit() -{ - register int i; - - for (i = 0; i < NISR; i++) - isrqueue[i].isr_forw = isrqueue[i].isr_back = &isrqueue[i]; -} - -void -isrlink(isr) - register struct isr *isr; -{ - int i = ISRIPL(isr->isr_ipl); - - if (i < 0 || i >= NISR) { - printf("bad IPL %d\n", i); - panic("configure"); - } - insque(isr, isrqueue[i].isr_back); -} - /* * Configure swap space and related parameters. */ @@ -1095,3 +1190,11 @@ setroot() dumpdev = swdevt[0].sw_dev; #endif } + +#ifndef NEWCONFIG /* XXX */ +void +config_init() +{ + /* Stub, so kernel will link. */ +} +#endif diff --git a/sys/arch/hp300/hp300/conf.c b/sys/arch/hp300/hp300/conf.c index 1ee7df73428..3465cf0ba27 100644 --- a/sys/arch/hp300/hp300/conf.c +++ b/sys/arch/hp300/hp300/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.3 1996/02/21 12:53:44 mickey Exp $ */ +/* $NetBSD: conf.c,v 1.31 1996/03/14 21:26:28 christos Exp $ */ /*- * Copyright (c) 1991 The Regents of the University of California. @@ -140,6 +140,7 @@ cdev_decl(ccd); cdev_decl(vnd); cdev_decl(st); cdev_decl(fd); +dev_decl(filedesc,open); #include "bpfilter.h" cdev_decl(bpf); #include "tun.h" @@ -182,7 +183,7 @@ struct cdevsw cdevsw[] = cdev_notdef(), /* 18 */ cdev_disk_init(NVND,vnd), /* 19: vnode disk driver */ cdev_tape_init(NST,st), /* 20: SCSI tape */ - cdev_fd_init(1,fd), /* 21: file descriptor pseudo-device */ + cdev_fd_init(1,filedesc), /* 21: file descriptor pseudo-device */ cdev_bpftun_init(NBPFILTER,bpf),/* 22: Berkeley packet filter */ cdev_bpftun_init(NTUN,tun), /* 23: network tunnel */ cdev_lkm_init(NLKM,lkm), /* 24: loadable module driver */ @@ -289,16 +290,46 @@ chrtoblk(dev) */ #include -#define itecnpollc nullcnpollc -cons_decl(ite); -#define dcacnpollc nullcnpollc +#define dvboxcngetc itecngetc +#define dvboxcnputc itecnputc +#define dvboxcnpollc nullcnpollc +cons_decl(dvbox); + +#define gboxcngetc itecngetc +#define gboxcnputc itecnputc +#define gboxcnpollc nullcnpollc +cons_decl(gbox); + +#define hypercngetc itecngetc +#define hypercnputc itecnputc +#define hypercnpollc nullcnpollc +cons_decl(hyper); + +#define rboxcngetc itecngetc +#define rboxcnputc itecnputc +#define rboxcnpollc nullcnpollc +cons_decl(rbox); + +#define topcatcngetc itecngetc +#define topcatcnputc itecnputc +#define topcatcnpollc nullcnpollc +cons_decl(topcat); + +#define dcacnpollc nullcnpollc cons_decl(dca); -#define dcmcnpollc nullcnpollc + +#define dcmcnpollc nullcnpollc cons_decl(dcm); struct consdev constab[] = { #if NITE > 0 - cons_init(ite), +#if NGRF > 0 /* XXX */ + cons_init(dvbox), + cons_init(gbox), + cons_init(hyper), + cons_init(rbox), + cons_init(topcat), +#endif #endif #if NDCA > 0 cons_init(dca), diff --git a/sys/arch/hp300/hp300/disksubr.c b/sys/arch/hp300/hp300/disksubr.c index c6c8b84d5c4..5690b4d0329 100644 --- a/sys/arch/hp300/hp300/disksubr.c +++ b/sys/arch/hp300/hp300/disksubr.c @@ -1,4 +1,4 @@ -/* $NetBSD: disksubr.c,v 1.6 1995/08/08 06:23:08 thorpej Exp $ */ +/* $NetBSD: disksubr.c,v 1.8 1996/02/02 19:50:26 scottr Exp $ */ /* * Copyright (c) 1982, 1986, 1988, 1993 @@ -40,11 +40,11 @@ * @(#)ufs_disksubr.c 8.5 (Berkeley) 1/21/94 */ -#include "param.h" -#include "systm.h" -#include "buf.h" -#include "disklabel.h" -#include "syslog.h" +#include +#include +#include +#include +#include #define b_cylinder b_resid @@ -138,17 +138,12 @@ setdisklabel(olp, nlp, openmask, osdep) npp->p_cpg = opp->p_cpg; } } - nlp->d_checksum = 0; - nlp->d_checksum = dkcksum(nlp); + nlp->d_checksum = 0; + nlp->d_checksum = dkcksum(nlp); *olp = *nlp; return (0); } -/* encoding of disk minor numbers, should be elsewhere... */ -#define dkunit(dev) (minor(dev) >> 3) -#define dkpart(dev) (minor(dev) & 07) -#define dkminor(unit, part) (((unit) << 3) | (part)) - /* * Write disk label back to device after modification. */ @@ -164,14 +159,14 @@ writedisklabel(dev, strat, lp, osdep) int labelpart; int error = 0; - labelpart = dkpart(dev); + labelpart = DISKPART(dev); if (lp->d_partitions[labelpart].p_offset != 0) { if (lp->d_partitions[0].p_offset != 0) return (EXDEV); /* not quite right */ labelpart = 0; } bp = geteblk((int)lp->d_secsize); - bp->b_dev = makedev(major(dev), dkminor(dkunit(dev), labelpart)); + bp->b_dev = MAKEDISKDEV(major(dev), DISKUNIT(dev), labelpart); bp->b_blkno = LABELSECTOR; bp->b_bcount = lp->d_secsize; bp->b_flags = B_READ; @@ -208,7 +203,7 @@ bounds_check_with_label(bp, lp, wlabel) struct disklabel *lp; int wlabel; { - struct partition *p = &lp->d_partitions[dkpart(bp->b_dev)]; + struct partition *p = &lp->d_partitions[DISKPART(bp->b_dev)]; int labelsect = lp->d_partitions[0].p_offset; int maxsz = p->p_size; int sz = (bp->b_bcount + DEV_BSIZE - 1) >> DEV_BSHIFT; diff --git a/sys/arch/hp300/hp300/genassym.c b/sys/arch/hp300/hp300/genassym.c index c9315e169cb..5cd135a972e 100644 --- a/sys/arch/hp300/hp300/genassym.c +++ b/sys/arch/hp300/hp300/genassym.c @@ -1,4 +1,4 @@ -/* $NetBSD: genassym.c,v 1.16 1995/12/11 17:09:09 thorpej Exp $ */ +/* $NetBSD: genassym.c,v 1.18 1996/02/02 23:53:20 mycroft Exp $ */ /* * Copyright (c) 1982, 1990, 1993 @@ -39,8 +39,6 @@ #define _VA_LIST_ _BSD_VA_LIST_ #define _PTRDIFF_T_ _BSD_PTRDIFF_T_ -#define _KERNEL - #include #include #include @@ -50,6 +48,8 @@ #include #include +#include + #include #include #include @@ -57,7 +57,6 @@ #include #include -#include #ifdef USELEDS #include #endif @@ -66,7 +65,6 @@ #include #include #include -#include extern int errno; diff --git a/sys/arch/hp300/hp300/hpux_machdep.c b/sys/arch/hp300/hp300/hpux_machdep.c index 1bda82daa27..10bf2ed1cff 100644 --- a/sys/arch/hp300/hp300/hpux_machdep.c +++ b/sys/arch/hp300/hp300/hpux_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: hpux_machdep.c,v 1.1 1996/01/06 12:44:06 thorpej Exp $ */ +/* $NetBSD: hpux_machdep.c,v 1.2 1996/02/14 02:56:45 thorpej Exp $ */ /* * Copyright (c) 1995, 1996 Jason R. Thorpe. All rights reserved. diff --git a/sys/arch/hp300/hp300/isr.h b/sys/arch/hp300/hp300/isr.h index 3317d790a2e..3bf7d404388 100644 --- a/sys/arch/hp300/hp300/isr.h +++ b/sys/arch/hp300/hp300/isr.h @@ -1,8 +1,11 @@ -/* $NetBSD: isr.h,v 1.4 1994/10/26 07:25:37 cgd Exp $ */ +/* $NetBSD: isr.h,v 1.6 1996/02/28 01:03:53 thorpej Exp $ */ -/* - * Copyright (c) 1982, 1993 - * The Regents of the University of California. All rights reserved. +/*- + * Copyright (c) 1996 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -14,34 +17,50 @@ * 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. + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * - * @(#)isr.h 8.1 (Berkeley) 6/10/93 + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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. + */ + +#include + +/* + * The location and size of the autovectored interrupt portion + * of the vector table. */ +#define ISRLOC 0x18 +#define NISR 8 struct isr { - struct isr *isr_forw; - struct isr *isr_back; - int (*isr_intr)(); - int isr_arg; - int isr_ipl; + LIST_ENTRY(isr) isr_link; + int (*isr_func) __P((void *)); + void *isr_arg; + int isr_ipl; + int isr_priority; }; -#define NISR 3 -#define ISRIPL(x) ((x) - 3) +/* + * ISR priorities. These are not the same as interrupt levels. + */ +#define ISRPRI_BIO 0 +#define ISRPRI_NET 1 +#define ISRPRI_TTY 2 +#define ISRPRI_TTYNOBUF 3 + +void isrinit __P((void)); +void isrlink __P((int (*)(void *), void *, int, int)); +void isrdispatch __P((int)); diff --git a/sys/arch/hp300/hp300/locore.s b/sys/arch/hp300/hp300/locore.s index 514efd22c11..7b936b40c06 100644 --- a/sys/arch/hp300/hp300/locore.s +++ b/sys/arch/hp300/hp300/locore.s @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.47 1996/01/16 22:24:28 thorpej Exp $ */ +/* $NetBSD: locore.s,v 1.50 1996/02/14 02:56:56 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -515,80 +515,42 @@ Lsigr1: /* * Interrupt handlers. - * All DIO device interrupts are auto-vectored. Most can be configured - * to interrupt in the range IPL3 to IPL5. Here are our assignments: - * - * Level 0: Spurious: ignored. - * Level 1: HIL - * Level 2: - * Level 3: Internal HP-IB, DCM - * Level 4: "Fast" HP-IBs, SCSI - * Level 5: DMA, Ethernet, Built-in RS232 (DCA) - * Level 6: Clock - * Level 7: Non-maskable: parity errors, RESET key + * All device interrupts are auto-vectored. The CPU provides + * the vector 0x18+level. Note we count spurious interrupts, but + * we don't do anything else with them. */ - .globl _hilint, _intrhand, _hardclock, _nmihand, _dmaintr - .globl _dcafastservice -_spurintr: +#define INTERRUPT_SAVEREG moveml #0xC0C0,sp@- +#define INTERRUPT_RESTOREREG moveml sp@+,#0x0303 + + /* Externs. */ + .globl _hilint, _isrdispatch, _nmihand + .globl _hardclock, _statintr + +_spurintr: /* Level 0 */ addql #1,_intrcnt+0 addql #1,_cnt+V_INTR jra rei -_lev1intr: - moveml #0xC0C0,sp@- +_lev1intr: /* Level 1: HIL XXX this needs to go away */ + INTERRUPT_SAVEREG jbsr _hilint - moveml sp@+,#0x0303 + INTERRUPT_RESTOREREG addql #1,_intrcnt+4 addql #1,_cnt+V_INTR jra rei -/* - * Check for unbuffered serial port (DCA) interrupts first in an attempt - * to minimize received character lossage. Then we check for DMA activity - * to reduce overhead there. - */ -_lev5intr: - moveml #0xC0C0,sp@- - tstl _dcafastservice | unbuffered port active? - jeq Ltrydma | no, check DMA - clrl sp@- | yes, check DCA port 0 - jbsr _dcaintr | first to avoid overflow +_intrhand: /* Levels 2 through 5 */ + INTERRUPT_SAVEREG + movw sp@(22),sp@- | push exception vector info + clrw sp@- + jbsr _isrdispatch | call dispatch routine addql #4,sp - tstl d0 | did it belong to DCA? - jeq Ltrydma | no, go try DMA - moveml sp@+,#0x0303 - addql #1,_intrcnt+20 - addql #1,_cnt+V_INTR - jra rei -Ltrydma: - jbsr _dmaintr | check DMA channels - tstl d0 | was it ours? - jeq Lnotdma | no, go poll other devices - moveml sp@+,#0x0303 - addql #1,_intrcnt+24 - addql #1,_cnt+V_INTR - jra rei - -_lev2intr: -_lev3intr: -_lev4intr: - moveml #0xC0C0,sp@- -Lnotdma: - lea _intrcnt,a0 - movw sp@(22),d0 | use vector offset - andw #0xfff,d0 | sans frame type - addql #1,a0@(-0x60,d0:w) | to increment apropos counter - movw sr,sp@- | push current SR value - clrw sp@- | padded to longword - jbsr _intrhand | handle interrupt - addql #4,sp | pop SR - moveml sp@+,#0x0303 - addql #1,_cnt+V_INTR - jra rei + INTERRUPT_RESTOREREG + jra rei | all done -_lev6intr: - moveml #0xC0C0,sp@- | save scratch registers +_lev6intr: /* Level 6: clock */ + INTERRUPT_SAVEREG CLKADDR(a0) movb a0@(CLKSR),d0 | read clock status Lclkagain: @@ -599,7 +561,7 @@ Lnotim1: btst #2,d0 | timer3 interrupt? jeq Lnotim3 | no, skip statclock movpw a0@(CLKMSB3),d1 | clear timer3 interrupt - addql #1,_intrcnt+32 | count clock interrupts + addql #1,_intrcnt+28 | count clock interrupts lea sp@(16),a1 | a1 = &clockframe movl d0,sp@- | save status movl a1,sp@- @@ -610,7 +572,7 @@ Lnotim1: Lnotim3: btst #0,d0 | timer1 interrupt? jeq Lrecheck | no, skip hardclock - addql #1,_intrcnt+28 | count hardclock interrupts + addql #1,_intrcnt+24 | count hardclock interrupts lea sp@(16),a1 | a1 = &clockframe movl a1,sp@- #ifdef USELEDS @@ -653,11 +615,11 @@ Lrecheck: addql #1,_cnt+V_INTR | chalk up another interrupt movb a0@(CLKSR),d0 | see if anything happened jmi Lclkagain | while we were in hardclock/statintr - moveml sp@+,#0x0303 | restore scratch registers + INTERRUPT_RESTOREREG jra rei | all done -_lev7intr: - addql #1,_intrcnt+36 +_lev7intr: /* Level 7: Parity errors, reset key */ + addql #1,_intrcnt+32 clrl sp@- moveml #0xFFFF,sp@- | save registers movl usp,a0 | and save @@ -2036,12 +1998,11 @@ _intrnames: .asciz "lev3" .asciz "lev4" .asciz "lev5" - .asciz "dma" .asciz "clock" .asciz "statclock" .asciz "nmi" _eintrnames: .even _intrcnt: - .long 0,0,0,0,0,0,0,0,0,0 + .long 0,0,0,0,0,0,0,0,0 _eintrcnt: diff --git a/sys/arch/hp300/hp300/machdep.c b/sys/arch/hp300/hp300/machdep.c index df2eed1a657..061afa4d7b0 100644 --- a/sys/arch/hp300/hp300/machdep.c +++ b/sys/arch/hp300/hp300/machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.56 1996/01/16 22:24:33 thorpej Exp $ */ +/* $NetBSD: machdep.c,v 1.62 1996/03/13 23:42:45 scottr Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -75,16 +75,17 @@ #include #endif +#include #include #include #include #include + #include -#include -#include #define MAXMEM 64*1024*CLSIZE /* XXX - from cmap.h */ #include +#include /* the following is used externally (sysctl_hw) */ char machine[] = "hp300"; /* cpu "architecture" */ @@ -122,6 +123,16 @@ extern short exframesize[]; extern struct emul emul_hpux; #endif +/* + * Select code of console. Set to -1 if console is on + * "internal" framebuffer. + */ +int conscode; +int consinit_active; /* flag for driver init routines */ +caddr_t conaddr; /* for drivers in cn_init() */ +int convasize; /* size of mapped console device */ +int conforced; /* console has been forced */ + /* * Console initialization: called early on from main, * before vm init or startup. Do enough configuration @@ -129,9 +140,18 @@ extern struct emul emul_hpux; */ consinit() { + extern struct map extiomap[]; /* - * Set cpuspeed immediately since cninit() called routines + * Initialize some variables for sanity. + */ + consinit_active = 1; + convasize = 0; + conforced = 0; + conscode = 1024; /* invalid */ + + /* + * Set cpuspeed immediately since hp300_cninit() called routines * might use delay. Note that we only set it if a custom value * has not already been specified. */ @@ -161,15 +181,18 @@ consinit() if (mmutype == MMU_68040) cpuspeed *= 2; /* XXX */ } + /* - * Find what hardware is attached to this machine. - */ - find_devs(); + * Initialize the DIO resource map. + */ + rminit(extiomap, (long)EIOMAPSIZE, (long)1, "extio", EIOMAPSIZE/16); /* * Initialize the console before we print anything out. */ - cninit(); + hp300_cninit(); + + consinit_active = 0; #ifdef DDB ddb_init(); @@ -1138,9 +1161,9 @@ boot(howto) /* Run any shutdown hooks. */ doshutdownhooks(); -#ifdef PANICWAIT - if ((howto & RB_HALT) == 0) { - printf("hit any hey to reboot...\n"); +#if defined(PANICWAIT) && !defined(DDB) + if ((howto & RB_HALT) == 0 && panicstr) { + printf("hit any key to reboot...\n"); (void)cngetc(); printf("\n"); } @@ -1324,89 +1347,6 @@ badbaddr(addr) return(0); } -netintr() -{ -#ifdef INET - if (netisr & (1 << NETISR_ARP)) { - netisr &= ~(1 << NETISR_ARP); - arpintr(); - } - if (netisr & (1 << NETISR_IP)) { - netisr &= ~(1 << NETISR_IP); - ipintr(); - } -#endif -#ifdef NS - if (netisr & (1 << NETISR_NS)) { - netisr &= ~(1 << NETISR_NS); - nsintr(); - } -#endif -#ifdef ISO - if (netisr & (1 << NETISR_ISO)) { - netisr &= ~(1 << NETISR_ISO); - clnlintr(); - } -#endif -#ifdef CCITT - if (netisr & (1 << NETISR_CCITT)) { - netisr &= ~(1 << NETISR_CCITT); - ccittintr(); - } -#endif -#include "ppp.h" -#if NPPP > 0 - if (netisr & (1 << NETISR_PPP)) { - netisr &= ~(1 << NETISR_PPP); - pppintr(); - } -#endif -} - -intrhand(sr) - int sr; -{ - register struct isr *isr; - register int found = 0; - register int ipl; - extern struct isr isrqueue[]; - static int straycount; - - ipl = (sr >> 8) & 7; - switch (ipl) { - - case 3: - case 4: - case 5: - ipl = ISRIPL(ipl); - isr = isrqueue[ipl].isr_forw; - for (; isr != &isrqueue[ipl]; isr = isr->isr_forw) { - if ((isr->isr_intr)(isr->isr_arg)) { - found++; - break; - } - } - if (found) - straycount = 0; - else if (++straycount > 50) - panic("intrhand: stray interrupt"); - else - printf("stray interrupt, sr 0x%x\n", sr); - break; - - case 0: - case 1: - case 2: - case 6: - case 7: - if (++straycount > 50) - panic("intrhand: unexpected sr"); - else - printf("intrhand: unexpected sr 0x%x\n", sr); - break; - } -} - #if (defined(DDB) || defined(DEBUG)) && !defined(PANICBUTTON) #define PANICBUTTON #endif diff --git a/sys/arch/hp300/hp300/vectors.s b/sys/arch/hp300/hp300/vectors.s index 30bcd767db0..cc0dd5f2f3b 100644 --- a/sys/arch/hp300/hp300/vectors.s +++ b/sys/arch/hp300/hp300/vectors.s @@ -1,4 +1,4 @@ -| $NetBSD: vectors.s,v 1.6 1994/10/26 07:26:03 cgd Exp $ +| $NetBSD: vectors.s,v 1.7 1996/02/14 02:57:07 thorpej Exp $ | Copyright (c) 1988 University of Utah | Copyright (c) 1990, 1993 @@ -39,8 +39,8 @@ .globl _buserr,_addrerr .globl _illinst,_zerodiv,_chkinst,_trapvinst,_privinst,_trace .globl _badtrap - .globl _spurintr,_lev1intr,_lev2intr,_lev3intr - .globl _lev4intr,_lev5intr,_lev6intr,_lev7intr + .globl _spurintr,_lev1intr,_lev6intr,_lev7intr + .globl _intrhand .globl _trap0,_trap1,_trap2,_trap15 .globl _fpfline, _fpunsupp .globl _trap12 @@ -72,10 +72,10 @@ Lvectab: .long _badtrap /* 23: unassigned, reserved */ .long _spurintr /* 24: spurious interrupt */ .long _lev1intr /* 25: level 1 interrupt autovector */ - .long _lev2intr /* 26: level 2 interrupt autovector */ - .long _lev3intr /* 27: level 3 interrupt autovector */ - .long _lev4intr /* 28: level 4 interrupt autovector */ - .long _lev5intr /* 29: level 5 interrupt autovector */ + .long _intrhand /* 26: level 2 interrupt autovector */ + .long _intrhand /* 27: level 3 interrupt autovector */ + .long _intrhand /* 28: level 4 interrupt autovector */ + .long _intrhand /* 29: level 5 interrupt autovector */ .long _lev6intr /* 30: level 6 interrupt autovector */ .long _lev7intr /* 31: level 7 interrupt autovector */ .long _trap0 /* 32: syscalls */ diff --git a/sys/arch/hp300/hp300/vm_machdep.c b/sys/arch/hp300/hp300/vm_machdep.c index 98e8a0d8289..94a388da4d4 100644 --- a/sys/arch/hp300/hp300/vm_machdep.c +++ b/sys/arch/hp300/hp300/vm_machdep.c @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.26 1995/12/09 04:37:38 mycroft Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.28 1996/02/09 16:58:40 scottr Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -303,8 +303,11 @@ extern vm_map_t phys_map; * is a total crock, the multiple mappings of these physical pages should * be reflected in the higher-level VM structures to avoid problems. */ -vmapbuf(bp) +/*ARGSUSED*/ +void +vmapbuf(bp, sz) register struct buf *bp; + vm_size_t sz; { register int npf; register caddr_t addr; @@ -337,8 +340,11 @@ vmapbuf(bp) /* * Free the io map PTEs associated with this IO operation. */ -vunmapbuf(bp) +/*ARGSUSED*/ +void +vunmapbuf(bp, sz) register struct buf *bp; + vm_size_t sz; { register caddr_t addr; register int npf; diff --git a/sys/arch/hp300/include/hpux_machdep.h b/sys/arch/hp300/include/hpux_machdep.h index 2942a7d6448..e56155c00bc 100644 --- a/sys/arch/hp300/include/hpux_machdep.h +++ b/sys/arch/hp300/include/hpux_machdep.h @@ -1,9 +1,12 @@ -/* $NetBSD: hpux_machdep.h,v 1.1 1996/01/06 12:44:08 thorpej Exp $ */ +/* $NetBSD: hpux_machdep.h,v 1.3 1996/02/28 01:05:57 thorpej Exp $ */ -/* - * Copyright (c) 1995, 1996 Jason R. Thorpe. +/*- + * Copyright (c) 1996 The NetBSD Foundation, Inc. * All rights reserved. * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -14,22 +17,23 @@ * 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. + * This product includes software developed by the NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation 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 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 SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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. */ #ifndef _MACHINE_HPUX_MACHDEP_H_ diff --git a/sys/arch/hp300/include/param.h b/sys/arch/hp300/include/param.h index 7106a3408b1..b068e77e409 100644 --- a/sys/arch/hp300/include/param.h +++ b/sys/arch/hp300/include/param.h @@ -1,4 +1,4 @@ -/* $NetBSD: param.h,v 1.23 1995/08/13 00:22:40 mycroft Exp $ */ +/* $NetBSD: param.h,v 1.25 1996/03/04 05:04:23 cgd Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -45,7 +45,9 @@ /* * Machine dependent constants for HP9000 series 300. */ +#define _MACHINE hp300 #define MACHINE "hp300" +#define _MACHINE_ARCH m68k #define MACHINE_ARCH "m68k" #define MID_MACHINE MID_M68K4K diff --git a/sys/arch/hp300/stand/dca.c b/sys/arch/hp300/stand/dca.c index 9253d141bcc..7091886374d 100644 --- a/sys/arch/hp300/stand/dca.c +++ b/sys/arch/hp300/stand/dca.c @@ -1,4 +1,4 @@ -/* $NetBSD: dca.c,v 1.8 1995/10/04 06:54:44 thorpej Exp $ */ +/* $NetBSD: dca.c,v 1.9 1996/02/26 21:51:25 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -56,13 +56,15 @@ struct dcadevice *dcacnaddr = 0; +#define DCACONSCODE 9 /* XXX */ + void dcaprobe(cp) struct consdev *cp; { register struct dcadevice *dca; - dcacnaddr = (struct dcadevice *) sctoaddr(CONSCODE); + dcacnaddr = (struct dcadevice *) sctoaddr(DCACONSCODE); if (badaddr((char *)dcacnaddr)) { cp->cn_pri = CN_DEAD; return; @@ -86,7 +88,7 @@ dcaprobe(cp) } #endif - curcons_scode = CONSCODE; + curcons_scode = DCACONSCODE; } void diff --git a/sys/arch/hp300/stand/dcm.c b/sys/arch/hp300/stand/dcm.c index 936db32224d..4de3fa555bf 100644 --- a/sys/arch/hp300/stand/dcm.c +++ b/sys/arch/hp300/stand/dcm.c @@ -1,4 +1,4 @@ -/* $NetBSD: dcm.c,v 1.8 1995/10/04 06:54:45 thorpej Exp $ */ +/* $NetBSD: dcm.c,v 1.9 1996/02/27 22:11:44 scottr Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -51,6 +51,8 @@ struct dcmdevice *dcmcnaddr = NULL; +#define DCMCONUNIT 0 /* XXX */ + void dcmprobe(cp) struct consdev *cp; @@ -89,7 +91,7 @@ dcminit(cp) struct consdev *cp; { register struct dcmdevice *dcm = dcmcnaddr; - register int port = CONUNIT; + register int port = DCMCONUNIT; dcm->dcm_ic = IC_ID; while (dcm->dcm_thead[port].ptr != dcm->dcm_ttail[port].ptr) @@ -115,7 +117,7 @@ dcmgetchar(dev) register unsigned head; int c, stat, port; - port = CONUNIT; + port = DCMCONUNIT; pp = dcm_preg(dcm, port); head = pp->r_head & RX_MASK; if (head == (pp->r_tail & RX_MASK)) @@ -150,7 +152,7 @@ dcmputchar(dev, c) unsigned tail; int port, stat; - port = CONUNIT; + port = DCMCONUNIT; pp = dcm_preg(dcm, port); tail = pp->t_tail & TX_MASK; timo = 50000; diff --git a/sys/arch/hp300/stand/ite.c b/sys/arch/hp300/stand/ite.c index b8390e4c0f5..f48d8858427 100644 --- a/sys/arch/hp300/stand/ite.c +++ b/sys/arch/hp300/stand/ite.c @@ -1,4 +1,4 @@ -/* $NetBSD: ite.c,v 1.10 1995/10/04 06:54:47 thorpej Exp $ */ +/* $NetBSD: ite.c,v 1.11 1996/03/03 04:23:33 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -51,57 +51,51 @@ #include #include #include -#include +#include #include #include #include -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(); +void ite_deinit_noop __P((struct ite_data *)); 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, + { GID_TOPCAT, + topcat_init, ite_deinit_noop, topcat_clear, topcat_putc, + topcat_cursor, topcat_scroll, ite_readbyte, ite_writeglyph }, + + { GID_GATORBOX, + gbox_init, ite_deinit_noop, gbox_clear, gbox_putc, + gbox_cursor, gbox_scroll, ite_readbyte, ite_writeglyph }, + + { GID_RENAISSANCE, + rbox_init, ite_deinit_noop, rbox_clear, rbox_putc, + rbox_cursor, rbox_scroll, ite_readbyte, ite_writeglyph }, + + { GID_LRCATSEYE, + topcat_init, ite_deinit_noop, topcat_clear, topcat_putc, + topcat_cursor, topcat_scroll, ite_readbyte, ite_writeglyph }, + + { GID_HRCCATSEYE, + topcat_init, ite_deinit_noop, topcat_clear, topcat_putc, + topcat_cursor, topcat_scroll, ite_readbyte, ite_writeglyph }, + + { GID_HRMCATSEYE, + topcat_init, ite_deinit_noop, topcat_clear, topcat_putc, + topcat_cursor, topcat_scroll, ite_readbyte, ite_writeglyph }, + + { GID_DAVINCI, + dvbox_init, ite_deinit_noop, dvbox_clear, dvbox_putc, + dvbox_cursor, dvbox_scroll, ite_readbyte, ite_writeglyph }, + + { GID_HYPERION, + hyper_init, ite_deinit_noop, 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 }; +struct ite_data ite_data[NITE] = { 0 }; int ite_scode[NITE] = { 0 }; /* @@ -113,7 +107,7 @@ iteconfig() int dtype, fboff, i; struct hp_hw *hw; struct grfreg *gr; - struct ite_softc *ip; + struct ite_data *ip; i = 0; for (hw = sc_table; hw < &sc_table[MAXCTLRS]; hw++) { @@ -131,7 +125,7 @@ iteconfig() if (i >= NITE) break; ite_scode[i] = hw->hw_sc; - ip = &ite_softc[i]; + ip = &ite_data[i]; ip->isw = &itesw[dtype]; ip->regbase = (caddr_t) gr; fboff = (gr->gr_fbomsb << 8) | gr->gr_fbolsb; @@ -172,7 +166,7 @@ iteprobe(cp) struct consdev *cp; { register int ite; - register struct ite_softc *ip; + register struct ite_data *ip; int unit, pri; #ifdef CONSDEBUG @@ -190,7 +184,7 @@ iteprobe(cp) if (ite < whichconsole) continue; #endif - ip = &ite_softc[ite]; + ip = &ite_data[ite]; if ((ip->flags & (ITE_ALIVE|ITE_CONSOLE)) != (ITE_ALIVE|ITE_CONSOLE)) continue; @@ -212,12 +206,12 @@ iteinit(cp) struct consdev *cp; { int ite = cp->cn_dev; - struct ite_softc *ip; + struct ite_data *ip; if (itecons != -1) return; - ip = &ite_softc[ite]; + ip = &ite_data[ite]; ip->curx = 0; ip->cury = 0; @@ -237,7 +231,7 @@ iteputchar(dev, c) dev_t dev; register int c; { - register struct ite_softc *ip = &ite_softc[itecons]; + register struct ite_data *ip = &ite_data[itecons]; register struct itesw *sp = ip->isw; c &= 0x7F; @@ -276,7 +270,7 @@ iteputchar(dev, c) } itecheckwrap(ip, sp) - register struct ite_softc *ip; + register struct ite_data *ip; register struct itesw *sp; { if (++ip->curx == ip->cols) { @@ -292,7 +286,7 @@ itecheckwrap(ip, sp) } ite_clrtoeol(ip, sp, y, x) - register struct ite_softc *ip; + register struct ite_data *ip; register struct itesw *sp; register int y, x; { @@ -312,3 +306,10 @@ itegetchar(dev) #endif } #endif + +/* ARGSUSED */ +void +ite_deinit_noop(ip) + struct ite_data *ip; +{ +} diff --git a/sys/arch/hp300/stand/ite_dv.c b/sys/arch/hp300/stand/ite_dv.c index b636a2e7549..c7116eba1a4 100644 --- a/sys/arch/hp300/stand/ite_dv.c +++ b/sys/arch/hp300/stand/ite_dv.c @@ -1,4 +1,4 @@ -/* $NetBSD: ite_dv.c,v 1.7 1994/10/26 07:27:31 cgd Exp $ */ +/* $NetBSD: ite_dv.c,v 1.8 1996/03/03 04:23:35 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -47,15 +47,19 @@ #ifdef ITECONSOLE #include -#include +#include #include #include #define REGBASE ((struct dvboxfb *)(ip->regbase)) #define WINDOWMOVER dvbox_windowmove +void dvbox_windowmove __P((struct ite_data *, int, int, int, int, + int, int, int)); + +void dvbox_init(ip) - struct ite_softc *ip; + struct ite_data *ip; { int i; @@ -129,8 +133,9 @@ dvbox_init(ip) db_waitbusy(ip->regbase); } +void dvbox_putc(ip, c, dy, dx, mode) - register struct ite_softc *ip; + register struct ite_data *ip; register int dy, dx; int c, mode; { @@ -139,8 +144,9 @@ dvbox_putc(ip, c, dy, dx, mode) ip->ftheight, ip->ftwidth, RR_COPY); } +void dvbox_cursor(ip, flag) - register struct ite_softc *ip; + register struct ite_data *ip; register int flag; { if (flag == DRAW_CURSOR) @@ -153,8 +159,9 @@ dvbox_cursor(ip, flag) erase_cursor(ip) } +void dvbox_clear(ip, sy, sx, h, w) - struct ite_softc *ip; + struct ite_data *ip; register int sy, sx, h, w; { dvbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth, @@ -163,8 +170,9 @@ dvbox_clear(ip, sy, sx, h, w) RR_CLEAR); } +void dvbox_scroll(ip, sy, sx, count, dir) - register struct ite_softc *ip; + register struct ite_data *ip; register int sy, count; int dir, sx; { @@ -179,8 +187,9 @@ dvbox_scroll(ip, sy, sx, count, dir) ip->cols * ip->ftwidth, RR_COPY); } +void dvbox_windowmove(ip, sy, sx, dy, dx, h, w, func) - struct ite_softc *ip; + struct ite_data *ip; int sy, sx, dy, dx, h, w, func; { register struct dvboxfb *dp = REGBASE; diff --git a/sys/arch/hp300/stand/ite_gb.c b/sys/arch/hp300/stand/ite_gb.c index 9a4f7dcce2e..ac89d3845aa 100644 --- a/sys/arch/hp300/stand/ite_gb.c +++ b/sys/arch/hp300/stand/ite_gb.c @@ -1,4 +1,4 @@ -/* $NetBSD: ite_gb.c,v 1.7 1994/10/26 07:27:33 cgd Exp $ */ +/* $NetBSD: ite_gb.c,v 1.8 1996/03/03 04:23:36 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -48,15 +48,19 @@ #include -#include +#include #include #include #define REGBASE ((struct gboxfb *)(ip->regbase)) #define WINDOWMOVER gbox_windowmove +void gbox_windowmove __P((struct ite_data *, int, int, int, int, + int, int, int)); + +void gbox_init(ip) - register struct ite_softc *ip; + register struct ite_data *ip; { REGBASE->write_protect = 0x0; REGBASE->interrupt = 0x4; @@ -109,8 +113,9 @@ gbox_init(ip) ip->ftwidth, RR_COPYINVERTED); } +void gbox_putc(ip, c, dy, dx, mode) - register struct ite_softc *ip; + register struct ite_data *ip; register int dy, dx; int c, mode; { @@ -119,8 +124,9 @@ gbox_putc(ip, c, dy, dx, mode) ip->ftheight, ip->ftwidth, RR_COPY); } +void gbox_cursor(ip, flag) - register struct ite_softc *ip; + register struct ite_data *ip; register int flag; { if (flag == DRAW_CURSOR) @@ -133,8 +139,9 @@ gbox_cursor(ip, flag) erase_cursor(ip) } +void gbox_clear(ip, sy, sx, h, w) - struct ite_softc *ip; + struct ite_data *ip; register int sy, sx, h, w; { gbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth, @@ -153,8 +160,9 @@ gbox_clear(ip, sy, sx, h, w) (w) * ip->ftwidth, \ RR_COPY) +void gbox_scroll(ip, sy, sx, count, dir) - register struct ite_softc *ip; + register struct ite_data *ip; register int sy; int dir, sx, count; { @@ -171,8 +179,9 @@ gbox_scroll(ip, sy, sx, count, dir) gbox_blockmove(ip, sy + i, sx, dy + i, 0, 1, ip->cols); } +void gbox_windowmove(ip, sy, sx, dy, dx, h, w, mask) - register struct ite_softc *ip; + register struct ite_data *ip; int sy, sx, dy, dx, mask; register int h, w; { diff --git a/sys/arch/hp300/stand/ite_hy.c b/sys/arch/hp300/stand/ite_hy.c index 5823df0296b..f907cdd5085 100644 --- a/sys/arch/hp300/stand/ite_hy.c +++ b/sys/arch/hp300/stand/ite_hy.c @@ -1,4 +1,4 @@ -/* $NetBSD: ite_hy.c,v 1.2 1994/10/26 07:27:34 cgd Exp $ */ +/* $NetBSD: ite_hy.c,v 1.3 1996/03/03 04:23:37 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -48,7 +48,7 @@ #ifdef ITECONSOLE #include -#include +#include #include #include @@ -59,8 +59,13 @@ #define charX(ip,c) \ (((c) % (ip)->cpl) * ((((ip)->ftwidth + 7) / 8) * 8) + (ip)->fontx) +void hyper_ite_fontinit __P((struct ite_data *)); +void hyper_windowmove __P((struct ite_data *, int, int, int, int, + int, int, int)); + +void hyper_init(ip) - register struct ite_softc *ip; + register struct ite_data *ip; { int width; @@ -86,8 +91,9 @@ hyper_init(ip) ip->ftwidth, RR_COPYINVERTED); } +void hyper_ite_fontinit(ip) - register struct ite_softc *ip; + register struct ite_data *ip; { register u_char *fbmem, *dp; int c, l, b; @@ -114,8 +120,9 @@ hyper_ite_fontinit(ip) } } +void hyper_putc(ip, c, dy, dx, mode) - register struct ite_softc *ip; + register struct ite_data *ip; register int dy, dx; int c, mode; { @@ -124,8 +131,9 @@ hyper_putc(ip, c, dy, dx, mode) ip->ftheight, ip->ftwidth, RR_COPY); } +void hyper_cursor(ip, flag) - register struct ite_softc *ip; + register struct ite_data *ip; int flag; { switch (flag) { @@ -141,8 +149,9 @@ hyper_cursor(ip, flag) } } +void hyper_clear(ip, sy, sx, h, w) - struct ite_softc *ip; + struct ite_data *ip; register int sy, sx, h, w; { hyper_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth, @@ -151,8 +160,9 @@ hyper_clear(ip, sy, sx, h, w) RR_CLEAR); } +void hyper_scroll(ip, sy, sx, count, dir) - register struct ite_softc *ip; + register struct ite_data *ip; register int sy, count; int dir, sx; { @@ -247,8 +257,9 @@ int endtab[32] = 0xFFFFFFFE }; +void hyper_windowmove(ip, sy, sx, dy, dx, h, w, func) - struct ite_softc *ip; + struct ite_data *ip; int sy, sx, dy, dx, h, w, func; { unsigned int *psrcBase, *pdstBase; diff --git a/sys/arch/hp300/stand/ite_rb.c b/sys/arch/hp300/stand/ite_rb.c index a2390cc54a0..f2053da77f6 100644 --- a/sys/arch/hp300/stand/ite_rb.c +++ b/sys/arch/hp300/stand/ite_rb.c @@ -1,4 +1,4 @@ -/* $NetBSD: ite_rb.c,v 1.7 1994/10/26 07:27:37 cgd Exp $ */ +/* $NetBSD: ite_rb.c,v 1.8 1996/03/03 04:23:38 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -47,7 +47,7 @@ #ifdef ITECONSOLE #include -#include +#include #include #include @@ -55,8 +55,12 @@ #define REGBASE ((struct rboxfb *)(ip->regbase)) #define WINDOWMOVER rbox_windowmove +void rbox_windowmove __P((struct ite_data *, int, int, int, int, + int, int, int)); + +void rbox_init(ip) - struct ite_softc *ip; + struct ite_data *ip; { int i; @@ -125,8 +129,9 @@ rbox_init(ip) ip->ftwidth, RR_COPYINVERTED); } +void rbox_putc(ip, c, dy, dx, mode) - register struct ite_softc *ip; + register struct ite_data *ip; register int dy, dx; int c, mode; { @@ -135,8 +140,9 @@ rbox_putc(ip, c, dy, dx, mode) ip->ftheight, ip->ftwidth, RR_COPY); } +void rbox_cursor(ip, flag) - register struct ite_softc *ip; + register struct ite_data *ip; register int flag; { if (flag == DRAW_CURSOR) @@ -149,8 +155,9 @@ rbox_cursor(ip, flag) erase_cursor(ip) } +void rbox_clear(ip, sy, sx, h, w) - struct ite_softc *ip; + struct ite_data *ip; register int sy, sx, h, w; { rbox_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth, @@ -159,8 +166,9 @@ rbox_clear(ip, sy, sx, h, w) RR_CLEAR); } +void rbox_scroll(ip, sy, sx, count, dir) - register struct ite_softc *ip; + register struct ite_data *ip; register int sy, count; int dir, sx; { @@ -175,8 +183,9 @@ rbox_scroll(ip, sy, sx, count, dir) ip->cols * ip->ftwidth, RR_COPY); } +void rbox_windowmove(ip, sy, sx, dy, dx, h, w, func) - struct ite_softc *ip; + struct ite_data *ip; int sy, sx, dy, dx, h, w, func; { register struct rboxfb *rp = REGBASE; diff --git a/sys/arch/hp300/stand/ite_subr.c b/sys/arch/hp300/stand/ite_subr.c index 4a7ceca585e..5be4068b1a3 100644 --- a/sys/arch/hp300/stand/ite_subr.c +++ b/sys/arch/hp300/stand/ite_subr.c @@ -1,4 +1,4 @@ -/* $NetBSD: ite_subr.c,v 1.7 1994/10/26 07:27:39 cgd Exp $ */ +/* $NetBSD: ite_subr.c,v 1.8 1996/03/03 04:23:40 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -47,11 +47,11 @@ #ifdef ITECONSOLE #include -#include +#include #include ite_fontinfo(ip) - struct ite_softc *ip; + struct ite_data *ip; { u_long fontaddr = getword(ip, getword(ip, FONTROM) + FONTADDR); @@ -83,7 +83,7 @@ ite_fontinfo(ip) } ite_fontinit(ip) - register struct ite_softc *ip; + register struct ite_data *ip; { int bytewidth = (((ip->ftwidth - 1) / 8) + 1); int glyphsize = bytewidth * ip->ftheight; @@ -111,14 +111,15 @@ ite_fontinit(ip) */ u_char ite_readbyte(ip, disp) - struct ite_softc *ip; + struct ite_data *ip; int disp; { return((u_char) *(((u_char *)ip->regbase) + disp)); } +void ite_writeglyph(ip, fbmem, glyphp) - register struct ite_softc *ip; + register struct ite_data *ip; register u_char *fbmem, *glyphp; { register int bn; diff --git a/sys/arch/hp300/stand/ite_tc.c b/sys/arch/hp300/stand/ite_tc.c index cf0ea58df44..2f0d52a48ff 100644 --- a/sys/arch/hp300/stand/ite_tc.c +++ b/sys/arch/hp300/stand/ite_tc.c @@ -1,4 +1,4 @@ -/* $NetBSD: ite_tc.c,v 1.7 1994/10/26 07:27:41 cgd Exp $ */ +/* $NetBSD: ite_tc.c,v 1.8 1996/03/03 04:23:41 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -47,7 +47,7 @@ #ifdef ITECONSOLE #include -#include +#include #include #include #include @@ -55,8 +55,12 @@ #define REGBASE ((struct tcboxfb *)(ip->regbase)) #define WINDOWMOVER topcat_windowmove +void topcat_windowmove __P((struct ite_data *, int, int, int, int, + int, int, int)); + +void topcat_init(ip) - register struct ite_softc *ip; + register struct ite_data *ip; { /* @@ -110,8 +114,9 @@ topcat_init(ip) ip->ftwidth, RR_COPYINVERTED); } +void topcat_putc(ip, c, dy, dx, mode) - register struct ite_softc *ip; + register struct ite_data *ip; register int dy, dx; int c, mode; { @@ -120,8 +125,9 @@ topcat_putc(ip, c, dy, dx, mode) ip->ftheight, ip->ftwidth, RR_COPY); } +void topcat_cursor(ip, flag) - register struct ite_softc *ip; + register struct ite_data *ip; register int flag; { if (flag == DRAW_CURSOR) @@ -134,8 +140,9 @@ topcat_cursor(ip, flag) erase_cursor(ip) } +void topcat_clear(ip, sy, sx, h, w) - struct ite_softc *ip; + struct ite_data *ip; register int sy, sx, h, w; { topcat_windowmove(ip, sy * ip->ftheight, sx * ip->ftwidth, @@ -144,8 +151,9 @@ topcat_clear(ip, sy, sx, h, w) RR_CLEAR); } +void topcat_scroll(ip, sy, sx, count, dir) - register struct ite_softc *ip; + register struct ite_data *ip; register int sy, count; int dir, sx; { @@ -160,8 +168,9 @@ topcat_scroll(ip, sy, sx, count, dir) ip->cols * ip->ftwidth, RR_COPY); } +void topcat_windowmove(ip, sy, sx, dy, dx, h, w, func) - struct ite_softc *ip; + struct ite_data *ip; int sy, sx, dy, dx, h, w, func; { register struct tcboxfb *rp = REGBASE; -- 2.20.1