| plan 9 kernel history: overview | file list | diff list |
1993/0212/pc/devether.c (diff list | history)
| 1992/1222/sys/src/9/pc/devether.c:15,34 – 1993/0212/sys/src/9/pc/devether.c:15,34 (short | long | prev | next) | ||
| 1992/0922 | * handle multiple controllers * much tidying * set ethernet address | |
| 1993/0212 | * need a ctl file passed down to card drivers * so we can set options. | |
| 1992/0922 | */ | |
| 1992/1222 |
| |
| 1993/0212 | extern Card ether8003, ether503, ether2000; extern Card ether509; | |
| 1992/0403 | ||
| 1992/1222 | /* | |
| 1993/0212 | * The ordering here is important for those cards * using the DP8390 (WD8003, 3Com503 and NE2000) as * attempting to determine if a card is a NE2000 | |
| 1992/1222 | * cannot be done passively, so it must be last to * prevent scrogging one of the others. */ | |
| 1993/0212 | static Card *cards[] = { | |
| 1992/1222 | ðer8003, ðer503, ðer2000, | |
| 1992/1222/sys/src/9/pc/devether.c:41,47 – 1993/0212/sys/src/9/pc/devether.c:41,47 | ||
| 1992/1222 | NCtlr = 1, | |
| 1992/0424 | }; | |
| 1992/0403 | ||
| 1992/1222 |
| |
| 1993/0212 | /*static */struct Ctlr *softctlr[NCtlr]; | |
| 1992/1222 | static int nctlr; | |
| 1992/0922 | ||
| 1992/0425 | Chan* | |
| 1992/1222/sys/src/9/pc/devether.c:123,129 – 1993/0212/sys/src/9/pc/devether.c:123,129 | ||
| 1992/1222 | Type *type; Etherpkt *pkt; RingBuf *ring; | |
| 1992/0922 |
| |
| 1993/0212 | int len, n, s; | |
| 1992/0403 | Block *nbp; | |
| 1992/1222 | type = q->ptr; | |
| 1992/1222/sys/src/9/pc/devether.c:141,147 – 1993/0212/sys/src/9/pc/devether.c:141,147 | ||
| 1992/1222 | type->prom = 1; ctlr->prom++; if(ctlr->prom == 1) | |
| 1993/0212 | (*ctlr->card.mode)(ctlr, 1); | |
| 1992/0403 | } | |
| 1992/1222 | qunlock(ctlr); | |
| 1992/0403 | freeb(bp); | |
| 1992/1222/sys/src/9/pc/devether.c:179,186 – 1993/0212/sys/src/9/pc/devether.c:179,186 | ||
| 1992/0403 | */ | |
| 1992/1222 | qlock(&ctlr->tlock); | |
| 1992/0403 | if(waserror()){ | |
| 1992/0411 |
| |
| 1992/1222 | qunlock(&ctlr->tlock); | |
| 1993/0212 | freeb(bp); | |
| 1992/0403 | nexterror(); } | |
| 1992/1222/sys/src/9/pc/devether.c:188,194 – 1993/0212/sys/src/9/pc/devether.c:188,202 | ||
| 1992/1222 | * Wait till we get an output buffer. | |
| 1992/0424 | * should try to restart. | |
| 1992/0403 | */ | |
| 1992/1222 |
| |
| 1993/0212 | if(isobuf(ctlr) == 0){ tsleep(&ctlr->tr, isobuf, ctlr, 3*1000); if(isobuf(ctlr) == 0){ qunlock(&ctlr->tlock); freeb(bp); poperror(); return; } } | |
| 1992/0403 | ||
| 1992/1222 | ring = &ctlr->tb[ctlr->th]; | |
| 1992/0424 | ||
| 1992/1222/sys/src/9/pc/devether.c:217,230 – 1993/0212/sys/src/9/pc/devether.c:225,239 | ||
| 1992/1222 | * Set up the transmit buffer and * start the transmission. | |
| 1992/0403 | */ | |
| 1992/1222 |
| |
| 1993/0212 | s = splhi(); | |
| 1992/1222 | ring->len = len; ring->owner = Interface; ctlr->th = NEXT(ctlr->th, ctlr->ntb); | |
| 1993/0212 | (*ctlr->card.transmit)(ctlr); splx(s); | |
| 1992/0403 |
| |
| 1992/1222 | qunlock(&ctlr->tlock); | |
| 1993/0212 | freeb(bp); | |
| 1992/0403 | poperror(); } | |
| 1992/1222/sys/src/9/pc/devether.c:267,273 – 1993/0212/sys/src/9/pc/devether.c:276,282 | ||
| 1992/1222 | qlock(ctlr); ctlr->prom--; if(ctlr->prom == 0) | |
| 1993/0212 | (*ctlr->card.mode)(ctlr, 0); | |
| 1992/1222 | qunlock(ctlr); } if(type->type == -1){ | |
| 1992/1222/sys/src/9/pc/devether.c:407,414 – 1993/0212/sys/src/9/pc/devether.c:416,423 | ||
| 1992/0403 | if(waserror()){ | |
| 1992/1222 | print("%s noted\n", ctlr->name); /* fix | |
| 1993/0212 | if(ctlr->card.reset) (*ctlr->card.reset)(ctlr); | |
| 1992/1222 | */ ctlr->kproc = 0; | |
| 1992/0403 | nexterror(); | |
| 1992/1222/sys/src/9/pc/devether.c:416,423 – 1993/0212/sys/src/9/pc/devether.c:425,432 | ||
| 1992/1222 | ||
| 1992/0403 | for(;;){ | |
| 1992/1222 | tsleep(&ctlr->rr, isinput, ctlr, 500); | |
| 1993/0212 | if(ctlr->card.watch) (*ctlr->card.watch)(ctlr); | |
| 1992/0424 | ||
| 1992/0406 | /* | |
| 1992/1222 | * Process any internal loopback packets. | |
| 1992/1222/sys/src/9/pc/devether.c:460,466 – 1993/0212/sys/src/9/pc/devether.c:469,475 | ||
| 1992/1222 | Ctlr *ctlr = softctlr[0]; | |
| 1992/0922 | USED(ur); | |
| 1992/1222 |
| |
| 1993/0212 | (*ctlr->card.intr)(ctlr); | |
| 1992/0922 | } | |
| 1992/0424 | void | |
| 1992/1222/sys/src/9/pc/devether.c:467,481 – 1993/0212/sys/src/9/pc/devether.c:476,493 | ||
| 1992/0424 | etherreset(void) { | |
| 1992/1222 | Ctlr *ctlr; | |
| 1993/0212 | Card **card; | |
| 1992/0625 | int i; | |
| 1992/0410 | ||
| 1993/0212 | if(nctlr >= NCtlr) return; | |
| 1992/1222 | if(softctlr[nctlr] == 0) softctlr[nctlr] = xalloc(sizeof(Ctlr)); ctlr = softctlr[nctlr]; | |
| 1993/0212 | for(card = cards; *card; card++){ memset(ctlr, 0, sizeof(Ctlr)); ctlr->card = **card; if((*ctlr->card.reset)(ctlr) == 0){ | |
| 1992/1222 | ctlr->present = 1; /* | |
| 1992/1222/sys/src/9/pc/devether.c:483,496 – 1993/0212/sys/src/9/pc/devether.c:495,517 | ||
| 1992/1222 | * controllers together. A device set to IRQ2 will appear on * the second interrupt controller as IRQ9. */ | |
| 1993/0212 | if(ctlr->card.irq == 2) ctlr->card.irq = 9; setvec(Int0vec + ctlr->card.irq, etherintr); | |
| 1992/0922 | break; } | |
| 1992/0917 | } | |
| 1992/1222 | if(ctlr->present == 0) | |
| 1992/0922 | return; | |
| 1993/0212 | print("ether%d: %s: I/O addr %lux width %d addr %lux size %d irq %d:", nctlr, ctlr->card.id, ctlr->card.io, ctlr->card.bit16 ? 16: 8, ctlr->card.ramstart, ctlr->card.ramstop-ctlr->card.ramstart, ctlr->card.irq); for(i = 0; i < sizeof(ctlr->ea); i++) print(" %2.2ux", ctlr->ea[i]); print("\n"); | |
| 1992/1222 | nctlr++; | |
| 1992/0410 | ||
| 1992/1222 | if(ctlr->nrb == 0) | |
| 1992/1222/sys/src/9/pc/devether.c:551,557 – 1993/0212/sys/src/9/pc/devether.c:572,578 | ||
| 1992/1222 | * Enable the interface * and start the kproc. | |
| 1992/0501 | */ | |
| 1992/1222 |
| |
| 1993/0212 | (*ctlr->card.attach)(ctlr); | |
| 1992/1222 | if(ctlr->kproc == 0){ sprint(ctlr->name, "ether%dkproc", ctlrno); ctlr->kproc = 1; | |