__P!= wanted
[dragonfly.git] / sys / dev / netif / ed / if_edvar.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
9  *    notice unmodified, this list of conditions, and the following
10  *    disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
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  * $FreeBSD: src/sys/dev/ed/if_edvar.h,v 1.4.2.4 2001/07/25 18:06:01 iedowse Exp $
28  * $DragonFly: src/sys/dev/netif/ed/if_edvar.h,v 1.3 2003/08/27 09:38:30 rob Exp $
29  */
30
31 /*
32  * ed_softc: per line info and status
33  */
34 struct ed_softc {
35         struct arpcom arpcom;   /* ethernet common */
36
37         char   *type_str;       /* pointer to type string */
38         u_char  vendor;         /* interface vendor */
39         u_char  type;           /* interface type code */
40         u_char  gone;           /* HW missing, presumed having a good time */
41
42         int     port_rid;       /* resource id for port range */
43         int     port_used;      /* nonzero if ports used */
44         struct resource* port_res; /* resource for port range */
45         int     mem_rid;        /* resource id for memory range */
46         int     mem_used;       /* nonzero if memory used */
47         struct resource* mem_res; /* resource for memory range */
48         int     irq_rid;        /* resource id for irq */
49         struct resource* irq_res; /* resource for irq */
50         void*   irq_handle;     /* handle for irq handler */
51         device_t miibus;        /* MII bus for cards with MII. */
52         void    (*mii_writebits)(struct ed_softc *, u_int, int);
53         u_int   (*mii_readbits)(struct ed_softc *, int);
54         struct callout_handle tick_ch; /* Callout handle for ed_tick */
55
56         int     nic_offset;     /* NIC (DS8390) I/O bus address offset */
57         int     asic_offset;    /* ASIC I/O bus address offset */
58
59 /*
60  * The following 'proto' variable is part of a work-around for 8013EBT asics
61  *      being write-only. It's sort of a prototype/shadow of the real thing.
62  */
63         u_char  wd_laar_proto;
64         u_char  cr_proto;
65         u_char  isa16bit;       /* width of access to card 0=8 or 1=16 */
66         int     chip_type;      /* the type of chip (one of ED_CHIP_TYPE_*) */
67
68 /*
69  * HP PC LAN PLUS card support.
70  */
71
72         u_short hpp_options;    /* flags controlling behaviour of the HP card */
73         u_short hpp_id;         /* software revision and other fields */
74         caddr_t hpp_mem_start;  /* Memory-mapped IO register address */
75
76         caddr_t mem_start;      /* NIC memory start address */
77         caddr_t mem_end;                /* NIC memory end address */
78         u_int32_t mem_size;     /* total NIC memory size */
79         caddr_t mem_ring;       /* start of RX ring-buffer (in NIC mem) */
80
81         u_char  mem_shared;     /* NIC memory is shared with host */
82         u_char  xmit_busy;      /* transmitter is busy */
83         u_char  txb_cnt;        /* number of transmit buffers */
84         u_char  txb_inuse;      /* number of TX buffers currently in-use */
85
86         u_char  txb_new;        /* pointer to where new buffer will be added */
87         u_char  txb_next_tx;    /* pointer to next buffer ready to xmit */
88         u_short txb_len[8];     /* buffered xmit buffer lengths */
89         u_char  tx_page_start;  /* first page of TX buffer area */
90         u_char  rec_page_start; /* first page of RX ring-buffer */
91         u_char  rec_page_stop;  /* last page of RX ring-buffer */
92         u_char  next_packet;    /* pointer to next unread RX packet */
93         struct  ifmib_iso_8802_3 mibdata; /* stuff for network mgmt */
94 };
95
96 #define ed_nic_inb(sc, port) \
97         bus_space_read_1(rman_get_bustag((sc)->port_res), \
98                 rman_get_bushandle((sc)->port_res), (sc)->nic_offset + (port))
99
100 #define ed_nic_outb(sc, port, value) \
101         bus_space_write_1(rman_get_bustag((sc)->port_res), \
102                 rman_get_bushandle((sc)->port_res), (sc)->nic_offset + (port), \
103                 (value))
104
105 #define ed_nic_inw(sc, port) \
106         bus_space_read_2(rman_get_bustag((sc)->port_res), \
107                 rman_get_bushandle((sc)->port_res), (sc)->nic_offset + (port))
108
109 #define ed_nic_outw(sc, port, value) \
110         bus_space_write_2(rman_get_bustag((sc)->port_res), \
111                 rman_get_bushandle((sc)->port_res), (sc)->nic_offset + (port), \
112                 (value))
113
114 #define ed_nic_insb(sc, port, addr, count) \
115         bus_space_read_multi_1(rman_get_bustag((sc)->port_res), \
116                 rman_get_bushandle((sc)->port_res), \
117                 (sc)->nic_offset + (port), (addr), (count))
118
119 #define ed_nic_outsb(sc, port, addr, count) \
120         bus_space_write_multi_1(rman_get_bustag((sc)->port_res), \
121                 rman_get_bushandle((sc)->port_res), \
122                 (sc)->nic_offset + (port), (addr), (count))
123
124 #define ed_nic_insw(sc, port, addr, count) \
125         bus_space_read_multi_2(rman_get_bustag((sc)->port_res), \
126                 rman_get_bushandle((sc)->port_res), \
127                 (sc)->nic_offset + (port), (u_int16_t *)(addr), (count))
128
129 #define ed_nic_outsw(sc, port, addr, count) \
130         bus_space_write_multi_2(rman_get_bustag((sc)->port_res), \
131                 rman_get_bushandle((sc)->port_res), \
132                 (sc)->nic_offset + (port), (u_int16_t *)(addr), (count))
133
134 #define ed_nic_insl(sc, port, addr, count) \
135         bus_space_read_multi_4(rman_get_bustag((sc)->port_res), \
136                 rman_get_bushandle((sc)->port_res), \
137                 (sc)->nic_offset + (port), (u_int32_t *)(addr), (count))
138
139 #define ed_nic_outsl(sc, port, addr, count) \
140         bus_space_write_multi_4(rman_get_bustag((sc)->port_res), \
141                 rman_get_bushandle((sc)->port_res), \
142                 (sc)->nic_offset + (port), (u_int32_t *)(addr), (count))
143
144 #define ed_asic_inb(sc, port) \
145         bus_space_read_1(rman_get_bustag((sc)->port_res), \
146                 rman_get_bushandle((sc)->port_res), (sc)->asic_offset + (port))
147
148 #define ed_asic_outb(sc, port, value) \
149         bus_space_write_1(rman_get_bustag((sc)->port_res), \
150                 rman_get_bushandle((sc)->port_res), (sc)->asic_offset + (port), \
151                 (value))
152
153 #define ed_asic_inw(sc, port) \
154         bus_space_read_2(rman_get_bustag((sc)->port_res), \
155                 rman_get_bushandle((sc)->port_res), (sc)->asic_offset + (port))
156
157 #define ed_asic_outw(sc, port, value) \
158         bus_space_write_2(rman_get_bustag((sc)->port_res), \
159                 rman_get_bushandle((sc)->port_res), (sc)->asic_offset + (port), \
160                 (value))
161
162 #define ed_asic_insb(sc, port, addr, count) \
163         bus_space_read_multi_1(rman_get_bustag((sc)->port_res), \
164                 rman_get_bushandle((sc)->port_res), \
165                 (sc)->asic_offset + (port), (addr), (count))
166
167 #define ed_asic_outsb(sc, port, addr, count) \
168         bus_space_write_multi_1(rman_get_bustag((sc)->port_res), \
169                 rman_get_bushandle((sc)->port_res), \
170                 (sc)->asic_offset + (port), (addr), (count))
171
172 #define ed_asic_insw(sc, port, addr, count) \
173         bus_space_read_multi_2(rman_get_bustag((sc)->port_res), \
174                 rman_get_bushandle((sc)->port_res), \
175                 (sc)->asic_offset + (port), (u_int16_t *)(addr), (count))
176
177 #define ed_asic_outsw(sc, port, addr, count) \
178         bus_space_write_multi_2(rman_get_bustag((sc)->port_res), \
179                 rman_get_bushandle((sc)->port_res), \
180                 (sc)->asic_offset + (port), (u_int16_t *)(addr), (count))
181
182 #define ed_asic_insl(sc, port, addr, count) \
183         bus_space_read_multi_4(rman_get_bustag((sc)->port_res), \
184                 rman_get_bushandle((sc)->port_res), \
185                 (sc)->asic_offset + (port), (u_int32_t *)(addr), (count))
186
187 #define ed_asic_outsl(sc, port, addr, count) \
188         bus_space_write_multi_4(rman_get_bustag((sc)->port_res), \
189                 rman_get_bushandle((sc)->port_res), \
190                 (sc)->asic_offset + (port), (u_int32_t *)(addr), (count))
191
192 void    ed_release_resources    (device_t);
193 int     ed_alloc_port           (device_t, int, int);
194 int     ed_alloc_memory         (device_t, int, int);
195 int     ed_alloc_irq            (device_t, int, int);
196
197 int     ed_probe_generic8390    (struct ed_softc *);
198 int     ed_probe_WD80x3         (device_t, int, int);
199 int     ed_probe_WD80x3_generic (device_t, int, unsigned short *[]);
200 int     ed_probe_3Com           (device_t, int, int);
201 int     ed_probe_Novell         (device_t, int, int);
202 int     ed_probe_Novell_generic (device_t, int);
203 int     ed_probe_HP_pclanp      (device_t, int, int);
204
205 int     ed_attach               (struct ed_softc *, int, int);
206 void    ed_stop                 (struct ed_softc *);
207 void    ed_pio_readmem          (struct ed_softc *, int, unsigned char *,
208                                      unsigned short);
209 void    ed_pio_writemem         (struct ed_softc *, char *,
210                                      unsigned short, unsigned short);
211 int     ed_miibus_readreg       (device_t, int, int);
212 void    ed_miibus_writereg      (device_t, int, int, int);
213 int     ed_ifmedia_upd          (struct ifnet *);
214 void    ed_ifmedia_sts          (struct ifnet *, struct ifmediareq *);
215 void    ed_child_detached       (device_t, device_t);
216
217 driver_intr_t   edintr;
218