2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: Send a message to a port.
8 #include "exec_intern.h"
9 #include <aros/libcall.h>
10 #include <exec/ports.h>
11 #include <proto/exec.h>
13 /*****************************************************************************
17 AROS_LH2(void, PutMsg
,
20 AROS_LHA(struct MsgPort
*, port
, A0
),
21 AROS_LHA(struct Message
*, message
, A1
),
24 struct ExecBase
*, SysBase
, 61, Exec
)
27 Sends a message to a given message port. Messages are not copied
28 from one task to another but must lie in shared memory instead.
29 Therefore the owner of the message may generally not reuse it before
30 it is returned. But this depends on the two tasks sharing the message.
33 port - Pointer to messageport.
34 message - Pointer to message.
39 It is legal to send a message from within interrupts.
41 Messages may either trigger a signal at the owner of the messageport
42 or raise a software interrupt, depending on port->mp_Flags&PF_ACTION.
53 ******************************************************************************/
56 ASSERT_VALID_PTR(message
);
57 ASSERT_VALID_PTR(port
);
59 /* FASTCALL is a special case that operates without the message list
60 * locked, so we have to check it before anything */
61 if (port
->mp_Flags
& PA_FASTCALL
)
63 if (port
->mp_SoftInt
== NULL
|| ((struct Interrupt
*) port
->mp_SoftInt
)->is_Code
== NULL
)
66 ASSERT_VALID_PTR(port
->mp_SoftInt
);
67 ASSERT_VALID_PTR(((struct Interrupt
*) port
->mp_SoftInt
)->is_Code
);
69 /* call the "interrupt" with the message as an argument */
70 AROS_UFC4(void, ((struct Interrupt
*) port
->mp_SoftInt
)->is_Code
,
71 AROS_UFCA(APTR
, ((struct Interrupt
*) port
->mp_SoftInt
)->is_Data
, A1
),
72 AROS_UFCA(ULONG_FUNC
, ((struct Interrupt
*) port
->mp_SoftInt
)->is_Code
, A5
),
73 AROS_UFCA(struct Message
*, message
, D0
),
74 AROS_UFCA(struct ExecBase
*, SysBase
, A6
));
80 Messages may be sent from interrupts. Therefore the message list
81 of the message port must be protected with Disable().
85 /* Set the node type to NT_MESSAGE == sent message. */
86 message
->mn_Node
.ln_Type
=NT_MESSAGE
;
88 /* Add it to the message list. */
89 AddTail(&port
->mp_MsgList
,&message
->mn_Node
);
93 ASSERT_VALID_PTR(port
->mp_SigTask
);
95 /* And trigger the action. */
96 switch(port
->mp_Flags
& PF_ACTION
)
100 Signal((struct Task
*)port
->mp_SigTask
,1<<port
->mp_SigBit
);
104 /* Raise a software interrupt */
105 Cause((struct Interrupt
*)port
->mp_SoftInt
);
113 /* Call the function in mp_SigTask. */
114 AROS_UFC2(void, port
->mp_SigTask
,
115 AROS_UFCA(struct MsgPort
*, port
, D0
),
116 AROS_UFCA(struct ExecBase
*, SysBase
, A6
));