summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/mac68k/conf/GENERIC4
-rw-r--r--sys/arch/mac68k/conf/GENERICSBC104
-rw-r--r--sys/arch/mac68k/conf/files.mac68k34
-rw-r--r--sys/arch/mac68k/conf/std.mac68k8
-rw-r--r--sys/arch/mac68k/dev/asc.c355
-rw-r--r--sys/arch/mac68k/dev/asc.h45
-rw-r--r--sys/arch/mac68k/dev/ascvar.h32
-rw-r--r--sys/arch/mac68k/dev/esp.c8
-rw-r--r--sys/arch/mac68k/dev/grf.c9
-rw-r--r--sys/arch/mac68k/dev/grf_iv.c5
-rw-r--r--sys/arch/mac68k/dev/grf_mv.c54
-rw-r--r--sys/arch/mac68k/dev/grf_subr.c5
-rw-r--r--sys/arch/mac68k/dev/if_ae.c509
-rw-r--r--sys/arch/mac68k/dev/if_ae_nubus.c408
-rw-r--r--sys/arch/mac68k/dev/if_aereg.h19
-rw-r--r--sys/arch/mac68k/dev/if_aevar.h74
-rw-r--r--sys/arch/mac68k/dev/ite.c36
-rw-r--r--sys/arch/mac68k/dev/mac68k5380.c8
-rw-r--r--sys/arch/mac68k/dev/ncr5380.c9
-rw-r--r--sys/arch/mac68k/dev/nubus.c45
-rw-r--r--sys/arch/mac68k/dev/nubus.h9
-rw-r--r--sys/arch/mac68k/dev/obio.c21
-rw-r--r--sys/arch/mac68k/dev/obiovar.h8
-rw-r--r--sys/arch/mac68k/dev/sbc.c364
-rw-r--r--sys/arch/mac68k/dev/sbc_obio.c291
-rw-r--r--sys/arch/mac68k/dev/sbcreg.h4
-rw-r--r--sys/arch/mac68k/dev/sbcvar.h122
-rw-r--r--sys/arch/mac68k/include/cpu.h8
-rw-r--r--sys/arch/mac68k/include/param.h17
-rw-r--r--sys/arch/mac68k/include/pmap.h5
-rw-r--r--sys/arch/mac68k/include/viareg.h68
-rw-r--r--sys/arch/mac68k/mac68k/clock.c10
-rw-r--r--sys/arch/mac68k/mac68k/conf.c16
-rw-r--r--sys/arch/mac68k/mac68k/locore.s4
-rw-r--r--sys/arch/mac68k/mac68k/machdep.c67
-rw-r--r--sys/arch/mac68k/mac68k/macrom.c49
-rw-r--r--sys/arch/mac68k/mac68k/via.c131
37 files changed, 1828 insertions, 1137 deletions
diff --git a/sys/arch/mac68k/conf/GENERIC b/sys/arch/mac68k/conf/GENERIC
index c4273760cd9..79376f024a7 100644
--- a/sys/arch/mac68k/conf/GENERIC
+++ b/sys/arch/mac68k/conf/GENERIC
@@ -1,4 +1,4 @@
-# $OpenBSD: GENERIC,v 1.14 1997/01/24 01:35:24 briggs Exp $
+# $OpenBSD: GENERIC,v 1.15 1997/03/08 16:16:46 briggs Exp $
# $NetBSD: GENERIC,v 1.52 1997/01/13 23:34:07 scottr Exp $
#
# GENERIC
@@ -57,12 +57,14 @@ options COMPAT_NOMID
options COMPAT_SUNOS
options ZS_CONSOLE_ABORT
options DISABLE_EXT_CACHE # Don't use IIci external cache
+options HWDIRECT
config bsd swap generic
options GENERIC
sn0 at obio? # SONIC ethernet (68040)
+asc0 at obio? # ASC/EASC audio
intvid0 at obio? # Internal video hardware
nubus0 at mainbus?
diff --git a/sys/arch/mac68k/conf/GENERICSBC b/sys/arch/mac68k/conf/GENERICSBC
new file mode 100644
index 00000000000..41782ae8255
--- /dev/null
+++ b/sys/arch/mac68k/conf/GENERICSBC
@@ -0,0 +1,104 @@
+# $OpenBSD: GENERICSBC,v 1.1 1997/03/08 16:16:46 briggs Exp $
+# $NetBSD: GENERIC,v 1.52 1997/01/13 23:34:07 scottr Exp $
+#
+# GENERIC
+
+include "arch/mac68k/conf/std.mac68k"
+
+maxusers 16
+
+# Standard system options
+options DIAGNOSTIC # DEBUG for extra kernel debugging
+options KTRACE # system call tracing support
+#options KGDB # support for kernel gdb
+#options GDB # support for normal gdb
+#options KGDBDEV=0xc01, KGDBRATE=38400 # device & baud rate
+
+# Filesystem options
+options FIFO # POSIX fifo support (in all filesystems)
+options DDB
+options FFS
+options QUOTA # fast filesystem with user and group quotas
+options MFS # memory-based filesystem
+#options NFSSERVER # Sun NFS-compatible filesystem
+options NFSCLIENT # Sun NFS-compatible filesystem
+options NULLFS # Null (formerly loop-back) filesystem
+options CD9660 # ISO-9660 w/ RockRidge
+options KERNFS # kernel data-structure filesystem
+options FDESC # user file descriptor filesystem
+#options UMAPFS # uid/gid remapping filesystem
+#options LFS # Log-based filesystem (still experimental)
+#options PORTAL # portal filesystem (still experimental)
+options PROCFS # Process filesystem
+
+options SCSI
+#options SCSIDEBUG
+
+# Networking options
+options INET
+options TCP_COMPAT_42 # compatibility with 4.2BSD TCP/IP
+options GATEWAY # IP packet forwarding
+#options ISO # OSI networking
+#options TPIP
+#options EON
+options COMPAT_43
+options NS
+options MAPMEM
+options SYSVSHM,SYSVSEM,SYSVMSG
+options PPP_BSDCOMP,PPP_DEFLATE
+
+# Mac-specific options
+options M68040
+options M68030
+options M68020 # Must have 68851 PMMU
+options FPSP
+options FPU_EMULATE
+options COMPAT_NOMID
+options COMPAT_SUNOS
+options ZS_CONSOLE_ABORT
+options DISABLE_EXT_CACHE # Don't use IIci external cache
+options HWDIRECT
+
+config bsd swap generic
+options GENERIC
+
+sn0 at obio? # SONIC ethernet (68040)
+
+asc0 at obio? # ASC/EASC audio
+intvid0 at obio? # Internal video hardware
+
+nubus0 at mainbus?
+
+ae* at nubus?
+macvid* at nubus?
+
+# Attach grf semantics to all video hardware as it is found
+grf* at intvid?
+grf* at macvid?
+
+# Attach ite semantics to the appropriate grf device
+ite0 at grf?
+
+# Use only one of ncrscsi or sbc
+#ncrscsi0 at obio? # SCSI NCR 5380
+sbc0 at obio? flags 0x1 # MI NCR 5380 SCSI Bus Controller
+
+esp0 at obio? # SCSI NCR 53C9x
+esp1 at obio? # SCSI NCR 53C9x
+
+scsibus* at scsi?
+sd* at scsibus? target ? lun ? # SCSI disk drives
+st* at scsibus? target ? lun ? # SCSI tape drives
+cd* at scsibus? target ? lun ? # SCSI CD-ROM drives
+ch* at scsibus? target ? lun ? # SCSI autochangers
+ss* at scsibus? target ? lun ? # SCSI scanners
+uk* at scsibus? target ? lun ? # SCSI unknown
+
+pseudo-device pty 16
+pseudo-device bpfilter 12
+pseudo-device vnd 2
+pseudo-device ccd 2
+pseudo-device ppp 2
+pseudo-device loop
+pseudo-device sl
+#pseudo-device ipfilter
diff --git a/sys/arch/mac68k/conf/files.mac68k b/sys/arch/mac68k/conf/files.mac68k
index 6b81c0629e2..274877a737f 100644
--- a/sys/arch/mac68k/conf/files.mac68k
+++ b/sys/arch/mac68k/conf/files.mac68k
@@ -1,5 +1,5 @@
-# $OpenBSD: files.mac68k,v 1.12 1997/02/27 14:03:41 briggs Exp $
-# $NetBSD: files.mac68k,v 1.55 1997/01/21 09:43:45 thorpej Exp $
+# $OpenBSD: files.mac68k,v 1.13 1997/03/08 16:16:47 briggs Exp $
+# $NetBSD: files.mac68k,v 1.61 1997/03/01 20:22:16 scottr Exp $
# mac68k-specific configuration info
@@ -11,7 +11,9 @@ maxusers 2 8 64
device mainbus { } # no locators (yet?)
attach mainbus at root
-device obio { }
+define obio_norm { [addr = -1], ["no drq" = -1], ["no hsk" = -1] }
+define obio_scsi5380 { [addr = -1], [drq = -1], [hsk = -1] }
+device obio: obio_norm, obio_scsi5380
attach obio at mainbus
file arch/mac68k/dev/obio.c obio
@@ -20,7 +22,7 @@ attach nubus at mainbus
file arch/mac68k/dev/nubus.c nubus
device adb
-attach adb at obio
+attach adb at obio_norm
file arch/mac68k/dev/adb.c adb
file arch/mac68k/dev/adbsys.c
file arch/mac68k/dev/adbsysasm.s
@@ -28,14 +30,14 @@ file arch/mac68k/dev/adb_direct.c hwdirect
file arch/mac68k/dev/pm_direct.c hwdirect
device asc
-attach asc at obio
-file arch/mac68k/dev/asc.c asc
+attach asc at obio_norm
+file arch/mac68k/dev/asc.c asc needs-flag
define grfbus { }
file arch/mac68k/dev/grf_subr.c grfbus
device intvid: grfbus
-attach intvid at obio
+attach intvid at obio_norm
file arch/mac68k/dev/grf_iv.c intvid
device macvid: grfbus
@@ -47,35 +49,37 @@ attach grf at grfbus
file arch/mac68k/dev/grf.c grf needs-flag
device ae: ifnet, ether
-attach ae at nubus
-file arch/mac68k/dev/if_ae.c ae needs-flag
+attach ae at nubus with ae_nubus
+file arch/mac68k/dev/if_ae_nubus.c ae_nubus
+file arch/mac68k/dev/if_ae.c ae
device ite
attach ite at grf
file arch/mac68k/dev/ite.c ite needs-flag
device sn: ifnet, ether
-attach sn at obio
+attach sn at obio_norm
file arch/mac68k/dev/if_sn.c sn needs-flag
include "../../../scsi/files.scsi"
# Option 1 for ncr5380 support
device ncrscsi: scsi
-attach ncrscsi at obio
+attach ncrscsi at obio_scsi5380
file arch/mac68k/dev/mac68k5380.c ncrscsi needs-flag
# Option 2 for ncr5380 support
device sbc: scsi, ncr5380sbc
-attach sbc at obio
+attach sbc at obio_scsi5380 with sbc_obio
+file arch/mac68k/dev/sbc_obio.c sbc_obio
file arch/mac68k/dev/sbc.c sbc
device esp: scsi, ncr53c9x
-attach esp at obio
+attach esp at obio_norm
file arch/mac68k/dev/esp.c esp
device zsc { channel = -1 }
-attach zsc at obio
+attach zsc at obio_norm
file arch/mac68k/dev/zs.c zsc needs-flag
file arch/mac68k/dev/z8530sc.c zsc
#file dev/ic/z8530sc.c zsc
@@ -87,7 +91,7 @@ file arch/mac68k/dev/z8530tty.c zstty needs-flag
# This one is out of alphabetical order
device fpu
-attach fpu at obio
+attach fpu at mainbus
file arch/mac68k/mac68k/fpu.c fpu
file arch/m68k/m68k/copy.s
diff --git a/sys/arch/mac68k/conf/std.mac68k b/sys/arch/mac68k/conf/std.mac68k
index 92484d90370..2da349674c3 100644
--- a/sys/arch/mac68k/conf/std.mac68k
+++ b/sys/arch/mac68k/conf/std.mac68k
@@ -1,5 +1,5 @@
-# $OpenBSD: std.mac68k,v 1.8 1997/01/24 01:35:26 briggs Exp $
-# $NetBSD: std.mac68k,v 1.16 1996/11/19 00:38:07 scottr Exp $
+# $OpenBSD: std.mac68k,v 1.9 1997/03/08 16:16:47 briggs Exp $
+# $NetBSD: std.mac68k,v 1.18 1997/02/13 17:29:43 scottr Exp $
#
# standard Macintosh information.
# roughly copied from std.sparc 14 Oct 1993.
@@ -8,12 +8,12 @@ machine mac68k m68k
mainbus0 at root
+fpu0 at mainbus?
+
# on-board I/O
obio0 at mainbus?
adb0 at obio?
-asc0 at obio?
-fpu0 at obio?
zsc0 at obio?
zstty* at zsc? channel ?
diff --git a/sys/arch/mac68k/dev/asc.c b/sys/arch/mac68k/dev/asc.c
index 42c0d3f0d7a..349165904dc 100644
--- a/sys/arch/mac68k/dev/asc.c
+++ b/sys/arch/mac68k/dev/asc.c
@@ -1,6 +1,36 @@
-/* $OpenBSD: asc.c,v 1.5 1997/01/24 01:35:29 briggs Exp $ */
-/* $NetBSD: asc.c,v 1.15 1996/12/16 16:17:02 scottr Exp $ */
+/* $OpenBSD: asc.c,v 1.6 1997/03/08 16:16:48 briggs Exp $ */
+/* $NetBSD: asc.c,v 1.20 1997/02/24 05:47:33 scottr Exp $ */
+/*
+ * Copyright (C) 1997 Scott Reynolds
+ * 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 Scott Reynolds for
+ * the NetBSD Project.
+ * 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.
+ */
/*-
* Copyright (C) 1993 Allen K. Briggs, Chris P. Caputo,
* Michael L. Finch, Bradley A. Grantham, and
@@ -35,7 +65,7 @@
*/
/*
- * ASC driver code and asc_ringbell() support
+ * ASC driver code and console bell support
*/
#include <sys/types.h>
@@ -45,28 +75,31 @@
#include <sys/systm.h>
#include <sys/param.h>
#include <sys/device.h>
+#include <sys/fcntl.h>
+
+#include <vm/vm.h>
+#include <vm/pmap.h>
#include <machine/autoconf.h>
#include <machine/cpu.h>
+#include <machine/bus.h>
#include "ascvar.h"
+#include "obiovar.h"
-/* Global ASC location */
-volatile unsigned char *ASCBase = (unsigned char *) 0x14000;
+#define MAC68K_ASC_BASE 0x50f14000
+#define MAC68K_ASC_LEN 0x01000
+static u_int8_t asc_wave_tab[0x800];
-/* bell support data */
-static int asc_configured = 0;
-static int bell_freq = 1880;
-static int bell_length = 10;
-static int bell_volume = 100;
-static int bell_ringing = 0;
+static int asc_ring_bell __P((void *, int, int, int));
+static void asc_stop_bell __P((void *));
-static int ascmatch __P((struct device *, struct cfdata *, void *));
-static void ascattach __P((struct device *, struct device *, void *));
+static int ascmatch __P((struct device *, void *, void *));
+static void ascattach __P((struct device *, struct device *, void *));
struct cfattach asc_ca = {
- sizeof(struct device), ascmatch, ascattach
+ sizeof(struct asc_softc), ascmatch, ascattach
};
struct cfdriver asc_cd = {
@@ -74,131 +107,251 @@ struct cfdriver asc_cd = {
};
static int
-ascmatch(parent, cf, aux)
+ascmatch(parent, vcf, aux)
struct device *parent;
- struct cfdata *cf;
+ void *vcf;
void *aux;
{
- if (badbaddr((unsigned char *) ASCBase))
- return 0;
- return 1;
+ struct obio_attach_args *oa = (struct obio_attach_args *)aux;
+ bus_addr_t addr;
+ bus_space_handle_t bsh;
+ int rval = 0;
+
+ addr = (bus_addr_t)(oa->oa_addr != (-1) ?
+ oa->oa_addr : MAC68K_ASC_BASE);
+
+ if (bus_space_map(oa->oa_tag, addr, MAC68K_ASC_LEN, 0, &bsh))
+ return (0);
+
+ if (bus_probe(oa->oa_tag, bsh, 0, 1))
+ rval = 1;
+ else
+ rval = 0;
+
+ bus_space_unmap(oa->oa_tag, bsh, MAC68K_ASC_LEN);
+
+ return rval;
}
static void
-ascattach(parent, dev, aux)
- struct device *parent, *dev;
- void *aux;
+ascattach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
{
- printf(" Apple sound chip.\n");
- asc_configured = 1;
+ struct asc_softc *sc = (struct asc_softc *)self;
+ struct obio_attach_args *oa = (struct obio_attach_args *)aux;
+ bus_addr_t addr;
+ int i;
+
+ sc->sc_tag = oa->oa_tag;
+ addr = (bus_addr_t)(oa->oa_addr != (-1) ?
+ oa->oa_addr : MAC68K_ASC_BASE);
+ if (bus_space_map(sc->sc_tag, addr, MAC68K_ASC_LEN, 0,
+ &sc->sc_handle)) {
+ printf(": can't map memory space\n");
+ return;
+ }
+ sc->sc_open = 0;
+ sc->sc_ringing = 0;
+
+ for (i = 0; i < 256; i++) { /* up part of wave, four voices? */
+ asc_wave_tab[i] = i / 4;
+ asc_wave_tab[i + 512] = i / 4;
+ asc_wave_tab[i + 1024] = i / 4;
+ asc_wave_tab[i + 1536] = i / 4;
+ }
+ for (i = 0; i < 256; i++) { /* down part of wave, four voices? */
+ asc_wave_tab[i + 256] = 0x3f - (i / 4);
+ asc_wave_tab[i + 768] = 0x3f - (i / 4);
+ asc_wave_tab[i + 1280] = 0x3f - (i / 4);
+ asc_wave_tab[i + 1792] = 0x3f - (i / 4);
+ }
+
+ printf(": Apple Sound Chip");
+ if (oa->oa_addr != (-1))
+ printf(" at %x", oa->oa_addr);
+ printf("\n");
+
+ mac68k_set_bell_callback(asc_ring_bell, sc);
}
-int
-asc_setbellparams(freq, length, volume)
- int freq;
- int length;
- int volume;
+int
+ascopen(dev, flag, mode, p)
+ dev_t dev;
+ int flag;
+ int mode;
+ struct proc *p;
{
- if (!asc_configured) return (ENODEV);
+ struct asc_softc *sc;
+ int unit;
- /* I only perform these checks for sanity. */
- /* I suppose someone might want a bell that rings */
- /* all day, but then the can make kernel mods themselves. */
+ unit = ASCUNIT(dev);
+ sc = asc_cd.cd_devs[unit];
+ if (unit >= asc_cd.cd_ndevs)
+ return (ENXIO);
+ if (sc->sc_open)
+ return (EBUSY);
+ sc->sc_open = 1;
+
+ return (0);
+}
- if (freq < 10 || freq > 40000)
- return (EINVAL);
- if (length < 0 || length > 3600)
- return (EINVAL);
- if (volume < 0 || volume > 100)
- return (EINVAL);
+int
+ascclose(dev, flag, mode, p)
+ dev_t dev;
+ int flag;
+ int mode;
+ struct proc *p;
+{
+ struct asc_softc *sc;
- bell_freq = freq;
- bell_length = length;
- bell_volume = volume;
+ sc = asc_cd.cd_devs[ASCUNIT(dev)];
+ sc->sc_open = 0;
return (0);
}
+int
+ascread(dev, uio, ioflag)
+ dev_t dev;
+ struct uio *uio;
+ int ioflag;
+{
+ return (ENXIO);
+}
-int
-asc_getbellparams(freq, length, volume)
- int *freq;
- int *length;
- int *volume;
+int
+ascwrite(dev, uio, ioflag)
+ dev_t dev;
+ struct uio *uio;
+ int ioflag;
{
- if (!asc_configured) return (ENODEV);
+ return (ENXIO);
+}
- *freq = bell_freq;
- *length = bell_length;
- *volume = bell_volume;
+int
+ascioctl(dev, cmd, data, flag, p)
+ dev_t dev;
+ int cmd;
+ caddr_t data;
+ int flag;
+ struct proc *p;
+{
+ struct asc_softc *sc;
+ int error;
+ int unit = ASCUNIT(dev);
- return (0);
-}
+ sc = asc_cd.cd_devs[unit];
+ error = 0;
+ switch (cmd) {
+ default:
+ error = EINVAL;
+ break;
+ }
+ return (error);
+}
-void
-asc_bellstop(param)
- int param;
+int
+ascselect(dev, rw, p)
+ dev_t dev;
+ int rw;
+ struct proc *p;
{
- if (!asc_configured) return;
+ switch (rw) {
+ case FREAD:
+ break;
- if (bell_ringing > 1000 || bell_ringing < 0)
- panic("bell got out of synch?????");
- if (--bell_ringing == 0) {
- ASCBase[0x801] = 0;
+ case FWRITE:
+ return (1); /* always fails => never blocks */
+ break;
}
- /* disable ASC */
+
+ return (0);
}
+int
+ascmmap(dev, off, prot)
+ dev_t dev;
+ int off;
+ int prot;
+{
+ int unit = ASCUNIT(dev);
+ struct asc_softc *sc;
+ vm_offset_t pa;
+
+ sc = asc_cd.cd_devs[unit];
+ if (off < MAC68K_ASC_LEN) {
+ pa = pmap_extract(pmap_kernel(), (vm_offset_t)sc->sc_handle);
+ return mac68k_btop(pa + off);
+ }
+
+ return (-1);
+}
-int
-asc_ringbell()
+static int
+asc_ring_bell(arg, freq, length, volume)
+ void *arg;
+ int freq, length, volume;
{
- int i;
- unsigned long freq;
-
- if (!asc_configured) return (ENODEV);
-
- if (bell_ringing == 0) {
- for (i = 0; i < 0x800; i++)
- ASCBase[i] = 0;
-
- for (i = 0; i < 256; i++) {
- ASCBase[i] = i / 4;
- ASCBase[i + 512] = i / 4;
- ASCBase[i + 1024] = i / 4;
- ASCBase[i + 1536] = i / 4;
- } /* up part of wave, four voices ? */
- for (i = 0; i < 256; i++) {
- ASCBase[i + 256] = 0x3f - (i / 4);
- ASCBase[i + 768] = 0x3f - (i / 4);
- ASCBase[i + 1280] = 0x3f - (i / 4);
- ASCBase[i + 1792] = 0x3f - (i / 4);
- } /* down part of wave, four voices ? */
+ struct asc_softc *sc = (struct asc_softc *)arg;
+ unsigned long cfreq;
+ int i;
+
+ if (!sc)
+ return (ENODEV);
+
+ if (sc->sc_ringing == 0) {
+
+ bus_space_write_multi_1(sc->sc_tag, sc->sc_handle,
+ 0, 0, 0x800);
+ bus_space_write_region_1(sc->sc_tag, sc->sc_handle,
+ 0, asc_wave_tab, 0x800);
/* Fix this. Need to find exact ASC sampling freq */
- freq = 65536 * bell_freq / 466;
+ cfreq = 65536 * freq / 466;
/* printf("beep: from %d, %02x %02x %02x %02x\n",
- * cur_beep.freq, (freq >> 24) & 0xff, (freq >> 16) & 0xff,
- * (freq >> 8) & 0xff, (freq) & 0xff); */
+ * cur_beep.freq, (cfreq >> 24) & 0xff, (cfreq >> 16) & 0xff,
+ * (cfreq >> 8) & 0xff, (cfreq) & 0xff); */
for (i = 0; i < 8; i++) {
- ASCBase[0x814 + 8 * i] = (freq >> 24) & 0xff;
- ASCBase[0x815 + 8 * i] = (freq >> 16) & 0xff;
- ASCBase[0x816 + 8 * i] = (freq >> 8) & 0xff;
- ASCBase[0x817 + 8 * i] = (freq) & 0xff;
+ bus_space_write_1(sc->sc_tag, sc->sc_handle,
+ 0x814 + 8 * i, (cfreq >> 24) & 0xff);
+ bus_space_write_1(sc->sc_tag, sc->sc_handle,
+ 0x815 + 8 * i, (cfreq >> 16) & 0xff);
+ bus_space_write_1(sc->sc_tag, sc->sc_handle,
+ 0x816 + 8 * i, (cfreq >> 8) & 0xff);
+ bus_space_write_1(sc->sc_tag, sc->sc_handle,
+ 0x817 + 8 * i, (cfreq) & 0xff);
} /* frequency; should put cur_beep.freq in here
* somewhere. */
- ASCBase[0x807] = 3; /* 44 ? */
- ASCBase[0x806] = 255 * bell_volume / 100;
- ASCBase[0x805] = 0;
- ASCBase[0x80f] = 0;
- ASCBase[0x802] = 2; /* sampled */
- ASCBase[0x801] = 2; /* enable sampled */
+ bus_space_write_1(sc->sc_tag, sc->sc_handle, 0x807, 3); /* 44 ? */
+ bus_space_write_1(sc->sc_tag, sc->sc_handle, 0x806,
+ 255 * volume / 100);
+ bus_space_write_1(sc->sc_tag, sc->sc_handle, 0x805, 0);
+ bus_space_write_1(sc->sc_tag, sc->sc_handle, 0x80f, 0);
+ bus_space_write_1(sc->sc_tag, sc->sc_handle, 0x802, 2); /* sampled */
+ bus_space_write_1(sc->sc_tag, sc->sc_handle, 0x801, 2); /* enable sampled */
}
- bell_ringing++;
- timeout((void *) asc_bellstop, 0, bell_length);
+ sc->sc_ringing++;
+ timeout(asc_stop_bell, sc, length);
+
+ return (0);
+}
+
+static void
+asc_stop_bell(arg)
+ void *arg;
+{
+ struct asc_softc *sc = (struct asc_softc *)arg;
+
+ if (!sc)
+ return;
+
+ if (sc->sc_ringing > 1000 || sc->sc_ringing < 0)
+ panic("bell got out of sync?");
- return 0;
+ if (--sc->sc_ringing == 0) /* disable ASC */
+ bus_space_write_1(sc->sc_tag, sc->sc_handle, 0x801, 0);
}
diff --git a/sys/arch/mac68k/dev/asc.h b/sys/arch/mac68k/dev/asc.h
deleted file mode 100644
index ca38d7e3016..00000000000
--- a/sys/arch/mac68k/dev/asc.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/* $OpenBSD: asc.h,v 1.2 1996/05/26 18:35:18 briggs Exp $ */
-/* $NetBSD: asc.h,v 1.3 1995/04/21 02:47:46 briggs Exp $ */
-
-/*-
- * Copyright (C) 1993 Allen K. Briggs, Chris P. Caputo,
- * Michael L. Finch, Bradley A. Grantham, and
- * Lawrence A. Kesteloot
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the Alice Group.
- * 4. The names of the Alice Group or any of its members may not be used
- * to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE ALICE GROUP ``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 ALICE GROUP 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.
- */
-
-/*
- * ASC driver code and asc_ringbell() support header
- */
-
-int asc_ringbell();
-
-int asc_getbellparams __P((int *freq, int *length, int *volume));
-
-int asc_setbellparams __P((int freq, int length, int volume));
diff --git a/sys/arch/mac68k/dev/ascvar.h b/sys/arch/mac68k/dev/ascvar.h
index 4863e392a9b..75c76ba6e69 100644
--- a/sys/arch/mac68k/dev/ascvar.h
+++ b/sys/arch/mac68k/dev/ascvar.h
@@ -1,8 +1,8 @@
-/* $OpenBSD: ascvar.h,v 1.1 1996/05/26 19:02:05 briggs Exp $ */
-/* $NetBSD: ascvar.h,v 1.1 1996/05/05 06:16:28 briggs Exp $ */
+/* $OpenBSD: ascvar.h,v 1.2 1997/03/08 16:16:49 briggs Exp $ */
+/* $NetBSD: ascvar.h,v 1.3 1997/02/24 05:47:34 scottr Exp $ */
/*
- * Copyright (c) 1995 Allen Briggs. All rights reserved.
+ * Copyright (C) 1997 Scott Reynolds. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -14,9 +14,10 @@
* 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 Allen Briggs.
+ * This product includes software developed by Scott Reynolds for
+ * the NetBSD Project.
* 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
+ * 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
@@ -30,7 +31,20 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-int asc_setbellparams __P((int freq, int length, int volume));
-int asc_getbellparams __P((int *freq, int *length, int *volume));
-void asc_bellstop __P((int param));
-int asc_ringbell __P((void));
+#define ASCUNIT(d) ((d) & 0x7)
+
+struct asc_softc {
+ struct device sc_dev;
+ bus_space_tag_t sc_tag;
+ bus_space_handle_t sc_handle;
+ int sc_open;
+ int sc_ringing;
+};
+
+int ascopen __P((dev_t dev, int flag, int mode, struct proc *p));
+int ascclose __P((dev_t dev, int flag, int mode, struct proc *p));
+int ascread __P((dev_t, struct uio *, int));
+int ascwrite __P((dev_t, struct uio *, int));
+int ascioctl __P((dev_t, int, caddr_t, int, struct proc *p));
+int ascselect __P((dev_t dev, int rw, struct proc *p));
+int ascmmap __P((dev_t dev, int off, int prot));
diff --git a/sys/arch/mac68k/dev/esp.c b/sys/arch/mac68k/dev/esp.c
index 02bbec4d718..35dd3d451fa 100644
--- a/sys/arch/mac68k/dev/esp.c
+++ b/sys/arch/mac68k/dev/esp.c
@@ -195,8 +195,8 @@ espattach(parent, self, aux)
unsigned long reg_offset;
esc->sc_reg = (volatile u_char *) SCSIBase;
- mac68k_register_scsi_irq(
- (void (*)(void *)) ncr53c9x_intr, esc);
+ via2_register_irq(VIA2_SCSIIRQ,
+ (void (*)(void *))ncr53c9x_intr, esc);
esc->irq_mask = V2IF_SCSIIRQ;
reg_offset = SCSIBase - IOBase;
if (reg_offset == 0x10000) {
@@ -206,8 +206,8 @@ espattach(parent, self, aux)
}
} else {
esc->sc_reg = (volatile u_char *) SCSIBase + 0x402;
- mac68k_register_scsi_b_irq(
- (void (*)(void *)) ncr53c9x_intr, sc);
+ via2_register_irq(VIA2_SCSIDRQ,
+ (void (*)(void *))ncr53c9x_intr, esc);
esc->irq_mask = V2IF_SCSIDRQ; /* V2IF_T1? */
sc->sc_freq = 25000000;
}
diff --git a/sys/arch/mac68k/dev/grf.c b/sys/arch/mac68k/dev/grf.c
index 162fad5c60a..233524a8d02 100644
--- a/sys/arch/mac68k/dev/grf.c
+++ b/sys/arch/mac68k/dev/grf.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: grf.c,v 1.5 1997/01/24 01:35:29 briggs Exp $ */
-/* $NetBSD: grf.c,v 1.39 1996/12/16 16:17:05 scottr Exp $ */
+/* $OpenBSD: grf.c,v 1.6 1997/03/08 16:16:50 briggs Exp $ */
+/* $NetBSD: grf.c,v 1.41 1997/02/24 06:20:04 scottr Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -60,8 +60,9 @@
#include <sys/vnode.h>
#include <sys/systm.h>
-#include <machine/grfioctl.h>
+#include <machine/bus.h>
#include <machine/cpu.h>
+#include <machine/grfioctl.h>
#include <miscfs/specfs/specdev.h>
@@ -363,7 +364,7 @@ grfmap(dev, addrp, p)
*addrp = (caddr_t) mac68k_trunc_page(mac68k_vidphys);
else
*addrp = (caddr_t) mac68k_trunc_page(
- NUBUS_SLOT_TO_PADDR(gp->sc_slot->slot));
+ NUBUS_SLOT2PA(gp->sc_slot->slot));
vn.v_type = VCHR; /* XXX */
vn.v_specinfo = &si; /* XXX */
diff --git a/sys/arch/mac68k/dev/grf_iv.c b/sys/arch/mac68k/dev/grf_iv.c
index 2ce58680ab9..fa295ae6f6f 100644
--- a/sys/arch/mac68k/dev/grf_iv.c
+++ b/sys/arch/mac68k/dev/grf_iv.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: grf_iv.c,v 1.7 1997/01/24 01:35:30 briggs Exp $ */
-/* $NetBSD: grf_iv.c,v 1.16 1996/12/16 16:17:06 scottr Exp $ */
+/* $OpenBSD: grf_iv.c,v 1.8 1997/03/08 16:16:51 briggs Exp $ */
+/* $NetBSD: grf_iv.c,v 1.17 1997/02/20 00:23:27 scottr Exp $ */
/*
* Copyright (c) 1995 Allen Briggs. All rights reserved.
@@ -45,6 +45,7 @@
#include <sys/systm.h>
#include <machine/autoconf.h>
+#include <machine/bus.h>
#include <machine/cpu.h>
#include <machine/macinfo.h>
#include <machine/grfioctl.h>
diff --git a/sys/arch/mac68k/dev/grf_mv.c b/sys/arch/mac68k/dev/grf_mv.c
index 0645c3482a2..febd98d1873 100644
--- a/sys/arch/mac68k/dev/grf_mv.c
+++ b/sys/arch/mac68k/dev/grf_mv.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: grf_mv.c,v 1.6 1997/01/24 01:35:31 briggs Exp $ */
-/* $NetBSD: grf_mv.c,v 1.15 1996/12/16 16:17:06 scottr Exp $ */
+/* $OpenBSD: grf_mv.c,v 1.7 1997/03/08 16:16:51 briggs Exp $ */
+/* $NetBSD: grf_mv.c,v 1.17 1997/02/24 06:20:06 scottr Exp $ */
/*
* Copyright (c) 1995 Allen Briggs. All rights reserved.
@@ -43,6 +43,7 @@
#include <sys/proc.h>
#include <sys/systm.h>
+#include <machine/bus.h>
#include <machine/cpu.h>
#include <machine/grfioctl.h>
#include <machine/viareg.h>
@@ -53,7 +54,9 @@
static void load_image_data __P((caddr_t data, struct image_data *image));
static void grfmv_intr __P((void *vsc, int slot));
+#ifndef MYSTERY
static char zero = 0;
+#endif
static int grfmv_mode __P((struct grf_softc *gp, int cmd, void *arg));
static caddr_t grfmv_phys __P((struct grf_softc *gp, vm_offset_t addr));
@@ -98,6 +101,50 @@ grfmv_intr(vsc, slot)
void *vsc;
int slot;
{
+#ifdef MYSTERY
+ struct grfbus_softc *sc;
+ caddr_t slotbase;
+
+ sc = (struct grfbus_softc *) vsc;
+ slotbase = (caddr_t) sc->sc_slot.virtual_base;
+ asm volatile(" movl %0,a0
+ movl a0@(0xff6028),d0
+ andl #0x2,d0
+ beq _mv_intr0
+ movql #0x3,d0
+ _mv_intr0:
+ movl a0@(0xff600c),d1
+ andl #0x3,d1
+ cmpl d1,d0
+ beq _mv_intr_fin
+ movl d0,a0@(0xff600c)
+ nop
+ tstb d0
+ beq _mv_intr1
+ movl #0x0002,a0@(0xff6040)
+ movl #0x0102,a0@(0xff6044)
+ movl #0x0105,a0@(0xff6048)
+ movl #0x000e,a0@(0xff604c)
+ movl #0x001c,a0@(0xff6050)
+ movl #0x00bc,a0@(0xff6054)
+ movl #0x00c3,a0@(0xff6058)
+ movl #0x0061,a0@(0xff605c)
+ movl #0x0012,a0@(0xff6060)
+ bra _mv_intr_fin
+ _mv_intr1:
+ movl #0x0002,a0@(0xff6040)
+ movl #0x0209,a0@(0xff6044)
+ movl #0x020c,a0@(0xff6048)
+ movl #0x000f,a0@(0xff604c)
+ movl #0x0027,a0@(0xff6050)
+ movl #0x00c7,a0@(0xff6054)
+ movl #0x00d7,a0@(0xff6058)
+ movl #0x006b,a0@(0xff605c)
+ movl #0x0029,a0@(0xff6060)
+ _mv_intr_fin:
+ movl #0x1,a0@(0xff6014)"
+ : : "g" (slotbase) : "a0","d0","d1");
+#else
caddr_t slotbase;
struct grfbus_softc *sc;
@@ -111,6 +158,7 @@ grfmv_intr(vsc, slot)
slotbase[0xa0000] = zero;
break;
}
+#endif
}
static int
@@ -248,6 +296,6 @@ grfmv_phys(gp, addr)
struct grf_softc *gp;
vm_offset_t addr;
{
- return (caddr_t) (NUBUS_SLOT_TO_PADDR(gp->sc_slot->slot) +
+ return (caddr_t) (NUBUS_SLOT2PA(gp->sc_slot->slot) +
(addr - gp->sc_slot->virtual_base));
}
diff --git a/sys/arch/mac68k/dev/grf_subr.c b/sys/arch/mac68k/dev/grf_subr.c
index 22ca3dcb055..eb2631a34dc 100644
--- a/sys/arch/mac68k/dev/grf_subr.c
+++ b/sys/arch/mac68k/dev/grf_subr.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: grf_subr.c,v 1.3 1996/11/23 21:45:51 kstailey Exp $ */
-/* $NetBSD: grf_subr.c,v 1.2 1996/08/04 06:03:56 scottr Exp $ */
+/* $OpenBSD: grf_subr.c,v 1.4 1997/03/08 16:16:52 briggs Exp $ */
+/* $NetBSD: grf_subr.c,v 1.6 1997/02/20 00:23:28 scottr Exp $ */
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -41,6 +41,7 @@
#include <sys/device.h>
#include <sys/systm.h>
+#include <machine/bus.h>
#include <machine/grfioctl.h>
#include <mac68k/dev/nubus.h>
diff --git a/sys/arch/mac68k/dev/if_ae.c b/sys/arch/mac68k/dev/if_ae.c
index 4047cd2e179..4e7766bc0ad 100644
--- a/sys/arch/mac68k/dev/if_ae.c
+++ b/sys/arch/mac68k/dev/if_ae.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: if_ae.c,v 1.9 1997/01/24 01:35:31 briggs Exp $ */
-/* $NetBSD: if_ae.c,v 1.50 1996/12/18 02:54:43 scottr Exp $ */
+/* $OpenBSD: if_ae.c,v 1.10 1997/03/08 16:16:52 briggs Exp $ */
+/* $NetBSD: if_ae.c,v 1.57 1997/03/04 15:12:04 scottr Exp $ */
/*
* Device driver for National Semiconductor DS8390/WD83C690 based ethernet
@@ -20,7 +20,6 @@
#include "bpfilter.h"
#include <sys/param.h>
-#include <sys/types.h>
#include <sys/systm.h>
#include <sys/errno.h>
#include <sys/ioctl.h>
@@ -47,367 +46,113 @@
#include <net/bpfdesc.h>
#endif
+#include <machine/bus.h>
#include <machine/viareg.h>
-#include "nubus.h"
+
#include <dev/ic/dp8390reg.h>
#include "if_aereg.h"
+#include "if_aevar.h"
#define INTERFACE_NAME_LEN 32
-/*
- * ae_softc: per line info and status
- */
-struct ae_softc {
- struct device sc_dev;
- nubus_slot sc_slot;
-/* struct intrhand sc_ih; */
-
- struct arpcom sc_arpcom;/* ethernet common */
-
- char type_str[INTERFACE_NAME_LEN]; /* type string */
- u_short type; /* interface type code */
- u_char vendor; /* interface vendor */
- u_char regs_rev; /* registers are reversed */
-
-#define REG_MAP(sc, reg) ((sc)->regs_rev ? (0x0f-(reg))<<2 : (reg)<<2)
-#define NIC_GET(sc, reg) ((sc)->nic_addr[REG_MAP(sc, reg)])
-#define NIC_PUT(sc, reg, val) ((sc)->nic_addr[REG_MAP(sc, reg)] = (val))
- volatile caddr_t nic_addr; /* NIC (DS8390) I/O bus address */
- caddr_t rom_addr; /* on board prom address */
-
- u_char cr_proto; /* values always set in CR */
-
- caddr_t mem_start; /* shared memory start address */
- caddr_t mem_end; /* shared memory end address */
- u_long mem_size; /* total shared memory size */
- caddr_t mem_ring; /* start of RX ring-buffer (in smem) */
-
- u_char txb_cnt; /* Number of transmit buffers */
- u_char txb_inuse; /* number of transmit buffers active */
-
- u_char txb_new; /* pointer to where new buffer will be added */
- u_char txb_next_tx; /* pointer to next buffer ready to xmit */
- u_short txb_len[8]; /* buffered xmit buffer lengths */
- u_char tx_page_start; /* first page of TX buffer area */
- u_char rec_page_start; /* first page of RX ring-buffer */
- u_char rec_page_stop; /* last page of RX ring-buffer */
- u_char next_packet; /* pointer to next unread RX packet */
-};
-
-static int ae_card_vendor __P((struct nubus_attach_args *na));
-static int ae_size_card_memory __P((caddr_t addr));
-
-int aematch __P((struct device *, struct cfdata *, void *));
-void aeattach __P((struct device *, struct device *, void *));
-void aeintr __P((void *, int));
-int aeioctl __P((struct ifnet *, u_long, caddr_t));
-void aestart __P((struct ifnet *));
-void aewatchdog __P((struct ifnet *));
-void aereset __P((struct ae_softc *));
-void aeinit __P((struct ae_softc *));
-void aestop __P((struct ae_softc *));
-
-void aeread __P((struct ae_softc *, caddr_t, int));
-struct mbuf *aeget __P((struct ae_softc *, caddr_t, int));
-
#define inline /* XXX for debugging porpoises */
-u_short ae_put __P((struct ae_softc *, struct mbuf *, caddr_t));
-void ae_getmcaf __P((struct arpcom *, u_char *));
-
static inline void ae_rint __P((struct ae_softc *));
static inline void ae_xmit __P((struct ae_softc *));
-static inline caddr_t ae_ring_copy __P((
- struct ae_softc *, caddr_t, caddr_t, int));
-
-struct cfattach ae_ca = {
- sizeof(struct ae_softc), aematch, aeattach
-};
-
-struct cfdriver ae_cd = {
- NULL, "ae", DV_IFNET
-};
+static inline int ae_ring_copy __P(( struct ae_softc *, int, caddr_t, int));
#define ETHER_MIN_LEN 64
#define ETHER_MAX_LEN 1518
#define ETHER_ADDR_LEN 6
-static char zero = 0;
-
-/*
- * XXX These two should be moved to locore, and maybe changed to use shorts
- * instead of bytes. The reason for these is that bcopy and bzero use longs,
- * which the ethernet cards can't handle.
- */
-
-void bszero __P((u_short *addr, int len));
-static inline void word_copy __P((caddr_t a, caddr_t b, int len));
-static inline void byte_copy __P((caddr_t a, caddr_t b, int len));
-void
-bszero(u_short * addr, int len)
-{
- while (len--)
- *addr++ = 0;
-}
-
-/*
- * Memory copy, copies word at time.
- */
-static inline void
-word_copy(a, b, len)
- caddr_t a, b;
- int len;
-{
- u_short *x = (u_short *) a, *y = (u_short *) b;
-
- len >>= 1;
- while (len--)
- *y++ = *x++;
-}
-
-/*
- * Memory copy, copies bytes at time.
- */
-static inline void
-byte_copy(a, b, len)
- caddr_t a, b;
- int len;
-{
- while (len--)
- *b++ = *a++;
-}
-
-static int
-ae_card_vendor(na)
- struct nubus_attach_args *na;
-{
- int vendor;
-
- switch (na->drsw) {
- case NUBUS_DRSW_3COM:
- case NUBUS_DRSW_APPLE:
- case NUBUS_DRSW_TECHWORKS:
- vendor = AE_VENDOR_APPLE;
- break;
- case NUBUS_DRSW_ASANTE:
- vendor = AE_VENDOR_ASANTE;
- break;
- case NUBUS_DRSW_FARALLON:
- vendor = AE_VENDOR_FARALLON;
- break;
- case NUBUS_DRSW_FOCUS:
- vendor = AE_VENDOR_FOCUS;
- break;
- case NUBUS_DRSW_GATOR:
- switch (na->drhw) {
- default:
- case NUBUS_DRHW_INTERLAN:
- vendor = AE_VENDOR_INTERLAN;
- break;
- case NUBUS_DRHW_KINETICS:
- vendor = AE_VENDOR_DAYNA;
- break;
- }
- break;
- default:
-#ifdef AE_DEBUG
- printf("Unknown ethernet drsw: %x\n", na->drsw);
-#endif
- vendor = AE_VENDOR_UNKNOWN;
- }
- return vendor;
-}
-
-static int
-ae_size_card_memory(addr)
- caddr_t addr;
+#define REG_MAP(sc, reg) ((sc)->regs_rev ? (0x0f-(reg))<<2 : (reg)<<2)
+#define NIC_GET(sc, reg) (bus_space_read_1((sc)->sc_regt, \
+ (sc)->sc_regh, \
+ (REG_MAP(sc, reg))))
+#define NIC_PUT(sc, reg, val) (bus_space_write_1((sc)->sc_regt, \
+ (sc)->sc_regh, \
+ (REG_MAP(sc, reg)), (val)))
+
+struct cfdriver ae_cd = {
+ NULL, "ae", DV_IFNET
+};
+
+int
+ae_size_card_memory(bst, bsh, ofs)
+ bus_space_tag_t bst;
+ bus_space_handle_t bsh;
+ int ofs;
{
- u_short *p;
- u_short i1, i2, i3, i4;
-
- p = (u_short *) addr;
+ int i1, i2, i3, i4;
/*
- * very simple size memory, assuming it's installed in 8k
* banks; also assume it will generally mirror in upper banks
* if not installed.
*/
- i1 = (8192 * 0) / 2;
- i2 = (8192 * 1) / 2;
- i3 = (8192 * 2) / 2;
- i4 = (8192 * 3) / 2;
-
- p[i1] = 0x1111;
- p[i2] = 0x2222;
- p[i3] = 0x3333;
- p[i4] = 0x4444;
-
- if (p[i1] == 0x1111 && p[i2] == 0x2222 &&
- p[i3] == 0x3333 && p[i4] == 0x4444)
+ i1 = (8192 * 0);
+ i2 = (8192 * 1);
+ i3 = (8192 * 2);
+ i4 = (8192 * 3);
+
+ bus_space_write_2(bst, bsh, ofs + i1, 0x1111);
+ bus_space_write_2(bst, bsh, ofs + i2, 0x2222);
+ bus_space_write_2(bst, bsh, ofs + i3, 0x3333);
+ bus_space_write_2(bst, bsh, ofs + i4, 0x4444);
+
+ if (bus_space_read_2(bst, bsh, ofs + i1) == 0x1111 &&
+ bus_space_read_2(bst, bsh, ofs + i2) == 0x2222 &&
+ bus_space_read_2(bst, bsh, ofs + i3) == 0x3333 &&
+ bus_space_read_2(bst, bsh, ofs + i4) == 0x4444)
return 8192 * 4;
- if ((p[i1] == 0x1111 && p[i2] == 0x2222) ||
- (p[i1] == 0x3333 && p[i2] == 0x4444))
+ if ((bus_space_read_2(bst, bsh, ofs + i1) == 0x1111 &&
+ bus_space_read_2(bst, bsh, ofs + i2) == 0x2222) ||
+ (bus_space_read_2(bst, bsh, ofs + i1) == 0x3333 &&
+ bus_space_read_2(bst, bsh, ofs + i2) == 0x4444))
return 8192 * 2;
- if (p[i1] == 0x1111 || p[i1] == 0x4444)
+ if (bus_space_read_2(bst, bsh, ofs + i1) == 0x1111 ||
+ bus_space_read_2(bst, bsh, ofs + i1) == 0x4444)
return 8192;
return 0;
}
-int
-aematch(parent, cf, aux)
- struct device *parent;
- struct cfdata *cf;
- void *aux;
-{
- struct nubus_attach_args *na = (struct nubus_attach_args *) aux;
-
- if (na->category != NUBUS_CATEGORY_NETWORK)
- return 0;
-
- if (na->type != NUBUS_TYPE_ETHERNET)
- return 0;
-
- switch (ae_card_vendor(na)) {
- case AE_VENDOR_APPLE:
- case AE_VENDOR_ASANTE:
- case AE_VENDOR_FARALLON:
- case AE_VENDOR_INTERLAN:
- break;
-
- case AE_VENDOR_DAYNA:
- case AE_VENDOR_FOCUS:
- default:
- return 0;
- }
- return 1;
-}
-
/*
- * Install interface into kernel networking data structures
+ * Do bus-independent setup.
*/
-void
-aeattach(parent, self, aux)
- struct device *parent, *self;
- void *aux;
+int
+aesetup(sc)
+ struct ae_softc *sc;
{
- struct ae_softc *sc = (struct ae_softc *) self;
- struct nubus_attach_args *na = (struct nubus_attach_args *) aux;
struct ifnet *ifp = &sc->sc_arpcom.ac_if;
- caddr_t addr;
- int i, memsize;
- int flags = 0;
-
- sc->regs_rev = 0;
- sc->vendor = ae_card_vendor(na);
- strncpy(sc->type_str, nubus_get_card_name(na->fmt),
- INTERFACE_NAME_LEN);
- sc->type_str[INTERFACE_NAME_LEN-1] = '\0';
-
- addr = (caddr_t) na->fmt->virtual_base;
- memsize = 0;
-
- switch (sc->vendor) {
- case AE_VENDOR_INTERLAN:
- sc->nic_addr = addr + GC_NIC_OFFSET;
- sc->rom_addr = addr + GC_ROM_OFFSET;
- sc->mem_start = addr + GC_DATA_OFFSET;
- if ((memsize = ae_size_card_memory(sc->mem_start)) == 0) {
- printf(": failed to determine size of RAM.\n");
- return;
- }
-
- /* reset the NIC chip */
- *((caddr_t) addr + GC_RESET_OFFSET) = (char) zero;
-
- /* Get station address from on-board ROM */
- for (i = 0; i < ETHER_ADDR_LEN; ++i)
- sc->sc_arpcom.ac_enaddr[i] = *(sc->rom_addr + i * 4);
- break;
-
- /* apple-compatible cards */
- case AE_VENDOR_ASANTE:
- case AE_VENDOR_APPLE:
- sc->regs_rev = 1;
- sc->nic_addr = addr + AE_NIC_OFFSET;
- sc->rom_addr = addr + AE_ROM_OFFSET;
- sc->mem_start = addr + AE_DATA_OFFSET;
- if ((memsize = ae_size_card_memory(sc->mem_start)) == 0) {
- printf(": failed to determine size of RAM.\n");
- return;
- }
-
- /* Get station address from on-board ROM */
- for (i = 0; i < ETHER_ADDR_LEN; ++i)
- sc->sc_arpcom.ac_enaddr[i] = *(sc->rom_addr + i * 2);
- break;
-
- case AE_VENDOR_DAYNA:
- sc->nic_addr = addr + DP_NIC_OFFSET;
- sc->rom_addr = addr + DP_ROM_OFFSET;
- sc->mem_start = addr + DP_DATA_OFFSET;
- if ((memsize = ae_size_card_memory(sc->mem_start)) == 0) {
- printf(": failed to determine size of RAM.\n");
- return;
- }
-
- /* Get station address from on-board ROM */
- for (i = 0; i < ETHER_ADDR_LEN; ++i)
- sc->sc_arpcom.ac_enaddr[i] = *(sc->rom_addr + i * 4);
-
- break;
-
- case AE_VENDOR_FARALLON:
- sc->regs_rev = 1;
- sc->rom_addr = addr + FE_ROM_OFFSET;
- sc->nic_addr = addr + AE_NIC_OFFSET;
- sc->mem_start = addr + AE_DATA_OFFSET;
- if ((memsize = ae_size_card_memory(sc->mem_start)) == 0) {
- printf(": failed to determine size of RAM.\n");
- return;
- }
-
- /* Get station address from on-board ROM */
- for (i = 0; i < ETHER_ADDR_LEN; ++i)
- sc->sc_arpcom.ac_enaddr[i] = *(sc->rom_addr + i);
- break;
- case AE_VENDOR_FOCUS:
- printf(": unsupported Focus hardware\n");
- return;
- default:
- return;
- break;
- }
+ int i;
sc->cr_proto = ED_CR_RD2;
/* Allocate one xmit buffer if < 16k, two buffers otherwise. */
- if ((memsize < 16384) || (flags & AE_FLAGS_NO_DOUBLE_BUFFERING))
+ if ((sc->mem_size < 16384) ||
+ (sc->sc_flags & AE_FLAGS_NO_DOUBLE_BUFFERING))
sc->txb_cnt = 1;
else
sc->txb_cnt = 2;
sc->tx_page_start = 0;
sc->rec_page_start = sc->tx_page_start + sc->txb_cnt * ED_TXBUF_SIZE;
- sc->rec_page_stop = sc->tx_page_start + (memsize >> ED_PAGE_SHIFT);
- sc->mem_ring = sc->mem_start + (sc->rec_page_start << ED_PAGE_SHIFT);
- sc->mem_size = memsize;
- sc->mem_end = sc->mem_start + memsize;
+ sc->rec_page_stop = sc->tx_page_start + (sc->mem_size >> ED_PAGE_SHIFT);
+ sc->mem_ring = sc->rec_page_start << ED_PAGE_SHIFT;
/* Now zero memory and verify that it is clear. */
- bszero((u_short *) sc->mem_start, memsize / 2);
-
- for (i = 0; i < memsize; ++i)
- if (sc->mem_start[i])
-printf("%s: failed to clear shared memory at %p - check configuration\n",
- sc->sc_dev.dv_xname,
- sc->mem_start + i);
-
- bcopy(na->fmt, &sc->sc_slot, sizeof(nubus_slot));
+ bus_space_set_region_2(sc->sc_buft, sc->sc_bufh,
+ 0, 0, sc->mem_size / 2);
+ for (i = 0; i < sc->mem_size; ++i) {
+ if (bus_space_read_1(sc->sc_buft, sc->sc_bufh, i)) {
+printf(": failed to clear shared memory - check configuration\n");
+ return 1;
+ }
+ }
/* Set interface to stopped condition (reset). */
aestop(sc);
@@ -417,7 +162,8 @@ printf("%s: failed to clear shared memory at %p - check configuration\n",
ifp->if_softc = sc;
ifp->if_start = aestart;
ifp->if_ioctl = aeioctl;
- ifp->if_watchdog = aewatchdog;
+ if (!ifp->if_watchdog)
+ ifp->if_watchdog = aewatchdog;
ifp->if_flags =
IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS | IFF_MULTICAST;
@@ -428,22 +174,13 @@ printf("%s: failed to clear shared memory at %p - check configuration\n",
/* Print additional info when attached. */
printf(": address %s, ", ether_sprintf(sc->sc_arpcom.ac_enaddr));
- printf("type %s, %ldKB memory\n", sc->type_str, sc->mem_size / 1024);
+ printf("type %s, %dKB memory\n", sc->type_str, sc->mem_size / 1024);
#if NBPFILTER > 0
bpfattach(&ifp->if_bpf, ifp, DLT_EN10MB, sizeof(struct ether_header));
#endif
- /* make sure interrupts are vectored to us */
- add_nubus_intr(sc->sc_slot.slot, aeintr, sc);
-
- /*
- * XXX -- enable nubus interrupts here. Should be done elsewhere,
- * but that currently breaks with some nubus video cards'
- * interrupts. So we only enable nubus interrupts if we
- * have an ethernet card... i.e., we do it here.
- */
- enable_nubus_intr();
+ return 0;
}
/*
@@ -485,7 +222,6 @@ aestop(sc)
* Device timeout/watchdog routine. Entered if the device neglects to generate
* an interrupt after a transmit has been started on it.
*/
-static int aeintr_ctr = 0;
void
aewatchdog(ifp)
@@ -493,25 +229,6 @@ aewatchdog(ifp)
{
struct ae_softc *sc = ifp->if_softc;
-#if 1
-/*
- * This is a kludge! The via code seems to miss slot interrupts
- * sometimes. This kludges around that by calling the handler
- * by hand if the watchdog is activated. -- XXX (akb)
- */
- int i;
-
- i = aeintr_ctr;
-
- (*via2itab[1]) ((void *) 1);
-
- if (i != aeintr_ctr) {
- log(LOG_ERR, "%s: device timeout, recovered\n",
- sc->sc_dev.dv_xname);
- return;
- }
-#endif
-
log(LOG_ERR, "%s: device timeout\n", sc->sc_dev.dv_xname);
++sc->sc_arpcom.ac_if.if_oerrors;
@@ -545,12 +262,16 @@ aeinit(sc)
/* Set interface for page 0, remote DMA complete, stopped. */
NIC_PUT(sc, ED_P0_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STP);
- /*
- * Set FIFO threshold to 8, No auto-init Remote DMA, byte
- * order=80x86, word-wide DMA xfers,
- */
- NIC_PUT(sc, ED_P0_DCR,
- ED_DCR_FT1 | ED_DCR_WTS | ED_DCR_LS);
+ if (sc->use16bit) {
+ /*
+ * Set FIFO threshold to 8, No auto-init Remote DMA, byte
+ * order=80x86, word-wide DMA xfers,
+ */
+ NIC_PUT(sc, ED_P0_DCR, ED_DCR_FT1 | ED_DCR_WTS | ED_DCR_LS);
+ } else {
+ /* Same as above, but byte-wide DMA xfers. */
+ NIC_PUT(sc, ED_P0_DCR, ED_DCR_FT1 | ED_DCR_LS);
+ }
/* Clear remote byte count registers. */
NIC_PUT(sc, ED_P0_RBCR0, 0);
@@ -681,8 +402,8 @@ aestart(ifp)
{
struct ae_softc *sc = ifp->if_softc;
struct mbuf *m0;
- caddr_t buffer;
- int len;
+ int buffer;
+ int len;
if ((ifp->if_flags & (IFF_RUNNING | IFF_OACTIVE)) != IFF_RUNNING)
return;
@@ -709,7 +430,7 @@ outloop:
#endif
/* txb_new points to next open buffer slot. */
- buffer = sc->mem_start + ((sc->txb_new * ED_TXBUF_SIZE) << ED_PAGE_SHIFT);
+ buffer = (sc->txb_new * ED_TXBUF_SIZE) << ED_PAGE_SHIFT;
len = ae_put(sc, m0, buffer);
#if DIAGNOSTIC
@@ -745,9 +466,10 @@ ae_rint(sc)
{
u_char boundary, current;
u_short len;
- u_char nlen, *lenp;
+ u_char nlen;
+ u_int8_t *lenp;
struct ae_ring packet_hdr;
- caddr_t packet_ptr;
+ int packet_ptr;
loop:
/* Set NIC to page 1 registers to get 'current' pointer. */
@@ -777,8 +499,9 @@ loop:
* The byte count includes a 4 byte header that was added by
* the NIC.
*/
- packet_hdr = *(struct ae_ring *) packet_ptr;
- lenp = (u_char *) &((struct ae_ring *) packet_ptr)->count;
+ bus_space_read_region_1(sc->sc_buft, sc->sc_bufh,
+ packet_ptr, &packet_hdr, sizeof(struct ae_ring));
+ lenp = (u_int8_t *)&packet_hdr.count; /* sigh. */
len = lenp[0] | (lenp[1] << 8);
packet_hdr.count = len;
@@ -854,14 +577,12 @@ loop:
/* Ethernet interface interrupt processor. */
void
aeintr(arg, slot)
- void *arg;
- int slot;
+ void *arg;
+ int slot;
{
- struct ae_softc *sc = arg;
+ struct ae_softc *sc = (struct ae_softc *)arg;
struct ifnet *ifp = &sc->sc_arpcom.ac_if;
- u_char isr;
-
- aeintr_ctr++;
+ u_char isr;
/* Set NIC to page 0 registers. */
NIC_PUT(sc, ED_P0_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STA);
@@ -909,6 +630,7 @@ aeintr(arg, slot)
*/
collisions = 16;
}
+
/* Update output errors counter. */
++ifp->if_oerrors;
} else {
@@ -942,6 +664,7 @@ aeintr(arg, slot)
if (sc->txb_inuse > 0)
ae_xmit(sc);
}
+
/* Handle receiver interrupts. */
if (isr & (ED_ISR_PRX | ED_ISR_RXE | ED_ISR_OVW)) {
/*
@@ -976,6 +699,7 @@ aeintr(arg, slot)
NIC_GET(sc, ED_P0_RSR));
#endif
}
+
/*
* Go get the packet(s)
* XXX - Doing this on an error is dubious
@@ -986,6 +710,7 @@ aeintr(arg, slot)
ae_rint(sc);
}
}
+
/*
* If it looks like the transmitter can take more data, attempt
* to start output on the interface. This is done after
@@ -1007,11 +732,11 @@ aeintr(arg, slot)
* otherwise - resulting in an infinite loop.
*/
if (isr & ED_ISR_CNT) {
- static u_char dummy;
- dummy = NIC_GET(sc, ED_P0_CNTR0);
- dummy = NIC_GET(sc, ED_P0_CNTR1);
- dummy = NIC_GET(sc, ED_P0_CNTR2);
+ (void)NIC_GET(sc, ED_P0_CNTR0);
+ (void)NIC_GET(sc, ED_P0_CNTR1);
+ (void)NIC_GET(sc, ED_P0_CNTR2);
}
+
isr = NIC_GET(sc, ED_P0_ISR);
if (!isr)
return;
@@ -1024,7 +749,7 @@ aeintr(arg, slot)
int
aeioctl(ifp, cmd, data)
register struct ifnet *ifp;
- u_long cmd;
+ u_long cmd;
caddr_t data;
{
struct ae_softc *sc = ifp->if_softc;
@@ -1118,7 +843,7 @@ aeioctl(ifp, cmd, data)
void
aeread(sc, buf, len)
struct ae_softc *sc;
- caddr_t buf;
+ int buf;
int len;
{
struct ifnet *ifp = &sc->sc_arpcom.ac_if;
@@ -1172,26 +897,29 @@ aeread(sc, buf, len)
* Given a source and destination address, copy 'amount' of a packet from the
* ring buffer into a linear destination buffer. Takes into account ring-wrap.
*/
-static inline caddr_t
+static inline int
ae_ring_copy(sc, src, dst, amount)
struct ae_softc *sc;
- caddr_t src, dst;
+ int src;
+ caddr_t dst;
int amount;
{
- u_short tmp_amount;
+ bus_space_tag_t bst = sc->sc_buft;
+ bus_space_handle_t bsh = sc->sc_bufh;
+ int tmp_amount;
/* Does copy wrap to lower addr in ring buffer? */
- if (src + amount > sc->mem_end) {
- tmp_amount = sc->mem_end - src;
+ if (src + amount > sc->mem_size) {
+ tmp_amount = sc->mem_size - src;
/* Copy amount up to end of NIC memory. */
- byte_copy(src, dst, tmp_amount);
+ bus_space_read_region_1(bst, bsh, src, dst, tmp_amount);
amount -= tmp_amount;
src = sc->mem_ring;
dst += tmp_amount;
}
- byte_copy(src, dst, amount);
+ bus_space_read_region_1(bst, bsh, src, dst, amount);
return (src + amount);
}
@@ -1207,7 +935,7 @@ ae_ring_copy(sc, src, dst, amount)
struct mbuf *
aeget(sc, src, total_len)
struct ae_softc *sc;
- caddr_t src;
+ int src;
u_short total_len;
{
struct ifnet *ifp = &sc->sc_arpcom.ac_if;
@@ -1238,7 +966,7 @@ aeget(sc, src, total_len)
len = MCLBYTES;
}
m->m_len = len = min(total_len, len);
- src = ae_ring_copy(sc, src, mtod(m, caddr_t), (int) len);
+ src = ae_ring_copy(sc, src, mtod(m, caddr_t), len);
total_len -= len;
*mp = m;
mp = &m->m_next;
@@ -1246,6 +974,7 @@ aeget(sc, src, total_len)
return top;
}
+
/*
* Compute the multicast address filter from the list of multicast addresses we
* need to listen to.
@@ -1318,6 +1047,7 @@ ae_getmcaf(ac, af)
}
ifp->if_flags &= ~IFF_ALLMULTI;
}
+
/*
* Copy packet from mbuf to the board memory
*
@@ -1325,14 +1055,14 @@ ae_getmcaf(ac, af)
* unless the whole packet fits in one mbuf.
*
*/
-u_short
+int
ae_put(sc, m, buf)
struct ae_softc *sc;
struct mbuf *m;
- caddr_t buf;
+ int buf;
{
u_char *data, savebyte[2];
- int len, wantbyte;
+ int len, wantbyte;
u_short totlen = 0;
wantbyte = 0;
@@ -1345,7 +1075,8 @@ ae_put(sc, m, buf)
/* Finish the last word. */
if (wantbyte) {
savebyte[1] = *data;
- word_copy(savebyte, buf, 2);
+ bus_space_write_region_2(sc->sc_buft,
+ sc->sc_bufh, buf, savebyte, 1);
buf += 2;
data++;
len--;
@@ -1353,7 +1084,8 @@ ae_put(sc, m, buf)
}
/* Output contiguous words. */
if (len > 1) {
- word_copy(data, buf, len);
+ bus_space_write_region_2(sc->sc_buft,
+ sc->sc_bufh, buf, data, len >> 1);
buf += len & ~1;
data += len & ~1;
len &= 1;
@@ -1368,7 +1100,8 @@ ae_put(sc, m, buf)
if (wantbyte) {
savebyte[1] = 0;
- word_copy(savebyte, buf, 2);
+ bus_space_write_region_2(sc->sc_buft, sc->sc_bufh,
+ buf, savebyte, 1);
}
return (totlen);
}
diff --git a/sys/arch/mac68k/dev/if_ae_nubus.c b/sys/arch/mac68k/dev/if_ae_nubus.c
new file mode 100644
index 00000000000..a0f519067db
--- /dev/null
+++ b/sys/arch/mac68k/dev/if_ae_nubus.c
@@ -0,0 +1,408 @@
+/* $NetBSD: if_ae_nubus.c,v 1.5 1997/02/28 08:56:06 scottr Exp $ */
+
+/*
+ * Copyright (C) 1997 Scott Reynolds
+ * 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 Scott Reynolds for
+ * the NetBSD Project.
+ * 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.
+ */
+
+#include <sys/param.h>
+#include <sys/device.h>
+#include <sys/errno.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <sys/syslog.h>
+#include <sys/systm.h>
+
+#include <net/if.h>
+
+#ifdef INET
+#include <netinet/in.h>
+#include <netinet/if_ether.h>
+#endif
+
+#include <machine/bus.h>
+#include <machine/viareg.h>
+
+#include "nubus.h"
+#include <dev/ic/dp8390reg.h>
+#include "if_aereg.h"
+#include "if_aevar.h"
+
+static int ae_nubus_match __P((struct device *, void *, void *));
+static void ae_nubus_attach __P((struct device *, struct device *, void *));
+static int ae_nb_card_vendor __P((struct nubus_attach_args *));
+static int ae_nb_get_enaddr __P((struct nubus_attach_args *, u_int8_t *));
+static void ae_nb_watchdog __P((struct ifnet *));
+
+struct cfattach ae_nubus_ca = {
+ sizeof(struct ae_softc), ae_nubus_match, ae_nubus_attach
+};
+
+static int
+ae_nubus_match(parent, vcf, aux)
+ struct device *parent;
+ void *vcf;
+ void *aux;
+{
+ struct nubus_attach_args *na = (struct nubus_attach_args *) aux;
+ bus_space_handle_t bsh;
+ int rv;
+
+ if (bus_space_map(na->na_tag, NUBUS_SLOT2PA(na->slot), NBMEMSIZE,
+ 0, &bsh))
+ return (0);
+
+ rv = 0;
+
+ if (na->category == NUBUS_CATEGORY_NETWORK &&
+ na->type == NUBUS_TYPE_ETHERNET) {
+ switch (ae_nb_card_vendor(na)) {
+ case AE_VENDOR_APPLE:
+ case AE_VENDOR_ASANTE:
+ case AE_VENDOR_FARALLON:
+ case AE_VENDOR_INTERLAN:
+ case AE_VENDOR_KINETICS:
+ rv = 1;
+ break;
+ case AE_VENDOR_DAYNA:
+ case AE_VENDOR_FOCUS:
+ rv = UNSUPP;
+ break;
+ default:
+ break;
+ }
+ }
+
+ bus_space_unmap(na->na_tag, bsh, NBMEMSIZE);
+
+printf("ae_nubus_match returning %d\n", rv);
+ return rv;
+}
+
+/*
+ * Install interface into kernel networking data structures
+ */
+static void
+ae_nubus_attach(parent, self, aux)
+ struct device *parent, *self;
+ void *aux;
+{
+ struct ae_softc *sc = (struct ae_softc *) self;
+ struct nubus_attach_args *na = (struct nubus_attach_args *) aux;
+ struct ifnet *ifp = &sc->sc_arpcom.ac_if;
+ bus_space_tag_t bst;
+ bus_space_handle_t bsh;
+ int success;
+#ifdef AE_OLD_GET_ENADDR
+ int i;
+#endif
+
+printf("ae_nubus_attach\n");
+ bst = na->na_tag;
+ if (bus_space_map(bst, NUBUS_SLOT2PA(na->slot), NBMEMSIZE,
+ 0, &bsh)) {
+ printf(": can't map memory space\n");
+ return;
+ }
+
+ sc->sc_regt = sc->sc_buft = bst;
+ sc->sc_flags = self->dv_cfdata->cf_flags;
+ sc->regs_rev = 0;
+ sc->use16bit = 1;
+ sc->vendor = ae_nb_card_vendor(na);
+ strncpy(sc->type_str, nubus_get_card_name(na->fmt),
+ INTERFACE_NAME_LEN);
+ sc->type_str[INTERFACE_NAME_LEN-1] = '\0';
+ sc->mem_size = 0;
+
+ success = 0;
+
+printf("ae_nubus_attach vendor switch\n");
+ switch (sc->vendor) {
+ case AE_VENDOR_APPLE: /* Apple-compatible cards */
+ case AE_VENDOR_ASANTE:
+ sc->regs_rev = 1;
+ if (bus_space_subregion(bst, bsh,
+ AE_REG_OFFSET, AE_REG_SIZE, &sc->sc_regh)) {
+ printf(": failed to map register space\n");
+ break;
+ }
+ if ((sc->mem_size = ae_size_card_memory(bst, bsh,
+ AE_DATA_OFFSET)) == 0) {
+ printf(": failed to determine size of RAM.\n");
+ break;
+ }
+ if (bus_space_subregion(bst, bsh,
+ AE_DATA_OFFSET, sc->mem_size, &sc->sc_bufh)) {
+ printf(": failed to map register space\n");
+ break;
+ }
+#ifdef AE_OLD_GET_ENADDR
+ /* Get station address from on-board ROM */
+ for (i = 0; i < ETHER_ADDR_LEN; ++i)
+ sc->sc_arpcom.ac_enaddr[i] =
+ bus_space_read_1(bst, bsh, (AE_ROM_OFFSET + i * 2));
+#else
+ if (ae_nb_get_enaddr(na, sc->sc_arpcom.ac_enaddr)) {
+ printf(": can't find MAC address\n");
+ break;
+ }
+#endif
+
+ success = 1;
+ break;
+
+ case AE_VENDOR_DAYNA:
+ if (bus_space_subregion(bst, bsh,
+ DP_REG_OFFSET, AE_REG_SIZE, &sc->sc_regh)) {
+ printf(": failed to map register space\n");
+ break;
+ }
+ sc->mem_size = 8192;
+ if (bus_space_subregion(bst, bsh,
+ DP_DATA_OFFSET, sc->mem_size, &sc->sc_bufh)) {
+ printf(": failed to map register space\n");
+ break;
+ }
+#ifdef AE_OLD_GET_ENADDR
+ /* Get station address from on-board ROM */
+ for (i = 0; i < ETHER_ADDR_LEN; ++i)
+ sc->sc_arpcom.ac_enaddr[i] =
+ bus_space_read_1(bst, bsh, (DP_ROM_OFFSET + i * 2));
+#else
+ if (ae_nb_get_enaddr(na, sc->sc_arpcom.ac_enaddr)) {
+ printf(": can't find MAC address\n");
+ break;
+ }
+#endif
+
+ printf(": unsupported Dayna hardware\n");
+ break;
+
+ case AE_VENDOR_FARALLON:
+ sc->regs_rev = 1;
+ if (bus_space_subregion(bst, bsh,
+ AE_REG_OFFSET, AE_REG_SIZE, &sc->sc_regh)) {
+ printf(": failed to map register space\n");
+ break;
+ }
+ if ((sc->mem_size = ae_size_card_memory(bst, bsh,
+ AE_DATA_OFFSET)) == 0) {
+ printf(": failed to determine size of RAM.\n");
+ break;
+ }
+ if (bus_space_subregion(bst, bsh,
+ AE_DATA_OFFSET, sc->mem_size, &sc->sc_bufh)) {
+ printf(": failed to map register space\n");
+ break;
+ }
+#ifdef AE_OLD_GET_ENADDR
+ /* Get station address from on-board ROM */
+ for (i = 0; i < ETHER_ADDR_LEN; ++i)
+ sc->sc_arpcom.ac_enaddr[i] =
+ bus_space_read_1(bst, bsh, (FE_ROM_OFFSET + i));
+#endif
+
+ success = 1;
+ break;
+
+ case AE_VENDOR_FOCUS:
+ printf(": unsupported Focus hardware\n");
+ break;
+
+ case AE_VENDOR_INTERLAN:
+ if (bus_space_subregion(bst, bsh,
+ GC_REG_OFFSET, AE_REG_SIZE, &sc->sc_regh)) {
+ printf(": failed to map register space\n");
+ break;
+ }
+ if ((sc->mem_size = ae_size_card_memory(bst, bsh,
+ GC_DATA_OFFSET)) == 0) {
+ printf(": failed to determine size of RAM.\n");
+ break;
+ }
+ if (bus_space_subregion(bst, bsh,
+ GC_DATA_OFFSET, sc->mem_size, &sc->sc_bufh)) {
+ printf(": failed to map register space\n");
+ break;
+ }
+
+ /* reset the NIC chip */
+ bus_space_write_1(bst, bsh, GC_RESET_OFFSET, 0);
+
+#ifdef AE_OLD_GET_ENADDR
+ /* Get station address from on-board ROM */
+ for (i = 0; i < ETHER_ADDR_LEN; ++i)
+ sc->sc_arpcom.ac_enaddr[i] =
+ bus_space_read_1(bst, bsh, (GC_ROM_OFFSET + i * 4));
+#else
+ if (ae_nb_get_enaddr(na, sc->sc_arpcom.ac_enaddr)) {
+ printf(": can't find MAC address\n");
+ break;
+ }
+#endif
+
+ success = 1;
+ break;
+
+ case AE_VENDOR_KINETICS:
+ sc->use16bit = 0;
+ if (bus_space_subregion(bst, bsh,
+ KE_REG_OFFSET, AE_REG_SIZE, &sc->sc_regh)) {
+ printf(": failed to map register space\n");
+ break;
+ }
+ if ((sc->mem_size = ae_size_card_memory(bst, bsh,
+ KE_DATA_OFFSET)) == 0) {
+ printf(": failed to determine size of RAM.\n");
+ break;
+ }
+ if (bus_space_subregion(bst, bsh,
+ KE_DATA_OFFSET, sc->mem_size, &sc->sc_bufh)) {
+ printf(": failed to map register space\n");
+ break;
+ }
+ if (ae_nb_get_enaddr(na, sc->sc_arpcom.ac_enaddr)) {
+ printf(": can't find MAC address\n");
+ break;
+ }
+
+ success = 1;
+ break;
+
+ default:
+ break;
+ }
+printf("ae_nubus_attach vendor switch done\n");
+
+ if (!success) {
+ bus_space_unmap(bst, bsh, NBMEMSIZE);
+ return;
+ }
+
+ ifp->if_watchdog = ae_nb_watchdog; /* Override watchdog */
+ if (aesetup(sc)) {
+ bus_space_unmap(bst, bsh, NBMEMSIZE);
+ return;
+ }
+
+ /* make sure interrupts are vectored to us */
+ add_nubus_intr(na->slot, aeintr, sc);
+}
+
+static int
+ae_nb_card_vendor(na)
+ struct nubus_attach_args *na;
+{
+ int vendor;
+
+ switch (na->drsw) {
+ case NUBUS_DRSW_3COM:
+ case NUBUS_DRSW_APPLE:
+ case NUBUS_DRSW_TECHWORKS:
+ vendor = AE_VENDOR_APPLE;
+ break;
+ case NUBUS_DRSW_ASANTE:
+ vendor = AE_VENDOR_ASANTE;
+ break;
+ case NUBUS_DRSW_FARALLON:
+ vendor = AE_VENDOR_FARALLON;
+ break;
+ case NUBUS_DRSW_FOCUS:
+ vendor = AE_VENDOR_FOCUS;
+ break;
+ case NUBUS_DRSW_GATOR:
+ switch (na->drhw) {
+ default:
+ case NUBUS_DRHW_INTERLAN:
+ vendor = AE_VENDOR_INTERLAN;
+ break;
+ case NUBUS_DRHW_KINETICS:
+ if (strncmp(
+ nubus_get_card_name(na->fmt), "EtherPort", 9) == 0)
+ vendor = AE_VENDOR_KINETICS;
+ else
+ vendor = AE_VENDOR_DAYNA;
+ break;
+ }
+ break;
+ default:
+#ifdef AE_DEBUG
+ printf("Unknown ethernet drsw: %x\n", na->drsw);
+#endif
+ vendor = AE_VENDOR_UNKNOWN;
+ }
+ return vendor;
+}
+
+static int
+ae_nb_get_enaddr(na, ep)
+ struct nubus_attach_args *na;
+ u_int8_t *ep;
+{
+ nubus_dir dir;
+ nubus_dirent dirent;
+
+ /*
+ * XXX - note hardwired resource IDs here (0x80); these are
+ * assumed to be used by all cards, but should be fixed when
+ * we find out more about Ethernet card resources.
+ */
+ nubus_get_main_dir(na->fmt, &dir);
+ if (nubus_find_rsrc(na->fmt, &dir, 0x80, &dirent) <= 0)
+ return 1;
+ nubus_get_dir_from_rsrc(na->fmt, &dirent, &dir);
+ if (nubus_find_rsrc(na->fmt, &dir, 0x80, &dirent) <= 0)
+ return 1;
+ if (nubus_get_ind_data(na->fmt, &dirent, ep, ETHER_ADDR_LEN) <= 0)
+ return 1;
+
+ return 0;
+}
+
+static void
+ae_nb_watchdog(ifp)
+ struct ifnet *ifp;
+{
+ struct ae_softc *sc = ifp->if_softc;
+
+#if 1
+/*
+ * This is a kludge! The via code seems to miss slot interrupts
+ * sometimes. This kludges around that by calling the handler
+ * by hand if the watchdog is activated. -- XXX (akb)
+ */
+ (*via2itab[1])((void *) 1);
+#endif
+
+ log(LOG_ERR, "%s: device timeout\n", sc->sc_dev.dv_xname);
+ ++sc->sc_arpcom.ac_if.if_oerrors;
+
+ aereset(sc);
+}
diff --git a/sys/arch/mac68k/dev/if_aereg.h b/sys/arch/mac68k/dev/if_aereg.h
index b549041e4ca..f77079a93bb 100644
--- a/sys/arch/mac68k/dev/if_aereg.h
+++ b/sys/arch/mac68k/dev/if_aereg.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: if_aereg.h,v 1.4 1997/01/24 01:35:32 briggs Exp $ */
-/* $NetBSD: if_aereg.h,v 1.12 1996/01/12 04:53:05 briggs Exp $ */
+/* $OpenBSD: if_aereg.h,v 1.5 1997/03/08 16:16:53 briggs Exp $ */
+/* $NetBSD: if_aereg.h,v 1.14 1997/02/24 07:34:20 scottr Exp $ */
/*
* National Semiconductor DS8390 NIC register definitions.
@@ -26,13 +26,14 @@ struct ae_ring {
/*
* Vendor types
*/
-#define AE_VENDOR_UNKNOWN 0xFF /* Unknown network card */
+#define AE_VENDOR_UNKNOWN 0xff /* Unknown network card */
#define AE_VENDOR_APPLE 0x00 /* Apple Ethernet card */
#define AE_VENDOR_INTERLAN 0x01 /* Interlan A310 card (GatorCard) */
#define AE_VENDOR_DAYNA 0x02 /* DaynaPORT E/30s (and others?) */
#define AE_VENDOR_ASANTE 0x03 /* Asante MacCon II/E */
#define AE_VENDOR_FARALLON 0x04 /* Farallon EtherMac II-TP */
#define AE_VENDOR_FOCUS 0x05 /* FOCUS Enhancements EtherLAN */
+#define AE_VENDOR_KINETICS 0x06 /* Kinetics EtherPort SE/30 */
/*
* Compile-time config flags
@@ -51,14 +52,20 @@ struct ae_ring {
#define GC_RESET_OFFSET 0x000c0000 /* writes here reset NIC */
#define GC_ROM_OFFSET 0x000c0000 /* address prom */
#define GC_DATA_OFFSET 0x000d0000 /* Offset to NIC memory */
-#define GC_NIC_OFFSET 0x000e0000 /* Offset to NIC registers */
+#define GC_REG_OFFSET 0x000e0000 /* Offset to NIC registers */
#define DP_ROM_OFFSET 0x000f0007 /* Offset to MAC address */
#define DP_DATA_OFFSET 0x00000000 /* Offset to NIC memory */
-#define DP_NIC_OFFSET 0x00080000 /* Offset to NIC registers */
+#define DP_REG_OFFSET 0x00080000 /* Offset to NIC registers */
#define AE_ROM_OFFSET 0x000f0000
#define AE_DATA_OFFSET 0x000d0000 /* Offset to NIC memory */
-#define AE_NIC_OFFSET 0x000e0000 /* Offset to NIC registers */
+#define AE_REG_OFFSET 0x000e0000 /* Offset to NIC registers */
#define FE_ROM_OFFSET 0x000d0006 /* Determined empirically */
+
+#define KE_ROM_OFFSET 0x000f0007
+#define KE_DATA_OFFSET 0x00000000 /* Offset to NIC memory */
+#define KE_REG_OFFSET 0x00080003 /* Offset to NIC registers */
+
+#define AE_REG_SIZE 0x40 /* Size of register space */
diff --git a/sys/arch/mac68k/dev/if_aevar.h b/sys/arch/mac68k/dev/if_aevar.h
new file mode 100644
index 00000000000..2edf6c690a1
--- /dev/null
+++ b/sys/arch/mac68k/dev/if_aevar.h
@@ -0,0 +1,74 @@
+/* $NetBSD: if_aevar.h,v 1.5 1997/02/28 08:56:07 scottr Exp $ */
+
+/*
+ * Device driver for National Semiconductor DS8390/WD83C690 based ethernet
+ * adapters.
+ *
+ * Copyright (c) 1994, 1995 Charles M. Hannum. All rights reserved.
+ *
+ * Copyright (C) 1993, David Greenman. This software may be used, modified,
+ * copied, distributed, and sold, in both source and binary form provided that
+ * the above copyright and these terms are retained. Under no circumstances is
+ * the author responsible for the proper functioning of this software, nor does
+ * the author assume any responsibility for damages incurred with its use.
+ *
+ * Adapted for MacBSD by Brad Parker <brad@fcr.com>.
+ */
+
+#define INTERFACE_NAME_LEN 32
+
+/*
+ * ae_softc: per line info and status
+ */
+struct ae_softc {
+ struct device sc_dev;
+ bus_space_tag_t sc_regt; /* NIC register space tag */
+ bus_space_handle_t sc_regh; /* NIC register space handle */
+ bus_space_tag_t sc_buft; /* Buffer space tag */
+ bus_space_handle_t sc_bufh; /* Buffer space handle */
+
+/* struct intrhand sc_ih; */
+
+ struct arpcom sc_arpcom;/* ethernet common */
+ int sc_flags; /* interface flags, from config */
+
+ char type_str[INTERFACE_NAME_LEN]; /* type string */
+ u_short type; /* interface type code */
+ u_char vendor; /* interface vendor */
+ u_char regs_rev; /* registers are reversed */
+ u_char use16bit; /* use word-width transfers */
+
+ u_char cr_proto; /* values always set in CR */
+
+ int mem_size; /* total shared memory size */
+ int mem_ring; /* start of RX ring-buffer (in smem) */
+
+ u_char txb_cnt; /* Number of transmit buffers */
+ u_char txb_inuse; /* number of transmit buffers active */
+
+ u_char txb_new; /* pointer to where new buffer will be added */
+ u_char txb_next_tx; /* pointer to next buffer ready to xmit */
+ u_short txb_len[8]; /* buffered xmit buffer lengths */
+ u_char tx_page_start; /* first page of TX buffer area */
+ u_char rec_page_start; /* first page of RX ring-buffer */
+ u_char rec_page_stop; /* last page of RX ring-buffer */
+ u_char next_packet; /* pointer to next unread RX packet */
+};
+
+int ae_size_card_memory __P((
+ bus_space_tag_t, bus_space_handle_t, int));
+
+int aesetup __P((struct ae_softc *));
+void aeintr __P((void *, int));
+int aeioctl __P((struct ifnet *, u_long, caddr_t));
+void aestart __P((struct ifnet *));
+void aewatchdog __P((struct ifnet *));
+void aereset __P((struct ae_softc *));
+void aeinit __P((struct ae_softc *));
+void aestop __P((struct ae_softc *));
+
+void aeread __P((struct ae_softc *, int, int));
+struct mbuf *aeget __P((struct ae_softc *, int, int));
+
+int ae_put __P((struct ae_softc *, struct mbuf *, int));
+void ae_getmcaf __P((struct arpcom *, u_char *));
diff --git a/sys/arch/mac68k/dev/ite.c b/sys/arch/mac68k/dev/ite.c
index c28c588e50c..58fb71bdf6b 100644
--- a/sys/arch/mac68k/dev/ite.c
+++ b/sys/arch/mac68k/dev/ite.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: ite.c,v 1.9 1997/01/24 01:35:33 briggs Exp $ */
-/* $NetBSD: ite.c,v 1.30 1996/12/18 03:06:06 scottr Exp $ */
+/* $OpenBSD: ite.c,v 1.10 1997/03/08 16:16:54 briggs Exp $ */
+/* $NetBSD: ite.c,v 1.32 1997/02/20 00:23:25 scottr Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -65,10 +65,11 @@
#include <sys/proc.h>
#include <sys/tty.h>
-#include <machine/viareg.h>
+#include <machine/bus.h>
#include <machine/cpu.h>
#include <machine/macinfo.h>
#include <machine/frame.h>
+#include <machine/viareg.h>
#define KEYBOARD_ARRAY
#include <machine/keyboard.h>
@@ -84,7 +85,6 @@
#include "nubus.h"
#include "itevar.h"
#include "grfvar.h"
-#include "ascvar.h"
#include "6x10.h"
#define CHARWIDTH 6
@@ -158,6 +158,11 @@ static char tab_stops[255]; /* tab stops */
static int scrreg_top; /* scroll region */
static int scrreg_bottom;
+/* Console bell parameters */
+static int bell_freq = 1880; /* frequency */
+static int bell_length = 10; /* duration */
+static int bell_volume = 100; /* volume */
+
/* For polled ADB mode */
static int polledkey;
extern int adb_polling;
@@ -513,7 +518,7 @@ putc_normal(ch)
{
switch (ch) {
case '\a': /* Beep */
- asc_ringbell();
+ mac68k_ring_bell(bell_freq, bell_length, bell_volume);
break;
case 127: /* Delete */
case '\b': /* Backspace */
@@ -999,22 +1004,31 @@ iteioctl(dev, cmd, addr, flag, p)
switch (cmd) {
case ITEIOC_RINGBELL:
- {
- asc_ringbell();
- return (0);
- }
+ return mac68k_ring_bell(bell_freq, bell_length, bell_volume);
case ITEIOC_SETBELL:
{
struct bellparams *bp = (void *) addr;
- asc_setbellparams(bp->freq, bp->len, bp->vol);
+ /* Do some sanity checks. */
+ if (bp->freq < 10 || bp->freq > 40000)
+ return (EINVAL);
+ if (bp->len < 0 || bp->len > 3600)
+ return (EINVAL);
+ if (bp->vol < 0 || bp->vol > 100)
+ return (EINVAL);
+
+ bell_freq = bp->freq;
+ bell_length = bp->len;
+ bell_volume = bp->vol;
return (0);
}
case ITEIOC_GETBELL:
{
struct bellparams *bp = (void *) addr;
- asc_getbellparams(&bp->freq, &bp->len, &bp->vol);
+ bell_freq = bp->freq;
+ bell_length = bp->len;
+ bell_volume = bp->vol;
return (0);
}
}
diff --git a/sys/arch/mac68k/dev/mac68k5380.c b/sys/arch/mac68k/dev/mac68k5380.c
index f01b8c90fd9..8876a47f305 100644
--- a/sys/arch/mac68k/dev/mac68k5380.c
+++ b/sys/arch/mac68k/dev/mac68k5380.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: mac68k5380.c,v 1.8 1997/01/24 01:35:33 briggs Exp $ */
-/* $NetBSD: mac68k5380.c,v 1.28 1996/12/19 21:48:17 scottr Exp $ */
+/* $OpenBSD: mac68k5380.c,v 1.9 1997/03/08 16:16:54 briggs Exp $ */
+/* $NetBSD: mac68k5380.c,v 1.29 1997/02/28 15:50:50 scottr Exp $ */
/*
* Copyright (c) 1995 Allen Briggs
@@ -175,8 +175,8 @@ scsi_mach_init(sc)
scsi_flag = Via1Base + VIA2 * 0x2000 + rIFR;
}
- mac68k_register_scsi_irq(ncr5380_irq_intr, sc);
- mac68k_register_scsi_drq(ncr5380_drq_intr, sc);
+ via2_register_irq(VIA2_SCSIIRQ, ncr5380_irq_intr, sc);
+ via2_register_irq(VIA2_SCSIDRQ, ncr5380_drq_intr, sc);
}
static int
diff --git a/sys/arch/mac68k/dev/ncr5380.c b/sys/arch/mac68k/dev/ncr5380.c
index b5aea64f8e7..17430effca8 100644
--- a/sys/arch/mac68k/dev/ncr5380.c
+++ b/sys/arch/mac68k/dev/ncr5380.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ncr5380.c,v 1.13 1997/01/26 18:57:04 briggs Exp $ */
+/* $OpenBSD: ncr5380.c,v 1.14 1997/03/08 16:16:55 briggs Exp $ */
/* $NetBSD: ncr5380.c,v 1.38 1996/12/19 21:48:18 scottr Exp $ */
/*
@@ -198,7 +198,7 @@ extern __inline__ void finish_req(SC_REQ *reqp)
* Auto config stuff....
*/
void ncr_attach __P((struct device *, struct device *, void *));
-int ncr_match __P((struct device *, struct cfdata *, void *));
+int ncr_match __P((struct device *, void *, void *));
/*
* Tricks to make driver-name configurable
@@ -218,10 +218,11 @@ struct cfdriver CFNAME(DRNAME) = {
int
ncr_match(parent, cf, aux)
struct device *parent;
- struct cfdata *cf;
+ void *cf;
void *aux;
{
- return (machine_match(parent, cf, aux, &CFNAME(DRNAME)));
+ return (machine_match(parent,
+ (struct cfdata *) cf, aux, &CFNAME(DRNAME)));
}
void
diff --git a/sys/arch/mac68k/dev/nubus.c b/sys/arch/mac68k/dev/nubus.c
index 84e88fd0df8..68257796977 100644
--- a/sys/arch/mac68k/dev/nubus.c
+++ b/sys/arch/mac68k/dev/nubus.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: nubus.c,v 1.7 1997/01/24 01:35:35 briggs Exp $ */
-/* $NetBSD: nubus.c,v 1.29 1996/12/17 06:47:39 scottr Exp $ */
+/* $OpenBSD: nubus.c,v 1.8 1997/03/08 16:16:56 briggs Exp $ */
+/* $NetBSD: nubus.c,v 1.32 1997/02/28 07:54:02 scottr Exp $ */
/*
* Copyright (c) 1995, 1996 Allen Briggs. All rights reserved.
@@ -42,22 +42,25 @@
#include <vm/vm_map.h>
#include <machine/autoconf.h>
+#include <machine/bus.h>
#include <machine/vmparam.h>
#include <machine/param.h>
#include <machine/cpu.h>
#include <machine/pte.h>
+#include <machine/viareg.h>
#include "nubus.h"
+#define DEBUG
#ifdef DEBUG
-static int nubus_debug = 0x01;
+static int nubus_debug = 0x07;
#define NDB_PROBE 0x1
#define NDB_FOLLOW 0x2
#define NDB_ARITH 0x4
#endif
static int nubus_print __P((void *, const char *));
-static int nubus_match __P((struct device *, struct cfdata *, void *));
+static int nubus_match __P((struct device *, void *, void *));
static void nubus_attach __P((struct device *, struct device *, void *));
int nubus_video_resource __P((int));
@@ -81,9 +84,9 @@ struct cfdriver nubus_cd = {
};
static int
-nubus_match(parent, cf, aux)
+nubus_match(parent, vcf, aux)
struct device *parent;
- struct cfdata *cf;
+ void *vcf;
void *aux;
{
static int nubus_matched = 0;
@@ -142,6 +145,11 @@ nubus_attach(parent, self, aux)
config_found(self, &na_args, nubus_print);
}
+
+ /*
+ * enable nubus interrupts here.
+ */
+ enable_nubus_intr();
}
static int
@@ -219,12 +227,12 @@ probe_slot(slot, fmt)
fmt->bytelanes = 0;
fmt->slot = (u_long)slot;
- rom_probe = (caddr_t) (NUBUS_SLOT_TO_PADDR(fmt->slot) + NBMEMSIZE);
+ rom_probe = (caddr_t) (NUBUS_SLOT2PA(fmt->slot) + NBMEMSIZE);
#ifdef DEBUG
if (nubus_debug & NDB_PROBE) {
pa = pmap_extract(pmap_kernel(), (vm_offset_t) rom_probe - 1);
- printf("probing slot %d, first probe at 0x%x (PA %p).\n",
+ printf("probing slot %d, first probe at %p (PA %lx).\n",
slot, rom_probe - 1, pa);
}
#endif
@@ -233,8 +241,16 @@ probe_slot(slot, fmt)
rom_probe--;
+#ifdef DEBUG
+ if (nubus_debug & NDB_PROBE) {
+ printf("Peeking %p\n", rom_probe);
+ }
+#endif
data = nubus_peek((vm_offset_t) rom_probe, 1);
- if (data == -1)
+
+ printf("data %u\n", data);
+
+ if (data == (u_int) -1)
continue;
if (data == 0)
@@ -270,12 +286,12 @@ probe_slot(slot, fmt)
* to work.
*/
hdr = (vm_offset_t)
- nubus_mapin(NUBUS_SLOT_TO_PADDR(fmt->slot), NBMEMSIZE);
+ nubus_mapin(NUBUS_SLOT2PA(fmt->slot), NBMEMSIZE);
if (hdr == NULL) {
printf("Failed to map %d bytes for NuBUS slot %d probe. ",
NBMEMSIZE, fmt->slot);
printf("Physical slot address %x\n",
- (unsigned int) NUBUS_SLOT_TO_PADDR(fmt->slot));
+ (unsigned int) NUBUS_SLOT2PA(fmt->slot));
}
fmt->virtual_base = hdr;
hdr += NBMEMSIZE;
@@ -289,7 +305,7 @@ probe_slot(slot, fmt)
hdr = IncPtr(fmt, hdr, -hdr_size);
#ifdef DEBUG
if (nubus_debug & NDB_PROBE)
- printf("fmt->top is 0x%p, that minus 0x%x puts us at 0x%p.\n",
+ printf("fmt->top is 0x%lx, that minus 0x%x puts us at 0x%lx.\n",
fmt->top, hdr_size, hdr);
#if 0
for (i=1 ; i < 8 ; i++) {
@@ -697,8 +713,10 @@ nubus_peek(paddr, sz)
rv = -1;
switch (sz) {
case 1:
+ printf("checking badbaddr\n");
if (!badbaddr(va))
rv = *((u_char *) va);
+ printf("got back %d\n", rv);
break;
case 2:
if (!badwaddr(va))
@@ -713,9 +731,12 @@ nubus_peek(paddr, sz)
rv = -1;
}
+printf("setting_pte_back\n");
mac68k_set_pte(pgva, PG_NV);
+printf("TBIS\n");
TBIS(pgva);
+printf("returning %d\n", rv);
return rv;
}
diff --git a/sys/arch/mac68k/dev/nubus.h b/sys/arch/mac68k/dev/nubus.h
index 1e61e6f9ae9..3290eb3ad35 100644
--- a/sys/arch/mac68k/dev/nubus.h
+++ b/sys/arch/mac68k/dev/nubus.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: nubus.h,v 1.6 1997/01/24 01:35:36 briggs Exp $ */
-/* $NetBSD: nubus.h,v 1.15 1996/12/17 03:56:11 scottr Exp $ */
+/* $OpenBSD: nubus.h,v 1.7 1997/03/08 16:16:56 briggs Exp $ */
+/* $NetBSD: nubus.h,v 1.17 1997/02/24 06:20:07 scottr Exp $ */
/*
* Copyright (c) 1995 Allen Briggs. All rights reserved.
@@ -225,10 +225,11 @@ typedef struct _NUBUS_EXEC_BLOCK {
#define NUBUS_MAX_SLOT 0xE
#define NUBUS_ROM_TEST_PATTERN 0x5A932BC7
-#define NUBUS_SLOT_TO_PADDR(x) ( 0xF9000000 + \
- ((((x)-NUBUS_MIN_SLOT) & 0xF) << 24))
+#define NUBUS_SLOT2PA(x) (0xf9000000 + \
+ ((((x) - NUBUS_MIN_SLOT) & 0xf) << 24))
struct nubus_attach_args {
+ bus_space_tag_t na_tag;
int slot;
int rsrcid;
u_int16_t category;
diff --git a/sys/arch/mac68k/dev/obio.c b/sys/arch/mac68k/dev/obio.c
index e4def800b1c..f8ad9d607f6 100644
--- a/sys/arch/mac68k/dev/obio.c
+++ b/sys/arch/mac68k/dev/obio.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: obio.c,v 1.2 1997/01/24 01:35:36 briggs Exp $ */
-/* $NetBSD: obio.c,v 1.5 1996/12/17 06:47:37 scottr Exp $ */
+/* $OpenBSD: obio.c,v 1.3 1997/03/08 16:16:57 briggs Exp $ */
+/* $NetBSD: obio.c,v 1.7 1997/02/13 19:01:07 scottr Exp $ */
/*
* Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -41,6 +41,8 @@
#include <sys/systm.h>
#include <sys/device.h>
+#include <machine/bus.h>
+
#include <mac68k/dev/obiovar.h>
static int obio_match __P((struct device *, struct cfdata *, void *));
@@ -81,7 +83,7 @@ obio_attach(parent, self, aux)
printf("\n");
/* Search for and attach children. */
- (void) config_search(obio_search, self, aux);
+ (void)config_search(obio_search, self, aux);
}
int
@@ -89,10 +91,10 @@ obio_print(args, name)
void *args;
const char *name;
{
- struct obio_attach_args *oa = (struct obio_attach_args *) args;
+ struct obio_attach_args *oa = (struct obio_attach_args *)args;
- if (oa->oa_addr)
- printf(" addr %p", oa->oa_addr);
+ if (oa->oa_addr != (-1))
+ printf(" addr %x", oa->oa_addr);
return (UNCONF);
}
@@ -105,8 +107,13 @@ obio_search(parent, cf, aux)
{
struct obio_attach_args oa;
- bzero(&oa, sizeof(oa));
+ oa.oa_addr = cf->cf_loc[0];
+ oa.oa_drq = cf->cf_loc[1];
+ oa.oa_hsk = cf->cf_loc[2];
+ oa.oa_tag = MAC68K_BUS_SPACE_MEM;
+
if ((*cf->cf_attach->ca_match)(parent, cf, &oa) > 0)
config_attach(parent, cf, &oa, obio_print);
+
return (0);
}
diff --git a/sys/arch/mac68k/dev/obiovar.h b/sys/arch/mac68k/dev/obiovar.h
index 243e33c512e..8b8aea41b20 100644
--- a/sys/arch/mac68k/dev/obiovar.h
+++ b/sys/arch/mac68k/dev/obiovar.h
@@ -1,5 +1,4 @@
-/* $OpenBSD: obiovar.h,v 1.1 1997/01/24 01:35:37 briggs Exp $ */
-/* $NetBSD: obiovar.h,v 1.1 1996/12/17 06:47:38 scottr Exp $ */
+/* $NetBSD: obiovar.h,v 1.3 1997/02/13 19:01:08 scottr Exp $ */
/*
* Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -46,5 +45,8 @@
* Arguments used to attach a device to the internal i/o space.
*/
struct obio_attach_args {
- caddr_t oa_addr; /* physical address */
+ int oa_addr; /* physical address */
+ int oa_drq; /* SCSI DRQ physical address */
+ int oa_hsk; /* SCSI HSK physical address */
+ bus_space_tag_t oa_tag; /* bus space tag */
};
diff --git a/sys/arch/mac68k/dev/sbc.c b/sys/arch/mac68k/dev/sbc.c
index 219a295b1f9..439c4714a2f 100644
--- a/sys/arch/mac68k/dev/sbc.c
+++ b/sys/arch/mac68k/dev/sbc.c
@@ -1,9 +1,8 @@
-/* $OpenBSD: sbc.c,v 1.7 1997/01/24 01:35:37 briggs Exp $ */
-/* $NetBSD: sbc.c,v 1.18 1997/01/20 04:27:49 scottr Exp $ */
+/* $OpenBSD: sbc.c,v 1.8 1997/03/08 16:16:58 briggs Exp $ */
+/* $NetBSD: sbc.c,v 1.22 1997/03/01 20:18:58 scottr Exp $ */
/*
- * Copyright (c) 1996 Scott Reynolds
- * All rights reserved.
+ * Copyright (C) 1996 Scott Reynolds. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -13,16 +12,17 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. The name of the authors may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- * 4. All advertising materials mentioning features or use of this software
- * must display the following acknowledgements:
- * This product includes software developed by Scott Reynolds.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Scott Reynolds for
+ * the NetBSD Project.
+ * 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 AUTHORS ``AS IS'' AND ANY EXPRESS OR
+ * 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 AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * 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
@@ -71,128 +71,15 @@
#include <machine/viareg.h>
#include "sbcreg.h"
+#include "sbcvar.h"
-/*
- * Transfers smaller than this are done using PIO
- * (on assumption they're not worth PDMA overhead)
- */
-#define MIN_DMA_LEN 128
-
-/*
- * Transfers larger than 8192 bytes need to be split up
- * due to the size of the PDMA space.
- */
-#define MAX_DMA_LEN 0x2000
-
-/*
- * From Guide to the Macintosh Family Hardware, pp. 137-143
- * These are offsets from SCSIBase (see pmap_bootstrap.c)
- */
-#define SBC_REG_OFS 0x10000
-#define SBC_DMA_OFS 0x12000
-#define SBC_HSK_OFS 0x06000
-
-#define SBC_DMA_OFS_PB500 0x06000
-
-#define SBC_REG_OFS_IIFX 0x08000 /* Just guessing... */
-#define SBC_DMA_OFS_IIFX 0x0c000
-#define SBC_HSK_OFS_IIFX 0x0e000
-
-#define SBC_REG_OFS_DUO2 0x00000
-#define SBC_DMA_OFS_DUO2 0x02000
-#define SBC_HSK_OFS_DUO2 0x04000
-
-#ifdef SBC_DEBUG
-# define SBC_DB_INTR 0x01
-# define SBC_DB_DMA 0x02
-# define SBC_DB_REG 0x04
-# define SBC_DB_BREAK 0x08
-
- int sbc_debug = 0 /* | SBC_DB_INTR | SBC_DB_DMA */;
- int sbc_link_flags = 0 /* | SDEV_DB2 */;
-
-# ifndef DDB
-# define Debugger() printf("Debug: sbc.c:%d\n", __LINE__)
-# endif
-# define SBC_BREAK \
- do { if (sbc_debug & SBC_DB_BREAK) Debugger(); } while (0)
-#else
-# define SBC_BREAK
-#endif
-
-/*
- * This structure is used to keep track of PDMA requests.
- */
-struct sbc_pdma_handle {
- int dh_flags; /* flags */
-#define SBC_DH_BUSY 0x01 /* This handle is in use */
-#define SBC_DH_OUT 0x02 /* PDMA data out (write) */
-#define SBC_DH_DONE 0x04 /* PDMA transfer is complete */
- u_char *dh_addr; /* data buffer */
- int dh_len; /* length of data buffer */
-};
-
-/*
- * The first structure member has to be the ncr5380_softc
- * so we can just cast to go back and forth between them.
- */
-struct sbc_softc {
- struct ncr5380_softc ncr_sc;
- volatile struct sbc_regs *sc_regs;
- volatile vm_offset_t sc_drq_addr;
- volatile vm_offset_t sc_nodrq_addr;
- volatile u_int8_t *sc_ienable;
- volatile u_int8_t *sc_iflag;
- int sc_options; /* options for this instance. */
- struct sbc_pdma_handle sc_pdma[SCI_OPENINGS];
-};
+int sbc_debug = 0 /* | SBC_DB_INTR | SBC_DB_DMA */;
+int sbc_link_flags = 0 /* | SDEV_DB2 */;
+int sbc_options = SBC_PDMA;
-/*
- * Options. By default, SCSI interrupts and reselect are disabled.
- * You may enable either of these features with the `flags' directive
- * in your kernel's configuration file.
- *
- * Alternatively, you can patch your kernel with DDB or some other
- * mechanism. The sc_options member of the softc is OR'd with
- * the value in sbc_options.
- *
- * The options code is based on the sparc 'si' driver's version of
- * the same.
- */
-#define SBC_PDMA 0x01 /* Use PDMA for polled transfers */
-#define SBC_INTR 0x02 /* Allow SCSI IRQ/DRQ interrupts */
-#define SBC_RESELECT 0x04 /* Allow disconnect/reselect */
-#define SBC_OPTIONS_MASK (SBC_RESELECT|SBC_INTR|SBC_PDMA)
-#define SBC_OPTIONS_BITS "\10\3RESELECT\2INTR\1PDMA"
-int sbc_options = SBC_PDMA;
-
-static int sbc_match __P((struct device *, struct cfdata *, void *));
-static void sbc_attach __P((struct device *, struct device *, void *));
-static int sbc_print __P((void *, const char *));
static void sbc_minphys __P((struct buf *bp));
-static int sbc_wait_busy __P((struct ncr5380_softc *));
-static int sbc_ready __P((struct ncr5380_softc *));
-static int sbc_wait_dreq __P((struct ncr5380_softc *));
-static int sbc_pdma_in __P((struct ncr5380_softc *, int, int, u_char *));
-static int sbc_pdma_out __P((struct ncr5380_softc *, int, int, u_char *));
-#ifdef SBC_DEBUG
-static void decode_5380_intr __P((struct ncr5380_softc *));
-#endif
-
- void sbc_intr_enable __P((struct ncr5380_softc *));
- void sbc_intr_disable __P((struct ncr5380_softc *));
- void sbc_irq_intr __P((void *));
- void sbc_drq_intr __P((void *));
- void sbc_dma_alloc __P((struct ncr5380_softc *));
- void sbc_dma_free __P((struct ncr5380_softc *));
- void sbc_dma_poll __P((struct ncr5380_softc *));
- void sbc_dma_setup __P((struct ncr5380_softc *));
- void sbc_dma_start __P((struct ncr5380_softc *));
- void sbc_dma_eop __P((struct ncr5380_softc *));
- void sbc_dma_stop __P((struct ncr5380_softc *));
-
-static struct scsi_adapter sbc_ops = {
+struct scsi_adapter sbc_ops = {
ncr5380_scsi_cmd, /* scsi_cmd() */
sbc_minphys, /* scsi_minphys() */
NULL, /* open_target_lu() */
@@ -201,189 +88,20 @@ static struct scsi_adapter sbc_ops = {
/* This is copied from julian's bt driver */
/* "so we have a default dev struct for our link struct." */
-static struct scsi_device sbc_dev = {
+struct scsi_device sbc_dev = {
NULL, /* Use default error handler. */
NULL, /* Use default start handler. */
NULL, /* Use default async handler. */
NULL, /* Use default "done" routine. */
};
-struct cfattach sbc_ca = {
- sizeof(struct sbc_softc), sbc_match, sbc_attach
-};
-
struct cfdriver sbc_cd = {
NULL, "sbc", DV_DULL
};
-
-static int
-sbc_match(parent, cf, args)
- struct device *parent;
- struct cfdata *cf;
- void *args;
-{
- switch (current_mac_model->machineid) {
- case MACH_MACIIFX: /* Note: the IIfx isn't (yet) supported. */
- break;
- case MACH_MACPB210:
- case MACH_MACPB230:
- case MACH_MACPB250:
- case MACH_MACPB270:
- case MACH_MACPB280:
- case MACH_MACPB280C:
- if (cf->cf_unit == 1)
- return 1;
- /*FALLTHROUGH*/
- default:
- if (cf->cf_unit == 0 && mac68k_machine.scsi80)
- return 1;
- }
- return 0;
-}
-
-static void
-sbc_attach(parent, self, args)
- struct device *parent, *self;
- void *args;
-{
- struct sbc_softc *sc = (struct sbc_softc *) self;
- struct ncr5380_softc *ncr_sc = (struct ncr5380_softc *) sc;
- char bits[64];
- extern vm_offset_t SCSIBase;
-
- /* Pull in the options flags. */
- sc->sc_options = ((ncr_sc->sc_dev.dv_cfdata->cf_flags | sbc_options)
- & SBC_OPTIONS_MASK);
-
- /*
- * Set up offsets to 5380 registers and GLUE I/O space, and turn
- * off options we know we can't support on certain models.
- */
- switch (current_mac_model->machineid) {
- case MACH_MACIIFX: /* Note: the IIfx isn't (yet) supported. */
- sc->sc_regs = (struct sbc_regs *)(SCSIBase + SBC_REG_OFS_IIFX);
- sc->sc_drq_addr = (vm_offset_t)(SCSIBase + SBC_HSK_OFS_IIFX);
- sc->sc_nodrq_addr = (vm_offset_t)(SCSIBase + SBC_DMA_OFS_IIFX);
- sc->sc_options &= ~(SBC_INTR | SBC_RESELECT);
- break;
- case MACH_MACPB500:
- sc->sc_regs = (struct sbc_regs *)(SCSIBase + SBC_REG_OFS);
- sc->sc_drq_addr = (vm_offset_t)(SCSIBase + SBC_HSK_OFS); /*??*/
- sc->sc_nodrq_addr = (vm_offset_t)(SCSIBase + SBC_DMA_OFS_PB500);
- sc->sc_options &= ~(SBC_INTR | SBC_RESELECT);
- break;
- case MACH_MACPB210:
- case MACH_MACPB230:
- case MACH_MACPB250:
- case MACH_MACPB270:
- case MACH_MACPB280:
- case MACH_MACPB280C:
- if (ncr_sc->sc_dev.dv_unit == 1) {
- sc->sc_regs = (struct sbc_regs *)(0xfee00000 + SBC_REG_OFS_DUO2);
- sc->sc_drq_addr = (vm_offset_t)(0xfee00000 + SBC_HSK_OFS_DUO2);
- sc->sc_nodrq_addr = (vm_offset_t)(0xfee00000 + SBC_DMA_OFS_DUO2);
- break;
- }
- /*FALLTHROUGH*/
- default:
- sc->sc_regs = (struct sbc_regs *)(SCSIBase + SBC_REG_OFS);
- sc->sc_drq_addr = (vm_offset_t)(SCSIBase + SBC_HSK_OFS);
- sc->sc_nodrq_addr = (vm_offset_t)(SCSIBase + SBC_DMA_OFS);
- break;
- }
-
- /*
- * Fill in the prototype scsi_link.
- */
- ncr_sc->sc_link.adapter_softc = sc;
- ncr_sc->sc_link.adapter_target = 7;
- ncr_sc->sc_link.adapter = &sbc_ops;
- ncr_sc->sc_link.device = &sbc_dev;
-
- /*
- * Initialize fields used by the MI code
- */
- ncr_sc->sci_r0 = &sc->sc_regs->sci_pr0.sci_reg;
- ncr_sc->sci_r1 = &sc->sc_regs->sci_pr1.sci_reg;
- ncr_sc->sci_r2 = &sc->sc_regs->sci_pr2.sci_reg;
- ncr_sc->sci_r3 = &sc->sc_regs->sci_pr3.sci_reg;
- ncr_sc->sci_r4 = &sc->sc_regs->sci_pr4.sci_reg;
- ncr_sc->sci_r5 = &sc->sc_regs->sci_pr5.sci_reg;
- ncr_sc->sci_r6 = &sc->sc_regs->sci_pr6.sci_reg;
- ncr_sc->sci_r7 = &sc->sc_regs->sci_pr7.sci_reg;
-
- /*
- * MD function pointers used by the MI code.
- */
- if (sc->sc_options & SBC_PDMA) {
- ncr_sc->sc_pio_out = sbc_pdma_out;
- ncr_sc->sc_pio_in = sbc_pdma_in;
- } else {
- ncr_sc->sc_pio_out = ncr5380_pio_out;
- ncr_sc->sc_pio_in = ncr5380_pio_in;
- }
- ncr_sc->sc_dma_alloc = NULL;
- ncr_sc->sc_dma_free = NULL;
- ncr_sc->sc_dma_poll = NULL;
- ncr_sc->sc_intr_on = NULL;
- ncr_sc->sc_intr_off = NULL;
- ncr_sc->sc_dma_setup = NULL;
- ncr_sc->sc_dma_start = NULL;
- ncr_sc->sc_dma_eop = NULL;
- ncr_sc->sc_dma_stop = NULL;
- ncr_sc->sc_flags = 0;
- ncr_sc->sc_min_dma_len = MIN_DMA_LEN;
-
- if (sc->sc_options & SBC_INTR) {
- if (sc->sc_options & SBC_RESELECT)
- ncr_sc->sc_flags |= NCR5380_PERMIT_RESELECT;
- ncr_sc->sc_dma_alloc = sbc_dma_alloc;
- ncr_sc->sc_dma_free = sbc_dma_free;
- ncr_sc->sc_dma_poll = sbc_dma_poll;
- ncr_sc->sc_dma_setup = sbc_dma_setup;
- ncr_sc->sc_dma_start = sbc_dma_start;
- ncr_sc->sc_dma_eop = sbc_dma_eop;
- ncr_sc->sc_dma_stop = sbc_dma_stop;
- mac68k_register_scsi_drq(sbc_drq_intr, ncr_sc);
- mac68k_register_scsi_irq(sbc_irq_intr, ncr_sc);
- } else
- ncr_sc->sc_flags |= NCR5380_FORCE_POLLING;
-
- /*
- * Initialize fields used only here in the MD code.
- */
- if (VIA2 == VIA2OFF) {
- sc->sc_ienable = Via1Base + VIA2 * 0x2000 + vIER;
- sc->sc_iflag = Via1Base + VIA2 * 0x2000 + vIFR;
- } else {
- sc->sc_ienable = Via1Base + VIA2 * 0x2000 + rIER;
- sc->sc_iflag = Via1Base + VIA2 * 0x2000 + rIFR;
- }
-
- if (sc->sc_options)
- printf(": options=%s", bitmask_snprintf(sc->sc_options,
- SBC_OPTIONS_BITS, bits, sizeof(bits)));
- printf("\n");
-
- /* Now enable SCSI interrupts through VIA2, if appropriate */
- if (sc->sc_options & SBC_INTR)
- sbc_intr_enable(ncr_sc);
-
-#ifdef SBC_DEBUG
- if (sbc_debug)
- printf("%s: softc=%p regs=%p\n", ncr_sc->sc_dev.dv_xname,
- sc, sc->sc_regs);
- ncr_sc->sc_link.flags |= sbc_link_flags;
-#endif
-
- /*
- * Initialize the SCSI controller itself.
- */
- ncr5380_init(ncr_sc);
- ncr5380_reset_scsibus(ncr_sc);
- config_found(self, &(ncr_sc->sc_link), scsiprint);
-}
+static int sbc_wait_busy __P((struct ncr5380_softc *));
+static int sbc_ready __P((struct ncr5380_softc *));
+static int sbc_wait_dreq __P((struct ncr5380_softc *));
static void
sbc_minphys(struct buf *bp)
@@ -464,35 +182,6 @@ sbc_wait_dreq(sc)
return (timo);
}
-
-/***
- * Macintosh SCSI interrupt support routines.
- ***/
-
-void
-sbc_intr_enable(ncr_sc)
- struct ncr5380_softc *ncr_sc;
-{
- register struct sbc_softc *sc = (struct sbc_softc *) ncr_sc;
- int s;
-
- s = splhigh();
- *sc->sc_ienable = 0x80 | (V2IF_SCSIIRQ | V2IF_SCSIDRQ);
- splx(s);
-}
-
-void
-sbc_intr_disable(ncr_sc)
- struct ncr5380_softc *ncr_sc;
-{
- register struct sbc_softc *sc = (struct sbc_softc *) ncr_sc;
- int s;
-
- s = splhigh();
- *sc->sc_ienable = (V2IF_SCSIIRQ | V2IF_SCSIDRQ);
- splx(s);
-}
-
void
sbc_irq_intr(p)
void *p;
@@ -562,7 +251,7 @@ decode_5380_intr(ncr_sc)
* The following code implements polled PDMA.
***/
-static int
+int
sbc_pdma_out(ncr_sc, phase, count, data)
struct ncr5380_softc *ncr_sc;
int phase;
@@ -639,7 +328,7 @@ timeout:
return count - len;
}
-static int
+int
sbc_pdma_in(ncr_sc, phase, count, data)
struct ncr5380_softc *ncr_sc;
int phase;
@@ -1083,14 +772,16 @@ sbc_dma_start(ncr_sc)
if (dh->dh_flags & SBC_DH_OUT) {
*ncr_sc->sci_tcmd = PHASE_DATA_OUT;
SCI_CLR_INTR(ncr_sc);
- *sc->sc_iflag = 0x80 | (V2IF_SCSIIRQ | V2IF_SCSIDRQ);
+ if (sc->sc_clrintr)
+ (*sc->sc_clrintr)(ncr_sc);
*ncr_sc->sci_mode |= SCI_MODE_DMA;
*ncr_sc->sci_icmd = SCI_ICMD_DATA;
*ncr_sc->sci_dma_send = 0;
} else {
*ncr_sc->sci_tcmd = PHASE_DATA_IN;
SCI_CLR_INTR(ncr_sc);
- *sc->sc_iflag = 0x80 | (V2IF_SCSIIRQ | V2IF_SCSIDRQ);
+ if (sc->sc_clrintr)
+ (*sc->sc_clrintr)(ncr_sc);
*ncr_sc->sci_mode |= SCI_MODE_DMA;
*ncr_sc->sci_icmd = 0;
*ncr_sc->sci_irecv = 0;
@@ -1148,7 +839,8 @@ sbc_dma_stop(ncr_sc)
/* Clear any pending interrupts. */
SCI_CLR_INTR(ncr_sc);
- *sc->sc_iflag = 0x80 | V2IF_SCSIIRQ;
+ if (sc->sc_clrintr)
+ (*sc->sc_clrintr)(ncr_sc);
}
/* Put SBIC back into PIO mode. */
diff --git a/sys/arch/mac68k/dev/sbc_obio.c b/sys/arch/mac68k/dev/sbc_obio.c
new file mode 100644
index 00000000000..f15011848c3
--- /dev/null
+++ b/sys/arch/mac68k/dev/sbc_obio.c
@@ -0,0 +1,291 @@
+/* $NetBSD: sbc_obio.c,v 1.1 1997/03/01 20:18:59 scottr Exp $ */
+
+/*
+ * Copyright (C) 1996,1997 Scott Reynolds. 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 Scott Reynolds for
+ * the NetBSD Project.
+ * 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.
+ */
+
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/errno.h>
+#include <sys/device.h>
+#include <sys/buf.h>
+#include <sys/proc.h>
+#include <sys/user.h>
+
+#include <scsi/scsi_all.h>
+#include <scsi/scsi_debug.h>
+#include <scsi/scsiconf.h>
+
+#include <dev/ic/ncr5380reg.h>
+#include <dev/ic/ncr5380var.h>
+
+#include <machine/cpu.h>
+#include <machine/viareg.h>
+
+#include "sbcreg.h"
+#include "sbcvar.h"
+
+/*
+ * From Guide to the Macintosh Family Hardware, pp. 137-143
+ * These are offsets from SCSIBase (see pmap_bootstrap.c)
+ */
+#define SBC_REG_OFS 0x10000
+#define SBC_DMA_OFS 0x12000
+#define SBC_HSK_OFS 0x06000
+
+#define SBC_DMA_OFS_PB500 0x06000
+
+#define SBC_REG_OFS_IIFX 0x08000 /* Just guessing... */
+#define SBC_DMA_OFS_IIFX 0x0c000
+#define SBC_HSK_OFS_IIFX 0x0e000
+
+#define SBC_REG_OFS_DUO2 0x00000
+#define SBC_DMA_OFS_DUO2 0x02000
+#define SBC_HSK_OFS_DUO2 0x04000
+
+static int sbc_obio_match __P((struct device *, void *, void *));
+static void sbc_obio_attach __P((struct device *, struct device *, void *));
+
+void sbc_intr_enable __P((struct ncr5380_softc *));
+void sbc_intr_disable __P((struct ncr5380_softc *));
+void sbc_obio_clrintr __P((struct ncr5380_softc *));
+
+struct cfattach sbc_obio_ca = {
+ sizeof(struct sbc_softc), sbc_obio_match, sbc_obio_attach
+};
+
+static int
+sbc_obio_match(parent, vcf, args)
+ struct device *parent;
+ void *vcf;
+ void *args;
+{
+ struct cfdata *cf = (struct cfdata *) vcf;
+
+ switch (current_mac_model->machineid) {
+ case MACH_MACIIFX: /* Note: the IIfx isn't (yet) supported. */
+ break;
+ case MACH_MACPB210:
+ case MACH_MACPB230:
+ case MACH_MACPB250:
+ case MACH_MACPB270:
+ case MACH_MACPB280:
+ case MACH_MACPB280C:
+ if (cf->cf_unit == 1)
+ return 1;
+ /*FALLTHROUGH*/
+ default:
+ if (cf->cf_unit == 0 && mac68k_machine.scsi80)
+ return 1;
+ }
+ return 0;
+}
+
+static void
+sbc_obio_attach(parent, self, args)
+ struct device *parent, *self;
+ void *args;
+{
+ struct sbc_softc *sc = (struct sbc_softc *) self;
+ struct ncr5380_softc *ncr_sc = (struct ncr5380_softc *) sc;
+ char bits[64];
+ extern vm_offset_t SCSIBase;
+
+ /* Pull in the options flags. */
+ sc->sc_options = ((ncr_sc->sc_dev.dv_cfdata->cf_flags | sbc_options)
+ & SBC_OPTIONS_MASK);
+
+ /*
+ * Set up offsets to 5380 registers and GLUE I/O space, and turn
+ * off options we know we can't support on certain models.
+ */
+ switch (current_mac_model->machineid) {
+ case MACH_MACIIFX: /* Note: the IIfx isn't (yet) supported. */
+ sc->sc_regs = (struct sbc_regs *)(SCSIBase + SBC_REG_OFS_IIFX);
+ sc->sc_drq_addr = (vm_offset_t)(SCSIBase + SBC_HSK_OFS_IIFX);
+ sc->sc_nodrq_addr = (vm_offset_t)(SCSIBase + SBC_DMA_OFS_IIFX);
+ sc->sc_options &= ~(SBC_INTR | SBC_RESELECT);
+ break;
+ case MACH_MACPB500:
+ sc->sc_regs = (struct sbc_regs *)(SCSIBase + SBC_REG_OFS);
+ sc->sc_drq_addr = (vm_offset_t)(SCSIBase + SBC_HSK_OFS); /*??*/
+ sc->sc_nodrq_addr = (vm_offset_t)(SCSIBase + SBC_DMA_OFS_PB500);
+ sc->sc_options &= ~(SBC_INTR | SBC_RESELECT);
+ break;
+ case MACH_MACPB210:
+ case MACH_MACPB230:
+ case MACH_MACPB250:
+ case MACH_MACPB270:
+ case MACH_MACPB280:
+ case MACH_MACPB280C:
+ if (ncr_sc->sc_dev.dv_unit == 1) {
+ sc->sc_regs = (struct sbc_regs *)(0xfee00000 + SBC_REG_OFS_DUO2);
+ sc->sc_drq_addr = (vm_offset_t)(0xfee00000 + SBC_HSK_OFS_DUO2);
+ sc->sc_nodrq_addr = (vm_offset_t)(0xfee00000 + SBC_DMA_OFS_DUO2);
+ break;
+ }
+ /*FALLTHROUGH*/
+ default:
+ sc->sc_regs = (struct sbc_regs *)(SCSIBase + SBC_REG_OFS);
+ sc->sc_drq_addr = (vm_offset_t)(SCSIBase + SBC_HSK_OFS);
+ sc->sc_nodrq_addr = (vm_offset_t)(SCSIBase + SBC_DMA_OFS);
+ break;
+ }
+
+ /*
+ * Fill in the prototype scsi_link.
+ */
+ ncr_sc->sc_link.channel = SCSI_CHANNEL_ONLY_ONE;
+ ncr_sc->sc_link.adapter_softc = sc;
+ ncr_sc->sc_link.adapter_target = 7;
+ ncr_sc->sc_link.adapter = &sbc_ops;
+ ncr_sc->sc_link.device = &sbc_dev;
+ ncr_sc->sc_link.max_target = 7;
+
+ /*
+ * Initialize fields used by the MI code
+ */
+ ncr_sc->sci_r0 = &sc->sc_regs->sci_pr0.sci_reg;
+ ncr_sc->sci_r1 = &sc->sc_regs->sci_pr1.sci_reg;
+ ncr_sc->sci_r2 = &sc->sc_regs->sci_pr2.sci_reg;
+ ncr_sc->sci_r3 = &sc->sc_regs->sci_pr3.sci_reg;
+ ncr_sc->sci_r4 = &sc->sc_regs->sci_pr4.sci_reg;
+ ncr_sc->sci_r5 = &sc->sc_regs->sci_pr5.sci_reg;
+ ncr_sc->sci_r6 = &sc->sc_regs->sci_pr6.sci_reg;
+ ncr_sc->sci_r7 = &sc->sc_regs->sci_pr7.sci_reg;
+
+ /*
+ * MD function pointers used by the MI code.
+ */
+ if (sc->sc_options & SBC_PDMA) {
+ ncr_sc->sc_pio_out = sbc_pdma_out;
+ ncr_sc->sc_pio_in = sbc_pdma_in;
+ } else {
+ ncr_sc->sc_pio_out = ncr5380_pio_out;
+ ncr_sc->sc_pio_in = ncr5380_pio_in;
+ }
+ ncr_sc->sc_dma_alloc = NULL;
+ ncr_sc->sc_dma_free = NULL;
+ ncr_sc->sc_dma_poll = NULL;
+ ncr_sc->sc_intr_on = NULL;
+ ncr_sc->sc_intr_off = NULL;
+ ncr_sc->sc_dma_setup = NULL;
+ ncr_sc->sc_dma_start = NULL;
+ ncr_sc->sc_dma_eop = NULL;
+ ncr_sc->sc_dma_stop = NULL;
+ ncr_sc->sc_flags = 0;
+ ncr_sc->sc_min_dma_len = MIN_DMA_LEN;
+
+ if (sc->sc_options & SBC_INTR) {
+ ncr_sc->sc_dma_alloc = sbc_dma_alloc;
+ ncr_sc->sc_dma_free = sbc_dma_free;
+ ncr_sc->sc_dma_poll = sbc_dma_poll;
+ ncr_sc->sc_dma_setup = sbc_dma_setup;
+ ncr_sc->sc_dma_start = sbc_dma_start;
+ ncr_sc->sc_dma_eop = sbc_dma_eop;
+ ncr_sc->sc_dma_stop = sbc_dma_stop;
+ via2_register_irq(VIA2_SCSIDRQ, sbc_drq_intr, ncr_sc);
+ via2_register_irq(VIA2_SCSIIRQ, sbc_irq_intr, ncr_sc);
+ } else
+ ncr_sc->sc_flags |= NCR5380_FORCE_POLLING;
+
+ if ((sc->sc_options & SBC_RESELECT) == 0)
+ ncr_sc->sc_no_disconnect = 0xff;
+
+ if (sc->sc_options & SBC_INTR)
+ sc->sc_clrintr = sbc_obio_clrintr;
+ else
+ sc->sc_clrintr = NULL;
+
+ if (sc->sc_options)
+ printf(": options=%s", bitmask_snprintf(sc->sc_options,
+ SBC_OPTIONS_BITS, bits, sizeof(bits)));
+ printf("\n");
+
+ /* Now enable SCSI interrupts through VIA2, if appropriate */
+ if (sc->sc_options & SBC_INTR)
+ sbc_intr_enable(ncr_sc);
+
+#ifdef SBC_DEBUG
+ if (sbc_debug)
+ printf("%s: softc=%p regs=%p\n", ncr_sc->sc_dev.dv_xname,
+ sc, sc->sc_regs);
+ ncr_sc->sc_link.flags |= sbc_link_flags;
+#endif
+
+ /*
+ * Initialize the SCSI controller itself.
+ */
+ ncr5380_init(ncr_sc);
+ ncr5380_reset_scsibus(ncr_sc);
+ config_found(self, &(ncr_sc->sc_link), scsiprint);
+}
+
+/*
+ * Interrupt support routines.
+ */
+void
+sbc_intr_enable(ncr_sc)
+ struct ncr5380_softc *ncr_sc;
+{
+ int s;
+
+ s = splhigh();
+ if (VIA2 == VIA2OFF)
+ via2_reg(vIER) = 0x80 | (V2IF_SCSIIRQ | V2IF_SCSIDRQ);
+ else
+ via2_reg(rIER) = 0x80 | (V2IF_SCSIIRQ | V2IF_SCSIDRQ);
+ splx(s);
+}
+
+void
+sbc_intr_disable(ncr_sc)
+ struct ncr5380_softc *ncr_sc;
+{
+ int s;
+
+ s = splhigh();
+ if (VIA2 == VIA2OFF)
+ via2_reg(vIER) = (V2IF_SCSIIRQ | V2IF_SCSIDRQ);
+ else
+ via2_reg(rIER) = (V2IF_SCSIIRQ | V2IF_SCSIDRQ);
+ splx(s);
+}
+
+void
+sbc_obio_clrintr(ncr_sc)
+ struct ncr5380_softc *ncr_sc;
+{
+ if (VIA2 == VIA2OFF)
+ via2_reg(vIFR) = 0x80 | (V2IF_SCSIIRQ | V2IF_SCSIDRQ);
+ else
+ via2_reg(rIFR) = 0x80 | (V2IF_SCSIIRQ | V2IF_SCSIDRQ);
+}
diff --git a/sys/arch/mac68k/dev/sbcreg.h b/sys/arch/mac68k/dev/sbcreg.h
index 6daf826b440..df384b7f836 100644
--- a/sys/arch/mac68k/dev/sbcreg.h
+++ b/sys/arch/mac68k/dev/sbcreg.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: sbcreg.h,v 1.1 1996/05/26 19:02:10 briggs Exp $ */
-/* $NetBSD: sbcreg.h,v 1.1 1996/04/25 22:26:56 scottr Exp $ */
+/* $OpenBSD: sbcreg.h,v 1.2 1997/03/08 16:16:59 briggs Exp $ */
+/* $NetBSD: sbcreg.h,v 1.2 1997/03/01 20:18:59 scottr Exp $ */
/*
* Register map for the Mac II SCSI Interface (sbc)
diff --git a/sys/arch/mac68k/dev/sbcvar.h b/sys/arch/mac68k/dev/sbcvar.h
new file mode 100644
index 00000000000..e6ebe9b0ce1
--- /dev/null
+++ b/sys/arch/mac68k/dev/sbcvar.h
@@ -0,0 +1,122 @@
+/* $NetBSD: sbcvar.h,v 1.1 1997/03/01 20:19:00 scottr Exp $ */
+
+/*
+ * Copyright (C) 1996 Scott Reynolds. 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 Scott Reynolds for
+ * the NetBSD Project.
+ * 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.
+ */
+
+/*
+ * Transfers smaller than this are done using PIO
+ * (on assumption they're not worth PDMA overhead)
+ */
+#define MIN_DMA_LEN 128
+
+/*
+ * Transfers larger than 8192 bytes need to be split up
+ * due to the size of the PDMA space.
+ */
+#define MAX_DMA_LEN 0x2000
+
+#ifdef SBC_DEBUG
+# define SBC_DB_INTR 0x01
+# define SBC_DB_DMA 0x02
+# define SBC_DB_REG 0x04
+# define SBC_DB_BREAK 0x08
+# ifndef DDB
+# define Debugger() printf("Debug: sbc.c:%d\n", __LINE__)
+# endif
+# define SBC_BREAK \
+ do { if (sbc_debug & SBC_DB_BREAK) Debugger(); } while (0)
+#else
+# define SBC_BREAK
+#endif
+
+/*
+ * This structure is used to keep track of PDMA requests.
+ */
+struct sbc_pdma_handle {
+ int dh_flags; /* flags */
+#define SBC_DH_BUSY 0x01 /* This handle is in use */
+#define SBC_DH_OUT 0x02 /* PDMA data out (write) */
+#define SBC_DH_DONE 0x04 /* PDMA transfer is complete */
+ u_char *dh_addr; /* data buffer */
+ int dh_len; /* length of data buffer */
+};
+
+/*
+ * The first structure member has to be the ncr5380_softc
+ * so we can just cast to go back and forth between them.
+ */
+struct sbc_softc {
+ struct ncr5380_softc ncr_sc;
+ volatile struct sbc_regs *sc_regs;
+ volatile vm_offset_t sc_drq_addr;
+ volatile vm_offset_t sc_nodrq_addr;
+ void (*sc_clrintr) __P((struct ncr5380_softc *));
+ int sc_options; /* options for this instance. */
+ struct sbc_pdma_handle sc_pdma[SCI_OPENINGS];
+};
+
+/*
+ * Options. By default, SCSI interrupts and reselect are disabled.
+ * You may enable either of these features with the `flags' directive
+ * in your kernel's configuration file.
+ *
+ * Alternatively, you can patch your kernel with DDB or some other
+ * mechanism. The sc_options member of the softc is OR'd with
+ * the value in sbc_options.
+ *
+ * The options code is based on the sparc 'si' driver's version of
+ * the same.
+ */
+#define SBC_PDMA 0x01 /* Use PDMA for polled transfers */
+#define SBC_INTR 0x02 /* Allow SCSI IRQ/DRQ interrupts */
+#define SBC_RESELECT 0x04 /* Allow disconnect/reselect */
+#define SBC_OPTIONS_MASK (SBC_RESELECT|SBC_INTR|SBC_PDMA)
+#define SBC_OPTIONS_BITS "\10\3RESELECT\2INTR\1PDMA"
+
+extern int sbc_debug;
+extern int sbc_link_flags;
+extern int sbc_options;
+extern struct scsi_adapter sbc_ops;
+extern struct scsi_device sbc_dev;
+
+int sbc_pdma_in __P((struct ncr5380_softc *, int, int, u_char *));
+int sbc_pdma_out __P((struct ncr5380_softc *, int, int, u_char *));
+void sbc_irq_intr __P((void *));
+void sbc_drq_intr __P((void *));
+void sbc_dma_alloc __P((struct ncr5380_softc *));
+void sbc_dma_free __P((struct ncr5380_softc *));
+void sbc_dma_poll __P((struct ncr5380_softc *));
+void sbc_dma_setup __P((struct ncr5380_softc *));
+void sbc_dma_start __P((struct ncr5380_softc *));
+void sbc_dma_eop __P((struct ncr5380_softc *));
+void sbc_dma_stop __P((struct ncr5380_softc *));
+#ifdef SBC_DEBUG
+void decode_5380_intr __P((struct ncr5380_softc *));
+#endif
diff --git a/sys/arch/mac68k/include/cpu.h b/sys/arch/mac68k/include/cpu.h
index bf16662a8f3..636c0788a7b 100644
--- a/sys/arch/mac68k/include/cpu.h
+++ b/sys/arch/mac68k/include/cpu.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: cpu.h,v 1.13 1997/01/24 01:35:40 briggs Exp $ */
-/* $NetBSD: cpu.h,v 1.44 1997/01/20 05:08:00 scottr Exp $ */
+/* $OpenBSD: cpu.h,v 1.14 1997/03/08 16:17:00 briggs Exp $ */
+/* $NetBSD: cpu.h,v 1.45 1997/02/10 22:13:40 scottr Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -180,7 +180,9 @@ extern volatile u_int8_t ssir;
__BEGIN_DECLS
/* machdep.c */
-u_int get_mapping __P((void));
+void mac68k_set_bell_callback __P((int (*)(void *, int, int, int), void *));
+int mac68k_ring_bell __P((int, int, int));
+u_int get_mapping __P((void));
/* locore.s */
void m68881_restore __P((struct fpframe *));
diff --git a/sys/arch/mac68k/include/param.h b/sys/arch/mac68k/include/param.h
index a9fed796565..06b9d6b78c0 100644
--- a/sys/arch/mac68k/include/param.h
+++ b/sys/arch/mac68k/include/param.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: param.h,v 1.5 1996/05/26 18:35:56 briggs Exp $ */
-/* $NetBSD: param.h,v 1.26 1996/05/05 06:17:49 briggs Exp $ */
+/* $OpenBSD: param.h,v 1.6 1997/03/08 16:17:00 briggs Exp $ */
+/* $NetBSD: param.h,v 1.28 1997/03/01 06:57:45 scottr Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -97,9 +97,16 @@
* Round p (pointer or byte index) up to a correctly-aligned value
* for all data types (int, long, ...). The result is u_int and
* must be cast to any desired pointer type.
+ *
+ * ALIGNED_POINTER is a boolean macro that checks whether an address
+ * is valid to fetch data elements of type t from on this architecture.
+ * This does not reflect the optimal alignment, just the possibility
+ * (within reasonable limits).
+ *
*/
-#define ALIGNBYTES (sizeof(int) - 1)
-#define ALIGN(p) (((u_int)(p) + ALIGNBYTES) &~ ALIGNBYTES)
+#define ALIGNBYTES (sizeof(int) - 1)
+#define ALIGN(p) (((u_int)(p) + ALIGNBYTES) &~ ALIGNBYTES)
+#define ALIGNED_POINTER(p,t) ((((u_long)(p)) & (sizeof(t)-1)) == 0)
#define PGSHIFT 12 /* LOG2(NBPG) */
#define NBPG (1 << PGSHIFT) /* bytes/page */
@@ -135,7 +142,9 @@
* of the hardware page size.
*/
#define MSIZE 128 /* size of an mbuf */
+#ifndef MCLSHIFT
#define MCLSHIFT 11 /* convert bytes to m_buf clusters */
+#endif /* MCLSHIFT */
#define MCLBYTES (1 << MCLSHIFT) /* size of an m_buf cluster */
#define MCLOFSET (MCLBYTES - 1) /* offset within an m_buf cluster */
diff --git a/sys/arch/mac68k/include/pmap.h b/sys/arch/mac68k/include/pmap.h
index 0b016d57c32..65ce48fa6e3 100644
--- a/sys/arch/mac68k/include/pmap.h
+++ b/sys/arch/mac68k/include/pmap.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: pmap.h,v 1.4 1997/02/18 05:13:13 gene Exp $ */
-/* $NetBSD: pmap.h,v 1.13 1996/05/18 18:52:41 briggs Exp $ */
+/* $OpenBSD: pmap.h,v 1.5 1997/03/08 16:17:01 briggs Exp $ */
+/* $NetBSD: pmap.h,v 1.14 1997/02/02 18:19:55 scottr Exp $ */
/*
* Copyright (c) 1987 Carnegie-Mellon University
@@ -211,7 +211,6 @@ void TBIA __P((void));
void TBIS __P((vm_offset_t));
void DCFP __P((vm_offset_t));
void ICPP __P((vm_offset_t));
-void copypage __P((void *, void *));
__END_DECLS
#endif /* _KERNEL */
diff --git a/sys/arch/mac68k/include/viareg.h b/sys/arch/mac68k/include/viareg.h
index 0883aa36d26..fbfc255854c 100644
--- a/sys/arch/mac68k/include/viareg.h
+++ b/sys/arch/mac68k/include/viareg.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: viareg.h,v 1.5 1997/01/24 01:35:41 briggs Exp $ */
-/* $NetBSD: viareg.h,v 1.5 1996/10/29 05:42:16 briggs Exp $ */
+/* $OpenBSD: viareg.h,v 1.6 1997/03/08 16:17:01 briggs Exp $ */
+/* $NetBSD: viareg.h,v 1.6 1997/02/28 07:41:41 scottr Exp $ */
/*-
* Copyright (C) 1993 Allen K. Briggs, Chris P. Caputo,
@@ -90,25 +90,47 @@
#define DB2O_vCDis 0x01
#define DB2O_CEnable 0x01
- /* VIA1 interrupt bits */
+/*
+ * VIA1 interrupts
+ */
+#define VIA1_T1 6
+#define VIA1_T2 5
+#define VIA1_ADBCLK 4
+#define VIA1_ADBDATA 3
+#define VIA1_ADBRDY 2
+#define VIA1_VBLNK 1
+#define VIA1_ONESEC 0
+
+/* VIA1 interrupt bits */
#define V1IF_IRQ 0x80
-#define V1IF_T1 0x40
-#define V1IF_T2 0x20
-#define V1IF_ADBCLK 0x10
-#define V1IF_ADBDATA 0x08
-#define V1IF_ADBRDY 0x04
-#define V1IF_VBLNK 0x02
-#define V1IF_ONESEC 0x01
-
- /* VIA2 interrupt bits */
-#define V2IF_IRQ 0x80
-#define V2IF_T1 0x40
-#define V2IF_T2 0x20
-#define V2IF_ASC 0x10
-#define V2IF_SCSIIRQ 0x08
-#define V2IF_EXPIRQ 0x04
-#define V2IF_SLOTINT 0x02
-#define V2IF_SCSIDRQ 0x01
+#define V1IF_T1 (1 << VIA1_T1)
+#define V1IF_T2 (1 << VIA1_T2)
+#define V1IF_ADBCLK (1 << VIA1_ADBCLK)
+#define V1IF_ADBDATA (1 << VIA1_ADBDATA)
+#define V1IF_ADBRDY (1 << VIA1_ADBRDY)
+#define V1IF_VBLNK (1 << VIA1_VBLNK)
+#define V1IF_ONESEC (1 << VIA1_ONESEC)
+
+/*
+ * VIA2 interrupts
+ */
+#define VIA2_T1 6
+#define VIA2_T2 5
+#define VIA2_ASC 4
+#define VIA2_SCSIIRQ 3
+#define VIA2_EXPIRQ 2
+#define VIA2_SLOTINT 1
+#define VIA2_SCSIDRQ 0
+
+/* VIA2 interrupt bits */
+#define V2IF_IRQ 0x80
+#define V2IF_T1 (1 << VIA2_T1)
+#define V2IF_T2 (1 << VIA2_T2)
+#define V2IF_ASC (1 << VIA2_ASC)
+#define V2IF_SCSIIRQ (1 << VIA2_SCSIIRQ)
+#define V2IF_EXPIRQ (1 << VIA2_EXPIRQ)
+#define V2IF_SLOTINT (1 << VIA2_SLOTINT)
+#define V2IF_SCSIDRQ (1 << VIA2_SCSIDRQ)
#define VIA1_INTS (V1IF_T1 | V1IF_ADBRDY)
#define VIA2_INTS (V2IF_T1 | V2IF_ASC | V2IF_SCSIIRQ | V2IF_SLOTINT | \
@@ -175,10 +197,8 @@ void via_shutdown __P((void));
void via_set_modem __P((int));
int add_nubus_intr __P((int, void (*) __P((void *, int)), void *));
void enable_nubus_intr __P((void));
-void mac68k_register_scsi_irq __P((void (*)(void *), void *clnt));
-void mac68k_register_scsi_b_irq __P((void (*)(void *), void *clnt));
-void mac68k_register_scsi_drq __P((void (*)(void *), void *clnt));
-void mac68k_register_via1_t1_irq __P((void (*)(void *)));
+void via1_register_irq __P((int, void (*)(void *), void *));
+void via2_register_irq __P((int, void (*)(void *), void *));
extern void (*via1itab[7]) __P((void *));
extern void (*via2itab[7]) __P((void *));
diff --git a/sys/arch/mac68k/mac68k/clock.c b/sys/arch/mac68k/mac68k/clock.c
index a7e9344fe94..10a03ed4d2d 100644
--- a/sys/arch/mac68k/mac68k/clock.c
+++ b/sys/arch/mac68k/mac68k/clock.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: clock.c,v 1.9 1997/02/26 06:17:00 gene Exp $ */
-/* $NetBSD: clock.c,v 1.32 1997/01/15 01:28:53 perry Exp $ */
+/* $OpenBSD: clock.c,v 1.10 1997/03/08 16:17:02 briggs Exp $ */
+/* $NetBSD: clock.c,v 1.33 1997/02/28 07:49:19 scottr Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -96,6 +96,8 @@
#include "clockreg.h"
#include <machine/viareg.h>
+void rtclock_intr __P((void));
+
#define DIFF19041970 2082844800
#define DIFF19701990 630720000
#define DIFF19702010 1261440000
@@ -482,7 +484,7 @@ mac68k_calibrate_delay()
/* Disable VIA1 timer 1 interrupts and set up service routine */
via_reg(VIA1, vIER) = V1IF_T1;
- mac68k_register_via1_t1_irq(delay_timer1_irq);
+ via1_register_irq(VIA1_T1, delay_timer1_irq, NULL);
/* Set the timer for one-shot mode, then clear and enable interrupts */
via_reg(VIA1, vACR) &= ~ACR_T1LATCH;
@@ -498,7 +500,7 @@ mac68k_calibrate_delay()
/* Disable timer interrupts and reset service routine */
via_reg(VIA1, vIER) = V1IF_T1;
- mac68k_register_via1_t1_irq(NULL);
+ via1_register_irq(VIA1_T1, (void (*)(void *))rtclock_intr, NULL);
/*
* If this weren't integer math, the following would look
diff --git a/sys/arch/mac68k/mac68k/conf.c b/sys/arch/mac68k/mac68k/conf.c
index f2317f54765..a5e96f93580 100644
--- a/sys/arch/mac68k/mac68k/conf.c
+++ b/sys/arch/mac68k/mac68k/conf.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: conf.c,v 1.14 1997/01/24 01:35:45 briggs Exp $ */
-/* $NetBSD: conf.c,v 1.34 1996/06/19 02:20:54 briggs Exp $ */
+/* $OpenBSD: conf.c,v 1.15 1997/03/08 16:17:02 briggs Exp $ */
+/* $NetBSD: conf.c,v 1.41 1997/02/11 07:35:49 scottr Exp $ */
/*
* Copyright (c) 1990 The Regents of the University of California.
@@ -85,13 +85,6 @@ struct bdevsw bdevsw[] =
};
int nblkdev = sizeof(bdevsw) / sizeof(bdevsw[0]);
-/* open, close, ioctl, select, mmap -- XXX should be a map device */
-#define cdev_grf_init(c,n) { \
- dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) nullop, \
- (dev_type_write((*))) nullop, dev_init(c,n,ioctl), \
- (dev_type_stop((*))) enodev, 0, dev_init(c,n,select), \
- dev_init(c,n,mmap) }
-
#include "ite.h"
cdev_decl(ite);
#define mmread mmrw
@@ -117,6 +110,8 @@ cdev_decl(ch);
#include "bpfilter.h"
#include "tun.h"
dev_decl(filedesc,open);
+#include "asc.h"
+cdev_decl(asc);
/* open, close, read, ioctl */
cdev_decl(ipl);
@@ -138,7 +133,7 @@ struct cdevsw cdevsw[] =
cdev_notdef(), /* 7 */
cdev_notdef(), /* 8 */
cdev_notdef(), /* 9 */
- cdev_grf_init(1,grf), /* 10: frame buffer */
+ cdev_fb_init(NGRF,grf), /* 10: frame buffer */
cdev_tty_init(NITE,ite), /* 11: console terminal emulator */
cdev_tty_init(NZSTTY,zs), /* 12: 2 mac serial ports -- BG*/
cdev_disk_init(NSD,sd), /* 13: SCSI disk */
@@ -164,6 +159,7 @@ struct cdevsw cdevsw[] =
cdev_ss_init(NSS,ss), /* 33: SCSI scanner */
cdev_uk_init(NUK,uk), /* 34: SCSI unknown */
cdev_gen_ipf(NIPF,ipl), /* 35: IP filter log */
+ cdev_audio_init(NASC,asc), /* 36: ASC audio device */
};
int nchrdev = sizeof(cdevsw) / sizeof(cdevsw[0]);
diff --git a/sys/arch/mac68k/mac68k/locore.s b/sys/arch/mac68k/mac68k/locore.s
index cd096a8d69f..9349af87823 100644
--- a/sys/arch/mac68k/mac68k/locore.s
+++ b/sys/arch/mac68k/mac68k/locore.s
@@ -1,5 +1,5 @@
-/* $OpenBSD: locore.s,v 1.18 1997/02/21 05:49:28 briggs Exp $ */
-/* $NetBSD: locore.s,v 1.73 1997/01/09 07:28:12 scottr Exp $ */
+/* $OpenBSD: locore.s,v 1.19 1997/03/08 16:17:03 briggs Exp $ */
+/* $NetBSD: locore.s,v 1.74 1997/02/02 08:17:46 thorpej Exp $ */
/*
* Copyright (c) 1988 University of Utah.
diff --git a/sys/arch/mac68k/mac68k/machdep.c b/sys/arch/mac68k/mac68k/machdep.c
index c89f8905be2..4557f78e005 100644
--- a/sys/arch/mac68k/mac68k/machdep.c
+++ b/sys/arch/mac68k/mac68k/machdep.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: machdep.c,v 1.30 1997/02/26 06:17:02 gene Exp $ */
-/* $NetBSD: machdep.c,v 1.129 1997/01/09 07:20:46 scottr Exp $ */
+/* $OpenBSD: machdep.c,v 1.31 1997/03/08 16:17:04 briggs Exp $ */
+/* $NetBSD: machdep.c,v 1.134 1997/02/14 06:15:30 scottr Exp $ */
/*
* Copyright (c) 1996 Jason R. Thorpe. All rights reserved.
@@ -96,8 +96,9 @@
#include <sys/mbuf.h>
#include <sys/msgbuf.h>
#include <sys/user.h>
-#include <sys/sysctl.h>
#include <sys/mount.h>
+#include <sys/extent.h>
+#include <sys/sysctl.h>
#include <sys/syscallargs.h>
#include <sys/extent.h>
#ifdef SYSVMSG
@@ -173,6 +174,10 @@ u_int32_t mac68k_vidlog; /* logical addr */
u_int32_t mac68k_vidphys; /* physical addr */
u_int32_t mac68k_vidlen; /* mem length */
+/* Callback and cookie to run bell */
+int (*mac68k_bell_callback) __P((void *, int, int, int));
+caddr_t mac68k_bell_cookie;
+
vm_map_t buffer_map;
/*
@@ -220,10 +225,26 @@ void dumpsys __P((void));
int bus_mem_add_mapping __P((bus_addr_t, bus_size_t,
int, bus_space_handle_t *));
+/*
+ * Extent maps to manage all memory space, including I/O ranges. Allocate
+ * storage for 8 regions in each, initially. Later, iomem_malloc_safe
+ * will indicate that it's safe to use malloc() to dynamically allocate
+ * region descriptors.
+ *
+ * The extent maps are not static! Machine-dependent NuBus and on-board
+ * I/O routines need access to them for bus address space allocation.
+ */
+static long iomem_ex_storage[EXTENT_FIXED_STORAGE_SIZE(8) / sizeof(long)];
+struct extent *iomem_ex;
+static iomem_malloc_safe;
+
static void identifycpu __P((void));
static u_long get_physical __P((u_int, u_long *));
void dumpsys __P((void));
+int bus_mem_add_mapping __P((bus_addr_t, bus_size_t,
+ int, bus_space_handle_t *));
+
/*
* Console initialization: called early on from main,
* before vm init or startup. Do enough configuration
@@ -468,6 +489,7 @@ again:
printf("kernel does not support -c; continuing..\n");
#endif
}
+ iomem_malloc_safe = 1;
configure();
}
@@ -1496,13 +1518,11 @@ getenvvars(flag, buf)
/*
* For now, we assume that the boot device is off the first controller.
*/
- if (bootdev == 0) {
- bootdev = (root_scsi_id << 16) | 4;
- }
+ if (bootdev == 0)
+ bootdev = MAKEBOOTDEV(4, 0, 0, root_scsi_id, 0);
- if (boothowto == 0) {
+ if (boothowto == 0)
boothowto = getenv("SINGLE_USER");
- }
/* These next two should give us mapped video & serial */
/* We need these for pre-mapping graybars & echo, but probably */
@@ -2562,7 +2582,6 @@ mac68k_set_io_offsets(base)
vm_offset_t base;
{
extern volatile u_char *sccA;
- extern volatile u_char *ASCBase;
/*
* Initialize the I/O mem extent map.
@@ -2582,7 +2601,6 @@ mac68k_set_io_offsets(base)
case MACH_CLASSQ:
Via1Base = (volatile u_char *) base;
sccA = (volatile u_char *) base + 0xc000;
- ASCBase = (volatile u_char *) base + 0x14000;
switch (current_mac_model->machineid) {
case MACH_MACQ900:
case MACH_MACQ950:
@@ -2602,13 +2620,11 @@ mac68k_set_io_offsets(base)
*/
Via1Base = (volatile u_char *) base;
sccA = (volatile u_char *) base + 0xc020;
- ASCBase = (volatile u_char *) base + 0x14000;
SCSIBase = base + 0x10000;
break;
case MACH_CLASSAV:
Via1Base = (volatile u_char *) base;
sccA = (volatile u_char *) base + 0x4000;
- ASCBase = (volatile u_char *) base + 0x14000;
SCSIBase = base + 0x18000;
break;
case MACH_CLASSII:
@@ -2619,7 +2635,6 @@ mac68k_set_io_offsets(base)
case MACH_CLASSLC:
Via1Base = (volatile u_char *) base;
sccA = (volatile u_char *) base + 0x4000;
- ASCBase = (volatile u_char *) base + 0x14000;
SCSIBase = base;
break;
default:
@@ -2956,6 +2971,32 @@ printstar(void)
}
/*
+ * Console bell callback; modularizes the console terminal emulator
+ * and the audio system, so neither requires direct knowledge of the
+ * other.
+ */
+
+void
+mac68k_set_bell_callback(callback, cookie)
+ int (*callback) __P((void *, int, int, int));
+ void *cookie;
+{
+ mac68k_bell_callback = callback;
+ mac68k_bell_cookie = (caddr_t) cookie;
+}
+
+int
+mac68k_ring_bell(freq, length, volume)
+ int freq, length, volume;
+{
+ if (mac68k_bell_callback)
+ return ((*mac68k_bell_callback)(mac68k_bell_cookie,
+ freq, length, volume));
+ else
+ return (ENXIO);
+}
+
+/*
* bus.h implementation
*/
diff --git a/sys/arch/mac68k/mac68k/macrom.c b/sys/arch/mac68k/mac68k/macrom.c
index bfef792ef48..51e055be4b2 100644
--- a/sys/arch/mac68k/mac68k/macrom.c
+++ b/sys/arch/mac68k/mac68k/macrom.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: macrom.c,v 1.9 1997/02/23 06:05:00 briggs Exp $ */
-/* $NetBSD: macrom.c,v 1.30 1996/12/18 07:21:06 scottr Exp $ */
+/* $OpenBSD: macrom.c,v 1.10 1997/03/08 16:17:05 briggs Exp $ */
+/* $NetBSD: macrom.c,v 1.31 1997/03/01 17:20:34 scottr Exp $ */
/*-
* Copyright (C) 1994 Bradley A. Grantham
@@ -432,17 +432,13 @@ mrg_NewPtr()
{
int result = noErr;
u_int numbytes;
- u_int32_t trapword;
caddr_t ptr;
- __asm(" movw d1, %0
- movl d0, %1"
- : "=g" (trapword), "=g" (numbytes) : : "d0", "d1");
+ __asm(" movw d0, %0"
+ : "=g" (numbytes) : : "d0");
#if defined(MRG_SHOWTRAPS)
- printf("mrg: NewPtr(%d bytes, %sclear, %ssys)", numbytes,
- TRAP_SYS(trapword) ? "" : "no ",
- TRAP_CLEAR(trapword) ? "" : "no ");
+ printf("mrg: NewPtr(%d bytes, ? clear, ? sys)", numbytes);
#endif
/* plus 4 for size */
@@ -457,7 +453,7 @@ mrg_NewPtr()
#endif
}else{
#if defined(MRG_SHOWTRAPS)
- printf(" succeded = %x.\n", ptr);
+ printf(" succeded = %p.\n", ptr);
#endif
*(u_int32_t *)ptr = numbytes;
ptr += 4;
@@ -477,7 +473,7 @@ mrg_DisposPtr()
__asm(" movl a0, %0" : "=g" (ptr) : : "a0");
#if defined(MRG_SHOWTRAPS)
- printf("mrg: DisposPtr(%x)\n", ptr);
+ printf("mrg: DisposPtr(%p)\n", ptr);
#endif
if(ptr == 0){
@@ -497,7 +493,7 @@ mrg_GetPtrSize()
__asm(" movl a0, %0" : "=g" (ptr) : : "a0");
#if defined(MRG_SHOWTRAPS)
- printf("mrg: GetPtrSize(%x)\n", ptr);
+ printf("mrg: GetPtrSize(%p)\n", ptr);
#endif
if(ptr == 0){
@@ -512,12 +508,12 @@ mrg_SetPtrSize()
caddr_t ptr;
int newbytes;
- __asm(" movl a1, %0
+ __asm(" movl a0, %0
movl d0, %1"
- : "=g" (ptr), "=g" (newbytes) : : "d0", "a1");
+ : "=g" (ptr), "=g" (newbytes) : : "d0", "a0");
#if defined(MRG_SHOWTRAPS)
- printf("mrg: SetPtrSize(%x, %d) failed\n", ptr, newbytes);
+ printf("mrg: SetPtrSize(%p, %d) failed\n", ptr, newbytes);
#endif
return(memFullErr); /* How would I handle this, anyway? */
@@ -663,33 +659,36 @@ mrg_aline_super(struct frame *frame)
#endif
/*
- * put trapword in d1
- * put trapaddr in a1
+ * put trapaddr in a2
* put a0 in a0
+ * put a1 in a1
* put d0 in d0
+ * put d1 in d1
* save a6
* call the damn routine
* restore a6
* store d0 in d0bucket
* store a0 in d0bucket
- * This will change a1,d1,d0,a0 and possibly a6
+ * This will change a2,a1,d1,d0,a0 and possibly a6
*/
__asm("
- movl %2, a1
+ movl %2, d0
movw %3, d1
- movl %4, d0
- movl %5, a0
- jbsr a1@
+ movl %4, a0
+ movl %5, a1
+ movl %6, a2
+ jbsr a2@
movl a0, %0
movl d0, %1"
: "=g" (a0bucket), "=g" (d0bucket)
- : "g" (trapaddr), "g" (trapword),
- "m" (frame->f_regs[0]), "m" (frame->f_regs[8])
+ : "m" (frame->f_regs[0]), "m" (frame->f_regs[1]),
+ "m" (frame->f_regs[8]), "m" (frame->f_regs[9]),
+ "g" (trapaddr)
- : "d0", "d1", "a0", "a1", "a6"
+ : "d0", "d1", "a0", "a1", "a2", "a6"
);
diff --git a/sys/arch/mac68k/mac68k/via.c b/sys/arch/mac68k/mac68k/via.c
index 97b32dbf528..664000211eb 100644
--- a/sys/arch/mac68k/mac68k/via.c
+++ b/sys/arch/mac68k/mac68k/via.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: via.c,v 1.12 1997/01/24 01:35:54 briggs Exp $ */
-/* $NetBSD: via.c,v 1.55 1997/01/07 07:45:45 scottr Exp $ */
+/* $OpenBSD: via.c,v 1.13 1997/03/08 16:17:06 briggs Exp $ */
+/* $NetBSD: via.c,v 1.58 1997/03/04 04:11:52 scottr Exp $ */
/*-
* Copyright (C) 1993 Allen K. Briggs, Chris P. Caputo,
@@ -201,9 +201,8 @@ void
via1_intr(fp)
struct frame *fp;
{
- register unsigned char intbits;
- register unsigned char mask;
- register unsigned char bitnum;
+ u_int8_t intbits, bitnum;
+ u_int mask;
intbits = via_reg(VIA1, vIFR) & via_reg(VIA1, vIER);
@@ -216,25 +215,23 @@ via1_intr(fp)
*/
via_reg(VIA1, vIFR) = intbits;
- mask = (unsigned char) 1;
-
+ intbits &= 0x7f;
+ mask = 1;
bitnum = 0;
do {
if (intbits & mask) {
via1itab[bitnum]((void *)((int) bitnum));
- /* via_reg(VIA1, vIFR) = mask; */
}
mask <<= 1;
- } while (intbits >= mask && ++bitnum < 7);
+ } while (intbits >= mask && ++bitnum);
}
void
via2_intr(fp)
struct frame *fp;
{
- register unsigned char intbits;
- register unsigned char mask;
- register unsigned char bitnum;
+ u_int8_t intbits, bitnum;
+ u_int mask;
intbits = via2_reg(vIFR) & via2_reg(vIER);
@@ -243,23 +240,22 @@ via2_intr(fp)
via2_reg(vIFR) = intbits;
- mask = (unsigned char) 1;
-
+ intbits &= 0x7f;
+ mask = 1;
bitnum = 0;
do {
if (intbits & mask)
via2itab[bitnum](via2iarg[bitnum]);
mask <<= 1;
- } while (intbits >= mask && ++bitnum < 7);
+ } while (intbits >= mask && ++bitnum);
}
void
rbv_intr(fp)
struct frame *fp;
{
- register unsigned char intbits;
- register unsigned char mask;
- register unsigned char bitnum;
+ u_int8_t intbits, bitnum;
+ u_int mask;
intbits = (via2_reg(vIFR + rIFR) & via2_reg(vIER + rIER));
@@ -268,14 +264,14 @@ rbv_intr(fp)
via2_reg(rIFR) = intbits;
- mask = (unsigned char) 1;
-
+ intbits &= 0x7f;
+ mask = 1;
bitnum = 0;
do {
if (intbits & mask)
via2itab[bitnum](via2iarg[bitnum]);
mask <<= 1;
- } while (intbits >= mask && ++bitnum < 7);
+ } while (intbits >= mask && ++bitnum);
}
static void
@@ -289,7 +285,7 @@ static void
via2_noint(bitnum)
void *bitnum;
{
- printf("via2_noint(%d)\n", (int) bitnum);
+ printf("via2_noint(%d)\n", (int)bitnum);
}
static int nubus_intr_mask = 0;
@@ -318,13 +314,6 @@ add_nubus_intr(slot, func, client_data)
nubus_intr_mask |= (1 << (slot-9));
- /*
- * The following should be uncommented and the call in if_ae.c
- * removed when we can reliably handle interrupts from the video
- * cards.
- */
-/* enable_nubus_intr(); */
-
splx(s);
return 1;
@@ -333,10 +322,13 @@ add_nubus_intr(slot, func, client_data)
void
enable_nubus_intr()
{
+ if (!nubus_intr_mask)
+ return;
+
if (VIA2 == VIA2OFF)
- via2_reg(vIER) = V2IF_SLOTINT | 0x80;
+ via2_reg(vIER) = 0x80 | V2IF_SLOTINT;
else
- via2_reg(rIER) = V2IF_SLOTINT | 0x80;
+ via2_reg(rIER) = 0x80 | V2IF_SLOTINT;
}
/*ARGSUSED*/
@@ -344,18 +336,18 @@ void
via2_nubus_intr(bitarg)
void *bitarg;
{
- register int i, mask, ints;
+ u_int8_t i, intbits, mask;
via2_reg(vIFR) = 0x80 | V2IF_SLOTINT;
- while ((ints = (~via2_reg(vBufA)) & nubus_intr_mask)) {
+ while ((intbits = (~via2_reg(vBufA)) & nubus_intr_mask)) {
i = 6;
mask = (1 << i);
- while (mask) {
- if (ints & mask)
+ do {
+ if (intbits & mask)
(*slotitab[i])(slotptab[i], i+9);
i--;
mask >>= 1;
- }
+ } while (mask);
via2_reg(vIFR) = V2IF_SLOTINT;
}
}
@@ -365,18 +357,18 @@ void
rbv_nubus_intr(bitarg)
void *bitarg;
{
- register int i, mask, ints;
+ u_int8_t i, intbits, mask;
via2_reg(rIFR) = 0x80 | V2IF_SLOTINT;
- while ((ints = (~via2_reg(rBufA)) & via2_reg(rSlotInt))) {
+ while ((intbits = (~via2_reg(rBufA)) & via2_reg(rSlotInt))) {
i = 6;
mask = (1 << i);
- while (mask) {
- if (ints & mask)
+ do {
+ if (intbits & mask)
(*slotitab[i])(slotptab[i], i+9);
i--;
mask >>= 1;
- }
+ } while (mask);
via2_reg(rIFR) = 0x80 | V2IF_SLOTINT;
}
}
@@ -428,53 +420,28 @@ rbv_vidstatus()
}
void
-mac68k_register_scsi_drq(drq_func, client_data)
- void (*drq_func)(void *);
- void *client_data;
-{
- if (drq_func) {
- via2itab[0] = drq_func;
- via2iarg[0] = client_data;
- } else {
- via2itab[0] = via2_noint;
- via2iarg[0] = (void *) 0;
- }
-}
-
-void
-mac68k_register_scsi_irq(irq_func, client_data)
- void (*irq_func)(void *);
- void *client_data;
+via1_register_irq(irq, irq_func, client_data)
+ int irq;
+ void (*irq_func)(void *);
+ void *client_data;
{
- if (irq_func) {
- via2itab[3] = irq_func;
- via2iarg[3] = client_data;
- } else {
- via2itab[3] = via2_noint;
- via2iarg[3] = (void *) 3;
- }
+ if (irq_func)
+ via1itab[irq] = irq_func;
+ else
+ via1itab[irq] = via1_noint;
}
void
-mac68k_register_scsi_b_irq(irq_func, client_data)
- void (*irq_func)(void *);
- void *client_data;
+via2_register_irq(irq, irq_func, client_data)
+ int irq;
+ void (*irq_func)(void *);
+ void *client_data;
{
if (irq_func) {
- via2itab[0] = irq_func;
- via2iarg[0] = client_data;
+ via2itab[irq] = irq_func;
+ via2iarg[irq] = client_data;
} else {
- via2itab[0] = via2_noint;
- via2iarg[0] = (void *) 0;
+ via2itab[irq] = via2_noint;
+ via2iarg[irq] = (void *) 0;
}
}
-
-void
-mac68k_register_via1_t1_irq(irq_func)
- void (*irq_func)(void *);
-{
- if (irq_func)
- via1itab[6] = irq_func;
- else
- via1itab[6] = rtclock_intr;
-}