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>
38 #define DEVICE_NAME "rhine.device"
41 #define DATE "12.6.2012"
43 #define UTILITY_VERSION 39
44 #define PROMETHEUS_VERSION 2
57 #if defined(__mc68000) && !defined(__AROS__)
58 #define _REG(A, B) B __asm(#A)
59 #define REG(A, B) _REG(A, B)
66 #define STR(A) _STR(A)
68 #if defined(__mc68000) || !defined(__AROS__)
77 struct ExecBase
*sys_base
;
78 struct UtilityBase
*utility_base
;
79 struct Library
*prometheus_base
;
80 struct MinList pci_units
;
81 struct timerequest timer_request
;
82 VOID (*wrapper_int_code
)();
103 #define FRAME_BUFFER_SIZE (ETH_HEADERSIZE + ETH_MTU + ETH_CRCSIZE)
104 #define TX_SLOT_COUNT 10
105 #define RX_SLOT_COUNT 10
116 struct MsgPort
*request_ports
[REQUEST_QUEUE_COUNT
];
117 struct DevBase
*device
;
119 BOOL (*insertion_function
)(APTR
, struct DevBase
*);
120 VOID (*removal_function
)(APTR
, struct DevBase
*);
121 ULONG (*ByteIn
)(APTR
, ULONG
);
122 VOID (*ByteOut
)(APTR
, ULONG
, UBYTE
);
123 UWORD (*LEWordIn
)(APTR
, ULONG
);
124 ULONG (*LELongIn
)(APTR
, ULONG
);
125 VOID (*LEWordOut
)(APTR
, ULONG
, UWORD
);
126 VOID (*LELongOut
)(APTR
, ULONG
, ULONG
);
127 APTR (*AllocDMAMem
)(APTR
, UPINT
, UWORD
);
128 VOID (*FreeDMAMem
)(APTR
, APTR
);
130 UBYTE
*tx_buffers
[TX_SLOT_COUNT
];
131 UBYTE
*rx_buffers
[RX_SLOT_COUNT
];
132 ULONG card_removed_signal
;
133 ULONG card_inserted_signal
;
135 UBYTE address
[ETH_ADDRESSSIZE
];
136 UBYTE default_address
[ETH_ADDRESSSIZE
];
137 struct MinList openers
;
138 struct MinList type_trackers
;
139 struct MinList multicast_ranges
;
140 struct Interrupt status_int
;
141 struct Interrupt rx_int
;
142 struct Interrupt tx_int
;
143 struct Interrupt tx_end_int
;
144 struct Interrupt reset_handler
;
145 struct Sana2DeviceStats stats
;
146 ULONG special_stats
[STAT_COUNT
];
147 ULONG
*tx_descs
[TX_SLOT_COUNT
];
148 ULONG tx_descs_p
[TX_SLOT_COUNT
];
149 ULONG
*rx_descs
[TX_SLOT_COUNT
];
150 ULONG rx_descs_p
[TX_SLOT_COUNT
];
151 struct IOSana2Req
**tx_requests
;
152 struct SignalSemaphore access_lock
;
164 struct MsgPort read_port
;
165 struct MsgPort mgmt_port
;
166 BOOL (*rx_function
)(REG(a0
, APTR
), REG(a1
, APTR
), REG(d0
, ULONG
));
167 BOOL (*tx_function
)(REG(a0
, APTR
), REG(a1
, APTR
), REG(d0
, ULONG
));
168 UBYTE
*(*dma_tx_function
)(REG(a0
, APTR
));
169 struct Hook
*filter_hook
;
170 struct MinList initial_stats
;
171 const VOID
*real_rx_function
;
172 const VOID
*real_tx_function
;
173 const VOID
*real_dma_tx_function
;
179 #define UNITF_SHARED (1 << 0)
180 #define UNITF_ONLINE (1 << 1)
181 #define UNITF_ALLMCAST (1 << 2)
182 #define UNITF_HAVEADAPTER (1 << 3)
183 #define UNITF_CONFIGURED (1 << 4)
184 #define UNITF_PROM (1 << 5)
185 #define UNITF_WASONLINE (1 << 6) /* card was online at time of removal */
186 #define UNITF_TXBUFFERINUSE (1 << 7)
187 #define UNITF_INTADDED (1 << 8)
188 #define UNITF_RESETADDED (1 << 9)
191 /* Library and device bases */
193 #define SysBase (base->sys_base)
194 #define UtilityBase (base->utility_base)
195 #define PrometheusBase (base->prometheus_base)
196 #define TimerBase (base->timer_request.tr_node.io_Device)