ReactOS 0.4.15-dev-7889-g76290a6
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
15VOID
18 IN PKTRAP_FRAME TrapFrame,
21);
22
23/* GLOBALS ********************************************************************/
24
26
27/* PRIVATE FUNCTIONS **********************************************************/
28
29VOID
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 */
44}
45
46VOID
48{
49 /* Clear the interrupt */
51}
52
53VOID
55{
56 PKPCR Pcr = KeGetPcr();
57 ULONG ClockInterval;
58 SP804_CONTROL_REGISTER ControlRegister;
59
60 /* Setup the clock and profile interrupt */
61 Pcr->InterruptRoutine[CLOCK2_LEVEL] = HalpStallInterrupt;
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 */
88VOID
91 IN ULONGLONG NewCount)
92{
94 while (TRUE);
95}
96
97/*
98 * @implemented
99 */
100ULONG
101NTAPI
103{
105 while (TRUE);
106 return Increment;
107}
108
109/*
110 * @implemented
111 */
112VOID
113NTAPI
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;
128
129 /* Now we will loop until the timer reached 0 */
131}
132
133/*
134 * @implemented
135 */
137NTAPI
139{
141
143 while (TRUE);
144
145 Value.QuadPart = 0;
146 return Value;
147}
148
149/* EOF */
#define WRITE_REGISTER_ULONG(r, v)
Definition: arm.h:27
#define READ_REGISTER_ULONG(r)
Definition: arm.h:26
#define UNIMPLEMENTED
Definition: debug.h:115
#define TRUE
Definition: types.h:120
#define CLOCK2_LEVEL
Definition: env_spec_w32.h:700
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
IN OUT PLONG IN OUT PLONG Addend IN OUT PLONG IN LONG Increment
Definition: CrNtStubs.h:46
VOID NTAPI KeStallExecutionProcessor(IN ULONG Microseconds)
Definition: timer.c:114
VOID HalpClockInterrupt(VOID)
Definition: timer.c:30
VOID HalpStallInterrupt(VOID)
Definition: timer.c:47
VOID FASTCALL KeUpdateSystemTime(IN PKTRAP_FRAME TrapFrame, IN ULONG Increment, IN KIRQL OldIrql)
Definition: time.c:64
ULONG NTAPI HalSetTimeIncrement(IN ULONG Increment)
Definition: timer.c:102
LARGE_INTEGER NTAPI KeQueryPerformanceCounter(IN PLARGE_INTEGER PerformanceFreq)
Definition: timer.c:138
VOID HalpInitializeClock(VOID)
Definition: timer.c:54
ULONG HalpNextIntervalCount
Definition: timer.c:25
ULONG HalpNextTimeIncrement
Definition: timer.c:25
ULONG HalpCurrentTimeIncrement
Definition: timer.c:25
VOID NTAPI HalCalibratePerformanceCounter(IN volatile PLONG Count, IN ULONGLONG NewCount)
Definition: timer.c:90
#define KeGetCurrentThread
Definition: hal.h:55
#define ASSERT(a)
Definition: mode.c:44
#define KeGetPcr()
Definition: ketypes.h:81
int Count
Definition: noreturn.cpp:7
#define FASTCALL
Definition: nt_native.h:50
#define TIMER1_VALUE
Definition: sp804.h:23
#define TIMER0_CONTROL
Definition: sp804.h:17
#define TIMER0_INT_CLEAR
Definition: sp804.h:18
#define TIMER1_LOAD
Definition: sp804.h:22
#define TIMER0_LOAD
Definition: sp804.h:15
#define TIMER1_CONTROL
Definition: sp804.h:24
Definition: ke.h:294
#define NTAPI
Definition: typedefs.h:36
#define IN
Definition: typedefs.h:39
int32_t * PLONG
Definition: typedefs.h:58
uint32_t ULONG
Definition: typedefs.h:59
uint64_t ULONGLONG
Definition: typedefs.h:67
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778