3 Copyright (C) 2001-2012 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>
34 #include <dos/dosextens.h>
39 #define DEVICE_NAME "prism2.device"
42 #define DATE "9.10.2012"
44 #define UTILITY_VERSION 39
45 #define PROMETHEUS_VERSION 2
46 #define POWERPCI_VERSION 2
47 #define CYBPCI_VERSION 2
48 #define EXPANSION_VERSION 50
49 #define OPENPCI_VERSION 1
50 #define PCCARD_VERSION 1
51 #define DOS_VERSION 36
64 #if defined(__mc68000) && !defined(__AROS__)
65 #define _REG(A, B) B __asm(#A)
66 #define REG(A, B) _REG(A, B)
73 #define STR(A) _STR(A)
79 #if defined(__mc68000) && !defined(__AROS__)
80 #define AddResetCallback(callback) TRUE
81 #define RemResetCallback(callback)
89 struct ExecBase
*sys_base
;
90 struct UtilityBase
*utility_base
;
91 struct Library
*prometheus_base
;
92 struct Library
*powerpci_base
;
93 struct Library
*cybpci_base
;
94 struct Library
*openpci_base
;
95 struct Library
*pccard_base
;
97 struct DosLibrary
*dos_base
;
98 struct MinList pci_units
;
99 struct MinList pccard_units
;
100 struct timerequest timer_request
;
102 struct Library
*expansion_base
;
103 struct ExecIFace
*i_exec
;
104 struct UtilityIFace
*i_utility
;
105 struct PCIIFace
*i_pci
;
106 struct CardIFace
*i_card
;
107 struct PCCardIFace
*i_pccard
;
108 struct DOSIFace
*i_dos
;
109 struct TimerIFace
*i_timer
;
111 VOID (*wrapper_int_code
)();
112 VOID (*wrapper_card_code
)();
144 #define IO_WINDOW_SIZE 0x40
146 #define ETH_ADDRESSSIZE 6
147 #define ETH_HEADERSIZE 14
149 #define ETH_MAXPACKETSIZE (ETH_HEADERSIZE + ETH_MTU)
151 #define ETH_PACKET_DEST 0
152 #define ETH_PACKET_SOURCE 6
153 #define ETH_PACKET_TYPE 12
154 #define ETH_PACKET_IEEELEN 12
155 #define ETH_PACKET_DATA 14
157 #define SNAP_HEADERSIZE 8
159 #define SNAP_FRM_TYPE 6
169 #define RX_BUFFER_COUNT 10
223 struct MsgPort
*request_ports
[REQUEST_QUEUE_COUNT
];
224 struct DevBase
*device
;
226 BOOL (*insertion_function
)(APTR
, struct DevBase
*);
227 VOID (*removal_function
)(APTR
, struct DevBase
*);
228 VOID (*WordsIn
)(APTR
, ULONG
, UWORD
*, ULONG
);
229 VOID (*WordsOut
)(APTR
, ULONG
, const UWORD
*, ULONG
);
230 VOID (*BEWordOut
)(APTR
, ULONG
, UWORD
);
231 UWORD (*LEWordIn
)(APTR
, ULONG
);
232 VOID (*LEWordOut
)(APTR
, ULONG
, UWORD
);
235 LONG rx_fragment_nos
[RX_BUFFER_COUNT
];
237 UBYTE
*rx_descriptor
;
238 UBYTE
*tx_descriptor
;
239 UBYTE ssid
[WIFI_MAXIDLEN
];
240 ULONG card_removed_signal
;
241 ULONG card_inserted_signal
;
242 ULONG scan_complete_signal
;
244 UBYTE address
[ETH_ADDRESSSIZE
];
245 UBYTE default_address
[ETH_ADDRESSSIZE
];
246 UBYTE bssid
[ETH_ADDRESSSIZE
+ 2];
247 struct MinList openers
;
248 struct MinList type_trackers
;
249 struct MinList multicast_ranges
;
250 struct Interrupt status_int
;
251 struct Interrupt rx_int
;
252 struct Interrupt tx_int
;
253 struct Interrupt info_int
;
254 struct Interrupt reset_handler
;
255 struct Sana2DeviceStats stats
;
256 ULONG special_stats
[STAT_COUNT
];
258 struct Sana2SignalQuality signal_quality
;
259 struct SignalSemaphore access_lock
;
265 UWORD ssid_length
; // ???
267 struct KeyUnion keys
[WIFI_KEYCOUNT
];
268 UWORD iv_sizes
[ENC_COUNT
];
269 VOID (*fragment_encrypt_functions
[ENC_COUNT
])(struct DevUnit
*, UBYTE
*,
270 UBYTE
*, UWORD
*, UBYTE
*, struct DevBase
*);
271 BOOL (*fragment_decrypt_functions
[ENC_COUNT
])(struct DevUnit
*, UBYTE
*,
272 UBYTE
*, UWORD
*, UBYTE
*, struct DevBase
*);
273 UWORD
*scan_results_rec
;
278 UWORD ethernet_offset
;
280 UWORD datalen_offset
;
281 UWORD txcontrol_offset
;
288 struct MsgPort read_port
;
289 BOOL (*rx_function
)(REG(a0
, APTR
), REG(a1
, APTR
), REG(d0
, ULONG
));
290 BOOL (*tx_function
)(REG(a0
, APTR
), REG(a1
, APTR
), REG(d0
, ULONG
));
291 UBYTE
*(*dma_tx_function
)(REG(a0
, APTR
));
292 struct Hook
*filter_hook
;
293 struct MinList initial_stats
;
294 #if defined(__amigaos4__) || defined(__MORPHOS__) || defined(__AROS__)
295 const VOID
*real_rx_function
;
296 const VOID
*real_tx_function
;
297 const VOID
*real_dma_tx_function
;
306 struct Sana2PacketTypeStats stats
;
314 struct Sana2PacketTypeStats stats
;
323 ULONG lower_bound_left
;
324 ULONG upper_bound_left
;
325 UWORD lower_bound_right
;
326 UWORD upper_bound_right
;
332 #define UNITF_SHARED (1 << 0)
333 #define UNITF_ONLINE (1 << 1)
334 #define UNITF_HAVEADAPTER (1 << 3)
335 #define UNITF_CONFIGURED (1 << 4)
336 #define UNITF_PROM (1 << 5)
337 #define UNITF_WASONLINE (1 << 6) /* card was online at time of removal */
338 #define UNITF_HASWEP (1 << 7)
339 #define UNITF_HASTKIP (1 << 8)
340 #define UNITF_HARDWEP (1 << 9)
341 #define UNITF_HARDTKIP (1 << 10)
342 #define UNITF_ALLMCAST (1 << 11)
343 #define UNITF_HASADHOC (1 << 12)
344 #define UNITF_INTADDED (1 << 13)
345 #define UNITF_RESETADDED (1 << 14)
346 #define UNITF_HASCCMP (1 << 15)
347 #define UNITF_ASSOCIATED (1 << 16)
350 /* Endianness macros */
352 #define FlipWord(A) \
354 UWORD _FlipWord_A = (A); \
355 _FlipWord_A = (_FlipWord_A << 8) | (_FlipWord_A >> 8); \
358 #define FlipLong(A) \
360 ULONG _FlipLong_A = (A); \
362 (FlipWord(_FlipLong_A) << 16) | FlipWord(_FlipLong_A >> 16); \
365 #ifndef __i386__ /* Big endian */
395 #define MakeBEWord(A) \
398 #define MakeBELong(A) \
401 #define MakeLEWord(A) \
404 #define MakeLELong(A) \
408 /* Library and device bases */
410 #define SysBase (base->sys_base)
411 #define CardResource (base->card_base)
412 #define UtilityBase (base->utility_base)
413 #define ExpansionBase (base->expansion_base)
414 #define OpenPciBase (base->openpci_base)
415 #define PrometheusBase (base->prometheus_base)
416 #define PowerPCIBase (base->powerpci_base)
417 #define CybPCIBase (base->cybpci_base)
418 #define PCCardBase (base->pccard_base)
419 #define DOSBase (base->dos_base)
420 #define TimerBase (base->timer_request.tr_node.io_Device)
423 #define IExec (base->i_exec)
424 #define IUtility (base->i_utility)
425 #define ICard (base->i_card)
426 #define IPCCard (base->i_pccard)
427 #define IDOS (base->i_dos)
428 #define ITimer (base->i_timer)