3 Copyright (c) 2008-2009, Apple Inc. All rights reserved.
5 All rights reserved. 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
))
36 // Align address (rounding down)
37 UINTN AlignedAddress
= (UINTN
)Start
- ((UINTN
)Start
& ArmCacheLineAlignmentMask
);
38 UINTN EndAddress
= (UINTN
)Start
+ Length
;
40 // Perform the line operation on an address in each cache line
41 while (AlignedAddress
< EndAddress
)
43 LineOperation(AlignedAddress
);
44 AlignedAddress
+= ArmCacheLineLength
;
51 InvalidateInstructionCache (
56 ArmInvalidateInstructionCache();
65 ArmInvalidateDataCache();
70 InvalidateInstructionCacheRange (
75 CacheRangeOperation(Address
, Length
, ArmCleanDataCache
, ArmCleanDataCacheEntryByMVA
);
76 ArmInvalidateInstructionCache();
82 WriteBackInvalidateDataCache (
86 ArmCleanInvalidateDataCache();
91 WriteBackInvalidateDataCacheRange (
96 CacheRangeOperation(Address
, Length
, ArmCleanInvalidateDataCache
, ArmCleanInvalidateDataCacheEntryByMVA
);
111 WriteBackDataCacheRange (
116 CacheRangeOperation(Address
, Length
, ArmCleanDataCache
, ArmCleanDataCacheEntryByMVA
);
122 InvalidateDataCacheRange (
127 CacheRangeOperation(Address
, Length
, NULL
, ArmInvalidateDataCacheEntryByMVA
);