Create a helper function to eliminate direct feature register reading. Returns BOOLEAN True if the CPU implements the Security extensions, otherwise returns BOOL False. This function is only implemented for ARM, not AArch64. Cc: Ard Biesheuvel <ard.biesheuvel@arm.com> Signed-off-by: Leif Lindholm <leif@nuviainc.com> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
105 lines
1.9 KiB
C
105 lines
1.9 KiB
C
/** @file
|
|
|
|
Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
|
|
Copyright (c) 2011 - 2014, ARM Limited. All rights reserved.
|
|
Copyright (c) 2020, NUVIA Inc. All rights reserved.<BR>
|
|
|
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
|
|
**/
|
|
|
|
#include <Base.h>
|
|
|
|
#include <Library/ArmLib.h>
|
|
#include <Library/DebugLib.h>
|
|
|
|
#include <Chipset/ArmV7.h>
|
|
|
|
#include "ArmV7Lib.h"
|
|
#include "ArmLibPrivate.h"
|
|
|
|
VOID
|
|
ArmV7DataCacheOperation (
|
|
IN ARM_V7_CACHE_OPERATION DataCacheOperation
|
|
)
|
|
{
|
|
UINTN SavedInterruptState;
|
|
|
|
SavedInterruptState = ArmGetInterruptState ();
|
|
ArmDisableInterrupts ();
|
|
|
|
ArmV7AllDataCachesOperation (DataCacheOperation);
|
|
|
|
ArmDataSynchronizationBarrier ();
|
|
|
|
if (SavedInterruptState) {
|
|
ArmEnableInterrupts ();
|
|
}
|
|
}
|
|
|
|
VOID
|
|
EFIAPI
|
|
ArmInvalidateDataCache (
|
|
VOID
|
|
)
|
|
{
|
|
ASSERT (!ArmMmuEnabled ());
|
|
|
|
ArmDataSynchronizationBarrier ();
|
|
ArmV7DataCacheOperation (ArmInvalidateDataCacheEntryBySetWay);
|
|
}
|
|
|
|
VOID
|
|
EFIAPI
|
|
ArmCleanInvalidateDataCache (
|
|
VOID
|
|
)
|
|
{
|
|
ASSERT (!ArmMmuEnabled ());
|
|
|
|
ArmDataSynchronizationBarrier ();
|
|
ArmV7DataCacheOperation (ArmCleanInvalidateDataCacheEntryBySetWay);
|
|
}
|
|
|
|
VOID
|
|
EFIAPI
|
|
ArmCleanDataCache (
|
|
VOID
|
|
)
|
|
{
|
|
ASSERT (!ArmMmuEnabled ());
|
|
|
|
ArmDataSynchronizationBarrier ();
|
|
ArmV7DataCacheOperation (ArmCleanDataCacheEntryBySetWay);
|
|
}
|
|
|
|
/**
|
|
Check whether the CPU supports the GIC system register interface (any version)
|
|
|
|
@return Whether GIC System Register Interface is supported
|
|
|
|
**/
|
|
BOOLEAN
|
|
EFIAPI
|
|
ArmHasGicSystemRegisters (
|
|
VOID
|
|
)
|
|
{
|
|
return ((ArmReadIdPfr1 () & ARM_PFR1_GIC) != 0);
|
|
}
|
|
|
|
/**
|
|
Check whether the CPU supports the Security extensions
|
|
|
|
@return Whether the Security extensions are implemented
|
|
|
|
**/
|
|
BOOLEAN
|
|
EFIAPI
|
|
ArmHasSecurityExtensions (
|
|
VOID
|
|
)
|
|
{
|
|
return ((ArmReadIdPfr1 () & ARM_PFR1_SEC) != 0);
|
|
}
|