2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: Timer startup and device commands
8 /****************************************************************************************/
10 #include <exec/types.h>
12 #include <exec/errors.h>
13 #include <exec/devices.h>
14 #include <exec/alerts.h>
15 #include <exec/initializers.h>
16 #include <devices/timer.h>
17 #include <hidd/timer.h>
18 #include <hardware/intbits.h>
20 #include <proto/exec.h>
21 #include <proto/timer.h>
23 #include <aros/symbolsets.h>
25 #include <aros/debug.h>
27 #include <proto/arossupport.h>
29 //#include "timer_intern.h"
30 #include LC_LIBDEFS_FILE
32 AROS_UFP4(ULONG
, VBlankInt
,
33 AROS_UFPA(ULONG
, dummy
, A0
),
34 AROS_UFPA(struct TimerBase
*, TimerBase
, A1
),
35 AROS_UFPA(ULONG
, dummy2
, A5
),
36 AROS_UFPA(struct ExecBase
*, SysBase
, A6
)
39 /****************************************************************************************/
41 AROS_SET_LIBFUNC(GM_UNIQUENAME(Init
), LIBBASETYPE
, LIBBASE
)
45 /* Setup the timer.device data */
46 LIBBASE
->tb_CurrentTime
.tv_secs
= 0;
47 LIBBASE
->tb_CurrentTime
.tv_micro
= 0;
48 LIBBASE
->tb_VBlankTime
.tv_secs
= 0;
49 LIBBASE
->tb_VBlankTime
.tv_micro
= 1000000 / SysBase
->VBlankFrequency
;
50 LIBBASE
->tb_Elapsed
.tv_secs
= 0;
51 LIBBASE
->tb_Elapsed
.tv_micro
= 0;
53 D(kprintf("Timer period: %ld secs, %ld micros\n",
54 LIBBASE
->tb_VBlankTime
.tv_secs
, LIBBASE
->tb_VBlankTime
.tv_micro
));
56 LIBBASE
->tb_MiscFlags
= TF_GO
;
58 /* Initialise the lists */
59 NEWLIST( &LIBBASE
->tb_Lists
[0] );
60 NEWLIST( &LIBBASE
->tb_Lists
[1] );
61 NEWLIST( &LIBBASE
->tb_Lists
[2] );
62 NEWLIST( &LIBBASE
->tb_Lists
[3] );
63 NEWLIST( &LIBBASE
->tb_Lists
[4] );
66 /* Open the boopsi.library */
67 LIBBASE
->tb_BOOPSIBase
= OpenLibrary("boopsi.library", 0);
68 if( BOOPSIBase
== NULL
)
70 /* timer.device couldn't open intuition.library (think about it!) */
71 Alert( AT_DeadEnd
| AG_OpenLib
| AO_Intuition
| AN_TimerDev
);
75 /* Start up the interrupt server. This is shared between us and the
76 HIDD that deals with the vblank */
77 LIBBASE
->tb_VBlankInt
.is_Node
.ln_Pri
= 0;
78 LIBBASE
->tb_VBlankInt
.is_Node
.ln_Type
= NT_INTERRUPT
;
79 LIBBASE
->tb_VBlankInt
.is_Node
.ln_Name
= (STRPTR
)MOD_NAME_STRING
;
80 LIBBASE
->tb_VBlankInt
.is_Code
= (APTR
)&VBlankInt
;
81 LIBBASE
->tb_VBlankInt
.is_Data
= LIBBASE
;
83 AddIntServer(INTB_VERTB
, &LIBBASE
->tb_VBlankInt
);
90 /****************************************************************************************/
92 AROS_SET_OPENDEVFUNC(GM_UNIQUENAME(Open
),
94 struct timerequest
, tr
,
101 Normally, we should check the length of the message and other
102 such things, however the RKM documents an example where the
103 length of the timerrequest isn't set, so we must not check
106 This fixes bug SF# 741580
113 tr
->tr_node
.io_Error
= 0;
114 tr
->tr_node
.io_Unit
= (struct Unit
*)unitNum
;
115 tr
->tr_node
.io_Device
= (struct Device
*)LIBBASE
;
120 case UNIT_WAITECLOCK
:
122 tr
->tr_node
.io_Error
= IOERR_OPENFAIL
;
127 AROS_SET_DEVFUNC_EXIT
130 /****************************************************************************************/
132 AROS_SET_LIBFUNC(GM_UNIQUENAME(Expunge
), LIBBASETYPE
, LIBBASE
)
134 AROS_SET_LIBFUNC_INIT
136 RemIntServer(INTB_VERTB
, &LIBBASE
->tb_VBlankInt
);
140 AROS_SET_LIBFUNC_EXIT
143 /****************************************************************************************/
145 ADD2INITLIB(GM_UNIQUENAME(Init
), 0)
146 ADD2OPENDEV(GM_UNIQUENAME(Open
), 0)
147 ADD2EXPUNGELIB(GM_UNIQUENAME(Expunge
), 0)