3 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include <Library/ArmLib.h>
16 #include <Library/PcdLib.h>
22 IN CACHE_OPERATION CacheOperation
,
23 IN LINE_OPERATION LineOperation
26 UINTN ArmCacheLineLength
= ArmDataCacheLineLength();
27 UINTN ArmCacheLineAlignmentMask
= ArmCacheLineLength
- 1;
28 UINTN ArmCacheOperationThreshold
= PcdGet32(PcdArmCacheOperationThreshold
);
30 if ((CacheOperation
!= NULL
) && (Length
>= ArmCacheOperationThreshold
)) {
33 // Align address (rounding down)
34 UINTN AlignedAddress
= (UINTN
)Start
- ((UINTN
)Start
& ArmCacheLineAlignmentMask
);
35 UINTN EndAddress
= (UINTN
)Start
+ Length
;
37 // Perform the line operation on an address in each cache line
38 while (AlignedAddress
< EndAddress
) {
39 LineOperation(AlignedAddress
);
40 AlignedAddress
+= ArmCacheLineLength
;
47 InvalidateInstructionCache (
52 ArmInvalidateInstructionCache();
61 ArmInvalidateDataCache();
66 InvalidateInstructionCacheRange (
71 CacheRangeOperation (Address
, Length
, ArmCleanDataCacheToPoU
, ArmCleanDataCacheEntryByMVA
);
72 ArmInvalidateInstructionCache ();
78 WriteBackInvalidateDataCache (
82 ArmCleanInvalidateDataCache();
87 WriteBackInvalidateDataCacheRange (
92 CacheRangeOperation(Address
, Length
, ArmCleanInvalidateDataCache
, ArmCleanInvalidateDataCacheEntryByMVA
);
107 WriteBackDataCacheRange (
112 CacheRangeOperation(Address
, Length
, ArmCleanDataCache
, ArmCleanDataCacheEntryByMVA
);
118 InvalidateDataCacheRange (
123 CacheRangeOperation(Address
, Length
, NULL
, ArmInvalidateDataCacheEntryByMVA
);