Deleted Added
full compact
if_ed.c (141494) if_ed.c (141495)
1/*-
2 * Copyright (c) 1995, David Greenman
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 12 unchanged lines hidden (view full) ---

21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
28#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1995, David Greenman
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 12 unchanged lines hidden (view full) ---

21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
28#include <sys/cdefs.h>
29__FBSDID("$FreeBSD: head/sys/dev/ed/if_ed.c 141494 2005-02-08 05:45:35Z imp $");
29__FBSDID("$FreeBSD: head/sys/dev/ed/if_ed.c 141495 2005-02-08 05:59:43Z imp $");
30
31/*
32 * Device driver for National Semiconductor DS8390/WD83C690 based ethernet
33 * adapters. By David Greenman, 29-April-1993
34 *
35 * Currently supports the Western Digital/SMC 8003 and 8013 series,
36 * the SMC Elite Ultra (8216), the 3Com 3c503, the NE1000 and NE2000,
37 * and a variety of similar clones.

--- 50 unchanged lines hidden (view full) ---

88
89static void ed_get_packet (struct ed_softc *, char *, /* u_short */ int);
90
91static __inline void ed_rint (struct ed_softc *);
92static __inline void ed_xmit (struct ed_softc *);
93static __inline char * ed_ring_copy(struct ed_softc *, char *, char *,
94 /* u_short */ int);
95static void ed_hpp_set_physical_link(struct ed_softc *);
30
31/*
32 * Device driver for National Semiconductor DS8390/WD83C690 based ethernet
33 * adapters. By David Greenman, 29-April-1993
34 *
35 * Currently supports the Western Digital/SMC 8003 and 8013 series,
36 * the SMC Elite Ultra (8216), the 3Com 3c503, the NE1000 and NE2000,
37 * and a variety of similar clones.

--- 50 unchanged lines hidden (view full) ---

88
89static void ed_get_packet (struct ed_softc *, char *, /* u_short */ int);
90
91static __inline void ed_rint (struct ed_softc *);
92static __inline void ed_xmit (struct ed_softc *);
93static __inline char * ed_ring_copy(struct ed_softc *, char *, char *,
94 /* u_short */ int);
95static void ed_hpp_set_physical_link(struct ed_softc *);
96static void ed_hpp_readmem (struct ed_softc *, int, unsigned char *,
97 /* u_short */ int);
98static void ed_hpp_writemem (struct ed_softc *, unsigned char *,
99 /* u_short */ int, /* u_short */ int);
96static void ed_hpp_readmem(struct ed_softc *, long, uint8_t *, uint16_t);
97static void ed_hpp_writemem(struct ed_softc *, uint8_t *, uint16_t,
98 uint16_t);
100static u_short ed_hpp_write_mbufs(struct ed_softc *, struct mbuf *, int);
101
102static u_short ed_pio_write_mbufs(struct ed_softc *, struct mbuf *, long);
103
99static u_short ed_hpp_write_mbufs(struct ed_softc *, struct mbuf *, int);
100
101static u_short ed_pio_write_mbufs(struct ed_softc *, struct mbuf *, long);
102
104static void ed_setrcr (struct ed_softc *);
103static void ed_setrcr(struct ed_softc *);
105
106/*
107 * Interrupt conversion table for WD/SMC ASIC/83C584
108 */
104
105/*
106 * Interrupt conversion table for WD/SMC ASIC/83C584
107 */
109static unsigned short ed_intr_val[] = {
108static uint16_t ed_intr_val[] = {
110 9,
111 3,
112 5,
113 7,
114 10,
115 11,
116 15,
117 4
118};
119
120/*
121 * Interrupt conversion table for 83C790
122 */
109 9,
110 3,
111 5,
112 7,
113 10,
114 11,
115 15,
116 4
117};
118
119/*
120 * Interrupt conversion table for 83C790
121 */
123static unsigned short ed_790_intr_val[] = {
122static uint16_t ed_790_intr_val[] = {
124 0,
125 9,
126 3,
127 5,
128 7,
129 10,
130 11,
131 15
132};
133
134/*
135 * Interrupt conversion table for the HP PC LAN+
136 */
137
123 0,
124 9,
125 3,
126 5,
127 7,
128 10,
129 11,
130 15
131};
132
133/*
134 * Interrupt conversion table for the HP PC LAN+
135 */
136
138static unsigned short ed_hpp_intr_val[] = {
137static uint16_t ed_hpp_intr_val[] = {
139 0, /* 0 */
140 0, /* 1 */
141 0, /* 2 */
142 3, /* 3 */
143 4, /* 4 */
144 5, /* 5 */
145 6, /* 6 */
146 7, /* 7 */

--- 457 unchanged lines hidden (view full) ---

604int
605ed_probe_WD80x3(dev, port_rid, flags)
606 device_t dev;
607 int port_rid;
608 int flags;
609{
610 struct ed_softc *sc = device_get_softc(dev);
611 int error;
138 0, /* 0 */
139 0, /* 1 */
140 0, /* 2 */
141 3, /* 3 */
142 4, /* 4 */
143 5, /* 5 */
144 6, /* 6 */
145 7, /* 7 */

--- 457 unchanged lines hidden (view full) ---

603int
604ed_probe_WD80x3(dev, port_rid, flags)
605 device_t dev;
606 int port_rid;
607 int flags;
608{
609 struct ed_softc *sc = device_get_softc(dev);
610 int error;
612 static unsigned short *intr_vals[] = {ed_intr_val, ed_790_intr_val};
611 static uint16_t *intr_vals[] = {ed_intr_val, ed_790_intr_val};
613
614 error = ed_alloc_port(dev, port_rid, ED_WD_IO_PORTS);
615 if (error)
616 return (error);
617
618 sc->asic_offset = ED_WD_ASIC_OFFSET;
619 sc->nic_offset = ED_WD_NIC_OFFSET;
620

--- 665 unchanged lines hidden (view full) ---

1286 int flags;
1287{
1288 struct ed_softc *sc = device_get_softc(dev);
1289 int error;
1290 int n; /* temp var */
1291 int memsize; /* mem on board */
1292 u_char checksum; /* checksum of board address */
1293 u_char irq; /* board configured IRQ */
612
613 error = ed_alloc_port(dev, port_rid, ED_WD_IO_PORTS);
614 if (error)
615 return (error);
616
617 sc->asic_offset = ED_WD_ASIC_OFFSET;
618 sc->nic_offset = ED_WD_NIC_OFFSET;
619

--- 665 unchanged lines hidden (view full) ---

1285 int flags;
1286{
1287 struct ed_softc *sc = device_get_softc(dev);
1288 int error;
1289 int n; /* temp var */
1290 int memsize; /* mem on board */
1291 u_char checksum; /* checksum of board address */
1292 u_char irq; /* board configured IRQ */
1294 char test_pattern[ED_HPP_TEST_SIZE]; /* read/write areas for */
1295 char test_buffer[ED_HPP_TEST_SIZE]; /* probing card */
1293 uint8_t test_pattern[ED_HPP_TEST_SIZE]; /* read/write areas for */
1294 uint8_t test_buffer[ED_HPP_TEST_SIZE]; /* probing card */
1296 u_long conf_maddr, conf_msize, conf_irq, junk;
1297
1298 error = ed_alloc_port(dev, 0, ED_HPP_IO_PORTS);
1299 if (error)
1300 return (error);
1301
1302 /* Fill in basic information */
1303 sc->asic_offset = ED_HPP_ASIC_OFFSET;

--- 1546 unchanged lines hidden (view full) ---

2850/*
2851 * Given a NIC memory source address and a host memory destination
2852 * address, copy 'amount' from NIC to host using Programmed I/O.
2853 * The 'amount' is rounded up to a word - okay as long as mbufs
2854 * are word sized.
2855 * This routine is currently Novell-specific.
2856 */
2857void
1295 u_long conf_maddr, conf_msize, conf_irq, junk;
1296
1297 error = ed_alloc_port(dev, 0, ED_HPP_IO_PORTS);
1298 if (error)
1299 return (error);
1300
1301 /* Fill in basic information */
1302 sc->asic_offset = ED_HPP_ASIC_OFFSET;

--- 1546 unchanged lines hidden (view full) ---

2849/*
2850 * Given a NIC memory source address and a host memory destination
2851 * address, copy 'amount' from NIC to host using Programmed I/O.
2852 * The 'amount' is rounded up to a word - okay as long as mbufs
2853 * are word sized.
2854 * This routine is currently Novell-specific.
2855 */
2856void
2858ed_pio_readmem(sc, src, dst, amount)
2859 struct ed_softc *sc;
2860 long src;
2861 unsigned char *dst;
2862 unsigned short amount;
2857ed_pio_readmem(struct ed_softc *sc, long src, uint8_t *dst, uint16_t amount)
2863{
2864 /* HP PC Lan+ cards need special handling */
2865 if (sc->vendor == ED_VENDOR_HP && sc->type == ED_TYPE_HP_PCLANPLUS) {
2866 ed_hpp_readmem(sc, src, dst, amount);
2867 return;
2868 }
2869
2870 /* Regular Novell cards */

--- 22 unchanged lines hidden (view full) ---

2893}
2894
2895/*
2896 * Stripped down routine for writing a linear buffer to NIC memory.
2897 * Only used in the probe routine to test the memory. 'len' must
2898 * be even.
2899 */
2900void
2858{
2859 /* HP PC Lan+ cards need special handling */
2860 if (sc->vendor == ED_VENDOR_HP && sc->type == ED_TYPE_HP_PCLANPLUS) {
2861 ed_hpp_readmem(sc, src, dst, amount);
2862 return;
2863 }
2864
2865 /* Regular Novell cards */

--- 22 unchanged lines hidden (view full) ---

2888}
2889
2890/*
2891 * Stripped down routine for writing a linear buffer to NIC memory.
2892 * Only used in the probe routine to test the memory. 'len' must
2893 * be even.
2894 */
2895void
2901ed_pio_writemem(sc, src, dst, len)
2902 struct ed_softc *sc;
2903 char *src;
2904 unsigned short dst;
2905 unsigned short len;
2896ed_pio_writemem(struct ed_softc *sc, uint8_t *src, uint16_t dst, uint16_t len)
2906{
2907 int maxwait = 200; /* about 240us */
2908
2909 /* select page 0 registers */
2910 ed_nic_outb(sc, ED_P0_CR, ED_CR_RD2 | ED_CR_STA);
2911
2912 /* reset remote DMA complete flag */
2913 ed_nic_outb(sc, ED_P0_ISR, ED_ISR_RDC);

--- 151 unchanged lines hidden (view full) ---

3065 */
3066
3067/*
3068 * HP PC Lan+: Read from NIC memory, using either PIO or memory mapped
3069 * IO.
3070 */
3071
3072static void
2897{
2898 int maxwait = 200; /* about 240us */
2899
2900 /* select page 0 registers */
2901 ed_nic_outb(sc, ED_P0_CR, ED_CR_RD2 | ED_CR_STA);
2902
2903 /* reset remote DMA complete flag */
2904 ed_nic_outb(sc, ED_P0_ISR, ED_ISR_RDC);

--- 151 unchanged lines hidden (view full) ---

3056 */
3057
3058/*
3059 * HP PC Lan+: Read from NIC memory, using either PIO or memory mapped
3060 * IO.
3061 */
3062
3063static void
3073ed_hpp_readmem(sc, src, dst, amount)
3074 struct ed_softc *sc;
3075 unsigned short src;
3076 unsigned char *dst;
3077 unsigned short amount;
3064ed_hpp_readmem(struct ed_softc *sc, long src, uint8_t *dst, uint16_t amount)
3078{
3079
3080 int use_32bit_access = !(sc->hpp_id & ED_HPP_ID_16_BIT_ACCESS);
3081
3082
3083 /* Program the source address in RAM */
3084 ed_asic_outw(sc, ED_HPP_PAGE_2, src);
3085

--- 82 unchanged lines hidden (view full) ---

3168
3169/*
3170 * HP PC Lan+: Write to NIC memory, using either PIO or memory mapped
3171 * IO.
3172 * Only used in the probe routine to test the memory. 'len' must
3173 * be even.
3174 */
3175static void
3065{
3066
3067 int use_32bit_access = !(sc->hpp_id & ED_HPP_ID_16_BIT_ACCESS);
3068
3069
3070 /* Program the source address in RAM */
3071 ed_asic_outw(sc, ED_HPP_PAGE_2, src);
3072

--- 82 unchanged lines hidden (view full) ---

3155
3156/*
3157 * HP PC Lan+: Write to NIC memory, using either PIO or memory mapped
3158 * IO.
3159 * Only used in the probe routine to test the memory. 'len' must
3160 * be even.
3161 */
3162static void
3176ed_hpp_writemem(sc, src, dst, len)
3177 struct ed_softc *sc;
3178 unsigned char *src;
3179 unsigned short dst;
3180 unsigned short len;
3163ed_hpp_writemem(struct ed_softc *sc, uint8_t *src, uint16_t dst, uint16_t len)
3181{
3182 /* reset remote DMA complete flag */
3183 ed_nic_outb(sc, ED_P0_ISR, ED_ISR_RDC);
3184
3185 /* program the write address in RAM */
3186 ed_asic_outw(sc, ED_HPP_PAGE_0, dst);
3187
3188 if (sc->hpp_mem_start) {

--- 362 unchanged lines hidden ---
3164{
3165 /* reset remote DMA complete flag */
3166 ed_nic_outb(sc, ED_P0_ISR, ED_ISR_RDC);
3167
3168 /* program the write address in RAM */
3169 ed_asic_outw(sc, ED_HPP_PAGE_0, dst);
3170
3171 if (sc->hpp_mem_start) {

--- 362 unchanged lines hidden ---