2 * Supposed NE2000 PCMCIA clones, see the comments in ether2000.c
12 #include "ether8390.h"
15 Data = 0x10, /* offset from I/O base of data port */
16 Reset = 0x1F, /* offset from I/O base of reset port */
19 static char* ec2tpcmcia[] = {
20 { "EC2T" }, /* Linksys Combo PCMCIA EthernetCard */
21 { "PCMPC100" }, /* EtherFast 10/100 PC Card */
22 { "PCM100" }, /* EtherFast PCM100 Card */
23 { "EN2216" }, /* Accton EtherPair-PCMCIA */
24 { "FA410TX" }, /* Netgear FA410TX */
25 { "FA411" }, /* Netgear FA411 PCMCIA */
26 { "Network Everywhere" }, /* Linksys NP10T 10BaseT Card */
27 { "10/100 Port Attached" }, /* SMC 8040TX */
28 { "8041TX-10/100-PC-Card-V2" }, /* SMC 8041TX */
29 { "SMC8022" }, /* SMC 8022 / EZCard-10-PCMCIA */
34 ec2treset(Ether* ether)
40 uchar ea[Eaddrlen], sum, x;
44 * Set up the software configuration.
45 * Use defaults for port, irq, mem and size
47 * The manual says 16KB memory, the box
48 * says 32KB. The manual seems to be correct.
57 ether->size = 16*1024;
60 //if(ioalloc(ether->port, 0x20, 0, "ec2t") < 0)
64 for(i = 0; ec2tpcmcia[i] != nil; i++){
66 if((slot = pcmspecial(type, ether)) >= 0)
69 if(ec2tpcmcia[i] == nil){
70 for(i = 0; i < ether->nopt; i++){
71 if(cistrncmp(ether->opt[i], "id=", 3))
73 type = ðer->opt[i][3];
74 if((slot = pcmspecial(type, ether)) >= 0)
83 ether->ctlr = malloc(sizeof(Dp8390));
89 ctlr->data = port+Data;
91 ctlr->tstart = HOWMANY(ether->mem, Dp8390BufSz);
92 ctlr->pstart = ctlr->tstart + HOWMANY(sizeof(Etherpkt), Dp8390BufSz);
93 ctlr->pstop = ctlr->tstart + HOWMANY(ether->size, Dp8390BufSz);
96 for(i = 0; i < ether->nopt; i++){
97 if(cistrcmp(ether->opt[i], "nodummyrr") == 0)
99 else if(cistrncmp(ether->opt[i], "dummyrr=", 8) == 0)
100 ctlr->dummyrr = strtol(ðer->opt[i][8], nil, 0);
104 * Reset the board. This is done by doing a read
105 * followed by a write to the Reset address.
107 buf[0] = inb(port+Reset);
109 outb(port+Reset, buf[0]);
113 * Init the (possible) chip, then use the (possible)
114 * chip to read the (possible) PROM for ethernet address
116 * Could just look at the DP8390 command register after
117 * initialisation has been tried, but that wouldn't be
118 * enough, there are other ethernet boards which could
123 if(cistrcmp(type, "PCMPC100") == 0 || cistrcmp(type, "FA410TX") == 0){
125 * The PCMPC100 has the ethernet address in I/O space.
126 * There's a checksum over 8 bytes which sums to 0xFF.
128 for(i = 0; i < 8; i++){
129 x = inb(port+0x14+i);
135 memset(buf, 0, sizeof(buf));
136 dp8390read(ctlr, buf, 0, sizeof(buf));
137 if((buf[0x0E] & 0xFF) == 0x57 && (buf[0x0F] & 0xFF) == 0x57)
141 pcmspecialclose(slot);
142 //iofree(ether->port);
148 * Stupid machine. Shorts were asked for,
149 * shorts were delivered, although the PROM is a byte array.
150 * Set the ethernet address.
152 memset(ea, 0, Eaddrlen);
153 if(memcmp(ea, ether->ea, Eaddrlen) == 0){
154 for(i = 0; i < sizeof(ether->ea); i++)
155 ether->ea[i] = buf[i];