]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.c
ArmPkg: remove cache maintenance by VA operation range size threshold
[mirror_edk2.git] / ArmPkg / Library / ArmCacheMaintenanceLib / ArmCacheMaintenanceLib.c
CommitLineData
1e57a462 1/** @file\r
2\r
3 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
01674afd 4 Copyright (c) 2011 - 2014, ARM Limited. All rights reserved.\r
3402aac7 5\r
1e57a462 6 This program and the accompanying materials\r
7 are licensed and made available under the terms and conditions of the BSD License\r
8 which accompanies this distribution. The full text of the license may be found at\r
9 http://opensource.org/licenses/bsd-license.php\r
10\r
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15#include <Base.h>\r
16#include <Library/ArmLib.h>\r
17#include <Library/PcdLib.h>\r
18\r
19VOID\r
20CacheRangeOperation (\r
21 IN VOID *Start,\r
22 IN UINTN Length,\r
1e57a462 23 IN LINE_OPERATION LineOperation\r
24 )\r
25{\r
26 UINTN ArmCacheLineLength = ArmDataCacheLineLength();\r
27 UINTN ArmCacheLineAlignmentMask = ArmCacheLineLength - 1;\r
3402aac7 28\r
6ea34e3a
AB
29 // Align address (rounding down)\r
30 UINTN AlignedAddress = (UINTN)Start - ((UINTN)Start & ArmCacheLineAlignmentMask);\r
31 UINTN EndAddress = (UINTN)Start + Length;\r
1e57a462 32\r
6ea34e3a
AB
33 // Perform the line operation on an address in each cache line\r
34 while (AlignedAddress < EndAddress) {\r
35 LineOperation(AlignedAddress);\r
36 AlignedAddress += ArmCacheLineLength;\r
1e57a462 37 }\r
38}\r
39\r
40VOID\r
41EFIAPI\r
42InvalidateInstructionCache (\r
43 VOID\r
44 )\r
45{\r
46 ArmCleanDataCache();\r
47 ArmInvalidateInstructionCache();\r
48}\r
49\r
50VOID\r
51EFIAPI\r
52InvalidateDataCache (\r
53 VOID\r
54 )\r
55{\r
56 ArmInvalidateDataCache();\r
57}\r
58\r
59VOID *\r
60EFIAPI\r
61InvalidateInstructionCacheRange (\r
62 IN VOID *Address,\r
63 IN UINTN Length\r
64 )\r
65{\r
6ea34e3a 66 CacheRangeOperation (Address, Length, ArmCleanDataCacheEntryByMVA);\r
1e57a462 67 ArmInvalidateInstructionCache ();\r
68 return Address;\r
69}\r
70\r
71VOID\r
72EFIAPI\r
73WriteBackInvalidateDataCache (\r
74 VOID\r
75 )\r
76{\r
77 ArmCleanInvalidateDataCache();\r
78}\r
79\r
80VOID *\r
81EFIAPI\r
82WriteBackInvalidateDataCacheRange (\r
83 IN VOID *Address,\r
84 IN UINTN Length\r
85 )\r
86{\r
6ea34e3a 87 CacheRangeOperation(Address, Length, ArmCleanInvalidateDataCacheEntryByMVA);\r
1e57a462 88 return Address;\r
89}\r
90\r
91VOID\r
92EFIAPI\r
93WriteBackDataCache (\r
94 VOID\r
95 )\r
96{\r
97 ArmCleanDataCache();\r
98}\r
99\r
100VOID *\r
101EFIAPI\r
102WriteBackDataCacheRange (\r
103 IN VOID *Address,\r
104 IN UINTN Length\r
105 )\r
106{\r
6ea34e3a 107 CacheRangeOperation(Address, Length, ArmCleanDataCacheEntryByMVA);\r
1e57a462 108 return Address;\r
109}\r
110\r
111VOID *\r
112EFIAPI\r
113InvalidateDataCacheRange (\r
114 IN VOID *Address,\r
115 IN UINTN Length\r
116 )\r
117{\r
6ea34e3a 118 CacheRangeOperation(Address, Length, ArmInvalidateDataCacheEntryByMVA);\r
1e57a462 119 return Address;\r
120}\r