TianoCore EDK2 master
Loading...
Searching...
No Matches
XenArmGenericTimerVirtCounterLib.c
Go to the documentation of this file.
1
11#include <Library/ArmLib.h>
12
13VOID
14EFIAPI
15ArmGenericTimerEnableTimer (
16 VOID
17 )
18{
19 UINTN TimerCtrlReg;
20
21 TimerCtrlReg = ArmReadCntvCtl ();
22 TimerCtrlReg |= ARM_ARCH_TIMER_ENABLE;
23 ArmWriteCntvCtl (TimerCtrlReg);
24}
25
26VOID
27EFIAPI
28ArmGenericTimerReenableTimer (
29 VOID
30 )
31{
32 UINTN TimerCtrlReg;
33
34 TimerCtrlReg = ArmReadCntvCtl ();
35 TimerCtrlReg |= ARM_ARCH_TIMER_ENABLE;
36
37 //
38 // When running under Xen, we need to unmask the interrupt on the timer side
39 // as Xen will mask it when servicing the interrupt at the hypervisor level
40 // and delivering the virtual timer interrupt to the guest. Otherwise, the
41 // interrupt will fire again, trapping into the hypervisor again, etc. etc.
42 //
43 TimerCtrlReg &= ~ARM_ARCH_TIMER_IMASK;
44 ArmWriteCntvCtl (TimerCtrlReg);
45}
46
47VOID
48EFIAPI
49ArmGenericTimerDisableTimer (
50 VOID
51 )
52{
53 UINTN TimerCtrlReg;
54
55 TimerCtrlReg = ArmReadCntvCtl ();
56 TimerCtrlReg &= ~ARM_ARCH_TIMER_ENABLE;
57 ArmWriteCntvCtl (TimerCtrlReg);
58}
59
60VOID
61EFIAPI
62ArmGenericTimerSetTimerFreq (
63 IN UINTN FreqInHz
64 )
65{
66 ArmWriteCntFrq (FreqInHz);
67}
68
70EFIAPI
71ArmGenericTimerGetTimerFreq (
72 VOID
73 )
74{
75 return ArmReadCntFrq ();
76}
77
79EFIAPI
80ArmGenericTimerGetTimerVal (
81 VOID
82 )
83{
84 return ArmReadCntvTval ();
85}
86
87VOID
88EFIAPI
89ArmGenericTimerSetTimerVal (
90 IN UINTN Value
91 )
92{
93 ArmWriteCntvTval (Value);
94}
95
96UINT64
97EFIAPI
98ArmGenericTimerGetSystemCount (
99 VOID
100 )
101{
102 return ArmReadCntvCt ();
103}
104
105UINTN
106EFIAPI
107ArmGenericTimerGetTimerCtrlReg (
108 VOID
109 )
110{
111 return ArmReadCntvCtl ();
112}
113
114VOID
115EFIAPI
116ArmGenericTimerSetTimerCtrlReg (
117 UINTN Value
118 )
119{
120 ArmWriteCntvCtl (Value);
121}
122
123UINT64
124EFIAPI
125ArmGenericTimerGetCompareVal (
126 VOID
127 )
128{
129 return ArmReadCntvCval ();
130}
131
132VOID
133EFIAPI
134ArmGenericTimerSetCompareVal (
135 IN UINT64 Value
136 )
137{
138 ArmWriteCntvCval (Value);
139}
UINT64 UINTN
#define IN
Definition: Base.h:279