2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
6 #include <devices/timer.h>
7 #include <exec/execbase.h>
9 #include <proto/exec.h>
10 #include <proto/timer.h>
14 int __nocommandline
= 1;
19 struct timerequest
*req
;
21 printf("exec.library v%u.%u\n", SysBase
->LibNode
.lib_Version
, SysBase
->LibNode
.lib_Revision
);
22 printf("VBlank frequency: %u\n", SysBase
->VBlankFrequency
);
23 printf("PSU frequency: %u\n", SysBase
->PowerSupplyFrequency
);
24 printf("EClock frequency: %u\n\n", (unsigned int)SysBase
->ex_EClockFrequency
);
28 req
= (struct timerequest
*)CreateIORequest(mp
, sizeof(struct timerequest
));
30 if (!OpenDevice("timer.device", UNIT_VBLANK
, &req
->tr_node
, 0))
32 struct Device
*TimerBase
= req
->tr_node
.io_Device
;
33 struct EClockVal clock
, oclock
;
34 struct timeval tv
, otv
;
37 printf("timer.device v%u.%u\n", TimerBase
->dd_Library
.lib_Version
, TimerBase
->dd_Library
.lib_Revision
);
38 printf("EClock frequency reported: %u\n\n", (unsigned int)ReadEClock(&clock
));
41 seconds
= tv
.tv_secs
+ 10;
42 while (!(SetSignal(0, SIGBREAKF_CTRL_C
) & SIGBREAKF_CTRL_C
) && tv
.tv_secs
< seconds
) {
43 oclock
.ev_hi
= clock
.ev_hi
;
44 oclock
.ev_lo
= clock
.ev_lo
;
45 otv
.tv_secs
= tv
.tv_secs
;
46 otv
.tv_micro
= tv
.tv_micro
;
49 if (oclock
.ev_hi
> clock
.ev_hi
|| (oclock
.ev_hi
== clock
.ev_hi
&& oclock
.ev_lo
> clock
.ev_lo
)) {
50 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
);
53 if (otv
.tv_secs
> tv
.tv_secs
|| (otv
.tv_secs
== tv
.tv_secs
&& otv
.tv_micro
>= tv
.tv_micro
) || tv
.tv_micro
>= 1000000) {
54 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
);
57 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
);
61 CloseDevice(&req
->tr_node
);
64 printf("Failed to open timer.device!\n");
68 printf("Failed to create IORequest!\n");
72 printf("Failed to create message port!\n");