From 838edf78fd2b5cc334fedfc997d398112ab3821e Mon Sep 17 00:00:00 2001 From: thorpej Date: Tue, 17 Dec 1996 08:40:56 +0000 Subject: [PATCH] Snapshot of new config for NetBSD/hp300. This isn't quite finished yet. We're about 75% there. SCSI and HP-IB are not yet supported in a new config kernel; some autoconfiguration hackery has to be done there, yet. These changes are enough to network boot a diskless kernel. New config glue is enabled with the "NEWCONFIG" kernel option. If that option is not present, an old config kernel will be built. Any kernel configured with config(8) will automatically pick up the NEWCONFIG option from std.hp300. --- sys/arch/hp300/conf/NEWCONFIG | 147 +++++++++++++++ sys/arch/hp300/conf/files.hp300 | 185 +++++++++++++++++++ sys/arch/hp300/conf/std.hp300 | 16 ++ sys/arch/hp300/dev/Makefile | 7 + sys/arch/hp300/dev/dca.c | 177 +++++++++++++++--- sys/arch/hp300/dev/dcm.c | 294 +++++++++++++++++++++-------- sys/arch/hp300/dev/devlist2h.awk | 166 +++++++++++++++++ sys/arch/hp300/dev/dio.c | 306 +++++++++++++++++++++++++++++++ sys/arch/hp300/dev/diodevs | 103 +++++++++++ sys/arch/hp300/dev/dioreg.h | 140 ++++++++++++++ sys/arch/hp300/dev/diovar.h | 79 ++++++++ sys/arch/hp300/dev/grf.c | 144 ++++++++++++--- sys/arch/hp300/dev/grf_conf.c | 7 +- sys/arch/hp300/dev/grf_dv.c | 114 +++++++++++- sys/arch/hp300/dev/grf_gb.c | 112 ++++++++++- sys/arch/hp300/dev/grf_hy.c | 69 ++++++- sys/arch/hp300/dev/grf_machdep.c | 8 +- sys/arch/hp300/dev/grf_rb.c | 112 ++++++++++- sys/arch/hp300/dev/grf_subr.c | 122 ++++++++++++ sys/arch/hp300/dev/grf_tc.c | 169 ++++++++++++++++- sys/arch/hp300/dev/grfvar.h | 30 ++- sys/arch/hp300/dev/if_le.c | 79 +++++++- sys/arch/hp300/dev/if_levar.h | 4 +- sys/arch/hp300/dev/intio.c | 114 ++++++++++++ sys/arch/hp300/dev/intiovar.h | 49 +++++ sys/arch/hp300/dev/ite.c | 119 ++++++++++-- sys/arch/hp300/dev/ite_subr.c | 7 +- sys/arch/hp300/dev/itevar.h | 3 +- sys/arch/hp300/hp300/autoconf.c | 207 ++++++++++++--------- sys/arch/hp300/hp300/conf.c | 30 ++- 30 files changed, 2831 insertions(+), 288 deletions(-) create mode 100644 sys/arch/hp300/conf/NEWCONFIG create mode 100644 sys/arch/hp300/conf/files.hp300 create mode 100644 sys/arch/hp300/conf/std.hp300 create mode 100644 sys/arch/hp300/dev/Makefile create mode 100644 sys/arch/hp300/dev/devlist2h.awk create mode 100644 sys/arch/hp300/dev/dio.c create mode 100644 sys/arch/hp300/dev/diodevs create mode 100644 sys/arch/hp300/dev/dioreg.h create mode 100644 sys/arch/hp300/dev/diovar.h create mode 100644 sys/arch/hp300/dev/grf_subr.c create mode 100644 sys/arch/hp300/dev/intio.c create mode 100644 sys/arch/hp300/dev/intiovar.h diff --git a/sys/arch/hp300/conf/NEWCONFIG b/sys/arch/hp300/conf/NEWCONFIG new file mode 100644 index 000000000000..42f18c54db9b --- /dev/null +++ b/sys/arch/hp300/conf/NEWCONFIG @@ -0,0 +1,147 @@ +# $NetBSD: NEWCONFIG,v 1.1 1996/12/17 08:40:56 thorpej Exp $ +# +# "Generic" kernel for new-style config. +# + +# Include attributes common to all hp300s +include "arch/hp300/conf/std.hp300" + +# Support for various CPU types +options HP320 +options HP330 # includes 318, 319 +options HP340 +options HP350 +options HP360 +options HP370 +options HP375 # includes 345, 400t, 400s +options HP380 # includes 425t, 425s, 433s + +# Need to set locally +maxusers 32 + +# Standard system options +options COMPAT_43 # compatibility with 4.3BSD interfaces +options COMPAT_44 # compatibility with 4.4BSD binaries +options COMPAT_09 # compatibility with NetBSD 0.9 +options COMPAT_10 # compatibility with NetBSD 1.0 +options COMPAT_11 # compatibility with NetBSD 1.1 +options COMPAT_12 # compatibility with NetBSD 1.2 +options SYSVSHM # System V-style shared memory +options SYSVSEM # System V-style semaphores +options SYSVMSG # System V-style message queues +options KTRACE # system call tracing support +options "NKMEMCLUSTERS=1024" # # 4K pages in kernel malloc pool + +# Filesystem options +options FIFO # POSIX fifo support (in all filesystems) +options FFS,QUOTA # fast filesystem with user and group quotas +options CD9660 # CD-ROM ISO-9660 filesystem +options NFSSERVER # Network filesystem server +options NFSCLIENT # Network filesystem client +options UNION # Union filesystem (req. for FDESC) +options KERNFS # kernel data-structure filesystem +options FDESC # user file descriptor filesystem +options PROCFS # /proc filesystem +options MFS # Memory-based filesystem + +# Networking options +options INET # Internet protocols +options GATEWAY # IP forwarding + larger mb_map +options MROUTING # Multicast routing +options TCP_COMPAT_42 # compatibility with 4.2BSD TCP/IP + +# Options for HP hardware +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 +options UK_KEYBOARD # include United Kingdom HIL keymap +options SE_KEYBOARD # include Swedish HIL keymap + +# This option enables a different copyin/copyout that uses page +# mapping for large copies. +#options MAPPEDCOPY # different copyin/copyout for large copies + +# +# HP-UX binary compatibility. +# NOTE: THIS IS STILL VERY EXPERIMENTAL. YOUR MILEAGE MAY VARY. +# +options COMPAT_HPUX # HP-UX binary compatibility + +options COMPAT_M68K4K # compat. with NetBSD/m68k4k binaries + +# Debugging options +options DIAGNOSTIC # Extra kernel sanity checks +#options DEBUG # Enable misc. kernel debugging code +options DDB # Kernel Dynamic Debugger + +config netbsd swap generic + +mainbus0 at root # root "bus" + +intio0 at mainbus0 # internal i/o space +dio0 at mainbus0 # DIO/DIO-II bus + +# Davinci framebuffer +dvbox* at intio? +dvbox* at dio? scode ? + +# Gatorbox framebuffer +gbox* at intio? +gbox* at dio? scode ? + +# Hyperion framebuffer +hyper* at dio? scode ? + +# Renaissance framebuffer +rbox* at intio? +rbox* at dio? scode ? + +# Topcat/catseye framebuffers +topcat* at intio? +topcat* at dio? scode ? + +# Framebuffer abstraction +grf* at dvbox? +grf* at gbox? +grf* at hyper? +grf* at rbox? +grf* at topcat? + +# Internal Terminal Emulator +ite* at grf? + +dca0 at dio? scode 9 flags 1 # DCA serial interfaces +dca* at dio? scode ? + +dcm* at dio? scode ? flags 0xe # DCM 4- or 8-port serial interfaces + +le* at dio? scode ? # LANCE ethernet interfaces + +#nhpib0 at dio? scode 7 # slow internal HP-IB +#nhpib* at dio? scode ? + +#fhpib* at dio? scode ? # `fast' HP-IB + +#hpibbus* at nhpib? +#hpibbus* at fhpib? + +#rd* at hpibbus? slave ? punit ? # HP-IB disks +#ct* at hpibbus? slave ? punit ? # HP-IB cartridge tapes +#mt* at hpibbus? slave ? punit ? # HP-IB 9-track tape +#ppi0 at hpibbus0 slave 5 punit 0 # HP-IB plotter + +#oscsi* at dio? scode ? # Old HP SCSI + +#sd* at oscsi? target ? lun ? # SCSI disks +#st* at oscsi? target ? lun ? # SCSI tapes +#ac* at oscsi? target ? lun ? # SCSI changers + +pseudo-device pty 64 # pseudo ptys +pseudo-device sl 4 # SLIP network interfaces +pseudo-device ppp 4 # PPP network interfaces +pseudo-device bpfilter 16 # Berkeley packet filter +pseudo-device vnd 4 # vnode pseudo-disks +pseudo-device ccd 4 # concatenated disk devices +pseudo-device loop # loopback network interface diff --git a/sys/arch/hp300/conf/files.hp300 b/sys/arch/hp300/conf/files.hp300 new file mode 100644 index 000000000000..56ac2fe8bfde --- /dev/null +++ b/sys/arch/hp300/conf/files.hp300 @@ -0,0 +1,185 @@ +# $NetBSD: files.hp300,v 1.20 1996/12/17 08:40:57 thorpej Exp $ +# +# hp300-specific configuration info + +# maxpartitions must be the first item in files.${ARCH} +maxpartitions 8 + +maxusers 2 8 64 + +# NOTE! The order of these lines is significant! Don't change them +# unless you absolutely know what you're doing! + +# Frame buffer attribute +define grfdev { } + +# Frame buffer devices +device dvbox: grfdev +file arch/hp300/dev/grf_dv.c dvbox needs-flag + +device gbox: grfdev +file arch/hp300/dev/grf_gb.c gbox needs-flag + +device hyper: grfdev +file arch/hp300/dev/grf_hy.c hyper needs-flag + +device rbox: grfdev +file arch/hp300/dev/grf_rb.c rbox needs-flag + +device topcat: grfdev +file arch/hp300/dev/grf_tc.c topcat needs-flag + +# `grf' framebuffer abstraction +device grf { } +attach grf at grfdev +file arch/hp300/dev/grf.c grf needs-flag +file arch/hp300/dev/grf_subr.c grf + +# Internal Terminal Emulator +device ite +attach ite at grf +file arch/hp300/dev/ite.c ite needs-flag +file arch/hp300/dev/ite_subr.c ite + +# +# Mainbus +# + +device mainbus { } +attach mainbus at root + +# +# Internal i/o space +# + +device intio { } +attach intio at mainbus +file arch/hp300/dev/intio.c intio + +# Internal i/o framebuffer attachments +attach dvbox at intio with dvbox_intio +attach gbox at intio with gbox_intio +attach rbox at intio with rbox_intio +attach topcat at intio with topcat_intio + +# +# DIO bus +# + +device dio { scode = -1 } +attach dio at mainbus +file arch/hp300/dev/dio.c dio + +# DIO framebuffer attachments +attach dvbox at dio with dvbox_dio +attach gbox at dio with gbox_dio +attach hyper at dio with hyper_dio +attach rbox at dio with rbox_dio +attach topcat at dio with topcat_dio + +# DCA serial interface +device dca: tty +attach dca at dio +file arch/hp300/dev/dca.c dca needs-flag + +# DCM serial interface +device dcm: tty +attach dcm at dio +file arch/hp300/dev/dcm.c dcm needs-flag + +# LANCE ethernet +attach le at dio +file arch/hp300/dev/if_le.c le + +# HP-IB interfaces +define hpibdev { } + +device nhpib: hpibdev +attach nhpib at dio +file arch/hp300/dev/nhpib.c nhpib + +device fhpib: hpibdev +attach fhpib at dio +file arch/hp300/dev/fhpib.c fhpib + +# HP-IB bus layer +device hpibbus { slave = -1, punit = -1 } +attach hpibbus at hpibdev +file arch/hp300/dev/hpib.c hpibbus + +# HP-IB devices +device ct: tape +attach ct at hpibbus +file arch/hp300/dev/ct.c ct needs-flag + +device mt: tape +attach mt at hpibbus +file arch/hp300/dev/mt.c mt needs-flag + +device rd: disk +attach rd at hpibbus +file arch/hp300/dev/rd.c rd needs-flag +file arch/hp300/dev/rd_compat.c rd # XXX + +device ppi +attach ppi at hpibbus +file arch/hp300/dev/ppi.c ppi needs-flag + +# Old HP SCSI layer +device oscsi { target = -1, lun = -1 } +attach oscsi at dio +file arch/hp300/dev/scsi.c scsi + +# Old HP SCSI devices +device sd: disk +attach sd at oscsi +file arch/hp300/dev/sd.c sd needs-flag +file arch/hp300/dev/sd_compat.c sd # XXX + +device st: tape +attach st at oscsi +file arch/hp300/dev/st.c st needs-flag + +device ac +attach ac at oscsi +file arch/hp300/dev/ac.c ac needs-flag + +# Human (Hilarious) Interface Loop +# XXX should be a real device +file arch/hp300/dev/hil.c +file arch/hp300/dev/hil_keymaps.c + +# +# Non-device files +# + +file arch/hp300/hp300/autoconf.c +file arch/hp300/hp300/clock.c +file arch/hp300/hp300/conf.c +file arch/hp300/hp300/db_memrw.c ddb | kgdb +file arch/hp300/hp300/dkbad.c +file arch/hp300/hp300/kgdb_glue.c kgdb compile-with "${NORMAL_C} -fno-defer-pop" +file arch/hp300/hp300/kgdb_stub.c kgdb +file arch/hp300/hp300/machdep.c +file arch/hp300/hp300/isr.c +file arch/hp300/hp300/mem.c +file arch/hp300/hp300/pmap.c +file arch/hp300/hp300/pmap_bootstrap.c +file arch/hp300/hp300/sys_machdep.c +file arch/hp300/hp300/trap.c +file arch/hp300/hp300/vm_machdep.c +file arch/hp300/hp300/disksubr.c +file arch/hp300/dev/dma.c + +file arch/m68k/m68k/copy.s + +file dev/cons.c +file dev/cninit.c + +file kludge_for_in_proto.c hy needs-flag + +# +# HP-UX binary compatibility +# +include "compat/hpux/files.hpux" +file arch/hp300/hp300/hpux_machdep.c compat_hpux diff --git a/sys/arch/hp300/conf/std.hp300 b/sys/arch/hp300/conf/std.hp300 new file mode 100644 index 000000000000..c3fb3a58b0ae --- /dev/null +++ b/sys/arch/hp300/conf/std.hp300 @@ -0,0 +1,16 @@ +# $NetBSD: std.hp300,v 1.1 1996/12/17 08:40:58 thorpej Exp $ +# +# Options/devices that all hp300s should have +# + +machine hp300 m68k + +# XXX new config glue, for now +options NEWCONFIG + +options SWAPPAGER # swap pager (anonymous and swap space) +options VNODEPAGER # vnode pager (mapped files) +options DEVPAGER # device pager (mapped devices) + +options EXEC_AOUT # support for exec'ing a.out +options EXEC_SCRIPT # support for #! scripts diff --git a/sys/arch/hp300/dev/Makefile b/sys/arch/hp300/dev/Makefile new file mode 100644 index 000000000000..4c1653bc6ebb --- /dev/null +++ b/sys/arch/hp300/dev/Makefile @@ -0,0 +1,7 @@ +# $NetBSD: Makefile,v 1.1 1996/12/17 08:40:59 thorpej Exp $ + +AWK= awk + +diodevs.h diodevs_data.h: diodevs devlist2h.awk + /bin/rm -f diodevs.h diodevs_data.h + ${AWK} -f devlist2h.awk diodevs diff --git a/sys/arch/hp300/dev/dca.c b/sys/arch/hp300/dev/dca.c index 9a0056c35652..79358bd33d6b 100644 --- a/sys/arch/hp300/dev/dca.c +++ b/sys/arch/hp300/dev/dca.c @@ -1,4 +1,4 @@ -/* $NetBSD: dca.c,v 1.30 1996/12/09 03:14:06 thorpej Exp $ */ +/* $NetBSD: dca.c,v 1.31 1996/12/17 08:41:00 thorpej Exp $ */ /* * Copyright (c) 1995, 1996 Jason R. Thorpe. All rights reserved. @@ -36,9 +36,6 @@ * @(#)dca.c 8.2 (Berkeley) 1/12/94 */ -#include "dca.h" -#if NDCA > 0 - /* * Driver for the 98626/98644/internal serial interface on hp300/hp400, * based on the National Semiconductor INS8250/NS16550AF/WD16C552 UARTs. @@ -61,24 +58,28 @@ #include #include #include +#include #include #include #include +#ifndef NEWCONFIG #include +#endif + +#include +#include +#include #include #include -int dcamatch(); -void dcaattach(); -struct driver dcadriver = { - dcamatch, dcaattach, "dca", -}; - struct dca_softc { + struct device sc_dev; /* generic device glue */ +#ifndef NEWCONFIG struct hp_device *sc_hd; /* device info */ +#endif struct dcadevice *sc_dca; /* pointer to hardware */ struct tty *sc_tty; /* our tty instance */ int sc_oflows; /* overflow counter */ @@ -92,12 +93,33 @@ struct dca_softc { #define DCA_HASFIFO 0x0004 /* indicates unit has FIFO */ #define DCA_ISCONSOLE 0x0008 /* indicates unit is console */ -} dca_softc[NDCA]; +}; + +#ifdef NEWCONFIG +int dcamatch __P((struct device *, struct cfdata *, void *)); +void dcaattach __P((struct device *, struct device *, void *)); + +struct cfattach dca_ca = { + sizeof(struct dca_softc), dcamatch, dcaattach +}; + +struct cfdriver dca_cd = { + NULL, "dca", DV_TTY +}; +#else /* ! NEWCONFIG */ +int dcamatch(); +void dcaattach(); +struct driver dcadriver = { + dcamatch, dcaattach, "dca", +}; + +#include "dca.h" +struct dca_softc dca_softc[NDCA]; +#endif /* NEWCONFIG */ void dcastart(); int dcaparam(); int dcaintr __P((void *)); -int ndca = NDCA; int dcadefaultrate = TTYDEF_SPEED; int dcamajor; @@ -146,6 +168,26 @@ long dcamintcount[16]; void dcainit __P((struct dcadevice *, int)); +#ifdef NEWCONFIG +int +dcamatch(parent, match, aux) + struct device *parent; + struct cfdata *match; + void *aux; +{ + struct dio_attach_args *da = aux; + + switch (da->da_id) { + case DIO_DEVICE_ID_DCA0: + case DIO_DEVICE_ID_DCA0REM: + case DIO_DEVICE_ID_DCA1: + case DIO_DEVICE_ID_DCA1REM: + return (1); + } + + return (0); +} +#else /* ! NEWCONFIG */ int dcamatch(hd) register struct hp_device *hd; @@ -164,7 +206,21 @@ dcamatch(hd) return (1); } +#endif /* NEWCONFIG */ +#ifdef NEWCONFIG +void +dcaattach(parent, self, aux) + struct device *parent, *self; + void *aux; +{ + struct dca_softc *sc = (struct dca_softc *)self; + struct dio_attach_args *da = aux; + struct dcadevice *dca; + int unit = self->dv_unit; + int scode = da->da_scode; + int ipl; +#else /* ! NEWCONFIG */ void dcaattach(hd) register struct hp_device *hd; @@ -172,8 +228,12 @@ dcaattach(hd) int unit = hd->hp_unit; struct dcadevice *dca = (struct dcadevice *)hd->hp_addr; struct dca_softc *sc = &dca_softc[unit]; + int scode = hd->hp_args->hw_sc; + int ipl = hd->hp_ipl; +#endif /* NEWCONFIG */ - if (hd->hp_args->hw_sc == conscode) { + if (scode == conscode) { + dca = (struct dcadevice *)conaddr; sc->sc_flags |= DCA_ISCONSOLE; DELAY(100000); @@ -182,8 +242,29 @@ dcaattach(hd) * the console probe, so we have to fixup cn_dev here. */ cn_tab->cn_dev = makedev(dcamajor, unit); + } else { +#ifdef NEWCONFIG + dca = (struct dcadevice *)iomap(dio_scodetopa(da->da_scode), + da->da_size); + if (dca == NULL) { + printf("\n%s: can't map registers\n", + sc->sc_dev.dv_xname); + return; + } +#endif /* NEWCONFIG */ } + sc->sc_dca = dca; + +#ifdef NEWCONFIG + ipl = DIO_IPL(dca); + printf(" ipl %d", ipl); +#else /* ! NEWCONFIG */ + /* XXX Set the device class. */ + hd->hp_dev.dv_class = DV_TTY; + bcopy(&hd->hp_dev, &sc->sc_dev, sizeof(struct device)); +#endif /* NEWCONFIG */ + dca->dca_reset = 0xFF; DELAY(100); @@ -193,14 +274,16 @@ dcaattach(hd) if ((dca->dca_iir & IIR_FIFO_MASK) == IIR_FIFO_MASK) sc->sc_flags |= DCA_HASFIFO; - sc->sc_dca = dca; - /* Establish interrupt handler. */ - (void) isrlink(dcaintr, sc, hd->hp_ipl, + (void) isrlink(dcaintr, sc, ipl, (sc->sc_flags & DCA_HASFIFO) ? ISRPRI_TTY : ISRPRI_TTYNOBUF); sc->sc_flags |= DCA_ACTIVE; +#ifdef NEWCONFIG + if (self->dv_cfdata->cf_flags) +#else if (hd->hp_flags) +#endif sc->sc_flags |= DCA_SOFTCAR; /* Enable interrupts. */ @@ -234,17 +317,14 @@ dcaattach(hd) * Print prefix of device name, * let kgdb_connect print the rest. */ - printf("%s: ", sc->sc_hd->hp_xname); + printf("%s: ", sc->sc_dev.dv_xname); kgdb_connect(1); } else printf("%s: kgdb enabled\n", - sc->sc_hd->hp_xname); + sc->sc_dev.dv_xname); } } #endif - - /* XXX Set the device class. */ - hd->hp_dev.dv_class = DV_TTY; } /* ARGSUSED */ @@ -261,10 +341,16 @@ dcaopen(dev, flag, mode, p) u_char code; int s, error = 0; +#ifdef NEWCONFIG + if (unit >= dca_cd.cd_ndevs || + (sc = dca_cd.cd_devs[unit]) == NULL) + return (ENXIO); +#else if (unit >= NDCA) return (ENXIO); - sc = &dca_softc[unit]; +#endif /* NEWCONFIG */ + if ((sc->sc_flags & DCA_ACTIVE) == 0) return (ENXIO); @@ -358,7 +444,12 @@ dcaclose(dev, flag, mode, p) unit = DCAUNIT(dev); +#ifdef NEWCONFIG + sc = dca_cd.cd_devs[unit]; +#else sc = &dca_softc[unit]; +#endif + dca = sc->sc_dca; tp = sc->sc_tty; (*linesw[tp->t_line].l_close)(tp, flag); @@ -393,10 +484,17 @@ dcaread(dev, uio, flag) int flag; { int unit = DCAUNIT(dev); - struct dca_softc *sc = &dca_softc[unit]; - struct tty *tp = sc->sc_tty; + struct dca_softc *sc; + struct tty *tp; int error, of; + +#ifdef NEWCONFIG + sc = dca_cd.cd_devs[unit]; +#else + sc = &dca_softc[unit]; +#endif + tp = sc->sc_tty; of = sc->sc_oflows; error = (*linesw[tp->t_line].l_read)(tp, uio, flag); /* @@ -404,7 +502,7 @@ dcaread(dev, uio, flag) * at interrupt time just exacerbates the problem. */ if (sc->sc_oflows != of) - log(LOG_WARNING, "%s: silo overflow\n", sc->sc_hd->hp_xname); + log(LOG_WARNING, "%s: silo overflow\n", sc->sc_dev.dv_xname); return (error); } @@ -414,7 +512,12 @@ dcawrite(dev, uio, flag) struct uio *uio; int flag; { +#ifdef NEWCONFIG + struct dca_softc *sc = dca_cd.cd_devs[DCAUNIT(dev)]; + struct tty *tp = sc->sc_tty; +#else struct tty *tp = dca_softc[DCAUNIT(dev)].sc_tty; +#endif return ((*linesw[tp->t_line].l_write)(tp, uio, flag)); } @@ -423,8 +526,13 @@ struct tty * dcatty(dev) dev_t dev; { +#ifdef NEWCONFIG + struct dca_softc *sc = dca_cd.cd_devs[DCAUNIT(dev)]; +#else + struct dca_softc *sc = &dca_softc[DCAUNIT(dev)]; +#endif - return (dca_softc[DCAUNIT(dev)].sc_tty); + return (sc->sc_tty); } int @@ -432,7 +540,7 @@ dcaintr(arg) void *arg; { struct dca_softc *sc = arg; - int unit = sc->sc_hd->hp_unit; + int unit = sc->sc_dev.dv_unit; register struct dcadevice *dca = sc->sc_dca; register struct tty *tp = sc->sc_tty; register u_char code; @@ -515,7 +623,7 @@ dcaintr(arg) if (code & IIR_NOPEND) return (1); log(LOG_WARNING, "%s: weird interrupt: 0x%x\n", - sc->sc_hd->hp_xname, code); + sc->sc_dev.dv_xname, code); /* fall through */ case IIR_MLSC: dcamint(sc); @@ -594,7 +702,11 @@ dcaioctl(dev, cmd, data, flag, p) struct proc *p; { int unit = DCAUNIT(dev); +#ifdef NEWCONFIG + struct dca_softc *sc = dca_cd.cd_devs[unit]; +#else struct dca_softc *sc = &dca_softc[unit]; +#endif struct tty *tp = sc->sc_tty; struct dcadevice *dca = sc->sc_dca; int error; @@ -683,7 +795,11 @@ dcaparam(tp, t) register struct termios *t; { int unit = DCAUNIT(tp->t_dev); +#ifdef NEWCONFIG + struct dca_softc *sc = dca_cd.cd_devs[unit]; +#else struct dca_softc *sc = &dca_softc[unit]; +#endif struct dcadevice *dca = sc->sc_dca; int cfcr, cflag = t->c_cflag; int ospeed = ttspeedtab(t->c_ospeed, dcaspeedtab); @@ -759,7 +875,11 @@ dcastart(tp) register struct tty *tp; { int s, c, unit = DCAUNIT(tp->t_dev); +#ifdef NEWCONFIG + struct dca_softc *sc = dca_cd.cd_devs[unit]; +#else struct dca_softc *sc = &dca_softc[unit]; +#endif struct dcadevice *dca = sc->sc_dca; s = spltty(); @@ -1034,4 +1154,3 @@ dcacnputc(dev, c) stat = dca_cn->dca_iir; splx(s); } -#endif /* NDCA > 0 */ diff --git a/sys/arch/hp300/dev/dcm.c b/sys/arch/hp300/dev/dcm.c index 570a55efe445..fe87112dd588 100644 --- a/sys/arch/hp300/dev/dcm.c +++ b/sys/arch/hp300/dev/dcm.c @@ -1,4 +1,4 @@ -/* $NetBSD: dcm.c,v 1.33 1996/12/09 03:14:08 thorpej Exp $ */ +/* $NetBSD: dcm.c,v 1.34 1996/12/17 08:41:01 thorpej Exp $ */ /* * Copyright (c) 1995, 1996 Jason R. Thorpe. All rights reserved. @@ -49,8 +49,6 @@ * Test console support. */ -#include "dcm.h" -#if NDCM > 0 /* * 98642/MUX */ @@ -65,13 +63,20 @@ #include #include #include +#include #include #include #include +#ifndef NEWCONFIG #include +#endif + +#include +#include +#include #include #include @@ -79,12 +84,6 @@ #define DEFAULT_BAUD_RATE 9600 #endif -int dcmmatch(), dcmparam(); -void dcmattach(), dcmstart(); -struct driver dcmdriver = { - dcmmatch, dcmattach, "dcm", -}; - struct speedtab dcmspeedtab[] = { 0, BR_0, 50, BR_50, @@ -223,7 +222,10 @@ static char iconv[16] = { #define NDCMPORT 4 struct dcm_softc { + struct device sc_dev; /* generic device glue */ +#ifndef NEWCONFIG struct hp_device *sc_hd; /* device info */ +#endif struct dcmdevice *sc_dcm; /* pointer to hardware */ struct tty *sc_tty[NDCMPORT]; /* our tty instances */ struct modemreg *sc_modem[NDCMPORT]; /* modem control */ @@ -249,71 +251,98 @@ struct dcm_softc { #ifdef DCMSTATS struct dcmstats sc_stats; /* metrics gathering */ #endif -} dcm_softc[NDCM]; +}; + +#ifdef NEWCONFIG +int dcmmatch __P((struct device *, struct cfdata *, void *)); +void dcmattach __P((struct device *, struct device *, void *)); + +struct cfattach dcm_ca = { + sizeof(struct dcm_softc), dcmmatch, dcmattach +}; + +struct cfdriver dcm_cd = { + NULL, "dcm", DV_TTY +}; +#else /* ! NEWCONFIG */ +int dcmmatch(); +void dcmattach(); + +struct driver dcmdriver = { + dcmmatch, dcmattach, "dcm", +}; + +#include "dcm.h" +struct dcm_softc dcm_softc[NDCM]; +#endif /* NEWCONFIG */ + +int dcmparam(); +void dcmstart(); void dcminit __P((struct dcmdevice *, int, int)); int dcmintr __P((void *)); +int dcmselftest __P((struct dcm_softc *)); + +#ifdef NEWCONFIG +int +dcmmatch(parent, match, aux) + struct device *parent; + struct cfdata *match; + void *aux; +{ + struct dio_attach_args *da = aux; + + switch (da->da_id) { + case DIO_DEVICE_ID_DCM: + case DIO_DEVICE_ID_DCMREM: + return (1); + } + + return (0); +} +#else /* ! NEWCONFIG */ int dcmmatch(hd) register struct hp_device *hd; { struct dcm_softc *sc = &dcm_softc[hd->hp_unit]; - struct dcmdevice *dcm; - int i, timo = 0; - int s, brd, mbits; + struct dcmdevice *dcm = (struct dcmdevice *)hd->hp_addr; - dcm = (struct dcmdevice *)hd->hp_addr; if ((dcm->dcm_rsid & 0x1f) != DCMID) return (0); - brd = hd->hp_unit; - sc->sc_hd = hd; hd->hp_ipl = DCMIPL(dcm->dcm_ic); - - /* - * Empirically derived self-test magic - */ - s = spltty(); - dcm->dcm_rsid = DCMRS; - DELAY(50000); /* 5000 is not long enough */ - dcm->dcm_rsid = 0; - dcm->dcm_ic = IC_IE; - dcm->dcm_cr = CR_SELFT; - while ((dcm->dcm_ic & IC_IR) == 0) - if (++timo == 20000) - return (0); - DELAY(50000); /* XXX why is this needed ???? */ - while ((dcm->dcm_iir & IIR_SELFT) == 0) - if (++timo == 400000) - return (0); - DELAY(50000); /* XXX why is this needed ???? */ - if (dcm->dcm_stcon != ST_OK) { - if (hd->hp_args->hw_sc != conscode) - printf("dcm%d: self test failed: %x\n", - brd, dcm->dcm_stcon); - return (0); - } - dcm->dcm_ic = IC_ID; - splx(s); - - return (1); } +#endif /* NEWCONFIG */ +#ifdef NEWCONFIG +void +dcmattach(parent, self, aux) + struct device *parent, *self; + void *aux; +{ + struct dcm_softc *sc = (struct dcm_softc *)self; + struct dio_attach_args *da = aux; + struct dcmdevice *dcm; + int brd = self->dv_unit; + int scode = da->da_scode; + int i, mbits, ipl; +#else /* ! NEWCONFIG */ void dcmattach(hd) register struct hp_device *hd; { struct dcm_softc *sc = &dcm_softc[hd->hp_unit]; - struct dcmdevice *dcm; - int i, timo = 0; - int s, brd, mbits; + struct dcmdevice *dcm = (struct dcmdevice *)hd->hp_addr; + int brd = hd->hp_unit; + int scode = hd->hp_args->hw_sc; + int i, mbits, ipl = hd->hp_ipl; +#endif /* NEWCONFIG */ - dcm = sc->sc_dcm = (struct dcmdevice *)hd->hp_addr; - - brd = hd->hp_unit; - if (hd->hp_args->hw_sc == conscode) { + if (scode == conscode) { + dcm = (struct dcmdevice *)conaddr; sc->sc_flags |= DCM_ISCONSOLE; /* @@ -322,17 +351,48 @@ dcmattach(hd) * Note that we always assume port 1 on the board. */ cn_tab->cn_dev = makedev(dcmmajor, (brd << 2) | DCMCONSPORT); + } else { +#ifdef NEWCONFIG + dcm = (struct dcmdevice *)iomap(dio_scodetopa(da->da_scode), + da->da_size); + if (dcm == NULL) { + printf("\n%s: can't map registers\n", + sc->sc_dev.dv_xname); + return; + } +#endif + } + + sc->sc_dcm = dcm; + +#ifdef NEWCONFIG + ipl = DIO_IPL(dcm); + printf(" ipl %d", ipl); +#else /* ! NEWCONFIG */ + /* XXX Set the device class. */ + hd->hp_dev.dv_class = DV_TTY; + bcopy(&hd->hp_dev, &sc->sc_dev, sizeof(struct device)); +#endif /* NEWCONFIG */ + + if (dcmselftest(sc)) { + printf("\n%s: self-test failed\n", sc->sc_dev.dv_xname); + return; } /* Extract configuration info from flags. */ +#ifdef NEWCONFIG + sc->sc_softCAR = self->dv_cfdata->cf_flags & DCM_SOFTCAR; + sc->sc_flags = self->dv_cfdata->cf_flags & DCM_FLAGMASK; +#else sc->sc_softCAR = (hd->hp_flags & DCM_SOFTCAR); sc->sc_flags = (hd->hp_flags & DCM_FLAGMASK); +#endif /* NEWCONFIG */ /* Mark our unit as configured. */ sc->sc_flags |= DCM_ACTIVE; /* Establish the interrupt handler. */ - (void) isrlink(dcmintr, sc, hd->hp_ipl, ISRPRI_TTY); + (void) isrlink(dcmintr, sc, ipl, ISRPRI_TTY); if (dcmistype == DIS_TIMER) dcmsetischeme(brd, DIS_RESET|DIS_TIMER); @@ -381,21 +441,18 @@ dcmattach(hd) dcminit(dcm, DCMPORT(DCMUNIT(kgdb_dev)), kgdb_rate); if (kgdb_debug_init) { - printf("%s port %d: ", sc->sc_hd->hp_xname, + printf("%s port %d: ", sc->sc_dev.dv_xname, DCMPORT(DCMUNIT(kgdb_dev))); kgdb_connect(1); } else printf("%s port %d: kgdb enabled\n", - sc->sc_hd->hp_xname, + sc->sc_dev.dv_xname, DCMPORT(DCMUNIT(kgdb_dev))); } /* end could be replaced */ -#endif +#endif /* KGDB_CHEAT */ } -#endif - - /* XXX Set device class. */ - hd->hp_dev.dv_class = DV_TTY; +#endif /* KGDB */ } /* ARGSUSED */ @@ -414,10 +471,16 @@ dcmopen(dev, flag, mode, p) brd = DCMBOARD(unit); port = DCMPORT(unit); +#ifdef NEWCONFIG + if (brd >= dcm_cd.cd_ndevs || port >= NDCMPORT || + (sc = dcm_cd.cd_devs[brd]) == NULL) + return (ENXIO); +#else /* ! NEWCONFIG */ if ((brd >= NDCM) || (port >= NDCMPORT)) return (ENXIO); - sc = &dcm_softc[brd]; +#endif /* NEWCONFIG */ + if ((sc->sc_flags & DCM_ACTIVE) == 0) return (ENXIO); @@ -471,7 +534,7 @@ dcmopen(dev, flag, mode, p) #ifdef DEBUG if (dcmdebug & DDB_MODEM) printf("%s: dcmopen port %d softcarr %c\n", - sc->sc_hd->hp_xname, port, + sc->sc_dev.dv_xname, port, (tp->t_state & TS_CARR_ON) ? '1' : '0'); #endif @@ -493,7 +556,7 @@ dcmopen(dev, flag, mode, p) #ifdef DEBUG if (dcmdebug & DDB_OPENCLOSE) printf("%s port %d: dcmopen: st %x fl %x\n", - sc->sc_hd->hp_xname, port, tp->t_state, tp->t_flags); + sc->sc_dev.dv_xname, port, tp->t_state, tp->t_flags); #endif if (error == 0) error = (*linesw[tp->t_line].l_open)(dev, tp); @@ -516,7 +579,11 @@ dcmclose(dev, flag, mode, p) board = DCMBOARD(unit); port = DCMPORT(unit); +#ifdef NEWCONFIG + sc = dcm_cd.cd_devs[board]; +#else sc = &dcm_softc[board]; +#endif tp = sc->sc_tty[port]; (*linesw[tp->t_line].l_close)(tp, flag); @@ -529,7 +596,7 @@ dcmclose(dev, flag, mode, p) #ifdef DEBUG if (dcmdebug & DDB_OPENCLOSE) printf("%s port %d: dcmclose: st %x fl %x\n", - sc->sc_hd->hp_xname, port, tp->t_state, tp->t_flags); + sc->sc_dev.dv_xname, port, tp->t_state, tp->t_flags); #endif splx(s); ttyclose(tp); @@ -555,7 +622,11 @@ dcmread(dev, uio, flag) board = DCMBOARD(unit); port = DCMPORT(unit); +#ifdef NEWCONFIG + sc = dcm_cd.cd_devs[board]; +#else sc = &dcm_softc[board]; +#endif tp = sc->sc_tty[port]; return ((*linesw[tp->t_line].l_read)(tp, uio, flag)); @@ -575,7 +646,11 @@ dcmwrite(dev, uio, flag) board = DCMBOARD(unit); port = DCMPORT(unit); +#ifdef NEWCONFIG + sc = dcm_cd.cd_devs[board]; +#else sc = &dcm_softc[board]; +#endif tp = sc->sc_tty[port]; return ((*linesw[tp->t_line].l_write)(tp, uio, flag)); @@ -592,7 +667,11 @@ dcmtty(dev) board = DCMBOARD(unit); port = DCMPORT(unit); +#ifdef NEWCONFIG + sc = dcm_cd.cd_devs[board]; +#else sc = &dcm_softc[board]; +#endif return (sc->sc_tty[port]); } @@ -604,7 +683,7 @@ dcmintr(arg) 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 brd = sc->sc_dev.dv_unit; int code, i; int pcnd[4], mcode, mcnd[4]; @@ -634,7 +713,7 @@ dcmintr(arg) #ifdef DEBUG if (dcmdebug & DDB_INTR) { printf("%s: dcmintr: iir %x pc %x/%x/%x/%x ", - sc->sc_hd->hp_xname, code, pcnd[0], pcnd[1], + sc->sc_dev.dv_xname, code, pcnd[0], pcnd[1], pcnd[2], pcnd[3]); printf("miir %x mc %x/%x/%x/%x\n", mcode, mcnd[0], mcnd[1], mcnd[2], mcnd[3]); @@ -776,7 +855,7 @@ dcmreadbuf(sc, port) #ifdef DEBUG if (dcmdebug & DDB_INPUT) printf("%s port %d: dcmreadbuf: c%x('%c') s%x f%x h%x t%x\n", - sc->sc_hd->hp_xname, port, + sc->sc_dev.dv_xname, port, c&0xFF, c, stat&0xFF, tp->t_flags, head, pp->r_tail); #endif @@ -787,7 +866,7 @@ dcmreadbuf(sc, port) #ifdef DEBUG if (dcmdebug & (DDB_INPUT|DDB_SIOERR)) printf("%s port %d: dcmreadbuf: err: c%x('%c') s%x\n", - sc->sc_hd->hp_xname, port, + sc->sc_dev.dv_xname, port, stat, c&0xFF, c); #endif if (stat & (RD_BD | RD_FE)) @@ -797,11 +876,11 @@ dcmreadbuf(sc, port) else if (stat & RD_OVF) log(LOG_WARNING, "%s port %d: silo overflow\n", - sc->sc_hd->hp_xname, port); + sc->sc_dev.dv_xname, port); else if (stat & RD_OE) log(LOG_WARNING, "%s port %d: uart overflow\n", - sc->sc_hd->hp_xname, port); + sc->sc_dev.dv_xname, port); } (*linesw[tp->t_line].l_rint)(c, tp); } @@ -841,7 +920,7 @@ dcmmint(sc, port, mcnd) #ifdef DEBUG if (dcmdebug & DDB_MODEM) printf("%s port %d: dcmmint: mcnd %x mcndlast %x\n", - sc->sc_hd->hp_xname, port, mcnd, sc->sc_mcndlast[port]); + sc->sc_dev.dv_xname, port, mcnd, sc->sc_mcndlast[port]); #endif delta = mcnd ^ sc->sc_mcndlast[port]; sc->sc_mcndlast[port] = mcnd; @@ -885,14 +964,18 @@ dcmioctl(dev, cmd, data, flag, p) port = DCMPORT(unit); board = DCMBOARD(unit); +#ifdef NEWCONFIG + sc = dcm_cd.cd_devs[board]; +#else sc = &dcm_softc[board]; +#endif dcm = sc->sc_dcm; tp = sc->sc_tty[port]; #ifdef DEBUG if (dcmdebug & DDB_IOCTL) printf("%s port %d: dcmioctl: cmd %x data %x flag %x\n", - sc->sc_hd->hp_xname, port, cmd, *data, flag); + sc->sc_dev.dv_xname, port, cmd, *data, flag); #endif error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p); if (error >= 0) @@ -1000,7 +1083,11 @@ dcmparam(tp, t) board = DCMBOARD(unit); port = DCMPORT(unit); +#ifdef NEWCONFIG + sc = dcm_cd.cd_devs[board]; +#else sc = &dcm_softc[board]; +#endif dcm = sc->sc_dcm; /* check requested parameters */ @@ -1039,7 +1126,7 @@ dcmparam(tp, t) #ifdef DEBUG if (dcmdebug & DDB_PARAM) printf("%s port %d: dcmparam: cflag %x mode %x speed %d uperch %d\n", - sc->sc_hd->hp_xname, port, cflag, mode, tp->t_ospeed, + sc->sc_dev.dv_xname, port, cflag, mode, tp->t_ospeed, DCM_USPERCH(tp->t_ospeed)); #endif @@ -1087,7 +1174,11 @@ dcmstart(tp) board = DCMBOARD(unit); port = DCMPORT(unit); +#ifdef NEWCONFIG + sc = dcm_cd.cd_devs[board]; +#else sc = &dcm_softc[board]; +#endif dcm = sc->sc_dcm; s = spltty(); @@ -1097,7 +1188,7 @@ dcmstart(tp) #ifdef DEBUG if (dcmdebug & DDB_OUTPUT) printf("%s port %d: dcmstart: state %x flags %x outcc %d\n", - sc->sc_hd->hp_xname, port, tp->t_state, tp->t_flags, + sc->sc_dev.dv_xname, port, tp->t_state, tp->t_flags, tp->t_outq.c_cc); #endif if (tp->t_state & (TS_TIMEOUT|TS_BUSY|TS_TTSTOP)) @@ -1179,7 +1270,7 @@ again: #ifdef DEBUG if (dcmdebug & DDB_INTR) printf("%s port %d: dcmstart(%d): head %x tail %x outqcc %d\n", - sc->sc_hd->hp_xname, port, head, tail, tp->t_outq.c_cc); + sc->sc_dev.dv_xname, port, head, tail, tp->t_outq.c_cc); #endif out: #ifdef DCMSTATS @@ -1225,13 +1316,18 @@ dcmmctl(dev, bits, how) unit = DCMUNIT(dev); brd = DCMBOARD(unit); port = DCMPORT(unit); + +#ifdef NEWCONFIG + sc = dcm_cd.cd_devs[brd]; +#else sc = &dcm_softc[brd]; +#endif dcm = sc->sc_dcm; #ifdef DEBUG if (dcmdebug & DDB_MODEM) printf("%s port %d: dcmmctl: bits 0x%x how %x\n", - sc->sc_hd->hp_xname, port, bits, how); + sc->sc_dev.dv_xname, port, bits, how); #endif s = spltty(); @@ -1275,7 +1371,11 @@ dcmmctl(dev, bits, how) dcmsetischeme(brd, flags) int brd, flags; { +#ifdef NEWCONFIG + struct dcm_softc *sc = dcm_cd.cd_devs[brd]; +#else struct dcm_softc *sc = &dcm_softc[brd]; +#endif struct dcmdevice *dcm = sc->sc_dcm; struct dcmischeme *dis = &sc->sc_scheme; int i; @@ -1285,11 +1385,11 @@ dcmsetischeme(brd, flags) #ifdef DEBUG if (dcmdebug & DDB_INTSCHM) printf("%s: dcmsetischeme(%d): cur %d, ints %d, chars %d\n", - sc->sc_hd->hp_xname, perchar, dis->dis_perchar, + sc->sc_dev.dv_xname, perchar, dis->dis_perchar, dis->dis_intr, dis->dis_char); if ((flags & DIS_RESET) == 0 && perchar == dis->dis_perchar) { printf("%s: dcmsetischeme: redundent request %d\n", - sc->sc_hd->hp_xname, perchar); + sc->sc_dev.dv_xname, perchar); return; } #endif @@ -1371,6 +1471,45 @@ dcminit(dcm, port, rate) splx(s); } +/* + * Empirically derived self-test magic + */ +int +dcmselftest(sc) + struct dcm_softc *sc; +{ + struct dcmdevice *dcm = sc->sc_dcm; + int i, timo = 0; + int s, brd, mbits; + + s = spltty(); + dcm->dcm_rsid = DCMRS; + DELAY(50000); /* 5000 is not long enough */ + dcm->dcm_rsid = 0; + dcm->dcm_ic = IC_IE; + dcm->dcm_cr = CR_SELFT; + while ((dcm->dcm_ic & IC_IR) == 0) + if (++timo == 20000) + return (1); + DELAY(50000); /* XXX why is this needed ???? */ + while ((dcm->dcm_iir & IIR_SELFT) == 0) + if (++timo == 400000) + return (1); + DELAY(50000); /* XXX why is this needed ???? */ + if (dcm->dcm_stcon != ST_OK) { +#if 0 + if (hd->hp_args->hw_sc != conscode) + printf("dcm%d: self test failed: %x\n", + brd, dcm->dcm_stcon); +#endif + return (1); + } + dcm->dcm_ic = IC_ID; + splx(s); + + return (0); +} + /* * Following are all routines needed for DCM to act as console */ @@ -1561,4 +1700,3 @@ dcmcnputc(dev, c) } splx(s); } -#endif /* NDCM > 0 */ diff --git a/sys/arch/hp300/dev/devlist2h.awk b/sys/arch/hp300/dev/devlist2h.awk new file mode 100644 index 000000000000..082e525011ad --- /dev/null +++ b/sys/arch/hp300/dev/devlist2h.awk @@ -0,0 +1,166 @@ +#! /usr/bin/awk -f +# +# $NetBSD: devlist2h.awk,v 1.1 1996/12/17 08:41:02 thorpej Exp $ +# +# Copyright (c) 1996 Jason R. Thorpe. All rights reserved. +# Copyright (c) 1995, 1996 Christopher G. Demetriou +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. All advertising materials mentioning features or use of this software +# must display the following acknowledgement: +# This product includes software developed by Christopher G. Demetriou. +# 4. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +BEGIN { + ndevices = 0 + fbid = 0 + dfile="diodevs_data.h" + hfile="diodevs.h" +} +NR == 1 { + VERSION = $0 + gsub("\\$", "", VERSION) + + printf("/*\n") > dfile + printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \ + > dfile + printf(" *\n") > dfile + printf(" * generated from:\n") > dfile + printf(" *\t%s\n", VERSION) > dfile + printf(" */\n") > dfile + + printf("/*\n") > hfile + printf(" * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n") \ + > hfile + printf(" *\n") > hfile + printf(" * generated from:\n") > hfile + printf(" *\t%s\n", VERSION) > hfile + printf(" */\n") > hfile + + next +} +$1 == "device" { + ndevices++ + + devices[ndevices, 1] = $2 # nickname + devices[ndevices, 2] = $3 # dio primary id + devices[ndevices, 3] = "0" # dio secondary id + devices[ndevices, 4] = $4 # number of select codes + # used by device + + # if this is the framebuffer entry, save the primary id + if ($2 == "FRAMEBUFFER") { + fbid = $3; + } + + # emit device primary id + printf("\n#define\tDIO_DEVICE_ID_%s\t%s\n", devices[ndevices, 1], \ + devices[ndevices, 2]) > hfile + + # emit description + printf("#define\tDIO_DEVICE_DESC_%s\t\"", devices[ndevices, 1]) \ + > hfile + + f = 5; + + while (f <= NF) { + printf("%s", $f) > hfile + if (f < NF) + printf(" ") > hfile + f++; + } + printf("\"\n") > hfile + + next +} +$1 == "framebuffer" { + ndevices++ + + devices[ndevices, 1] = $2 # nickname + devices[ndevices, 2] = fbid # dio primary id + devices[ndevices, 3] = $3 # dio secondary id + devices[ndevices, 4] = $4 # number of select codes + # used by device + + # emit device secondary id + printf("\n#define\tDIO_DEVICE_SECID_%s\t%s\n", devices[ndevices, 1], \ + devices[ndevices, 3]) > hfile + + # emit description + printf("#define\tDIO_DEVICE_DESC_%s\t\"", devices[ndevices, 1]) \ + > hfile + + f = 5; + + while (f <= NF) { + printf("%s", $f) > hfile + if (f < NF) + printf(" ") > hfile + f++; + } + printf("\"\n") > hfile + + next +} +{ + if ($0 == "") + blanklines++ + if (blanklines != 2 && blanklines != 3) + print $0 > hfile + if (blanklines < 2) + print $0 > dfile +} +END { + # emit device count + + printf("\n") > dfile + printf("#define DIO_NDEVICES\t%d\n", ndevices) > dfile + + # emit select code size table + + printf("\n") > dfile + + printf("struct dio_devdata dio_devdatas[] = {\n") > dfile + for (i = 1; i <= ndevices; i++) { + printf("\t{ %s,\t%s,\t%s },\n", devices[i, 2], + devices[i, 3], devices[i, 4]) > dfile + } + + printf("};\n") > dfile + + # emit description table + + printf("\n") > dfile + printf("#ifdef DIOVERBOSE\n") > dfile + + printf("struct dio_devdesc dio_devdescs[] = {\n") > dfile + + for (i = 1; i <= ndevices; i++) { + printf("\t{ %s,\t%s,\tDIO_DEVICE_DESC_%s },\n", + devices[i, 2], devices[i, 3], devices[i, 1]) > dfile + } + + printf("};\n") > dfile + + printf("#endif /* DIOVERBOSE */\n") > dfile +} diff --git a/sys/arch/hp300/dev/dio.c b/sys/arch/hp300/dev/dio.c new file mode 100644 index 000000000000..85b5d2b9d985 --- /dev/null +++ b/sys/arch/hp300/dev/dio.c @@ -0,0 +1,306 @@ +/* $NetBSD: dio.c,v 1.1 1996/12/17 08:41:02 thorpej Exp $ */ + +/*- + * 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: + * 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 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 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. + */ + +/* + * Autoconfiguration and mapping support for the DIO bus. + */ + +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include +#include + +extern caddr_t internalhpib; + +int dio_scodesize __P((struct dio_attach_args *)); +char *dio_devinfo __P((struct dio_attach_args *, char *, size_t)); + +#ifdef NEWCONFIG +int diomatch __P((struct device *, struct cfdata *, void *)); +void dioattach __P((struct device *, struct device *, void *)); +int dioprint __P((void *, const char *)); +int diosubmatch __P((struct device *, struct cfdata *, void *)); + +struct cfattach dio_ca = { + sizeof(struct device), diomatch, dioattach +}; + +struct cfdriver dio_cd = { + NULL, "dio", DV_DULL +}; + +int +diomatch(parent, match, aux) + struct device *parent; + struct cfdata *match; + void *aux; +{ + static int dio_matched = 0; + + /* Allow only one instance. */ + if (dio_matched) + return (0); + + dio_matched = 1; + return (1); +} + +void +dioattach(parent, self, aux) + struct device *parent, *self; + void *aux; +{ + struct dio_attach_args da; + caddr_t pa, va; + int scode, scmax, didmap, scodesize; + + scmax = DIO_SCMAX(machineid); + printf("\n"); + + for (scode = 0; scode < scmax; ) { + if (DIO_INHOLE(scode)) { + scode++; + continue; + } + + didmap = 0; + + /* + * Temporarily map the space corresponding to + * the current select code unless: + * - this is the internal hpib select code, + * - this is the console select code. + */ + pa = dio_scodetopa(scode); + if (scode == conscode) + va = conaddr; + else if ((scode == 7) && internalhpib) + va = internalhpib = (caddr_t)IIOV(pa); + else { + va = iomap(pa, NBPG); + if (va == NULL) { + printf("%s: can't map scode %d\n", scode); + scode++; + continue; + } + didmap = 1; + } + + /* Check for hardware. */ + if (badaddr(va)) { + if (didmap) + iounmap(va, NBPG); + scode++; + continue; + } + + /* Fill out attach args. */ + bzero(&da, sizeof(da)); + da.da_scode = scode; + da.da_id = DIO_ID(va); + + if (DIO_ISFRAMEBUFFER(da.da_id)) + da.da_secid = DIO_SECID(va); + + da.da_size = DIO_SIZE(scode, va); + scodesize = dio_scodesize(&da); + if (DIO_ISDIO(scode)) + da.da_size *= scodesize; + + /* No longer need the device to be mapped. */ + if (didmap) + iounmap(va, NBPG); + + /* Attach matching device. */ + config_found_sm(self, &da, dioprint, diosubmatch); + scode += scodesize; + } +} + +int +diosubmatch(parent, cf, aux) + struct device *parent; + struct cfdata *cf; + void *aux; +{ + struct dio_attach_args *da = aux; + + if (cf->diocf_scode != DIO_UNKNOWN_SCODE && + cf->diocf_scode != da->da_scode) + return (0); + + return ((*cf->cf_attach->ca_match)(parent, cf, aux)); +} + +int +dioprint(aux, pnp) + void *aux; + const char *pnp; +{ + struct dio_attach_args *da = aux; + char buf[128]; + + if (pnp) + printf("%s at %s", dio_devinfo(da, buf, sizeof(buf)), pnp); + printf(" scode %d", da->da_scode); + return (UNCONF); +} +#endif /* NEWCONFIG */ + +/* + * Convert a select code to a system physical address. + */ +void * +dio_scodetopa(scode) + int scode; +{ + u_long rval; + + if (scode == 7 && internalhpib) + rval = DIO_IHPIBADDR; + else if (DIO_ISDIO(scode)) + rval = DIO_BASE + (scode * DIO_DEVSIZE); + else if (DIO_ISDIOII(scode)) + rval = DIOII_BASE + (scode * DIOII_DEVSIZE); + else + rval = 0; + + return ((void *)rval); +} + +/* + * Return the select code size for this device, defaulting to 1 + * if we don't know what kind of device we have. + */ +int +dio_scodesize(da) + struct dio_attach_args *da; +{ + int i; + + /* + * Deal with lame internal HP-IB controllers which don't have + * consistent/reliable device ids. + */ + if (da->da_scode == 7 && internalhpib) + return (1); + + /* + * Find the dio_devdata matchind the primary id. + * If we're a framebuffer, we also check the secondary id. + */ + for (i = 0; i < DIO_NDEVICES; i++) { + if (da->da_id == dio_devdatas[i].dd_id) { + if (DIO_ISFRAMEBUFFER(da->da_id)) { + if (da->da_secid == dio_devdatas[i].dd_secid) { + goto foundit; + } + } else { + foundit: + return (dio_devdatas[i].dd_nscode); + } + } + } + + /* + * Device is unknown. Print a warning and assume a default. + */ + printf("WARNING: select code size unknown for id = 0x%x secid = 0x%x\n", + da->da_id, da->da_secid); + return (1); +} + +/* + * Return a reasonable description of a DIO device. + */ +char * +dio_devinfo(da, buf, buflen) + struct dio_attach_args *da; + char *buf; + size_t buflen; +{ + int i; + + bzero(buf, buflen); + + /* + * Deal with lame internal HP-IB controllers which don't have + * consistent/reliable device ids. + */ + if (da->da_scode == 7 && internalhpib) { + sprintf(buf, DIO_DEVICE_DESC_IHPIB); + return (buf); + } + +#ifdef DIOVERBOSE + /* + * Find the description matching our primary id. + * If we're a framebuffer, we also check the secondary id. + */ + for (i = 0; i < DIO_NDEVICES; i++) { + if (da->da_id == dio_devdescs[i].dd_id) { + if (DIO_ISFRAMEBUFFER(da->da_id)) { + if (da->da_secid == dio_devdescs[i].dd_secid) { + goto foundit; + } + } else { + foundit: + sprintf(buf, "%s", dio_devdescs[i].dd_desc); + return (buf); + } + } + } +#endif /* DIOVERBOSE */ + + /* + * Device is unknown. Construct something reasonable. + */ + sprintf(buf, "device id = 0x%x secid = 0x%x", + da->da_id, da->da_secid); + return (buf); +} diff --git a/sys/arch/hp300/dev/diodevs b/sys/arch/hp300/dev/diodevs new file mode 100644 index 000000000000..f6b5f779880a --- /dev/null +++ b/sys/arch/hp300/dev/diodevs @@ -0,0 +1,103 @@ +$NetBSD: diodevs,v 1.1 1996/12/17 08:41:03 thorpej Exp $ + +/*- + * 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: + * 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 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 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. + */ + +/* + * List of known DIO devices + */ + +/* Devices we have drivers for. */ + +device DCA0 0x02 1 98644A serial +device DCA0REM 0x82 1 98644A serial +device DCA1 0x42 1 98644A serial +device DCA1REM 0xc2 1 98644A serial + +device DCM 0x05 1 98642A serial MUX +device DCMREM 0x85 1 98642A serial MUX + +device LAN 0x15 1 98643A LAN + +device FHPIB 0x08 1 98625A/98625B HP-IB +device NHPIB 0x80 1 98624A HP-IB +device IHPIB 0x00 1 internal HP-IB + +device SCSI0 0x07 1 98625A SCSI +device SCSI1 0x27 1 98625A SCSI +device SCSI2 0x47 1 98625A SCSI +device SCSI3 0x67 1 98625A SCSI + +/* Framebuffer devices; same primary ID, different secondary IDs. */ + +device FRAMEBUFFER 0x39 1 bitmapped display + +framebuffer GATORBOX 0x01 1 98700/98710 (\"gatorbox\") display +framebuffer TOPCAT 0x02 1 98544/98545/98547 (\"topcat\") display +framebuffer RENASSIANCE 0x04 2 98720/98721 (\"renassiance\") display +framebuffer LRCATSEYE 0x05 1 low-res catseye display +framebuffer HRCCATSEYE 0x06 1 high-res color catseye display +framebuffer HRMCATSEYE 0x07 1 high-res mono catseye display +framebuffer DAVINCI 0x08 2 98730/98731 (\"davinci\") display +framebuffer XXXCATSEYE 0x09 1 catseye display +framebuffer HYPERION 0x0e 1 A1096A (\"hyperion\") display + +/* Unsupported framebuffers. */ + +framebuffer XGENESIS 0x0b 1 x-genesis display +framebuffer TIGER 0x0c 1 tiger display +framebuffer YGENESIS 0x0d 1 y-genesis display + +/* Devices not yet supported. Descriptions are lacking. */ + +device MISC0 0x03 1 98622A +device MISC1 0x04 1 98623A +device PARALLEL 0x06 1 internal parallel +device MISC2 0x09 1 98287A keyboard +device MISC3 0x0a 1 HP98635A floating point accelerator +device MISC4 0x0b 1 timer +device MISC5 0x12 1 98640A +device MISC6 0x16 1 98659A +device MISC7 0x19 1 237 display +device MISC8 0x1a 4 quad-wide card +device MISC9 0x1b 1 98253A +device MISC10 0x1c 1 98627A +device MISC11 0x1d 1 98633A +device MISC12 0x1e 1 98259A +device MISC13 0x1f 1 8741 +device VME 0x31 2 98577A VME adapter +device DCL 0x34 1 98628A serial +device DCLREM 0xb4 1 98628A serial diff --git a/sys/arch/hp300/dev/dioreg.h b/sys/arch/hp300/dev/dioreg.h new file mode 100644 index 000000000000..19d6c20b0c18 --- /dev/null +++ b/sys/arch/hp300/dev/dioreg.h @@ -0,0 +1,140 @@ +/* $NetBSD: dioreg.h,v 1.1 1996/12/17 08:41:04 thorpej Exp $ */ + +/*- + * 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. + * + * Portions of this file are 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 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 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. + */ + +/* + * Register definitions for the DIO and DIO-II bus. + */ + +/* + * DIO/DIO-II device registers, offsets from base of device. All + * registers are 8-bit. + */ +#define DIO_IDOFF 0x01 /* primary device id */ +#define DIO_IPLOFF 0x03 /* interrupt level */ +#define DIO_SECIDOFF 0x15 /* secondary device id */ +#define DIOII_SIZEOFF 0x101 /* device size */ + +/* + * System physical addresses of some `special' DIO devices. + */ +#define DIO_IHPIBADDR 0x478000 /* internal HP-IB; select code 7 */ + +/* + * DIO ranges from select codes 0-63 at physical addresses given by: + * 0x600000 + (sc - 32) * 0x10000 + * DIO cards are addressed in the range 0-31 [0x600000-0x800000) for + * their control space and the remaining areas, [0x200000-0x400000) and + * [0x800000-0x1000000), are for additional space required by a card; + * e.g. a display framebuffer. + * + * DIO-II ranges from select codes 132-255 at physical addresses given by: + * 0x1000000 + (sc - 132) * 0x400000 + * The address range of DIO-II space is thus [0x1000000-0x20000000). + * + * DIO/DIO-II space is too large to map in its entirety, instead devices + * are mapped into kernel virtual address space allocated from a range + * of EIOMAPSIZE pages (vmparam.h) starting at ``extiobase''. + */ +#define DIO_BASE 0x600000 /* start of DIO space */ +#define DIO_END 0x1000000 /* end of DIO space */ +#define DIO_DEVSIZE 0x10000 /* size of a DIO device */ + +#define DIOII_BASE 0x01000000 /* start of DIO-II space */ +#define DIOII_END 0x20000000 /* end of DIO-II space */ +#define DIOII_DEVSIZE 0x00400000 /* size of a DIO-II device */ + +/* + * Find the highest select code for a given machine; HP320 doesn't + * have DIO-II. + */ +#define DIO_SCMAX(machineid) ((machineid) == HP_320 ? 32 : 256) + +/* + * Macro that returns true if a select code lies within + * the select code `hole'. + */ +#define DIO_INHOLE(scode) ((scode) >= 32 && (scode) < 132) + +/* + * Macros to determine if device is DIO or DIO-II. + */ +#define DIO_ISDIO(scode) ((scode) >= 0 && (scode) < 32) +#define DIO_ISDIOII(scode) ((scode) >= 132 && (scode) < 256) + +/* + * Macro to determine if device is a framebuffer, given the + * primary id of the device. We key off this to determine if + * we should look at secondary id and ignore interrupt level. + */ +#define DIO_ISFRAMEBUFFER(id) \ + ((id) == DIO_DEVICE_ID_FRAMEBUFFER) + +/* + * Macro to extract primary and decondary device ids, given + * the base address of the device. + */ +#define DIO_ID(base) \ + (*((u_int8_t *)((u_long)(base) + DIO_IDOFF))) +#define DIO_SECID(base) \ + (*((u_int8_t *)((u_long)(base) + DIO_SECIDOFF))) + +/* + * Macro to extract the interrupt level, given the + * base address of the device. + */ +#define DIO_IPL(base) \ + ((((*((u_int8_t *)((u_long)(base) + DIO_IPLOFF))) >> 4) & 0x03) + 3) + +/* + * Macro to compute the size of a DIO-II device's address + * space, given the base address of the device. + */ +#define DIOII_SIZE(base) \ + ((int)((*((u_int8_t *)((u_long)(base) + DIOII_SIZEOFF)) + 1) \ + * 0x100000)) + +/* + * Given a select code and device base address, compute + * the size of the DIO/DIO-II device. + */ +#define DIO_SIZE(scode, base) \ + (DIO_ISDIOII((scode)) ? DIOII_SIZE((base)) : DIO_DEVSIZE) diff --git a/sys/arch/hp300/dev/diovar.h b/sys/arch/hp300/dev/diovar.h new file mode 100644 index 000000000000..b8928dce3d95 --- /dev/null +++ b/sys/arch/hp300/dev/diovar.h @@ -0,0 +1,79 @@ +/* $NetBSD: diovar.h,v 1.1 1996/12/17 08:41:05 thorpej Exp $ */ + +/*- + * 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: + * 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 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 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. + */ + +/* + * Autoconfiguration definitions and prototypes for the DIO bus. + */ + +/* + * Arguments used to attach a device to the DIO bus. + */ +struct dio_attach_args { + int da_scode; /* select code */ + int da_size; /* size of address space */ + u_int8_t da_id; /* primary device id */ + u_int8_t da_secid; /* secondary device id */ +}; + +/* + * This structure is used by the autoconfiguration code to lookup + * the size of a DIO device (not all use one select code). + */ +struct dio_devdata { + u_int8_t dd_id; /* primary device id */ + u_int8_t dd_secid; /* secondary device id */ + int dd_nscode; /* number of select codes */ +}; + +/* + * This structure is used by the autoconfiguration code to print + * a textual description of a device. + */ +struct dio_devdesc { + u_int8_t dd_id; /* primary device id */ + u_int8_t dd_secid; /* secondary device id */ + const char *dd_desc; /* description */ +}; + +#define diocf_scode cf_loc[0] + +#define DIO_UNKNOWN_SCODE -1 + +#ifdef _KERNEL +void *dio_scodetopa __P((int)); +#endif /* _KERNEL */ diff --git a/sys/arch/hp300/dev/grf.c b/sys/arch/hp300/dev/grf.c index 89254ea48e03..96d2962208c4 100644 --- a/sys/arch/hp300/dev/grf.c +++ b/sys/arch/hp300/dev/grf.c @@ -1,4 +1,4 @@ -/* $NetBSD: grf.c,v 1.20 1996/10/13 03:14:11 christos Exp $ */ +/* $NetBSD: grf.c,v 1.21 1996/12/17 08:41:05 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -48,9 +48,6 @@ * Hardware access is through the machine dependent grf switch routines. */ -#include "grf.h" -#if NGRF > 0 - #include #include #include @@ -60,6 +57,7 @@ #include #include #include +#include #include #include @@ -91,7 +89,23 @@ extern struct emul emul_hpux; /* prototypes for the devsw entry points */ cdev_decl(grf); +#ifdef NEWCONFIG +int grfmatch __P((struct device *, struct cfdata *, void *)); +void grfattach __P((struct device *, struct device *, void *)); + +struct cfattach grf_ca = { + sizeof(struct grf_softc), grfmatch, grfattach +}; + +struct cfdriver grf_cd = { + NULL, "grf", DV_DULL +}; + +int grfprint __P((void *, const char *)); +#else /* ! NEWCONFIG */ +#include "grf.h" struct grf_softc grf_softc[NGRF]; +#endif /* NEWCONFIG */ /* * Frambuffer state information, statically allocated for benefit @@ -107,6 +121,48 @@ int grfdebug = 0; #define GDB_LOCK 0x08 #endif +#ifdef NEWCONFIG +int +grfmatch(parent, match, aux) + struct device *parent; + struct cfdata *match; + void *aux; +{ + + return (1); +} + +void +grfattach(parent, self, aux) + struct device *parent, *self; + void *aux; +{ + struct grf_softc *sc = (struct grf_softc *)self; + struct grfdev_attach_args *ga = aux; + + printf("\n"); + + sc->sc_data = ga->ga_data; + sc->sc_scode = ga->ga_scode; /* XXX */ + + /* Attach an ITE. */ + (void)config_found(self, aux, grfprint); +} + +int +grfprint(aux, pnp) + void *aux; + const char *pnp; +{ + + /* Only ITEs can attach to GRFs, easy... */ + if (pnp) + printf("ite at %s", pnp); + + return (UNCONF); +} +#endif /* NEWCONFIG */ + /*ARGSUSED*/ int grfopen(dev, flags, mode, p) @@ -119,10 +175,16 @@ grfopen(dev, flags, mode, p) struct grf_data *gp; int error = 0; +#ifdef NEWCONFIG + if (unit >= grf_cd.cd_ndevs || + (sc = grf_cd.cd_devs[unit]) == NULL) + return (ENXIO); +#else if (unit >= NGRF) return(ENXIO); - sc = &grf_softc[unit]; +#endif + gp = sc->sc_data; if ((gp->g_flags & GF_ALIVE) == 0) @@ -168,10 +230,12 @@ grfclose(dev, flags, mode, p) struct grf_softc *sc; struct grf_data *gp; - if (unit >= NGRF) - return(ENXIO); - +#ifdef NEWCONFIG + sc = grf_cd.cd_devs[unit]; +#else sc = &grf_softc[unit]; +#endif + gp = sc->sc_data; if ((gp->g_flags & GF_ALIVE) == 0) @@ -198,10 +262,12 @@ grfioctl(dev, cmd, data, flag, p) struct grf_data *gp; int error, unit = GRFUNIT(dev); - if (unit >= NGRF) - return(ENXIO); - +#ifdef NEWCONFIG + sc = grf_cd.cd_devs[unit]; +#else sc = &grf_softc[unit]; +#endif + gp = sc->sc_data; if ((gp->g_flags & GF_ALIVE) == 0) @@ -259,7 +325,13 @@ grfmmap(dev, off, prot) dev_t dev; int off, prot; { - return(grfaddr(&grf_softc[GRFUNIT(dev)], off)); +#ifdef NEWCONFIG + struct grf_softc *sc = grf_cd.cd_devs[GRFUNIT(dev)]; +#else + struct grf_softc *sc = &grf_softc[GRFUNIT(dev)]; +#endif + + return (grfaddr(sc, off)); } int @@ -270,7 +342,11 @@ grfon(dev) struct grf_softc *sc; struct grf_data *gp; +#ifdef NEWCONFIG + sc = grf_cd.cd_devs[unit]; +#else sc = &grf_softc[unit]; +#endif gp = sc->sc_data; /* @@ -293,7 +369,11 @@ grfoff(dev) struct grf_data *gp; int error; +#ifdef NEWCONFIG + sc = grf_cd.cd_devs[unit]; +#else sc = &grf_softc[unit]; +#endif gp = sc->sc_data; (void) grfunmap(dev, (caddr_t)0, curproc); @@ -339,7 +419,11 @@ hpuxgrfioctl(dev, cmd, data, flag, p) caddr_t data; struct proc *p; { +#ifdef NEWCONFIG + struct grf_softc *sc = grf_cd.cd_devs[GRFUNIT(dev)]; +#else struct grf_softc *sc = &grf_softc[GRFUNIT(dev)]; +#endif struct grf_data *gp = sc->sc_data; int error; @@ -533,19 +617,29 @@ grfdevno(dev) dev_t dev; { int unit = GRFUNIT(dev); - struct grf_softc *sc = &grf_softc[unit]; - struct grf_data *gp = sc->sc_data; + struct grf_softc *sc; + struct grf_data *gp; int newdev; - if (unit >= NGRF || (gp->g_flags&GF_ALIVE) == 0) - return(bsdtohpuxdev(dev)); +#ifdef NEWCONFIG + if (unit >= grf_cd.cd_ndevs || + (sc = grf_cd.cd_devs[unit]) == NULL) + return (bsdtohpuxdev(dev)); +#else + if (unit >= NGRF) + return (bsdtohpuxdev(dev)); + sc = &grf_softc[unit]; +#endif + + gp = sc->sc_data; + if ((gp->g_flags & GF_ALIVE) == 0) + return (bsdtohpuxdev(dev)); + /* magic major number */ newdev = 12 << 24; /* now construct minor number */ - if (gp->g_display.gd_regaddr != (caddr_t)GRFIADDR) { - int sc = patosc(gp->g_display.gd_regaddr); - newdev |= (sc << 16) | 0x200; - } + if (gp->g_display.gd_regaddr != (caddr_t)GRFIADDR) + newdev |= (sc->sc_scode << 16) | 0x200; if (dev & GRFIMDEV) newdev |= 0x02; else if (dev & GRFOVDEV) @@ -565,7 +659,11 @@ grfmap(dev, addrp, p) caddr_t *addrp; struct proc *p; { +#ifdef NEWCONFIG + struct grf_softc *sc = grf_cd.cd_devs[GRFUNIT(dev)]; +#else struct grf_softc *sc = &grf_softc[GRFUNIT(dev)]; +#endif struct grf_data *gp = sc->sc_data; int len, error; struct vnode vn; @@ -598,7 +696,11 @@ grfunmap(dev, addr, p) caddr_t addr; struct proc *p; { +#ifdef NEWCONFIG + struct grf_softc *sc = grf_cd.cd_devs[GRFUNIT(dev)]; +#else struct grf_softc *sc = &grf_softc[GRFUNIT(dev)]; +#endif struct grf_data *gp = sc->sc_data; vm_size_t size; int rv; @@ -745,5 +847,3 @@ grflckunmmap(dev, addr) return(EINVAL); } #endif /* COMPAT_HPUX */ - -#endif /* NGRF > 0 */ diff --git a/sys/arch/hp300/dev/grf_conf.c b/sys/arch/hp300/dev/grf_conf.c index 3bbafb6cc199..8b7b2d783cf9 100644 --- a/sys/arch/hp300/dev/grf_conf.c +++ b/sys/arch/hp300/dev/grf_conf.c @@ -1,4 +1,8 @@ -/* $NetBSD: grf_conf.c,v 1.3 1996/02/24 00:55:08 thorpej Exp $ */ +/* $NetBSD: grf_conf.c,v 1.4 1996/12/17 08:41:06 thorpej Exp $ */ + +/* + * XXX This file is old config only! + */ /* * Copyright (c) 1996 Jason R. Thorpe. All rights reserved. @@ -50,6 +54,7 @@ #if NGRF > 0 #include +#include #include /* XXX */ #include diff --git a/sys/arch/hp300/dev/grf_dv.c b/sys/arch/hp300/dev/grf_dv.c index af5639475c76..1de782dfaf3d 100644 --- a/sys/arch/hp300/dev/grf_dv.c +++ b/sys/arch/hp300/dev/grf_dv.c @@ -1,4 +1,4 @@ -/* $NetBSD: grf_dv.c,v 1.8 1996/10/05 05:22:04 thorpej Exp $ */ +/* $NetBSD: grf_dv.c,v 1.9 1996/12/17 08:41:07 thorpej Exp $ */ /* * Copyright (c) 1996 Jason R. Thorpe. All rights reserved. @@ -43,9 +43,6 @@ * @(#)grf_dv.c 8.4 (Berkeley) 1/12/94 */ -#include "grf.h" -#if NGRF > 0 - /* * Graphics routines for the DaVinci, HP98730/98731 Graphics system. */ @@ -56,12 +53,17 @@ #include #include #include +#include #include #include #include +#include +#include +#include + #include #include #include @@ -76,9 +78,29 @@ 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 *)); +#ifdef NEWCONFIG +int dvbox_intio_match __P((struct device *, struct cfdata *, void *)); +void dvbox_intio_attach __P((struct device *, struct device *, void *)); + +int dvbox_dio_match __P((struct device *, struct cfdata *, void *)); +void dvbox_dio_attach __P((struct device *, struct device *, void *)); + +struct cfattach dvbox_intio_ca = { + sizeof(struct grfdev_softc), dvbox_intio_match, dvbox_intio_attach +}; + +struct cfattach dvbox_dio_ca = { + sizeof(struct grfdev_softc), dvbox_dio_match, dvbox_dio_attach +}; + +struct cfdriver dvbox_cd = { + NULL, "dvbox", DV_DULL +}; +#endif /* NEWCONFIG */ + /* DaVinci grf switch */ struct grfsw dvbox_grfsw = { - GID_DAVINCI, GRFDAVINCI, "davinci", dv_init, dv_mode + GID_DAVINCI, GRFDAVINCI, "dvbox", dv_init, dv_mode }; #if NITE > 0 @@ -98,6 +120,83 @@ struct itesw dvbox_itesw = { }; #endif /* NITE > 0 */ +#ifdef NEWCONFIG +int +dvbox_intio_match(parent, match, aux) + struct device *parent; + struct cfdata *match; + void *aux; +{ + struct intio_attach_args *ia = aux; + struct grfreg *grf; + + grf = (struct grfreg *)IIOV(GRFIADDR); + if (badaddr((caddr_t)grf)) + return (0); + + if (grf->gr_id == DIO_DEVICE_ID_FRAMEBUFFER && + grf->gr_id2 == DIO_DEVICE_SECID_DAVINCI) { + ia->ia_addr = (caddr_t)GRFIADDR; + return (1); + } + + return (0); +} + +void +dvbox_intio_attach(parent, self, aux) + struct device *parent, *self; + void *aux; +{ + struct grfdev_softc *sc = (struct grfdev_softc *)self; + caddr_t grf; + + grf = (caddr_t)IIOV(GRFIADDR); + sc->sc_scode = -1; /* XXX internal i/o */ + + grfdev_attach(sc, dv_init, grf, &dvbox_grfsw); +} + +int +dvbox_dio_match(parent, match, aux) + struct device *parent; + struct cfdata *match; + void *aux; +{ + struct dio_attach_args *da = aux; + + if (da->da_id == DIO_DEVICE_ID_FRAMEBUFFER && + da->da_secid == DIO_DEVICE_SECID_DAVINCI) + return (1); + + return (0); +} + +void +dvbox_dio_attach(parent, self, aux) + struct device *parent, *self; + void *aux; +{ + struct grfdev_softc *sc = (struct grfdev_softc *)self; + struct dio_attach_args *da = aux; + caddr_t grf; + + sc->sc_scode = da->da_scode; + if (sc->sc_scode == conscode) + grf = conaddr; + else { + grf = iomap(dio_scodetopa(sc->sc_scode), da->da_size); + if (grf == 0) { + printf("%s: can't map framebuffer\n", + sc->sc_dev.dv_xname); + return; + } + } + + grfdev_attach(sc, dv_init, grf, &dvbox_grfsw); +} +#endif /* NEWCONFIG */ + /* * Initialize hardware. * Must point g_display at a grfinfo structure describing the hardware. @@ -112,7 +211,7 @@ dv_init(gp, scode, addr) register struct dvboxfb *dbp; struct grfinfo *gi = &gp->g_display; int fboff; - extern caddr_t sctopa(), iomap(); + extern caddr_t iomap(); /* * If the console has been initialized, and it was us, there's @@ -123,7 +222,7 @@ dv_init(gp, scode, addr) if (ISIIOVA(addr)) gi->gd_regaddr = (caddr_t) IIOP(addr); else - gi->gd_regaddr = sctopa(scode); + gi->gd_regaddr = dio_scodetopa(scode); gi->gd_regsize = 0x20000; gi->gd_fbwidth = (dbp->fbwmsb << 8) | dbp->fbwlsb; gi->gd_fbheight = (dbp->fbhmsb << 8) | dbp->fbhlsb; @@ -639,4 +738,3 @@ dvboxcninit(cp) } #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 6715348c40e6..7fb13b0ac360 100644 --- a/sys/arch/hp300/dev/grf_gb.c +++ b/sys/arch/hp300/dev/grf_gb.c @@ -1,4 +1,4 @@ -/* $NetBSD: grf_gb.c,v 1.8 1996/10/05 05:22:05 thorpej Exp $ */ +/* $NetBSD: grf_gb.c,v 1.9 1996/12/17 08:41:08 thorpej Exp $ */ /* * Copyright (c) 1996 Jason R. Thorpe. All rights reserved. @@ -43,9 +43,6 @@ * @(#)grf_gb.c 8.4 (Berkeley) 1/12/94 */ -#include "grf.h" -#if NGRF > 0 - /* * Graphics routines for the Gatorbox. * @@ -60,12 +57,17 @@ #include #include #include +#include #include #include #include +#include +#include +#include + #include #include #include @@ -86,6 +88,26 @@ 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 *)); +#ifdef NEWCONFIG +int gbox_intio_match __P((struct device *, struct cfdata *, void *)); +void gbox_intio_attach __P((struct device *, struct device *, void *)); + +int gbox_dio_match __P((struct device *, struct cfdata *, void *)); +void gbox_dio_attach __P((struct device *, struct device *, void *)); + +struct cfattach gbox_intio_ca = { + sizeof(struct grfdev_softc), gbox_intio_match, gbox_intio_attach +}; + +struct cfattach gbox_dio_ca = { + sizeof(struct grfdev_softc), gbox_dio_match, gbox_dio_attach +}; + +struct cfdriver gbox_cd = { + NULL, "gbox", DV_DULL +}; +#endif /* NEWCONFIG */ + /* Gatorbox grf switch */ struct grfsw gbox_grfsw = { GID_GATORBOX, GRFGATOR, "gatorbox", gb_init, gb_mode @@ -108,6 +130,83 @@ struct itesw gbox_itesw = { }; #endif /* NITE > 0 */ +#ifdef NEWCONFIG +int +gbox_intio_match(parent, match, aux) + struct device *parent; + struct cfdata *match; + void *aux; +{ + struct intio_attach_args *ia = aux; + struct grfreg *grf; + + grf = (struct grfreg *)IIOV(GRFIADDR); + if (badaddr((caddr_t)grf)) + return (0); + + if (grf->gr_id == DIO_DEVICE_ID_FRAMEBUFFER && + grf->gr_id2 == DIO_DEVICE_SECID_GATORBOX) { + ia->ia_addr = (caddr_t)GRFIADDR; + return (1); + } + + return (0); +} + +void +gbox_intio_attach(parent, self, aux) + struct device *parent, *self; + void *aux; +{ + struct grfdev_softc *sc = (struct grfdev_softc *)self; + caddr_t grf; + + grf = (caddr_t)IIOV(GRFIADDR); + sc->sc_scode = -1; /* XXX internal i/o */ + + grfdev_attach(sc, gb_init, grf, &gbox_grfsw); +} + +int +gbox_dio_match(parent, match, aux) + struct device *parent; + struct cfdata *match; + void *aux; +{ + struct dio_attach_args *da = aux; + + if (da->da_id == DIO_DEVICE_ID_FRAMEBUFFER && + da->da_secid == DIO_DEVICE_SECID_GATORBOX) + return (1); + + return (0); +} + +void +gbox_dio_attach(parent, self, aux) + struct device *parent, *self; + void *aux; +{ + struct grfdev_softc *sc = (struct grfdev_softc *)self; + struct dio_attach_args *da = aux; + caddr_t grf; + + sc->sc_scode = da->da_scode; + if (sc->sc_scode == conscode) + grf = conaddr; + else { + grf = iomap(dio_scodetopa(sc->sc_scode), da->da_size); + if (grf == 0) { + printf("%s: can't map framebuffer\n", + sc->sc_dev.dv_xname); + return; + } + } + + grfdev_attach(sc, gb_init, grf, &gbox_grfsw); +} +#endif /* NEWCONFIG */ + /* * Initialize hardware. * Must point g_display at a grfinfo structure describing the hardware. @@ -123,7 +222,7 @@ gb_init(gp, scode, addr) struct grfinfo *gi = &gp->g_display; u_char *fbp, save; int fboff; - extern caddr_t sctopa(), iomap(); + extern caddr_t iomap(); /* * If the console has been initialized, and it was us, there's @@ -134,7 +233,7 @@ gb_init(gp, scode, addr) if (ISIIOVA(addr)) gi->gd_regaddr = (caddr_t) IIOP(addr); else - gi->gd_regaddr = sctopa(scode); + gi->gd_regaddr = dio_scodetopa(scode); gi->gd_regsize = 0x10000; gi->gd_fbwidth = 1024; /* XXX */ gi->gd_fbheight = 1024; /* XXX */ @@ -589,4 +688,3 @@ gboxcninit(cp) } #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 a9bb798dcc31..c0653f89bf5f 100644 --- a/sys/arch/hp300/dev/grf_hy.c +++ b/sys/arch/hp300/dev/grf_hy.c @@ -1,4 +1,4 @@ -/* $NetBSD: grf_hy.c,v 1.6 1996/10/05 05:22:06 thorpej Exp $ */ +/* $NetBSD: grf_hy.c,v 1.7 1996/12/17 08:41:09 thorpej Exp $ */ /* * Copyright (c) 1996 Jason R. Thorpe. All rights reserved. @@ -44,9 +44,6 @@ * @(#)grf_hy.c 8.4 (Berkeley) 1/12/94 */ -#include "grf.h" -#if NGRF > 0 - /* * Graphics routines for HYPERION frame buffer */ @@ -58,12 +55,17 @@ #include #include #include +#include #include #include #include +#include +#include +#include + #include #include #include @@ -80,6 +82,19 @@ 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 *)); +#ifdef NEWCONFIG +int hyper_dio_match __P((struct device *, struct cfdata *, void *)); +void hyper_dio_attach __P((struct device *, struct device *, void *)); + +struct cfattach hyper_dio_ca = { + sizeof(struct grfdev_softc), hyper_dio_match, hyper_dio_attach +}; + +struct cfdriver hyper_cd = { + NULL, "hyper", DV_DULL +}; +#endif /* NEWCONFIG */ + /* Hyperion grf switch */ struct grfsw hyper_grfsw = { GID_HYPERION, GRFHYPERION, "hyperion", hy_init, hy_mode @@ -103,6 +118,47 @@ struct itesw hyper_itesw = { }; #endif /* NITE > 0 */ +#ifdef NEWCONFIG +int +hyper_dio_match(parent, match, aux) + struct device *parent; + struct cfdata *match; + void *aux; +{ + struct dio_attach_args *da = aux; + + if (da->da_id == DIO_DEVICE_ID_FRAMEBUFFER && + da->da_secid == DIO_DEVICE_SECID_HYPERION) + return (1); + + return (0); +} + +void +hyper_dio_attach(parent, self, aux) + struct device *parent, *self; + void *aux; +{ + struct grfdev_softc *sc = (struct grfdev_softc *)self; + struct dio_attach_args *da = aux; + caddr_t grf; + + sc->sc_scode = da->da_scode; + if (sc->sc_scode == conscode) + grf = conaddr; + else { + grf = iomap(dio_scodetopa(sc->sc_scode), da->da_size); + if (grf == 0) { + printf("%s: can't map framebuffer\n", + sc->sc_dev.dv_xname); + return; + } + } + + grfdev_attach(sc, hy_init, grf, &hyper_grfsw); +} +#endif /* NEWCONFIG */ + /* * Initialize hardware. * Must fill in the grfinfo structure in g_softc. @@ -117,7 +173,7 @@ hy_init(gp, scode, addr) register struct hyboxfb *hy = (struct hyboxfb *) addr; struct grfinfo *gi = &gp->g_display; int fboff; - extern caddr_t sctopa(), iomap(); + extern caddr_t iomap(); /* * If the console has been initialized, and it was us, there's @@ -127,7 +183,7 @@ hy_init(gp, scode, addr) if (ISIIOVA(addr)) gi->gd_regaddr = (caddr_t) IIOP(addr); else - gi->gd_regaddr = sctopa(scode); + gi->gd_regaddr = dio_scodetopa(scode); gi->gd_regsize = 0x20000; gi->gd_fbwidth = (hy->fbwmsb << 8) | hy->fbwlsb; gi->gd_fbheight = (hy->fbhmsb << 8) | hy->fbhlsb; @@ -785,4 +841,3 @@ hypercninit(cp) } #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 32076fd9027e..014b23286121 100644 --- a/sys/arch/hp300/dev/grf_machdep.c +++ b/sys/arch/hp300/dev/grf_machdep.c @@ -1,4 +1,8 @@ -/* $NetBSD: grf_machdep.c,v 1.6 1996/10/13 03:14:12 christos Exp $ */ +/* $NetBSD: grf_machdep.c,v 1.7 1996/12/17 08:41:09 thorpej Exp $ */ + +/* + * XXX This file is old config only! + */ /* * Copyright (c) 1996 Jason R. Thorpe. All rights reserved. @@ -125,6 +129,8 @@ grfattach(hd) else isconsole = 0; + sc->sc_scode = scode; + printf(": %d x %d ", gp->g_display.gd_dwidth, gp->g_display.gd_dheight); if (gp->g_display.gd_colors == 2) diff --git a/sys/arch/hp300/dev/grf_rb.c b/sys/arch/hp300/dev/grf_rb.c index b027886a90ba..49d396c31805 100644 --- a/sys/arch/hp300/dev/grf_rb.c +++ b/sys/arch/hp300/dev/grf_rb.c @@ -1,4 +1,4 @@ -/* $NetBSD: grf_rb.c,v 1.8 1996/10/05 05:22:07 thorpej Exp $ */ +/* $NetBSD: grf_rb.c,v 1.9 1996/12/17 08:41:10 thorpej Exp $ */ /* * Copyright (c) 1996 Jason R. Thorpe. All rights reserved. @@ -43,9 +43,6 @@ * @(#)grf_rb.c 8.4 (Berkeley) 1/12/94 */ -#include "grf.h" -#if NGRF > 0 - /* * Graphics routines for the Renaissance, HP98720 Graphics system. */ @@ -56,12 +53,17 @@ #include #include #include +#include #include #include #include +#include +#include +#include + #include #include #include @@ -75,6 +77,26 @@ int rb_init __P((struct grf_data *gp, int, caddr_t)); int rb_mode __P((struct grf_data *gp, int, caddr_t)); +#ifdef NEWCONFIG +int rbox_intio_match __P((struct device *, struct cfdata *, void *)); +void rbox_intio_attach __P((struct device *, struct device *, void *)); + +int rbox_dio_match __P((struct device *, struct cfdata *, void *)); +void rbox_dio_attach __P((struct device *, struct device *, void *)); + +struct cfattach rbox_intio_ca = { + sizeof(struct grfdev_softc), rbox_intio_match, rbox_intio_attach +}; + +struct cfattach rbox_dio_ca = { + sizeof(struct grfdev_softc), rbox_dio_match, rbox_dio_attach +}; + +struct cfdriver rbox_cd = { + NULL, "rbox", DV_DULL +}; +#endif /* NEWCONFIG */ + /* Renaissance grf switch */ struct grfsw rbox_grfsw = { GID_RENAISSANCE, GRFRBOX, "renaissance", rb_init, rb_mode @@ -97,6 +119,83 @@ struct itesw rbox_itesw = { }; #endif /* NITE > 0 */ +#ifdef NEWCONFIG +int +rbox_intio_match(parent, match, aux) + struct device *parent; + struct cfdata *match; + void *aux; +{ + struct intio_attach_args *ia = aux; + struct grfreg *grf; + + grf = (struct grfreg *)IIOV(GRFIADDR); + if (badaddr((caddr_t)grf)) + return (0); + + if (grf->gr_id == DIO_DEVICE_ID_FRAMEBUFFER && + grf->gr_id2 == DIO_DEVICE_SECID_RENASSIANCE) { + ia->ia_addr = (caddr_t)GRFIADDR; + return (1); + } + + return (0); +} + +void +rbox_intio_attach(parent, self, aux) + struct device *parent, *self; + void *aux; +{ + struct grfdev_softc *sc = (struct grfdev_softc *)self; + caddr_t grf; + + grf = (caddr_t)IIOV(GRFIADDR); + sc->sc_scode = -1; /* XXX internal i/o */ + + grfdev_attach(sc, rb_init, grf, &rbox_grfsw); +} + +int +rbox_dio_match(parent, match, aux) + struct device *parent; + struct cfdata *match; + void *aux; +{ + struct dio_attach_args *da = aux; + + if (da->da_id == DIO_DEVICE_ID_FRAMEBUFFER && + da->da_secid == DIO_DEVICE_SECID_RENASSIANCE) + return (1); + + return (0); +} + +void +rbox_dio_attach(parent, self, aux) + struct device *parent, *self; + void *aux; +{ + struct grfdev_softc *sc = (struct grfdev_softc *)self; + struct dio_attach_args *da = aux; + caddr_t grf; + + sc->sc_scode = da->da_scode; + if (sc->sc_scode == conscode) + grf = conaddr; + else { + grf = iomap(dio_scodetopa(sc->sc_scode), da->da_size); + if (grf == 0) { + printf("%s: can't map framebuffer\n", + sc->sc_dev.dv_xname); + return; + } + } + + grfdev_attach(sc, rb_init, grf, &rbox_grfsw); +} +#endif /* NEWCONFIG */ + /* * Initialize hardware. * Must point g_display at a grfinfo structure describing the hardware. @@ -111,7 +210,7 @@ rb_init(gp, scode, addr) register struct rboxfb *rbp; struct grfinfo *gi = &gp->g_display; int fboff; - extern caddr_t sctopa(), iomap(); + extern caddr_t iomap(); /* * If the console has been initialized, and it was us, there's @@ -122,7 +221,7 @@ rb_init(gp, scode, addr) if (ISIIOVA(addr)) gi->gd_regaddr = (caddr_t) IIOP(addr); else - gi->gd_regaddr = sctopa(scode); + gi->gd_regaddr = dio_scodetopa(scode); gi->gd_regsize = 0x20000; gi->gd_fbwidth = (rbp->fbwmsb << 8) | rbp->fbwlsb; gi->gd_fbheight = (rbp->fbhmsb << 8) | rbp->fbhlsb; @@ -586,4 +685,3 @@ rboxcninit(cp) } #endif /* NITE > 0 */ -#endif /* NGRF > 0 */ diff --git a/sys/arch/hp300/dev/grf_subr.c b/sys/arch/hp300/dev/grf_subr.c new file mode 100644 index 000000000000..1df0398c09a3 --- /dev/null +++ b/sys/arch/hp300/dev/grf_subr.c @@ -0,0 +1,122 @@ +/* $NetBSD: grf_subr.c,v 1.1 1996/12/17 08:41:11 thorpej Exp $ */ + +/*- + * 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: + * 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 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 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. + */ + +/* + * Subroutines common to all framebuffer devices. + */ + +#include +#include +#include +#include + +#include +#include + +#include +#include + +int grfdevprint __P((void *, const char *)); + +void +grfdev_attach(sc, init, regs, sw) + struct grfdev_softc *sc; + int (*init) __P((struct grf_data *, int, caddr_t)); + caddr_t regs; + struct grfsw *sw; +{ + struct grfdev_attach_args ga; + struct grf_data *gp; + int isconsole; + + isconsole = (sc->sc_scode == conscode); + + if (isconsole) + sc->sc_data = gp = &grf_cn; + else { + sc->sc_data = gp = + (struct grf_data *)malloc(sizeof(struct grf_data), + M_DEVBUF, M_NOWAIT); + if (sc->sc_data == NULL) { + printf("\n%s: can't allocate grf data\n", + sc->sc_dev.dv_xname); + return; + } + bzero(sc->sc_data, sizeof(struct grf_data)); + + /* Initialize the framebuffer hardware. */ + if ((*init)(sc->sc_data, sc->sc_scode, regs) == 0) { + printf("\n%s: init failed\n", + sc->sc_dev.dv_xname); + free(sc->sc_data, M_DEVBUF); + return; + } + + gp->g_sw = sw; + gp->g_display.gd_id = gp->g_sw->gd_swid; + } + + /* Announce ourselves. */ + printf(": %d x %d ", gp->g_display.gd_dwidth, + gp->g_display.gd_dheight); + if (gp->g_display.gd_colors == 2) + printf("monochrome"); + else + printf("%d color", gp->g_display.gd_colors); + printf(" %s display\n", gp->g_sw->gd_desc); + + /* Attach a grf. */ + ga.ga_scode = sc->sc_scode; /* XXX */ + ga.ga_isconsole = isconsole; + ga.ga_data = (void *)sc->sc_data; + (void)config_found(&sc->sc_dev, &ga, grfdevprint); +} + +int +grfdevprint(aux, pnp) + void *aux; + const char *pnp; +{ + struct grfdev_attach_args *ga = aux; + + /* Only grf's can attach to grfdev's... easy. */ + if (pnp) + printf("grf at %s", pnp); + + return (UNCONF); +} diff --git a/sys/arch/hp300/dev/grf_tc.c b/sys/arch/hp300/dev/grf_tc.c index 704f57a7ee5a..610d9e4904ec 100644 --- a/sys/arch/hp300/dev/grf_tc.c +++ b/sys/arch/hp300/dev/grf_tc.c @@ -1,4 +1,4 @@ -/* $NetBSD: grf_tc.c,v 1.8 1996/10/05 05:22:08 thorpej Exp $ */ +/* $NetBSD: grf_tc.c,v 1.9 1996/12/17 08:41:12 thorpej Exp $ */ /* * Copyright (c) 1996 Jason R. Thorpe. All rights reserved. @@ -43,9 +43,6 @@ * @(#)grf_tc.c 8.4 (Berkeley) 1/12/94 */ -#include "grf.h" -#if NGRF > 0 - /* * Graphics routines for TOPCAT and CATSEYE frame buffers */ @@ -56,12 +53,17 @@ #include #include #include +#include #include #include #include +#include +#include +#include + #include #include #include @@ -75,6 +77,28 @@ int tc_init __P((struct grf_data *, int, caddr_t)); int tc_mode __P((struct grf_data *, int, caddr_t)); +#ifdef NEWCONFIG +void topcat_common_attach __P((struct grfdev_softc *, caddr_t, u_int8_t)); + +int topcat_intio_match __P((struct device *, struct cfdata *, void *)); +void topcat_intio_attach __P((struct device *, struct device *, void *)); + +int topcat_dio_match __P((struct device *, struct cfdata *, void *)); +void topcat_dio_attach __P((struct device *, struct device *, void *)); + +struct cfattach topcat_intio_ca = { + sizeof(struct grfdev_softc), topcat_intio_match, topcat_intio_attach +}; + +struct cfattach topcat_dio_ca = { + sizeof(struct grfdev_softc), topcat_dio_match, topcat_dio_attach +}; + +struct cfdriver topcat_cd = { + NULL, "topcat", DV_DULL +}; +#endif /* NEWCONFIG */ + /* Topcat (bobcat) grf switch */ struct grfsw topcat_grfsw = { GID_TOPCAT, GRFBOBCAT, "topcat", tc_init, tc_mode @@ -112,6 +136,139 @@ struct itesw topcat_itesw = { }; #endif /* NITE > 0 */ +#ifdef NEWCONFIG +int +topcat_intio_match(parent, match, aux) + struct device *parent; + struct cfdata *match; + void *aux; +{ + struct intio_attach_args *ia = aux; + struct grfreg *grf; + + grf = (struct grfreg *)IIOV(GRFIADDR); + + if (badaddr((caddr_t)grf)) + return (0); + + if (grf->gr_id == DIO_DEVICE_ID_FRAMEBUFFER) { + switch (grf->gr_id2) { + case DIO_DEVICE_SECID_TOPCAT: + case DIO_DEVICE_SECID_LRCATSEYE: + case DIO_DEVICE_SECID_HRCCATSEYE: + case DIO_DEVICE_SECID_HRMCATSEYE: +#if 0 + case DIO_DEVICE_SECID_XXXCATSEYE: +#endif + ia->ia_addr = (caddr_t)GRFIADDR; + return (1); + } + } + + return (0); +} + +void +topcat_intio_attach(parent, self, aux) + struct device *parent, *self; + void *aux; +{ + struct grfdev_softc *sc = (struct grfdev_softc *)self; + struct grfreg *grf; + + grf = (struct grfreg *)IIOV(GRFIADDR); + sc->sc_scode = -1; /* XXX internal i/o */ + + topcat_common_attach(sc, (caddr_t)grf, grf->gr_id2); +} + +int +topcat_dio_match(parent, match, aux) + struct device *parent; + struct cfdata *match; + void *aux; +{ + struct dio_attach_args *da = aux; + + if (da->da_id == DIO_DEVICE_ID_FRAMEBUFFER) { + switch (da->da_secid) { + case DIO_DEVICE_SECID_TOPCAT: + case DIO_DEVICE_SECID_LRCATSEYE: + case DIO_DEVICE_SECID_HRCCATSEYE: + case DIO_DEVICE_SECID_HRMCATSEYE: +#if 0 + case DIO_DEVICE_SECID_XXXCATSEYE: +#endif + return (1); + } + } + + return (0); +} + +void +topcat_dio_attach(parent, self, aux) + struct device *parent, *self; + void *aux; +{ + struct grfdev_softc *sc = (struct grfdev_softc *)self; + struct dio_attach_args *da = aux; + caddr_t grf; + + sc->sc_scode = da->da_scode; + if (sc->sc_scode == conscode) + grf = conaddr; + else { + grf = iomap(dio_scodetopa(sc->sc_scode), da->da_size); + if (grf == 0) { + printf("%s: can't map framebuffer\n", + sc->sc_dev.dv_xname); + return; + } + } + + topcat_common_attach(sc, grf, da->da_secid); +} + +void +topcat_common_attach(sc, grf, secid) + struct grfdev_softc *sc; + caddr_t grf; + u_int8_t secid; +{ + struct grfsw *sw; + + switch (secid) { + case DIO_DEVICE_SECID_TOPCAT: + sw = &topcat_grfsw; + break; + + case DIO_DEVICE_SECID_LRCATSEYE: + sw = &lrcatseye_grfsw; + break; + + case DIO_DEVICE_SECID_HRCCATSEYE: + sw = &hrcatseye_grfsw; + break; + + case DIO_DEVICE_SECID_HRMCATSEYE: + sw = &hrmcatseye_grfsw; + break; +#if 0 + case DIO_DEVICE_SECID_XXXCATSEYE: + sw = XXX? + break; +#endif + default: + printf("%s: unkown device 0x%x\n", + sc->sc_dev.dv_xname, secid); + panic("topcat_common_attach"); + } + + grfdev_attach(sc, tc_init, grf, sw); +} +#endif /* NEWCONFIG */ + /* * Initialize hardware. * Must fill in the grfinfo structure in g_softc. @@ -128,7 +285,6 @@ tc_init(gp, scode, addr) volatile u_char *fbp; u_char save; int fboff; - extern caddr_t sctopa(); /* * If the console has been initialized, and it was us, there's @@ -138,7 +294,7 @@ tc_init(gp, scode, addr) if (ISIIOVA(addr)) gi->gd_regaddr = (caddr_t) IIOP(addr); else - gi->gd_regaddr = sctopa(scode); + gi->gd_regaddr = dio_scodetopa(scode); gi->gd_regsize = 0x10000; gi->gd_fbwidth = (tp->fbwmsb << 8) | tp->fbwlsb; gi->gd_fbheight = (tp->fbhmsb << 8) | tp->fbhlsb; @@ -668,4 +824,3 @@ topcatcninit(cp) } #endif /* NITE > 0 */ -#endif /* NGRF > 0 */ diff --git a/sys/arch/hp300/dev/grfvar.h b/sys/arch/hp300/dev/grfvar.h index f6f02a0158f3..3fa8cea50c2a 100644 --- a/sys/arch/hp300/dev/grfvar.h +++ b/sys/arch/hp300/dev/grfvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: grfvar.h,v 1.7 1996/02/24 00:55:18 thorpej Exp $ */ +/* $NetBSD: grfvar.h,v 1.8 1996/12/17 08:41:12 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -77,10 +77,28 @@ struct grfsw { }; struct grf_softc { + struct device sc_dev; /* generic device info */ + int sc_scode; /* select code; for grfdevno() */ struct grf_data *sc_data; /* display state information */ struct ite_softc *sc_ite; /* pointer to ite; may be NULL */ }; +struct grfdev_softc { + struct device sc_dev; /* generic device info */ + struct grf_data *sc_data; /* generic grf data */ + int sc_scode; /* select code, -1 for intio */ +}; + +/* + * Set up by the hardware driver, and passed all the way down to + * the ITE, if appropriate. + */ +struct grfdev_attach_args { + int ga_scode; /* XXX select code, -1 for intio */ + int ga_isconsole; /* from hardware; is console? */ + void *ga_data; /* hardware-dependent data */ +}; + /* flags */ #define GF_ALIVE 0x01 #define GF_OPEN 0x02 @@ -105,7 +123,15 @@ struct grf_softc { #ifdef _KERNEL extern struct grf_data grf_cn; /* grf_data for console device */ +#ifndef NEWCONFIG extern struct grf_softc grf_softc[]; extern struct grfsw *grfsw[]; extern int ngrfsw; -#endif +#endif /* ! NEWCONFIG */ + +#ifdef NEWCONFIG +void grfdev_attach __P((struct grfdev_softc *, + int (*init)(struct grf_data *, int, caddr_t), + caddr_t, struct grfsw *)); +#endif /* NEWCONFIG */ +#endif /* _KERNEL */ diff --git a/sys/arch/hp300/dev/if_le.c b/sys/arch/hp300/dev/if_le.c index 54c9eb43af67..b2adfee4c4ec 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.35 1996/12/09 03:14:10 thorpej Exp $ */ +/* $NetBSD: if_le.c,v 1.36 1996/12/17 08:41:13 thorpej Exp $ */ /*- * Copyright (c) 1995 Charles M. Hannum. All rights reserved. @@ -55,6 +55,7 @@ #include #endif +#include #include #include @@ -64,24 +65,39 @@ #include #endif +#ifndef NEWCONFIG #include +#endif #include #include +#include +#include +#include #include #include +#ifdef NEWCONFIG +int lematch __P((struct device *, struct cfdata *, void *)); +void leattach __P((struct device *, struct device *, void *)); + +struct cfattach le_ca = { + sizeof(struct le_softc), lematch, leattach +}; +#else /* ! NEWCONFIG */ #include "le.h" struct le_softc le_softc[NLE]; int lematch __P((struct hp_device *)); void leattach __P((struct hp_device *)); -int leintr __P((void *)); struct driver ledriver = { lematch, leattach, "le", }; +#endif /* NEWCONFIG */ + +int leintr __P((void *)); /* offsets for: ID, REGS, MEM, NVRAM */ int lestd[] = { 0, 0x4000, 0x8000, 0xC008 }; @@ -123,6 +139,20 @@ lerdcsr(sc, port) return (val); } +#ifdef NEWCONFIG +int +lematch(parent, match, aux) + struct device *parent; + struct cfdata *match; + void *aux; +{ + struct dio_attach_args *da = aux; + + if (da->da_id == DIO_DEVICE_ID_LAN) + return (1); + return (0); +} +#else /* ! NEWCONFIG */ int lematch(hd) struct hp_device *hd; @@ -139,33 +169,62 @@ lematch(hd) return (1); } +#endif /* NEWCONFIG */ /* * Interface exists: make available by filling in network interface * record. System will initialize the interface when it is ready * to accept packets. */ +#ifdef NEWCONFIG +void +leattach(parent, self, aux) + struct device *parent, *self; + void *aux; +#else /* ! NEWCONFIG */ void leattach(hd) struct hp_device *hd; +#endif /* NEWCONFIG */ { register struct lereg0 *ler0; +#ifdef NEWCONFIG + struct dio_attach_args *da = aux; + struct le_softc *lesc = (struct le_softc *)self; + caddr_t addr; +#else struct le_softc *lesc = &le_softc[hd->hp_unit]; + caddr_t addr = hd->hp_addr; +#endif /* NEWCONFIG */ struct am7990_softc *sc = &lesc->sc_am7990; char *cp; - int i; + int i, ipl; - ler0 = lesc->sc_r0 = (struct lereg0 *)(lestd[0] + (int)hd->hp_addr); +#ifdef NEWCONFIG + addr = iomap(dio_scodetopa(da->da_scode), da->da_size); + if (addr == 0) { + printf("\n%s: can't map LANCE registers\n", + sc->sc_dev.dv_xname); + return; + } +#endif /* NEWCONFIG */ + + ler0 = lesc->sc_r0 = (struct lereg0 *)(lestd[0] + (int)addr); ler0->ler0_id = 0xFF; DELAY(100); +#ifdef NEWCONFIG + ipl = DIO_IPL(addr); + printf(" ipl %d", ipl); +#else /* ! NEWCONFIG */ /* XXXX kluge for now */ - sc->sc_dev.dv_unit = hd->hp_unit; - sprintf(sc->sc_dev.dv_xname, "%s%d", le_cd.cd_name, hd->hp_unit); hd->hp_dev.dv_class = DV_IFNET; + bcopy(&hd->hp_dev, &sc->sc_dev, sizeof(struct device)); + ipl = hd->hp_ipl; +#endif /* NEWCONFIG */ - lesc->sc_r1 = (struct lereg1 *)(lestd[1] + (int)hd->hp_addr); - sc->sc_mem = (void *)(lestd[2] + (int)hd->hp_addr); + lesc->sc_r1 = (struct lereg1 *)(lestd[1] + (int)addr); + sc->sc_mem = (void *)(lestd[2] + (int)addr); sc->sc_conf3 = LE_C3_BSWP; sc->sc_addr = 0; sc->sc_memsize = 16384; @@ -173,7 +232,7 @@ leattach(hd) /* * Read the ethernet address off the board, one nibble at a time. */ - cp = (char *)(lestd[3] + (int)hd->hp_addr); + cp = (char *)(lestd[3] + (int)addr); for (i = 0; i < sizeof(sc->sc_arpcom.ac_enaddr); i++) { sc->sc_arpcom.ac_enaddr[i] = (*++cp & 0xF) << 4; cp++; @@ -194,7 +253,7 @@ leattach(hd) am7990_config(sc); /* Establish the interrupt handler. */ - (void) isrlink(leintr, sc, hd->hp_ipl, ISRPRI_NET); + (void) isrlink(leintr, sc, ipl, ISRPRI_NET); ler0->ler0_status = LE_IE; } diff --git a/sys/arch/hp300/dev/if_levar.h b/sys/arch/hp300/dev/if_levar.h index 40d64ab8e1fe..f8b18aac3a58 100644 --- a/sys/arch/hp300/dev/if_levar.h +++ b/sys/arch/hp300/dev/if_levar.h @@ -1,4 +1,4 @@ -/* $NetBSD: if_levar.h,v 1.4 1996/05/07 00:58:00 thorpej Exp $ */ +/* $NetBSD: if_levar.h,v 1.5 1996/12/17 08:41:14 thorpej Exp $ */ /*- * Copyright (c) 1995 Charles M. Hannum. All rights reserved. @@ -49,7 +49,9 @@ struct le_softc { struct am7990_softc sc_am7990; /* glue to MI code */ +#ifndef NEWCONFIG struct hp_device *sc_hd; +#endif struct isr sc_isr; struct lereg0 *sc_r0; /* DIO registers */ struct lereg1 *sc_r1; /* LANCE registers */ diff --git a/sys/arch/hp300/dev/intio.c b/sys/arch/hp300/dev/intio.c new file mode 100644 index 000000000000..d3dbdb85f95a --- /dev/null +++ b/sys/arch/hp300/dev/intio.c @@ -0,0 +1,114 @@ +/* $NetBSD: intio.c,v 1.1 1996/12/17 08:41:15 thorpej Exp $ */ + +/*- + * 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: + * 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 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 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. + */ + +/* + * Autoconfiguration support for hp300 internal i/o space. + */ + +#include +#include +#include + +#include + +int intiomatch __P((struct device *, struct cfdata *, void *)); +void intioattach __P((struct device *, struct device *, void *)); +int intioprint __P((void *, const char *)); +int intiosearch __P((struct device *, struct cfdata *, void *)); + +struct cfattach intio_ca = { + sizeof(struct device), intiomatch, intioattach +}; + +struct cfdriver intio_cd = { + NULL, "intio", DV_DULL +}; + +int +intiomatch(parent, match, aux) + struct device *parent; + struct cfdata *match; + void *aux; +{ + static int intio_matched = 0; + + /* Allow only one instance. */ + if (intio_matched) + return (0); + + intio_matched = 1; + return (1); +} + +void +intioattach(parent, self, aux) + struct device *parent, *self; + void *aux; +{ + + printf("\n"); + + /* Search for and attach children. */ + config_search(intiosearch, self, NULL); +} + +int +intioprint(aux, pnp) + void *aux; + const char *pnp; +{ + struct intio_attach_args *ia = aux; + + if (ia->ia_addr != 0) + printf(" addr %p", ia->ia_addr); + return (UNCONF); +} + +int +intiosearch(parent, cf, aux) + struct device *parent; + struct cfdata *cf; + void *aux; +{ + struct intio_attach_args ia; + + bzero(&ia, sizeof(ia)); + if ((*cf->cf_attach->ca_match)(parent, cf, &ia) > 0) + config_attach(parent, cf, &ia, intioprint); + return (0); +} diff --git a/sys/arch/hp300/dev/intiovar.h b/sys/arch/hp300/dev/intiovar.h new file mode 100644 index 000000000000..0ecc34320652 --- /dev/null +++ b/sys/arch/hp300/dev/intiovar.h @@ -0,0 +1,49 @@ +/* $NetBSD: intiovar.h,v 1.1 1996/12/17 08:41:15 thorpej Exp $ */ + +/*- + * 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: + * 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 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 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. + */ + +/* + * Autoconfiguration definitions and prototypes for the hp300 + * internal i/o space. + */ + +/* + * Arguments used to attach a device to the internal i/o space. + */ +struct intio_attach_args { + caddr_t ia_addr; /* physical address */ +}; diff --git a/sys/arch/hp300/dev/ite.c b/sys/arch/hp300/dev/ite.c index f90234599790..835dc25aeaaf 100644 --- a/sys/arch/hp300/dev/ite.c +++ b/sys/arch/hp300/dev/ite.c @@ -1,4 +1,4 @@ -/* $NetBSD: ite.c,v 1.33 1996/10/13 03:14:17 christos Exp $ */ +/* $NetBSD: ite.c,v 1.34 1996/12/17 08:41:16 thorpej Exp $ */ /* * Copyright (c) 1996 Jason R. Thorpe. All rights reserved. @@ -48,12 +48,6 @@ * This is a very rudimentary. Much more can be abstracted out of * the hardware dependent routines. */ -#include "ite.h" -#if NITE > 0 - -#include "grf.h" -#undef NITE -#define NITE NGRF #include #include @@ -62,6 +56,7 @@ #include #include #include +#include #include @@ -90,9 +85,23 @@ */ int iteburst = 64; -int nite = NITE; struct ite_data *kbd_ite = NULL; -struct ite_softc ite_softc[NITE]; + +#ifdef NEWCONFIG +int itematch __P((struct device *, struct cfdata *, void *)); +void iteattach __P((struct device *, struct device *, void *)); + +struct cfattach ite_ca = { + sizeof(struct ite_softc), itematch, iteattach +}; + +struct cfdriver ite_cd = { + NULL, "ite", DV_TTY +}; +#else /* ! NEWCONFIG */ +#include "grf.h" +struct ite_softc ite_softc[NGRF]; +#endif /* NEWCONFIG */ /* * Terminal emulator state information, statically allocated @@ -131,6 +140,57 @@ u_char ite_console_attributes[0x2200]; (*(sp)->ite_cursor)((ip), MOVE_CURSOR); \ } +#ifdef NEWCONFIG +int +itematch(parent, match, aux) + struct device *parent; + struct cfdata *match; + void *aux; +{ + + return (1); +} + +void +iteattach(parent, self, aux) + struct device *parent, *self; + void *aux; +{ + struct ite_softc *ite = (struct ite_softc *)self; + struct grf_softc *grf = (struct grf_softc *)parent; + struct grfdev_attach_args *ga = aux; + + /* Allocate the ite_data. */ + if (ga->ga_isconsole) { + ite->sc_data = &ite_cn; + printf(": console"); + + /* + * 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(), self->dv_unit); + } else { + ite->sc_data = + (struct ite_data *)malloc(sizeof(struct ite_data), + M_DEVBUF, M_NOWAIT); + if (ite->sc_data == NULL) { + printf("\n%s: malloc for ite_data failed\n", + ite->sc_dev.dv_xname); + 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("\n"); +} +#else /* ! NEWCONFIG */ /* * Dummy for pseudo-device config. */ @@ -182,6 +242,7 @@ ite_attach_grf(unit, isconsole) printf("ite%d at grf%d: attached\n", unit, unit); } +#endif /* NEWCONFIG */ /* * Perform functions necessary to setup device as a terminal emulator. @@ -290,11 +351,22 @@ iteopen(dev, mode, devtype, p) { int unit = ITEUNIT(dev); struct tty *tp; - struct ite_softc *sc = &ite_softc[unit]; - struct ite_data *ip = sc->sc_data; + struct ite_softc *sc; + struct ite_data *ip; int error; int first = 0; +#ifdef NEWCONFIG + if (unit >= ite_cd.cd_ndevs || + (sc = ite_cd.cd_devs[unit]) == NULL) + return (ENXIO); +#else + if (unit >= NGRF) + return (ENXIO); + sc = &ite_softc[unit]; +#endif + ip = sc->sc_data; + if (ip->tty == NULL) { tp = ip->tty = ttymalloc(); tty_attach(tp); @@ -338,7 +410,11 @@ iteclose(dev, flag, mode, p) int flag, mode; struct proc *p; { +#ifdef NEWCONFIG + struct ite_softc *sc = ite_cd.cd_devs[ITEUNIT(dev)]; +#else struct ite_softc *sc = &ite_softc[ITEUNIT(dev)]; +#endif struct ite_data *ip = sc->sc_data; struct tty *tp = ip->tty; @@ -359,7 +435,11 @@ iteread(dev, uio, flag) struct uio *uio; int flag; { +#ifdef NEWCONFIG + struct ite_softc *sc = ite_cd.cd_devs[ITEUNIT(dev)]; +#else struct ite_softc *sc = &ite_softc[ITEUNIT(dev)]; +#endif struct tty *tp = sc->sc_data->tty; return ((*linesw[tp->t_line].l_read)(tp, uio, flag)); @@ -371,7 +451,11 @@ itewrite(dev, uio, flag) struct uio *uio; int flag; { +#ifdef NEWCONFIG + struct ite_softc *sc = ite_cd.cd_devs[ITEUNIT(dev)]; +#else struct ite_softc *sc = &ite_softc[ITEUNIT(dev)]; +#endif struct tty *tp = sc->sc_data->tty; return ((*linesw[tp->t_line].l_write)(tp, uio, flag)); @@ -381,7 +465,11 @@ struct tty * itetty(dev) dev_t dev; { +#ifdef NEWCONFIG + struct ite_softc *sc = ite_cd.cd_devs[ITEUNIT(dev)]; +#else struct ite_softc *sc = &ite_softc[ITEUNIT(dev)]; +#endif return (sc->sc_data->tty); } @@ -394,7 +482,11 @@ iteioctl(dev, cmd, addr, flag, p) int flag; struct proc *p; { +#ifdef NEWCONFIG + struct ite_softc *sc = ite_cd.cd_devs[ITEUNIT(dev)]; +#else struct ite_softc *sc = &ite_softc[ITEUNIT(dev)]; +#endif struct ite_data *ip = sc->sc_data; struct tty *tp = ip->tty; int error; @@ -417,7 +509,11 @@ itestart(tp) struct ite_softc *sc; struct ite_data *ip; +#ifdef NEWCONFIG + sc = ite_cd.cd_devs[ITEUNIT(tp->t_dev)]; +#else sc = &ite_softc[ITEUNIT(tp->t_dev)]; +#endif ip = sc->sc_data; /* @@ -1004,4 +1100,3 @@ itecnputc(dev, c) } iteputchar(c, ip); } -#endif diff --git a/sys/arch/hp300/dev/ite_subr.c b/sys/arch/hp300/dev/ite_subr.c index dcf26adae6d1..c5377b88875c 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.6 1996/02/24 00:55:29 thorpej Exp $ */ +/* $NetBSD: ite_subr.c,v 1.7 1996/12/17 08:41:17 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -42,15 +42,13 @@ * @(#)ite_subr.c 8.2 (Berkeley) 1/12/94 */ -#include "ite.h" -#if NITE > 0 - #include #include #include #include #include #include +#include #include #include @@ -152,4 +150,3 @@ ite_writeglyph(ip, fbmem, glyphp) fbmem += ip->fbwidth; } } -#endif diff --git a/sys/arch/hp300/dev/itevar.h b/sys/arch/hp300/dev/itevar.h index 658df5f05a88..bc36d9c1c95c 100644 --- a/sys/arch/hp300/dev/itevar.h +++ b/sys/arch/hp300/dev/itevar.h @@ -1,4 +1,4 @@ -/* $NetBSD: itevar.h,v 1.10 1996/10/05 05:22:11 thorpej Exp $ */ +/* $NetBSD: itevar.h,v 1.11 1996/12/17 08:41:17 thorpej Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -88,6 +88,7 @@ struct itesw { }; struct ite_softc { + struct device sc_dev; /* generic device info */ struct ite_data *sc_data; /* terminal state info */ struct grf_softc *sc_grf; /* pointer to framebuffer */ }; diff --git a/sys/arch/hp300/hp300/autoconf.c b/sys/arch/hp300/hp300/autoconf.c index a68c0e249654..3b6002aa310f 100644 --- a/sys/arch/hp300/hp300/autoconf.c +++ b/sys/arch/hp300/hp300/autoconf.c @@ -1,4 +1,4 @@ -/* $NetBSD: autoconf.c,v 1.28 1996/12/09 03:07:11 thorpej Exp $ */ +/* $NetBSD: autoconf.c,v 1.29 1996/12/17 08:41:19 thorpej Exp $ */ /* * Copyright (c) 1996 Jason R. Thorpe. All rights reserved. @@ -85,6 +85,10 @@ #include +#include +#include +#include + #include #include #include @@ -95,7 +99,6 @@ * the machine. */ int cold; /* if 1, still working on cold-start */ -struct hp_hw sc_table[MAXCTLRS]; /* XXX must be allocated statically because of early console init */ struct map extiomap[EIOMAPSIZE/16]; @@ -103,10 +106,6 @@ struct map extiomap[EIOMAPSIZE/16]; extern caddr_t internalhpib; extern char *extiobase; -#ifdef DEBUG -int acdebug = 0; -#endif - /* The boot device. */ struct device *booted_device; @@ -161,14 +160,7 @@ ddlist_t dev_data_list; /* all dev_datas */ ddlist_t dev_data_list_hpib; /* hpib controller dev_datas */ ddlist_t dev_data_list_scsi; /* scsi controller dev_datas */ -#ifndef NEWCONFIG /* XXX */ -struct devicelist alldevs; -struct evcntlist allevents; - -struct dio_attach_args { - int da_scode; -}; - +#if 1 /* XXX for now */ struct scsi_link { int target; int lun; @@ -182,14 +174,23 @@ struct hpib_attach_args { int ha_slave; int ha_punit; }; +#endif /* XXX */ + +#ifndef NEWCONFIG /* XXX */ +struct hp_hw sc_table[MAXCTLRS]; + +#ifdef DEBUG +int acdebug = 0; +#endif + +struct devicelist alldevs; +struct evcntlist allevents; struct dio_attach_args hp300_dio_attach_args; struct scsi_link hp300_scsi_link; struct scsibus_attach_args hp300_scsibus_attach_args; struct hpib_attach_args hp300_hpib_attach_args; - -void device_register __P((struct device *, void *)); /* here for now */ -#endif +#endif /* ! NEWCONFIG */ void setroot __P((void)); void swapconf __P((void)); @@ -208,6 +209,60 @@ static int findblkmajor __P((struct device *dv)); static char *findblkname __P((int)); static int getstr __P((char *cp, int size)); +#ifdef NEWCONFIG +int mainbusmatch __P((struct device *, struct cfdata *, void *)); +void mainbusattach __P((struct device *, struct device *, void *)); +int mainbussearch __P((struct device *, struct cfdata *, void *)); + +struct cfattach mainbus_ca = { + sizeof(struct device), mainbusmatch, mainbusattach +}; + +struct cfdriver mainbus_cd = { + NULL, "mainbus", DV_DULL +}; + +int +mainbusmatch(parent, match, aux) + struct device *parent; + struct cfdata *match; + void *aux; +{ + static int mainbus_matched = 0; + + /* Allow only one instance. */ + if (mainbus_matched) + return (0); + + mainbus_matched = 1; + return (1); +} + +void +mainbusattach(parent, self, aux) + struct device *parent, *self; + void *aux; +{ + + printf("\n"); + + /* Search for and attach children. */ + config_search(mainbussearch, self, NULL); +} + +int +mainbussearch(parent, cf, aux) + struct device *parent; + struct cfdata *cf; + void *aux; +{ + + if ((*cf->cf_attach->ca_match)(parent, cf, NULL) > 0) + config_attach(parent, cf, NULL, NULL); + return (0); +} +#endif /* NEWCONFIG */ + /* * Determine the device configuration for the running system. */ @@ -224,12 +279,6 @@ configure() LIST_INIT(&dev_data_list_hpib); LIST_INIT(&dev_data_list_scsi); - /* - * Find out what hardware is attached to the machine. - * XXX goes away with new config. - */ - find_devs(); - /* Initialize the interrupt system. */ isrinit(); @@ -246,6 +295,17 @@ configure() hilinit(0, HILADDR); dmainit(); +#ifdef NEWCONFIG + (void)splhigh(); + if (config_rootfound("mainbus", "mainbus") == NULL) + panic("no mainbus found"); + (void)spl0(); +#else + /* + * Find out what hardware is attached to the machine. + */ + find_devs(); + /* * Look over each hardware device actually found and attempt * to match it with an ioconf.c table entry. @@ -257,20 +317,29 @@ configure() found = find_device(hw); if (!found) { - int sc = patosc(hw->hw_pa); + extern char *dio_devinfo __P((struct dio_attach_args *, + char *, size_t)); + int sc = hw->hw_sc; + char descbuf[80]; - printf("unconfigured card id %x ", hw->hw_id); - if (sc < 256) - printf("at sc%d\n", sc); + bzero(&hp300_dio_attach_args, + sizeof(hp300_dio_attach_args)); + hp300_dio_attach_args.da_scode = sc; + hp300_dio_attach_args.da_id = hw->hw_id; + hp300_dio_attach_args.da_secid = hw->hw_secid; + printf("%s", dio_devinfo(&hp300_dio_attach_args, + descbuf, sizeof(descbuf))); + if (sc >= 0 && sc < 256) + printf(" at scode %d", sc); else - printf("csr at %x\n", sc); + printf(" csr at 0x%lx", (u_long)hw->hw_pa); + printf(" not configured\n"); } } +#endif /* NEWCONFIG */ isrprintlevels(); - /* XXX Should enable interrupts here. */ - /* * Find boot device. */ @@ -1130,7 +1199,7 @@ console_scan(func, arg) * Scan all select codes. Check each location for some * hardware. If there's something there, call (*func)(). */ - sctop = (machineid == HP_320) ? 32 : 256; + sctop = DIO_SCMAX(machineid); for (scode = 0; scode < sctop; ++scode) { /* * Abort mission if console has been forced. @@ -1147,7 +1216,7 @@ console_scan(func, arg) continue; /* Map current PA. */ - pa = sctopa(scode); + pa = dio_scodetopa(scode); va = iomap(pa, NBPG); if (va == 0) continue; @@ -1215,7 +1284,7 @@ hp300_cninit() } /********************************************************************** - * Misc. mapping and select code conversion functions + * Mapping functions **********************************************************************/ /* @@ -1264,42 +1333,6 @@ iounmap(kva, size) rmfree(extiomap, btoc(size), ix); } -/* - * Convert a select code to a system physical address. - */ -caddr_t -sctopa(sc) - register int sc; -{ - register caddr_t addr; - - if (sc == 7 && internalhpib) - addr = internalhpib; - else if (sc < 32) - addr = (caddr_t) (DIOBASE + sc * DIOCSIZE); - else if (sc >= 132) - addr = (caddr_t) (DIOIIBASE + (sc - 132) * DIOIICSIZE); - else - addr = 0; - return(addr); -} - -/* - * Convert a system physcal address to a select code. - */ -int -patosc(addr) - register caddr_t addr; -{ - if (addr == (caddr_t)0x478000) - return(7); - if (addr >= (caddr_t)DIOBASE && addr < (caddr_t)DIOTOP) - return(((unsigned)addr - DIOBASE) / DIOCSIZE); - if (addr >= (caddr_t)DIOIIBASE && addr < (caddr_t)DIOIITOP) - return(((unsigned)addr - DIOIIBASE) / DIOIICSIZE + 132); - return((int)addr); -} - /********************************************************************** * Old-style device configuration code **********************************************************************/ @@ -1401,11 +1434,11 @@ find_controller(hw) /* Print what we've found. */ printf("%s at ", hc->hp_xname); - sc = patosc(hw->hw_pa); - if (sc < 256) - printf("scode%d", sc); + sc = hw->hw_sc; + if (sc >= 0 && sc < 256) + printf("scode %d", sc); else - printf("addr 0x%x,", sc); + printf("addr 0x%lx,", (u_long)hw->hw_pa); printf(" ipl %d", hc->hp_ipl); if (hc->hp_flags) printf(" flags 0x%x", hc->hp_flags); @@ -1521,11 +1554,11 @@ find_device(hw) /* Print what we've found. */ printf("%s at ", hd->hp_xname); - sc = patosc(hw->hw_pa); - if (sc < 256) - printf("scode%d", sc); + sc = hw->hw_sc; + if (sc >= 0 && sc < 256) + printf("scode %d", sc); else - printf("addr 0x%x", sc); + printf("addr 0x%lx", (u_long)hw->hw_pa); if (hd->hp_ipl) printf(" ipl %d", hd->hp_ipl); if (hd->hp_flags) @@ -1853,7 +1886,7 @@ find_devs() /* * Probe all select codes + internal display addr */ - sctop = machineid == HP_320 ? 32 : 256; + sctop = DIO_SCMAX(machineid); for (sc = -1; sc < sctop; sc++) { /* * Invalid select codes @@ -1866,7 +1899,7 @@ find_devs() addr = (caddr_t) IIOV(hw->hw_pa); didmap = 0; } else if (sc == 7 && internalhpib) { - hw->hw_pa = (caddr_t) 0x478000; + hw->hw_pa = (caddr_t)DIO_IHPIBADDR; addr = internalhpib = (caddr_t) IIOV(hw->hw_pa); didmap = 0; } else if (sc == conscode) { @@ -1874,11 +1907,11 @@ find_devs() * If this is the console, it's already been * mapped, and the address is known. */ - hw->hw_pa = sctopa(sc); + hw->hw_pa = dio_scodetopa(sc); addr = conaddr; didmap = 0; } else { - hw->hw_pa = sctopa(sc); + hw->hw_pa = dio_scodetopa(sc); addr = iomap(hw->hw_pa, NBPG); if (addr == 0) { printf(notmappedmsg); @@ -1891,14 +1924,14 @@ find_devs() iounmap(addr, NBPG); continue; } - id_reg = (u_char *) addr; - if (sc >= 132) - hw->hw_size = (id_reg[0x101] + 1) * 0x100000; - else - hw->hw_size = DIOCSIZE; + + hw->hw_size = DIO_SIZE(sc, addr); hw->hw_kva = addr; - hw->hw_id = id_reg[1]; + hw->hw_id = DIO_ID(addr); + if (DIO_ISFRAMEBUFFER(hw->hw_id)) + hw->hw_secid = DIO_SECID(addr); hw->hw_sc = sc; + /* * Internal HP-IB on some machines (345/375) doesn't return * consistant id info so we use the info gleaned from the diff --git a/sys/arch/hp300/hp300/conf.c b/sys/arch/hp300/hp300/conf.c index fd0ee81ed0fd..e178bfe73501 100644 --- a/sys/arch/hp300/hp300/conf.c +++ b/sys/arch/hp300/hp300/conf.c @@ -1,4 +1,4 @@ -/* $NetBSD: conf.c,v 1.33 1996/09/07 12:40:28 mycroft Exp $ */ +/* $NetBSD: conf.c,v 1.34 1996/12/17 08:41:20 thorpej Exp $ */ /*- * Copyright (c) 1991 The Regents of the University of California. @@ -298,16 +298,40 @@ cons_decl(dca); #define dcmcnpollc nullcnpollc cons_decl(dcm); +#ifdef NEWCONFIG +#include "dvbox.h" +#include "gbox.h" +#include "hyper.h" +#include "rbox.h" +#include "topcat.h" +#else /* ! NEWCONFIG */ +#if NGRF > 0 +#define NDVBOX 1 +#define NGBOX 1 +#define NHYPER 1 +#define NRBOX 1 +#define NTOPCAT 1 +#endif /* NGRF > 0 */ +#endif /* NEWCONFIG */ + struct consdev constab[] = { #if NITE > 0 -#if NGRF > 0 /* XXX */ +#if NDVBOX > 0 cons_init(dvbox), +#endif +#if NGBOX > 0 cons_init(gbox), +#endif +#if NHYPER > 0 cons_init(hyper), +#endif +#if NRBOX > 0 cons_init(rbox), +#endif +#if NTOPCAT > 0 cons_init(topcat), #endif -#endif +#endif /* NITE > 0 */ #if NDCA > 0 cons_init(dca), #endif