|
@@ -20,6 +20,9 @@
|
|
|
|
|
|
static Ether *etherxx[MaxEther];
|
|
|
|
|
|
+extern Ether *archetherprobe(int ctlrno, char *type, int (*reset)(Ether *));
|
|
|
+extern void archethershutdown(Ether *ether);
|
|
|
+
|
|
|
Chan*
|
|
|
etherattach(char* spec)
|
|
|
{
|
|
@@ -377,72 +380,12 @@ parseether(uint8_t *to, char *from)
|
|
|
static Ether*
|
|
|
etherprobe(int cardno, int ctlrno)
|
|
|
{
|
|
|
- int i, j;
|
|
|
- Ether *ether;
|
|
|
- char buf[128], name[32];
|
|
|
-
|
|
|
- ether = malloc(sizeof(Ether));
|
|
|
- memset(ether, 0, sizeof(Ether));
|
|
|
- ether->ctlrno = ctlrno;
|
|
|
- ether->tbdf = BUSUNKNOWN;
|
|
|
- ether->Netif.mbps = 10;
|
|
|
- ether->Netif.minmtu = ETHERMINTU;
|
|
|
- ether->Netif.mtu = ETHERMAXTU;
|
|
|
- ether->Netif.maxmtu = ETHERMAXTU;
|
|
|
-
|
|
|
- if(cardno >= MaxEther || cards[cardno].type == nil){
|
|
|
- free(ether);
|
|
|
+
|
|
|
+ if(cardno >= MaxEther)
|
|
|
return nil;
|
|
|
- }
|
|
|
- if(cards[cardno].reset(ether) < 0){
|
|
|
- free(ether);
|
|
|
+ if(cards[cardno].type == nil || cards[cardno].reset == nil)
|
|
|
return nil;
|
|
|
- }
|
|
|
-
|
|
|
- /*
|
|
|
- * IRQ2 doesn't really exist, it's used to gang the interrupt
|
|
|
- * controllers together. A device set to IRQ2 will appear on
|
|
|
- * the second interrupt controller as IRQ9.
|
|
|
- */
|
|
|
- if(ether->ISAConf.irq == 2)
|
|
|
- ether->ISAConf.irq = 9;
|
|
|
- snprint(name, sizeof(name), "ether%d", ctlrno);
|
|
|
-
|
|
|
- /*
|
|
|
- * If ether->irq is <0, it is a hack to indicate no interrupt
|
|
|
- * used by ethersink.
|
|
|
- */
|
|
|
- if(ether->ISAConf.irq >= 0)
|
|
|
- intrenable(ether->ISAConf.irq, ether->interrupt, ether, ether->tbdf, name);
|
|
|
-
|
|
|
- i = sprint(buf, "#l%d: %s: %dMbps port %#p irq %d tu %d",
|
|
|
- ctlrno, cards[cardno].type, ether->Netif.mbps, ether->ISAConf.port, ether->ISAConf.irq, ether->Netif.mtu);
|
|
|
- if(ether->ISAConf.mem)
|
|
|
- i += sprint(buf+i, " addr %#p", ether->ISAConf.mem);
|
|
|
- if(ether->ISAConf.size)
|
|
|
- i += sprint(buf+i, " size 0x%lX", ether->ISAConf.size);
|
|
|
- i += sprint(buf+i, ": %2.2x%2.2x%2.2x%2.2x%2.2x%2.2x",
|
|
|
- ether->ea[0], ether->ea[1], ether->ea[2],
|
|
|
- ether->ea[3], ether->ea[4], ether->ea[5]);
|
|
|
- sprint(buf+i, "\n");
|
|
|
- print(buf);
|
|
|
-
|
|
|
- j = ether->Netif.mbps;
|
|
|
- if(j > 1000)
|
|
|
- j *= 10;
|
|
|
- for(i = 0; j >= 100; i++)
|
|
|
- j /= 10;
|
|
|
- i = (128<<i)*1024;
|
|
|
- netifinit(ðer->Netif, name, Ntypes, i);
|
|
|
- if(ether->oq == 0)
|
|
|
- ether->oq = qopen(i, Qmsg, 0, 0);
|
|
|
- if(ether->oq == 0)
|
|
|
- panic("etherreset %s", name);
|
|
|
- ether->Netif.alen = Eaddrlen;
|
|
|
- memmove(ether->Netif.addr, ether->ea, Eaddrlen);
|
|
|
- memset(ether->Netif.bcast, 0xFF, Eaddrlen);
|
|
|
-
|
|
|
- return ether;
|
|
|
+ return archetherprobe(ctlrno, cards[cardno].type, cards[cardno].reset);
|
|
|
}
|
|
|
|
|
|
static void
|
|
@@ -482,9 +425,7 @@ ethershutdown(void)
|
|
|
continue;
|
|
|
}
|
|
|
snprint(name, sizeof(name), "ether%d", i);
|
|
|
- if(ether->ISAConf.irq >= 0){
|
|
|
- // intrdisable(ether->irq, ether->interrupt, ether, ether->tbdf, name);
|
|
|
- }
|
|
|
+ archethershutdown(ether);
|
|
|
(*ether->shutdown)(ether);
|
|
|
}
|
|
|
}
|