Updated PCI IDs to latest snapshot.
[tangerine.git] / arch / x86_64-pc / timer / timervblank.c
blobc027a01bf27fac6ebf5a0f394985fb78986f84a3
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 <aros/debug.h>
9 #include <exec/types.h>
10 #include <exec/execbase.h>
11 #include <hardware/intbits.h>
12 #include <proto/exec.h>
13 #include <proto/timer.h>
14 #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 *);
33 AROS_UFH4(ULONG, VBlankInt,
34 AROS_UFHA(ULONG, dummy, A0),
35 AROS_UFHA(struct TimerBase *, TimerBase, A1),
36 AROS_UFHA(ULONG, dummy2, A5),
37 AROS_UFHA(struct ExecBase *, SysBase, A6)
40 AROS_USERFUNC_INIT
42 void VBlankInt(struct TimerBase *TimerBase, struct ExecBase *SysBase)
44 struct timerequest *tr, *next;
46 EClockUpdate(TimerBase);
49 Go through the "wait for x seconds" list and return requests
50 that have completed. A completed request is one whose time
51 is less than that of the elapsed time.
53 ForeachNodeSafe(&TimerBase->tb_Lists[TL_VBLANK], tr, next)
55 if(CmpTime(&TimerBase->tb_Elapsed, &tr->tr_time) <= 0)
57 if (tr == &TimerBase->tb_vblank_timerequest)
59 struct IntVector *iv = &SysBase->IntVects[INTB_VERTB];
61 /* VBlank Emu */
63 if (iv->iv_Code)
65 AROS_UFC5(void, iv->iv_Code,
66 AROS_UFCA(ULONG, 0, D1),
67 AROS_UFCA(ULONG, 0, A0),
68 AROS_UFCA(APTR, iv->iv_Data, A1),
69 AROS_UFCA(APTR, iv->iv_Code, A5),
70 AROS_UFCA(struct ExecBase *, SysBase, A6)
74 /* Decrease SysBase->Elapsed */
75 if (SysBase->Elapsed == 0)
77 SysBase->SysFlags |= 0x2000;
78 SysBase->AttnResched |= 0x80;
80 else SysBase->Elapsed--;
82 /* Automatically requeue/reactivate request */
84 Remove((struct Node *)tr);
85 tr->tr_node.io_Command = TR_ADDREQUEST;
86 tr->tr_time.tv_secs = 0;
87 tr->tr_time.tv_micro = 1000000 / SysBase->VBlankFrequency;
88 AddTime(&tr->tr_time, &TimerBase->tb_Elapsed);
90 timer_addToWaitList(TimerBase, &TimerBase->tb_Lists[TL_VBLANK], tr);
93 else
95 /* This request has finished */
96 Remove((struct Node *)tr);
97 tr->tr_time.tv_secs = tr->tr_time.tv_micro = 0;
98 tr->tr_node.io_Error = 0;
99 ReplyMsg((struct Message *)tr);
102 else
105 The first request hasn't finished, as all requests are in
106 order, we don't bother searching through the remaining
108 break;
113 The other this is the "wait until a specified time". Here a request
114 is complete if the time we are waiting for is before the current time.
116 ForeachNodeSafe(&TimerBase->tb_Lists[TL_WAITVBL], tr, next)
118 if(CmpTime(&TimerBase->tb_CurrentTime, &tr->tr_time) <= 0)
120 /* This request has finished */
121 Remove((struct Node *)tr);
122 tr->tr_time.tv_secs = tr->tr_time.tv_micro = 0;
123 tr->tr_node.io_Error = 0;
124 ReplyMsg((struct Message *)tr);
126 else
129 The first request hasn't finished, as all requests are in
130 order, we don't bother searching through the remaining
132 break;
136 Timer0Setup(TimerBase);
138 /* return 0;
139 AROS_USERFUNC_EXIT */