static int readnodeid(int slot, Ether* ether) { uchar data[Eaddrlen + 1]; int len; len = sizeof(data); if (pcmcistuple(slot, TupleFunce, TfNodeId, data, len) != len) return -1; if (data[0] != Eaddrlen) return -1; memmove(ether->ea, &data[1], Eaddrlen); return 0; }
static int reset(Ether* ether) { int i, t, slot; char *type; int port; enum { WantAny, Want10BT, Want10B2 }; int want; uchar ea[6]; char *p; if(ether->irq == 0) ether->irq = 10; if(ether->port == 0) ether->port = 0x240; port = ether->port; if(ioalloc(port, 0x10, 0, "3C589") < 0) return -1; type = nil; slot = -1; for(i = 0; tcmpcmcia[i] != nil; i++){ type = tcmpcmcia[i]; if((slot = pcmspecial(type, ether)) >= 0) break; } if(slot < 0){ iofree(port); return -1; } /* * Read Ethernet address from card memory * on 3C562, but only if the user has not * overridden it. */ memset(ea, 0, sizeof ea); if(memcmp(ea, ether->ea, 6) == 0 && strcmp(type, "3C562") == 0) { if(pcmcistuple(slot, 0x88, -1, ea, 6) == 6) { for(i = 0; i < 6; i += 2){ t = ea[i]; ea[i] = ea[i+1]; ea[i+1] = t; } memmove(ether->ea, ea, 6); } } /* * Allow user to specify desired media in plan9.ini */ want = WantAny; for(i = 0; i < ether->nopt; i++){ if(cistrncmp(ether->opt[i], "media=", 6) != 0) continue; p = ether->opt[i]+6; if(cistrcmp(p, "10base2") == 0) want = Want10B2; else if(cistrcmp(p, "10baseT") == 0) want = Want10BT; } /* try configuring as a 10BaseT */ if(want==WantAny || want==Want10BT){ if(configASIC(ether, port, xcvr10BaseT) < 0){ pcmspecialclose(slot); iofree(port); return -1; } delay(100); COMMAND(port, SelectRegisterWindow, Wdiagnostic); if((ins(port+MediaStatus)&linkBeatDetect) || want==Want10BT){ COMMAND(port, SelectRegisterWindow, Wop); print("#l%d: xcvr10BaseT %s\n", ether->ctlrno, type); return 0; } } /* try configuring as a 10base2 */ if(want==WantAny || want==Want10B2){ COMMAND(port, GlobalReset, 0); if(configASIC(ether, port, xcvr10Base2) < 0){ pcmspecialclose(slot); iofree(port); return -1; } print("#l%d: xcvr10Base2 %s\n", ether->ctlrno, type); return 0; } return -1; /* not reached */ }