Annotation of sys/arch/vax/vsa/if_ze_vsbus.c, Revision 1.1
1.1 ! nbrk 1: /* $OpenBSD: if_ze_vsbus.c,v 1.4 2006/08/30 19:28:13 miod Exp $ */
! 2: /* $NetBSD: if_ze_vsbus.c,v 1.5 2000/07/26 21:50:49 matt Exp $ */
! 3: /*
! 4: * Copyright (c) 1999 Ludd, University of Lule}, Sweden. All rights reserved.
! 5: *
! 6: * Redistribution and use in source and binary forms, with or without
! 7: * modification, are permitted provided that the following conditions
! 8: * are met:
! 9: * 1. Redistributions of source code must retain the above copyright
! 10: * notice, this list of conditions and the following disclaimer.
! 11: * 2. Redistributions in binary form must reproduce the above copyright
! 12: * notice, this list of conditions and the following disclaimer in the
! 13: * documentation and/or other materials provided with the distribution.
! 14: * 3. All advertising materials mentioning features or use of this software
! 15: * must display the following acknowledgement:
! 16: * This product includes software developed at Ludd, University of
! 17: * Lule}, Sweden and its contributors.
! 18: * 4. The name of the author may not be used to endorse or promote products
! 19: * derived from this software without specific prior written permission
! 20: *
! 21: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
! 22: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
! 23: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
! 24: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
! 25: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
! 26: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
! 27: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
! 28: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
! 29: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
! 30: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
! 31: */
! 32:
! 33: #include <sys/param.h>
! 34: #include <sys/socket.h>
! 35: #include <sys/device.h>
! 36: #include <sys/systm.h>
! 37: #include <sys/sockio.h>
! 38:
! 39: #include <net/if.h>
! 40: #include <net/if_dl.h>
! 41:
! 42: #include <netinet/in.h>
! 43: #include <netinet/if_ether.h>
! 44:
! 45: #if NBPFILTER > 0
! 46: #include <net/bpf.h>
! 47: #include <net/bpfdesc.h>
! 48: #endif
! 49:
! 50: #include <machine/bus.h>
! 51: #include <machine/vsbus.h>
! 52: #include <machine/cpu.h>
! 53: #include <machine/scb.h>
! 54: #include <machine/sid.h>
! 55:
! 56: #include <arch/vax/if/sgecreg.h>
! 57: #include <arch/vax/if/sgecvar.h>
! 58:
! 59: /*
! 60: * Addresses.
! 61: */
! 62: #define SGECADDR 0x20008000
! 63: #define NISA_ROM 0x27800000
! 64: #define SGECVEC 0x108
! 65:
! 66: static int zematch(struct device *, void *, void *);
! 67: static void zeattach(struct device *, struct device *, void *);
! 68:
! 69: struct cfattach ze_vsbus_ca = {
! 70: sizeof(struct ze_softc), zematch, zeattach
! 71: };
! 72:
! 73: /*
! 74: * Check for present SGEC.
! 75: */
! 76: int
! 77: zematch(parent, cf, aux)
! 78: struct device *parent;
! 79: void *cf;
! 80: void *aux;
! 81: {
! 82: /*
! 83: * Should some more intelligent checking be done???
! 84: * Should for sure force an interrupt instead...
! 85: */
! 86: if (vax_boardtype != VAX_BTYP_49)
! 87: return 0;
! 88:
! 89: /* Fool the interrupt system. */
! 90: scb_fake(SGECVEC, 0x15);
! 91: return 12;
! 92: }
! 93:
! 94: /*
! 95: * Interface exists: make available by filling in network interface
! 96: * record. System will initialize the interface when it is ready
! 97: * to accept packets.
! 98: */
! 99: void
! 100: zeattach(parent, self, aux)
! 101: struct device *parent, *self;
! 102: void *aux;
! 103: {
! 104: struct ze_softc *sc = (struct ze_softc *)self;
! 105: struct vsbus_attach_args *va = aux;
! 106: extern struct vax_bus_dma_tag vax_bus_dma_tag;
! 107: int *ea, i;
! 108:
! 109: /*
! 110: * Map in SGEC registers.
! 111: */
! 112: sc->sc_ioh = vax_map_physmem(SGECADDR, 1);
! 113: sc->sc_iot = 0; /* :-) */
! 114: sc->sc_dmat = &vax_bus_dma_tag;
! 115:
! 116: sc->sc_intvec = SGECVEC;
! 117: scb_vecalloc(va->va_cvec, (void (*)(void *)) sgec_intr,
! 118: sc, SCB_ISTACK, &sc->sc_intrcnt);
! 119: evcount_attach(&sc->sc_intrcnt, sc->sc_dev.dv_xname,
! 120: (void *)&sc->sc_intvec, &evcount_intr);
! 121:
! 122: /*
! 123: * Map in, read and release ethernet rom address.
! 124: */
! 125: ea = (int *)vax_map_physmem(NISA_ROM, 1);
! 126: for (i = 0; i < ETHER_ADDR_LEN; i++)
! 127: sc->sc_ac.ac_enaddr[i] = ea[i] & 0377;
! 128: vax_unmap_physmem((vaddr_t)ea, 1);
! 129:
! 130: sgec_attach(sc);
! 131: }
CVSweb