if_ep.c revision 37101
1/* 2 * Copyright (c) 1994 Herb Peyerl <hpeyerl@novatel.ca> 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. All advertising materials mentioning features or use of this software 14 * must display the following acknowledgement: 15 * This product includes software developed by Herb Peyerl. 16 * 4. The name of Herb Peyerl may not be used to endorse or promote products 17 * derived from this software without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 * 30 * if_ep.c,v 1.19 1995/01/24 20:53:45 davidg Exp 31 */ 32 33/* 34 * Modified from the FreeBSD 1.1.5.1 version by: 35 * Andres Vega Garcia 36 * INRIA - Sophia Antipolis, France 37 * avega@sophia.inria.fr 38 */ 39 40/* 41 * $Id: if_ep.c,v 1.75 1998/06/07 17:10:28 dfr Exp $ 42 * 43 * Promiscuous mode added and interrupt logic slightly changed 44 * to reduce the number of adapter failures. Transceiver select 45 * logic changed to use value from EEPROM. Autoconfiguration 46 * features added. 47 * Done by: 48 * Serge Babkin 49 * Chelindbank (Chelyabinsk, Russia) 50 * babkin@hq.icb.chel.su 51 */ 52 53/* 54 * Pccard support for 3C589 by: 55 * HAMADA Naoki 56 * nao@tom-yam.or.jp 57 */ 58 59#include "ep.h" 60#if NEP > 0 61 62#include "bpfilter.h" 63#include "opt_inet.h" 64#include "opt_ipx.h" 65 66#include <sys/param.h> 67#if defined(__FreeBSD__) 68#include <sys/kernel.h> 69#include <sys/systm.h> 70#endif 71#include <sys/malloc.h> 72#include <sys/mbuf.h> 73#include <sys/socket.h> 74#include <sys/sockio.h> 75#if defined(__NetBSD__) 76#include <sys/select.h> 77#endif 78 79#include <net/if.h> 80 81#ifdef INET 82#include <netinet/in.h> 83#include <netinet/if_ether.h> 84#endif 85 86#ifdef IPX 87#include <netipx/ipx.h> 88#include <netipx/ipx_if.h> 89#endif 90 91#ifdef NS 92#include <netns/ns.h> 93#include <netns/ns_if.h> 94#endif 95 96#if NBPFILTER > 0 97#include <net/bpf.h> 98#endif 99 100#if defined(__FreeBSD__) 101#include <machine/clock.h> 102#endif 103 104#include <i386/isa/isa_device.h> 105#include <i386/isa/if_epreg.h> 106#include <i386/isa/elink.h> 107 108/* Exported variables */ 109u_long ep_unit; 110int ep_boards; 111struct ep_board ep_board[EP_MAX_BOARDS + 1]; 112 113static int eeprom_rdy __P((struct ep_softc *sc)); 114 115static int ep_isa_probe __P((struct isa_device *)); 116static struct ep_board * ep_look_for_board_at __P((struct isa_device *is)); 117static int ep_isa_attach __P((struct isa_device *)); 118static int epioctl __P((struct ifnet * ifp, u_long, caddr_t)); 119 120static void epinit __P((struct ep_softc *)); 121static void epread __P((struct ep_softc *)); 122void epreset __P((int)); 123static void epstart __P((struct ifnet *)); 124static void epstop __P((struct ep_softc *)); 125static void epwatchdog __P((struct ifnet *)); 126 127#if 0 128static int send_ID_sequence __P((int)); 129#endif 130static int get_eeprom_data __P((int, int)); 131 132static struct ep_softc* ep_softc[NEP]; 133static int ep_current_tag = EP_LAST_TAG + 1; 134static char *ep_conn_type[] = {"UTP", "AUI", "???", "BNC"}; 135 136#define ep_ftst(f) (sc->stat&(f)) 137#define ep_fset(f) (sc->stat|=(f)) 138#define ep_frst(f) (sc->stat&=~(f)) 139 140struct isa_driver epdriver = { 141 ep_isa_probe, 142 ep_isa_attach, 143 "ep", 144 0 145}; 146 147#include "card.h" 148 149#if NCARD > 0 150#include <sys/select.h> 151#include <pccard/cardinfo.h> 152#include <pccard/slot.h> 153 154/* 155 * PC-Card (PCMCIA) specific code. 156 */ 157static int ep_pccard_init __P((struct pccard_devinfo *)); 158static int ep_pccard_attach __P((struct pccard_devinfo *)); 159static void ep_unload __P((struct pccard_devinfo *)); 160static int card_intr __P((struct pccard_devinfo *)); 161 162static struct pccard_device ep_info = { 163 "ep", 164 ep_pccard_init, 165 ep_unload, 166 card_intr, 167 0, /* Attributes - presently unused */ 168 &net_imask 169}; 170 171DATA_SET(pccarddrv_set, ep_info); 172 173/* 174 * Initialize the device - called from Slot manager. 175 */ 176static int 177ep_pccard_init(devi) 178 struct pccard_devinfo *devi; 179{ 180 struct isa_device *is = &devi->isahd; 181 struct ep_softc *sc = ep_softc[is->id_unit]; 182 struct ep_board *epb; 183 int i; 184 185 epb = &ep_board[is->id_unit]; 186 187 if (sc == 0) { 188 if ((sc = ep_alloc(is->id_unit, epb)) == 0) { 189 return (ENXIO); 190 } 191 ep_unit++; 192 } 193 194 /* get_e() requires these. */ 195 sc->ep_io_addr = is->id_iobase; 196 sc->unit = is->id_unit; 197 198 epb->epb_addr = is->id_iobase; 199 epb->epb_used = 1; 200 epb->prod_id = get_e(sc, EEPROM_PROD_ID); 201 202 /* 3C589's product id? */ 203 if (epb->prod_id != 0x9058) { 204 printf("ep%d: failed to come ready.\n", is->id_unit); 205 return (ENXIO); 206 } 207 208 epb->res_cfg = get_e(sc, EEPROM_RESOURCE_CFG); 209 for (i = 0; i < 3; i++) 210 sc->epb->eth_addr[i] = get_e(sc, EEPROM_NODE_ADDR_0 + i); 211 212 if (ep_pccard_attach(devi) == 0) 213 return (ENXIO); 214 215 sc->arpcom.ac_if.if_snd.ifq_maxlen = ifqmaxlen; 216 return (0); 217} 218 219static int 220ep_pccard_attach(devi) 221 struct pccard_devinfo *devi; 222{ 223 struct isa_device *is = &devi->isahd; 224 struct ep_softc *sc = ep_softc[is->id_unit]; 225 u_short config; 226 227 sc->ep_connectors = 0; 228 config = inw(IS_BASE + EP_W0_CONFIG_CTRL); 229 if (config & IS_BNC) { 230 sc->ep_connectors |= BNC; 231 } 232 if (config & IS_UTP) { 233 sc->ep_connectors |= UTP; 234 } 235 if (!(sc->ep_connectors & 7)) 236 printf("no connectors!"); 237 sc->ep_connector = inw(BASE + EP_W0_ADDRESS_CFG) >> ACF_CONNECTOR_BITS; 238 239 /* ROM size = 0, ROM base = 0 */ 240 /* For now, ignore AUTO SELECT feature of 3C589B and later. */ 241 outw(BASE + EP_W0_ADDRESS_CFG, get_e(sc, EEPROM_ADDR_CFG) & 0xc000); 242 243 /* Fake IRQ must be 3 */ 244 outw(BASE + EP_W0_RESOURCE_CFG, (sc->epb->res_cfg & 0x0fff) | 0x3000); 245 246 outw(BASE + EP_W0_PRODUCT_ID, sc->epb->prod_id); 247 248 ep_attach(sc); 249 250 return 1; 251} 252 253static void 254ep_unload(devi) 255 struct pccard_devinfo *devi; 256{ 257 struct ep_softc *sc = ep_softc[devi->isahd.id_unit]; 258 259 if (sc->gone) { 260 printf("ep%d: already unloaded\n", devi->isahd.id_unit); 261 return; 262 } 263 sc->arpcom.ac_if.if_flags &= ~IFF_RUNNING; 264 sc->gone = 1; 265 printf("ep%d: unload\n", devi->isahd.id_unit); 266} 267 268/* 269 * card_intr - Shared interrupt called from 270 * front end of PC-Card handler. 271 */ 272static int 273card_intr(devi) 274 struct pccard_devinfo *devi; 275{ 276 epintr(devi->isahd.id_unit); 277 return(1); 278} 279#endif /* NCARD > 0 */ 280 281static int 282eeprom_rdy(sc) 283 struct ep_softc *sc; 284{ 285 int i; 286 287 for (i = 0; is_eeprom_busy(BASE) && i < MAX_EEPROMBUSY; i++) 288 continue; 289 if (i >= MAX_EEPROMBUSY) { 290 printf("ep%d: eeprom failed to come ready.\n", sc->unit); 291 return (0); 292 } 293 return (1); 294} 295 296static struct ep_board * 297ep_look_for_board_at(is) 298 struct isa_device *is; 299{ 300 int data, i, j, id_port = ELINK_ID_PORT; 301 int count = 0; 302 303 if (ep_current_tag == (EP_LAST_TAG + 1)) { 304 /* Come here just one time */ 305 306 ep_current_tag--; 307 308 /* Look for the ISA boards. Init and leave them actived */ 309 outb(id_port, 0); 310 outb(id_port, 0); 311 312 elink_idseq(0xCF); 313 314 elink_reset(); 315 DELAY(10000); 316 for (i = 0; i < EP_MAX_BOARDS; i++) { 317 outb(id_port, 0); 318 outb(id_port, 0); 319 elink_idseq(0xCF); 320 321 data = get_eeprom_data(id_port, EEPROM_MFG_ID); 322 if (data != MFG_ID) 323 break; 324 325 /* resolve contention using the Ethernet address */ 326 327 for (j = 0; j < 3; j++) 328 get_eeprom_data(id_port, j); 329 330 /* and save this address for later use */ 331 332 for (j = 0; j < 3; j++) 333 ep_board[ep_boards].eth_addr[j] = get_eeprom_data(id_port, j); 334 335 ep_board[ep_boards].res_cfg = 336 get_eeprom_data(id_port, EEPROM_RESOURCE_CFG); 337 338 ep_board[ep_boards].prod_id = 339 get_eeprom_data(id_port, EEPROM_PROD_ID); 340 341 ep_board[ep_boards].epb_used = 0; 342#ifdef PC98 343 ep_board[ep_boards].epb_addr = 344 (get_eeprom_data(id_port, EEPROM_ADDR_CFG) & 0x1f) * 0x100 + 0x40d0; 345#else 346 ep_board[ep_boards].epb_addr = 347 (get_eeprom_data(id_port, EEPROM_ADDR_CFG) & 0x1f) * 0x10 + 0x200; 348 349 if (ep_board[ep_boards].epb_addr > 0x3E0) 350 /* Board in EISA configuration mode */ 351 continue; 352#endif /* PC98 */ 353 354 outb(id_port, ep_current_tag); /* tags board */ 355 outb(id_port, ACTIVATE_ADAPTER_TO_CONFIG); 356 ep_boards++; 357 count++; 358 ep_current_tag--; 359 } 360 361 ep_board[ep_boards].epb_addr = 0; 362 if (count) { 363 printf("%d 3C5x9 board(s) on ISA found at", count); 364 for (j = 0; ep_board[j].epb_addr; j++) 365 if (ep_board[j].epb_addr <= 0x3E0) 366 printf(" 0x%x", ep_board[j].epb_addr); 367 printf("\n"); 368 } 369 } 370 371 /* we have two cases: 372 * 373 * 1. Device was configured with 'port ?' 374 * In this case we search for the first unused card in list 375 * 376 * 2. Device was configured with 'port xxx' 377 * In this case we search for the unused card with that address 378 * 379 */ 380 381 if (IS_BASE == -1) { /* port? */ 382 for (i = 0; ep_board[i].epb_addr && ep_board[i].epb_used; i++) 383 ; 384 if (ep_board[i].epb_addr == 0) 385 return 0; 386 387 IS_BASE = ep_board[i].epb_addr; 388 ep_board[i].epb_used = 1; 389 390 return &ep_board[i]; 391 } else { 392 for (i = 0; 393 ep_board[i].epb_addr && ep_board[i].epb_addr != IS_BASE; 394 i++) 395 ; 396 397 if (ep_board[i].epb_used || ep_board[i].epb_addr != IS_BASE) 398 return 0; 399 400 if (inw(IS_BASE + EP_W0_EEPROM_COMMAND) & EEPROM_TST_MODE) { 401 printf("ep%d: 3c5x9 at 0x%x in PnP mode. Disable PnP mode!\n", 402 is->id_unit, IS_BASE); 403 } 404 ep_board[i].epb_used = 1; 405 406 return &ep_board[i]; 407 } 408} 409 410/* 411 * get_e: gets a 16 bits word from the EEPROM. we must have set the window 412 * before 413 */ 414u_int16_t 415get_e(sc, offset) 416 struct ep_softc *sc; 417 int offset; 418{ 419 if (!eeprom_rdy(sc)) 420 return (0xffff); 421 outw(BASE + EP_W0_EEPROM_COMMAND, EEPROM_CMD_RD | offset); 422 if (!eeprom_rdy(sc)) 423 return (0xffff); 424 return (inw(BASE + EP_W0_EEPROM_DATA)); 425} 426 427struct ep_softc * 428ep_alloc(unit, epb) 429 int unit; 430 struct ep_board *epb; 431{ 432 struct ep_softc *sc; 433 434 if (unit >= NEP) { 435 printf("ep: unit number (%d) too high\n", unit); 436 return NULL; 437 } 438 439 /* 440 * Allocate a storage area for us 441 */ 442 if (ep_softc[unit]) { 443 printf("ep%d: unit number already allocated to another " 444 "adaptor\n", unit); 445 return NULL; 446 } 447 448 sc = malloc(sizeof(struct ep_softc), M_DEVBUF, M_NOWAIT); 449 if (!sc) { 450 printf("ep%d: cannot malloc!\n", unit); 451 return NULL; 452 } 453 bzero(sc, sizeof(struct ep_softc)); 454 ep_softc[unit] = sc; 455 sc->unit = unit; 456 sc->ep_io_addr = epb->epb_addr; 457 sc->epb = epb; 458 459 return(sc); 460} 461 462void 463ep_free(sc) 464 struct ep_softc *sc; 465{ 466 ep_softc[sc->unit] = NULL; 467 free(sc, M_DEVBUF); 468 return; 469} 470 471int 472ep_isa_probe(is) 473 struct isa_device *is; 474{ 475 struct ep_softc *sc; 476 struct ep_board *epb; 477 u_short k; 478 479 if ((epb = ep_look_for_board_at(is)) == 0) 480 return (0); 481 482 /* 483 * Allocate a storage area for us 484 */ 485 sc = ep_alloc(ep_unit, epb); 486 if (!sc) 487 return (0); 488 489 is->id_unit = ep_unit++; 490 491 /* 492 * The iobase was found and MFG_ID was 0x6d50. PROD_ID should be 493 * 0x9[0-f]50 (IBM-PC) 494 * 0x9[0-f]5[0-f] (PC-98) 495 */ 496 GO_WINDOW(0); 497 k = sc->epb->prod_id; 498#ifdef PC98 499 if ((k & 0xf0f0) != (PROD_ID & 0xf0f0)) { 500#else 501 if ((k & 0xf0ff) != (PROD_ID & 0xf0ff)) { 502#endif 503 printf("ep_isa_probe: ignoring model %04x\n", k); 504 ep_free(sc); 505 return (0); 506 } 507 508 k = sc->epb->res_cfg; 509 510 k >>= 12; 511 512 /* Now we have two cases again: 513 * 514 * 1. Device was configured with 'irq?' 515 * In this case we use irq read from the board 516 * 517 * 2. Device was configured with 'irq xxx' 518 * In this case we set up the board to use specified interrupt 519 * 520 */ 521 522 if (is->id_irq == 0) { /* irq? */ 523 is->id_irq = 1 << ((k == 2) ? 9 : k); 524 } 525 526 sc->stat = 0; /* 16 bit access */ 527 528 /* By now, the adapter is already activated */ 529 530 return (EP_IOSIZE); /* 16 bytes of I/O space used. */ 531} 532 533static int 534ep_isa_attach(is) 535 struct isa_device *is; 536{ 537 struct ep_softc *sc = ep_softc[is->id_unit]; 538 u_short config; 539 int irq; 540 541 sc->ep_connectors = 0; 542 config = inw(IS_BASE + EP_W0_CONFIG_CTRL); 543 if (config & IS_AUI) { 544 sc->ep_connectors |= AUI; 545 } 546 if (config & IS_BNC) { 547 sc->ep_connectors |= BNC; 548 } 549 if (config & IS_UTP) { 550 sc->ep_connectors |= UTP; 551 } 552 if (!(sc->ep_connectors & 7)) 553 printf("no connectors!"); 554 sc->ep_connector = inw(BASE + EP_W0_ADDRESS_CFG) >> ACF_CONNECTOR_BITS; 555 /* 556 * Write IRQ value to board 557 */ 558 559 irq = ffs(is->id_irq) - 1; 560 if (irq == -1) { 561 printf(" invalid irq... cannot attach\n"); 562 return 0; 563 } 564 565 GO_WINDOW(0); 566 SET_IRQ(BASE, irq); 567 568 ep_attach(sc); 569 return 1; 570} 571 572int 573ep_attach(sc) 574 struct ep_softc *sc; 575{ 576 struct ifnet *ifp = &sc->arpcom.ac_if; 577 u_short *p; 578 int i; 579 int attached; 580 581 sc->gone = 0; 582 attached = (ifp->if_softc != 0); 583 584 printf("ep%d: ", sc->unit); 585 /* 586 * Current media type 587 */ 588 if (sc->ep_connectors & AUI) { 589 printf("aui"); 590 if (sc->ep_connectors & ~AUI) 591 printf("/"); 592 } 593 if (sc->ep_connectors & UTP) { 594 printf("utp"); 595 if (sc->ep_connectors & BNC) 596 printf("/"); 597 } 598 if (sc->ep_connectors & BNC) { 599 printf("bnc"); 600 } 601 602 printf("[*%s*]", ep_conn_type[sc->ep_connector]); 603 604 /* 605 * Setup the station address 606 */ 607 p = (u_short *) & sc->arpcom.ac_enaddr; 608 GO_WINDOW(2); 609 for (i = 0; i < 3; i++) { 610 p[i] = htons(sc->epb->eth_addr[i]); 611 outw(BASE + EP_W2_ADDR_0 + (i * 2), ntohs(p[i])); 612 } 613 printf(" address %6D\n", sc->arpcom.ac_enaddr, ":"); 614 615 ifp->if_softc = sc; 616 ifp->if_unit = sc->unit; 617 ifp->if_name = "ep"; 618 ifp->if_mtu = ETHERMTU; 619 ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; 620 ifp->if_output = ether_output; 621 ifp->if_start = epstart; 622 ifp->if_ioctl = epioctl; 623 ifp->if_watchdog = epwatchdog; 624 625 if (!attached) { 626 if_attach(ifp); 627 ether_ifattach(ifp); 628 } 629 630#ifdef EP_LOCAL_STATS 631 sc->rx_no_first = sc->rx_no_mbuf = 632 sc->rx_bpf_disc = sc->rx_overrunf = sc->rx_overrunl = 633 sc->tx_underrun = 0; 634#endif 635 ep_fset(F_RX_FIRST); 636 sc->top = sc->mcur = 0; 637 638#if NBPFILTER > 0 639 if (!attached) { 640 bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header)); 641 } 642#endif 643 return 0; 644} 645 646 647/* 648 * The order in here seems important. Otherwise we may not receive 649 * interrupts. ?! 650 */ 651static void 652epinit(sc) 653 struct ep_softc *sc; 654{ 655 register struct ifnet *ifp = &sc->arpcom.ac_if; 656 int s, i, j; 657 658 if (sc->gone) 659 return; 660 661 /* 662 if (ifp->if_addrlist == (struct ifaddr *) 0) 663 return; 664 */ 665 666 s = splimp(); 667 while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS); 668 669 GO_WINDOW(0); 670 outw(BASE + EP_COMMAND, STOP_TRANSCEIVER); 671 GO_WINDOW(4); 672 outw(BASE + EP_W4_MEDIA_TYPE, DISABLE_UTP); 673 GO_WINDOW(0); 674 675 /* Disable the card */ 676 outw(BASE + EP_W0_CONFIG_CTRL, 0); 677 678 /* Enable the card */ 679 outw(BASE + EP_W0_CONFIG_CTRL, ENABLE_DRQ_IRQ); 680 681 GO_WINDOW(2); 682 683 /* Reload the ether_addr. */ 684 for (i = 0; i < 6; i++) 685 outb(BASE + EP_W2_ADDR_0 + i, sc->arpcom.ac_enaddr[i]); 686 687 outw(BASE + EP_COMMAND, RX_RESET); 688 outw(BASE + EP_COMMAND, TX_RESET); 689 while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS); 690 691 /* Window 1 is operating window */ 692 GO_WINDOW(1); 693 for (i = 0; i < 31; i++) 694 inb(BASE + EP_W1_TX_STATUS); 695 696 /* get rid of stray intr's */ 697 outw(BASE + EP_COMMAND, ACK_INTR | 0xff); 698 699 outw(BASE + EP_COMMAND, SET_RD_0_MASK | S_5_INTS); 700 701 outw(BASE + EP_COMMAND, SET_INTR_MASK | S_5_INTS); 702 703 if (ifp->if_flags & IFF_PROMISC) 704 outw(BASE + EP_COMMAND, SET_RX_FILTER | FIL_INDIVIDUAL | 705 FIL_GROUP | FIL_BRDCST | FIL_ALL); 706 else 707 outw(BASE + EP_COMMAND, SET_RX_FILTER | FIL_INDIVIDUAL | 708 FIL_GROUP | FIL_BRDCST); 709 710 /* 711 * S.B. 712 * 713 * Now behavior was slightly changed: 714 * 715 * if any of flags link[0-2] is used and its connector is 716 * physically present the following connectors are used: 717 * 718 * link0 - AUI * highest precedence 719 * link1 - BNC 720 * link2 - UTP * lowest precedence 721 * 722 * If none of them is specified then 723 * connector specified in the EEPROM is used 724 * (if present on card or AUI if not). 725 * 726 */ 727 728 /* Set the xcvr. */ 729 if (ifp->if_flags & IFF_LINK0 && sc->ep_connectors & AUI) { 730 i = ACF_CONNECTOR_AUI; 731 } else if (ifp->if_flags & IFF_LINK1 && sc->ep_connectors & BNC) { 732 i = ACF_CONNECTOR_BNC; 733 } else if (ifp->if_flags & IFF_LINK2 && sc->ep_connectors & UTP) { 734 i = ACF_CONNECTOR_UTP; 735 } else { 736 i = sc->ep_connector; 737 } 738 GO_WINDOW(0); 739 j = inw(BASE + EP_W0_ADDRESS_CFG) & 0x3fff; 740 outw(BASE + EP_W0_ADDRESS_CFG, j | (i << ACF_CONNECTOR_BITS)); 741 742 switch(i) { 743 case ACF_CONNECTOR_UTP: 744 if (sc->ep_connectors & UTP) { 745 GO_WINDOW(4); 746 outw(BASE + EP_W4_MEDIA_TYPE, ENABLE_UTP); 747 } 748 break; 749 case ACF_CONNECTOR_BNC: 750 if (sc->ep_connectors & BNC) { 751 outw(BASE + EP_COMMAND, START_TRANSCEIVER); 752 DELAY(1000); 753 } 754 break; 755 case ACF_CONNECTOR_AUI: 756 /* nothing to do */ 757 break; 758 default: 759 printf("ep%d: strange connector type in EEPROM: assuming AUI\n", 760 sc->unit); 761 break; 762 } 763 764 outw(BASE + EP_COMMAND, RX_ENABLE); 765 outw(BASE + EP_COMMAND, TX_ENABLE); 766 767 ifp->if_flags |= IFF_RUNNING; 768 ifp->if_flags &= ~IFF_OACTIVE; /* just in case */ 769 770#ifdef EP_LOCAL_STATS 771 sc->rx_no_first = sc->rx_no_mbuf = 772 sc->rx_bpf_disc = sc->rx_overrunf = sc->rx_overrunl = 773 sc->tx_underrun = 0; 774#endif 775 ep_fset(F_RX_FIRST); 776 if (sc->top) { 777 m_freem(sc->top); 778 sc->top = sc->mcur = 0; 779 } 780 outw(BASE + EP_COMMAND, SET_RX_EARLY_THRESH | RX_INIT_EARLY_THRESH); 781 outw(BASE + EP_COMMAND, SET_TX_START_THRESH | 16); 782 783 /* 784 * Store up a bunch of mbuf's for use later. (MAX_MBS). First we free up 785 * any that we had in case we're being called from intr or somewhere 786 * else. 787 */ 788 789 GO_WINDOW(1); 790 epstart(ifp); 791 792 splx(s); 793} 794 795static const char padmap[] = {0, 3, 2, 1}; 796 797static void 798epstart(ifp) 799 struct ifnet *ifp; 800{ 801 register struct ep_softc *sc = ifp->if_softc; 802 register u_int len; 803 register struct mbuf *m; 804 struct mbuf *top; 805 int s, pad; 806 807 if (sc->gone) { 808 return; 809 } 810 811 s = splimp(); 812 while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS); 813 if (ifp->if_flags & IFF_OACTIVE) { 814 splx(s); 815 return; 816 } 817startagain: 818 /* Sneak a peek at the next packet */ 819 m = ifp->if_snd.ifq_head; 820 if (m == 0) { 821 splx(s); 822 return; 823 } 824 for (len = 0, top = m; m; m = m->m_next) 825 len += m->m_len; 826 827 pad = padmap[len & 3]; 828 829 /* 830 * The 3c509 automatically pads short packets to minimum ethernet length, 831 * but we drop packets that are too large. Perhaps we should truncate 832 * them instead? 833 */ 834 if (len + pad > ETHER_MAX_LEN) { 835 /* packet is obviously too large: toss it */ 836 ++ifp->if_oerrors; 837 IF_DEQUEUE(&ifp->if_snd, m); 838 m_freem(m); 839 goto readcheck; 840 } 841 if (inw(BASE + EP_W1_FREE_TX) < len + pad + 4) { 842 /* no room in FIFO */ 843 outw(BASE + EP_COMMAND, SET_TX_AVAIL_THRESH | (len + pad + 4)); 844 /* make sure */ 845 if (inw(BASE + EP_W1_FREE_TX) < len + pad + 4) { 846 ifp->if_flags |= IFF_OACTIVE; 847 splx(s); 848 return; 849 } 850 } 851 IF_DEQUEUE(&ifp->if_snd, m); 852 853 outw(BASE + EP_W1_TX_PIO_WR_1, len); 854 outw(BASE + EP_W1_TX_PIO_WR_1, 0x0); /* Second dword meaningless */ 855 856 for (top = m; m != 0; m = m->m_next) 857 if (ep_ftst(F_ACCESS_32_BITS)) { 858 outsl(BASE + EP_W1_TX_PIO_WR_1, mtod(m, caddr_t), 859 m->m_len / 4); 860 if (m->m_len & 3) 861 outsb(BASE + EP_W1_TX_PIO_WR_1, 862 mtod(m, caddr_t) + (m->m_len & (~3)), 863 m->m_len & 3); 864 } else { 865 outsw(BASE + EP_W1_TX_PIO_WR_1, mtod(m, caddr_t), m->m_len / 2); 866 if (m->m_len & 1) 867 outb(BASE + EP_W1_TX_PIO_WR_1, 868 *(mtod(m, caddr_t) + m->m_len - 1)); 869 } 870 871 while (pad--) 872 outb(BASE + EP_W1_TX_PIO_WR_1, 0); /* Padding */ 873 874#if NBPFILTER > 0 875 if (ifp->if_bpf) { 876 bpf_mtap(ifp, top); 877 } 878#endif 879 880 ifp->if_timer = 2; 881 ifp->if_opackets++; 882 m_freem(top); 883 884 /* 885 * Is another packet coming in? We don't want to overflow the tiny RX 886 * fifo. 887 */ 888readcheck: 889 if (inw(BASE + EP_W1_RX_STATUS) & RX_BYTES_MASK) { 890 /* 891 * we check if we have packets left, in that case we prepare to come 892 * back later 893 */ 894 if (ifp->if_snd.ifq_head) { 895 outw(BASE + EP_COMMAND, SET_TX_AVAIL_THRESH | 8); 896 } 897 splx(s); 898 return; 899 } 900 goto startagain; 901} 902 903void 904epintr(unit) 905 int unit; 906{ 907 register struct ep_softc *sc = ep_softc[unit]; 908 909 if (sc->gone) { 910 return; 911 } 912 913 ep_intr(sc); 914} 915 916void 917ep_intr(arg) 918 void *arg; 919{ 920 struct ep_softc *sc; 921 register int status; 922 struct ifnet *ifp; 923 int x; 924 925 x = splbio(); 926 927 sc = (struct ep_softc *)arg; 928 929 ifp = &sc->arpcom.ac_if; 930 931 outw(BASE + EP_COMMAND, SET_INTR_MASK); /* disable all Ints */ 932 933rescan: 934 935 while ((status = inw(BASE + EP_STATUS)) & S_5_INTS) { 936 937 /* first acknowledge all interrupt sources */ 938 outw(BASE + EP_COMMAND, ACK_INTR | (status & S_MASK)); 939 940 if (status & (S_RX_COMPLETE | S_RX_EARLY)) { 941 epread(sc); 942 continue; 943 } 944 if (status & S_TX_AVAIL) { 945 /* we need ACK */ 946 ifp->if_timer = 0; 947 ifp->if_flags &= ~IFF_OACTIVE; 948 GO_WINDOW(1); 949 inw(BASE + EP_W1_FREE_TX); 950 epstart(ifp); 951 } 952 if (status & S_CARD_FAILURE) { 953 ifp->if_timer = 0; 954#ifdef EP_LOCAL_STATS 955 printf("\nep%d:\n\tStatus: %x\n", sc->unit, status); 956 GO_WINDOW(4); 957 printf("\tFIFO Diagnostic: %x\n", inw(BASE + EP_W4_FIFO_DIAG)); 958 printf("\tStat: %x\n", sc->stat); 959 printf("\tIpackets=%d, Opackets=%d\n", 960 ifp->if_ipackets, ifp->if_opackets); 961 printf("\tNOF=%d, NOMB=%d, BPFD=%d, RXOF=%d, RXOL=%d, TXU=%d\n", 962 sc->rx_no_first, sc->rx_no_mbuf, sc->rx_bpf_disc, sc->rx_overrunf, 963 sc->rx_overrunl, sc->tx_underrun); 964#else 965 966#ifdef DIAGNOSTIC 967 printf("ep%d: Status: %x (input buffer overflow)\n", sc->unit, status); 968#else 969 ++ifp->if_ierrors; 970#endif 971 972#endif 973 epinit(sc); 974 splx(x); 975 return; 976 } 977 if (status & S_TX_COMPLETE) { 978 ifp->if_timer = 0; 979 /* we need ACK. we do it at the end */ 980 /* 981 * We need to read TX_STATUS until we get a 0 status in order to 982 * turn off the interrupt flag. 983 */ 984 while ((status = inb(BASE + EP_W1_TX_STATUS)) & TXS_COMPLETE) { 985 if (status & TXS_SUCCES_INTR_REQ); 986 else if (status & (TXS_UNDERRUN | TXS_JABBER | TXS_MAX_COLLISION)) { 987 outw(BASE + EP_COMMAND, TX_RESET); 988 if (status & TXS_UNDERRUN) { 989#ifdef EP_LOCAL_STATS 990 sc->tx_underrun++; 991#endif 992 } else { 993 if (status & TXS_JABBER); 994 else /* TXS_MAX_COLLISION - we shouldn't get here */ 995 ++ifp->if_collisions; 996 } 997 ++ifp->if_oerrors; 998 outw(BASE + EP_COMMAND, TX_ENABLE); 999 /* 1000 * To have a tx_avail_int but giving the chance to the 1001 * Reception 1002 */ 1003 if (ifp->if_snd.ifq_head) { 1004 outw(BASE + EP_COMMAND, SET_TX_AVAIL_THRESH | 8); 1005 } 1006 } 1007 outb(BASE + EP_W1_TX_STATUS, 0x0); /* pops up the next 1008 * status */ 1009 } /* while */ 1010 ifp->if_flags &= ~IFF_OACTIVE; 1011 GO_WINDOW(1); 1012 inw(BASE + EP_W1_FREE_TX); 1013 epstart(ifp); 1014 } /* end TX_COMPLETE */ 1015 } 1016 1017 outw(BASE + EP_COMMAND, C_INTR_LATCH); /* ACK int Latch */ 1018 1019 if ((status = inw(BASE + EP_STATUS)) & S_5_INTS) 1020 goto rescan; 1021 1022 /* re-enable Ints */ 1023 outw(BASE + EP_COMMAND, SET_INTR_MASK | S_5_INTS); 1024 1025 splx(x); 1026} 1027 1028static void 1029epread(sc) 1030 register struct ep_softc *sc; 1031{ 1032 struct ether_header *eh; 1033 struct mbuf *top, *mcur, *m; 1034 struct ifnet *ifp; 1035 int lenthisone; 1036 1037 short rx_fifo2, status; 1038 register short rx_fifo; 1039 1040 ifp = &sc->arpcom.ac_if; 1041 status = inw(BASE + EP_W1_RX_STATUS); 1042 1043read_again: 1044 1045 if (status & ERR_RX) { 1046 ++ifp->if_ierrors; 1047 if (status & ERR_RX_OVERRUN) { 1048 /* 1049 * we can think the rx latency is actually greather than we 1050 * expect 1051 */ 1052#ifdef EP_LOCAL_STATS 1053 if (ep_ftst(F_RX_FIRST)) 1054 sc->rx_overrunf++; 1055 else 1056 sc->rx_overrunl++; 1057#endif 1058 } 1059 goto out; 1060 } 1061 rx_fifo = rx_fifo2 = status & RX_BYTES_MASK; 1062 1063 if (ep_ftst(F_RX_FIRST)) { 1064 MGETHDR(m, M_DONTWAIT, MT_DATA); 1065 if (!m) 1066 goto out; 1067 if (rx_fifo >= MINCLSIZE) 1068 MCLGET(m, M_DONTWAIT); 1069 sc->top = sc->mcur = top = m; 1070#define EROUND ((sizeof(struct ether_header) + 3) & ~3) 1071#define EOFF (EROUND - sizeof(struct ether_header)) 1072 top->m_data += EOFF; 1073 1074 /* Read what should be the header. */ 1075 insw(BASE + EP_W1_RX_PIO_RD_1, 1076 mtod(top, caddr_t), sizeof(struct ether_header) / 2); 1077 top->m_len = sizeof(struct ether_header); 1078 rx_fifo -= sizeof(struct ether_header); 1079 sc->cur_len = rx_fifo2; 1080 } else { 1081 /* come here if we didn't have a complete packet last time */ 1082 top = sc->top; 1083 m = sc->mcur; 1084 sc->cur_len += rx_fifo2; 1085 } 1086 1087 /* Reads what is left in the RX FIFO */ 1088 while (rx_fifo > 0) { 1089 lenthisone = min(rx_fifo, M_TRAILINGSPACE(m)); 1090 if (lenthisone == 0) { /* no room in this one */ 1091 mcur = m; 1092 MGET(m, M_DONTWAIT, MT_DATA); 1093 if (!m) 1094 goto out; 1095 if (rx_fifo >= MINCLSIZE) 1096 MCLGET(m, M_DONTWAIT); 1097 m->m_len = 0; 1098 mcur->m_next = m; 1099 lenthisone = min(rx_fifo, M_TRAILINGSPACE(m)); 1100 } 1101 if (ep_ftst(F_ACCESS_32_BITS)) { /* default for EISA configured cards*/ 1102 insl(BASE + EP_W1_RX_PIO_RD_1, mtod(m, caddr_t) + m->m_len, 1103 lenthisone / 4); 1104 m->m_len += (lenthisone & ~3); 1105 if (lenthisone & 3) 1106 insb(BASE + EP_W1_RX_PIO_RD_1, 1107 mtod(m, caddr_t) + m->m_len, 1108 lenthisone & 3); 1109 m->m_len += (lenthisone & 3); 1110 } else { 1111 insw(BASE + EP_W1_RX_PIO_RD_1, mtod(m, caddr_t) + m->m_len, 1112 lenthisone / 2); 1113 m->m_len += lenthisone; 1114 if (lenthisone & 1) 1115 *(mtod(m, caddr_t) + m->m_len - 1) = inb(BASE + EP_W1_RX_PIO_RD_1); 1116 } 1117 rx_fifo -= lenthisone; 1118 } 1119 1120 if (status & ERR_RX_INCOMPLETE) { /* we haven't received the complete 1121 * packet */ 1122 sc->mcur = m; 1123#ifdef EP_LOCAL_STATS 1124 sc->rx_no_first++; /* to know how often we come here */ 1125#endif 1126 ep_frst(F_RX_FIRST); 1127 if (!((status = inw(BASE + EP_W1_RX_STATUS)) & ERR_RX_INCOMPLETE)) { 1128 /* we see if by now, the packet has completly arrived */ 1129 goto read_again; 1130 } 1131 outw(BASE + EP_COMMAND, SET_RX_EARLY_THRESH | RX_NEXT_EARLY_THRESH); 1132 return; 1133 } 1134 outw(BASE + EP_COMMAND, RX_DISCARD_TOP_PACK); 1135 ++ifp->if_ipackets; 1136 ep_fset(F_RX_FIRST); 1137 top->m_pkthdr.rcvif = &sc->arpcom.ac_if; 1138 top->m_pkthdr.len = sc->cur_len; 1139 1140#if NBPFILTER > 0 1141 if (ifp->if_bpf) { 1142 bpf_mtap(ifp, top); 1143 1144 /* 1145 * Note that the interface cannot be in promiscuous mode if there are 1146 * no BPF listeners. And if we are in promiscuous mode, we have to 1147 * check if this packet is really ours. 1148 */ 1149 eh = mtod(top, struct ether_header *); 1150 if ((ifp->if_flags & IFF_PROMISC) && 1151 (eh->ether_dhost[0] & 1) == 0 && 1152 bcmp(eh->ether_dhost, sc->arpcom.ac_enaddr, 1153 sizeof(eh->ether_dhost)) != 0 && 1154 bcmp(eh->ether_dhost, etherbroadcastaddr, 1155 sizeof(eh->ether_dhost)) != 0) { 1156 if (sc->top) { 1157 m_freem(sc->top); 1158 sc->top = 0; 1159 } 1160 ep_fset(F_RX_FIRST); 1161#ifdef EP_LOCAL_STATS 1162 sc->rx_bpf_disc++; 1163#endif 1164 while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS); 1165 outw(BASE + EP_COMMAND, SET_RX_EARLY_THRESH | RX_INIT_EARLY_THRESH); 1166 return; 1167 } 1168 } 1169#endif 1170 1171 eh = mtod(top, struct ether_header *); 1172 m_adj(top, sizeof(struct ether_header)); 1173 ether_input(ifp, eh, top); 1174 sc->top = 0; 1175 while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS); 1176 outw(BASE + EP_COMMAND, SET_RX_EARLY_THRESH | RX_INIT_EARLY_THRESH); 1177 return; 1178 1179out: 1180 outw(BASE + EP_COMMAND, RX_DISCARD_TOP_PACK); 1181 if (sc->top) { 1182 m_freem(sc->top); 1183 sc->top = 0; 1184#ifdef EP_LOCAL_STATS 1185 sc->rx_no_mbuf++; 1186#endif 1187 } 1188 ep_fset(F_RX_FIRST); 1189 while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS); 1190 outw(BASE + EP_COMMAND, SET_RX_EARLY_THRESH | RX_INIT_EARLY_THRESH); 1191} 1192 1193/* 1194 * Look familiar? 1195 */ 1196static int 1197epioctl(ifp, cmd, data) 1198 register struct ifnet *ifp; 1199 u_long cmd; 1200 caddr_t data; 1201{ 1202 register struct ifaddr *ifa = (struct ifaddr *) data; 1203 struct ep_softc *sc = ifp->if_softc; 1204 struct ifreq *ifr = (struct ifreq *) data; 1205 int s, error = 0; 1206 1207 s = splimp(); 1208 1209 switch (cmd) { 1210 case SIOCSIFADDR: 1211 ifp->if_flags |= IFF_UP; 1212 1213 /* netifs are BUSY when UP */ 1214 1215 switch (ifa->ifa_addr->sa_family) { 1216#ifdef INET 1217 case AF_INET: 1218 epinit(sc); /* before arpwhohas */ 1219 arp_ifinit((struct arpcom *)ifp, ifa); 1220 break; 1221#endif 1222#ifdef IPX 1223 case AF_IPX: 1224 { 1225 register struct ipx_addr *ina = &(IA_SIPX(ifa)->sipx_addr); 1226 1227 if (ipx_nullhost(*ina)) 1228 ina->x_host = 1229 *(union ipx_host *) (sc->arpcom.ac_enaddr); 1230 else { 1231 ifp->if_flags &= ~IFF_RUNNING; 1232 bcopy((caddr_t) ina->x_host.c_host, 1233 (caddr_t) sc->arpcom.ac_enaddr, 1234 sizeof(sc->arpcom.ac_enaddr)); 1235 } 1236 epinit(sc); 1237 break; 1238 } 1239#endif 1240#ifdef NS 1241 case AF_NS: 1242 { 1243 register struct ns_addr *ina = &(IA_SNS(ifa)->sns_addr); 1244 1245 if (ns_nullhost(*ina)) 1246 ina->x_host = 1247 *(union ns_host *) (sc->arpcom.ac_enaddr); 1248 else { 1249 ifp->if_flags &= ~IFF_RUNNING; 1250 bcopy((caddr_t) ina->x_host.c_host, 1251 (caddr_t) sc->arpcom.ac_enaddr, 1252 sizeof(sc->arpcom.ac_enaddr)); 1253 } 1254 epinit(sc); 1255 break; 1256 } 1257#endif 1258 default: 1259 epinit(sc); 1260 break; 1261 } 1262 break; 1263 case SIOCGIFADDR: 1264 { 1265 struct sockaddr *sa; 1266 1267 sa = (struct sockaddr *) & ifr->ifr_data; 1268 bcopy((caddr_t) sc->arpcom.ac_enaddr, 1269 (caddr_t) sa->sa_data, ETHER_ADDR_LEN); 1270 } 1271 break; 1272 case SIOCSIFFLAGS: 1273 1274 if ((ifp->if_flags & IFF_UP) == 0 && ifp->if_flags & IFF_RUNNING) { 1275 ifp->if_flags &= ~IFF_RUNNING; 1276 epstop(sc); 1277 break; 1278 } else { 1279 /* reinitialize card on any parameter change */ 1280 epinit(sc); 1281 break; 1282 } 1283 1284 /* NOTREACHED */ 1285 break; 1286#ifdef notdef 1287 case SIOCGHWADDR: 1288 bcopy((caddr_t) sc->sc_addr, (caddr_t) & ifr->ifr_data, 1289 sizeof(sc->sc_addr)); 1290 break; 1291#endif 1292 case SIOCSIFMTU: 1293 1294 /* 1295 * Set the interface MTU. 1296 */ 1297 if (ifr->ifr_mtu > ETHERMTU) { 1298 error = EINVAL; 1299 } else { 1300 ifp->if_mtu = ifr->ifr_mtu; 1301 } 1302 break; 1303 case SIOCADDMULTI: 1304 case SIOCDELMULTI: 1305 /* 1306 * The Etherlink III has no programmable multicast 1307 * filter. We always initialize the card to be 1308 * promiscuous to multicast, since we're always a 1309 * member of the ALL-SYSTEMS group, so there's no 1310 * need to process SIOC*MULTI requests. 1311 */ 1312 error = 0; 1313 break; 1314 default: 1315 error = EINVAL; 1316 } 1317 1318 splx(s); 1319 1320 return (error); 1321} 1322 1323static void 1324epwatchdog(ifp) 1325 struct ifnet *ifp; 1326{ 1327 struct ep_softc *sc = ifp->if_softc; 1328 1329 /* 1330 printf("ep: watchdog\n"); 1331 1332 log(LOG_ERR, "ep%d: watchdog\n", ifp->if_unit); 1333 ifp->if_oerrors++; 1334 */ 1335 1336 if (sc->gone) { 1337 return; 1338 } 1339 1340 ifp->if_flags &= ~IFF_OACTIVE; 1341 epstart(ifp); 1342 ep_intr(ifp->if_softc); 1343} 1344 1345static void 1346epstop(sc) 1347 struct ep_softc *sc; 1348{ 1349 if (sc->gone) { 1350 return; 1351 } 1352 1353 outw(BASE + EP_COMMAND, RX_DISABLE); 1354 outw(BASE + EP_COMMAND, RX_DISCARD_TOP_PACK); 1355 while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS); 1356 outw(BASE + EP_COMMAND, TX_DISABLE); 1357 outw(BASE + EP_COMMAND, STOP_TRANSCEIVER); 1358 outw(BASE + EP_COMMAND, RX_RESET); 1359 outw(BASE + EP_COMMAND, TX_RESET); 1360 while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS); 1361 outw(BASE + EP_COMMAND, C_INTR_LATCH); 1362 outw(BASE + EP_COMMAND, SET_RD_0_MASK); 1363 outw(BASE + EP_COMMAND, SET_INTR_MASK); 1364 outw(BASE + EP_COMMAND, SET_RX_FILTER); 1365} 1366 1367 1368#if 0 1369static int 1370send_ID_sequence(port) 1371 int port; 1372{ 1373 int cx, al; 1374 1375 for (al = 0xff, cx = 0; cx < 255; cx++) { 1376 outb(port, al); 1377 al <<= 1; 1378 if (al & 0x100) 1379 al ^= 0xcf; 1380 } 1381 return (1); 1382} 1383#endif 1384 1385 1386/* 1387 * We get eeprom data from the id_port given an offset into the eeprom. 1388 * Basically; after the ID_sequence is sent to all of the cards; they enter 1389 * the ID_CMD state where they will accept command requests. 0x80-0xbf loads 1390 * the eeprom data. We then read the port 16 times and with every read; the 1391 * cards check for contention (ie: if one card writes a 0 bit and another 1392 * writes a 1 bit then the host sees a 0. At the end of the cycle; each card 1393 * compares the data on the bus; if there is a difference then that card goes 1394 * into ID_WAIT state again). In the meantime; one bit of data is returned in 1395 * the AX register which is conveniently returned to us by inb(). Hence; we 1396 * read 16 times getting one bit of data with each read. 1397 */ 1398static int 1399get_eeprom_data(id_port, offset) 1400 int id_port; 1401 int offset; 1402{ 1403 int i, data = 0; 1404 outb(id_port, 0x80 + offset); 1405 DELAY(1000); 1406 for (i = 0; i < 16; i++) 1407 data = (data << 1) | (inw(id_port) & 1); 1408 return (data); 1409} 1410 1411#endif /* NEP > 0 */ 1412