mirror of
https://github.com/CloverHackyColor/CloverBootloader.git
synced 2024-12-04 13:23:26 +01:00
84f41b2b58
Signed-off-by: Slice <sergey.slice@gmail.com>
122 lines
2.1 KiB
C
122 lines
2.1 KiB
C
/** @file
|
|
|
|
Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
|
|
Copyright (c) 2011 - 2014, ARM Limited. All rights reserved.
|
|
Copyright (c) 2021, 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);
|
|
}
|
|
|
|
/** Checks if CCIDX is implemented.
|
|
|
|
@retval TRUE CCIDX is implemented.
|
|
@retval FALSE CCIDX is not implemented.
|
|
**/
|
|
BOOLEAN
|
|
EFIAPI
|
|
ArmHasCcidx (
|
|
VOID
|
|
)
|
|
{
|
|
UINTN Mmfr4;
|
|
|
|
Mmfr4 = ArmReadIdMmfr4 ();
|
|
return (((Mmfr4 >> 24) & 0xF) == 1) ? TRUE : FALSE;
|
|
}
|