X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=ArmPkg%2FInclude%2FLibrary%2FArmLib.h;h=79ea755777a9a6f2cb042794f552ed38d63f631a;hb=a63914d3f603580e5aeceb5edbafe56688210141;hp=9622444ec63f61b4d2aaf0653ad7540b96695d56;hpb=3b1495156a3576992b31a77e799db207cb61d9de;p=mirror_edk2.git diff --git a/ArmPkg/Include/Library/ArmLib.h b/ArmPkg/Include/Library/ArmLib.h index 9622444ec6..79ea755777 100644 --- a/ArmPkg/Include/Library/ArmLib.h +++ b/ArmPkg/Include/Library/ArmLib.h @@ -1,20 +1,15 @@ /** @file Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
- Copyright (c) 2011 - 2015, ARM Ltd. All rights reserved.
+ Copyright (c) 2011 - 2016, ARM Ltd. All rights reserved.
+ Copyright (c) 2020 - 2021, NUVIA Inc. All rights reserved.
- 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. + SPDX-License-Identifier: BSD-2-Clause-Patent **/ -#ifndef __ARM_LIB__ -#define __ARM_LIB__ +#ifndef ARM_LIB_H_ +#define ARM_LIB_H_ #include @@ -26,6 +21,10 @@ #error "Unknown chipset." #endif +#define EFI_MEMORY_CACHETYPE_MASK (EFI_MEMORY_UC | EFI_MEMORY_WC | \ + EFI_MEMORY_WT | EFI_MEMORY_WB | \ + EFI_MEMORY_UCE) + /** * The UEFI firmware must not use the ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_* attributes. * @@ -37,6 +36,14 @@ typedef enum { ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_UNCACHED_UNBUFFERED, ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK, ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_BACK, + + // On some platforms, memory mapped flash region is designed as not supporting + // shareable attribute, so WRITE_BACK_NONSHAREABLE is added for such special + // need. + // Do NOT use below two attributes if you are not sure. + ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK_NONSHAREABLE, + ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_BACK_NONSHAREABLE, + ARM_MEMORY_REGION_ATTRIBUTE_WRITE_THROUGH, ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_THROUGH, ARM_MEMORY_REGION_ATTRIBUTE_DEVICE, @@ -102,39 +109,59 @@ typedef enum { #define GET_MPID(ClusterId, CoreId) (((ClusterId) << 8) | (CoreId)) #define PRIMARY_CORE_ID (PcdGet32(PcdArmPrimaryCore) & ARM_CORE_MASK) +/** Reads the CCSIDR register for the specified cache. + + @param CSSELR The CSSELR cache selection register value. + + @return The contents of the CCSIDR_EL1 register for the specified cache, when in AARCH64 mode. + Returns the contents of the CCSIDR register in AARCH32 mode. +**/ UINTN -EFIAPI -ArmDataCacheLineLength ( - VOID +ReadCCSIDR ( + IN UINT32 CSSELR ); -UINTN -EFIAPI -ArmInstructionCacheLineLength ( +/** Reads the CCSIDR2 for the specified cache. + + @param CSSELR The CSSELR cache selection register value + + @return The contents of the CCSIDR2 register for the specified cache. +**/ +UINT32 +ReadCCSIDR2 ( + IN UINT32 CSSELR + ); + +/** Reads the Cache Level ID (CLIDR) register. + + @return The contents of the CLIDR_EL1 register. +**/ +UINT32 +ReadCLIDR ( VOID ); UINTN EFIAPI -ArmCacheWritebackGranule ( +ArmDataCacheLineLength ( VOID ); UINTN EFIAPI -ArmIsArchTimerImplemented ( +ArmInstructionCacheLineLength ( VOID ); UINTN EFIAPI -ArmReadIdPfr0 ( +ArmCacheWritebackGranule ( VOID ); UINTN EFIAPI -ArmReadIdPfr1 ( +ArmIsArchTimerImplemented ( VOID ); @@ -183,32 +210,26 @@ ArmInvalidateDataCacheEntryByMVA ( VOID EFIAPI -ArmCleanDataCacheEntryByMVA ( +ArmCleanDataCacheEntryToPoUByMVA ( IN UINTN Address ); VOID EFIAPI -ArmCleanInvalidateDataCacheEntryByMVA ( +ArmInvalidateInstructionCacheEntryToPoUByMVA ( IN UINTN Address ); VOID EFIAPI -ArmInvalidateDataCacheEntryBySetWay ( - IN UINTN SetWayFormat - ); - -VOID -EFIAPI -ArmCleanDataCacheEntryBySetWay ( - IN UINTN SetWayFormat - ); +ArmCleanDataCacheEntryByMVA ( +IN UINTN Address +); VOID EFIAPI -ArmCleanInvalidateDataCacheEntryBySetWay ( - IN UINTN SetWayFormat +ArmCleanInvalidateDataCacheEntryByMVA ( + IN UINTN Address ); VOID @@ -347,18 +368,16 @@ ArmSetTTBR0 ( IN VOID *TranslationTableBase ); -VOID * +VOID EFIAPI -ArmGetTTBR0BaseAddress ( - VOID +ArmSetTTBCR ( + IN UINT32 Bits ); -RETURN_STATUS +VOID * EFIAPI -ArmConfigureMmu ( - IN ARM_MEMORY_REGION_DESCRIPTOR *MemoryTable, - OUT VOID **TranslationTableBase OPTIONAL, - OUT UINTN *TranslationTableSize OPTIONAL +ArmGetTTBR0BaseAddress ( + VOID ); BOOLEAN @@ -536,6 +555,12 @@ ArmReadSctlr ( VOID ); +VOID +EFIAPI +ArmWriteSctlr ( + IN UINT32 Value + ); + UINTN EFIAPI ArmReadHVBar ( @@ -577,28 +602,183 @@ ArmUnsetCpuActlrBit ( IN UINTN Bits ); -RETURN_STATUS -ArmSetMemoryRegionNoExec ( - IN EFI_PHYSICAL_ADDRESS BaseAddress, - IN UINT64 Length +// +// 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 ); -RETURN_STATUS -ArmClearMemoryRegionNoExec ( - IN EFI_PHYSICAL_ADDRESS BaseAddress, - IN UINT64 Length +VOID +EFIAPI +ArmWriteCntFrq ( + UINTN FreqInHz ); -RETURN_STATUS -ArmSetMemoryRegionReadOnly ( - IN EFI_PHYSICAL_ADDRESS BaseAddress, - IN UINT64 Length +UINT64 +EFIAPI +ArmReadCntPct ( + VOID ); -RETURN_STATUS -ArmClearMemoryRegionReadOnly ( - IN EFI_PHYSICAL_ADDRESS BaseAddress, - IN UINT64 Length +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 + ); + +UINTN +EFIAPI +ArmGetPhysicalAddressBits ( + VOID + ); + + +/// +/// ID Register Helper functions +/// + +/** + Check whether the CPU supports the GIC system register interface (any version) + + @return Whether GIC System Register Interface is supported + +**/ +BOOLEAN +EFIAPI +ArmHasGicSystemRegisters ( + VOID + ); + +/** Checks if CCIDX is implemented. + + @retval TRUE CCIDX is implemented. + @retval FALSE CCIDX is not implemented. +**/ +BOOLEAN +EFIAPI +ArmHasCcidx ( + VOID + ); + +#ifdef MDE_CPU_ARM +/// +/// AArch32-only ID Register Helper functions +/// +/** + Check whether the CPU supports the Security extensions + + @return Whether the Security extensions are implemented + +**/ +BOOLEAN +EFIAPI +ArmHasSecurityExtensions ( + VOID ); +#endif // MDE_CPU_ARM -#endif // __ARM_LIB__ +#endif // ARM_LIB_H_