summaryrefslogtreecommitdiff
path: root/sys/dev/isa/if_tribm_isa.c
diff options
context:
space:
mode:
authorFederico G. Schwindt <fgsch@cvs.openbsd.org>1999-12-27 21:51:36 +0000
committerFederico G. Schwindt <fgsch@cvs.openbsd.org>1999-12-27 21:51:36 +0000
commitd22c519e835f6ff88c8df7f1ee3837808ed67a4b (patch)
tree32685fa72e7c6b42e4fceadac4bac4e7f18a3dc2 /sys/dev/isa/if_tribm_isa.c
parent27c6ceea191523e7370c6ecd6a6837d88fe6a13b (diff)
Token ring driver for Tropic based boards; from NetBSD.
This is as is in NetBSD. I've some mods in my tree ready to be merged. For the records: * This driver needs massive work to be ready for production (people is invited to help, don't be shy). Rewrite part/whole is my list. * IP isn't working at the moment. ARP handling needs several changes. (remember this guys? maybe this time...) * This only handle SNAP frames. IPX using IPX frames doesn't work (you could receive but not transmit to be exact). In order to do that, dsap needs to be changed. I don't know how to setup multiple dsap's at the moment (don't worry about it now, our IPX code is going to be replaced soon since the current implementation is buggy). * Source routing is missing. * tcpdump needs some hacking too (in my tree too). * More things I'm probably forgetting now (haven't worked on this for a while). Our networking code needs some cleanup and rearrangement (specially the headers). net/if_ether.h is an example; arp is not ether specific.
Diffstat (limited to 'sys/dev/isa/if_tribm_isa.c')
-rw-r--r--sys/dev/isa/if_tribm_isa.c174
1 files changed, 174 insertions, 0 deletions
diff --git a/sys/dev/isa/if_tribm_isa.c b/sys/dev/isa/if_tribm_isa.c
new file mode 100644
index 00000000000..69f92b688f9
--- /dev/null
+++ b/sys/dev/isa/if_tribm_isa.c
@@ -0,0 +1,174 @@
+/* $OpenBSD: if_tribm_isa.c,v 1.1 1999/12/27 21:51:35 fgsch Exp $ */
+/* $NetBSD: if_tribm_isa.c,v 1.2 1999/03/22 23:01:37 bad Exp $ */
+
+/*
+ * Copyright (c) 1999 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Onno van der Linden.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by The NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/socket.h>
+#include <sys/device.h>
+
+#include <net/if.h>
+#include <net/if_media.h>
+#include <netinet/in.h>
+#include <netinet/if_ether.h>
+
+#include <machine/bus.h>
+
+#include <dev/isa/isavar.h>
+
+#include <dev/ic/tropicreg.h>
+#include <dev/ic/tropicvar.h>
+
+int tribm_isa_probe __P((struct device *, void *, void *));
+int tr_isa_map_io __P((struct isa_attach_args *, bus_space_handle_t *,
+ bus_space_handle_t *));
+void tr_isa_unmap_io __P((struct isa_attach_args *, bus_space_handle_t,
+ bus_space_handle_t));
+
+int
+tribm_isa_probe(parent, match, aux)
+ struct device *parent;
+ void *match, *aux;
+{
+ struct isa_attach_args *ia = aux;
+ static int irq_f[4] = { 9, 3, 6, 7 };
+ static int irq_e[4] = { 9, 3, 10, 11 };
+ bus_space_tag_t piot = ia->ia_iot;
+ bus_space_tag_t memt = ia->ia_memt;
+ bus_space_handle_t pioh, mmioh;
+ int i, irq;
+ u_int8_t s;
+
+#ifdef notyet
+/* XXX Try both 0xa20 and 0xa24 and store that info like 3com */
+ if (ia->ia_iobase == IOBASEUNK)
+ ia->ia_iobase = 0xa20;
+#else
+ if (ia->ia_iobase == IOBASEUNK)
+ return 0;
+#endif
+
+ ia->ia_iosize = 4;
+ ia->ia_aux = NULL;
+
+ if (tr_isa_map_io(ia, &pioh, &mmioh))
+ return 0;
+
+/*
+ * F = Token-Ring Network PC Adapter
+ * Token-Ring Network PC Adapter II
+ * Token-Ring Network Adapter/A
+ * E = Token-Ring Network 16/4 Adapter/A (long card)
+ * Token-Ring Network 16/4 Adapter
+ * D = Token-Ring Network 16/4 Adapter/A (short card)
+ * 16/4 ISA-16 Adapter
+ * C = Auto 16/4 Token-Ring ISA Adapter
+ * Auto 16/4 Token-Ring MC Adapter
+ */
+/*
+ * XXX Both 0xD and 0xC types should be able to use 16-bit read and writes
+ */
+ switch (bus_space_read_1(memt, mmioh, TR_TYP_OFFSET)) {
+ case 0xF:
+ case 0xE:
+ case 0xD:
+ if (ia->ia_maddr == MADDRUNK)
+#ifdef notyet
+ ia->ia_maddr = TR_SRAM_DEFAULT;
+#else
+ return 0;
+#endif
+ break;
+ case 0xC:
+ i = bus_space_read_1(memt, mmioh, TR_ACA_OFFSET) << 12;
+ if (ia->ia_maddr == MADDRUNK)
+ ia->ia_maddr = i;
+ else if (ia->ia_maddr != i) {
+ printf(
+"tribm_isa_probe: sram mismatch; kernel configured %x != board configured %x\n",
+ ia->ia_maddr, i);
+ tr_isa_unmap_io(ia, pioh, mmioh);
+ return 0;
+ }
+ break;
+ default:
+ printf("tribm_isa_probe: unknown type code %x\n",
+ bus_space_read_1(memt, mmioh, TR_TYP_OFFSET));
+ tr_isa_unmap_io(ia, pioh, mmioh);
+ return 0;
+ }
+
+ s = bus_space_read_1(piot, pioh, TR_SWITCH);
+
+ switch (bus_space_read_1(memt, mmioh, TR_IRQ_OFFSET)) {
+ case 0xF:
+ irq = irq_f[s & 3];
+ break;
+ case 0xE:
+ irq = irq_e[s & 3];
+ break;
+ default:
+ printf("tribm_isa_probe: Unknown IRQ code %x\n",
+ bus_space_read_1(memt, mmioh, TR_IRQ_OFFSET));
+ tr_isa_unmap_io(ia, pioh, mmioh);
+ return 0;
+ }
+
+ if (ia->ia_irq == IRQUNK)
+ ia->ia_irq = irq;
+ else if (ia->ia_irq != irq) {
+ printf(
+"tribm_isa_probe: irq mismatch; kernel configured %d != board configured %d\n",
+ ia->ia_irq, irq);
+ tr_isa_unmap_io(ia, pioh, mmioh);
+ return 0;
+ }
+/*
+ * XXX 0x0c == MSIZEMASK (MSIZEBITS)
+ */
+ ia->ia_msize = 8192 <<
+ ((bus_space_read_1(memt, mmioh, TR_ACA_OFFSET + 1) & 0x0c) >> 2);
+ tr_isa_unmap_io(ia, pioh, mmioh);
+ /* Check alignment of membase. */
+ if ((ia->ia_maddr & (ia->ia_msize-1)) != 0) {
+ printf("tribm_isa_probe: SRAM unaligned 0x%04x/%d\n",
+ ia->ia_maddr, ia->ia_msize);
+ return 0;
+ }
+ return 1;
+}