revert between 56095 -> 55830 in arch
[AROS.git] / rom / timer / abortio.c
blob631584e9d9959f54d58b2aa2a57fd4ddd94cc8e1
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: AbortIO() - abort a running timer request.
6 Lang: english
7 */
8 #include "timer_intern.h"
9 #include <exec/io.h>
10 #include <exec/errors.h>
12 /*****i***********************************************************************
14 NAME */
15 #include <devices/timer.h>
16 #include <proto/exec.h>
17 #include <proto/execlock.h>
18 #include <proto/timer.h>
20 AROS_LH1(LONG, AbortIO,
22 /* SYNOPSIS */
23 AROS_LHA(struct timerequest *, timereq, A1),
25 /* LOCATION */
26 struct TimerBase *, TimerBase, 6,Timer)
28 /* FUNCTION
29 Abort a running timer.device request.
31 INPUTS
32 timereq - The request you wish to abort.
34 RESULT
35 0 if the request was aborted, io_Error will also be set
36 to the value IOERR_ABORTED.
38 -1 otherwise (most likely that the request isn't working).
40 If the request is successfully aborted, you should WaitIO() on
41 the message before you try and reuse it.
43 NOTES
44 This function may be called from interrupts.
46 EXAMPLE
48 BUGS
50 SEE ALSO
51 exec/AbortIO(), exec/WaitIO()
53 INTERNALS
55 HISTORY
56 18-02-1997 iaint Implemented.
58 ******************************************************************************/
60 AROS_LIBFUNC_INIT
61 #if defined(__AROSEXEC_SMP__)
62 struct ExecLockBase *ExecLockBase = TimerBase->tb_ExecLockBase;
63 #endif
64 LONG ret = -1;
67 As the timer.device runs as an interrupt, we had better protect
68 the "waiting timers" list from being corrupted.
71 Disable();
72 #if defined(__AROSEXEC_SMP__)
73 if (ExecLockBase) ObtainLock(TimerBase->tb_ListLock, SPINLOCK_MODE_WRITE, 0);
74 #endif
75 if(timereq->tr_node.io_Message.mn_Node.ln_Type != NT_REPLYMSG)
77 Remove((struct Node *)timereq);
79 timereq->tr_node.io_Error = IOERR_ABORTED;
80 timereq->tr_time.tv_secs = 0;
81 timereq->tr_time.tv_micro = 0;
83 if (!(timereq->tr_node.io_Flags & IOF_QUICK))
84 ReplyMsg((struct Message *)timereq);
85 ret = 0;
87 #if defined(__AROSEXEC_SMP__)
88 if (ExecLockBase) ReleaseLock(TimerBase->tb_ListLock, 0);
89 #endif
90 Enable();
92 return ret;
94 AROS_LIBFUNC_EXIT
95 } /* AbortIO */