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,
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 "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
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
)();
131 #define ETH_ADDRESSSIZE 6
132 #define ETH_HEADERSIZE 14
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
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)
159 struct MsgPort
*request_ports
[REQUEST_QUEUE_COUNT
];
160 struct DevBase
*device
;
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
);
181 UPINT window1_offset
;
182 ULONG card_removed_signal
;
183 ULONG card_inserted_signal
;
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
];
201 struct IOSana2Req
**tx_requests
;
202 struct SignalSemaphore access_lock
;
212 UWORD tx_active_req_count
;
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
;
228 const VOID
*real_rx_function
;
229 const VOID
*real_tx_function
;
230 const VOID
*real_dma_tx_function
;
239 struct Sana2PacketTypeStats stats
;
247 struct Sana2PacketTypeStats stats
;
256 ULONG lower_bound_left
;
257 ULONG upper_bound_left
;
258 UWORD lower_bound_right
;
259 UWORD upper_bound_right
;
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)
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)