AROS_INT: oops - forgot to resolve a conflict
[AROS.git] / workbench / devs / networks / prism2 / aros_device.c
blob26872b157e25162a57f917669cc6e234c3e19530
1 /*
3 Copyright (C) 2011 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.
23 #include <exec/types.h>
24 #include <exec/resident.h>
25 #include <aros/asmcall.h>
26 #include <aros/libcall.h>
27 #include <resources/card.h>
29 #include "initializers.h"
31 #include "device.h"
33 #include "device_protos.h"
36 /* Private prototypes */
38 AROS_LD2(struct DevBase *, AROSDevInit,
39 AROS_LDA(struct DevBase *, dev_base, D0),
40 AROS_LDA(struct DevBase *, seg_list, A0),
41 struct DevBase *, base, 0, S2);
42 AROS_LD3(BYTE, AROSDevOpen,
43 AROS_LDA(struct IOSana2Req *, request, A1),
44 AROS_LDA(LONG, unit_num, D0),
45 AROS_LDA(ULONG, flags, D1),
46 struct DevBase *, base, 1, S2);
47 AROS_LD1(APTR, AROSDevClose,
48 AROS_LDA(struct IOSana2Req *, request, A1),
49 struct DevBase *, base, 2, S2);
50 AROS_LD0(APTR, AROSDevExpunge,
51 struct DevBase *, base, 3, S2);
52 AROS_LD0(APTR, AROSDevReserved,
53 struct DevBase *, base, 4, S2);
54 AROS_LD1(VOID, AROSDevBeginIO,
55 AROS_LDA(struct IOSana2Req *, request, A1),
56 struct DevBase *, base, 5, S2);
57 AROS_LD1(VOID, AROSDevAbortIO,
58 AROS_LDA(struct IOSana2Req *, request, A1),
59 struct DevBase *, base, 6, S2);
60 static BOOL RXFunction(struct IOSana2Req *request, APTR buffer, ULONG size);
61 static BOOL TXFunction(APTR buffer, struct IOSana2Req *request, ULONG size);
62 static UBYTE *DMATXFunction(struct IOSana2Req *request);
63 AROS_INTP(AROSInt);
64 AROS_CARDP(AROSCardInt);
66 extern const APTR init_data;
67 extern const struct Resident rom_tag;
68 extern const TEXT device_name[];
69 extern const TEXT version_string[];
72 static const APTR vectors[] =
74 (APTR)AROS_SLIB_ENTRY(AROSDevOpen, S2, 1),
75 (APTR)AROS_SLIB_ENTRY(AROSDevClose, S2, 2),
76 (APTR)AROS_SLIB_ENTRY(AROSDevExpunge, S2, 3),
77 (APTR)AROS_SLIB_ENTRY(AROSDevReserved, S2, 4),
78 (APTR)AROS_SLIB_ENTRY(AROSDevBeginIO, S2, 5),
79 (APTR)AROS_SLIB_ENTRY(AROSDevAbortIO, S2, 6),
80 (APTR)-1
84 static const APTR init_table[] =
86 (APTR)sizeof(struct DevBase),
87 (APTR)vectors,
88 (APTR)&init_data,
89 (APTR)AROS_SLIB_ENTRY(AROSDevInit, S2, 0),
93 const struct Resident aros_rom_tag =
95 RTC_MATCHWORD,
96 (struct Resident *)&aros_rom_tag,
97 (APTR)(&rom_tag + 1),
98 RTF_AUTOINIT,
99 VERSION,
100 NT_DEVICE,
102 (TEXT *)device_name,
103 (TEXT *)version_string,
104 (APTR)init_table
109 /****i* prism2.device/AROSDevInit **************************************
111 * NAME
112 * AROSDevInit
114 ****************************************************************************
118 AROS_LH2(struct DevBase *, AROSDevInit,
119 AROS_LHA(struct DevBase *, dev_base, D0),
120 AROS_LHA(struct DevBase *, seg_list, A0),
121 struct DevBase *, base, 0, S2)
123 AROS_LIBFUNC_INIT
125 base = DevInit(dev_base, seg_list, base);
127 if(base != NULL) {
128 base->wrapper_int_code = (APTR)AROSInt;
129 base->wrapper_card_code = (APTR)AROSCardInt;
131 return base;
133 AROS_LIBFUNC_EXIT
138 /****i* prism2.device/AROSDevOpen **************************************
140 * NAME
141 * AROSDevOpen
143 ****************************************************************************
147 AROS_LH3(BYTE, AROSDevOpen,
148 AROS_LHA(struct IOSana2Req *, request, A1),
149 AROS_LHA(LONG, unit_num, D0),
150 AROS_LHA(ULONG, flags, D1),
151 struct DevBase *, base, 1, S2)
153 AROS_LIBFUNC_INIT
155 struct Opener *opener;
156 BYTE error;
158 error = DevOpen(request, unit_num, flags, base);
160 /* Set up wrapper hooks to hide register-call functions */
162 if(error == 0)
164 opener = request->ios2_BufferManagement;
165 opener->real_rx_function = opener->rx_function;
166 opener->real_tx_function = opener->tx_function;
167 opener->rx_function = (APTR)RXFunction;
168 opener->tx_function = (APTR)TXFunction;
169 if(opener->dma_tx_function != NULL)
171 opener->real_dma_tx_function = opener->dma_tx_function;
172 opener->dma_tx_function = (APTR)DMATXFunction;
176 return error;
178 AROS_LIBFUNC_EXIT
183 /****i* prism2.device/AROSDevClose *************************************
185 * NAME
186 * AROSDevClose
188 ****************************************************************************
192 AROS_LH1(APTR, AROSDevClose,
193 AROS_LHA(struct IOSana2Req *, request, A1),
194 struct DevBase *, base, 2, S2)
196 AROS_LIBFUNC_INIT
198 return DevClose(request, base);
200 AROS_LIBFUNC_EXIT
205 /****i* prism2.device/AROSDevExpunge ***********************************
207 * NAME
208 * AROSDevExpunge
210 ****************************************************************************
214 AROS_LH0(APTR, AROSDevExpunge,
215 struct DevBase *, base, 3, S2)
217 AROS_LIBFUNC_INIT
219 return DevExpunge(base);
221 AROS_LIBFUNC_EXIT
226 /****i* prism2.device/AROSDevReserved **********************************
228 * NAME
229 * AROSDevReserved
231 ****************************************************************************
235 AROS_LH0(APTR, AROSDevReserved,
236 struct DevBase *, base, 4, S2)
238 AROS_LIBFUNC_INIT
240 return DevReserved(base);
242 AROS_LIBFUNC_EXIT
247 /****i* prism2.device/AROSDevBeginIO ***********************************
249 * NAME
250 * AROSDevBeginIO
252 ****************************************************************************
256 AROS_LH1(VOID, AROSDevBeginIO,
257 AROS_LHA(struct IOSana2Req *, request, A1),
258 struct DevBase *, base, 5, S2)
260 AROS_LIBFUNC_INIT
262 /* Replace caller's cookie with our own */
264 switch(request->ios2_Req.io_Command)
266 case CMD_READ:
267 case CMD_WRITE:
268 case S2_MULTICAST:
269 case S2_BROADCAST:
270 case S2_READORPHAN:
271 request->ios2_StatData = request->ios2_Data;
272 request->ios2_Data = request;
275 DevBeginIO(request, base);
277 AROS_LIBFUNC_EXIT
282 /****i* prism2.device/AROSDevAbortIO ***********************************
284 * NAME
285 * AROSDevAbortIO -- Try to stop a request.
287 ****************************************************************************
291 AROS_LH1(VOID, AROSDevAbortIO,
292 AROS_LHA(struct IOSana2Req *, request, A1),
293 struct DevBase *, base, 6, S2)
295 AROS_LIBFUNC_INIT
297 DevAbortIO(request, base);
299 AROS_LIBFUNC_EXIT
304 /****i* prism2.device/RXFunction ***************************************
306 * NAME
307 * RXFunction
309 ****************************************************************************
313 static BOOL RXFunction(struct IOSana2Req *request, APTR buffer, ULONG size)
315 struct Opener *opener;
316 APTR cookie;
318 opener = request->ios2_BufferManagement;
319 cookie = request->ios2_StatData;
320 request->ios2_Data = cookie;
322 return AROS_UFC3(BOOL, (APTR)opener->real_rx_function,
323 AROS_UFCA(APTR, cookie, A0),
324 AROS_UFCA(APTR, buffer, A1),
325 AROS_UFCA(ULONG, size, D0));
330 /****i* prism2.device/TXFunction ***************************************
332 * NAME
333 * TXFunction
335 ****************************************************************************
339 static BOOL TXFunction(APTR buffer, struct IOSana2Req *request, ULONG size)
341 struct Opener *opener;
342 APTR cookie;
344 opener = request->ios2_BufferManagement;
345 cookie = request->ios2_StatData;
346 request->ios2_Data = cookie;
348 return AROS_UFC3(BOOL, (APTR)opener->real_tx_function,
349 AROS_UFCA(APTR, buffer, A0),
350 AROS_UFCA(APTR, cookie, A1),
351 AROS_UFCA(ULONG, size, D0));
356 /****i* prism2.device/DMATXFunction ************************************
358 * NAME
359 * DMATXFunction
361 ****************************************************************************
365 static UBYTE *DMATXFunction(struct IOSana2Req *request)
367 struct Opener *opener;
368 APTR cookie;
370 opener = request->ios2_BufferManagement;
371 cookie = request->ios2_StatData;
372 request->ios2_Data = cookie;
374 return AROS_UFC1(UBYTE *, (APTR)opener->real_dma_tx_function,
375 AROS_UFCA(APTR, cookie, A0));
380 /****i* prism2.device/AROSInt ******************************************
382 * NAME
383 * AROSInt
385 ****************************************************************************
388 #undef SysBase
390 AROS_INTH2(AROSInt, APTR *, int_data, mask)
392 AROS_INTFUNC_INIT
394 BOOL (*int_code)(APTR, APTR, UBYTE);
396 int_code = int_data[0];
397 return int_code(int_data[1], int_code, mask);
399 AROS_INTFUNC_EXIT
402 /****i* prism2.device/AROSCardInt ******************************************
404 * NAME
405 * AROSCardInt
407 ****************************************************************************
410 /* Mask is in D0 */
411 AROS_CARDH(AROSCardInt, APTR *, int_data, mask)
413 AROS_CARDFUNC_INIT
415 BOOL (*int_code)(APTR, APTR, UBYTE);
417 int_code = int_data[0];
418 return int_code(int_data[1], int_code, mask);
420 AROS_CARDFUNC_EXIT