2 Copyright © 2015-2016, The AROS Development Team. All rights reserved.
5 Desc: timer implementation.
12 #include <aros/debug.h>
14 #include <proto/dos.h>
15 #include <proto/exec.h>
17 #include <exec/interrupts.h>
18 #include <hardware/intbits.h>
20 #include "realtime_intern.h"
24 /* RealTime timer interrupt -- currently only a VBlank interrupt */
25 static AROS_INTH1(rtVBlank
, struct internal_RealTimeBase
*, RealTimeBase
)
29 // kprintf("Signalling task %p\n", RealTimeBase->rtb_PulseTask);
30 Signal(RealTimeBase
->rtb_PulseTask
, SIGF_SINGLE
);
38 BOOL
AllocTimer(struct internal_RealTimeBase
*RealTimeBase
)
40 RealTimeBase
->rtb_TickErr
= 0; /* How may such a thing be measured? */
41 RealTimeBase
->rtb_Reserved1
= 60; /* NB: rtb_Reserved1 contains the TICK_FREQ,
42 * which in our case is vblank (60) */
44 /* I use a process here just to be able to use CreateNewProc() so
45 I don't have to fiddle with stack order and such... */
47 struct TagItem tags
[] = { { NP_Entry
, (IPTR
)Pulse
},
48 { NP_Name
, (IPTR
)"RealTime Pulse" },
49 { NP_Priority
, (IPTR
)127 },
50 { NP_UserData
, (IPTR
)RealTimeBase
},
51 { TAG_DONE
, (IPTR
)NULL
} };
53 RealTimeBase
->rtb_PulseTask
= (struct Task
*)CreateNewProc(tags
);
56 if (RealTimeBase
->rtb_PulseTask
== NULL
)
61 D(bug("[realtime.library] pulse task created @ 0x%p\n", GPB(RealTimeBase
)->rtb_PulseTask
));
64 /* This should be replaced by some timer.device thing when an accurate
65 timer is available -- UNIT_MICROHZ? */
67 RealTimeBase
->rtb_VBlank
.is_Code
= (APTR
)&rtVBlank
;
68 RealTimeBase
->rtb_VBlank
.is_Data
= (APTR
)RealTimeBase
;
69 RealTimeBase
->rtb_VBlank
.is_Node
.ln_Name
= "RealTime VBlank server";
70 RealTimeBase
->rtb_VBlank
.is_Node
.ln_Pri
= 127;
71 RealTimeBase
->rtb_VBlank
.is_Node
.ln_Type
= NT_INTERRUPT
;
73 /* Add a VBLANK server to take care of the heartbeats. */
74 AddIntServer(INTB_VERTB
, &RealTimeBase
->rtb_VBlank
);
80 void FreeTimer(struct internal_RealTimeBase
*RealTimeBase
)
82 RemIntServer(INTB_VERTB
, &RealTimeBase
->rtb_VBlank
);
84 if (RealTimeBase
->rtb_PulseTask
)
85 Signal(RealTimeBase
->rtb_PulseTask
, SIGBREAKF_CTRL_C
);