1/* 2 * Copyright (C) 1996 Naoki Hamada <nao@tom-yam.or.jp> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. Neither the name of the author nor the names of any co-contributors 14 * may be used to endorse or promote products derived from this software 15 * without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 */ 30 31#include "eisa.h" 32#if NEISA > 0 33 34#include "vx.h" 35#if NVX > 0 36 37#include "opt_inet.h" 38 39#include <sys/param.h> 40#include <sys/systm.h> 41#include <sys/kernel.h> 42#include <sys/socket.h> 43 44#include <net/ethernet.h> 45#include <net/if.h> 46#include <net/if_arp.h> 47 48#ifdef INET 49#include <netinet/in.h> 50#endif 51 52#ifdef NS 53#include <netns/ns.h> 54#include <netns/ns_if.h> 55#endif 56 57#include <i386/eisa/eisaconf.h> 58 59#include <dev/vx/if_vxreg.h> 60 61#define EISA_DEVICE_ID_3COM_3C592 0x506d5920 62#define EISA_DEVICE_ID_3COM_3C597_TX 0x506d5970 63#define EISA_DEVICE_ID_3COM_3C597_T4 0x506d5971 64#define EISA_DEVICE_ID_3COM_3C597_MII 0x506d5972 65 66 67#define VX_EISA_SLOT_OFFSET 0x0c80 68#define VX_EISA_IOSIZE 0x000a 69#define VX_RESOURCE_CONFIG 0x0008 70 71 72static const char *vx_match __P((eisa_id_t type)); 73static int vx_eisa_probe __P((void)); 74static int vx_eisa_attach __P((struct eisa_device *)); 75
|
76struct eisa_driver vx_eisa_driver = {
|
76static struct eisa_driver vx_eisa_driver = { |
77 "vx", 78 vx_eisa_probe, 79 vx_eisa_attach, 80 /* shutdown */ NULL, 81 &vx_count 82}; 83 84DATA_SET(eisadriver_set, vx_eisa_driver); 85 86static const char* 87vx_match(type) 88 eisa_id_t type; 89{ 90 switch (type) { 91 case EISA_DEVICE_ID_3COM_3C592: 92 return "3Com 3C592 Network Adapter"; 93 break; 94 case EISA_DEVICE_ID_3COM_3C597_TX: 95 return "3Com 3C597-TX Network Adapter"; 96 break; 97 case EISA_DEVICE_ID_3COM_3C597_T4: 98 return "3Com 3C597-T4 Network Adapter"; 99 break; 100 case EISA_DEVICE_ID_3COM_3C597_MII: 101 return "3Com 3C597-MII Network Adapter"; 102 break; 103 default: 104 break; 105 } 106 return (NULL); 107} 108 109static int 110vx_eisa_probe(void) 111{ 112 u_long iobase; 113 struct eisa_device *e_dev = NULL; 114 int count; 115 116 count = 0; 117 while ((e_dev = eisa_match_dev(e_dev, vx_match))) { 118 u_long port; 119 120 port = e_dev->ioconf.slot * EISA_SLOT_SIZE; 121 iobase = port + VX_EISA_SLOT_OFFSET; 122 123 eisa_add_iospace(e_dev, iobase, VX_EISA_IOSIZE, RESVADDR_NONE); 124 eisa_add_iospace(e_dev, port, VX_IOSIZE, RESVADDR_NONE); 125 126 /* Set irq */ 127 eisa_add_intr(e_dev, inw(iobase + VX_RESOURCE_CONFIG) >> 12); 128 eisa_registerdev(e_dev, &vx_eisa_driver); 129 count++; 130 } 131 return count; 132} 133 134static int 135vx_eisa_attach(e_dev) 136 struct eisa_device *e_dev; 137{ 138 struct vx_softc *sc; 139 int unit = e_dev->unit; 140 int irq; 141 resvaddr_t *ioport; 142 resvaddr_t *eisa_ioport; 143 u_char level_intr; 144 145 if (TAILQ_FIRST(&e_dev->ioconf.irqs) == NULL) 146 return (-1); 147 148 irq = TAILQ_FIRST(&e_dev->ioconf.irqs)->irq_no; 149 150 ioport = e_dev->ioconf.ioaddrs.lh_first; 151 152 if (!ioport) 153 return -1; 154 155 eisa_ioport = ioport->links.le_next; 156 157 if (!eisa_ioport) 158 return -1; 159 160 eisa_reg_start(e_dev); 161 if (eisa_reg_iospace(e_dev, ioport)) 162 return -1; 163 164 if (eisa_reg_iospace(e_dev, eisa_ioport)) 165 return -1; 166 167 if ((sc = vxalloc(unit)) == NULL) 168 return -1; 169 170 sc->vx_io_addr = ioport->addr; 171 172 level_intr = FALSE; 173 174 if (eisa_reg_intr(e_dev, irq, (void (*)(void *)) vxintr, (void *) sc, &net_imask, 175 /* shared == */ level_intr)) { 176 vxfree(sc); 177 return -1; 178 } 179 eisa_reg_end(e_dev); 180 181 /* Now the registers are availible through the lower ioport */ 182 183 vxattach(sc); 184 185 if (eisa_enable_intr(e_dev, irq)) { 186 vxfree(sc); 187 eisa_release_intr(e_dev, irq, (void (*)(void *)) vxintr); 188 return -1; 189 } 190 return 0; 191} 192 193#endif /* NVX > 0 */ 194#endif /* NEISA > 0 */
|