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,
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>
36 #define DEVICE_NAME "etherlink3.device"
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
59 #if defined(__mc68000) && !defined(__AROS__)
60 #define _REG(A, B) B __asm(#A)
61 #define REG(A, B) _REG(A, B)
68 #define STR(A) _STR(A)
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
;
86 struct MinList pci_units
;
87 struct MinList isa_units
;
88 struct MinList pccard_units
;
89 struct timerequest timer_request
;
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
;
99 VOID (*wrapper_int_code
)();
100 VOID (*wrapper_card_code
)();
132 #define ETH_ADDRESSSIZE 6
133 #define ETH_HEADERSIZE 14
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
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)
160 struct MsgPort
*request_ports
[REQUEST_QUEUE_COUNT
];
161 struct DevBase
*device
;
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
);
182 UPINT window1_offset
;
183 ULONG card_removed_signal
;
184 ULONG card_inserted_signal
;
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
];
202 struct IOSana2Req
**tx_requests
;
203 struct SignalSemaphore access_lock
;
213 UWORD tx_active_req_count
;
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
;
240 struct Sana2PacketTypeStats stats
;
248 struct Sana2PacketTypeStats stats
;
257 ULONG lower_bound_left
;
258 ULONG upper_bound_left
;
259 UWORD lower_bound_right
;
260 UWORD upper_bound_right
;
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)
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)