2 * Supposed NE2000 PCMCIA clones, see the comments in ether2000.c
5 #include "../port/lib.h"
10 #include "../port/error.h"
11 #include "../port/netif.h"
14 #include "ether8390.h"
17 Data = 0x10, /* offset from I/O base of data port */
18 Reset = 0x1F, /* offset from I/O base of reset port */
26 static Ec2t ec2tpcmcia[] = {
27 { "EC2T", 0, }, /* Linksys Combo PCMCIA EthernetCard */
28 { "PCMPC100", 1, }, /* EtherFast 10/100 PC Card */
29 { "PCM100", 1, }, /* EtherFast PCM100 Card */
30 { "EN2216", 0, }, /* Accton EtherPair-PCMCIA */
31 { "FA410TX", 1, }, /* Netgear FA410TX */
32 { "FA411", 0 }, /* Netgear FA411 PCMCIA */
33 { "Network Everywhere", 0, }, /* Linksys NP10T 10BaseT Card */
34 { "10/100 Port Attached", 1, }, /* SMC 8040TX */
35 { "8041TX-10/100-PC-Card-V2", 0 }, /* SMC 8041TX */
36 { "SMC8022", 0}, /* SMC 8022 / EZCard-10-PCMCIA */
47 uchar ea[Eaddrlen], sum, x;
51 * Set up the software configuration.
52 * Use defaults for port, irq, mem and size
54 * The manual says 16KB memory, the box
55 * says 32KB. The manual seems to be correct.
64 ether->size = 16*1024;
67 if(ioalloc(ether->port, 0x20, 0, "ec2t") < 0)
70 for(ec2t = ec2tpcmcia; ec2t->name != nil; ec2t++){
71 if((slot = pcmspecial(ec2t->name, ether)) >= 0)
74 if(ec2t->name == nil){
78 for(i = 0; i < ether->nopt; i++){
79 if(cistrncmp(ether->opt[i], "id=", 3) == 0){
80 ec2t->name = ðer->opt[i][3];
81 slot = pcmspecial(ec2t->name, ether);
83 else if(cistrncmp(ether->opt[i], "iochecksum", 10) == 0)
87 ctlr = malloc(sizeof(Dp8390));
88 if(ctlr == nil || slot < 0){
98 ctlr->data = port+Data;
100 ctlr->tstart = HOWMANY(ether->mem, Dp8390BufSz);
101 ctlr->pstart = ctlr->tstart + HOWMANY(sizeof(Etherpkt), Dp8390BufSz);
102 ctlr->pstop = ctlr->tstart + HOWMANY(ether->size, Dp8390BufSz);
105 for(i = 0; i < ether->nopt; i++){
106 if(cistrcmp(ether->opt[i], "nodummyrr") == 0)
108 else if(cistrncmp(ether->opt[i], "dummyrr=", 8) == 0)
109 ctlr->dummyrr = strtol(ðer->opt[i][8], nil, 0);
113 * Reset the board. This is done by doing a read
114 * followed by a write to the Reset address.
116 buf[0] = inb(port+Reset);
118 outb(port+Reset, buf[0]);
122 * Init the (possible) chip, then use the (possible)
123 * chip to read the (possible) PROM for ethernet address
125 * Could just look at the DP8390 command register after
126 * initialisation has been tried, but that wouldn't be
127 * enough, there are other ethernet boards which could
132 if(ec2t->iochecksum){
134 * These cards have the ethernet address in I/O space.
135 * There's a checksum over 8 bytes which sums to 0xFF.
137 for(i = 0; i < 8; i++){
138 x = inb(port+0x14+i);
144 memset(buf, 0, sizeof(buf));
145 dp8390read(ctlr, buf, 0, sizeof(buf));
146 if((buf[0x0E] & 0xFF) == 0x57 && (buf[0x0F] & 0xFF) == 0x57)
150 pcmspecialclose(slot);
157 * Stupid machine. Shorts were asked for,
158 * shorts were delivered, although the PROM is a byte array.
159 * Set the ethernet address.
161 memset(ea, 0, Eaddrlen);
162 if(memcmp(ea, ether->ea, Eaddrlen) == 0){
163 for(i = 0; i < sizeof(ether->ea); i++)
164 ether->ea[i] = buf[i];
174 addethercard("EC2T", reset);