]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BaseCacheMaintenanceLib/IpfCache.c
Change NameGuid to FvFileName
[mirror_edk2.git] / MdePkg / Library / BaseCacheMaintenanceLib / IpfCache.c
CommitLineData
e1f414b6 1/** @file\r
2 Cache Maintenance Functions.\r
3\r
4 Copyright (c) 2006, Intel Corporation<BR>\r
5 All rights reserved. This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15\r
16//\r
17// Include common header file for this module.\r
18//\r
f734a10a
A
19#include <Base.h>\r
20#include <Library/BaseLib.h>\r
21#include <Library/DebugLib.h>\r
e1f414b6 22\r
23/**\r
24 Invalidates the entire instruction cache in cache coherency domain of the\r
25 calling CPU.\r
26\r
27 Invalidates the entire instruction cache in cache coherency domain of the\r
28 calling CPU.\r
29\r
30**/\r
31VOID\r
32EFIAPI\r
33InvalidateInstructionCache (\r
34 VOID\r
35 )\r
36{\r
37 PalCallStatic (NULL, 1, 1, 1, 0);\r
38}\r
39\r
40/**\r
41 Invalidates a range of instruction cache lines in the cache coherency domain\r
42 of the calling CPU.\r
43\r
44 Invalidates the instruction cache lines specified by Address and Length. If\r
45 Address is not aligned on a cache line boundary, then entire instruction\r
46 cache line containing Address is invalidated. If Address + Length is not\r
47 aligned on a cache line boundary, then the entire instruction cache line\r
48 containing Address + Length -1 is invalidated. This function may choose to\r
49 invalidate the entire instruction cache if that is more efficient than\r
50 invalidating the specified range. If Length is 0, the no instruction cache\r
51 lines are invalidated. Address is returned.\r
52\r
53 If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().\r
54\r
55 @param Address The base address of the instruction cache lines to\r
56 invalidate. If the CPU is in a physical addressing mode, then\r
57 Address is a physical address. If the CPU is in a virtual\r
58 addressing mode, then Address is a virtual address.\r
59\r
60 @param Length The number of bytes to invalidate from the instruction cache.\r
61\r
62 @return Address\r
63\r
64**/\r
65VOID *\r
66EFIAPI\r
67InvalidateInstructionCacheRange (\r
68 IN VOID *Address,\r
69 IN UINTN Length\r
70 )\r
71{\r
72 return IpfFlushCacheRange (Address, Length);\r
73}\r
74\r
75/**\r
76 Writes Back and Invalidates the entire data cache in cache coherency domain\r
77 of the calling CPU.\r
78\r
79 Writes Back and Invalidates the entire data cache in cache coherency domain\r
80 of the calling CPU. This function guarantees that all dirty cache lines are\r
81 written back to system memory, and also invalidates all the data cache lines\r
82 in the cache coherency domain of the calling CPU.\r
83\r
84**/\r
85VOID\r
86EFIAPI\r
87WriteBackInvalidateDataCache (\r
88 VOID\r
89 )\r
90{\r
91 PalCallStatic (NULL, 1, 2, 1, 0);\r
92}\r
93\r
94/**\r
95 Writes Back and Invalidates a range of data cache lines in the cache\r
96 coherency domain of the calling CPU.\r
97\r
98 Writes Back and Invalidate the data cache lines specified by Address and\r
99 Length. If Address is not aligned on a cache line boundary, then entire data\r
100 cache line containing Address is written back and invalidated. If Address +\r
101 Length is not aligned on a cache line boundary, then the entire data cache\r
102 line containing Address + Length -1 is written back and invalidated. This\r
103 function may choose to write back and invalidate the entire data cache if\r
104 that is more efficient than writing back and invalidating the specified\r
105 range. If Length is 0, the no data cache lines are written back and\r
106 invalidated. Address is returned.\r
107\r
108 If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().\r
109\r
110 @param Address The base address of the data cache lines to write back and\r
111 invalidate. If the CPU is in a physical addressing mode, then\r
112 Address is a physical address. If the CPU is in a virtual\r
113 addressing mode, then Address is a virtual address.\r
114 @param Length The number of bytes to write back and invalidate from the\r
115 data cache.\r
116\r
117 @return Address\r
118\r
119**/\r
120VOID *\r
121EFIAPI\r
122WriteBackInvalidateDataCacheRange (\r
123 IN VOID *Address,\r
124 IN UINTN Length\r
125 )\r
126{\r
127 ASSERT (Length <= MAX_ADDRESS - (UINTN)Address + 1);\r
128\r
129 return IpfFlushCacheRange (Address, Length);\r
130}\r
131\r
132/**\r
133 Writes Back the entire data cache in cache coherency domain of the calling\r
134 CPU.\r
135\r
136 Writes Back the entire data cache in cache coherency domain of the calling\r
137 CPU. This function guarantees that all dirty cache lines are written back to\r
138 system memory. This function may also invalidate all the data cache lines in\r
139 the cache coherency domain of the calling CPU.\r
140\r
141**/\r
142VOID\r
143EFIAPI\r
144WriteBackDataCache (\r
145 VOID\r
146 )\r
147{\r
148 PalCallStatic (NULL, 1, 2, 0, 0);\r
149}\r
150\r
151/**\r
152 Writes Back a range of data cache lines in the cache coherency domain of the\r
153 calling CPU.\r
154\r
155 Writes Back the data cache lines specified by Address and Length. If Address\r
156 is not aligned on a cache line boundary, then entire data cache line\r
157 containing Address is written back. If Address + Length is not aligned on a\r
158 cache line boundary, then the entire data cache line containing Address +\r
159 Length -1 is written back. This function may choose to write back the entire\r
160 data cache if that is more efficient than writing back the specified range.\r
161 If Length is 0, the no data cache lines are written back. This function may\r
162 also invalidate all the data cache lines in the specified range of the cache\r
163 coherency domain of the calling CPU. Address is returned.\r
164\r
165 If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().\r
166\r
167 @param Address The base address of the data cache lines to write back. If\r
168 the CPU is in a physical addressing mode, then Address is a\r
169 physical address. If the CPU is in a virtual addressing\r
170 mode, then Address is a virtual address.\r
171 @param Length The number of bytes to write back from the data cache.\r
172\r
173 @return Address\r
174\r
175**/\r
176VOID *\r
177EFIAPI\r
178WriteBackDataCacheRange (\r
179 IN VOID *Address,\r
180 IN UINTN Length\r
181 )\r
182{\r
183 ASSERT (Length <= MAX_ADDRESS - (UINTN)Address + 1);\r
184\r
185 return IpfFlushCacheRange (Address, Length);\r
186}\r
187\r
188/**\r
189 Invalidates the entire data cache in cache coherency domain of the calling\r
190 CPU.\r
191\r
192 Invalidates the entire data cache in cache coherency domain of the calling\r
193 CPU. This function must be used with care because dirty cache lines are not\r
194 written back to system memory. It is typically used for cache diagnostics. If\r
195 the CPU does not support invalidation of the entire data cache, then a write\r
196 back and invalidate operation should be performed on the entire data cache.\r
197\r
198**/\r
199VOID\r
200EFIAPI\r
201InvalidateDataCache (\r
202 VOID\r
203 )\r
204{\r
205 WriteBackInvalidateDataCache ();\r
206}\r
207\r
208/**\r
209 Invalidates a range of data cache lines in the cache coherency domain of the\r
210 calling CPU.\r
211\r
212 Invalidates the data cache lines specified by Address and Length. If Address\r
213 is not aligned on a cache line boundary, then entire data cache line\r
214 containing Address is invalidated. If Address + Length is not aligned on a\r
215 cache line boundary, then the entire data cache line containing Address +\r
216 Length -1 is invalidated. This function must never invalidate any cache lines\r
217 outside the specified range. If Length is 0, the no data cache lines are\r
218 invalidated. Address is returned. This function must be used with care\r
219 because dirty cache lines are not written back to system memory. It is\r
220 typically used for cache diagnostics. If the CPU does not support\r
221 invalidation of a data cache range, then a write back and invalidate\r
222 operation should be performed on the data cache range.\r
223\r
224 If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().\r
225\r
226 @param Address The base address of the data cache lines to invalidate. If\r
227 the CPU is in a physical addressing mode, then Address is a\r
228 physical address. If the CPU is in a virtual addressing mode,\r
229 then Address is a virtual address.\r
230 @param Length The number of bytes to invalidate from the data cache.\r
231\r
232 @return Address\r
233\r
234**/\r
235VOID *\r
236EFIAPI\r
237InvalidateDataCacheRange (\r
238 IN VOID *Address,\r
239 IN UINTN Length\r
240 )\r
241{\r
242 return IpfFlushCacheRange (Address, Length);\r
243}\r