3 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
4 Copyright (c) 2011 - 2021, ARM Limited. All rights reserved.
6 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #include <Library/ArmLib.h>
11 #include <Library/DebugLib.h>
12 #include <Library/PcdLib.h>
19 IN LINE_OPERATION LineOperation
,
23 UINTN ArmCacheLineAlignmentMask
;
24 // Align address (rounding down)
28 ArmCacheLineAlignmentMask
= LineLength
- 1;
29 AlignedAddress
= (UINTN
)Start
- ((UINTN
)Start
& ArmCacheLineAlignmentMask
);
30 EndAddress
= (UINTN
)Start
+ Length
;
32 // Perform the line operation on an address in each cache line
33 while (AlignedAddress
< EndAddress
) {
34 LineOperation(AlignedAddress
);
35 AlignedAddress
+= LineLength
;
37 ArmDataSynchronizationBarrier ();
42 InvalidateInstructionCache (
60 InvalidateInstructionCacheRange (
65 CacheRangeOperation (Address
, Length
, ArmCleanDataCacheEntryToPoUByMVA
,
66 ArmDataCacheLineLength ());
67 CacheRangeOperation (Address
, Length
,
68 ArmInvalidateInstructionCacheEntryToPoUByMVA
,
69 ArmInstructionCacheLineLength ());
71 ArmInstructionSynchronizationBarrier ();
78 WriteBackInvalidateDataCache (
87 WriteBackInvalidateDataCacheRange (
92 CacheRangeOperation(Address
, Length
, ArmCleanInvalidateDataCacheEntryByMVA
,
93 ArmDataCacheLineLength ());
108 WriteBackDataCacheRange (
113 CacheRangeOperation(Address
, Length
, ArmCleanDataCacheEntryByMVA
,
114 ArmDataCacheLineLength ());
120 InvalidateDataCacheRange (
125 CacheRangeOperation(Address
, Length
, ArmInvalidateDataCacheEntryByMVA
,
126 ArmDataCacheLineLength ());