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.
7 This software may be used and distributed according to the terms of
8 the GNU Public License, incorporated herein by reference. */
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 /* 2002-12-30: Try to support more cards, some clues from NetBSD driver */
18 /* 2003-12-26: Make sure Asante cards always work. */
20 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
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>
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>
41 #include <asm/hwtest.h>
42 #include <asm/macints.h>
44 static char version
[] =
45 "v0.4 2001-05-15 David Huggins-Daines <dhd@debian.org> and others\n";
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)
55 #define WD_START_PG 0x00 /* First page of TX buffer */
56 #define CABLETRON_RX_START_PG 0x00 /* First page of RX buffer */
57 #define CABLETRON_RX_STOP_PG 0x30 /* Last page +1 of RX ring */
58 #define CABLETRON_TX_START_PG CABLETRON_RX_STOP_PG
59 /* First page of TX buffer */
62 * Unfortunately it seems we have to hardcode these for the moment
63 * Shouldn't the card know about this?
64 * Does anyone know where to read it off the card?
65 * Do we trust the data provided by the card?
68 #define DAYNA_8390_BASE 0x80000
69 #define DAYNA_8390_MEM 0x00000
71 #define CABLETRON_8390_BASE 0x90000
72 #define CABLETRON_8390_MEM 0x00000
74 #define INTERLAN_8390_BASE 0xE0000
75 #define INTERLAN_8390_MEM 0xD0000
88 static const char *cardname
[] = {
98 static const int word16
[] = {
108 /* on which cards do we use NuBus resources? */
109 static const int useresources
[] = {
119 enum mac8390_access
{
125 extern int mac8390_memtest(struct net_device
*dev
);
126 static int mac8390_initdev(struct net_device
*dev
, struct nubus_dev
*ndev
,
127 enum mac8390_type type
);
129 static int mac8390_open(struct net_device
*dev
);
130 static int mac8390_close(struct net_device
*dev
);
131 static void mac8390_no_reset(struct net_device
*dev
);
132 static void interlan_reset(struct net_device
*dev
);
134 /* Sane (32-bit chunk memory read/write) - Some Farallon and Apple do this*/
135 static void sane_get_8390_hdr(struct net_device
*dev
,
136 struct e8390_pkt_hdr
*hdr
, int ring_page
);
137 static void sane_block_input(struct net_device
*dev
, int count
,
138 struct sk_buff
*skb
, int ring_offset
);
139 static void sane_block_output(struct net_device
*dev
, int count
,
140 const unsigned char *buf
, const int start_page
);
142 /* dayna_memcpy to and from card */
143 static void dayna_memcpy_fromcard(struct net_device
*dev
, void *to
,
144 int from
, int count
);
145 static void dayna_memcpy_tocard(struct net_device
*dev
, int to
,
146 const void *from
, int count
);
148 /* Dayna - Dayna/Kinetics use this */
149 static void dayna_get_8390_hdr(struct net_device
*dev
,
150 struct e8390_pkt_hdr
*hdr
, int ring_page
);
151 static void dayna_block_input(struct net_device
*dev
, int count
,
152 struct sk_buff
*skb
, int ring_offset
);
153 static void dayna_block_output(struct net_device
*dev
, int count
,
154 const unsigned char *buf
, int start_page
);
156 #define memcpy_fromio(a, b, c) memcpy((a), (void *)(b), (c))
157 #define memcpy_toio(a, b, c) memcpy((void *)(a), (b), (c))
159 #define memcmp_withio(a, b, c) memcmp((a), (void *)(b), (c))
161 /* Slow Sane (16-bit chunk memory read/write) Cabletron uses this */
162 static void slow_sane_get_8390_hdr(struct net_device
*dev
,
163 struct e8390_pkt_hdr
*hdr
, int ring_page
);
164 static void slow_sane_block_input(struct net_device
*dev
, int count
,
165 struct sk_buff
*skb
, int ring_offset
);
166 static void slow_sane_block_output(struct net_device
*dev
, int count
,
167 const unsigned char *buf
, int start_page
);
168 static void word_memcpy_tocard(unsigned long tp
, const void *fp
, int count
);
169 static void word_memcpy_fromcard(void *tp
, unsigned long fp
, int count
);
170 static u32 mac8390_msg_enable
;
172 static enum mac8390_type __init
mac8390_ident(struct nubus_dev
*dev
)
174 switch (dev
->dr_sw
) {
175 case NUBUS_DRSW_3COM
:
176 switch (dev
->dr_hw
) {
177 case NUBUS_DRHW_APPLE_SONIC_NB
:
178 case NUBUS_DRHW_APPLE_SONIC_LC
:
179 case NUBUS_DRHW_SONNET
:
183 return MAC8390_APPLE
;
188 case NUBUS_DRSW_APPLE
:
189 switch (dev
->dr_hw
) {
190 case NUBUS_DRHW_ASANTE_LC
:
193 case NUBUS_DRHW_CABLETRON
:
194 return MAC8390_CABLETRON
;
197 return MAC8390_APPLE
;
202 case NUBUS_DRSW_ASANTE
:
203 return MAC8390_ASANTE
;
206 case NUBUS_DRSW_TECHWORKS
:
207 case NUBUS_DRSW_DAYNA2
:
208 case NUBUS_DRSW_DAYNA_LC
:
209 if (dev
->dr_hw
== NUBUS_DRHW_CABLETRON
)
210 return MAC8390_CABLETRON
;
212 return MAC8390_APPLE
;
215 case NUBUS_DRSW_FARALLON
:
216 return MAC8390_FARALLON
;
219 case NUBUS_DRSW_KINETICS
:
220 switch (dev
->dr_hw
) {
221 case NUBUS_DRHW_INTERLAN
:
222 return MAC8390_INTERLAN
;
225 return MAC8390_KINETICS
;
230 case NUBUS_DRSW_DAYNA
:
232 * These correspond to Dayna Sonic cards
233 * which use the macsonic driver
235 if (dev
->dr_hw
== NUBUS_DRHW_SMC9194
||
236 dev
->dr_hw
== NUBUS_DRHW_INTERLAN
)
239 return MAC8390_DAYNA
;
245 static enum mac8390_access __init
mac8390_testio(volatile unsigned long membase
)
247 unsigned long outdata
= 0xA5A0B5B0;
248 unsigned long indata
= 0x00000000;
249 /* Try writing 32 bits */
250 memcpy_toio(membase
, &outdata
, 4);
251 /* Now compare them */
252 if (memcmp_withio(&outdata
, membase
, 4) == 0)
254 /* Write 16 bit output */
255 word_memcpy_tocard(membase
, &outdata
, 4);
256 /* Now read it back */
257 word_memcpy_fromcard(&indata
, membase
, 4);
258 if (outdata
== indata
)
260 return ACCESS_UNKNOWN
;
263 static int __init
mac8390_memsize(unsigned long membase
)
268 local_irq_save(flags
);
269 /* Check up to 32K in 4K increments */
270 for (i
= 0; i
< 8; i
++) {
271 volatile unsigned short *m
= (unsigned short *)(membase
+ (i
* 0x1000));
273 /* Unwriteable - we have a fully decoded card and the
275 if (hwreg_present(m
) == 0)
278 /* write a distinctive byte */
280 /* check that we read back what we wrote */
281 if (*m
!= (0xA5A0 | i
))
284 /* check for partial decode and wrap */
285 for (j
= 0; j
< i
; j
++) {
286 volatile unsigned short *p
= (unsigned short *)(membase
+ (j
* 0x1000));
287 if (*p
!= (0xA5A0 | j
))
291 local_irq_restore(flags
);
293 * in any case, we stopped once we tried one block too many,
294 * or once we reached 32K
299 static bool __init
mac8390_init(struct net_device
*dev
, struct nubus_dev
*ndev
,
300 enum mac8390_type cardtype
)
302 struct nubus_dir dir
;
303 struct nubus_dirent ent
;
305 volatile unsigned short *i
;
307 printk_once(KERN_INFO
pr_fmt("%s"), version
);
309 dev
->irq
= SLOT2IRQ(ndev
->board
->slot
);
310 /* This is getting to be a habit */
311 dev
->base_addr
= (ndev
->board
->slot_addr
|
312 ((ndev
->board
->slot
& 0xf) << 20));
315 * Get some Nubus info - we will trust the card's idea
316 * of where its memory and registers are.
319 if (nubus_get_func_dir(ndev
, &dir
) == -1) {
320 pr_err("%s: Unable to get Nubus functional directory for slot %X!\n",
321 dev
->name
, ndev
->board
->slot
);
325 /* Get the MAC address */
326 if (nubus_find_rsrc(&dir
, NUBUS_RESID_MAC_ADDRESS
, &ent
) == -1) {
327 pr_info("%s: Couldn't get MAC address!\n", dev
->name
);
331 nubus_get_rsrc_mem(dev
->dev_addr
, &ent
, 6);
333 if (useresources
[cardtype
] == 1) {
334 nubus_rewinddir(&dir
);
335 if (nubus_find_rsrc(&dir
, NUBUS_RESID_MINOR_BASEOS
,
337 pr_err("%s: Memory offset resource for slot %X not found!\n",
338 dev
->name
, ndev
->board
->slot
);
341 nubus_get_rsrc_mem(&offset
, &ent
, 4);
342 dev
->mem_start
= dev
->base_addr
+ offset
;
343 /* yes, this is how the Apple driver does it */
344 dev
->base_addr
= dev
->mem_start
+ 0x10000;
345 nubus_rewinddir(&dir
);
346 if (nubus_find_rsrc(&dir
, NUBUS_RESID_MINOR_LENGTH
,
348 pr_info("%s: Memory length resource for slot %X not found, probing\n",
349 dev
->name
, ndev
->board
->slot
);
350 offset
= mac8390_memsize(dev
->mem_start
);
352 nubus_get_rsrc_mem(&offset
, &ent
, 4);
354 dev
->mem_end
= dev
->mem_start
+ offset
;
357 case MAC8390_KINETICS
:
358 case MAC8390_DAYNA
: /* it's the same */
359 dev
->base_addr
= (int)(ndev
->board
->slot_addr
+
361 dev
->mem_start
= (int)(ndev
->board
->slot_addr
+
363 dev
->mem_end
= dev
->mem_start
+
364 mac8390_memsize(dev
->mem_start
);
366 case MAC8390_INTERLAN
:
367 dev
->base_addr
= (int)(ndev
->board
->slot_addr
+
369 dev
->mem_start
= (int)(ndev
->board
->slot_addr
+
371 dev
->mem_end
= dev
->mem_start
+
372 mac8390_memsize(dev
->mem_start
);
374 case MAC8390_CABLETRON
:
375 dev
->base_addr
= (int)(ndev
->board
->slot_addr
+
376 CABLETRON_8390_BASE
);
377 dev
->mem_start
= (int)(ndev
->board
->slot_addr
+
379 /* The base address is unreadable if 0x00
380 * has been written to the command register
381 * Reset the chip by writing E8390_NODMA +
382 * E8390_PAGE0 + E8390_STOP just to be
385 i
= (void *)dev
->base_addr
;
387 dev
->mem_end
= dev
->mem_start
+
388 mac8390_memsize(dev
->mem_start
);
392 pr_err("Card type %s is unsupported, sorry\n",
401 struct net_device
* __init
mac8390_probe(int unit
)
403 struct net_device
*dev
;
404 struct nubus_dev
*ndev
= NULL
;
406 struct ei_device
*ei_local
;
408 static unsigned int slots
;
410 enum mac8390_type cardtype
;
412 /* probably should check for Nubus instead */
415 return ERR_PTR(-ENODEV
);
417 dev
= ____alloc_ei_netdev(0);
419 return ERR_PTR(-ENOMEM
);
422 sprintf(dev
->name
, "eth%d", unit
);
424 while ((ndev
= nubus_find_type(NUBUS_CAT_NETWORK
, NUBUS_TYPE_ETHERNET
,
426 /* Have we seen it already? */
427 if (slots
& (1 << ndev
->board
->slot
))
429 slots
|= 1 << ndev
->board
->slot
;
431 cardtype
= mac8390_ident(ndev
);
432 if (cardtype
== MAC8390_NONE
)
435 if (!mac8390_init(dev
, ndev
, cardtype
))
438 /* Do the nasty 8390 stuff */
439 if (!mac8390_initdev(dev
, ndev
, cardtype
))
446 ei_local
= netdev_priv(dev
);
447 ei_local
->msg_enable
= mac8390_msg_enable
;
449 err
= register_netdev(dev
);
460 MODULE_AUTHOR("David Huggins-Daines <dhd@debian.org> and others");
461 MODULE_DESCRIPTION("Macintosh NS8390-based Nubus Ethernet driver");
462 MODULE_LICENSE("GPL");
464 /* overkill, of course */
465 static struct net_device
*dev_mac8390
[15];
466 int init_module(void)
469 for (i
= 0; i
< 15; i
++) {
470 struct net_device
*dev
= mac8390_probe(-1);
476 pr_notice("No useable cards found, driver NOT installed.\n");
482 void cleanup_module(void)
485 for (i
= 0; i
< 15; i
++) {
486 struct net_device
*dev
= dev_mac890
[i
];
488 unregister_netdev(dev
);
496 static const struct net_device_ops mac8390_netdev_ops
= {
497 .ndo_open
= mac8390_open
,
498 .ndo_stop
= mac8390_close
,
499 .ndo_start_xmit
= __ei_start_xmit
,
500 .ndo_tx_timeout
= __ei_tx_timeout
,
501 .ndo_get_stats
= __ei_get_stats
,
502 .ndo_set_rx_mode
= __ei_set_multicast_list
,
503 .ndo_validate_addr
= eth_validate_addr
,
504 .ndo_set_mac_address
= eth_mac_addr
,
505 .ndo_change_mtu
= eth_change_mtu
,
506 #ifdef CONFIG_NET_POLL_CONTROLLER
507 .ndo_poll_controller
= __ei_poll
,
511 static int __init
mac8390_initdev(struct net_device
*dev
,
512 struct nubus_dev
*ndev
,
513 enum mac8390_type type
)
515 static u32 fwrd4_offsets
[16] = {
521 static u32 back4_offsets
[16] = {
527 static u32 fwrd2_offsets
[16] = {
534 int access_bitmode
= 0;
536 /* Now fill in our stuff */
537 dev
->netdev_ops
= &mac8390_netdev_ops
;
539 /* GAR, ei_status is actually a macro even though it looks global */
540 ei_status
.name
= cardname
[type
];
541 ei_status
.word16
= word16
[type
];
543 /* Cabletron's TX/RX buffers are backwards */
544 if (type
== MAC8390_CABLETRON
) {
545 ei_status
.tx_start_page
= CABLETRON_TX_START_PG
;
546 ei_status
.rx_start_page
= CABLETRON_RX_START_PG
;
547 ei_status
.stop_page
= CABLETRON_RX_STOP_PG
;
548 ei_status
.rmem_start
= dev
->mem_start
;
549 ei_status
.rmem_end
= dev
->mem_start
+ CABLETRON_RX_STOP_PG
*256;
551 ei_status
.tx_start_page
= WD_START_PG
;
552 ei_status
.rx_start_page
= WD_START_PG
+ TX_PAGES
;
553 ei_status
.stop_page
= (dev
->mem_end
- dev
->mem_start
)/256;
554 ei_status
.rmem_start
= dev
->mem_start
+ TX_PAGES
*256;
555 ei_status
.rmem_end
= dev
->mem_end
;
558 /* Fill in model-specific information and functions */
560 case MAC8390_FARALLON
:
562 switch (mac8390_testio(dev
->mem_start
)) {
564 pr_err("Don't know how to access card memory!\n");
569 /* 16 bit card, register map is reversed */
570 ei_status
.reset_8390
= mac8390_no_reset
;
571 ei_status
.block_input
= slow_sane_block_input
;
572 ei_status
.block_output
= slow_sane_block_output
;
573 ei_status
.get_8390_hdr
= slow_sane_get_8390_hdr
;
574 ei_status
.reg_offset
= back4_offsets
;
578 /* 32 bit card, register map is reversed */
579 ei_status
.reset_8390
= mac8390_no_reset
;
580 ei_status
.block_input
= sane_block_input
;
581 ei_status
.block_output
= sane_block_output
;
582 ei_status
.get_8390_hdr
= sane_get_8390_hdr
;
583 ei_status
.reg_offset
= back4_offsets
;
590 /* Some Asante cards pass the 32 bit test
591 * but overwrite system memory when run at 32 bit.
592 * so we run them all at 16 bit.
594 ei_status
.reset_8390
= mac8390_no_reset
;
595 ei_status
.block_input
= slow_sane_block_input
;
596 ei_status
.block_output
= slow_sane_block_output
;
597 ei_status
.get_8390_hdr
= slow_sane_get_8390_hdr
;
598 ei_status
.reg_offset
= back4_offsets
;
601 case MAC8390_CABLETRON
:
602 /* 16 bit card, register map is short forward */
603 ei_status
.reset_8390
= mac8390_no_reset
;
604 ei_status
.block_input
= slow_sane_block_input
;
605 ei_status
.block_output
= slow_sane_block_output
;
606 ei_status
.get_8390_hdr
= slow_sane_get_8390_hdr
;
607 ei_status
.reg_offset
= fwrd2_offsets
;
611 case MAC8390_KINETICS
:
612 /* 16 bit memory, register map is forward */
613 /* dayna and similar */
614 ei_status
.reset_8390
= mac8390_no_reset
;
615 ei_status
.block_input
= dayna_block_input
;
616 ei_status
.block_output
= dayna_block_output
;
617 ei_status
.get_8390_hdr
= dayna_get_8390_hdr
;
618 ei_status
.reg_offset
= fwrd4_offsets
;
621 case MAC8390_INTERLAN
:
622 /* 16 bit memory, register map is forward */
623 ei_status
.reset_8390
= interlan_reset
;
624 ei_status
.block_input
= slow_sane_block_input
;
625 ei_status
.block_output
= slow_sane_block_output
;
626 ei_status
.get_8390_hdr
= slow_sane_get_8390_hdr
;
627 ei_status
.reg_offset
= fwrd4_offsets
;
631 pr_err("Card type %s is unsupported, sorry\n",
636 __NS8390_init(dev
, 0);
638 /* Good, done, now spit out some messages */
639 pr_info("%s: %s in slot %X (type %s)\n",
640 dev
->name
, ndev
->board
->name
, ndev
->board
->slot
,
642 pr_info("MAC %pM IRQ %d, %d KB shared memory at %#lx, %d-bit access.\n",
643 dev
->dev_addr
, dev
->irq
,
644 (unsigned int)(dev
->mem_end
- dev
->mem_start
) >> 10,
645 dev
->mem_start
, access_bitmode
? 32 : 16);
649 static int mac8390_open(struct net_device
*dev
)
654 err
= request_irq(dev
->irq
, __ei_interrupt
, 0, "8390 Ethernet", dev
);
656 pr_err("%s: unable to get IRQ %d\n", dev
->name
, dev
->irq
);
660 static int mac8390_close(struct net_device
*dev
)
662 free_irq(dev
->irq
, dev
);
667 static void mac8390_no_reset(struct net_device
*dev
)
669 struct ei_device
*ei_local
= netdev_priv(dev
);
672 netif_info(ei_local
, hw
, dev
, "reset not supported\n");
675 static void interlan_reset(struct net_device
*dev
)
677 unsigned char *target
= nubus_slot_addr(IRQ2SLOT(dev
->irq
));
678 struct ei_device
*ei_local
= netdev_priv(dev
);
680 netif_info(ei_local
, hw
, dev
, "Need to reset the NS8390 t=%lu...",
684 if (netif_msg_hw(ei_local
))
685 pr_cont("reset complete\n");
688 /* dayna_memcpy_fromio/dayna_memcpy_toio */
689 /* directly from daynaport.c by Alan Cox */
690 static void dayna_memcpy_fromcard(struct net_device
*dev
, void *to
, int from
,
693 volatile unsigned char *ptr
;
694 unsigned char *target
= to
;
695 from
<<= 1; /* word, skip overhead */
696 ptr
= (unsigned char *)(dev
->mem_start
+from
);
704 *(unsigned short *)target
= *(unsigned short volatile *)ptr
;
705 ptr
+= 4; /* skip cruft */
714 static void dayna_memcpy_tocard(struct net_device
*dev
, int to
,
715 const void *from
, int count
)
717 volatile unsigned short *ptr
;
718 const unsigned char *src
= from
;
719 to
<<= 1; /* word, skip overhead */
720 ptr
= (unsigned short *)(dev
->mem_start
+to
);
722 if (to
& 2) { /* avoid a byte write (stomps on other data) */
723 ptr
[-1] = (ptr
[-1]&0xFF00)|*src
++;
728 *ptr
++ = *(unsigned short *)src
; /* Copy and */
729 ptr
++; /* skip cruft */
735 /* card doesn't like byte writes */
736 *ptr
= (*ptr
& 0x00FF) | (*src
<< 8);
740 /* sane block input/output */
741 static void sane_get_8390_hdr(struct net_device
*dev
,
742 struct e8390_pkt_hdr
*hdr
, int ring_page
)
744 unsigned long hdr_start
= (ring_page
- WD_START_PG
)<<8;
745 memcpy_fromio(hdr
, dev
->mem_start
+ hdr_start
, 4);
747 hdr
->count
= swab16(hdr
->count
);
750 static void sane_block_input(struct net_device
*dev
, int count
,
751 struct sk_buff
*skb
, int ring_offset
)
753 unsigned long xfer_base
= ring_offset
- (WD_START_PG
<<8);
754 unsigned long xfer_start
= xfer_base
+ dev
->mem_start
;
756 if (xfer_start
+ count
> ei_status
.rmem_end
) {
757 /* We must wrap the input move. */
758 int semi_count
= ei_status
.rmem_end
- xfer_start
;
759 memcpy_fromio(skb
->data
, dev
->mem_start
+ xfer_base
,
762 memcpy_fromio(skb
->data
+ semi_count
, ei_status
.rmem_start
,
765 memcpy_fromio(skb
->data
, dev
->mem_start
+ xfer_base
, count
);
769 static void sane_block_output(struct net_device
*dev
, int count
,
770 const unsigned char *buf
, int start_page
)
772 long shmem
= (start_page
- WD_START_PG
)<<8;
774 memcpy_toio(dev
->mem_start
+ shmem
, buf
, count
);
777 /* dayna block input/output */
778 static void dayna_get_8390_hdr(struct net_device
*dev
,
779 struct e8390_pkt_hdr
*hdr
, int ring_page
)
781 unsigned long hdr_start
= (ring_page
- WD_START_PG
)<<8;
783 dayna_memcpy_fromcard(dev
, hdr
, hdr_start
, 4);
785 hdr
->count
= (hdr
->count
& 0xFF) << 8 | (hdr
->count
>> 8);
788 static void dayna_block_input(struct net_device
*dev
, int count
,
789 struct sk_buff
*skb
, int ring_offset
)
791 unsigned long xfer_base
= ring_offset
- (WD_START_PG
<<8);
792 unsigned long xfer_start
= xfer_base
+dev
->mem_start
;
794 /* Note the offset math is done in card memory space which is word
795 per long onto our space. */
797 if (xfer_start
+ count
> ei_status
.rmem_end
) {
798 /* We must wrap the input move. */
799 int semi_count
= ei_status
.rmem_end
- xfer_start
;
800 dayna_memcpy_fromcard(dev
, skb
->data
, xfer_base
, semi_count
);
802 dayna_memcpy_fromcard(dev
, skb
->data
+ semi_count
,
803 ei_status
.rmem_start
- dev
->mem_start
,
806 dayna_memcpy_fromcard(dev
, skb
->data
, xfer_base
, count
);
810 static void dayna_block_output(struct net_device
*dev
, int count
,
811 const unsigned char *buf
,
814 long shmem
= (start_page
- WD_START_PG
)<<8;
816 dayna_memcpy_tocard(dev
, shmem
, buf
, count
);
819 /* Cabletron block I/O */
820 static void slow_sane_get_8390_hdr(struct net_device
*dev
,
821 struct e8390_pkt_hdr
*hdr
,
824 unsigned long hdr_start
= (ring_page
- WD_START_PG
)<<8;
825 word_memcpy_fromcard(hdr
, dev
->mem_start
+ hdr_start
, 4);
826 /* Register endianism - fix here rather than 8390.c */
827 hdr
->count
= (hdr
->count
&0xFF)<<8|(hdr
->count
>>8);
830 static void slow_sane_block_input(struct net_device
*dev
, int count
,
831 struct sk_buff
*skb
, int ring_offset
)
833 unsigned long xfer_base
= ring_offset
- (WD_START_PG
<<8);
834 unsigned long xfer_start
= xfer_base
+dev
->mem_start
;
836 if (xfer_start
+ count
> ei_status
.rmem_end
) {
837 /* We must wrap the input move. */
838 int semi_count
= ei_status
.rmem_end
- xfer_start
;
839 word_memcpy_fromcard(skb
->data
, dev
->mem_start
+ xfer_base
,
842 word_memcpy_fromcard(skb
->data
+ semi_count
,
843 ei_status
.rmem_start
, count
);
845 word_memcpy_fromcard(skb
->data
, dev
->mem_start
+ xfer_base
,
850 static void slow_sane_block_output(struct net_device
*dev
, int count
,
851 const unsigned char *buf
, int start_page
)
853 long shmem
= (start_page
- WD_START_PG
)<<8;
855 word_memcpy_tocard(dev
->mem_start
+ shmem
, buf
, count
);
858 static void word_memcpy_tocard(unsigned long tp
, const void *fp
, int count
)
860 volatile unsigned short *to
= (void *)tp
;
861 const unsigned short *from
= fp
;
870 static void word_memcpy_fromcard(void *tp
, unsigned long fp
, int count
)
872 unsigned short *to
= tp
;
873 const volatile unsigned short *from
= (const void *)fp
;