Restored work-around for hangs when trying to use disk-based handlers
[tangerine.git] / arch / i386-pc / timer / timervblank.c
blobb60e7e31d6fde19cc3ba4fbcb6e0dd9860eb62c0
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: VBlank server for the timer.device/timer.hidd
6 Lang: english
7 */
8 #include <exec/types.h>
9 #include <exec/execbase.h>
10 #include <hardware/intbits.h>
11 #include <proto/exec.h>
12 #include <proto/timer.h>
13 #include <aros/debug.h>
15 #include "ticks.h"
16 #undef SysBase
19 This is a slightly faster version of AddTime() that we use here. It
20 also saves the function call overhead...
22 #define FastAddTime(d, s)\
23 (d)->tv_micro += (s)->tv_micro;\
24 (d)->tv_secs += (s)->tv_secs;\
25 if((d)->tv_micro > 999999) {\
26 (d)->tv_secs++;\
27 (d)->tv_micro -= 1000000;\
30 BOOL timer_addToWaitList(struct TimerBase *, struct MinList *, struct timerequest *);
32 AROS_UFH4(ULONG, VBlankInt,
33 AROS_UFHA(ULONG, dummy, A0),
34 AROS_UFHA(struct TimerBase *, TimerBase, A1),
35 AROS_UFHA(ULONG, dummy2, A5),
36 AROS_UFHA(struct ExecBase *, SysBase, A6)
39 AROS_USERFUNC_INIT
41 struct timerequest *tr, *next;
43 EClockUpdate(TimerBase);
46 Go through the "wait for x seconds" list and return requests
47 that have completed. A completed request is one whose time
48 is less than that of the elapsed time.
50 ForeachNodeSafe(&TimerBase->tb_Lists[TL_VBLANK], tr, next)
52 if(CmpTime(&TimerBase->tb_Elapsed, &tr->tr_time) <= 0)
54 if (tr == &TimerBase->tb_vblank_timerequest)
56 struct IntVector *iv = &SysBase->IntVects[INTB_VERTB];
58 /* VBlank Emu */
60 if (iv->iv_Code)
62 AROS_UFC5(void, iv->iv_Code,
63 AROS_UFCA(ULONG, 0, D1),
64 AROS_UFCA(ULONG, 0, A0),
65 AROS_UFCA(APTR, iv->iv_Data, A1),
66 AROS_UFCA(APTR, iv->iv_Code, A5),
67 AROS_UFCA(struct ExecBase *, SysBase, A6)
71 /* Automatically requeue/reactivate request */
73 Remove((struct Node *)tr);
74 tr->tr_node.io_Command = TR_ADDREQUEST;
75 tr->tr_time.tv_secs = 0;
76 tr->tr_time.tv_micro = 1000000 / SysBase->VBlankFrequency;
77 AddTime(&tr->tr_time, &TimerBase->tb_Elapsed);
79 timer_addToWaitList(TimerBase, &TimerBase->tb_Lists[TL_VBLANK], tr);
82 else
84 /* This request has finished */
85 Remove((struct Node *)tr);
86 tr->tr_time.tv_secs = tr->tr_time.tv_micro = 0;
87 tr->tr_node.io_Error = 0;
88 ReplyMsg((struct Message *)tr);
91 else
94 The first request hasn't finished, as all requests are in
95 order, we don't bother searching through the remaining
97 break;
102 The other this is the "wait until a specified time". Here a request
103 is complete if the time we are waiting for is before the current time.
105 ForeachNodeSafe(&TimerBase->tb_Lists[TL_WAITVBL], tr, next)
107 if(CmpTime(&TimerBase->tb_CurrentTime, &tr->tr_time) <= 0)
109 /* This request has finished */
110 Remove((struct Node *)tr);
111 tr->tr_time.tv_secs = tr->tr_time.tv_micro = 0;
112 tr->tr_node.io_Error = 0;
113 ReplyMsg((struct Message *)tr);
115 else
118 The first request hasn't finished, as all requests are in
119 order, we don't bother searching through the remaining
121 break;
125 Timer0Setup(TimerBase);
127 return 0;
128 AROS_USERFUNC_EXIT