3 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
4 Copyright (c) 2011 - 2014, ARM Limited. All rights reserved.
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.
16 #include <Library/ArmLib.h>
17 #include <Library/DebugLib.h>
18 #include <Library/PcdLib.h>
25 IN LINE_OPERATION LineOperation
,
29 UINTN ArmCacheLineAlignmentMask
= LineLength
- 1;
31 // Align address (rounding down)
32 UINTN AlignedAddress
= (UINTN
)Start
- ((UINTN
)Start
& ArmCacheLineAlignmentMask
);
33 UINTN EndAddress
= (UINTN
)Start
+ Length
;
35 // Perform the line operation on an address in each cache line
36 while (AlignedAddress
< EndAddress
) {
37 LineOperation(AlignedAddress
);
38 AlignedAddress
+= LineLength
;
40 ArmDataSynchronizationBarrier ();
45 InvalidateInstructionCache (
63 InvalidateInstructionCacheRange (
68 CacheRangeOperation (Address
, Length
, ArmCleanDataCacheEntryToPoUByMVA
,
69 ArmDataCacheLineLength ());
70 CacheRangeOperation (Address
, Length
,
71 ArmInvalidateInstructionCacheEntryToPoUByMVA
,
72 ArmInstructionCacheLineLength ());
74 ArmInstructionSynchronizationBarrier ();
81 WriteBackInvalidateDataCache (
90 WriteBackInvalidateDataCacheRange (
95 CacheRangeOperation(Address
, Length
, ArmCleanInvalidateDataCacheEntryByMVA
,
96 ArmDataCacheLineLength ());
111 WriteBackDataCacheRange (
116 CacheRangeOperation(Address
, Length
, ArmCleanDataCacheEntryByMVA
,
117 ArmDataCacheLineLength ());
123 InvalidateDataCacheRange (
128 CacheRangeOperation(Address
, Length
, ArmInvalidateDataCacheEntryByMVA
,
129 ArmDataCacheLineLength ());