grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / devs / networks / realtek8180 / device.h
blobe259cfc37cf32b947d3f44aa1791201fdfd508f0
1 /*
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,
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 "realtek8180.device"
39 #define VERSION 0
40 #define REVISION 4
41 #define DATE "1.8.2012"
43 #define UTILITY_VERSION 39
44 #define POSEIDON_VERSION 0
46 #ifndef UPINT
47 #ifdef __AROS__
48 typedef IPTR UPINT;
49 typedef SIPTR PINT;
50 #else
51 typedef ULONG UPINT;
52 typedef LONG PINT;
53 #endif
54 #endif
56 #ifndef REG
57 #if defined(__mc68000) && !defined(__AROS__)
58 #define _REG(A, B) B __asm(#A)
59 #define REG(A, B) _REG(A, B)
60 #else
61 #define REG(A, B) B
62 #endif
63 #endif
65 #define _STR(A) #A
66 #define STR(A) _STR(A)
68 #ifdef __AROS__
69 #include <aros/debug.h>
70 #define DebugPrintF kprintf
71 #endif
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 *poseidon_base;
85 struct MinList usb_units;
86 struct timerequest timer_request;
87 #ifdef __amigaos4__
88 struct Library *expansion_base;
89 struct ExecIFace *i_exec;
90 struct UtilityIFace *i_utility;
91 struct PCIIFace *i_pci;
92 struct TimerIFace *i_timer;
93 #endif
94 VOID (*wrapper_int_code)();
98 enum
100 WRITE_QUEUE,
101 MGMT_QUEUE,
102 ADOPT_QUEUE,
103 EVENT_QUEUE,
104 SCAN_QUEUE,
105 GENERAL_QUEUE,
106 REQUEST_QUEUE_COUNT
109 enum
111 PCI_BUS,
112 USB_BUS,
115 enum
117 RTL8187L_GEN,
118 RTL8187B0_GEN,
119 RTL8187B1_GEN,
120 RTL8187B2_GEN,
123 enum
125 RTL8225_RADIO,
126 RTL8225V2_RADIO,
127 RTL8225V2B_RADIO,
130 #define ETH_ADDRESSSIZE 6
131 #define ETH_HEADERSIZE 14
132 #define ETH_MTU 1500
133 #define ETH_MAXPACKETSIZE (ETH_HEADERSIZE + ETH_MTU)
135 #define ETH_PACKET_DEST 0
136 #define ETH_PACKET_SOURCE 6
137 #define ETH_PACKET_TYPE 12
138 #define ETH_PACKET_IEEELEN 12
139 #define ETH_PACKET_DATA 14
141 #define SNAP_HEADERSIZE 8
143 #define SNAP_FRM_TYPE 6
145 #define CHANNEL_COUNT 14
147 #define IV_SIZE 4
148 #define EIV_SIZE 8
149 #define ICV_SIZE 4
150 #define MIC_SIZE 8
152 #define STAT_COUNT 3
153 #define ENC_COUNT 4
155 #define FRAME_BUFFER_SIZE (WIFI_FRM_DATA + SNAP_HEADERSIZE \
156 + ETH_MTU + EIV_SIZE + ICV_SIZE + MIC_SIZE)
157 #define FRAME_BUFFER_COUNT 10
158 #define TX_SLOT_COUNT 30
159 #define RX_SLOT_COUNT 30
162 struct KeyUnion
164 UWORD type;
165 union
167 struct WEPKey
169 UWORD length;
170 UBYTE key[13];
171 ULONG tx_iv;
173 wep;
174 struct TKIPKey
176 UWORD key[8];
177 ULONG tx_mic_key[2];
178 ULONG rx_mic_key[2];
179 UWORD tx_iv_low;
180 ULONG tx_iv_high;
181 UWORD rx_iv_low;
182 ULONG rx_iv_high;
183 UWORD tx_ttak[5];
184 BOOL tx_ttak_set;
185 UWORD rx_ttak[5];
186 BOOL rx_ttak_set;
188 tkip;
189 struct CCMPKey
191 UBYTE key[16];
192 BOOL stream_set;
193 ULONG stream[44];
194 UWORD tx_iv_low;
195 ULONG tx_iv_high;
196 UWORD rx_iv_low;
197 ULONG rx_iv_high;
199 ccmp;
205 struct DevUnit
207 struct MinNode node;
208 ULONG index;
209 ULONG open_count;
210 ULONG flags;
211 UWORD bus;
212 UWORD generation;
213 UWORD eeprom_addr_size;
214 UWORD radio_type;
215 struct Task *task;
216 struct MsgPort *request_ports[REQUEST_QUEUE_COUNT];
217 struct DevBase *device;
218 APTR card;
219 BOOL (*insertion_function)(APTR, struct DevBase *);
220 VOID (*removal_function)(APTR, struct DevBase *);
221 ULONG (*ByteIn)(APTR, ULONG);
222 VOID (*ByteOut)(APTR, ULONG, UBYTE);
223 UWORD (*LEWordIn)(APTR, ULONG);
224 ULONG (*LELongIn)(APTR, ULONG);
225 VOID (*LEWordOut)(APTR, ULONG, UWORD);
226 VOID (*LELongOut)(APTR, ULONG, ULONG);
227 VOID (*SendFrame)(APTR, APTR, ULONG);
228 VOID (*ReceiveFrame)(APTR, APTR, ULONG);
229 APTR (*AllocDMAMem)(APTR, UPINT, UWORD);
230 VOID (*FreeDMAMem)(APTR, APTR);
231 UBYTE *tx_buffer;
232 UBYTE *tx_buffers[TX_SLOT_COUNT];
233 UBYTE *rx_buffer;
234 UBYTE *rx_buffers[RX_SLOT_COUNT];
235 UBYTE *rx_frames;
236 LONG rx_fragment_nos[FRAME_BUFFER_COUNT];
237 ULONG card_removed_signal;
238 ULONG card_inserted_signal;
239 ULONG range_count;
240 UBYTE address[ETH_ADDRESSSIZE];
241 UBYTE default_address[ETH_ADDRESSSIZE];
242 UBYTE bssid[ETH_ADDRESSSIZE + 2];
243 struct MinList openers;
244 struct MinList type_trackers;
245 struct MinList multicast_ranges;
246 struct Interrupt rx_int;
247 struct Interrupt tx_int;
248 struct Interrupt mgmt_int;
249 struct Sana2DeviceStats stats;
250 ULONG special_stats[STAT_COUNT];
251 UBYTE *tx_descs[TX_SLOT_COUNT];
252 UBYTE *rx_descs[RX_SLOT_COUNT];
253 struct IOSana2Req **tx_requests;
254 ULONG speed;
255 struct Sana2SignalQuality signal_quality;
256 struct SignalSemaphore access_lock;
257 UWORD tx_in_slot;
258 UWORD tx_out_slot;
259 UWORD rx_slot;
260 UWORD mode;
261 UWORD band;
262 UWORD channel;
263 UBYTE base_cck_power;
264 UBYTE base_ofdm_power;
265 UBYTE cck_power[CHANNEL_COUNT + 1];
266 UBYTE ofdm_power[CHANNEL_COUNT + 1];
267 UWORD assoc_id;
268 UWORD capabilities;
269 UWORD tx_rate;
270 UWORD mgmt_rate;
271 UWORD tx_rate_code;
272 UWORD mgmt_rate_code;
273 UWORD tx_sequence;
274 UWORD tx_key_no;
275 struct KeyUnion keys[WIFI_KEYCOUNT];
276 UWORD iv_sizes[ENC_COUNT];
277 VOID (*fragment_encrypt_functions[ENC_COUNT])(struct DevUnit *, UBYTE *,
278 UBYTE *, UWORD *, UBYTE *, struct DevBase *);
279 BOOL (*fragment_decrypt_functions[ENC_COUNT])(struct DevUnit *, UBYTE *,
280 UBYTE *, UWORD *, UBYTE *, struct DevBase *);
281 UWORD retries_offset;
282 UWORD tx_desc_size;
283 UWORD rx_desc_size;
287 struct Opener
289 struct MinNode node;
290 struct MsgPort read_port;
291 struct MsgPort mgmt_port;
292 BOOL (*rx_function)(REG(a0, APTR), REG(a1, APTR), REG(d0, ULONG));
293 BOOL (*tx_function)(REG(a0, APTR), REG(a1, APTR), REG(d0, ULONG));
294 UBYTE *(*dma_tx_function)(REG(a0, APTR));
295 struct Hook *filter_hook;
296 struct MinList initial_stats;
297 #if defined(__amigaos4__) || defined(__MORPHOS__) || defined(__AROS__)
298 const VOID *real_rx_function;
299 const VOID *real_tx_function;
300 const VOID *real_dma_tx_function;
301 #endif
305 struct TypeStats
307 struct MinNode node;
308 ULONG packet_type;
309 struct Sana2PacketTypeStats stats;
313 struct TypeTracker
315 struct MinNode node;
316 ULONG packet_type;
317 struct Sana2PacketTypeStats stats;
318 ULONG user_count;
322 struct AddressRange
324 struct MinNode node;
325 ULONG add_count;
326 ULONG lower_bound_left;
327 ULONG upper_bound_left;
328 UWORD lower_bound_right;
329 UWORD upper_bound_right;
333 /* Unit flags */
335 #define UNITF_SHARED (1 << 0)
336 #define UNITF_ONLINE (1 << 1)
337 #define UNITF_HAVEADAPTER (1 << 2)
338 #define UNITF_CONFIGURED (1 << 3)
339 #define UNITF_PROM (1 << 4)
340 #define UNITF_WASONLINE (1 << 5) /* card was online at time of removal */
341 #define UNITF_HARDWEP (1 << 6)
342 #define UNITF_HARDTKIP (1 << 7)
343 #define UNITF_HARDCCMP (1 << 8)
344 #define UNITF_ALLMCAST (1 << 9)
345 #define UNITF_HASADHOC (1 << 10)
346 #define UNITF_SHORTPREAMBLE (1 << 11)
347 #define UNITF_INTADDED (1 << 12)
348 #define UNITF_RESETADDED (1 << 13)
351 /* Endianness macros */
353 #define FlipWord(A) \
354 ({ \
355 UWORD _FlipWord_A = (A); \
356 _FlipWord_A = (_FlipWord_A << 8) | (_FlipWord_A >> 8); \
359 #define FlipLong(A) \
360 ({ \
361 ULONG _FlipLong_A = (A); \
362 _FlipLong_A = \
363 (FlipWord(_FlipLong_A) << 16) | FlipWord(_FlipLong_A >> 16); \
366 #define FlipQuad(A) \
367 ({ \
368 UQUAD _FlipQuad_A = (A); \
369 _FlipQuad_A = \
370 (FlipLong(_FlipQuad_A) << 32) | FlipLong(_FlipQuad_A >> 32); \
373 #ifndef __i386__ /* Big endian */
375 #define BEWord(A) \
378 #define BELong(A) \
381 #define LEWord(A) \
382 FlipWord(A)
384 #define LELong(A) \
385 FlipLong(A)
387 #define LEQuad(A) \
388 FlipQuad(A)
390 #else
392 #define BEWord(A) \
393 FlipWord(A)
395 #define BELong(A) \
396 FlipLong(A)
398 #define LEWord(A) \
401 #define LELong(A) \
404 #define LEQuad(A) \
407 #endif
409 #define MakeBEWord(A) \
410 BEWord(A)
412 #define MakeBELong(A) \
413 BELong(A)
415 #define MakeLEWord(A) \
416 LEWord(A)
418 #define MakeLELong(A) \
419 LELong(A)
422 /* Library and device bases */
424 #define SysBase (base->sys_base)
425 #define UtilityBase (base->utility_base)
426 #define PsdBase (base->poseidon_base)
427 #define TimerBase (base->timer_request.tr_node.io_Device)
429 #ifdef __amigaos4__
430 #define IExec (base->i_exec)
431 #define IUtility (base->i_utility)
432 #define ITimer (base->i_timer)
433 #endif
435 #ifdef __AROS__
436 #define ps PsdBase
437 #endif
439 #ifndef BASE_REG
440 #define BASE_REG a6
441 #endif
444 #endif