Check for SYS/GL during library init. Reason is that
[AROS.git] / workbench / devs / networks / etherlink3 / device.h
blob4308e7e65f43e4a1278a061165923849de17a8ae
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/timer.h>
34 #include "io.h"
36 #define DEVICE_NAME "etherlink3.device"
37 #define VERSION 1
38 #define REVISION 2
39 #define DATE "12.6.2012"
41 #define UTILITY_VERSION 39
42 #define PROMETHEUS_VERSION 2
43 #define POWERPCI_VERSION 2
44 #define EXPANSION_VERSION 50
45 #define OPENPCI_VERSION 1
46 #define PCCARD_VERSION 1
48 #ifndef UPINT
49 #ifdef __AROS__
50 typedef IPTR UPINT;
51 typedef SIPTR PINT;
52 #else
53 typedef ULONG UPINT;
54 typedef LONG PINT;
55 #endif
56 #endif
58 #ifndef REG
59 #if defined(__mc68000) && !defined(__AROS__)
60 #define _REG(A, B) B __asm(#A)
61 #define REG(A, B) _REG(A, B)
62 #else
63 #define REG(A, B) B
64 #endif
65 #endif
67 #define _STR(A) #A
68 #define STR(A) _STR(A)
70 #ifndef __AROS__
71 #define USE_HACKS
72 #endif
75 struct DevBase
77 struct Device device;
78 APTR seg_list;
79 struct ExecBase *sys_base;
80 struct UtilityBase *utility_base;
81 struct Library *prometheus_base;
82 struct Library *powerpci_base;
83 struct Library *openpci_base;
84 struct Library *pccard_base;
85 APTR card_base;
86 struct MinList pci_units;
87 struct MinList isa_units;
88 struct MinList pccard_units;
89 struct timerequest timer_request;
90 #ifdef __amigaos4__
91 struct Library *expansion_base;
92 struct ExecIFace *i_exec;
93 struct UtilityIFace *i_utility;
94 struct PCIIFace *i_pci;
95 struct CardIFace *i_card;
96 struct PCCardIFace *i_pccard;
97 struct TimerIFace *i_timer;
98 #endif
99 VOID (*wrapper_int_code)();
100 VOID (*wrapper_card_code)();
104 enum
106 WRITE_QUEUE,
107 ADOPT_QUEUE,
108 EVENT_QUEUE,
109 GENERAL_QUEUE,
110 REQUEST_QUEUE_COUNT
113 enum
115 PCI_BUS,
116 EISA_BUS,
117 ISA_BUS,
118 PCCARD_BUS
121 enum
123 FIRST_GEN,
124 SECOND_GEN,
125 DEMON_GEN,
126 VORTEX_GEN,
127 BOOMERANG_GEN,
128 CYCLONE_GEN,
129 TORNADO_GEN
132 #define ETH_ADDRESSSIZE 6
133 #define ETH_HEADERSIZE 14
134 #define ETH_MTU 1500
135 #define ETH_MAXPACKETSIZE ((ETH_HEADERSIZE) + (ETH_MTU))
137 #define ETH_PACKET_DEST 0
138 #define ETH_PACKET_SOURCE 6
139 #define ETH_PACKET_TYPE 12
140 #define ETH_PACKET_IEEELEN 12
141 #define ETH_PACKET_SNAPTYPE 20
142 #define ETH_PACKET_DATA 14
144 #define STAT_COUNT 3
146 #define TX_SLOT_COUNT 20
147 #define RX_SLOT_COUNT 20
148 #define DPD_SIZE (sizeof(ULONG) * 6)
149 #define UPD_SIZE (sizeof(ULONG) * 4)
152 struct DevUnit
154 struct MinNode node;
155 ULONG index;
156 ULONG open_count;
157 UWORD flags;
158 UWORD transceiver;
159 struct Task *task;
160 struct MsgPort *request_ports[REQUEST_QUEUE_COUNT];
161 struct DevBase *device;
162 APTR card;
163 BOOL (*insertion_function)(APTR, struct DevBase *);
164 VOID (*removal_function)(APTR, struct DevBase *);
165 UBYTE (*ByteIn)(APTR, UBYTE);
166 ULONG (*LongIn)(APTR, ULONG);
167 VOID (*ByteOut)(APTR, ULONG, UBYTE);
168 VOID (*WordOut)(APTR, ULONG, UWORD);
169 VOID (*LongOut)(APTR, ULONG, ULONG);
170 VOID (*LongsIn)(APTR, ULONG, ULONG *, ULONG);
171 VOID (*LongsOut)(APTR, ULONG, const ULONG *, ULONG);
172 VOID (*BEWordOut)(APTR, ULONG, UWORD);
173 UWORD (*LEWordIn)(APTR, ULONG);
174 ULONG (*LELongIn)(APTR, ULONG);
175 VOID (*LEWordOut)(APTR, ULONG, UWORD);
176 VOID (*LELongOut)(APTR, ULONG, ULONG);
177 APTR (*AllocDMAMem)(APTR, UPINT, UWORD);
178 VOID (*FreeDMAMem)(APTR, APTR);
179 UBYTE *rx_buffer;
180 UBYTE *tx_buffer;
181 UPINT io_base;
182 UPINT window1_offset;
183 ULONG card_removed_signal;
184 ULONG card_inserted_signal;
185 ULONG range_count;
186 UBYTE address[ETH_ADDRESSSIZE];
187 UBYTE default_address[ETH_ADDRESSSIZE];
188 struct MinList openers;
189 struct MinList type_trackers;
190 struct MinList multicast_ranges;
191 struct Interrupt status_int;
192 struct Interrupt rx_int;
193 struct Interrupt tx_int;
194 struct Interrupt tx_end_int;
195 struct Sana2DeviceStats stats;
196 ULONG special_stats[STAT_COUNT];
197 ULONG *dpds;
198 ULONG *upds;
199 ULONG *next_upd;
200 UBYTE *headers;
201 ULONG speed;
202 struct IOSana2Req **tx_requests;
203 struct SignalSemaphore access_lock;
204 UWORD capabilities;
205 UWORD rx_filter_cmd;
206 UWORD size_shift;
207 UWORD bus;
208 UWORD generation;
209 UWORD autoneg_modes;
210 UWORD buffer_size;
211 UWORD tx_in_slot;
212 UWORD tx_out_slot;
213 UWORD tx_active_req_count;
214 UWORD int_mask;
215 UBYTE mii_phy_no;
219 struct Opener
221 struct MinNode node;
222 struct MsgPort read_port;
223 BOOL (*rx_function)(REG(a0, APTR), REG(a1, APTR), REG(d0, ULONG));
224 BOOL (*tx_function)(REG(a0, APTR), REG(a1, APTR), REG(d0, ULONG));
225 UBYTE *(*dma_tx_function)(REG(a0, APTR));
226 struct Hook *filter_hook;
227 struct MinList initial_stats;
228 #if defined(__amigaos4__) || defined(__MORPHOS__) || defined(__AROS__)
229 const VOID *real_rx_function;
230 const VOID *real_tx_function;
231 const VOID *real_dma_tx_function;
232 #endif
236 struct TypeStats
238 struct MinNode node;
239 ULONG packet_type;
240 struct Sana2PacketTypeStats stats;
244 struct TypeTracker
246 struct MinNode node;
247 ULONG packet_type;
248 struct Sana2PacketTypeStats stats;
249 ULONG user_count;
253 struct AddressRange
255 struct MinNode node;
256 ULONG add_count;
257 ULONG lower_bound_left;
258 ULONG upper_bound_left;
259 UWORD lower_bound_right;
260 UWORD upper_bound_right;
264 /* Unit flags */
266 #define UNITF_SHARED (1 << 0)
267 #define UNITF_ONLINE (1 << 1)
268 #define UNITF_WASONLINE (1 << 2) /* card was online at time of removal */
269 #define UNITF_HAVEADAPTER (1 << 3)
270 #define UNITF_CONFIGURED (1 << 4)
271 #define UNITF_PROM (1 << 5)
272 #define UNITF_FULLDUPLEX (1 << 6)
273 #define UNITF_RXBUFFERINUSE (1 << 7)
274 #define UNITF_TXBUFFERINUSE (1 << 8)
277 /* Library and device bases */
279 #define SysBase (base->sys_base)
280 #define CardResource (base->card_base)
281 #define UtilityBase (base->utility_base)
282 #define ExpansionBase (base->expansion_base)
283 #define PrometheusBase (base->prometheus_base)
284 #define PowerPCIBase (base->powerpci_base)
285 #define OpenPciBase (base->openpci_base)
286 #define PCCardBase (base->pccard_base)
287 #define TimerBase (base->timer_request.tr_node.io_Device)
289 #ifdef __amigaos4__
290 #define IExec (base->i_exec)
291 #define IUtility (base->i_utility)
292 #define ICard (base->i_card)
293 #define IPCCard (base->i_pccard)
294 #define ITimer (base->i_timer)
295 #endif
297 #ifndef BASE_REG
298 #define BASE_REG a6
299 #endif
302 #endif