39df262a578e01bf890a581ec6a5b19b844953bb
[AROS.git] / arch / m68k-amiga / timer / abortio.c
blob39df262a578e01bf890a581ec6a5b19b844953bb
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/timer.h>
19 AROS_LH1(LONG, AbortIO,
21 /* SYNOPSIS */
22 AROS_LHA(struct timerequest *, timereq, A1),
24 /* LOCATION */
25 struct TimerBase *, TimerBase, 6,Timer)
27 /* FUNCTION
28 Abort a running timer.device request.
30 INPUTS
31 timereq - The request you wish to abort.
33 RESULT
34 0 if the request was aborted, io_Error will also be set
35 to the value IOERR_ABORTED.
37 -1 otherwise (most likely that the request isn't working).
39 If the request is successfully aborted, you should WaitIO() on
40 the message before you try and reuse it.
42 NOTES
43 This function may be called from interrupts.
45 EXAMPLE
47 BUGS
49 SEE ALSO
50 exec/AbortIO(), exec/WaitIO()
52 INTERNALS
54 HISTORY
55 18-02-1997 iaint Implemented.
57 ******************************************************************************/
59 AROS_LIBFUNC_INIT
61 LONG ret = -1;
64 As the timer.device runs as an interrupt, we had better protect
65 the "waiting timers" list from being corrupted.
68 Disable();
69 if(timereq->tr_node.io_Message.mn_Node.ln_Type != NT_REPLYMSG)
71 ULONG unit = (ULONG)timereq->tr_node.io_Unit;
72 timereq->tr_node.io_Error = IOERR_ABORTED;
73 Remove((struct Node *)timereq);
74 if (unit == UNIT_WAITUNTIL || unit == UNIT_VBLANK) {
75 if (IsListEmpty(&TimerBase->tb_Lists[UNIT_VBLANK]))
76 TimerBase->tb_vblank_on = FALSE;
77 } else {
78 if (IsListEmpty(&TimerBase->tb_Lists[UNIT_MICROHZ]))
79 TimerBase->tb_micro_on = FALSE;
81 ReplyMsg((struct Message *)timereq);
82 ret = 0;
84 Enable();
87 return ret;
89 AROS_LIBFUNC_EXIT
90 } /* AbortIO */