tools/adflib: build only host variant which is used by Sam440 target
[AROS.git] / rom / exec / putmsg.c
blob1eafa88f3d0f4e1016dc90d9ac870afbd95be90d
1 /*
2 Copyright © 1995-2015, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Send a message to a port.
6 Lang: english
7 */
9 #include <aros/debug.h>
10 #include <aros/libcall.h>
11 #include <exec/ports.h>
12 #include <proto/exec.h>
14 #include "exec_intern.h"
15 #include "exec_util.h"
17 /*****************************************************************************
19 NAME */
21 AROS_LH2(void, PutMsg,
23 /* SYNOPSIS */
24 AROS_LHA(struct MsgPort *, port, A0),
25 AROS_LHA(struct Message *, message, A1),
27 /* LOCATION */
28 struct ExecBase *, SysBase, 61, Exec)
30 /* FUNCTION
31 Sends a message to a given message port. Messages are not copied
32 from one task to another but must lie in shared memory instead.
33 Therefore the owner of the message may generally not reuse it before
34 it is returned. But this depends on the two tasks sharing the message.
36 INPUTS
37 port - Pointer to messageport.
38 message - Pointer to message.
40 RESULT
42 NOTES
43 It is legal to send a message from within interrupts.
45 Messages may either trigger a signal at the owner of the messageport
46 or raise a software interrupt, depending on port->mp_Flags&PF_ACTION.
48 EXAMPLE
50 BUGS
52 SEE ALSO
53 WaitPort(), GetMsg()
55 INTERNALS
57 ******************************************************************************/
59 AROS_LIBFUNC_INIT
60 ASSERT_VALID_PTR(message);
61 ASSERT_VALID_PTR(port);
63 /* Set the node type to NT_MESSAGE == sent message. */
64 message->mn_Node.ln_Type = NT_MESSAGE;
66 InternalPutMsg(port, message, SysBase);
68 AROS_LIBFUNC_EXIT
69 } /* PutMsg() */
71 void InternalPutMsg(struct MsgPort *port, struct Message *message, struct ExecBase *SysBase)
73 /* Add it to the message list. Messages may be sent from interrupts.
74 Therefore the message list of the message port must be protected with
75 Disable() */
76 Disable();
77 AddTail(&port->mp_MsgList, &message->mn_Node);
78 Enable();
80 if (port->mp_SigTask)
82 ASSERT_VALID_PTR(port->mp_SigTask);
84 /* And trigger the action. */
85 switch(port->mp_Flags & PF_ACTION)
87 case PA_SIGNAL:
88 D(bug("[EXEC] PutMsg: PA_SIGNAL, task 0x%p, signal %08x\n", port->mp_SigTask, (1 << port->mp_SigBit));)
90 /* Send the signal */
91 Signal((struct Task *)port->mp_SigTask, (1 << port->mp_SigBit));
92 break;
94 case PA_SOFTINT:
95 D(bug("[EXEC] PutMsg: PA_SOFTINT, port 0x%p, msg 0x%p, int %s\n", port, message, ((struct Interrupt *)port->mp_SoftInt)->is_Node.ln_Name);)
97 /* Raise a software interrupt */
98 Cause((struct Interrupt *)port->mp_SoftInt);
99 break;
101 case PA_IGNORE:
102 /* Do nothing. */
103 break;
105 case PA_CALL:
106 D(bug("[EXEC] PutMsg: PA_CALL, task 0x%p, port 0x%p\n", port->mp_SigTask, port);)
108 /* Call the function in mp_SigTask. */
109 AROS_UFC2NR(void, port->mp_SigTask,
110 AROS_UFCA(struct MsgPort *, port, D0),
111 AROS_UFCA(struct ExecBase *, SysBase, A6));
112 break;