3 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
4 Copyright (c) 2011 - 2014, 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
= LineLength
- 1;
25 // Align address (rounding down)
26 UINTN AlignedAddress
= (UINTN
)Start
- ((UINTN
)Start
& ArmCacheLineAlignmentMask
);
27 UINTN EndAddress
= (UINTN
)Start
+ Length
;
29 // Perform the line operation on an address in each cache line
30 while (AlignedAddress
< EndAddress
) {
31 LineOperation(AlignedAddress
);
32 AlignedAddress
+= LineLength
;
34 ArmDataSynchronizationBarrier ();
39 InvalidateInstructionCache (
57 InvalidateInstructionCacheRange (
62 CacheRangeOperation (Address
, Length
, ArmCleanDataCacheEntryToPoUByMVA
,
63 ArmDataCacheLineLength ());
64 CacheRangeOperation (Address
, Length
,
65 ArmInvalidateInstructionCacheEntryToPoUByMVA
,
66 ArmInstructionCacheLineLength ());
68 ArmInstructionSynchronizationBarrier ();
75 WriteBackInvalidateDataCache (
84 WriteBackInvalidateDataCacheRange (
89 CacheRangeOperation(Address
, Length
, ArmCleanInvalidateDataCacheEntryByMVA
,
90 ArmDataCacheLineLength ());
105 WriteBackDataCacheRange (
110 CacheRangeOperation(Address
, Length
, ArmCleanDataCacheEntryByMVA
,
111 ArmDataCacheLineLength ());
117 InvalidateDataCacheRange (
122 CacheRangeOperation(Address
, Length
, ArmInvalidateDataCacheEntryByMVA
,
123 ArmDataCacheLineLength ());