3 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
4 Copyright (c) 2011 - 2014, ARM Ltd. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19 #include <Uefi/UefiBaseType.h>
23 #include <Chipset/ARM1176JZ-S.h>
25 #include <Chipset/ArmV7.h>
27 #elif defined(MDE_CPU_AARCH64)
28 #include <Chipset/AArch64.h>
30 #error "Unknown chipset."
34 ARM_CACHE_TYPE_WRITE_BACK
,
35 ARM_CACHE_TYPE_UNKNOWN
39 ARM_CACHE_ARCHITECTURE_UNIFIED
,
40 ARM_CACHE_ARCHITECTURE_SEPARATE
,
41 ARM_CACHE_ARCHITECTURE_UNKNOWN
42 } ARM_CACHE_ARCHITECTURE
;
46 ARM_CACHE_ARCHITECTURE Architecture
;
47 BOOLEAN DataCachePresent
;
49 UINTN DataCacheAssociativity
;
50 UINTN DataCacheLineLength
;
51 BOOLEAN InstructionCachePresent
;
52 UINTN InstructionCacheSize
;
53 UINTN InstructionCacheAssociativity
;
54 UINTN InstructionCacheLineLength
;
58 * The UEFI firmware must not use the ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_* attributes.
60 * The Non Secure memory attribute (ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_*) should only
61 * be used in Secure World to distinguished Secure to Non-Secure memory.
64 ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED
= 0,
65 ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_UNCACHED_UNBUFFERED
,
66 ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK
,
67 ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_BACK
,
68 ARM_MEMORY_REGION_ATTRIBUTE_WRITE_THROUGH
,
69 ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_THROUGH
,
70 ARM_MEMORY_REGION_ATTRIBUTE_DEVICE
,
71 ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE
72 } ARM_MEMORY_REGION_ATTRIBUTES
;
74 #define IS_ARM_MEMORY_REGION_ATTRIBUTES_SECURE(attr) ((UINT32)(attr) & 1)
77 EFI_PHYSICAL_ADDRESS PhysicalBase
;
78 EFI_VIRTUAL_ADDRESS VirtualBase
;
80 ARM_MEMORY_REGION_ATTRIBUTES Attributes
;
81 } ARM_MEMORY_REGION_DESCRIPTOR
;
83 typedef VOID (*CACHE_OPERATION
)(VOID
);
84 typedef VOID (*LINE_OPERATION
)(UINTN
);
90 ARM_PROCESSOR_MODE_USER
= 0x10,
91 ARM_PROCESSOR_MODE_FIQ
= 0x11,
92 ARM_PROCESSOR_MODE_IRQ
= 0x12,
93 ARM_PROCESSOR_MODE_SUPERVISOR
= 0x13,
94 ARM_PROCESSOR_MODE_ABORT
= 0x17,
95 ARM_PROCESSOR_MODE_HYP
= 0x1A,
96 ARM_PROCESSOR_MODE_UNDEFINED
= 0x1B,
97 ARM_PROCESSOR_MODE_SYSTEM
= 0x1F,
98 ARM_PROCESSOR_MODE_MASK
= 0x1F
104 #define ARM_CPU_IMPLEMENTER_MASK (0xFFU << 24)
105 #define ARM_CPU_IMPLEMENTER_ARMLTD (0x41U << 24)
106 #define ARM_CPU_IMPLEMENTER_DEC (0x44U << 24)
107 #define ARM_CPU_IMPLEMENTER_MOT (0x4DU << 24)
108 #define ARM_CPU_IMPLEMENTER_QUALCOMM (0x51U << 24)
109 #define ARM_CPU_IMPLEMENTER_MARVELL (0x56U << 24)
111 #define ARM_CPU_PRIMARY_PART_MASK (0xFFF << 4)
112 #define ARM_CPU_PRIMARY_PART_CORTEXA5 (0xC05 << 4)
113 #define ARM_CPU_PRIMARY_PART_CORTEXA7 (0xC07 << 4)
114 #define ARM_CPU_PRIMARY_PART_CORTEXA8 (0xC08 << 4)
115 #define ARM_CPU_PRIMARY_PART_CORTEXA9 (0xC09 << 4)
116 #define ARM_CPU_PRIMARY_PART_CORTEXA15 (0xC0F << 4)
121 #define ARM_CORE_MASK 0xFF
122 #define ARM_CLUSTER_MASK (0xFF << 8)
123 #define GET_CORE_ID(MpId) ((MpId) & ARM_CORE_MASK)
124 #define GET_CLUSTER_ID(MpId) (((MpId) & ARM_CLUSTER_MASK) >> 8)
125 #define GET_MPID(ClusterId, CoreId) (((ClusterId) << 8) | (CoreId))
126 #define PRIMARY_CORE_ID (PcdGet32(PcdArmPrimaryCore) & ARM_CORE_MASK)
134 ARM_CACHE_ARCHITECTURE
136 ArmCacheArchitecture (
142 ArmCacheInformation (
143 OUT ARM_CACHE_INFO
*CacheInfo
148 ArmDataCachePresent (
160 ArmDataCacheAssociativity (
166 ArmDataCacheLineLength (
172 ArmInstructionCachePresent (
178 ArmInstructionCacheSize (
184 ArmInstructionCacheAssociativity (
190 ArmInstructionCacheLineLength (
196 ArmIsArchTimerImplemented (
226 ArmInvalidateDataCache (
233 ArmCleanInvalidateDataCache (
245 ArmCleanDataCacheToPoU (
251 ArmInvalidateInstructionCache (
257 ArmInvalidateDataCacheEntryByMVA (
263 ArmCleanDataCacheEntryByMVA (
269 ArmCleanInvalidateDataCacheEntryByMVA (
275 ArmInvalidateDataCacheEntryBySetWay (
276 IN UINTN SetWayFormat
281 ArmCleanDataCacheEntryBySetWay (
282 IN UINTN SetWayFormat
287 ArmCleanInvalidateDataCacheEntryBySetWay (
288 IN UINTN SetWayFormat
299 ArmDisableDataCache (
305 ArmEnableInstructionCache (
311 ArmDisableInstructionCache (
329 ArmEnableCachesAndMmu (
335 ArmDisableCachesAndMmu (
341 ArmInvalidateInstructionAndDataTlb (
347 ArmEnableInterrupts (
353 ArmDisableInterrupts (
359 ArmGetInterruptState (
365 ArmEnableAsynchronousAbort (
371 ArmDisableAsynchronousAbort (
413 ArmUpdateTranslationTableEntry (
414 IN VOID
*TranslationTableEntry
,
420 ArmSetDomainAccessControl (
427 IN VOID
*TranslationTableBase
432 ArmGetTTBR0BaseAddress (
439 IN ARM_MEMORY_REGION_DESCRIPTOR
*MemoryTable
,
440 OUT VOID
**TranslationTableBase OPTIONAL
,
441 OUT UINTN
*TranslationTableSize OPTIONAL
452 ArmEnableBranchPrediction (
458 ArmDisableBranchPrediction (
476 ArmDrainWriteBuffer (
482 ArmDataMemoryBarrier (
488 ArmDataSyncronizationBarrier (
494 ArmInstructionSynchronizationBarrier (
584 Get the Secure Configuration Register value
586 @return Value read from the Secure Configuration Register
596 Set the Secure Configuration Register
598 @param Value Value to write to the Secure Configuration Register
616 IN UINT32 VectorMonitorBase
634 IN UINTN HypModeVectorBase
639 // Helper functions for accessing CPU ACTLR
662 ArmUnsetCpuActlrBit (
666 #endif // __ARM_LIB__