Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/atari Add support for the EtherNEC.



details:   https://anonhg.NetBSD.org/src/rev/ba101cb16021
branches:  trunk
changeset: 753557:ba101cb16021
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Thu Apr 01 17:07:51 2010 +0000

description:
Add support for the EtherNEC.

The EtherNEC is yet another user designed device for Atari machines,
an NE2000 based ISA board connected to Atari's ROM cartridge slot with
simple but ingenious interface and cartridge port adapter, and
it's the most available network solution for the old Atari machines.

See following pages for more details about EtherNEC:
http://hardware.atari.org/ether/
http://home.arcor.de/thomas.redelberger/prj/atari/etherne/
http://www.freemint.org/ethernec/ethernec.html

diffstat:

 sys/arch/atari/atari/autoconf.c |    5 +-
 sys/arch/atari/conf/GENERIC.in  |    3 +-
 sys/arch/atari/conf/HADES.in    |    3 +-
 sys/arch/atari/conf/MILAN.in    |    3 +-
 sys/arch/atari/conf/files.atari |    6 +-
 sys/arch/atari/dev/if_ne_mb.c   |  459 ++++++++++++++++++++++++++++++++++++++++
 6 files changed, 473 insertions(+), 6 deletions(-)

diffs (truncated from 564 to 300 lines):

