Copyright clean-up (part 1):
[AROS.git] / workbench / system / SysMon / timer.c
blob8c804965a1c5ecb34fb12733d4a7add8c40fd53c
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include "sysmon_intern.h"
8 #include <devices/timer.h>
9 #include <clib/alib_protos.h>
11 /* Timer information */
12 static struct MsgPort * timerport = NULL;
13 static struct timerequest * timermsg = NULL;
14 static ULONG SIG_TIMER = 0;
16 /* Timer functions */
17 static BOOL InitTimer(struct SysMonData *smdata)
19 if((timerport = CreatePort(0,0)) == NULL)
20 return FALSE;
22 if((timermsg = (struct timerequest *) CreateExtIO(timerport, sizeof(struct timerequest))) == NULL)
24 DeletePort(timerport);
25 timerport = NULL;
26 return FALSE;
29 if(OpenDevice("timer.device", UNIT_VBLANK, ((struct IORequest *) timermsg), 0) != 0)
31 DeletePort(timerport);
32 timerport = NULL;
33 DeleteExtIO((struct IORequest *)timermsg);
34 timermsg = NULL;
35 return FALSE;
38 SIG_TIMER = 1 << timerport->mp_SigBit;
40 return TRUE;
43 VOID SignalMeAfter(ULONG msecs)
45 timermsg->tr_node.io_Command = TR_ADDREQUEST;
46 timermsg->tr_time.tv_secs = msecs / 1000;
47 timermsg->tr_time.tv_micro = (msecs % 1000) * 1000;
48 SendIO((struct IORequest *)timermsg);
51 static VOID DeInitTimer(struct SysMonData *smdata)
53 if (timermsg != NULL)
55 AbortIO((struct IORequest *)timermsg);
56 WaitIO((struct IORequest *)timermsg);
57 CloseDevice((struct IORequest *)timermsg);
58 DeleteExtIO((struct IORequest *)timermsg);
61 if(timerport != NULL) DeletePort(timerport);
64 ULONG GetSIG_TIMER()
66 return SIG_TIMER;
69 struct SysMonModule timermodule =
71 .Init = InitTimer,
72 .DeInit = DeInitTimer,