only bring in as many sdl things as are strictly necessary
[tangerine.git] / arch / all-mingw32 / timer / timer_init.c
blobb416fe495da4bc0974458ba7ffc95881e613cab6
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 static int GM_UNIQUENAME(Init)(LIBBASETYPEPTR LIBBASE)
43 /* Setup the timer.device data */
44 LIBBASE->tb_CurrentTime.tv_secs = 0;
45 LIBBASE->tb_CurrentTime.tv_micro = 0;
46 LIBBASE->tb_VBlankTime.tv_secs = 0;
47 LIBBASE->tb_VBlankTime.tv_micro = 1000000 / (SysBase->VBlankFrequency);
48 LIBBASE->tb_Elapsed.tv_secs = 0;
49 LIBBASE->tb_Elapsed.tv_micro = 0;
51 D(kprintf("Timer period: %ld secs, %ld micros\n",
52 LIBBASE->tb_VBlankTime.tv_secs, LIBBASE->tb_VBlankTime.tv_micro));
54 LIBBASE->tb_MiscFlags = TF_GO;
56 /* Initialise the lists */
57 NEWLIST( &LIBBASE->tb_Lists[0] );
58 NEWLIST( &LIBBASE->tb_Lists[1] );
59 NEWLIST( &LIBBASE->tb_Lists[2] );
60 NEWLIST( &LIBBASE->tb_Lists[3] );
61 NEWLIST( &LIBBASE->tb_Lists[4] );
63 /* Start up the interrupt server. This is shared between us and the
64 HIDD that deals with the vblank */
65 LIBBASE->tb_VBlankInt.is_Node.ln_Pri = 0;
66 LIBBASE->tb_VBlankInt.is_Node.ln_Type = NT_INTERRUPT;
67 LIBBASE->tb_VBlankInt.is_Node.ln_Name = (STRPTR)MOD_NAME_STRING;
68 LIBBASE->tb_VBlankInt.is_Code = (APTR)&VBlankInt;
69 LIBBASE->tb_VBlankInt.is_Data = LIBBASE;
71 AddIntServer(INTB_VERTB, &LIBBASE->tb_VBlankInt);
73 return TRUE;
76 /****************************************************************************************/
78 static int GM_UNIQUENAME(Open)
80 LIBBASETYPEPTR LIBBASE,
81 struct timerequest *tr,
82 ULONG unitNum,
83 ULONG flags
87 Normally, we should check the length of the message and other
88 such things, however the RKM documents an example where the
89 length of the timerrequest isn't set, so we must not check
90 this.
92 This fixes bug SF# 741580
95 switch(unitNum)
97 case UNIT_VBLANK:
98 case UNIT_MICROHZ:
99 case UNIT_WAITUNTIL:
100 tr->tr_node.io_Error = 0;
101 tr->tr_node.io_Unit = (struct Unit *)unitNum;
102 tr->tr_node.io_Device = (struct Device *)LIBBASE;
103 break;
105 case UNIT_ECLOCK:
106 case UNIT_WAITECLOCK:
107 default:
108 tr->tr_node.io_Error = IOERR_OPENFAIL;
111 return TRUE;
114 /****************************************************************************************/
116 static int GM_UNIQUENAME(Expunge)(LIBBASETYPEPTR LIBBASE)
118 RemIntServer(INTB_VERTB, &LIBBASE->tb_VBlankInt);
119 return TRUE;
122 /****************************************************************************************/
124 ADD2INITLIB(GM_UNIQUENAME(Init), 0)
125 ADD2OPENDEV(GM_UNIQUENAME(Open), 0)
126 ADD2EXPUNGELIB(GM_UNIQUENAME(Expunge), 0)