Fixed binary search: no more infinite loops when vendor is unknown.
[tangerine.git] / workbench / devs / networks / prism2 / device.h
blob542fc29ac677bf6acd431dbcbb42dbe5c36999f3
1 /*
3 Copyright (C) 2001-2007 Neil Cafferkey
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18 MA 02111-1307, USA.
22 #ifndef DEVICE_H
23 #define DEVICE_H
26 #include <exec/types.h>
27 #include <exec/devices.h>
28 #include <exec/interrupts.h>
29 #include <exec/semaphores.h>
30 #include <devices/sana2.h>
31 #include <devices/sana2specialstats.h>
32 #include <devices/timer.h>
33 #include <dos/dosextens.h>
35 #include "wireless.h"
36 #include "io.h"
38 #define DEVICE_NAME "prism2.device"
39 #define VERSION 1
40 #define REVISION 7
41 #define DATE "29.10.2007"
43 #define UTILITY_VERSION 39
44 #define PROMETHEUS_VERSION 2
45 #define POWERPCI_VERSION 2
46 #define EXPANSION_VERSION 50
47 #define OPENPCI_VERSION 1
48 #define PCCARD_VERSION 1
49 #define DOS_VERSION 36
51 #ifndef UPINT
52 #ifdef __AROS__
53 typedef IPTR UPINT;
54 typedef SIPTR PINT;
55 #else
56 typedef ULONG UPINT;
57 typedef LONG PINT;
58 #endif
59 #endif
61 #ifndef REG
62 #ifdef __mc68000
63 #define _REG(A, B) B __asm(#A)
64 #define REG(A, B) _REG(A, B)
65 #else
66 #define REG(A, B) B
67 #endif
68 #endif
70 #define _STR(A) #A
71 #define STR(A) _STR(A)
73 #ifndef __AROS__
74 #define USE_HACKS
75 #endif
78 struct DevBase
80 struct Device device;
81 APTR seg_list;
82 struct ExecBase *sys_base;
83 struct UtilityBase *utility_base;
84 struct Library *prometheus_base;
85 struct Library *powerpci_base;
86 struct Library *openpci_base;
87 struct Library *pccard_base;
88 APTR card_base;
89 struct DosLibrary *dos_base;
90 struct MinList pci_units;
91 struct MinList pccard_units;
92 struct timerequest timer_request;
93 #ifdef __amigaos4__
94 struct Library *expansion_base;
95 struct ExecIFace *i_exec;
96 struct UtilityIFace *i_utility;
97 struct PCIIFace *i_pci;
98 struct DOSIFace *i_dos;
99 struct TimerIFace *i_timer;
100 #endif
101 VOID (*wrapper_int_code)();
105 enum
107 WRITE_QUEUE,
108 ADOPT_QUEUE,
109 EVENT_QUEUE,
110 GENERAL_QUEUE,
111 REQUEST_QUEUE_COUNT
114 enum
116 PCI_BUS,
117 TMD_BUS,
118 PLX_BUS,
119 PCCARD_BUS
122 enum
124 LUCENT_FIRMWARE,
125 INTERSIL_FIRMWARE,
126 SYMBOL_FIRMWARE,
127 HERMES2_FIRMWARE,
128 AIRONET_FIRMWARE
131 #define IO_WINDOW_SIZE 0x40
133 #define ETH_ADDRESSSIZE 6
134 #define ETH_HEADERSIZE 14
135 #define ETH_SNAPHEADERSIZE 22
136 #define ETH_MTU 1500
137 #define ETH_MAXPACKETSIZE ((ETH_HEADERSIZE) + (ETH_MTU))
139 #define ETH_PACKET_DEST 0
140 #define ETH_PACKET_SOURCE 6
141 #define ETH_PACKET_TYPE 12
142 #define ETH_PACKET_IEEELEN 12
143 #define ETH_PACKET_SNAPTYPE 20
144 #define ETH_PACKET_DATA 14
146 #define STAT_COUNT 3
149 struct DevUnit
151 struct MinNode node;
152 ULONG index;
153 ULONG open_count;
154 UWORD flags;
155 UWORD bus;
156 struct Task *task;
157 struct MsgPort *request_ports[REQUEST_QUEUE_COUNT];
158 struct DevBase *device;
159 APTR card;
160 BOOL (*insertion_function)(APTR, struct DevBase *);
161 VOID (*removal_function)(APTR, struct DevBase *);
162 VOID (*WordsIn)(APTR, ULONG, UWORD *, ULONG);
163 VOID (*WordsOut)(APTR, ULONG, const UWORD *, ULONG);
164 VOID (*BEWordOut)(APTR, ULONG, UWORD);
165 UWORD (*LEWordIn)(APTR, ULONG);
166 VOID (*LEWordOut)(APTR, ULONG, UWORD);
167 UBYTE *rx_buffer;
168 UBYTE *tx_buffer;
169 UBYTE ssid[IEEE802_11_MAXIDLEN];
170 ULONG card_removed_signal;
171 ULONG card_inserted_signal;
172 ULONG range_count;
173 UBYTE address[ETH_ADDRESSSIZE];
174 UBYTE default_address[ETH_ADDRESSSIZE];
175 struct MinList openers;
176 struct MinList type_trackers;
177 struct MinList multicast_ranges;
178 struct Interrupt status_int;
179 struct Interrupt rx_int;
180 struct Interrupt tx_int;
181 struct Interrupt info_int;
182 struct Sana2DeviceStats stats;
183 ULONG special_stats[STAT_COUNT];
184 ULONG speed;
185 struct Sana2SignalQuality signal_quality;
186 struct SignalSemaphore access_lock;
187 UWORD encryption;
188 UWORD tx_frame_id;
189 UWORD mode;
190 UWORD channel;
191 UWORD firmware_type;
192 UWORD ssid_length;
193 UWORD key_no;
194 struct WEPKey keys[IEEE802_11_WEPKEYCOUNT];
198 struct Opener
200 struct MinNode node;
201 struct MsgPort read_port;
202 BOOL (*rx_function)(REG(a0, APTR), REG(a1, APTR), REG(d0, ULONG));
203 BOOL (*tx_function)(REG(a0, APTR), REG(a1, APTR), REG(d0, ULONG));
204 UBYTE *(*dma_tx_function)(REG(a0, APTR));
205 struct Hook *filter_hook;
206 struct MinList initial_stats;
207 #if defined(__amigaos4__) || defined(__MORPHOS__)
208 const VOID *real_rx_function;
209 const VOID *real_tx_function;
210 const VOID *real_dma_tx_function;
211 #endif
215 struct TypeStats
217 struct MinNode node;
218 ULONG packet_type;
219 struct Sana2PacketTypeStats stats;
223 struct TypeTracker
225 struct MinNode node;
226 ULONG packet_type;
227 struct Sana2PacketTypeStats stats;
228 ULONG user_count;
232 struct AddressRange
234 struct MinNode node;
235 ULONG add_count;
236 ULONG lower_bound_left;
237 ULONG upper_bound_left;
238 UWORD lower_bound_right;
239 UWORD upper_bound_right;
243 /* Unit flags */
245 #define UNITF_SHARED (1 << 0)
246 #define UNITF_ONLINE (1 << 1)
247 #define UNITF_HAVEADAPTER (1 << 3)
248 #define UNITF_CONFIGURED (1 << 4)
249 #define UNITF_PROM (1 << 5)
250 #define UNITF_WASONLINE (1 << 6) /* card was online at time of removal */
251 #define UNITF_HASWEP (1 << 7)
252 #define UNITF_ALLMCAST (1 << 8)
255 /* Endianness macros */
257 #define FlipWord(A) \
258 ({ \
259 UWORD _FlipWord_A = (A); \
260 _FlipWord_A = (_FlipWord_A << 8) | (_FlipWord_A >> 8); \
263 #define FlipLong(A) \
264 ({ \
265 ULONG _FlipLong_A = (A); \
266 _FlipLong_A = \
267 (FlipWord(_FlipLong_A) << 16) | FlipWord(_FlipLong_A >> 16); \
270 #ifndef __i386__ /* Big endian */
272 #define BEWord(A) \
275 #define BELong(A) \
278 #define LEWord(A) \
279 FlipWord(A)
281 #define LELong(A) \
282 FlipLong(A)
284 #else
286 #define BEWord(A) \
287 FlipWord(A)
289 #define BELong(A) \
290 FlipLong(A)
292 #define LEWord(A) \
295 #define LELong(A) \
298 #endif
300 #define MakeBEWord(A) \
301 BEWord(A)
303 #define MakeBELong(A) \
304 BELong(A)
306 #define MakeLEWord(A) \
307 LEWord(A)
309 #define MakeLELong(A) \
310 LELong(A)
313 /* Library and device bases */
315 #define SysBase (base->sys_base)
316 #define CardResource (base->card_base)
317 #define UtilityBase (base->utility_base)
318 #define ExpansionBase (base->expansion_base)
319 #define OpenPciBase (base->openpci_base)
320 #define PrometheusBase (base->prometheus_base)
321 #define PowerPCIBase (base->powerpci_base)
322 #define PCCardBase (base->pccard_base)
323 #define DOSBase (base->dos_base)
324 #define TimerBase (base->timer_request.tr_node.io_Device)
326 #ifdef __amigaos4__
327 #define IExec (base->i_exec)
328 #define IUtility (base->i_utility)
329 #define IDOS (base->i_dos)
330 #define ITimer (base->i_timer)
331 #endif
333 #ifndef BASE_REG
334 #define BASE_REG a6
335 #endif
338 #endif