grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / devs / networks / rhine / device.h
blob5ecbd9e2f56104b324ece91f379973897488c746
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 "endian.h"
35 #include "io.h"
36 #include "ethernet.h"
38 #define DEVICE_NAME "rhine.device"
39 #define VERSION 0
40 #define REVISION 3
41 #define DATE "12.6.2012"
43 #define UTILITY_VERSION 39
44 #define PROMETHEUS_VERSION 2
46 #ifndef UPINT
47 #ifdef __AROS__
48 typedef IPTR UPINT;
49 typedef SIPTR PINT;
50 #else
51 typedef ULONG UPINT;
52 typedef LONG PINT;
53 #endif
54 #endif
56 #ifndef REG
57 #if defined(__mc68000) && !defined(__AROS__)
58 #define _REG(A, B) B __asm(#A)
59 #define REG(A, B) _REG(A, B)
60 #else
61 #define REG(A, B) B
62 #endif
63 #endif
65 #define _STR(A) #A
66 #define STR(A) _STR(A)
68 #if defined(__mc68000) || !defined(__AROS__)
69 #define USE_HACKS
70 #endif
73 struct DevBase
75 struct Device device;
76 APTR seg_list;
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)();
86 enum
88 WRITE_QUEUE,
89 MGMT_QUEUE,
90 ADOPT_QUEUE,
91 EVENT_QUEUE,
92 GENERAL_QUEUE,
93 REQUEST_QUEUE_COUNT
96 enum
98 PCI_BUS
101 #define STAT_COUNT 3
103 #define FRAME_BUFFER_SIZE (ETH_HEADERSIZE + ETH_MTU + ETH_CRCSIZE)
104 #define TX_SLOT_COUNT 10
105 #define RX_SLOT_COUNT 10
108 struct DevUnit
110 struct MinNode node;
111 ULONG index;
112 ULONG open_count;
113 ULONG flags;
114 UWORD bus;
115 struct Task *task;
116 struct MsgPort *request_ports[REQUEST_QUEUE_COUNT];
117 struct DevBase *device;
118 APTR card;
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);
129 UBYTE *tx_buffer;
130 UBYTE *tx_buffers[TX_SLOT_COUNT];
131 UBYTE *rx_buffers[RX_SLOT_COUNT];
132 ULONG card_removed_signal;
133 ULONG card_inserted_signal;
134 ULONG range_count;
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;
153 UWORD tx_in_slot;
154 UWORD tx_out_slot;
155 UWORD rx_slot;
156 UBYTE mii_phy_no;
157 ULONG speed;
161 struct Opener
163 struct MinNode node;
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;
177 /* Unit flags */
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)
198 #ifndef BASE_REG
199 #define BASE_REG a6
200 #endif
203 #endif