some fixes to accented characters
[tangerine.git] / rom / exec / putmsg.c
blob4c0555bdfc53c47860b3e332dc6215a563abe6d9
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Send a message to a port.
6 Lang: english
7 */
8 #include "exec_intern.h"
9 #include <aros/libcall.h>
10 #include <exec/ports.h>
11 #include <proto/exec.h>
13 /*****************************************************************************
15 NAME */
17 AROS_LH2(void, PutMsg,
19 /* SYNOPSIS */
20 AROS_LHA(struct MsgPort *, port, A0),
21 AROS_LHA(struct Message *, message, A1),
23 /* LOCATION */
24 struct ExecBase *, SysBase, 61, Exec)
26 /* FUNCTION
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.
32 INPUTS
33 port - Pointer to messageport.
34 message - Pointer to message.
36 RESULT
38 NOTES
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.
44 EXAMPLE
46 BUGS
48 SEE ALSO
49 WaitPort(), GetMsg()
51 INTERNALS
53 ******************************************************************************/
55 AROS_LIBFUNC_INIT
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)
64 return;
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));
76 return;
80 Messages may be sent from interrupts. Therefore the message list
81 of the message port must be protected with Disable().
83 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);
91 if(port->mp_SigTask)
93 ASSERT_VALID_PTR(port->mp_SigTask);
95 /* And trigger the action. */
96 switch(port->mp_Flags & PF_ACTION)
98 case PA_SIGNAL:
99 /* Send the signal */
100 Signal((struct Task *)port->mp_SigTask,1<<port->mp_SigBit);
101 break;
103 case PA_SOFTINT:
104 /* Raise a software interrupt */
105 Cause((struct Interrupt *)port->mp_SoftInt);
106 break;
108 case PA_IGNORE:
109 /* Do nothing. */
110 break;
112 case PA_CALL:
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));
117 break;
121 /* All done. */
122 Enable();
123 AROS_LIBFUNC_EXIT
124 } /* PutMsg() */