aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/mac8390.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/net/mac8390.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'drivers/net/mac8390.c')
-rw-r--r--drivers/net/mac8390.c757
1 files changed, 757 insertions, 0 deletions
diff --git a/drivers/net/mac8390.c b/drivers/net/mac8390.c
new file mode 100644
index 000000000000..ce5761816a64
--- /dev/null
+++ b/drivers/net/mac8390.c
@@ -0,0 +1,757 @@
1/* mac8390.c: New driver for 8390-based Nubus (or Nubus-alike)
2 Ethernet cards on Linux */
3/* Based on the former daynaport.c driver, by Alan Cox. Some code
4 taken from or inspired by skeleton.c by Donald Becker, acenic.c by
5 Jes Sorensen, and ne2k-pci.c by Donald Becker and Paul Gortmaker.
6
7 This software may be used and distributed according to the terms of
8 the GNU Public License, incorporated herein by reference. */
9
10/* 2000-02-28: support added for Dayna and Kinetics cards by
11 A.G.deWijn@phys.uu.nl */
12/* 2000-04-04: support added for Dayna2 by bart@etpmod.phys.tue.nl */
13/* 2001-04-18: support for DaynaPort E/LC-M by rayk@knightsmanor.org */
14/* 2001-05-15: support for Cabletron ported from old daynaport driver
15 * and fixed access to Sonic Sys card which masquerades as a Farallon
16 * by rayk@knightsmanor.org */
17
18#include <linux/version.h>
19#include <linux/module.h>
20#include <linux/kernel.h>
21#include <linux/types.h>
22#include <linux/fcntl.h>
23#include <linux/interrupt.h>
24#include <linux/ptrace.h>
25#include <linux/ioport.h>
26#include <linux/nubus.h>
27#include <linux/in.h>
28#include <linux/slab.h>
29#include <linux/string.h>
30#include <linux/errno.h>
31#include <linux/init.h>
32#include <linux/netdevice.h>
33#include <linux/etherdevice.h>
34#include <linux/skbuff.h>
35#include <linux/bitops.h>
36
37#include <asm/system.h>
38#include <asm/io.h>
39#include <asm/dma.h>
40#include <asm/hwtest.h>
41#include <asm/macints.h>
42
43#include "8390.h"
44
45#define WD_START_PG 0x00 /* First page of TX buffer */
46#define CABLETRON_RX_START_PG 0x00 /* First page of RX buffer */
47#define CABLETRON_RX_STOP_PG 0x30 /* Last page +1 of RX ring */
48#define CABLETRON_TX_START_PG CABLETRON_RX_STOP_PG /* First page of TX buffer */
49
50/* Unfortunately it seems we have to hardcode these for the moment */
51/* Shouldn't the card know about this? Does anyone know where to read it off the card? Do we trust the data provided by the card? */
52
53#define DAYNA_8390_BASE 0x80000
54#define DAYNA_8390_MEM 0x00000
55
56#define KINETICS_8390_BASE 0x80000
57#define KINETICS_8390_MEM 0x00000
58
59#define CABLETRON_8390_BASE 0x90000
60#define CABLETRON_8390_MEM 0x00000
61
62enum mac8390_type {
63 MAC8390_NONE = -1,
64 MAC8390_APPLE,
65 MAC8390_ASANTE,
66 MAC8390_FARALLON, /* Apple, Asante, and Farallon are all compatible */
67 MAC8390_CABLETRON,
68 MAC8390_DAYNA,
69 MAC8390_INTERLAN,
70 MAC8390_KINETICS,
71 MAC8390_FOCUS,
72 MAC8390_SONICSYS,
73 MAC8390_DAYNA2,
74 MAC8390_DAYNA3,
75};
76
77static const char * cardname[] = {
78 "apple",
79 "asante",
80 "farallon",
81 "cabletron",
82 "dayna",
83 "interlan",
84 "kinetics",
85 "focus",
86 "sonic systems",
87 "dayna2",
88 "dayna_lc",
89};
90
91static int word16[] = {
92 1, /* apple */
93 1, /* asante */
94 1, /* farallon */
95 1, /* cabletron */
96 0, /* dayna */
97 1, /* interlan */
98 0, /* kinetics */
99 1, /* focus (??) */
100 1, /* sonic systems */
101 1, /* dayna2 */
102 1, /* dayna-lc */
103};
104
105/* on which cards do we use NuBus resources? */
106static int useresources[] = {
107 1, /* apple */
108 1, /* asante */
109 1, /* farallon */
110 0, /* cabletron */
111 0, /* dayna */
112 0, /* interlan */
113 0, /* kinetics */
114 0, /* focus (??) */
115 1, /* sonic systems */
116 1, /* dayna2 */
117 1, /* dayna-lc */
118};
119
120static char version[] __initdata =
121 "mac8390.c: v0.4 2001-05-15 David Huggins-Daines <dhd@debian.org> and others\n";
122
123extern enum mac8390_type mac8390_ident(struct nubus_dev * dev);
124extern int mac8390_memsize(unsigned long membase);
125extern int mac8390_memtest(struct net_device * dev);
126static int mac8390_initdev(struct net_device * dev, struct nubus_dev * ndev,
127 enum mac8390_type type);
128
129static int mac8390_open(struct net_device * dev);
130static int mac8390_close(struct net_device * dev);
131static void mac8390_no_reset(struct net_device *dev);
132
133/* Sane (32-bit chunk memory read/write) - Apple/Asante/Farallon do this*/
134static void sane_get_8390_hdr(struct net_device *dev,
135 struct e8390_pkt_hdr *hdr, int ring_page);
136static void sane_block_input(struct net_device * dev, int count,
137 struct sk_buff * skb, int ring_offset);
138static void sane_block_output(struct net_device * dev, int count,
139 const unsigned char * buf, const int start_page);
140
141/* dayna_memcpy to and from card */
142static void dayna_memcpy_fromcard(struct net_device *dev, void *to,
143 int from, int count);
144static void dayna_memcpy_tocard(struct net_device *dev, int to,
145 const void *from, int count);
146
147/* Dayna - Dayna/Kinetics use this */
148static void dayna_get_8390_hdr(struct net_device *dev,
149 struct e8390_pkt_hdr *hdr, int ring_page);
150static void dayna_block_input(struct net_device *dev, int count,
151 struct sk_buff *skb, int ring_offset);
152static void dayna_block_output(struct net_device *dev, int count,
153 const unsigned char *buf, int start_page);
154
155#define memcpy_fromio(a,b,c) memcpy((a),(void *)(b),(c))
156#define memcpy_toio(a,b,c) memcpy((void *)(a),(b),(c))
157
158/* Slow Sane (16-bit chunk memory read/write) Cabletron uses this */
159static void slow_sane_get_8390_hdr(struct net_device *dev,
160 struct e8390_pkt_hdr *hdr, int ring_page);
161static void slow_sane_block_input(struct net_device *dev, int count,
162 struct sk_buff *skb, int ring_offset);
163static void slow_sane_block_output(struct net_device *dev, int count,
164 const unsigned char *buf, int start_page);
165static void word_memcpy_tocard(void *tp, const void *fp, int count);
166static void word_memcpy_fromcard(void *tp, const void *fp, int count);
167
168enum mac8390_type __init mac8390_ident(struct nubus_dev * dev)
169{
170 if (dev->dr_sw == NUBUS_DRSW_ASANTE)
171 return MAC8390_ASANTE;
172 if (dev->dr_sw == NUBUS_DRSW_FARALLON)
173 return MAC8390_FARALLON;
174 if (dev->dr_sw == NUBUS_DRSW_KINETICS)
175 return MAC8390_KINETICS;
176 if (dev->dr_sw == NUBUS_DRSW_DAYNA)
177 return MAC8390_DAYNA;
178 if (dev->dr_sw == NUBUS_DRSW_DAYNA2)
179 return MAC8390_DAYNA2;
180 if (dev->dr_sw == NUBUS_DRSW_DAYNA_LC)
181 return MAC8390_DAYNA3;
182 if (dev->dr_hw == NUBUS_DRHW_CABLETRON)
183 return MAC8390_CABLETRON;
184 return MAC8390_NONE;
185}
186
187int __init mac8390_memsize(unsigned long membase)
188{
189 unsigned long flags;
190 int i, j;
191
192 local_irq_save(flags);
193 /* Check up to 32K in 4K increments */
194 for (i = 0; i < 8; i++) {
195 volatile unsigned short *m = (unsigned short *) (membase + (i * 0x1000));
196
197 /* Unwriteable - we have a fully decoded card and the
198 RAM end located */
199 if (hwreg_present(m) == 0)
200 break;
201
202 /* write a distinctive byte */
203 *m = 0xA5A0 | i;
204 /* check that we read back what we wrote */
205 if (*m != (0xA5A0 | i))
206 break;
207
208 /* check for partial decode and wrap */
209 for (j = 0; j < i; j++) {
210 volatile unsigned short *p = (unsigned short *) (membase + (j * 0x1000));
211 if (*p != (0xA5A0 | j))
212 break;
213 }
214 }
215 local_irq_restore(flags);
216 /* in any case, we stopped once we tried one block too many,
217 or once we reached 32K */
218 return i * 0x1000;
219}
220
221struct net_device * __init mac8390_probe(int unit)
222{
223 struct net_device *dev;
224 volatile unsigned short *i;
225 int version_disp = 0;
226 struct nubus_dev * ndev = NULL;
227 int err = -ENODEV;
228
229 struct nubus_dir dir;
230 struct nubus_dirent ent;
231 int offset;
232 static unsigned int slots;
233
234 enum mac8390_type cardtype;
235
236 /* probably should check for Nubus instead */
237
238 if (!MACH_IS_MAC)
239 return ERR_PTR(-ENODEV);
240
241 dev = alloc_ei_netdev();
242 if (!dev)
243 return ERR_PTR(-ENOMEM);
244
245 if (unit >= 0)
246 sprintf(dev->name, "eth%d", unit);
247
248 SET_MODULE_OWNER(dev);
249
250 while ((ndev = nubus_find_type(NUBUS_CAT_NETWORK, NUBUS_TYPE_ETHERNET, ndev))) {
251 /* Have we seen it already? */
252 if (slots & (1<<ndev->board->slot))
253 continue;
254 slots |= 1<<ndev->board->slot;
255
256 if ((cardtype = mac8390_ident(ndev)) == MAC8390_NONE)
257 continue;
258
259 if (version_disp == 0) {
260 version_disp = 1;
261 printk(version);
262 }
263
264 dev->irq = SLOT2IRQ(ndev->board->slot);
265 /* This is getting to be a habit */
266 dev->base_addr = ndev->board->slot_addr | ((ndev->board->slot&0xf) << 20);
267
268 /* Get some Nubus info - we will trust the card's idea
269 of where its memory and registers are. */
270
271 if (nubus_get_func_dir(ndev, &dir) == -1) {
272 printk(KERN_ERR "%s: Unable to get Nubus functional"
273 " directory for slot %X!\n",
274 dev->name, ndev->board->slot);
275 continue;
276 }
277
278 /* Get the MAC address */
279 if ((nubus_find_rsrc(&dir, NUBUS_RESID_MAC_ADDRESS, &ent)) == -1) {
280 printk(KERN_INFO "%s: Couldn't get MAC address!\n",
281 dev->name);
282 continue;
283 } else {
284 nubus_get_rsrc_mem(dev->dev_addr, &ent, 6);
285 /* Some Sonic Sys cards masquerade as Farallon */
286 if (cardtype == MAC8390_FARALLON &&
287 dev->dev_addr[0] == 0x0 &&
288 dev->dev_addr[1] == 0x40 &&
289 dev->dev_addr[2] == 0x10) {
290 /* This is really Sonic Sys card */
291 cardtype = MAC8390_SONICSYS;
292 }
293 }
294
295 if (useresources[cardtype] == 1) {
296 nubus_rewinddir(&dir);
297 if (nubus_find_rsrc(&dir, NUBUS_RESID_MINOR_BASEOS, &ent) == -1) {
298 printk(KERN_ERR "%s: Memory offset resource"
299 " for slot %X not found!\n",
300 dev->name, ndev->board->slot);
301 continue;
302 }
303 nubus_get_rsrc_mem(&offset, &ent, 4);
304 dev->mem_start = dev->base_addr + offset;
305 /* yes, this is how the Apple driver does it */
306 dev->base_addr = dev->mem_start + 0x10000;
307 nubus_rewinddir(&dir);
308 if (nubus_find_rsrc(&dir, NUBUS_RESID_MINOR_LENGTH, &ent) == -1) {
309 printk(KERN_INFO "%s: Memory length resource"
310 " for slot %X not found"
311 ", probing\n",
312 dev->name, ndev->board->slot);
313 offset = mac8390_memsize(dev->mem_start);
314 } else {
315 nubus_get_rsrc_mem(&offset, &ent, 4);
316 }
317 dev->mem_end = dev->mem_start + offset;
318 } else {
319 switch (cardtype) {
320 case MAC8390_KINETICS:
321 case MAC8390_DAYNA: /* it's the same */
322 dev->base_addr =
323 (int)(ndev->board->slot_addr +
324 DAYNA_8390_BASE);
325 dev->mem_start =
326 (int)(ndev->board->slot_addr +
327 DAYNA_8390_MEM);
328 dev->mem_end =
329 dev->mem_start +
330 mac8390_memsize(dev->mem_start);
331 break;
332 case MAC8390_CABLETRON:
333 dev->base_addr =
334 (int)(ndev->board->slot_addr +
335 CABLETRON_8390_BASE);
336 dev->mem_start =
337 (int)(ndev->board->slot_addr +
338 CABLETRON_8390_MEM);
339 /* The base address is unreadable if 0x00
340 * has been written to the command register
341 * Reset the chip by writing E8390_NODMA +
342 * E8390_PAGE0 + E8390_STOP just to be
343 * sure
344 */
345 i = (void *)dev->base_addr;
346 *i = 0x21;
347 dev->mem_end =
348 dev->mem_start +
349 mac8390_memsize(dev->mem_start);
350 break;
351
352 default:
353 printk(KERN_ERR "Card type %s is"
354 " unsupported, sorry\n",
355 cardname[cardtype]);
356 continue;
357 }
358 }
359
360 /* Do the nasty 8390 stuff */
361 if (!mac8390_initdev(dev, ndev, cardtype))
362 break;
363 }
364
365 if (!ndev)
366 goto out;
367 err = register_netdev(dev);
368 if (err)
369 goto out;
370 return dev;
371
372out:
373 free_netdev(dev);
374 return ERR_PTR(err);
375}
376
377#ifdef MODULE
378MODULE_AUTHOR("David Huggins-Daines <dhd@debian.org> and others");
379MODULE_DESCRIPTION("Macintosh NS8390-based Nubus Ethernet driver");
380MODULE_LICENSE("GPL");
381
382/* overkill, of course */
383static struct net_device *dev_mac8390[15];
384int init_module(void)
385{
386 int i;
387 for (i = 0; i < 15; i++) {
388 struct net_device *dev = mac8390_probe(-1);
389 if (IS_ERR(dev))
390 break;
391 dev_mac890[i] = dev;
392 }
393 if (!i) {
394 printk(KERN_NOTICE "mac8390.c: No useable cards found, driver NOT installed.\n");
395 return -ENODEV;
396 }
397 return 0;
398}
399
400void cleanup_module(void)
401{
402 int i;
403 for (i = 0; i < 15; i++) {
404 struct net_device *dev = dev_mac890[i];
405 if (dev) {
406 unregister_netdev(dev);
407 free_netdev(dev);
408 }
409 }
410}
411
412#endif /* MODULE */
413
414static int __init mac8390_initdev(struct net_device * dev, struct nubus_dev * ndev,
415 enum mac8390_type type)
416{
417 static u32 fwrd4_offsets[16]={
418 0, 4, 8, 12,
419 16, 20, 24, 28,
420 32, 36, 40, 44,
421 48, 52, 56, 60
422 };
423 static u32 back4_offsets[16]={
424 60, 56, 52, 48,
425 44, 40, 36, 32,
426 28, 24, 20, 16,
427 12, 8, 4, 0
428 };
429 static u32 fwrd2_offsets[16]={
430 0, 2, 4, 6,
431 8, 10, 12, 14,
432 16, 18, 20, 22,
433 24, 26, 28, 30
434 };
435
436 int access_bitmode;
437
438 /* Now fill in our stuff */
439 dev->open = &mac8390_open;
440 dev->stop = &mac8390_close;
441#ifdef CONFIG_NET_POLL_CONTROLLER
442 dev->poll_controller = ei_poll;
443#endif
444
445 /* GAR, ei_status is actually a macro even though it looks global */
446 ei_status.name = cardname[type];
447 ei_status.word16 = word16[type];
448
449 /* Cabletron's TX/RX buffers are backwards */
450 if (type == MAC8390_CABLETRON) {
451 ei_status.tx_start_page = CABLETRON_TX_START_PG;
452 ei_status.rx_start_page = CABLETRON_RX_START_PG;
453 ei_status.stop_page = CABLETRON_RX_STOP_PG;
454 ei_status.rmem_start = dev->mem_start;
455 ei_status.rmem_end = dev->mem_start + CABLETRON_RX_STOP_PG*256;
456 } else {
457 ei_status.tx_start_page = WD_START_PG;
458 ei_status.rx_start_page = WD_START_PG + TX_PAGES;
459 ei_status.stop_page = (dev->mem_end - dev->mem_start)/256;
460 ei_status.rmem_start = dev->mem_start + TX_PAGES*256;
461 ei_status.rmem_end = dev->mem_end;
462 }
463
464 /* Fill in model-specific information and functions */
465 switch(type) {
466 case MAC8390_SONICSYS:
467 /* 16 bit card, register map is reversed */
468 ei_status.reset_8390 = &mac8390_no_reset;
469 ei_status.block_input = &slow_sane_block_input;
470 ei_status.block_output = &slow_sane_block_output;
471 ei_status.get_8390_hdr = &slow_sane_get_8390_hdr;
472 ei_status.reg_offset = back4_offsets;
473 access_bitmode = 0;
474 break;
475 case MAC8390_FARALLON:
476 case MAC8390_APPLE:
477 case MAC8390_ASANTE:
478 case MAC8390_DAYNA2:
479 case MAC8390_DAYNA3:
480 /* 32 bit card, register map is reversed */
481 /* sane */
482 ei_status.reset_8390 = &mac8390_no_reset;
483 ei_status.block_input = &sane_block_input;
484 ei_status.block_output = &sane_block_output;
485 ei_status.get_8390_hdr = &sane_get_8390_hdr;
486 ei_status.reg_offset = back4_offsets;
487 access_bitmode = 1;
488 break;
489 case MAC8390_CABLETRON:
490 /* 16 bit card, register map is short forward */
491 ei_status.reset_8390 = &mac8390_no_reset;
492 ei_status.block_input = &slow_sane_block_input;
493 ei_status.block_output = &slow_sane_block_output;
494 ei_status.get_8390_hdr = &slow_sane_get_8390_hdr;
495 ei_status.reg_offset = fwrd2_offsets;
496 access_bitmode = 0;
497 break;
498 case MAC8390_DAYNA:
499 case MAC8390_KINETICS:
500 /* 16 bit memory */
501 /* dayna and similar */
502 ei_status.reset_8390 = &mac8390_no_reset;
503 ei_status.block_input = &dayna_block_input;
504 ei_status.block_output = &dayna_block_output;
505 ei_status.get_8390_hdr = &dayna_get_8390_hdr;
506 ei_status.reg_offset = fwrd4_offsets;
507 access_bitmode = 0;
508 break;
509 default:
510 printk(KERN_ERR "Card type %s is unsupported, sorry\n", cardname[type]);
511 return -ENODEV;
512 }
513
514 NS8390_init(dev, 0);
515
516 /* Good, done, now spit out some messages */
517 printk(KERN_INFO "%s: %s in slot %X (type %s)\n",
518 dev->name, ndev->board->name, ndev->board->slot, cardname[type]);
519 printk(KERN_INFO "MAC ");
520 {
521 int i;
522 for (i = 0; i < 6; i++) {
523 printk("%2.2x", dev->dev_addr[i]);
524 if (i < 5)
525 printk(":");
526 }
527 }
528 printk(" IRQ %d, shared memory at %#lx-%#lx, %d-bit access.\n",
529 dev->irq, dev->mem_start, dev->mem_end-1,
530 access_bitmode?32:16);
531 return 0;
532}
533
534static int mac8390_open(struct net_device *dev)
535{
536 ei_open(dev);
537 if (request_irq(dev->irq, ei_interrupt, 0, "8390 Ethernet", dev)) {
538 printk ("%s: unable to get IRQ %d.\n", dev->name, dev->irq);
539 return -EAGAIN;
540 }
541 return 0;
542}
543
544static int mac8390_close(struct net_device *dev)
545{
546 free_irq(dev->irq, dev);
547 ei_close(dev);
548 return 0;
549}
550
551static void mac8390_no_reset(struct net_device *dev)
552{
553 ei_status.txing = 0;
554 if (ei_debug > 1)
555 printk("reset not supported\n");
556 return;
557}
558
559/* dayna_memcpy_fromio/dayna_memcpy_toio */
560/* directly from daynaport.c by Alan Cox */
561static void dayna_memcpy_fromcard(struct net_device *dev, void *to, int from, int count)
562{
563 volatile unsigned short *ptr;
564 unsigned short *target=to;
565 from<<=1; /* word, skip overhead */
566 ptr=(unsigned short *)(dev->mem_start+from);
567 /* Leading byte? */
568 if (from&2) {
569 *((char *)target)++ = *(((char *)ptr++)-1);
570 count--;
571 }
572 while(count>=2)
573 {
574 *target++=*ptr++; /* Copy and */
575 ptr++; /* skip cruft */
576 count-=2;
577 }
578 /* Trailing byte? */
579 if(count)
580 {
581 /* Big endian */
582 unsigned short v=*ptr;
583 *((char *)target)=v>>8;
584 }
585}
586
587static void dayna_memcpy_tocard(struct net_device *dev, int to, const void *from, int count)
588{
589 volatile unsigned short *ptr;
590 const unsigned short *src=from;
591 to<<=1; /* word, skip overhead */
592 ptr=(unsigned short *)(dev->mem_start+to);
593 /* Leading byte? */
594 if (to&2) { /* avoid a byte write (stomps on other data) */
595 ptr[-1] = (ptr[-1]&0xFF00)|*((unsigned char *)src)++;
596 ptr++;
597 count--;
598 }
599 while(count>=2)
600 {
601 *ptr++=*src++; /* Copy and */
602 ptr++; /* skip cruft */
603 count-=2;
604 }
605 /* Trailing byte? */
606 if(count)
607 {
608 /* Big endian */
609 unsigned short v=*src;
610 /* card doesn't like byte writes */
611 *ptr=(*ptr&0x00FF)|(v&0xFF00);
612 }
613}
614
615/* sane block input/output */
616static void sane_get_8390_hdr(struct net_device *dev,
617 struct e8390_pkt_hdr *hdr, int ring_page)
618{
619 unsigned long hdr_start = (ring_page - WD_START_PG)<<8;
620 memcpy_fromio((void *)hdr, (char *)dev->mem_start + hdr_start, 4);
621 /* Fix endianness */
622 hdr->count = swab16(hdr->count);
623}
624
625static void sane_block_input(struct net_device *dev, int count,
626 struct sk_buff *skb, int ring_offset)
627{
628 unsigned long xfer_base = ring_offset - (WD_START_PG<<8);
629 unsigned long xfer_start = xfer_base + dev->mem_start;
630
631 if (xfer_start + count > ei_status.rmem_end) {
632 /* We must wrap the input move. */
633 int semi_count = ei_status.rmem_end - xfer_start;
634 memcpy_fromio(skb->data, (char *)dev->mem_start + xfer_base, semi_count);
635 count -= semi_count;
636 memcpy_toio(skb->data + semi_count, (char *)ei_status.rmem_start, count);
637 } else {
638 memcpy_fromio(skb->data, (char *)dev->mem_start + xfer_base, count);
639 }
640}
641
642static void sane_block_output(struct net_device *dev, int count,
643 const unsigned char *buf, int start_page)
644{
645 long shmem = (start_page - WD_START_PG)<<8;
646
647 memcpy_toio((char *)dev->mem_start + shmem, buf, count);
648}
649
650/* dayna block input/output */
651static void dayna_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr, int ring_page)
652{
653 unsigned long hdr_start = (ring_page - WD_START_PG)<<8;
654
655 dayna_memcpy_fromcard(dev, (void *)hdr, hdr_start, 4);
656 /* Fix endianness */
657 hdr->count=(hdr->count&0xFF)<<8|(hdr->count>>8);
658}
659
660static void dayna_block_input(struct net_device *dev, int count, struct sk_buff *skb, int ring_offset)
661{
662 unsigned long xfer_base = ring_offset - (WD_START_PG<<8);
663 unsigned long xfer_start = xfer_base+dev->mem_start;
664
665 /* Note the offset math is done in card memory space which is word
666 per long onto our space. */
667
668 if (xfer_start + count > ei_status.rmem_end)
669 {
670 /* We must wrap the input move. */
671 int semi_count = ei_status.rmem_end - xfer_start;
672 dayna_memcpy_fromcard(dev, skb->data, xfer_base, semi_count);
673 count -= semi_count;
674 dayna_memcpy_fromcard(dev, skb->data + semi_count,
675 ei_status.rmem_start - dev->mem_start,
676 count);
677 }
678 else
679 {
680 dayna_memcpy_fromcard(dev, skb->data, xfer_base, count);
681 }
682}
683
684static void dayna_block_output(struct net_device *dev, int count, const unsigned char *buf,
685 int start_page)
686{
687 long shmem = (start_page - WD_START_PG)<<8;
688
689 dayna_memcpy_tocard(dev, shmem, buf, count);
690}
691
692/* Cabletron block I/O */
693static void slow_sane_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr,
694 int ring_page)
695{
696 unsigned long hdr_start = (ring_page - WD_START_PG)<<8;
697 word_memcpy_fromcard((void *)hdr, (char *)dev->mem_start+hdr_start, 4);
698 /* Register endianism - fix here rather than 8390.c */
699 hdr->count = (hdr->count&0xFF)<<8|(hdr->count>>8);
700}
701
702static void slow_sane_block_input(struct net_device *dev, int count, struct sk_buff *skb,
703 int ring_offset)
704{
705 unsigned long xfer_base = ring_offset - (WD_START_PG<<8);
706 unsigned long xfer_start = xfer_base+dev->mem_start;
707
708 if (xfer_start + count > ei_status.rmem_end)
709 {
710 /* We must wrap the input move. */
711 int semi_count = ei_status.rmem_end - xfer_start;
712 word_memcpy_fromcard(skb->data, (char *)dev->mem_start +
713 xfer_base, semi_count);
714 count -= semi_count;
715 word_memcpy_fromcard(skb->data + semi_count,
716 (char *)ei_status.rmem_start, count);
717 }
718 else
719 {
720 word_memcpy_fromcard(skb->data, (char *)dev->mem_start +
721 xfer_base, count);
722 }
723}
724
725static void slow_sane_block_output(struct net_device *dev, int count, const unsigned char *buf,
726 int start_page)
727{
728 long shmem = (start_page - WD_START_PG)<<8;
729
730 word_memcpy_tocard((char *)dev->mem_start + shmem, buf, count);
731}
732
733static void word_memcpy_tocard(void *tp, const void *fp, int count)
734{
735 volatile unsigned short *to = tp;
736 const unsigned short *from = fp;
737
738 count++;
739 count/=2;
740
741 while(count--)
742 *to++=*from++;
743}
744
745static void word_memcpy_fromcard(void *tp, const void *fp, int count)
746{
747 unsigned short *to = tp;
748 const volatile unsigned short *from = fp;
749
750 count++;
751 count/=2;
752
753 while(count--)
754 *to++=*from++;
755}
756
757