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,
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>
38 #define DEVICE_NAME "prism2.device"
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
63 #define _REG(A, B) B __asm(#A)
64 #define REG(A, B) _REG(A, B)
71 #define STR(A) _STR(A)
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
;
89 struct DosLibrary
*dos_base
;
90 struct MinList pci_units
;
91 struct MinList pccard_units
;
92 struct timerequest timer_request
;
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
;
101 VOID (*wrapper_int_code
)();
131 #define IO_WINDOW_SIZE 0x40
133 #define ETH_ADDRESSSIZE 6
134 #define ETH_HEADERSIZE 14
135 #define ETH_SNAPHEADERSIZE 22
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
157 struct MsgPort
*request_ports
[REQUEST_QUEUE_COUNT
];
158 struct DevBase
*device
;
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
);
169 UBYTE ssid
[IEEE802_11_MAXIDLEN
];
170 ULONG card_removed_signal
;
171 ULONG card_inserted_signal
;
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
];
185 struct Sana2SignalQuality signal_quality
;
186 struct SignalSemaphore access_lock
;
194 struct WEPKey keys
[IEEE802_11_WEPKEYCOUNT
];
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
;
219 struct Sana2PacketTypeStats stats
;
227 struct Sana2PacketTypeStats stats
;
236 ULONG lower_bound_left
;
237 ULONG upper_bound_left
;
238 UWORD lower_bound_right
;
239 UWORD upper_bound_right
;
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) \
259 UWORD _FlipWord_A = (A); \
260 _FlipWord_A = (_FlipWord_A << 8) | (_FlipWord_A >> 8); \
263 #define FlipLong(A) \
265 ULONG _FlipLong_A = (A); \
267 (FlipWord(_FlipLong_A) << 16) | FlipWord(_FlipLong_A >> 16); \
270 #ifndef __i386__ /* Big endian */
300 #define MakeBEWord(A) \
303 #define MakeBELong(A) \
306 #define MakeLEWord(A) \
309 #define MakeLELong(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)
327 #define IExec (base->i_exec)
328 #define IUtility (base->i_utility)
329 #define IDOS (base->i_dos)
330 #define ITimer (base->i_timer)