Check for SYS/GL during library init. Reason is that
[AROS.git] / workbench / devs / networks / intelpro100 / device.h
blob4747aa612f266bdfc18d05eebfbb2995cdd147ea
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"
35 #include "endian.h"
36 #undef Lock
38 #define DEVICE_NAME "intelpro100.device"
39 #define VERSION 1
40 #define REVISION 1
41 #define DATE "12.6.2012"
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
49 #ifndef UPINT
50 #ifdef __AROS__
51 typedef IPTR UPINT;
52 typedef SIPTR PINT;
53 #else
54 typedef ULONG UPINT;
55 typedef LONG PINT;
56 #endif
57 #endif
59 #ifndef REG
60 #if defined(__mc68000) && !defined(__AROS__)
61 #define _REG(A, B) B __asm(#A)
62 #define REG(A, B) _REG(A, B)
63 #else
64 #define REG(A, B) B
65 #endif
66 #endif
68 #define _STR(A) #A
69 #define STR(A) _STR(A)
71 #ifndef __AROS__
72 #define USE_HACKS
73 #endif
76 struct DevBase
78 struct Device device;
79 APTR seg_list;
80 struct ExecBase *sys_base;
81 struct UtilityBase *utility_base;
82 struct Library *prometheus_base;
83 struct Library *powerpci_base;
84 struct Library *openpci_base;
85 struct MinList pci_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 ADOPT_QUEUE,
102 EVENT_QUEUE,
103 GENERAL_QUEUE,
104 REQUEST_QUEUE_COUNT
107 enum
109 PCI_BUS
112 enum
114 I82557_GEN,
115 I82558_GEN,
116 I82559_GEN,
117 I82550_GEN,
118 I82551_GEN,
119 I82562_GEN
122 #define IO_WINDOW_SIZE 0x40
124 #define ETH_ADDRESSSIZE 6
125 #define ETH_HEADERSIZE 14
126 #define ETH_MTU 1500
127 #define ETH_MAXPACKETSIZE ((ETH_HEADERSIZE) + (ETH_MTU))
129 #define ETH_PACKET_DEST 0
130 #define ETH_PACKET_SOURCE 6
131 #define ETH_PACKET_TYPE 12
132 #define ETH_PACKET_IEEELEN 12
133 #define ETH_PACKET_SNAPTYPE 20
134 #define ETH_PACKET_DATA 14
136 #define SPECIAL_STAT_COUNT 3
138 #define TX_SLOT_COUNT 10
139 #define RX_SLOT_COUNT 10
140 #define TCB_SIZE \
141 (sizeof(ULONG) * (PROCB_EXTBUFFER + PRO_FRAGLEN * 2) \
142 + ((ETH_HEADERSIZE + 3) & ~3))
143 #define RCB_SIZE \
144 (sizeof(ULONG) * PROCB_BUFFER + ((ETH_MAXPACKETSIZE + 3) & ~3))
147 struct DevUnit
149 struct MinNode node;
150 ULONG index;
151 ULONG open_count;
152 UWORD flags;
153 struct Task *task;
154 struct MsgPort *request_ports[REQUEST_QUEUE_COUNT];
155 struct DevBase *device;
156 APTR card;
157 ULONG (*ByteIn)(APTR, UBYTE);
158 VOID (*ByteOut)(APTR, ULONG, UBYTE);
159 UWORD (*LEWordIn)(APTR, ULONG);
160 ULONG (*LELongIn)(APTR, ULONG);
161 VOID (*LEWordOut)(APTR, ULONG, UWORD);
162 VOID (*LELongOut)(APTR, ULONG, ULONG);
163 APTR (*AllocDMAMem)(APTR, UPINT, UWORD);
164 VOID (*FreeDMAMem)(APTR, APTR);
165 UBYTE *tx_buffer;
166 UBYTE address[ETH_ADDRESSSIZE];
167 UBYTE default_address[ETH_ADDRESSSIZE];
168 struct MinList openers;
169 struct MinList type_trackers;
170 struct MinList multicast_ranges;
171 struct MinList tx_requests;
172 struct Interrupt status_int;
173 struct Interrupt rx_int;
174 struct Interrupt tx_int;
175 struct Interrupt tx_end_int;
176 struct Sana2DeviceStats stats;
177 ULONG *stats_buffer;
178 ULONG special_stats[SPECIAL_STAT_COUNT];
179 ULONG *tcbs;
180 ULONG *rcbs;
181 ULONG *last_rcb;
182 ULONG *first_tcb;
183 ULONG *last_tcb;
184 ULONG *multicast_cb;
185 ULONG *link_cb;
186 ULONG speed;
187 struct SignalSemaphore access_lock;
188 UWORD phy_info;
189 UWORD bus;
190 UWORD eeprom_addr_size;
194 struct Opener
196 struct MinNode node;
197 struct MsgPort read_port;
198 BOOL (*rx_function)(REG(a0, APTR), REG(a1, APTR), REG(d0, ULONG));
199 BOOL (*tx_function)(REG(a0, APTR), REG(a1, APTR), REG(d0, ULONG));
200 UBYTE *(*dma_tx_function)(REG(a0, APTR));
201 struct Hook *filter_hook;
202 struct MinList initial_stats;
203 #if defined(__amigaos4__) || defined(__MORPHOS__) || defined(__AROS__)
204 const VOID *real_rx_function;
205 const VOID *real_tx_function;
206 const VOID *real_dma_tx_function;
207 #endif
211 struct TypeStats
213 struct MinNode node;
214 ULONG packet_type;
215 struct Sana2PacketTypeStats stats;
219 struct TypeTracker
221 struct MinNode node;
222 ULONG packet_type;
223 struct Sana2PacketTypeStats stats;
224 ULONG user_count;
228 struct AddressRange
230 struct MinNode node;
231 ULONG add_count;
232 ULONG lower_bound_left;
233 ULONG upper_bound_left;
234 UWORD lower_bound_right;
235 UWORD upper_bound_right;
239 /* Unit flags */
241 #define UNITF_SHARED (1 << 0)
242 #define UNITF_ONLINE (1 << 1)
243 #define UNITF_ALLMCAST (1 << 2)
244 #define UNITF_HAVEADAPTER (1 << 3)
245 #define UNITF_CONFIGURED (1 << 4)
246 #define UNITF_PROM (1 << 5)
247 #define UNITF_WASONLINE (1 << 6) /* card was online at time of removal */
248 #define UNITF_TXBUFFERINUSE (1 << 7)
249 #define UNITF_MCASTBUFFERINUSE (1 << 8)
252 /* Library and device bases */
254 #define SysBase (base->sys_base)
255 #define UtilityBase (base->utility_base)
256 #define ExpansionBase (base->expansion_base)
257 #define OpenPciBase (base->openpci_base)
258 #define PrometheusBase (base->prometheus_base)
259 #define PowerPCIBase (base->powerpci_base)
260 #define TimerBase (base->timer_request.tr_node.io_Device)
262 #ifdef __amigaos4__
263 #define IExec (base->i_exec)
264 #define IUtility (base->i_utility)
265 #define ITimer (base->i_timer)
266 #endif
268 #ifndef BASE_REG
269 #define BASE_REG a6
270 #endif
273 #endif