revert between 56095 -> 55830 in arch
[AROS.git] / workbench / devs / networks / prism2 / device.h
blob6d9c9f60e34936fd95a22c628709d10e44de1a35
1 /*
3 Copyright (C) 2001-2017 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/sana2wireless.h>
33 #include <devices/timer.h>
35 #include "wireless.h"
36 #include "io.h"
38 #define DEVICE_NAME "prism2.device"
39 #define VERSION 2
40 #define REVISION 6
41 #define DATE "9.5.2017"
43 #define UTILITY_VERSION 39
44 #define PROMETHEUS_VERSION 2
45 #define POWERPCI_VERSION 2
46 #define CYBPCI_VERSION 2
47 #define EXPANSION_VERSION 50
48 #define OPENPCI_VERSION 1
49 #define PCCARD_VERSION 1
50 #define DOS_VERSION 36
52 #ifndef UPINT
53 #ifdef __AROS__
54 typedef IPTR UPINT;
55 typedef SIPTR PINT;
56 #else
57 typedef ULONG UPINT;
58 typedef LONG PINT;
59 #endif
60 #endif
62 #ifndef REG
63 #if defined(__mc68000) && !defined(__AROS__)
64 #define _REG(A, B) B __asm(#A)
65 #define REG(A, B) _REG(A, B)
66 #else
67 #define REG(A, B) B
68 #endif
69 #endif
71 #define _STR(A) #A
72 #define STR(A) _STR(A)
74 #ifndef __AROS__
75 #define USE_HACKS
76 #endif
78 #if defined(__mc68000) && !defined(__AROS__)
79 #define AddResetCallback(callback) TRUE
80 #define RemResetCallback(callback)
81 #endif
84 struct DevBase
86 struct Device device;
87 APTR seg_list;
88 struct ExecBase *sys_base;
89 struct UtilityBase *utility_base;
90 struct Library *prometheus_base;
91 struct Library *powerpci_base;
92 struct Library *cybpci_base;
93 struct Library *openpci_base;
94 struct Library *pccard_base;
95 APTR card_base;
96 struct DosLibrary *dos_base;
97 struct MinList pci_units;
98 struct MinList pccard_units;
99 struct timerequest timer_request;
100 #ifdef __amigaos4__
101 struct Library *expansion_base;
102 struct ExecIFace *i_exec;
103 struct UtilityIFace *i_utility;
104 struct PCIIFace *i_pci;
105 struct CardIFace *i_card;
106 struct PCCardIFace *i_pccard;
107 struct DOSIFace *i_dos;
108 struct TimerIFace *i_timer;
109 #endif
110 VOID (*wrapper_int_code)();
111 VOID (*wrapper_card_code)();
115 enum
117 WRITE_QUEUE,
118 ADOPT_QUEUE,
119 EVENT_QUEUE,
120 SCAN_QUEUE,
121 GENERAL_QUEUE,
122 REQUEST_QUEUE_COUNT
125 enum
127 PCI_BUS,
128 TMD_BUS,
129 PLX_BUS,
130 PCCARD_BUS
133 enum
135 INTERSIL_FIRMWARE,
136 SYMBOL_FIRMWARE,
137 LUCENT_FIRMWARE,
138 HERMES2_FIRMWARE,
139 HERMES2G_FIRMWARE,
142 #define IO_WINDOW_SIZE 0x40
144 #define ETH_ADDRESSSIZE 6
145 #define ETH_HEADERSIZE 14
146 #define ETH_MTU 1500
147 #define ETH_MAXPACKETSIZE (ETH_HEADERSIZE + ETH_MTU)
149 #define ETH_PACKET_DEST 0
150 #define ETH_PACKET_SOURCE 6
151 #define ETH_PACKET_TYPE 12
152 #define ETH_PACKET_IEEELEN 12
153 #define ETH_PACKET_DATA 14
155 #define SNAP_HEADERSIZE 8
157 #define SNAP_FRM_TYPE 6
159 #define IV_SIZE 4
160 #define EIV_SIZE 8
161 #define ICV_SIZE 4
162 #define MIC_SIZE 8
164 #define ENC_COUNT 4
165 #define STAT_COUNT 3
167 #define RX_BUFFER_COUNT 10
170 struct KeyUnion
172 UWORD type;
173 union
175 struct WEPKey
177 UWORD length;
178 UBYTE key[13];
179 ULONG tx_iv;
181 wep;
182 struct TKIPKey
184 UWORD key[8];
185 ULONG tx_mic_key[2];
186 ULONG rx_mic_key[2];
187 UWORD tx_iv_low;
188 ULONG tx_iv_high;
189 UWORD rx_iv_low;
190 ULONG rx_iv_high;
191 UWORD tx_ttak[5];
192 BOOL tx_ttak_set;
193 UWORD rx_ttak[5];
194 BOOL rx_ttak_set;
196 tkip;
197 struct CCMPKey
199 UBYTE key[16];
200 BOOL stream_set;
201 ULONG stream[44];
202 UWORD tx_iv_low;
203 ULONG tx_iv_high;
204 UWORD rx_iv_low;
205 ULONG rx_iv_high;
207 ccmp;
213 struct DevUnit
215 struct MinNode node;
216 ULONG index;
217 ULONG open_count;
218 ULONG flags;
219 UWORD bus;
220 struct Task *task;
221 struct MsgPort *request_ports[REQUEST_QUEUE_COUNT];
222 struct DevBase *device;
223 APTR card;
224 BOOL (*insertion_function)(APTR, struct DevBase *);
225 VOID (*removal_function)(APTR, struct DevBase *);
226 VOID (*WordsIn)(APTR, ULONG, UWORD *, ULONG);
227 VOID (*WordsOut)(APTR, ULONG, const UWORD *, ULONG);
228 VOID (*BEWordOut)(APTR, ULONG, UWORD);
229 UWORD (*LEWordIn)(APTR, ULONG);
230 VOID (*LEWordOut)(APTR, ULONG, UWORD);
231 UBYTE *rx_buffer;
232 UBYTE *rx_buffers;
233 LONG rx_fragment_nos[RX_BUFFER_COUNT];
234 UBYTE *tx_buffer;
235 UBYTE *rx_descriptor;
236 UBYTE *tx_descriptor;
237 UBYTE ssid[WIFI_MAXIDLEN];
238 ULONG card_removed_signal;
239 ULONG card_inserted_signal;
240 ULONG scan_complete_signal;
241 ULONG range_count;
242 UBYTE address[ETH_ADDRESSSIZE];
243 UBYTE default_address[ETH_ADDRESSSIZE];
244 UBYTE bssid[ETH_ADDRESSSIZE + 2];
245 struct MinList openers;
246 struct MinList type_trackers;
247 struct MinList multicast_ranges;
248 struct Interrupt status_int;
249 struct Interrupt rx_int;
250 struct Interrupt tx_int;
251 struct Interrupt info_int;
252 struct Interrupt reset_handler;
253 struct Sana2DeviceStats stats;
254 ULONG special_stats[STAT_COUNT];
255 ULONG speed;
256 struct Sana2SignalQuality signal_quality;
257 struct SignalSemaphore access_lock;
258 UWORD tx_frame_id;
259 UWORD mode;
260 UWORD channel;
261 UWORD firmware_type;
262 UWORD auth_types;
263 UWORD ssid_length;
264 UWORD tx_key_no;
265 struct KeyUnion keys[WIFI_KEYCOUNT];
266 UWORD iv_sizes[ENC_COUNT];
267 VOID (*fragment_encrypt_functions[ENC_COUNT])(struct DevUnit *, UBYTE *,
268 UBYTE *, UWORD *, UBYTE *, struct DevBase *);
269 BOOL (*fragment_decrypt_functions[ENC_COUNT])(struct DevUnit *, UBYTE *,
270 UBYTE *, UWORD *, UBYTE *, struct DevBase *);
271 UWORD *scan_results_rec;
272 UBYTE *beacons;
273 UBYTE *next_beacon;
274 UBYTE wpa_ie[100];
275 UWORD beacon_count;
276 UWORD ethernet_offset;
277 UWORD data_offset;
278 UWORD datalen_offset;
279 UWORD txcontrol_offset;
283 struct Opener
285 struct MinNode node;
286 struct MsgPort read_port;
287 BOOL (*rx_function)(REG(a0, APTR), REG(a1, APTR), REG(d0, ULONG));
288 BOOL (*tx_function)(REG(a0, APTR), REG(a1, APTR), REG(d0, ULONG));
289 UBYTE *(*dma_tx_function)(REG(a0, APTR));
290 struct Hook *filter_hook;
291 struct MinList initial_stats;
292 #if defined(__amigaos4__) || defined(__MORPHOS__) || defined(__AROS__)
293 const VOID *real_rx_function;
294 const VOID *real_tx_function;
295 const VOID *real_dma_tx_function;
296 #endif
300 struct TypeStats
302 struct MinNode node;
303 ULONG packet_type;
304 struct Sana2PacketTypeStats stats;
308 struct TypeTracker
310 struct MinNode node;
311 ULONG packet_type;
312 struct Sana2PacketTypeStats stats;
313 ULONG user_count;
317 struct AddressRange
319 struct MinNode node;
320 ULONG add_count;
321 ULONG lower_bound_left;
322 ULONG upper_bound_left;
323 UWORD lower_bound_right;
324 UWORD upper_bound_right;
328 /* Unit flags */
330 #define UNITF_SHARED (1 << 0)
331 #define UNITF_ONLINE (1 << 1)
332 #define UNITF_TASKADDED (1 << 2)
333 #define UNITF_HAVEADAPTER (1 << 3)
334 #define UNITF_CONFIGURED (1 << 4)
335 #define UNITF_PROM (1 << 5)
336 #define UNITF_WASONLINE (1 << 6) /* card was online at time of removal */
337 #define UNITF_HASWEP (1 << 7)
338 #define UNITF_HASTKIP (1 << 8)
339 #define UNITF_HARDWEP (1 << 9)
340 #define UNITF_HARDTKIP (1 << 10)
341 #define UNITF_ALLMCAST (1 << 11)
342 #define UNITF_HASADHOC (1 << 12)
343 #define UNITF_INTADDED (1 << 13)
344 #define UNITF_RESETADDED (1 << 14)
345 #define UNITF_HASCCMP (1 << 15)
346 #define UNITF_ASSOCIATED (1 << 16)
349 /* Endianness macros */
351 #define FlipWord(A) \
352 ({ \
353 UWORD _FlipWord_A = (A); \
354 _FlipWord_A = (_FlipWord_A << 8) | (_FlipWord_A >> 8); \
357 #define FlipLong(A) \
358 ({ \
359 ULONG _FlipLong_A = (A); \
360 _FlipLong_A = \
361 (FlipWord(_FlipLong_A) << 16) | FlipWord(_FlipLong_A >> 16); \
364 #ifndef __i386__ /* Big endian */
366 #define BEWord(A) \
369 #define BELong(A) \
372 #define LEWord(A) \
373 FlipWord(A)
375 #define LELong(A) \
376 FlipLong(A)
378 #else
380 #define BEWord(A) \
381 FlipWord(A)
383 #define BELong(A) \
384 FlipLong(A)
386 #define LEWord(A) \
389 #define LELong(A) \
392 #endif
394 #define MakeBEWord(A) \
395 BEWord(A)
397 #define MakeBELong(A) \
398 BELong(A)
400 #define MakeLEWord(A) \
401 LEWord(A)
403 #define MakeLELong(A) \
404 LELong(A)
407 /* Library and device bases */
409 #define SysBase (base->sys_base)
410 #define CardResource (base->card_base)
411 #define UtilityBase (base->utility_base)
412 #define ExpansionBase (base->expansion_base)
413 #define OpenPciBase (base->openpci_base)
414 #define PrometheusBase (base->prometheus_base)
415 #define PowerPCIBase (base->powerpci_base)
416 #define CybPCIBase (base->cybpci_base)
417 #define PCCardBase (base->pccard_base)
418 #define DOSBase (base->dos_base)
419 #define TimerBase (base->timer_request.tr_node.io_Device)
421 #ifdef __amigaos4__
422 #define IExec (base->i_exec)
423 #define IUtility (base->i_utility)
424 #define ICard (base->i_card)
425 #define IPCCard (base->i_pccard)
426 #define IDOS (base->i_dos)
427 #define ITimer (base->i_timer)
428 #endif
430 #ifndef BASE_REG
431 #define BASE_REG a6
432 #endif
435 #endif