No empty .Rs/.Re
[netbsd-mini2440.git] / sys / dev / if_ndis / if_ndisvar.h
blob5d7b005ed6efaa1f4e3805bdf1902a471300555e
1 /*-
2 * Copyright (c) 2003
3 * Bill Paul <wpaul@windriver.com>. All rights reserved.
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, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by Bill Paul.
16 * 4. Neither the name of the author nor the names of any co-contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30 * THE POSSIBILITY OF SUCH DAMAGE.
32 * $FreeBSD: src/sys/dev/if_ndis/if_ndisvar.h,v 1.15.2.2 2005/02/18 16:30:10 wpaul Exp $
33 */
35 #define NDIS_DEFAULT_NODENAME "FreeBSD NDIS node"
36 #define NDIS_NODENAME_LEN 32
38 #ifdef __NetBSD__
39 #include <dev/pci/pcivar.h>
40 #include <dev/pci/pcireg.h>
41 #include <dev/pci/pcidevs.h>
43 #include <dev/pcmcia/pcmciareg.h>
44 #include <dev/pcmcia/pcmciavar.h>
45 #include <dev/pcmcia/pcmciadevs.h>
47 #include <dev/cardbus/cardbusvar.h>
48 #include <dev/cardbus/cardbusreg.h>
49 #endif
51 struct ndis_pci_type {
52 const uint16_t ndis_vid;
53 const uint16_t ndis_did;
54 const uint32_t ndis_subsys;
55 const char *ndis_name;
58 struct ndis_pccard_type {
59 const char *ndis_vid;
60 const char *ndis_did;
61 char *ndis_name;
64 struct ndis_shmem {
65 bus_dma_tag_t ndis_stag;
66 bus_dmamap_t ndis_smap;
67 void *ndis_saddr;
68 struct ndis_shmem *ndis_next;
71 struct ndis_cfglist {
72 ndis_cfg ndis_cfg;
73 TAILQ_ENTRY(ndis_cfglist) link;
76 TAILQ_HEAD(nch, ndis_cfglist);
78 #define NDIS_INITIALIZED(sc) (sc->ndis_block->nmb_miniportadapterctx != NULL)
80 #define NDIS_INC(x) \
81 (x)->ndis_txidx = ((x)->ndis_txidx + 1) % (x)->ndis_maxpkts
83 #ifdef __NetBSD__
84 /*
85 * A linked list of resources
87 struct resource {
88 SLIST_ENTRY(resource) link;
89 cm_partial_resource_desc win_res;
91 SLIST_HEAD(resource_list, resource);
92 #endif /* __NetBSD__ */
94 #ifdef __FreeBSD__
95 #define arpcom ic.ic_ac
96 #endif
98 #ifdef __NetBSD__
99 struct ndis_resource {
100 bus_space_handle_t res_handle;
101 bus_space_tag_t res_tag;
102 bus_addr_t res_base;
103 bus_size_t res_size;
105 #endif
107 #ifdef __NetBSD__
108 int ndis_in_isr;
109 #endif
111 struct ndis_softc {
112 #ifdef __NetBSD__
114 * TODO: It seems like in the attach function the ndis "struct device" object
115 * and the softc are the same thing, so I added a "struct device" to the
116 * front of the softc, to make sure the arpcom field wasn't getting
117 * messed up. However, I'm not sure if the arpcom field is supposed
118 * to be first for some other reason.
120 struct device dev;
121 struct ethercom arpcom;
122 #endif
123 struct ieee80211com ic; /* interface info */
124 #ifdef notdef
125 struct ieee80211com arpcom; /* interface info */
126 #endif
127 struct ifmedia ifmedia; /* media info */
128 u_long ndis_hwassist;
129 uint32_t ndis_v4tx;
130 uint32_t ndis_v4rx;
131 bus_space_handle_t ndis_bhandle;
132 bus_space_tag_t ndis_btag;
133 void *ndis_intrhand;
134 #ifdef __FreeBSD__
135 struct resource *ndis_irq;
136 struct resource *ndis_res;
137 struct resource *ndis_res_io;
138 int ndis_io_rid;
139 struct resource *ndis_res_mem;
140 int ndis_mem_rid;
141 struct resource *ndis_res_altmem;
142 int ndis_altmem_rid;
143 struct resource *ndis_res_am; /* attribute mem (pccard) */
144 int ndis_am_rid;
145 struct resource *ndis_res_cm; /* common mem (pccard) */
146 struct resource_list ndis_rl;
147 #else /* __NetBSD__ */
148 uint8_t ndis_mac[ETHER_ADDR_LEN];
149 int ndis_sysctl_mib;
150 struct sysctllog *sysctllog;
152 //ndis_resource_list ndis_rl;
153 ndis_resource_list *ndis_rl;
154 int error;
155 /* TODO: Is the ndis_irq set up right? */
156 void *ndis_irq;
158 /* for both pci and cardbus ? */
159 struct ndis_resource *ndis_res_io;
160 int ndis_io_rid; /* not actuially used, just for bus_release_resource() */
161 struct ndis_resource *ndis_res_mem;
162 struct ndis_resource *ndis_res_altmem;
163 int ndis_mem_rid; /* not actuially used, just for bus_release_resource() */
165 /* pci specific */
166 pci_chipset_tag_t ndis_res_pc; /* pci chipset */
167 pcitag_t ndis_res_pctag; /* pci tag */
168 pci_intr_handle_t pci_ih; /* interrupt handle */
170 /* pcmcia specific */
171 struct pcmcia_io_handle ndis_res_pcioh; /* specific i/o for pcmcia */
172 struct pcmcia_mem_handle ndis_res_pcmem; /* specific mem for pcmcia */
173 int sc_io_windows; /* i/o window */
174 struct pcmcia_function * ndis_res_pcfunc; /* pcmcia function */
176 /* cardbus specific */
177 cardbus_devfunc_t ndis_res_ct; /* cardbus devfuncs */
178 cardbustag_t ndis_res_ctag; /* carbus tag */
179 bus_size_t ndis_res_mapsize; /* size of mapped bus space region */
180 #endif /* end __NetBSD__ section */
181 int ndis_rescnt;
182 #ifdef __FreeBSD__
183 struct mtx ndis_mtx;
184 #else /* __NetBSD__ */
185 struct simplelock ndis_mtx;
186 #endif
187 device_t ndis_dev;
188 int ndis_unit;
189 ndis_miniport_block *ndis_block;
190 ndis_miniport_characteristics *ndis_chars;
191 interface_type ndis_type;
192 #ifdef __FreeBSD__
193 struct callout_handle ndis_stat_ch;
194 #else
195 struct callout ndis_stat_ch;
196 #endif
197 int ndis_maxpkts;
198 ndis_oid *ndis_oids;
199 int ndis_oidcnt;
200 int ndis_txidx;
201 int ndis_txpending;
202 ndis_packet **ndis_txarray;
203 ndis_handle ndis_txpool;
204 int ndis_sc;
205 ndis_cfg *ndis_regvals;
206 struct nch ndis_cfglist_head;
207 int ndis_80211;
208 int ndis_link;
209 uint32_t ndis_filter;
210 int ndis_if_flags;
211 int ndis_skip;
213 #ifdef __FreeBSD__
214 struct sysctl_ctx_list ndis_ctx;
215 #endif
216 #if __FreeBSD__ && __FreeBSD_version < 502113
217 struct sysctl_oid *ndis_tree;
218 #endif
219 int ndis_devidx;
220 interface_type ndis_iftype;
222 bus_dma_tag_t ndis_parent_tag;
223 struct ndis_shmem *ndis_shlist;
224 bus_dma_tag_t ndis_mtag;
225 bus_dma_tag_t ndis_ttag;
226 bus_dmamap_t *ndis_mmaps;
227 bus_dmamap_t *ndis_tmaps;
228 int ndis_mmapcnt;
231 #ifdef __FreeBSD__
233 #define NDIS_LOCK(_sc) mtx_lock(&(_sc)->ndis_mtx)
234 #define NDIS_UNLOCK(_sc) mtx_unlock(&(_sc)->ndis_mtx)
236 #else /* __NetBSD__ */
238 #define NDIS_LOCK(_sc) do {s = spl_sc(); simple_lock(&(_sc)->ndis_mtx);} while(0)
239 #define NDIS_UNLOCK(_sc) do {simple_unlock(&(_sc)->ndis_mtx); splx(s);} while(0)
240 #define spl_sc() splnet()
242 #endif
244 /*static*/ __stdcall void ndis_txeof (ndis_handle, ndis_packet *, ndis_status);
245 /*static*/ __stdcall void ndis_rxeof (ndis_handle, ndis_packet **, uint32_t);
246 /*static*/ __stdcall void ndis_linksts (ndis_handle, ndis_status, void *, uint32_t);
247 /*static*/ __stdcall void ndis_linksts_done (ndis_handle);