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,
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>
38 #define DEVICE_NAME "prism2.device"
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
63 #if defined(__mc68000) && !defined(__AROS__)
64 #define _REG(A, B) B __asm(#A)
65 #define REG(A, B) _REG(A, B)
72 #define STR(A) _STR(A)
78 #if defined(__mc68000) && !defined(__AROS__)
79 #define AddResetCallback(callback) TRUE
80 #define RemResetCallback(callback)
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
;
96 struct DosLibrary
*dos_base
;
97 struct MinList pci_units
;
98 struct MinList pccard_units
;
99 struct timerequest timer_request
;
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
;
110 VOID (*wrapper_int_code
)();
111 VOID (*wrapper_card_code
)();
142 #define IO_WINDOW_SIZE 0x40
144 #define ETH_ADDRESSSIZE 6
145 #define ETH_HEADERSIZE 14
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
167 #define RX_BUFFER_COUNT 10
221 struct MsgPort
*request_ports
[REQUEST_QUEUE_COUNT
];
222 struct DevBase
*device
;
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
);
233 LONG rx_fragment_nos
[RX_BUFFER_COUNT
];
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
;
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
];
256 struct Sana2SignalQuality signal_quality
;
257 struct SignalSemaphore access_lock
;
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
;
276 UWORD ethernet_offset
;
278 UWORD datalen_offset
;
279 UWORD txcontrol_offset
;
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
;
304 struct Sana2PacketTypeStats stats
;
312 struct Sana2PacketTypeStats stats
;
321 ULONG lower_bound_left
;
322 ULONG upper_bound_left
;
323 UWORD lower_bound_right
;
324 UWORD upper_bound_right
;
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) \
353 UWORD _FlipWord_A = (A); \
354 _FlipWord_A = (_FlipWord_A << 8) | (_FlipWord_A >> 8); \
357 #define FlipLong(A) \
359 ULONG _FlipLong_A = (A); \
361 (FlipWord(_FlipLong_A) << 16) | FlipWord(_FlipLong_A >> 16); \
364 #ifndef __i386__ /* Big endian */
394 #define MakeBEWord(A) \
397 #define MakeBELong(A) \
400 #define MakeLEWord(A) \
403 #define MakeLELong(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)
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)