Create a helper function to eliminate direct feature register reading, which gets messy in code shared between ARM/AArch64. Returns BOOLEAN True if the CPU implements the GIC System Register Interface (any version), otherwise returns BOOL False. Cc: Ard Biesheuvel <ard.biesheuvel@arm.com> Signed-off-by: Leif Lindholm <leif@nuviainc.com> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
90 lines
1.6 KiB
C
90 lines
1.6 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);
|
|
}
|