refactored some code. compiles now without suppresing any warning with gcc-6.3.0.
[AROS.git] / rom / timer / timer_intern.h
blobdda8677185d25a4f8fdfcde99e96798af60f1e25
1 #ifndef _TIMER_INTERN_H
2 #define _TIMER_INTERN_H
4 /*
5 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
6 $Id$
8 Desc: Internal information about the timer.device and HIDD's
9 Lang: english
12 #include <aros/config.h>
14 #include <exec/execbase.h>
15 #include <exec/lists.h>
16 #include <exec/interrupts.h>
17 #include <exec/io.h>
18 #include <exec/devices.h>
19 #include <exec/interrupts.h>
20 #include <devices/timer.h>
21 #include <dos/bptr.h>
22 #include <hardware/intbits.h>
23 #include <aros/asmcall.h>
25 /* Platform-specific portion */
26 #include <timer_platform.h>
28 #if defined(__AROSEXEC_SMP__)
29 #include <aros/types/spinlock_s.h>
30 #endif
33 * First two of these correspond to UNIT_MICROHZ and UNIT_VBLANK.
34 * This is important.
36 #define TL_MICROHZ 0
37 #define TL_VBLANK 1
38 #define TL_WAITVBL 2
39 #define NUM_LISTS 3
41 struct TimerBase
43 /* Required by the system */
44 struct Device tb_Device; /* Our base */
45 APTR tb_KernelBase; /* kernel.resource base */
47 /* Time counters */
48 struct timeval tb_CurrentTime; /* Absolute system time. Can be set by TR_SETSYSTIME. */
49 struct timeval tb_Elapsed; /* Relative system time. Used for measuring intervals. */
51 /* This is required for hardware-specific code */
52 APTR tb_TimerIRQHandle; /* Timer IRQ handle */
53 struct Interrupt tb_VBlankInt; /* Used by older implementations, needs to be removed */
55 /* Request queues */
56 struct MinList tb_Lists[NUM_LISTS];
58 /* EClock counter */
59 UQUAD tb_ticks_total; /* Effective EClock value */
60 ULONG tb_ticks_sec; /* Fraction of second for CurrentTime in ticks */
61 ULONG tb_ticks_elapsed; /* Fraction of second for Elapsed in ticks */
62 ULONG tb_prev_tick; /* Hardware-specific */
63 ULONG tb_eclock_rate; /* EClock frequency */
65 #ifdef USE_VBLANK_EMU
66 struct timerequest tb_vblank_timerequest; /* VBlank emulation request */
67 #endif
69 struct PlatformTimer tb_Platform; /* Platform-specific data */
70 #if defined(__AROSEXEC_SMP__)
71 void *tb_ExecLockBase;
72 void *tb_ListLock;
73 #endif
76 #define GetTimerBase(tb) ((struct TimerBase *)(tb))
77 #define GetDevice(tb) ((struct Device *)(tb))
79 BOOL common_BeginIO(struct timerequest *timereq, struct TimerBase *TimerBase);
80 void TimerProcessMicroHZ(struct TimerBase *TimerBase, struct ExecBase *SysBase, BOOL locked);
81 void TimerProcessVBlank(struct TimerBase *TimerBase, struct ExecBase *SysBase, BOOL locked);
82 #define handleMicroHZ(x,y) TimerProcessMicroHZ(x,y,FALSE)
83 #define handleVBlank(x,y) TimerProcessVBlank(x,y,FALSE)
84 void EClockUpdate(struct TimerBase *TimerBase);
85 void EClockSet(struct TimerBase *TimerBase);
87 /* Call exec VBlank vector, if present */
88 static inline void vblank_Cause(struct ExecBase *SysBase)
90 struct IntVector *iv = &SysBase->IntVects[INTB_VERTB];
92 if (iv->iv_Code)
93 AROS_INTC2(iv->iv_Code, iv->iv_Data, INTF_VERTB);
96 #endif /* _TIMER_INTERN_H */