Detabbed
[AROS.git] / rom / dos / dopkt.c
blob2b99d55f74b7dc4e912e8a3e0d55de4db76e4f97
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: English
7 */
9 #include <aros/debug.h>
11 #include "dos_intern.h"
13 /*****************************************************************************
15 NAME */
16 #include <proto/dos.h>
18 AROS_LH7I(SIPTR, DoPkt,
20 /* SYNOPSIS */
21 AROS_LHA(struct MsgPort *, port, D1),
22 AROS_LHA(LONG , action, D2),
23 AROS_LHA(SIPTR , arg1, D3),
24 AROS_LHA(SIPTR , arg2, D4),
25 AROS_LHA(SIPTR , arg3, D5),
26 AROS_LHA(SIPTR , arg4, D6),
27 AROS_LHA(SIPTR , arg5, D7),
29 /* LOCATION */
30 struct DosLibrary *, DOSBase, 40, Dos)
32 /* FUNCTION
34 Send a dos packet to a filesystem and wait for the action to complete.
36 INPUTS
38 RESULT
40 NOTES
42 Callable from a task.
44 This function should NOT be used; it's only here for AmigaOS compatibility.
46 EXAMPLE
48 BUGS
50 SEE ALSO
52 INTERNALS
54 *****************************************************************************/
56 AROS_LIBFUNC_INIT
58 return dopacket(NULL, port, action, arg1, arg2, arg3, arg4, arg5, 0, 0);
60 AROS_LIBFUNC_EXIT
64 * All Amiga kickstart versions accept most dos packet dos calls without dosbase in A6.
65 * So we have this internal routine here for compatibility purposes.
67 SIPTR dopacket(SIPTR *res2, struct MsgPort *port, LONG action, SIPTR arg1, SIPTR arg2, SIPTR arg3, SIPTR arg4, SIPTR arg5, SIPTR arg6, SIPTR arg7)
69 SIPTR res;
70 struct Process *me = (struct Process *)FindTask(NULL);
71 struct DosPacket *dp;
72 struct MsgPort *replyPort;
74 ASSERT_VALID_PROCESS(me);
76 if (port == NULL)
78 /* NIL: */
79 D(bug("null port\n"));
80 return TRUE;
83 /* First I create a regular dos packet */
84 dp = allocdospacket();
85 if (NULL == dp)
86 return FALSE;
88 if (__is_process(me))
89 replyPort = &me->pr_MsgPort;
90 else
93 * Make sure that tasks can use DoPkt().
94 * This is needed, for example, by Dos/Init()
95 * when creating the initial Shell.
97 replyPort = CreateMsgPort();
99 if (NULL == replyPort)
101 freedospacket(dp);
102 return FALSE;
106 D(bug("dp=0x%p act=%d port=0x%p reply=0x%p proc=%d 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx '%s'\n",
107 dp, action, port, replyPort, __is_process(me), arg1, arg2, arg3, arg4, arg5, arg6, arg7, me->pr_Task.tc_Node.ln_Name));
108 dp->dp_Type = action;
109 dp->dp_Arg1 = arg1;
110 dp->dp_Arg2 = arg2;
111 dp->dp_Arg3 = arg3;
112 dp->dp_Arg4 = arg4;
113 dp->dp_Arg5 = arg5;
114 dp->dp_Arg6 = arg6;
115 dp->dp_Arg7 = arg7;
116 dp->dp_Res1 = 0;
117 dp->dp_Res2 = 0;
119 internal_SendPkt(dp, port, replyPort);
121 /* Did we get different packet back? System is in unstable state. */
122 if (internal_WaitPkt(replyPort) != dp)
123 Alert(AN_AsyncPkt);
125 D(bug("res1=%x res2=%x\n", dp->dp_Res1, dp->dp_Res2));
127 res = dp->dp_Res1;
128 if (res2)
129 *res2 = dp->dp_Res2;
131 if (__is_process(me))
132 me->pr_Result2 = dp->dp_Res2;
133 else
134 DeleteMsgPort(replyPort);
136 freedospacket(dp);
137 return res;