2009-12-06 02:57:05 +01:00
|
|
|
/** @file
|
|
|
|
|
2010-04-29 14:15:47 +02:00
|
|
|
Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
|
2020-12-10 14:12:00 +01:00
|
|
|
Copyright (c) 2011 - 2021, ARM Ltd. All rights reserved.<BR>
|
2014-08-19 15:29:52 +02:00
|
|
|
|
2019-04-04 01:03:18 +02:00
|
|
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
2009-12-06 02:57:05 +01:00
|
|
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
#include <Base.h>
|
|
|
|
|
|
|
|
#include <Library/ArmLib.h>
|
|
|
|
|
|
|
|
#include "ArmLibPrivate.h"
|
|
|
|
|
2011-09-27 18:31:20 +02:00
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
ArmSetAuxCrBit (
|
|
|
|
IN UINT32 Bits
|
|
|
|
)
|
|
|
|
{
|
2020-12-10 14:12:00 +01:00
|
|
|
ArmWriteAuxCr (ArmReadAuxCr () | Bits);
|
2011-09-27 18:31:20 +02:00
|
|
|
}
|
|
|
|
|
2012-05-02 22:02:39 +02:00
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
ArmUnsetAuxCrBit (
|
|
|
|
IN UINT32 Bits
|
|
|
|
)
|
|
|
|
{
|
2020-12-10 14:12:00 +01:00
|
|
|
ArmWriteAuxCr (ArmReadAuxCr () & ~Bits);
|
2012-05-02 22:02:39 +02:00
|
|
|
}
|
2014-03-26 20:31:01 +01:00
|
|
|
|
|
|
|
//
|
|
|
|
// Helper functions for accessing CPUACTLR
|
|
|
|
//
|
|
|
|
|
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
ArmSetCpuActlrBit (
|
|
|
|
IN UINTN Bits
|
|
|
|
)
|
|
|
|
{
|
2020-12-10 14:12:00 +01:00
|
|
|
ArmWriteCpuActlr (ArmReadCpuActlr () | Bits);
|
2014-03-26 20:31:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
ArmUnsetCpuActlrBit (
|
|
|
|
IN UINTN Bits
|
|
|
|
)
|
|
|
|
{
|
2020-12-10 14:12:00 +01:00
|
|
|
ArmWriteCpuActlr (ArmReadCpuActlr () & ~Bits);
|
2014-03-26 20:31:01 +01:00
|
|
|
}
|
2015-11-09 14:26:52 +01:00
|
|
|
|
|
|
|
UINTN
|
|
|
|
EFIAPI
|
|
|
|
ArmDataCacheLineLength (
|
|
|
|
VOID
|
|
|
|
)
|
|
|
|
{
|
|
|
|
return 4 << ((ArmCacheInfo () >> 16) & 0xf); // CTR_EL0.DminLine
|
|
|
|
}
|
|
|
|
|
|
|
|
UINTN
|
|
|
|
EFIAPI
|
|
|
|
ArmInstructionCacheLineLength (
|
|
|
|
VOID
|
|
|
|
)
|
|
|
|
{
|
|
|
|
return 4 << (ArmCacheInfo () & 0xf); // CTR_EL0.IminLine
|
|
|
|
}
|
2015-11-09 14:28:17 +01:00
|
|
|
|
|
|
|
UINTN
|
|
|
|
EFIAPI
|
|
|
|
ArmCacheWritebackGranule (
|
|
|
|
VOID
|
|
|
|
)
|
|
|
|
{
|
|
|
|
UINTN CWG;
|
|
|
|
|
|
|
|
CWG = (ArmCacheInfo () >> 24) & 0xf; // CTR_EL0.CWG
|
|
|
|
|
|
|
|
if (CWG == 0) {
|
|
|
|
return SIZE_2KB;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 4 << CWG;
|
|
|
|
}
|