Updated PCI IDs to latest snapshot.
[tangerine.git] / arch / ppc-sam440 / exec / wait.c
blob5ab60ac377d1bbc75e8458898eb529c41faf1e2f
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Wait for some signal.
6 Lang: english
7 */
8 #include <exec/execbase.h>
9 #include <aros/libcall.h>
10 #include <proto/exec.h>
11 #include <proto/kernel.h>
13 #include "../kernel/kernel_intern.h"
15 /*****************************************************************************
17 NAME */
19 AROS_LH1(ULONG, Wait,
21 /* SYNOPSIS */
22 AROS_LHA(ULONG, signalSet, D0),
24 /* LOCATION */
25 struct ExecBase *, SysBase, 53, Exec)
27 /* FUNCTION
28 Wait until some signals are sent to the current task. If any signal
29 of the specified set is already set when entering this function it
30 returns immediately. Since almost any event in the OS can send a
31 signal to your task if you specify it to do so signals are a very
32 powerful mechanism.
34 INPUTS
35 signalSet - The set of signals to wait for.
37 RESULT
38 The set of active signals.
40 NOTES
41 Naturally it's not allowed to wait in supervisor mode.
43 Calling Wait() breaks an active Disable() or Forbid().
45 EXAMPLE
47 BUGS
49 SEE ALSO
50 Signal(), SetSignal(), AllocSignal(), FreeSignal()
52 INTERNALS
54 HISTORY
56 ******************************************************************************/
58 AROS_LIBFUNC_INIT
60 ULONG rcvd;
61 struct Task *me;
62 void *KernelBase = getKernelBase();
64 /* Get pointer to current task - I'll need it very often */
65 me = FindTask (NULL);
67 /* Protect the task lists against access by other tasks. */
68 Disable();
70 /* If at least one of the signals is already set do not wait. */
71 while(!(me->tc_SigRecvd&signalSet))
73 BYTE old_TDNestCnt;
75 /* Set the wait signal mask */
76 me->tc_SigWait=signalSet;
79 Clear TDNestCnt (because Switch() will not care about it),
80 but memorize it first. IDNestCnt is handled by Switch().
81 This could as well be stored in a local variable which makes
82 the tc_TDNestCnt field somehow redundant.
84 old_TDNestCnt=SysBase->TDNestCnt;
85 SysBase->TDNestCnt=-1;
87 /* Move current task to the waiting list. */
88 me->tc_State=TS_WAIT;
91 remove it from what!?
92 sheutlin
94 // me->tc_Node.ln_Pred->ln_Succ = me->tc_Node.ln_Succ;
95 // me->tc_Node.ln_Succ->ln_Pred = me->tc_Node.ln_Pred;
97 Enqueue(&SysBase->TaskWait,&me->tc_Node);
99 /* And switch to the next ready task. */
100 KrnSwitch();
102 // Reschedule(me);
105 OK. Somebody awakened me. This means that either the
106 signals are there or it's just a finished task exception.
107 Test again to be sure (see above).
110 /* Restore TDNestCnt. */
111 SysBase->TDNestCnt=old_TDNestCnt;
113 /* Get active signals. */
114 rcvd=me->tc_SigRecvd&signalSet;
116 /* And clear them. */
117 me->tc_SigRecvd&=~signalSet;
119 /* All done. */
120 Enable();
122 return rcvd;
123 AROS_LIBFUNC_EXIT