1 #include <devices/timer.h>
2 #include <exec/execbase.h>
4 #include <proto/exec.h>
5 #include <proto/timer.h>
9 int __nocommandline
= 1;
14 struct timerequest
*req
;
16 printf("exec.library v%u.%u\n", SysBase
->LibNode
.lib_Version
, SysBase
->LibNode
.lib_Revision
);
17 printf("VBlank frequency: %u\n", SysBase
->VBlankFrequency
);
18 printf("PSU frequency: %u\n", SysBase
->PowerSupplyFrequency
);
19 printf("EClock frequency: %u\n\n", (unsigned int)SysBase
->ex_EClockFrequency
);
23 req
= (struct timerequest
*)CreateIORequest(mp
, sizeof(struct timerequest
));
25 if (!OpenDevice("timer.device", UNIT_VBLANK
, &req
->tr_node
, 0))
27 struct Device
*TimerBase
= req
->tr_node
.io_Device
;
28 struct EClockVal clock
, oclock
;
29 struct timeval tv
, otv
;
32 printf("timer.device v%u.%u\n", TimerBase
->dd_Library
.lib_Version
, TimerBase
->dd_Library
.lib_Revision
);
33 printf("EClock frequency reported: %u\n\n", (unsigned int)ReadEClock(&clock
));
36 seconds
= tv
.tv_secs
+ 10;
37 while (!(SetSignal(0, SIGBREAKF_CTRL_C
) & SIGBREAKF_CTRL_C
) && tv
.tv_secs
< seconds
) {
38 oclock
.ev_hi
= clock
.ev_hi
;
39 oclock
.ev_lo
= clock
.ev_lo
;
40 otv
.tv_secs
= tv
.tv_secs
;
41 otv
.tv_micro
= tv
.tv_micro
;
44 if (oclock
.ev_hi
> clock
.ev_hi
|| (oclock
.ev_hi
== clock
.ev_hi
&& oclock
.ev_lo
> clock
.ev_lo
)) {
45 printf("\n\nFAIL: EClock old: %08x.%08x new: %08x.%08x\n", (unsigned int)oclock
.ev_hi
, (unsigned int)oclock
.ev_lo
, (unsigned int)clock
.ev_hi
, (unsigned int)clock
.ev_lo
);
48 if (otv
.tv_secs
> tv
.tv_secs
|| (otv
.tv_secs
== tv
.tv_secs
&& otv
.tv_micro
>= tv
.tv_micro
) || tv
.tv_micro
>= 1000000) {
49 printf("\n\nFAIL: SysTime old: %u.%06u new: %u.%06u\n", (unsigned int)otv
.tv_secs
, (unsigned int)otv
.tv_micro
, (unsigned int)tv
.tv_secs
, (unsigned int)tv
.tv_micro
);
52 printf("%08x.%08x %u.%06u\r", (unsigned int)clock
.ev_hi
, (unsigned int)clock
.ev_lo
, (unsigned int)tv
.tv_secs
, (unsigned int)tv
.tv_micro
);
56 CloseDevice(&req
->tr_node
);
59 printf("Failed to open timer.device!\n");
63 printf("Failed to create IORequest!\n");
67 printf("Failed to create message port!\n");