Fixed binary search: no more infinite loops when vendor is unknown.
[tangerine.git] / workbench / devs / networks / etherlink3 / device.h
blob582c61e1b9e8196cece437a39411afbffc146989
1 /*
3 Copyright (C) 2001-2006 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 0
38 #define REVISION 8
39 #define DATE "3.3.2006"
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 #ifdef __mc68000
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)();
103 enum
105 WRITE_QUEUE,
106 ADOPT_QUEUE,
107 EVENT_QUEUE,
108 GENERAL_QUEUE,
109 REQUEST_QUEUE_COUNT
112 enum
114 PCI_BUS,
115 EISA_BUS,
116 ISA_BUS,
117 PCCARD_BUS
120 enum
122 FIRST_GEN,
123 SECOND_GEN,
124 DEMON_GEN,
125 VORTEX_GEN,
126 BOOMERANG_GEN,
127 CYCLONE_GEN,
128 TORNADO_GEN
131 #define ETH_ADDRESSSIZE 6
132 #define ETH_HEADERSIZE 14
133 #define ETH_MTU 1500
134 #define ETH_MAXPACKETSIZE ((ETH_HEADERSIZE) + (ETH_MTU))
136 #define ETH_PACKET_DEST 0
137 #define ETH_PACKET_SOURCE 6
138 #define ETH_PACKET_TYPE 12
139 #define ETH_PACKET_IEEELEN 12
140 #define ETH_PACKET_SNAPTYPE 20
141 #define ETH_PACKET_DATA 14
143 #define STAT_COUNT 3
145 #define TX_SLOT_COUNT 20
146 #define RX_SLOT_COUNT 20
147 #define DPD_SIZE (sizeof(ULONG) * 6)
148 #define UPD_SIZE (sizeof(ULONG) * 4)
151 struct DevUnit
153 struct MinNode node;
154 ULONG index;
155 ULONG open_count;
156 UWORD flags;
157 UWORD transceiver;
158 struct Task *task;
159 struct MsgPort *request_ports[REQUEST_QUEUE_COUNT];
160 struct DevBase *device;
161 APTR card;
162 BOOL (*insertion_function)(APTR, struct DevBase *);
163 VOID (*removal_function)(APTR, struct DevBase *);
164 ULONG (*ByteIn)(APTR, UBYTE);
165 ULONG (*LongIn)(APTR, ULONG);
166 VOID (*ByteOut)(APTR, ULONG, UBYTE);
167 VOID (*WordOut)(APTR, ULONG, UWORD);
168 VOID (*LongOut)(APTR, ULONG, ULONG);
169 VOID (*LongsIn)(APTR, ULONG, ULONG *, ULONG);
170 VOID (*LongsOut)(APTR, ULONG, const ULONG *, ULONG);
171 VOID (*BEWordOut)(APTR, ULONG, UWORD);
172 UWORD (*LEWordIn)(APTR, ULONG);
173 ULONG (*LELongIn)(APTR, ULONG);
174 VOID (*LEWordOut)(APTR, ULONG, UWORD);
175 VOID (*LELongOut)(APTR, ULONG, ULONG);
176 APTR (*AllocDMAMem)(APTR, UPINT, UWORD);
177 VOID (*FreeDMAMem)(APTR, APTR);
178 UBYTE *rx_buffer;
179 UBYTE *tx_buffer;
180 UPINT io_base;
181 UPINT window1_offset;
182 ULONG card_removed_signal;
183 ULONG card_inserted_signal;
184 ULONG range_count;
185 UBYTE address[ETH_ADDRESSSIZE];
186 UBYTE default_address[ETH_ADDRESSSIZE];
187 struct MinList openers;
188 struct MinList type_trackers;
189 struct MinList multicast_ranges;
190 struct Interrupt status_int;
191 struct Interrupt rx_int;
192 struct Interrupt tx_int;
193 struct Interrupt tx_end_int;
194 struct Sana2DeviceStats stats;
195 ULONG special_stats[STAT_COUNT];
196 ULONG *dpds;
197 ULONG *upds;
198 ULONG *next_upd;
199 UBYTE *headers;
200 ULONG speed;
201 struct IOSana2Req **tx_requests;
202 struct SignalSemaphore access_lock;
203 UWORD capabilities;
204 UWORD rx_filter_cmd;
205 UWORD size_shift;
206 UWORD bus;
207 UWORD generation;
208 UWORD autoneg_modes;
209 UWORD buffer_size;
210 UWORD tx_in_slot;
211 UWORD tx_out_slot;
212 UWORD tx_active_req_count;
213 UWORD int_mask;
214 UBYTE mii_phy_no;
218 struct Opener
220 struct MinNode node;
221 struct MsgPort read_port;
222 BOOL (*rx_function)(REG(a0, APTR), REG(a1, APTR), REG(d0, ULONG));
223 BOOL (*tx_function)(REG(a0, APTR), REG(a1, APTR), REG(d0, ULONG));
224 UBYTE *(*dma_tx_function)(REG(a0, APTR));
225 struct Hook *filter_hook;
226 struct MinList initial_stats;
227 #ifdef __amigaos4__
228 const VOID *real_rx_function;
229 const VOID *real_tx_function;
230 const VOID *real_dma_tx_function;
231 #endif
235 struct TypeStats
237 struct MinNode node;
238 ULONG packet_type;
239 struct Sana2PacketTypeStats stats;
243 struct TypeTracker
245 struct MinNode node;
246 ULONG packet_type;
247 struct Sana2PacketTypeStats stats;
248 ULONG user_count;
252 struct AddressRange
254 struct MinNode node;
255 ULONG add_count;
256 ULONG lower_bound_left;
257 ULONG upper_bound_left;
258 UWORD lower_bound_right;
259 UWORD upper_bound_right;
263 /* Unit flags */
265 #define UNITF_SHARED (1 << 0)
266 #define UNITF_ONLINE (1 << 1)
267 #define UNITF_WASONLINE (1 << 2) /* card was online at time of removal */
268 #define UNITF_HAVEADAPTER (1 << 3)
269 #define UNITF_CONFIGURED (1 << 4)
270 #define UNITF_PROM (1 << 5)
271 #define UNITF_FULLDUPLEX (1 << 6)
272 #define UNITF_RXBUFFERINUSE (1 << 7)
273 #define UNITF_TXBUFFERINUSE (1 << 8)
276 /* Library and device bases */
278 #define SysBase (base->sys_base)
279 #define CardResource (base->card_base)
280 #define UtilityBase (base->utility_base)
281 #define ExpansionBase (base->expansion_base)
282 #define PrometheusBase (base->prometheus_base)
283 #define PowerPCIBase (base->powerpci_base)
284 #define OpenPciBase (base->openpci_base)
285 #define PCCardBase (base->pccard_base)
286 #define TimerBase (base->timer_request.tr_node.io_Device)
288 #ifdef __amigaos4__
289 #define IExec (base->i_exec)
290 #define IUtility (base->i_utility)
291 #define ICard (base->i_card)
292 #define IPCCard (base->i_pccard)
293 #define ITimer (base->i_timer)
294 #endif
296 #ifndef BASE_REG
297 #define BASE_REG a6
298 #endif
301 #endif