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/PcdLib.h>
23 IN CACHE_OPERATION CacheOperation
,
24 IN LINE_OPERATION LineOperation
27 UINTN ArmCacheLineLength
= ArmDataCacheLineLength();
28 UINTN ArmCacheLineAlignmentMask
= ArmCacheLineLength
- 1;
29 UINTN ArmCacheOperationThreshold
= PcdGet32(PcdArmCacheOperationThreshold
);
31 if ((CacheOperation
!= NULL
) && (Length
>= ArmCacheOperationThreshold
)) {
32 ArmDrainWriteBuffer ();
35 // Align address (rounding down)
36 UINTN AlignedAddress
= (UINTN
)Start
- ((UINTN
)Start
& ArmCacheLineAlignmentMask
);
37 UINTN EndAddress
= (UINTN
)Start
+ Length
;
39 // Perform the line operation on an address in each cache line
40 while (AlignedAddress
< EndAddress
) {
41 LineOperation(AlignedAddress
);
42 AlignedAddress
+= ArmCacheLineLength
;
49 InvalidateInstructionCache (
54 ArmInvalidateInstructionCache();
63 ArmInvalidateDataCache();
68 InvalidateInstructionCacheRange (
73 CacheRangeOperation (Address
, Length
, ArmCleanDataCacheToPoU
, ArmCleanDataCacheEntryByMVA
);
74 ArmInvalidateInstructionCache ();
80 WriteBackInvalidateDataCache (
84 ArmCleanInvalidateDataCache();
89 WriteBackInvalidateDataCacheRange (
94 CacheRangeOperation(Address
, Length
, ArmCleanInvalidateDataCache
, ArmCleanInvalidateDataCacheEntryByMVA
);
109 WriteBackDataCacheRange (
114 CacheRangeOperation(Address
, Length
, ArmCleanDataCache
, ArmCleanDataCacheEntryByMVA
);
120 InvalidateDataCacheRange (
125 CacheRangeOperation(Address
, Length
, NULL
, ArmInvalidateDataCacheEntryByMVA
);