3 Copyright (C) 2011,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,
23 #include <exec/types.h>
24 #include <exec/resident.h>
25 #include <aros/asmcall.h>
26 #include <aros/libcall.h>
27 #include "initializers.h"
31 #include "device_protos.h"
34 /* Private prototypes */
36 AROS_UFP3(struct DevBase
*, AROSDevInit
,
37 AROS_UFPA(struct DevBase
*, dev_base
, D0
),
38 AROS_UFPA(APTR
, seg_list
, A0
),
39 AROS_UFPA(struct DevBase
*, base
, A6
));
40 AROS_LD3(BYTE
, AROSDevOpen
,
41 AROS_LDA(struct IOSana2Req
*, request
, A1
),
42 AROS_LDA(LONG
, unit_num
, D0
),
43 AROS_LDA(ULONG
, flags
, D1
),
44 struct DevBase
*, base
, 1, S2
);
45 AROS_LD1(APTR
, AROSDevClose
,
46 AROS_LDA(struct IOSana2Req
*, request
, A1
),
47 struct DevBase
*, base
, 2, S2
);
48 AROS_LD0(APTR
, AROSDevExpunge
,
49 struct DevBase
*, base
, 3, S2
);
50 AROS_LD0(APTR
, AROSDevReserved
,
51 struct DevBase
*, base
, 4, S2
);
52 AROS_LD1(VOID
, AROSDevBeginIO
,
53 AROS_LDA(struct IOSana2Req
*, request
, A1
),
54 struct DevBase
*, base
, 5, S2
);
55 AROS_LD1(VOID
, AROSDevAbortIO
,
56 AROS_LDA(struct IOSana2Req
*, request
, A1
),
57 struct DevBase
*, base
, 6, S2
);
58 static BOOL
RXFunction(struct IOSana2Req
*request
, APTR buffer
, ULONG size
);
59 static BOOL
TXFunction(APTR buffer
, struct IOSana2Req
*request
, ULONG size
);
60 static UBYTE
*DMATXFunction(struct IOSana2Req
*request
);
61 AROS_UFP3(BOOL
, AROSInt
,
62 AROS_UFPA(APTR
*, int_data
, A1
),
63 AROS_UFPA(APTR
, this_code
, A5
),
64 AROS_UFPA(UBYTE
, mask
, D0
));
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),
84 static const APTR init_table
[] =
86 (APTR
)sizeof(struct DevBase
),
93 const struct Resident aros_rom_tag
=
96 (struct Resident
*)&aros_rom_tag
,
103 (TEXT
*)version_string
,
109 /****i* intelpro100.device/AROSDevInit *************************************
114 ****************************************************************************
118 AROS_UFH3(struct DevBase
*, AROSDevInit
,
119 AROS_UFHA(struct DevBase
*, dev_base
, D0
),
120 AROS_UFHA(APTR
, seg_list
, A0
),
121 AROS_UFHA(struct DevBase
*, base
, A6
))
125 base
= DevInit(dev_base
, seg_list
, base
);
128 base
->wrapper_int_code
= (APTR
)AROSInt
;
136 /****i* intelpro100.device/AROSDevOpen *************************************
141 ****************************************************************************
145 AROS_LH3(BYTE
, AROSDevOpen
,
146 AROS_LHA(struct IOSana2Req
*, request
, A1
),
147 AROS_LHA(LONG
, unit_num
, D0
),
148 AROS_LHA(ULONG
, flags
, D1
),
149 struct DevBase
*, base
, 1, S2
)
153 struct Opener
*opener
;
156 error
= DevOpen(request
, unit_num
, flags
, base
);
158 /* Set up wrapper hooks to hide register-call functions */
162 opener
= request
->ios2_BufferManagement
;
163 opener
->real_rx_function
= opener
->rx_function
;
164 opener
->real_tx_function
= opener
->tx_function
;
165 opener
->rx_function
= (APTR
)RXFunction
;
166 opener
->tx_function
= (APTR
)TXFunction
;
167 if(opener
->dma_tx_function
!= NULL
)
169 opener
->real_dma_tx_function
= opener
->dma_tx_function
;
170 opener
->dma_tx_function
= (APTR
)DMATXFunction
;
181 /****i* intelpro100.device/AROSDevClose ************************************
186 ****************************************************************************
190 AROS_LH1(APTR
, AROSDevClose
,
191 AROS_LHA(struct IOSana2Req
*, request
, A1
),
192 struct DevBase
*, base
, 2, S2
)
196 return DevClose(request
, base
);
203 /****i* intelpro100.device/AROSDevExpunge **********************************
208 ****************************************************************************
212 AROS_LH0(APTR
, AROSDevExpunge
,
213 struct DevBase
*, base
, 3, S2
)
217 return DevExpunge(base
);
224 /****i* intelpro100.device/AROSDevReserved *********************************
229 ****************************************************************************
233 AROS_LH0(APTR
, AROSDevReserved
,
234 struct DevBase
*, base
, 4, S2
)
238 return DevReserved(base
);
245 /****i* intelpro100.device/AROSDevBeginIO **********************************
250 ****************************************************************************
254 AROS_LH1(VOID
, AROSDevBeginIO
,
255 AROS_LHA(struct IOSana2Req
*, request
, A1
),
256 struct DevBase
*, base
, 5, S2
)
260 /* Replace caller's cookie with our own */
262 switch(request
->ios2_Req
.io_Command
)
269 request
->ios2_StatData
= request
->ios2_Data
;
270 request
->ios2_Data
= request
;
273 DevBeginIO(request
, base
);
280 /****i* intelpro100.device/AROSDevAbortIO **********************************
283 * AROSDevAbortIO -- Try to stop a request.
285 ****************************************************************************
289 AROS_LH1(VOID
, AROSDevAbortIO
,
290 AROS_LHA(struct IOSana2Req
*, request
, A1
),
291 struct DevBase
*, base
, 6, S2
)
295 DevAbortIO(request
, base
);
302 /****i* intelpro100.device/RXFunction **************************************
307 ****************************************************************************
311 static BOOL
RXFunction(struct IOSana2Req
*request
, APTR buffer
, ULONG size
)
313 struct Opener
*opener
;
316 opener
= request
->ios2_BufferManagement
;
317 cookie
= request
->ios2_StatData
;
318 request
->ios2_Data
= cookie
;
320 return AROS_UFC3(BOOL
, (APTR
)opener
->real_rx_function
,
321 AROS_UFCA(APTR
, cookie
, A0
),
322 AROS_UFCA(APTR
, buffer
, A1
),
323 AROS_UFCA(ULONG
, size
, D0
));
328 /****i* intelpro100.device/TXFunction **************************************
333 ****************************************************************************
337 static BOOL
TXFunction(APTR buffer
, struct IOSana2Req
*request
, ULONG size
)
339 struct Opener
*opener
;
342 opener
= request
->ios2_BufferManagement
;
343 cookie
= request
->ios2_StatData
;
344 request
->ios2_Data
= cookie
;
346 return AROS_UFC3(BOOL
, (APTR
)opener
->real_tx_function
,
347 AROS_UFCA(APTR
, buffer
, A0
),
348 AROS_UFCA(APTR
, cookie
, A1
),
349 AROS_UFCA(ULONG
, size
, D0
));
354 /****i* intelpro100.device/DMATXFunction ***********************************
359 ****************************************************************************
363 static UBYTE
*DMATXFunction(struct IOSana2Req
*request
)
365 struct Opener
*opener
;
368 opener
= request
->ios2_BufferManagement
;
369 cookie
= request
->ios2_StatData
;
370 request
->ios2_Data
= cookie
;
372 return AROS_UFC1(UBYTE
*, (APTR
)opener
->real_dma_tx_function
,
373 AROS_UFCA(APTR
, cookie
, A0
));
378 /****i* intelpro100.device/AROSInt *****************************************
383 ****************************************************************************
387 AROS_UFH3(BOOL
, AROSInt
,
388 AROS_UFHA(APTR
*, int_data
, A1
),
389 AROS_UFHA(APTR
, this_code
, A5
),
390 AROS_UFHA(UBYTE
, mask
, D0
))
394 BOOL (*int_code
)(APTR
, APTR
, UBYTE
);
396 int_code
= int_data
[0];
397 return int_code(int_data
[1], int_code
, mask
);