| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: if_ec.c,v 1.33 2008/04/28 20:23:52 martin Exp $ */ | | 1 | /* $NetBSD: if_ec.c,v 1.34 2011/04/24 18:54:41 plunky Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, | | 8 | * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, |
9 | * NASA Ames Research Center. | | 9 | * NASA Ames Research Center. |
10 | * | | 10 | * |
11 | * Redistribution and use in source and binary forms, with or without | | 11 | * Redistribution and use in source and binary forms, with or without |
12 | * modification, are permitted provided that the following conditions | | 12 | * modification, are permitted provided that the following conditions |
13 | * are met: | | 13 | * are met: |
14 | * 1. Redistributions of source code must retain the above copyright | | 14 | * 1. Redistributions of source code must retain the above copyright |
| @@ -38,27 +38,27 @@ | | | @@ -38,27 +38,27 @@ |
38 | * | | 38 | * |
39 | * Copyright (C) 1993, David Greenman. This software may be used, modified, | | 39 | * Copyright (C) 1993, David Greenman. This software may be used, modified, |
40 | * copied, distributed, and sold, in both source and binary form provided that | | 40 | * copied, distributed, and sold, in both source and binary form provided that |
41 | * the above copyright and these terms are retained. Under no circumstances is | | 41 | * the above copyright and these terms are retained. Under no circumstances is |
42 | * the author responsible for the proper functioning of this software, nor does | | 42 | * the author responsible for the proper functioning of this software, nor does |
43 | * the author assume any responsibility for damages incurred with its use. | | 43 | * the author assume any responsibility for damages incurred with its use. |
44 | */ | | 44 | */ |
45 | | | 45 | |
46 | /* | | 46 | /* |
47 | * Device driver for the 3Com Etherlink II (3c503). | | 47 | * Device driver for the 3Com Etherlink II (3c503). |
48 | */ | | 48 | */ |
49 | | | 49 | |
50 | #include <sys/cdefs.h> | | 50 | #include <sys/cdefs.h> |
51 | __KERNEL_RCSID(0, "$NetBSD: if_ec.c,v 1.33 2008/04/28 20:23:52 martin Exp $"); | | 51 | __KERNEL_RCSID(0, "$NetBSD: if_ec.c,v 1.34 2011/04/24 18:54:41 plunky Exp $"); |
52 | | | 52 | |
53 | #include <sys/param.h> | | 53 | #include <sys/param.h> |
54 | #include <sys/systm.h> | | 54 | #include <sys/systm.h> |
55 | #include <sys/device.h> | | 55 | #include <sys/device.h> |
56 | #include <sys/socket.h> | | 56 | #include <sys/socket.h> |
57 | #include <sys/mbuf.h> | | 57 | #include <sys/mbuf.h> |
58 | #include <sys/syslog.h> | | 58 | #include <sys/syslog.h> |
59 | | | 59 | |
60 | #include <net/if.h> | | 60 | #include <net/if.h> |
61 | #include <net/if_dl.h> | | 61 | #include <net/if_dl.h> |
62 | #include <net/if_types.h> | | 62 | #include <net/if_types.h> |
63 | #include <net/if_media.h> | | 63 | #include <net/if_media.h> |
64 | | | 64 | |
| @@ -96,28 +96,26 @@ int ec_set_media(struct ec_softc *, int) | | | @@ -96,28 +96,26 @@ int ec_set_media(struct ec_softc *, int) |
96 | | | 96 | |
97 | void ec_media_init(struct dp8390_softc *); | | 97 | void ec_media_init(struct dp8390_softc *); |
98 | | | 98 | |
99 | int ec_mediachange(struct dp8390_softc *); | | 99 | int ec_mediachange(struct dp8390_softc *); |
100 | void ec_mediastatus(struct dp8390_softc *, struct ifmediareq *); | | 100 | void ec_mediastatus(struct dp8390_softc *, struct ifmediareq *); |
101 | | | 101 | |
102 | void ec_init_card(struct dp8390_softc *); | | 102 | void ec_init_card(struct dp8390_softc *); |
103 | int ec_write_mbuf(struct dp8390_softc *, struct mbuf *, int); | | 103 | int ec_write_mbuf(struct dp8390_softc *, struct mbuf *, int); |
104 | int ec_ring_copy(struct dp8390_softc *, int, void *, u_short); | | 104 | int ec_ring_copy(struct dp8390_softc *, int, void *, u_short); |
105 | void ec_read_hdr(struct dp8390_softc *, int, struct dp8390_ring *); | | 105 | void ec_read_hdr(struct dp8390_softc *, int, struct dp8390_ring *); |
106 | int ec_fake_test_mem(struct dp8390_softc *); | | 106 | int ec_fake_test_mem(struct dp8390_softc *); |
107 | int ec_test_mem(struct dp8390_softc *); | | 107 | int ec_test_mem(struct dp8390_softc *); |
108 | | | 108 | |
109 | inline void ec_readmem(struct ec_softc *, int, u_int8_t *, int); | | | |
110 | | | | |
111 | static const int ec_iobase[] = { | | 109 | static const int ec_iobase[] = { |
112 | 0x2e0, 0x2a0, 0x280, 0x250, 0x350, 0x330, 0x310, 0x300, | | 110 | 0x2e0, 0x2a0, 0x280, 0x250, 0x350, 0x330, 0x310, 0x300, |
113 | }; | | 111 | }; |
114 | #define NEC_IOBASE (sizeof(ec_iobase) / sizeof(ec_iobase[0])) | | 112 | #define NEC_IOBASE (sizeof(ec_iobase) / sizeof(ec_iobase[0])) |
115 | | | 113 | |
116 | static const int ec_membase[] = { | | 114 | static const int ec_membase[] = { |
117 | -1, -1, -1, -1, | | 115 | -1, -1, -1, -1, |
118 | 0xc8000, 0xcc000, 0xd8000, 0xdc000, | | 116 | 0xc8000, 0xcc000, 0xd8000, 0xdc000, |
119 | }; | | 117 | }; |
120 | #define NEC_MEMBASE (sizeof(ec_membase) / sizeof(ec_membase[0])) | | 118 | #define NEC_MEMBASE (sizeof(ec_membase) / sizeof(ec_membase[0])) |
121 | | | 119 | |
122 | int | | 120 | int |
123 | ec_probe(device_t parent, cfdata_t match, void *aux) | | 121 | ec_probe(device_t parent, cfdata_t match, void *aux) |
| @@ -539,27 +537,27 @@ ec_test_mem(struct dp8390_softc *sc) | | | @@ -539,27 +537,27 @@ ec_test_mem(struct dp8390_softc *sc) |
539 | return (0); | | 537 | return (0); |
540 | | | 538 | |
541 | fail: | | 539 | fail: |
542 | aprint_error_dev(sc->sc_dev, | | 540 | aprint_error_dev(sc->sc_dev, |
543 | "failed to clear shared memory at offset 0x%x\n", i); | | 541 | "failed to clear shared memory at offset 0x%x\n", i); |
544 | return (1); | | 542 | return (1); |
545 | } | | 543 | } |
546 | | | 544 | |
547 | /* | | 545 | /* |
548 | * Given a NIC memory source address and a host memory destination address, | | 546 | * Given a NIC memory source address and a host memory destination address, |
549 | * copy 'len' from NIC to host using shared memory. The 'len' is rounded | | 547 | * copy 'len' from NIC to host using shared memory. The 'len' is rounded |
550 | * up to a word - ok as long as mbufs are word-sized. | | 548 | * up to a word - ok as long as mbufs are word-sized. |
551 | */ | | 549 | */ |
552 | inline void | | 550 | static inline void |
553 | ec_readmem(struct ec_softc *esc, int from, uint8_t *to, int len) | | 551 | ec_readmem(struct ec_softc *esc, int from, uint8_t *to, int len) |
554 | { | | 552 | { |
555 | bus_space_tag_t memt = esc->sc_dp8390.sc_buft; | | 553 | bus_space_tag_t memt = esc->sc_dp8390.sc_buft; |
556 | bus_space_handle_t memh = esc->sc_dp8390.sc_bufh; | | 554 | bus_space_handle_t memh = esc->sc_dp8390.sc_bufh; |
557 | | | 555 | |
558 | if (len & 1) | | 556 | if (len & 1) |
559 | ++len; | | 557 | ++len; |
560 | | | 558 | |
561 | if (esc->sc_16bitp) | | 559 | if (esc->sc_16bitp) |
562 | bus_space_read_region_2(memt, memh, from, (u_int16_t *)to, | | 560 | bus_space_read_region_2(memt, memh, from, (u_int16_t *)to, |
563 | len >> 1); | | 561 | len >> 1); |
564 | else | | 562 | else |
565 | bus_space_read_region_1(memt, memh, from, to, len); | | 563 | bus_space_read_region_1(memt, memh, from, to, len); |