ReactOS  r75625
timer.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS HAL
3  * LICENSE: BSD - See COPYING.ARM in the top level directory
4  * FILE: hal/halarm/generic/timer.c
5  * PURPOSE: Timer Routines
6  * PROGRAMMERS: ReactOS Portable Systems Group
7  */
8 
9 /* INCLUDES *******************************************************************/
10 
11 #include <hal.h>
12 #define NDEBUG
13 #include <debug.h>
14 
15 VOID
18  IN PKTRAP_FRAME TrapFrame,
21 );
22 
23 /* GLOBALS ********************************************************************/
24 
26 
27 /* PRIVATE FUNCTIONS **********************************************************/
28 
29 VOID
31 {
32  /* Clear the interrupt */
35 
36  /* FIXME: Update HAL Perf counters */
37 
38  /* FIXME: Check if someone changed the clockrate */
39 
40  /* Call the kernel */
43  CLOCK2_LEVEL);
44 }
45 
46 VOID
48 {
49  /* Clear the interrupt */
51 }
52 
53 VOID
55 {
56  PKIPCR Pcr = (PKIPCR)KeGetPcr();
57  ULONG ClockInterval;
58  SP804_CONTROL_REGISTER ControlRegister;
59 
60  /* Setup the clock and profile interrupt */
62 
63  /*
64  * Configure the interval to 10ms
65  * (INTERVAL (10ms) * TIMCLKfreq (1MHz))
66  * --------------------------------------- == 10^4
67  * (TIMCLKENXdiv (1) * PRESCALEdiv (1))
68  */
69  ClockInterval = 0x2710;
70 
71  /* Configure the timer */
72  ControlRegister.AsUlong = 0;
73  ControlRegister.Wide = TRUE;
74  ControlRegister.Periodic = TRUE;
75  ControlRegister.Interrupt = TRUE;
76  ControlRegister.Enabled = TRUE;
77 
78  /* Enable the timer */
79  WRITE_REGISTER_ULONG(TIMER0_LOAD, ClockInterval);
81 }
82 
83 /* PUBLIC FUNCTIONS ***********************************************************/
84 
85 /*
86  * @implemented
87  */
88 VOID
89 NTAPI
91  IN ULONGLONG NewCount)
92 {
94  while (TRUE);
95 }
96 
97 /*
98  * @implemented
99  */
100 ULONG
101 NTAPI
103 {
105  while (TRUE);
106  return Increment;
107 }
108 
109 /*
110  * @implemented
111  */
112 VOID
113 NTAPI
115 {
116  SP804_CONTROL_REGISTER ControlRegister;
117 
118  /* Enable the timer */
119  WRITE_REGISTER_ULONG(TIMER1_LOAD, Microseconds);
120 
121  /* Configure the timer */
122  ControlRegister.AsUlong = 0;
123  ControlRegister.OneShot = TRUE;
124  ControlRegister.Wide = TRUE;
125  ControlRegister.Periodic = TRUE;
126  ControlRegister.Enabled = TRUE;
127  WRITE_REGISTER_ULONG(TIMER1_CONTROL, ControlRegister.AsUlong);
128 
129  /* Now we will loop until the timer reached 0 */
131 }
132 
133 /*
134  * @implemented
135  */
137 NTAPI
139 {
141 
143  while (TRUE);
144 
145  Value.QuadPart = 0;
146  return Value;
147 }
148 
149 /* EOF */
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
VOID NTAPI HalCalibratePerformanceCounter(IN volatile PLONG Count, IN ULONGLONG NewCount)
Definition: timer.c:90
VOID HalpStallInterrupt(VOID)
Definition: timer.c:47
#define IN
Definition: typedefs.h:39
LARGE_INTEGER NTAPI KeQueryPerformanceCounter(IN PLARGE_INTEGER PerformanceFreq)
Definition: timer.c:138
NTKERNELAPI VOID NTAPI WRITE_REGISTER_ULONG(IN PULONG Register, IN ULONG Value)
#define TRUE
Definition: types.h:120
#define TIMER0_LOAD
Definition: sp804.h:15
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
VOID FASTCALL KeUpdateSystemTime(IN PKTRAP_FRAME TrapFrame, IN ULONG Increment, IN KIRQL OldIrql)
Definition: time.c:64
struct _KIPCR * PKIPCR
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
NTKERNELAPI ULONG NTAPI READ_REGISTER_ULONG(IN PULONG Register)
#define FASTCALL
Definition: nt_native.h:50
#define KeGetPcr()
Definition: ke.h:25
UCHAR KIRQL
Definition: env_spec_w32.h:591
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
ULONG HalpNextTimeIncrement
Definition: timer.c:25
#define TIMER0_INT_CLEAR
Definition: sp804.h:18
uint64_t ULONGLONG
Definition: typedefs.h:66
#define CLOCK2_LEVEL
Definition: env_spec_w32.h:700
VOID HalpInitializeClock(VOID)
Definition: timer.c:54
VOID NTAPI KeStallExecutionProcessor(IN ULONG Microseconds)
Definition: timer.c:114
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:803
#define TIMER0_CONTROL
Definition: sp804.h:17
VOID HalpClockInterrupt(VOID)
Definition: timer.c:30
UINTN UINT8 Value
Definition: acefiex.h:751
#define TIMER1_VALUE
Definition: sp804.h:23
#define TIMER1_LOAD
Definition: sp804.h:22
ULONG HalpCurrentTimeIncrement
Definition: timer.c:25
ULONG HalpNextIntervalCount
Definition: timer.c:25
unsigned int ULONG
Definition: retypes.h:1
#define UNIMPLEMENTED
Definition: debug.h:114
PKINTERRUPT_ROUTINE InterruptRoutine[MAXIMUM_VECTOR]
Definition: ketypes.h:510
#define TIMER1_CONTROL
Definition: sp804.h:24
#define KeGetCurrentThread
Definition: hal.h:44
IN OUT PLONG IN OUT PLONG Addend IN OUT PLONG IN LONG Increment
Definition: CrNtStubs.h:42
signed int * PLONG
Definition: retypes.h:5
ULONG NTAPI HalSetTimeIncrement(IN ULONG Increment)
Definition: timer.c:102
LONGLONG QuadPart
Definition: typedefs.h:113