2014-09-09 18:06:10 +02:00
|
|
|
/** @file
|
|
|
|
|
|
|
|
Copyright (c) 2011 - 2014, ARM Ltd. All rights reserved.<BR>
|
|
|
|
Copyright (c) 2014, Linaro Ltd. All rights reserved.<BR>
|
|
|
|
|
|
|
|
This program and the accompanying materials
|
|
|
|
are licensed and made available under the terms and conditions of the BSD License
|
|
|
|
which accompanies this distribution. The full text of the license may be found at
|
|
|
|
http://opensource.org/licenses/bsd-license.php
|
|
|
|
|
|
|
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
#include <Library/ArmGenericTimerCounterLib.h>
|
2017-01-20 12:58:37 +01:00
|
|
|
#include <Library/ArmLib.h>
|
2014-09-09 18:06:10 +02:00
|
|
|
|
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
ArmGenericTimerEnableTimer (
|
|
|
|
VOID
|
|
|
|
)
|
|
|
|
{
|
|
|
|
UINTN TimerCtrlReg;
|
|
|
|
|
2017-01-20 12:58:37 +01:00
|
|
|
TimerCtrlReg = ArmReadCntpCtl ();
|
2014-09-09 18:06:10 +02:00
|
|
|
TimerCtrlReg |= ARM_ARCH_TIMER_ENABLE;
|
2017-01-20 12:58:37 +01:00
|
|
|
ArmWriteCntpCtl (TimerCtrlReg);
|
2014-09-09 18:06:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
ArmGenericTimerDisableTimer (
|
|
|
|
VOID
|
|
|
|
)
|
|
|
|
{
|
|
|
|
UINTN TimerCtrlReg;
|
|
|
|
|
2017-01-20 12:58:37 +01:00
|
|
|
TimerCtrlReg = ArmReadCntpCtl ();
|
2014-09-09 18:06:10 +02:00
|
|
|
TimerCtrlReg &= ~ARM_ARCH_TIMER_ENABLE;
|
2017-01-20 12:58:37 +01:00
|
|
|
ArmWriteCntpCtl (TimerCtrlReg);
|
2014-09-09 18:06:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
ArmGenericTimerSetTimerFreq (
|
|
|
|
IN UINTN FreqInHz
|
|
|
|
)
|
|
|
|
{
|
2017-01-20 12:58:37 +01:00
|
|
|
ArmWriteCntFrq (FreqInHz);
|
2014-09-09 18:06:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
UINTN
|
|
|
|
EFIAPI
|
|
|
|
ArmGenericTimerGetTimerFreq (
|
|
|
|
VOID
|
|
|
|
)
|
|
|
|
{
|
2017-01-20 12:58:37 +01:00
|
|
|
return ArmReadCntFrq ();
|
2014-09-09 18:06:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
UINTN
|
|
|
|
EFIAPI
|
|
|
|
ArmGenericTimerGetTimerVal (
|
|
|
|
VOID
|
|
|
|
)
|
|
|
|
{
|
2017-01-20 12:58:37 +01:00
|
|
|
return ArmReadCntpTval ();
|
2014-09-09 18:06:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
ArmGenericTimerSetTimerVal (
|
|
|
|
IN UINTN Value
|
|
|
|
)
|
|
|
|
{
|
2017-01-20 12:58:37 +01:00
|
|
|
ArmWriteCntpTval (Value);
|
2014-09-09 18:06:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
UINT64
|
|
|
|
EFIAPI
|
|
|
|
ArmGenericTimerGetSystemCount (
|
|
|
|
VOID
|
|
|
|
)
|
|
|
|
{
|
2017-01-20 12:58:37 +01:00
|
|
|
return ArmReadCntPct ();
|
2014-09-09 18:06:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
UINTN
|
|
|
|
EFIAPI
|
|
|
|
ArmGenericTimerGetTimerCtrlReg (
|
|
|
|
VOID
|
|
|
|
)
|
|
|
|
{
|
2017-01-20 12:58:37 +01:00
|
|
|
return ArmReadCntpCtl ();
|
2014-09-09 18:06:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
ArmGenericTimerSetTimerCtrlReg (
|
|
|
|
UINTN Value
|
|
|
|
)
|
|
|
|
{
|
2017-01-20 12:58:37 +01:00
|
|
|
ArmWriteCntpCtl (Value);
|
2014-09-09 18:06:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
UINT64
|
|
|
|
EFIAPI
|
|
|
|
ArmGenericTimerGetCompareVal (
|
|
|
|
VOID
|
|
|
|
)
|
|
|
|
{
|
2017-01-20 12:58:37 +01:00
|
|
|
return ArmReadCntpCval ();
|
2014-09-09 18:06:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
ArmGenericTimerSetCompareVal (
|
|
|
|
IN UINT64 Value
|
|
|
|
)
|
|
|
|
{
|
2017-01-20 12:58:37 +01:00
|
|
|
ArmWriteCntpCval (Value);
|
2014-09-09 18:06:10 +02:00
|
|
|
}
|