3 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
4 Copyright (c) 2011 - 2012, 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>
22 #include <Chipset/ARM1176JZ-S.h>
24 #include <Chipset/ArmV7.h>
28 ARM_CACHE_TYPE_WRITE_BACK
,
29 ARM_CACHE_TYPE_UNKNOWN
33 ARM_CACHE_ARCHITECTURE_UNIFIED
,
34 ARM_CACHE_ARCHITECTURE_SEPARATE
,
35 ARM_CACHE_ARCHITECTURE_UNKNOWN
36 } ARM_CACHE_ARCHITECTURE
;
40 ARM_CACHE_ARCHITECTURE Architecture
;
41 BOOLEAN DataCachePresent
;
43 UINTN DataCacheAssociativity
;
44 UINTN DataCacheLineLength
;
45 BOOLEAN InstructionCachePresent
;
46 UINTN InstructionCacheSize
;
47 UINTN InstructionCacheAssociativity
;
48 UINTN InstructionCacheLineLength
;
52 * The UEFI firmware must not use the ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_* attributes.
54 * The Non Secure memory attribute (ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_*) should only
55 * be used in Secure World to distinguished Secure to Non-Secure memory.
58 ARM_MEMORY_REGION_ATTRIBUTE_UNCACHED_UNBUFFERED
= 0,
59 ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_UNCACHED_UNBUFFERED
,
60 ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK
,
61 ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_BACK
,
62 ARM_MEMORY_REGION_ATTRIBUTE_WRITE_THROUGH
,
63 ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_THROUGH
,
64 ARM_MEMORY_REGION_ATTRIBUTE_DEVICE
,
65 ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_DEVICE
66 } ARM_MEMORY_REGION_ATTRIBUTES
;
68 #define IS_ARM_MEMORY_REGION_ATTRIBUTES_SECURE(attr) ((UINT32)(attr) & 1)
71 EFI_PHYSICAL_ADDRESS PhysicalBase
;
72 EFI_VIRTUAL_ADDRESS VirtualBase
;
74 ARM_MEMORY_REGION_ATTRIBUTES Attributes
;
75 } ARM_MEMORY_REGION_DESCRIPTOR
;
77 typedef VOID (*CACHE_OPERATION
)(VOID
);
78 typedef VOID (*LINE_OPERATION
)(UINTN
);
81 ARM_PROCESSOR_MODE_USER
= 0x10,
82 ARM_PROCESSOR_MODE_FIQ
= 0x11,
83 ARM_PROCESSOR_MODE_IRQ
= 0x12,
84 ARM_PROCESSOR_MODE_SUPERVISOR
= 0x13,
85 ARM_PROCESSOR_MODE_ABORT
= 0x17,
86 ARM_PROCESSOR_MODE_HYP
= 0x1A,
87 ARM_PROCESSOR_MODE_UNDEFINED
= 0x1B,
88 ARM_PROCESSOR_MODE_SYSTEM
= 0x1F,
89 ARM_PROCESSOR_MODE_MASK
= 0x1F
92 #define IS_PRIMARY_CORE(MpId) (((MpId) & PcdGet32(PcdArmPrimaryCoreMask)) == PcdGet32(PcdArmPrimaryCore))
93 #define GET_CORE_ID(MpId) ((MpId) & 0xFF)
94 #define GET_CLUSTER_ID(MpId) (((MpId) >> 8) & 0xFF)
95 // Get the position of the core for the Stack Offset (4 Core per Cluster)
96 // Position = (ClusterId * 4) + CoreId
97 #define GET_CORE_POS(MpId) ((((MpId) >> 6) & 0xFF) + ((MpId) & 0xFF))
98 #define PRIMARY_CORE_ID (PcdGet32(PcdArmPrimaryCore) & 0xFF)
106 ARM_CACHE_ARCHITECTURE
108 ArmCacheArchitecture (
114 ArmCacheInformation (
115 OUT ARM_CACHE_INFO
*CacheInfo
120 ArmDataCachePresent (
132 ArmDataCacheAssociativity (
138 ArmDataCacheLineLength (
144 ArmInstructionCachePresent (
150 ArmInstructionCacheSize (
156 ArmInstructionCacheAssociativity (
162 ArmInstructionCacheLineLength (
186 ArmInvalidateDataCache (
193 ArmCleanInvalidateDataCache (
205 ArmCleanDataCacheToPoU (
211 ArmInvalidateInstructionCache (
217 ArmInvalidateDataCacheEntryByMVA (
223 ArmCleanDataCacheEntryByMVA (
229 ArmCleanInvalidateDataCacheEntryByMVA (
241 ArmDisableDataCache (
247 ArmEnableInstructionCache (
253 ArmDisableInstructionCache (
271 ArmDisableCachesAndMmu (
277 ArmInvalidateInstructionAndDataTlb (
283 ArmEnableInterrupts (
289 ArmDisableInterrupts (
295 ArmGetInterruptState (
325 ArmUpdateTranslationTableEntry (
326 IN VOID
*TranslationTableEntry
,
332 ArmSetDomainAccessControl (
339 IN VOID
*TranslationTableBase
344 ArmGetTTBR0BaseAddress (
351 IN ARM_MEMORY_REGION_DESCRIPTOR
*MemoryTable
,
352 OUT VOID
**TranslationTableBase OPTIONAL
,
353 OUT UINTN
*TranslationTableSize OPTIONAL
364 ArmSwitchProcessorMode (
365 IN ARM_PROCESSOR_MODE Mode
376 ArmEnableBranchPrediction (
382 ArmDisableBranchPrediction (
400 ArmDataMemoryBarrier (
406 ArmDataSyncronizationBarrier (
412 ArmInstructionSynchronizationBarrier (
503 IN UINT32 SetWayFormat
515 IN UINT32 SetWayFormat
527 IN UINT32 VectorMonitorBase
536 #endif // __ARM_LIB__