Fixed a warning (missing type cast)
[tangerine.git] / rom / timer / timer_init.c
blob6c815725ead1f011c68e1b53bebab1be5d82ebb1
1 /*
2 Copyright © 1995-2006, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Timer startup and device commands
6 */
8 /****************************************************************************************/
10 #include <exec/types.h>
11 #include <exec/io.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>
26 #undef kprintf
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)
43 AROS_SET_LIBFUNC_INIT
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 * SysBase->PowerSupplyFrequency);
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] );
65 /* Start up the interrupt server. This is shared between us and the
66 HIDD that deals with the vblank */
67 LIBBASE->tb_VBlankInt.is_Node.ln_Pri = 0;
68 LIBBASE->tb_VBlankInt.is_Node.ln_Type = NT_INTERRUPT;
69 LIBBASE->tb_VBlankInt.is_Node.ln_Name = (STRPTR)MOD_NAME_STRING;
70 LIBBASE->tb_VBlankInt.is_Code = (APTR)&VBlankInt;
71 LIBBASE->tb_VBlankInt.is_Data = LIBBASE;
73 AddIntServer(INTB_TIMERTICK, &LIBBASE->tb_VBlankInt);
75 return TRUE;
77 AROS_SET_LIBFUNC_EXIT
80 /****************************************************************************************/
82 AROS_SET_OPENDEVFUNC(GM_UNIQUENAME(Open),
83 LIBBASETYPE, LIBBASE,
84 struct timerequest, tr,
85 unitNum, flags
88 AROS_SET_DEVFUNC_INIT
91 Normally, we should check the length of the message and other
92 such things, however the RKM documents an example where the
93 length of the timerrequest isn't set, so we must not check
94 this.
96 This fixes bug SF# 741580
99 switch(unitNum)
101 case UNIT_VBLANK:
102 case UNIT_WAITUNTIL:
103 tr->tr_node.io_Error = 0;
104 tr->tr_node.io_Unit = (struct Unit *)unitNum;
105 tr->tr_node.io_Device = (struct Device *)LIBBASE;
106 break;
108 case UNIT_MICROHZ:
109 case UNIT_ECLOCK:
110 case UNIT_WAITECLOCK:
111 default:
112 tr->tr_node.io_Error = IOERR_OPENFAIL;
115 return TRUE;
117 AROS_SET_DEVFUNC_EXIT
120 /****************************************************************************************/
122 AROS_SET_LIBFUNC(GM_UNIQUENAME(Expunge), LIBBASETYPE, LIBBASE)
124 AROS_SET_LIBFUNC_INIT
126 RemIntServer(INTB_VERTB, &LIBBASE->tb_VBlankInt);
128 return TRUE;
130 AROS_SET_LIBFUNC_EXIT
133 /****************************************************************************************/
135 ADD2INITLIB(GM_UNIQUENAME(Init), 0)
136 ADD2OPENDEV(GM_UNIQUENAME(Open), 0)
137 ADD2EXPUNGELIB(GM_UNIQUENAME(Expunge), 0)