diff -r 09fe3ff3090c -r ba101cb16021 sys/arch/atari/atari/autoconf.c
--- a/sys/arch/atari/atari/autoconf.c   Thu Apr 01 14:31:51 2010 +0000
+++ b/sys/arch/atari/atari/autoconf.c   Thu Apr 01 17:07:51 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: autoconf.c,v 1.56 2009/03/08 05:25:30 tsutsui Exp $    */
+/*     $NetBSD: autoconf.c,v 1.57 2010/04/01 17:07:51 tsutsui Exp $    */
 
 /*
  * Copyright (c) 1995 Leo Weppelman
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.56 2009/03/08 05:25:30 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.57 2010/04/01 17:07:51 tsutsui Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -280,6 +280,7 @@
        config_found(dp, __UNCONST("nvr")     , simple_devprint);
        config_found(dp, __UNCONST("lpt")     , simple_devprint);
        config_found(dp, __UNCONST("wdc")     , simple_devprint);
+       config_found(dp, __UNCONST("ne")      , simple_devprint);
        config_found(dp, __UNCONST("isab")    , simple_devprint);
        config_found(dp, __UNCONST("pcib")    , simple_devprint);
        config_found(dp, __UNCONST("avmebus") , simple_devprint);
diff -r 09fe3ff3090c -r ba101cb16021 sys/arch/atari/conf/GENERIC.in
--- a/sys/arch/atari/conf/GENERIC.in    Thu Apr 01 14:31:51 2010 +0000
+++ b/sys/arch/atari/conf/GENERIC.in    Thu Apr 01 17:07:51 2010 +0000
@@ -1,5 +1,5 @@
 #
-#      $NetBSD: GENERIC.in,v 1.84 2010/03/13 16:30:02 tsutsui Exp $
+#      $NetBSD: GENERIC.in,v 1.85 2010/04/01 17:07:51 tsutsui Exp $
 #
 # Generic atari
 #
@@ -349,6 +349,7 @@
 ite2           at grfcc2       # 3rd tty
 lp0            at mainbus0     # centronics printer
 ser0           at mainbus0     # UART on first 68901 (ttyB0)
+ne0            at mainbus0     # EtherNEC on Atari ROM cartridge slot
 
 #if defined(TT030_KERNEL)
 avmebus0       at mainbus0     # VME bus
diff -r 09fe3ff3090c -r ba101cb16021 sys/arch/atari/conf/HADES.in
--- a/sys/arch/atari/conf/HADES.in      Thu Apr 01 14:31:51 2010 +0000
+++ b/sys/arch/atari/conf/HADES.in      Thu Apr 01 17:07:51 2010 +0000
@@ -1,5 +1,5 @@
 #
-#      $NetBSD: HADES.in,v 1.9 2009/01/24 00:19:47 abs Exp $
+#      $NetBSD: HADES.in,v 1.10 2010/04/01 17:07:51 tsutsui Exp $
 #
 # Medusa-Hades
 #
@@ -21,6 +21,7 @@
 nvr0           at mainbus0     # nvram driver
 lp0            at mainbus0     # centronics printer
 ser0           at mainbus0     # UART on first 68901 (ttyB0)
+ne0            at mainbus0     # EtherNEC on Atari ROM cartridge slot
 grfbus0                at mainbus0     # bitmapped display's
 grfet0         at grfbus0      # et4000/et6000/et6100 consoles
 ite0           at grfet0
diff -r 09fe3ff3090c -r ba101cb16021 sys/arch/atari/conf/MILAN.in
--- a/sys/arch/atari/conf/MILAN.in      Thu Apr 01 14:31:51 2010 +0000
+++ b/sys/arch/atari/conf/MILAN.in      Thu Apr 01 17:07:51 2010 +0000
@@ -1,5 +1,5 @@
 #
-#      $NetBSD: MILAN.in,v 1.23 2009/12/23 09:17:41 mbalmer Exp $
+#      $NetBSD: MILAN.in,v 1.24 2010/04/01 17:07:51 tsutsui Exp $
 #
 # Milan
 #
@@ -45,6 +45,7 @@
 pci0           at pcib0
 nvr0           at mainbus0                     # nvram driver
 ser0           at mainbus0
+ne0            at mainbus0                     # EtherNEC
 fdcisa0        at isa? port 0x3f0 irq 6 drq 2  # standard PC floppy contr.
 fdisa0                 at fdcisa0 drive 0
 
diff -r 09fe3ff3090c -r ba101cb16021 sys/arch/atari/conf/files.atari
--- a/sys/arch/atari/conf/files.atari   Thu Apr 01 14:31:51 2010 +0000
+++ b/sys/arch/atari/conf/files.atari   Thu Apr 01 17:07:51 2010 +0000
@@ -1,5 +1,5 @@
 #
-#      $NetBSD: files.atari,v 1.116 2010/03/13 16:30:03 tsutsui Exp $
+#      $NetBSD: files.atari,v 1.117 2010/04/01 17:07:51 tsutsui Exp $
 
 maxpartitions 16
 
@@ -182,6 +182,10 @@
 attach wdc at mainbus with wdc_mb: mbdma
 file   arch/atari/dev/wdc_mb.c         wdc_mb
 
+# EtherNEC on Atari ROM cartridge slot
+attach ne at mainbus with ne_mb: rtl80x9
+file   arch/atari/dev/if_ne_mb.c       ne_mb
+
 # ISA Plug 'n Play devices
 file   arch/atari/isa/isapnp_machdep.c isapnp
 
diff -r 09fe3ff3090c -r ba101cb16021 sys/arch/atari/dev/if_ne_mb.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/atari/dev/if_ne_mb.c     Thu Apr 01 17:07:51 2010 +0000
@@ -0,0 +1,459 @@
+/*     $NetBSD: if_ne_mb.c,v 1.1 2010/04/01 17:07:52 tsutsui Exp $     */
+
+/*
+ * Copyright (c) 2010 Izumi Tsutsui.  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.
+ *
+ * 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.
+ */
+
+/*
+ * Device driver for the EtherNEC,
+ * NE2000 in 8bit mode over Atari ROM cartridge slot.
+ * http://hardware.atari.org/ether/
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: if_ne_mb.c,v 1.1 2010/04/01 17:07:52 tsutsui Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+#include <sys/kernel.h>
+#include <sys/callout.h>
+
+#include <sys/bus.h>
+#include <sys/intr.h>
+
+#include <net/if.h>
+#include <net/if_dl.h>
+#include <net/if_ether.h>
+#include <net/if_media.h>
+
+#include <machine/cpu.h>
+#include <machine/iomap.h>
+
+#include <atari/atari/device.h>
+
+#include <dev/ic/dp8390reg.h>
+#include <dev/ic/dp8390var.h>
+#include <dev/ic/ne2000reg.h>
+#include <dev/ic/ne2000var.h>
+
+/*
+ * EtherNEC specific address configuration
+ */
+
+/* I/O read ops are through /ROM4 area (0xFA0000) */
+#define AD_CART_ROM4           (AD_CART + 0x00000)
+#define ETHERNEC_READ_PORT     AD_CART_ROM4
+
+/* I/O write ops are through /ROM3 area (0xFB0000) */
+#define AD_CART_ROM3           (AD_CART + 0x10000)
+#define ETHERNEC_WRITE_PORT    AD_CART_ROM3
+
+/* CPU address lines A13-A9 are connected to ISA A4-A0 */
+#define ETHERNEC_PORT_STRIDE   9
+
+/* Using A8-A1 lines to specify write data (no A0 but UDS/LDS on m68k) */
+#define ETHERNEC_WR_ADDR_SHIFT 1
+
+/* interrupt polling per HZ */
+#define ETHERNEC_TICK          1
+
+static int  ne_mb_probe(device_t, cfdata_t, void *);
+static void ne_mb_attach(device_t, device_t, void *);
+
+static void ne_mb_poll(void *);
+
+static bus_space_tag_t ethernec_init_bus_space_tag(bus_space_tag_t);
+static void    ethernec_bus_space_unimpl(void);
+
+static int     ethernec_bus_space_peek_1(bus_space_tag_t, bus_space_handle_t,
+    bus_size_t);
+static uint8_t ethernec_bus_space_read_1(bus_space_tag_t, bus_space_handle_t,
+    bus_size_t);
+static void    ethernec_bus_space_write_1(bus_space_tag_t, bus_space_handle_t,
+    bus_size_t, uint8_t);
+static void    ethernec_bus_space_read_multi_1(bus_space_tag_t,
+    bus_space_handle_t, bus_size_t, uint8_t *, bus_size_t);
+static void    ethernec_bus_space_read_multi_2(bus_space_tag_t,
+    bus_space_handle_t, bus_size_t, uint16_t *, bus_size_t);
+static void    ethernec_bus_space_write_multi_1(bus_space_tag_t,
+    bus_space_handle_t, bus_size_t, const uint8_t *, bus_size_t);
+static void    ethernec_bus_space_write_multi_2(bus_space_tag_t,
+    bus_space_handle_t, bus_size_t, const uint16_t *, bus_size_t);
+
+struct ne_mb_softc {
+       struct ne2000_softc sc_ne2000;          /* MI ne2000 softc */
+
+       struct atari_bus_space sc_bs;
+       struct callout sc_poll;
+};
+
+CFATTACH_DECL_NEW(ne_mb, sizeof(struct ne_mb_softc),
+    ne_mb_probe, ne_mb_attach, NULL, NULL);
+
+static int
+ne_mb_probe(device_t parent, cfdata_t cf, void *aux)
+{
+       static bool ne_matched = false;
+       struct atari_bus_space bs;
+       bus_space_tag_t iot, asict;
+       bus_space_handle_t ioh, iowh, asich;
+       int netype, rv;
+
+       rv = 0;
+
+       if (!atari_realconfig)
+               goto out;
+       if (strcmp("ne", aux) || ne_matched)
+               goto out;
+
+       iot = ethernec_init_bus_space_tag(&bs);
+
+       /* map I/O space for read ops */
+       if (bus_space_map(iot, ETHERNEC_READ_PORT,
+           NE2000_NPORTS << ETHERNEC_PORT_STRIDE, 0, &ioh) != 0)
+               goto out;
+
+       /* map I/O space for write ops */
+       if (bus_space_map(iot, ETHERNEC_WRITE_PORT,
+           NE2000_NPORTS << ETHERNEC_PORT_STRIDE, 0, &iowh) != 0)
+               goto out1;
+
+       /* XXX abuse stride for offset of write ports from read ones */
+       iot->stride =
+           (vaddr_t)bus_space_vaddr(iot, iowh) -
+           (vaddr_t)bus_space_vaddr(iot, ioh);
+
+       /* check if register regions are vaild */
+       if (bus_space_peek_1(iot, ioh, 0) == 0)
+               goto out2;
+
+       asict = iot;
+       if (bus_space_subregion(iot, ioh,
+           NE2000_ASIC_OFFSET << ETHERNEC_PORT_STRIDE,
+           NE2000_ASIC_NPORTS << ETHERNEC_PORT_STRIDE, &asich))
+               goto out2;
+
+       /* Look for an NE2000 compatible card */
+       netype = ne2000_detect(iot, ioh, asict, asich);
+       switch (netype) {
+       /* XXX should we reject non RTL8019 variants? */
+       case NE2000_TYPE_NE1000:
+       case NE2000_TYPE_NE2000:
+       case NE2000_TYPE_RTL8019:
+               ne_matched = true;
+               rv = 1;
+               break;
+       default:
+               break;
+       }
+
+ out2:
+       bus_space_unmap(iot, iowh, NE2000_NPORTS << ETHERNEC_PORT_STRIDE);
+ out1:
+       bus_space_unmap(iot, ioh, NE2000_NPORTS << ETHERNEC_PORT_STRIDE);
+ out:
+       return rv;
+}
+
+static void
+ne_mb_attach(device_t parent, device_t self, void *aux)
+{
+       struct ne_mb_softc *sc = device_private(self);
+       struct ne2000_softc *nsc = &sc->sc_ne2000;
+       struct dp8390_softc *dsc = &nsc->sc_dp8390;
+       bus_space_tag_t iot, asict;
+       bus_space_handle_t ioh, iowh, asich;
+       const char *typestr;
+       int netype;
+
+       dsc->sc_dev = self;
+       aprint_normal(": EtherNEC on Atari ROM cartridge slot\n");
+
+       iot = ethernec_init_bus_space_tag(&sc->sc_bs);
+
+       /* map I/O space for read ops */



Home | Main Index | Thread Index | Old Index