ae8c9e4a2b15b1e4f6d5ac265e96dab92fe2796c
[AROS.git] / arch / m68k-all / dos / callglobvec.c
blobae8c9e4a2b15b1e4f6d5ac265e96dab92fe2796c
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Open a file with the specified mode.
6 Lang: english
7 */
9 #include <aros/debug.h>
10 #include <exec/memory.h>
11 #include <exec/lists.h>
12 #include <proto/exec.h>
13 #include <utility/tagitem.h>
14 #include <dos/dosextens.h>
15 #include <dos/stdio.h>
16 #include <proto/dos.h>
17 #include <proto/utility.h>
19 #include "dos_intern.h"
20 #include "bcpl.h"
22 extern void BCPL_thunk(void);
23 #define __is_process(task) (((struct Task *)task)->tc_Node.ln_Type == NT_PROCESS)
25 /*****************************************************************************
27 NAME */
28 #include <proto/dos.h>
30 AROS_UFH5(LONG, CallGlobVec,
32 /* SYNOPSIS */
33 AROS_UFHA(LONG, function, D0),
34 AROS_UFHA(LONG, d1, D1),
35 AROS_UFHA(LONG, d2, D2),
36 AROS_UFHA(LONG, d3, D3),
37 AROS_UFHA(LONG, d4, D4)
39 /* LOCATION */
42 /* FUNCTION
43 Private function to call a BCPL routine from C
45 INPUTS
46 function - BCPL Global Vector function index
47 d1..d4 - Parameter to the function
49 RESULT
50 return value of the BCPL routine
52 NOTES
53 This works only on m68k.
55 EXAMPLE
57 BUGS
59 SEE ALSO
61 INTERNALS
63 *****************************************************************************/
65 AROS_USERFUNC_INIT
67 struct Process *me = (struct Process *)FindTask(NULL);
68 LONG ret;
69 APTR oldReturnAddr;
71 D(bug("%s: 0x%d (0x%x, 0x%x, 0x%x, 0x%x) GV %p\n", __func__, function, d1, d2, d3, d4, __is_process(me) ? me->pr_GlobVec : NULL));
73 if (!__is_process(me))
74 return DOSFALSE;
76 oldReturnAddr = me->pr_ReturnAddr;
77 ret = AROS_UFC8(LONG, BCPL_thunk,
78 AROS_UFCA(LONG, d1, D1),
79 AROS_UFCA(LONG, d2, D2),
80 AROS_UFCA(LONG, d3, D3),
81 AROS_UFCA(LONG, d4, D4),
82 AROS_UFCA(APTR, me->pr_Task.tc_SPLower, A1),
83 AROS_UFCA(APTR, me->pr_GlobVec, A2),
84 AROS_UFCA(APTR, &me->pr_ReturnAddr, A3),
85 AROS_UFCA(LONG_FUNC, ((LONG_FUNC *)me->pr_GlobVec)[function], A4));
86 me->pr_ReturnAddr = oldReturnAddr;
88 return ret;
90 AROS_USERFUNC_EXIT
91 } /* CallGlobVec */