ArmPkg/ArmLib: remove indirection layer from timer register accessors
The generic timer support libraries call the actual system register accessor function via a single pair of functions ArmArchTimerReadReg() and ArmArchTimerWriteReg(), which take an enum argument to identify the register, and return output values by pointer reference. Since these functions are never called with a non-immediate argument, we can simply replace each invocation with the underlying system register accessor instead. This is mostly functionally equivalent, with the exception of the bounds check for the enum (which is pointless given the fact that we never pass a variable), the check for the presence of the architected timer (which only makes sense for ARMv7, but is highly unlikely to vary between platforms that are similar enough to run the same firmware image), and a check for enum values that refer to the HYP view of the timer, which we never referred to anywhere in the code in the first place. So get rid of the middle man, and update the ArmGenericTimerPhyCounterLib and ArmGenericTimerVirtCounterLib implementations to call the system register accessors directly. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org> Tested-by: Ryan Harkin <ryan.harkin@linaro.org>
This commit is contained in:
@@ -1,55 +0,0 @@
|
||||
/** @file
|
||||
|
||||
Copyright (c) 2011 - 2013, ARM 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.
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __ARM_ARCH_TIMER_H__
|
||||
#define __ARM_ARCH_TIMER_H__
|
||||
|
||||
#define ARM_ARCH_TIMER_ENABLE (1 << 0)
|
||||
#define ARM_ARCH_TIMER_IMASK (1 << 1)
|
||||
#define ARM_ARCH_TIMER_ISTATUS (1 << 2)
|
||||
|
||||
typedef enum {
|
||||
CntFrq = 0,
|
||||
CntPct,
|
||||
CntkCtl,
|
||||
CntpTval,
|
||||
CntpCtl,
|
||||
CntvTval,
|
||||
CntvCtl,
|
||||
CntvCt,
|
||||
CntpCval,
|
||||
CntvCval,
|
||||
CntvOff,
|
||||
CnthCtl,
|
||||
CnthpTval,
|
||||
CnthpCtl,
|
||||
CnthpCval,
|
||||
RegMaximum
|
||||
} ARM_ARCH_TIMER_REGS;
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
ArmArchTimerReadReg (
|
||||
IN ARM_ARCH_TIMER_REGS Reg,
|
||||
OUT VOID *DstBuf
|
||||
);
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
ArmArchTimerWriteReg (
|
||||
IN ARM_ARCH_TIMER_REGS Reg,
|
||||
IN VOID *SrcBuf
|
||||
);
|
||||
|
||||
#endif // __ARM_ARCH_TIMER_H__
|
@@ -587,4 +587,132 @@ ArmUnsetCpuActlrBit (
|
||||
IN UINTN Bits
|
||||
);
|
||||
|
||||
//
|
||||
// Accessors for the architected generic timer registers
|
||||
//
|
||||
|
||||
#define ARM_ARCH_TIMER_ENABLE (1 << 0)
|
||||
#define ARM_ARCH_TIMER_IMASK (1 << 1)
|
||||
#define ARM_ARCH_TIMER_ISTATUS (1 << 2)
|
||||
|
||||
UINTN
|
||||
EFIAPI
|
||||
ArmReadCntFrq (
|
||||
VOID
|
||||
);
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
ArmWriteCntFrq (
|
||||
UINTN FreqInHz
|
||||
);
|
||||
|
||||
UINT64
|
||||
EFIAPI
|
||||
ArmReadCntPct (
|
||||
VOID
|
||||
);
|
||||
|
||||
UINTN
|
||||
EFIAPI
|
||||
ArmReadCntkCtl (
|
||||
VOID
|
||||
);
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
ArmWriteCntkCtl (
|
||||
UINTN Val
|
||||
);
|
||||
|
||||
UINTN
|
||||
EFIAPI
|
||||
ArmReadCntpTval (
|
||||
VOID
|
||||
);
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
ArmWriteCntpTval (
|
||||
UINTN Val
|
||||
);
|
||||
|
||||
UINTN
|
||||
EFIAPI
|
||||
ArmReadCntpCtl (
|
||||
VOID
|
||||
);
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
ArmWriteCntpCtl (
|
||||
UINTN Val
|
||||
);
|
||||
|
||||
UINTN
|
||||
EFIAPI
|
||||
ArmReadCntvTval (
|
||||
VOID
|
||||
);
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
ArmWriteCntvTval (
|
||||
UINTN Val
|
||||
);
|
||||
|
||||
UINTN
|
||||
EFIAPI
|
||||
ArmReadCntvCtl (
|
||||
VOID
|
||||
);
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
ArmWriteCntvCtl (
|
||||
UINTN Val
|
||||
);
|
||||
|
||||
UINT64
|
||||
EFIAPI
|
||||
ArmReadCntvCt (
|
||||
VOID
|
||||
);
|
||||
|
||||
UINT64
|
||||
EFIAPI
|
||||
ArmReadCntpCval (
|
||||
VOID
|
||||
);
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
ArmWriteCntpCval (
|
||||
UINT64 Val
|
||||
);
|
||||
|
||||
UINT64
|
||||
EFIAPI
|
||||
ArmReadCntvCval (
|
||||
VOID
|
||||
);
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
ArmWriteCntvCval (
|
||||
UINT64 Val
|
||||
);
|
||||
|
||||
UINT64
|
||||
EFIAPI
|
||||
ArmReadCntvOff (
|
||||
VOID
|
||||
);
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
ArmWriteCntvOff (
|
||||
UINT64 Val
|
||||
);
|
||||
|
||||
#endif // __ARM_LIB__
|
||||
|
Reference in New Issue
Block a user