1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
21
22#include <linux/module.h>
23#include <linux/kernel.h>
24#include <linux/types.h>
25#include <linux/fcntl.h>
26#include <linux/interrupt.h>
27#include <linux/ptrace.h>
28#include <linux/ioport.h>
29#include <linux/nubus.h>
30#include <linux/in.h>
31#include <linux/string.h>
32#include <linux/errno.h>
33#include <linux/init.h>
34#include <linux/netdevice.h>
35#include <linux/etherdevice.h>
36#include <linux/skbuff.h>
37#include <linux/bitops.h>
38#include <linux/io.h>
39
40#include <asm/dma.h>
41#include <asm/hwtest.h>
42#include <asm/macints.h>
43
44static char version[] =
45 "v0.4 2001-05-15 David Huggins-Daines <dhd@debian.org> and others\n";
46
47#define EI_SHIFT(x) (ei_local->reg_offset[x])
48#define ei_inb(port) in_8(port)
49#define ei_outb(val, port) out_8(port, val)
50#define ei_inb_p(port) in_8(port)
51#define ei_outb_p(val, port) out_8(port, val)
52
53#include "lib8390.c"
54
55#define WD_START_PG 0x00
56#define CABLETRON_RX_START_PG 0x00
57#define CABLETRON_RX_STOP_PG 0x30
58#define CABLETRON_TX_START_PG CABLETRON_RX_STOP_PG
59
60
61
62
63
64
65
66
67
68#define DAYNA_8390_BASE 0x80000
69#define DAYNA_8390_MEM 0x00000
70
71#define CABLETRON_8390_BASE 0x90000
72#define CABLETRON_8390_MEM 0x00000
73
74#define INTERLAN_8390_BASE 0xE0000
75#define INTERLAN_8390_MEM 0xD0000
76
77enum mac8390_type {
78 MAC8390_NONE = -1,
79 MAC8390_APPLE,
80 MAC8390_ASANTE,
81 MAC8390_FARALLON,
82 MAC8390_CABLETRON,
83 MAC8390_DAYNA,
84 MAC8390_INTERLAN,
85 MAC8390_KINETICS,
86};
87
88static const char *cardname[] = {
89 "apple",
90 "asante",
91 "farallon",
92 "cabletron",
93 "dayna",
94 "interlan",
95 "kinetics",
96};
97
98static const int word16[] = {
99 1,
100 1,
101 1,
102 1,
103 0,
104 1,
105 0,
106};
107
108
109static const int useresources[] = {
110 1,
111 1,
112 1,
113 0,
114 0,
115 0,
116 0,
117};
118
119enum mac8390_access {
120 ACCESS_UNKNOWN = 0,
121 ACCESS_32,
122 ACCESS_16,
123};
124
125extern int mac8390_memtest(struct net_device *dev);
126static int mac8390_initdev(struct net_device *dev, struct nubus_board *board,
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);
132static void interlan_reset(struct net_device *dev);
133
134
135static void sane_get_8390_hdr(struct net_device *dev,
136 struct e8390_pkt_hdr *hdr, int ring_page);
137static void sane_block_input(struct net_device *dev, int count,
138 struct sk_buff *skb, int ring_offset);
139static void sane_block_output(struct net_device *dev, int count,
140 const unsigned char *buf, const int start_page);
141
142
143static void dayna_memcpy_fromcard(struct net_device *dev, void *to,
144 int from, int count);
145static void dayna_memcpy_tocard(struct net_device *dev, int to,
146 const void *from, int count);
147
148
149static void dayna_get_8390_hdr(struct net_device *dev,
150 struct e8390_pkt_hdr *hdr, int ring_page);
151static void dayna_block_input(struct net_device *dev, int count,
152 struct sk_buff *skb, int ring_offset);
153static void dayna_block_output(struct net_device *dev, int count,
154 const unsigned char *buf, int start_page);
155
156#define memcpy_fromio(a, b, c) memcpy((a), (void *)(b), (c))
157#define memcpy_toio(a, b, c) memcpy((void *)(a), (b), (c))
158
159#define memcmp_withio(a, b, c) memcmp((a), (void *)(b), (c))
160
161
162static void slow_sane_get_8390_hdr(struct net_device *dev,
163 struct e8390_pkt_hdr *hdr, int ring_page);
164static void slow_sane_block_input(struct net_device *dev, int count,
165 struct sk_buff *skb, int ring_offset);
166static void slow_sane_block_output(struct net_device *dev, int count,
167 const unsigned char *buf, int start_page);
168static void word_memcpy_tocard(unsigned long tp, const void *fp, int count);
169static void word_memcpy_fromcard(void *tp, unsigned long fp, int count);
170
171static enum mac8390_type mac8390_ident(struct nubus_rsrc *fres)
172{
173 switch (fres->dr_sw) {
174 case NUBUS_DRSW_3COM:
175 switch (fres->dr_hw) {
176 case NUBUS_DRHW_APPLE_SONIC_NB:
177 case NUBUS_DRHW_APPLE_SONIC_LC:
178 case NUBUS_DRHW_SONNET:
179 return MAC8390_NONE;
180 default:
181 return MAC8390_APPLE;
182 }
183 break;
184
185 case NUBUS_DRSW_APPLE:
186 switch (fres->dr_hw) {
187 case NUBUS_DRHW_ASANTE_LC:
188 return MAC8390_NONE;
189 case NUBUS_DRHW_CABLETRON:
190 return MAC8390_CABLETRON;
191 default:
192 return MAC8390_APPLE;
193 }
194 break;
195
196 case NUBUS_DRSW_ASANTE:
197 return MAC8390_ASANTE;
198 break;
199
200 case NUBUS_DRSW_TECHWORKS:
201 case NUBUS_DRSW_DAYNA2:
202 case NUBUS_DRSW_DAYNA_LC:
203 if (fres->dr_hw == NUBUS_DRHW_CABLETRON)
204 return MAC8390_CABLETRON;
205 else
206 return MAC8390_APPLE;
207 break;
208
209 case NUBUS_DRSW_FARALLON:
210 return MAC8390_FARALLON;
211 break;
212
213 case NUBUS_DRSW_KINETICS:
214 switch (fres->dr_hw) {
215 case NUBUS_DRHW_INTERLAN:
216 return MAC8390_INTERLAN;
217 default:
218 return MAC8390_KINETICS;
219 }
220 break;
221
222 case NUBUS_DRSW_DAYNA:
223
224
225
226
227 if (fres->dr_hw == NUBUS_DRHW_SMC9194 ||
228 fres->dr_hw == NUBUS_DRHW_INTERLAN)
229 return MAC8390_NONE;
230 else
231 return MAC8390_DAYNA;
232 break;
233 }
234 return MAC8390_NONE;
235}
236
237static enum mac8390_access mac8390_testio(unsigned long membase)
238{
239 unsigned long outdata = 0xA5A0B5B0;
240 unsigned long indata = 0x00000000;
241
242 memcpy_toio(membase, &outdata, 4);
243
244 if (memcmp_withio(&outdata, membase, 4) == 0)
245 return ACCESS_32;
246
247 word_memcpy_tocard(membase, &outdata, 4);
248
249 word_memcpy_fromcard(&indata, membase, 4);
250 if (outdata == indata)
251 return ACCESS_16;
252 return ACCESS_UNKNOWN;
253}
254
255static int mac8390_memsize(unsigned long membase)
256{
257 unsigned long flags;
258 int i, j;
259
260 local_irq_save(flags);
261
262 for (i = 0; i < 8; i++) {
263 volatile unsigned short *m = (unsigned short *)(membase + (i * 0x1000));
264
265
266
267 if (hwreg_present(m) == 0)
268 break;
269
270
271 *m = 0xA5A0 | i;
272
273 if (*m != (0xA5A0 | i))
274 break;
275
276
277 for (j = 0; j < i; j++) {
278 volatile unsigned short *p = (unsigned short *)(membase + (j * 0x1000));
279 if (*p != (0xA5A0 | j))
280 break;
281 }
282 }
283 local_irq_restore(flags);
284
285
286
287
288 return i * 0x1000;
289}
290
291static bool mac8390_rsrc_init(struct net_device *dev,
292 struct nubus_rsrc *fres,
293 enum mac8390_type cardtype)
294{
295 struct nubus_board *board = fres->board;
296 struct nubus_dir dir;
297 struct nubus_dirent ent;
298 int offset;
299 volatile unsigned short *i;
300
301 dev->irq = SLOT2IRQ(board->slot);
302
303 dev->base_addr = board->slot_addr | ((board->slot & 0xf) << 20);
304
305
306
307
308
309
310 if (nubus_get_func_dir(fres, &dir) == -1) {
311 dev_err(&board->dev,
312 "Unable to get Nubus functional directory\n");
313 return false;
314 }
315
316
317 if (nubus_find_rsrc(&dir, NUBUS_RESID_MAC_ADDRESS, &ent) == -1) {
318 dev_info(&board->dev, "MAC address resource not found\n");
319 return false;
320 }
321
322 nubus_get_rsrc_mem(dev->dev_addr, &ent, 6);
323
324 if (useresources[cardtype] == 1) {
325 nubus_rewinddir(&dir);
326 if (nubus_find_rsrc(&dir, NUBUS_RESID_MINOR_BASEOS,
327 &ent) == -1) {
328 dev_err(&board->dev,
329 "Memory offset resource not found\n");
330 return false;
331 }
332 nubus_get_rsrc_mem(&offset, &ent, 4);
333 dev->mem_start = dev->base_addr + offset;
334
335 dev->base_addr = dev->mem_start + 0x10000;
336 nubus_rewinddir(&dir);
337 if (nubus_find_rsrc(&dir, NUBUS_RESID_MINOR_LENGTH,
338 &ent) == -1) {
339 dev_info(&board->dev,
340 "Memory length resource not found, probing\n");
341 offset = mac8390_memsize(dev->mem_start);
342 } else {
343 nubus_get_rsrc_mem(&offset, &ent, 4);
344 }
345 dev->mem_end = dev->mem_start + offset;
346 } else {
347 switch (cardtype) {
348 case MAC8390_KINETICS:
349 case MAC8390_DAYNA:
350 dev->base_addr = (int)(board->slot_addr +
351 DAYNA_8390_BASE);
352 dev->mem_start = (int)(board->slot_addr +
353 DAYNA_8390_MEM);
354 dev->mem_end = dev->mem_start +
355 mac8390_memsize(dev->mem_start);
356 break;
357 case MAC8390_INTERLAN:
358 dev->base_addr = (int)(board->slot_addr +
359 INTERLAN_8390_BASE);
360 dev->mem_start = (int)(board->slot_addr +
361 INTERLAN_8390_MEM);
362 dev->mem_end = dev->mem_start +
363 mac8390_memsize(dev->mem_start);
364 break;
365 case MAC8390_CABLETRON:
366 dev->base_addr = (int)(board->slot_addr +
367 CABLETRON_8390_BASE);
368 dev->mem_start = (int)(board->slot_addr +
369 CABLETRON_8390_MEM);
370
371
372
373
374
375
376 i = (void *)dev->base_addr;
377 *i = 0x21;
378 dev->mem_end = dev->mem_start +
379 mac8390_memsize(dev->mem_start);
380 break;
381
382 default:
383 dev_err(&board->dev,
384 "No known base address for card type\n");
385 return false;
386 }
387 }
388
389 return true;
390}
391
392static int mac8390_device_probe(struct nubus_board *board)
393{
394 struct net_device *dev;
395 int err = -ENODEV;
396 struct nubus_rsrc *fres;
397 enum mac8390_type cardtype = MAC8390_NONE;
398
399 dev = ____alloc_ei_netdev(0);
400 if (!dev)
401 return -ENOMEM;
402
403 SET_NETDEV_DEV(dev, &board->dev);
404
405 for_each_board_func_rsrc(board, fres) {
406 if (fres->category != NUBUS_CAT_NETWORK ||
407 fres->type != NUBUS_TYPE_ETHERNET)
408 continue;
409
410 cardtype = mac8390_ident(fres);
411 if (cardtype == MAC8390_NONE)
412 continue;
413
414 if (mac8390_rsrc_init(dev, fres, cardtype))
415 break;
416 }
417 if (!fres)
418 goto out;
419
420 err = mac8390_initdev(dev, board, cardtype);
421 if (err)
422 goto out;
423
424 err = register_netdev(dev);
425 if (err)
426 goto out;
427
428 nubus_set_drvdata(board, dev);
429 return 0;
430
431out:
432 free_netdev(dev);
433 return err;
434}
435
436static int mac8390_device_remove(struct nubus_board *board)
437{
438 struct net_device *dev = nubus_get_drvdata(board);
439
440 unregister_netdev(dev);
441 free_netdev(dev);
442 return 0;
443}
444
445static struct nubus_driver mac8390_driver = {
446 .probe = mac8390_device_probe,
447 .remove = mac8390_device_remove,
448 .driver = {
449 .name = KBUILD_MODNAME,
450 .owner = THIS_MODULE,
451 }
452};
453
454MODULE_AUTHOR("David Huggins-Daines <dhd@debian.org> and others");
455MODULE_DESCRIPTION("Macintosh NS8390-based Nubus Ethernet driver");
456MODULE_LICENSE("GPL");
457
458static int __init mac8390_init(void)
459{
460 return nubus_driver_register(&mac8390_driver);
461}
462module_init(mac8390_init);
463
464static void __exit mac8390_exit(void)
465{
466 nubus_driver_unregister(&mac8390_driver);
467}
468module_exit(mac8390_exit);
469
470static const struct net_device_ops mac8390_netdev_ops = {
471 .ndo_open = mac8390_open,
472 .ndo_stop = mac8390_close,
473 .ndo_start_xmit = __ei_start_xmit,
474 .ndo_tx_timeout = __ei_tx_timeout,
475 .ndo_get_stats = __ei_get_stats,
476 .ndo_set_rx_mode = __ei_set_multicast_list,
477 .ndo_validate_addr = eth_validate_addr,
478 .ndo_set_mac_address = eth_mac_addr,
479#ifdef CONFIG_NET_POLL_CONTROLLER
480 .ndo_poll_controller = __ei_poll,
481#endif
482};
483
484static int mac8390_initdev(struct net_device *dev, struct nubus_board *board,
485 enum mac8390_type type)
486{
487 static u32 fwrd4_offsets[16] = {
488 0, 4, 8, 12,
489 16, 20, 24, 28,
490 32, 36, 40, 44,
491 48, 52, 56, 60
492 };
493 static u32 back4_offsets[16] = {
494 60, 56, 52, 48,
495 44, 40, 36, 32,
496 28, 24, 20, 16,
497 12, 8, 4, 0
498 };
499 static u32 fwrd2_offsets[16] = {
500 0, 2, 4, 6,
501 8, 10, 12, 14,
502 16, 18, 20, 22,
503 24, 26, 28, 30
504 };
505
506 int access_bitmode = 0;
507
508
509 dev->netdev_ops = &mac8390_netdev_ops;
510
511
512 ei_status.name = cardname[type];
513 ei_status.word16 = word16[type];
514
515
516 if (type == MAC8390_CABLETRON) {
517 ei_status.tx_start_page = CABLETRON_TX_START_PG;
518 ei_status.rx_start_page = CABLETRON_RX_START_PG;
519 ei_status.stop_page = CABLETRON_RX_STOP_PG;
520 ei_status.rmem_start = dev->mem_start;
521 ei_status.rmem_end = dev->mem_start + CABLETRON_RX_STOP_PG*256;
522 } else {
523 ei_status.tx_start_page = WD_START_PG;
524 ei_status.rx_start_page = WD_START_PG + TX_PAGES;
525 ei_status.stop_page = (dev->mem_end - dev->mem_start)/256;
526 ei_status.rmem_start = dev->mem_start + TX_PAGES*256;
527 ei_status.rmem_end = dev->mem_end;
528 }
529
530
531 switch (type) {
532 case MAC8390_FARALLON:
533 case MAC8390_APPLE:
534 switch (mac8390_testio(dev->mem_start)) {
535 case ACCESS_UNKNOWN:
536 dev_err(&board->dev,
537 "Don't know how to access card memory\n");
538 return -ENODEV;
539
540 case ACCESS_16:
541
542 ei_status.reset_8390 = mac8390_no_reset;
543 ei_status.block_input = slow_sane_block_input;
544 ei_status.block_output = slow_sane_block_output;
545 ei_status.get_8390_hdr = slow_sane_get_8390_hdr;
546 ei_status.reg_offset = back4_offsets;
547 break;
548
549 case ACCESS_32:
550
551 ei_status.reset_8390 = mac8390_no_reset;
552 ei_status.block_input = sane_block_input;
553 ei_status.block_output = sane_block_output;
554 ei_status.get_8390_hdr = sane_get_8390_hdr;
555 ei_status.reg_offset = back4_offsets;
556 access_bitmode = 1;
557 break;
558 }
559 break;
560
561 case MAC8390_ASANTE:
562
563
564
565
566 ei_status.reset_8390 = mac8390_no_reset;
567 ei_status.block_input = slow_sane_block_input;
568 ei_status.block_output = slow_sane_block_output;
569 ei_status.get_8390_hdr = slow_sane_get_8390_hdr;
570 ei_status.reg_offset = back4_offsets;
571 break;
572
573 case MAC8390_CABLETRON:
574
575 ei_status.reset_8390 = mac8390_no_reset;
576 ei_status.block_input = slow_sane_block_input;
577 ei_status.block_output = slow_sane_block_output;
578 ei_status.get_8390_hdr = slow_sane_get_8390_hdr;
579 ei_status.reg_offset = fwrd2_offsets;
580 break;
581
582 case MAC8390_DAYNA:
583 case MAC8390_KINETICS:
584
585
586 ei_status.reset_8390 = mac8390_no_reset;
587 ei_status.block_input = dayna_block_input;
588 ei_status.block_output = dayna_block_output;
589 ei_status.get_8390_hdr = dayna_get_8390_hdr;
590 ei_status.reg_offset = fwrd4_offsets;
591 break;
592
593 case MAC8390_INTERLAN:
594
595 ei_status.reset_8390 = interlan_reset;
596 ei_status.block_input = slow_sane_block_input;
597 ei_status.block_output = slow_sane_block_output;
598 ei_status.get_8390_hdr = slow_sane_get_8390_hdr;
599 ei_status.reg_offset = fwrd4_offsets;
600 break;
601
602 default:
603 dev_err(&board->dev, "Unsupported card type\n");
604 return -ENODEV;
605 }
606
607 __NS8390_init(dev, 0);
608
609
610 dev_info(&board->dev, "%s (type %s)\n", board->name, cardname[type]);
611 dev_info(&board->dev, "MAC %pM, IRQ %d, %d KB shared memory at %#lx, %d-bit access.\n",
612 dev->dev_addr, dev->irq,
613 (unsigned int)(dev->mem_end - dev->mem_start) >> 10,
614 dev->mem_start, access_bitmode ? 32 : 16);
615 return 0;
616}
617
618static int mac8390_open(struct net_device *dev)
619{
620 int err;
621
622 __ei_open(dev);
623 err = request_irq(dev->irq, __ei_interrupt, 0, "8390 Ethernet", dev);
624 if (err)
625 pr_err("%s: unable to get IRQ %d\n", dev->name, dev->irq);
626 return err;
627}
628
629static int mac8390_close(struct net_device *dev)
630{
631 free_irq(dev->irq, dev);
632 __ei_close(dev);
633 return 0;
634}
635
636static void mac8390_no_reset(struct net_device *dev)
637{
638 struct ei_device *ei_local = netdev_priv(dev);
639
640 ei_status.txing = 0;
641 netif_info(ei_local, hw, dev, "reset not supported\n");
642}
643
644static void interlan_reset(struct net_device *dev)
645{
646 unsigned char *target = nubus_slot_addr(IRQ2SLOT(dev->irq));
647 struct ei_device *ei_local = netdev_priv(dev);
648
649 netif_info(ei_local, hw, dev, "Need to reset the NS8390 t=%lu...",
650 jiffies);
651 ei_status.txing = 0;
652 target[0xC0000] = 0;
653 if (netif_msg_hw(ei_local))
654 pr_cont("reset complete\n");
655}
656
657
658
659static void dayna_memcpy_fromcard(struct net_device *dev, void *to, int from,
660 int count)
661{
662 volatile unsigned char *ptr;
663 unsigned char *target = to;
664 from <<= 1;
665 ptr = (unsigned char *)(dev->mem_start+from);
666
667 if (from & 2) {
668 *target++ = ptr[-1];
669 ptr += 2;
670 count--;
671 }
672 while (count >= 2) {
673 *(unsigned short *)target = *(unsigned short volatile *)ptr;
674 ptr += 4;
675 target += 2;
676 count -= 2;
677 }
678
679 if (count)
680 *target = *ptr;
681}
682
683static void dayna_memcpy_tocard(struct net_device *dev, int to,
684 const void *from, int count)
685{
686 volatile unsigned short *ptr;
687 const unsigned char *src = from;
688 to <<= 1;
689 ptr = (unsigned short *)(dev->mem_start+to);
690
691 if (to & 2) {
692 ptr[-1] = (ptr[-1]&0xFF00)|*src++;
693 ptr++;
694 count--;
695 }
696 while (count >= 2) {
697 *ptr++ = *(unsigned short *)src;
698 ptr++;
699 src += 2;
700 count -= 2;
701 }
702
703 if (count) {
704
705 *ptr = (*ptr & 0x00FF) | (*src << 8);
706 }
707}
708
709
710static void sane_get_8390_hdr(struct net_device *dev,
711 struct e8390_pkt_hdr *hdr, int ring_page)
712{
713 unsigned long hdr_start = (ring_page - WD_START_PG)<<8;
714 memcpy_fromio(hdr, dev->mem_start + hdr_start, 4);
715
716 hdr->count = swab16(hdr->count);
717}
718
719static void sane_block_input(struct net_device *dev, int count,
720 struct sk_buff *skb, int ring_offset)
721{
722 unsigned long xfer_base = ring_offset - (WD_START_PG<<8);
723 unsigned long xfer_start = xfer_base + dev->mem_start;
724
725 if (xfer_start + count > ei_status.rmem_end) {
726
727 int semi_count = ei_status.rmem_end - xfer_start;
728 memcpy_fromio(skb->data, dev->mem_start + xfer_base,
729 semi_count);
730 count -= semi_count;
731 memcpy_fromio(skb->data + semi_count, ei_status.rmem_start,
732 count);
733 } else {
734 memcpy_fromio(skb->data, dev->mem_start + xfer_base, count);
735 }
736}
737
738static void sane_block_output(struct net_device *dev, int count,
739 const unsigned char *buf, int start_page)
740{
741 long shmem = (start_page - WD_START_PG)<<8;
742
743 memcpy_toio(dev->mem_start + shmem, buf, count);
744}
745
746
747static void dayna_get_8390_hdr(struct net_device *dev,
748 struct e8390_pkt_hdr *hdr, int ring_page)
749{
750 unsigned long hdr_start = (ring_page - WD_START_PG)<<8;
751
752 dayna_memcpy_fromcard(dev, hdr, hdr_start, 4);
753
754 hdr->count = (hdr->count & 0xFF) << 8 | (hdr->count >> 8);
755}
756
757static void dayna_block_input(struct net_device *dev, int count,
758 struct sk_buff *skb, int ring_offset)
759{
760 unsigned long xfer_base = ring_offset - (WD_START_PG<<8);
761 unsigned long xfer_start = xfer_base+dev->mem_start;
762
763
764
765
766 if (xfer_start + count > ei_status.rmem_end) {
767
768 int semi_count = ei_status.rmem_end - xfer_start;
769 dayna_memcpy_fromcard(dev, skb->data, xfer_base, semi_count);
770 count -= semi_count;
771 dayna_memcpy_fromcard(dev, skb->data + semi_count,
772 ei_status.rmem_start - dev->mem_start,
773 count);
774 } else {
775 dayna_memcpy_fromcard(dev, skb->data, xfer_base, count);
776 }
777}
778
779static void dayna_block_output(struct net_device *dev, int count,
780 const unsigned char *buf,
781 int start_page)
782{
783 long shmem = (start_page - WD_START_PG)<<8;
784
785 dayna_memcpy_tocard(dev, shmem, buf, count);
786}
787
788
789static void slow_sane_get_8390_hdr(struct net_device *dev,
790 struct e8390_pkt_hdr *hdr,
791 int ring_page)
792{
793 unsigned long hdr_start = (ring_page - WD_START_PG)<<8;
794 word_memcpy_fromcard(hdr, dev->mem_start + hdr_start, 4);
795
796 hdr->count = (hdr->count&0xFF)<<8|(hdr->count>>8);
797}
798
799static void slow_sane_block_input(struct net_device *dev, int count,
800 struct sk_buff *skb, int ring_offset)
801{
802 unsigned long xfer_base = ring_offset - (WD_START_PG<<8);
803 unsigned long xfer_start = xfer_base+dev->mem_start;
804
805 if (xfer_start + count > ei_status.rmem_end) {
806
807 int semi_count = ei_status.rmem_end - xfer_start;
808 word_memcpy_fromcard(skb->data, dev->mem_start + xfer_base,
809 semi_count);
810 count -= semi_count;
811 word_memcpy_fromcard(skb->data + semi_count,
812 ei_status.rmem_start, count);
813 } else {
814 word_memcpy_fromcard(skb->data, dev->mem_start + xfer_base,
815 count);
816 }
817}
818
819static void slow_sane_block_output(struct net_device *dev, int count,
820 const unsigned char *buf, int start_page)
821{
822 long shmem = (start_page - WD_START_PG)<<8;
823
824 word_memcpy_tocard(dev->mem_start + shmem, buf, count);
825}
826
827static void word_memcpy_tocard(unsigned long tp, const void *fp, int count)
828{
829 volatile unsigned short *to = (void *)tp;
830 const unsigned short *from = fp;
831
832 count++;
833 count /= 2;
834
835 while (count--)
836 *to++ = *from++;
837}
838
839static void word_memcpy_fromcard(void *tp, unsigned long fp, int count)
840{
841 unsigned short *to = tp;
842 const volatile unsigned short *from = (const void *)fp;
843
844 count++;
845 count /= 2;
846
847 while (count--)
848 *to++ = *from++;
849}
850
851
852