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