9 #include <exec/types.h> 10 #include <exec/ports.h> 11 #include <proto/exec.h> 12 #include <proto/dos.h> 13 #include <devices/timer.h> 19 struct Library *TimerBase = NULL;
20 struct MsgPort *timer_port = NULL;
21 struct timerequest *timer_io = NULL;
22 BYTE time_r_error = 0;
24 BOOL init_timer_device(
void)
27 printf(
"init_timer_device()\n");
29 timer_port = CreatePort(NULL, 0);
33 printf(
"could not create message port\n");
37 timer_io = (
struct timerequest *)CreateExtIO(timer_port,
38 sizeof(
struct timerequest));
42 printf(
"could not create create timerequest object\n");
44 DeletePort(timer_port);
47 time_r_error = OpenDevice(TIMERNAME, UNIT_MICROHZ,
48 (
struct IORequest *)timer_io, 0);
50 TimerBase = (
struct Library *)timer_io->tr_node.io_Device;
53 printf(
"could not open timer.device\n");
57 void timer_device_get_system_time(
struct timeval *time_val)
59 timer_io->tr_node.io_Command = TR_GETSYSTIME;
60 DoIO((
struct IORequest *) timer_io);
61 time_val->tv_secs = timer_io->tr_time.tv_secs;
62 time_val->tv_micro = timer_io->tr_time.tv_micro;
65 void uninit_timer_device(
void)
68 printf(
"uninit_timer_device()\n");
70 if (!CheckIO((
struct IORequest *)timer_io))
71 AbortIO((
struct IORequest *)timer_io);
73 WaitIO((
struct IORequest *)timer_io);
77 CloseDevice((
struct IORequest *)timer_io);
79 DeleteExtIO((
struct IORequest *)timer_io);
81 DeletePort(timer_port);