]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BaseCacheMaintenanceLib/IpfCache.c
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2882 6f19259b...
[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
19#include "CommonHeader.h"\r
20\r
21/**\r
22 Invalidates the entire instruction cache in cache coherency domain of the\r
23 calling CPU.\r
24\r
25 Invalidates the entire instruction cache in cache coherency domain of the\r
26 calling CPU.\r
27\r
28**/\r
29VOID\r
30EFIAPI\r
31InvalidateInstructionCache (\r
32 VOID\r
33 )\r
34{\r
35 PalCallStatic (NULL, 1, 1, 1, 0);\r
36}\r
37\r
38/**\r
39 Invalidates a range of instruction cache lines in the cache coherency domain\r
40 of the calling CPU.\r
41\r
42 Invalidates the instruction cache lines specified by Address and Length. If\r
43 Address is not aligned on a cache line boundary, then entire instruction\r
44 cache line containing Address is invalidated. If Address + Length is not\r
45 aligned on a cache line boundary, then the entire instruction cache line\r
46 containing Address + Length -1 is invalidated. This function may choose to\r
47 invalidate the entire instruction cache if that is more efficient than\r
48 invalidating the specified range. If Length is 0, the no instruction cache\r
49 lines are invalidated. Address is returned.\r
50\r
51 If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().\r
52\r
53 @param Address The base address of the instruction cache lines to\r
54 invalidate. If the CPU is in a physical addressing mode, then\r
55 Address is a physical address. If the CPU is in a virtual\r
56 addressing mode, then Address is a virtual address.\r
57\r
58 @param Length The number of bytes to invalidate from the instruction cache.\r
59\r
60 @return Address\r
61\r
62**/\r
63VOID *\r
64EFIAPI\r
65InvalidateInstructionCacheRange (\r
66 IN VOID *Address,\r
67 IN UINTN Length\r
68 )\r
69{\r
70 return IpfFlushCacheRange (Address, Length);\r
71}\r
72\r
73/**\r
74 Writes Back and Invalidates the entire data cache in cache coherency domain\r
75 of the calling CPU.\r
76\r
77 Writes Back and Invalidates the entire data cache in cache coherency domain\r
78 of the calling CPU. This function guarantees that all dirty cache lines are\r
79 written back to system memory, and also invalidates all the data cache lines\r
80 in the cache coherency domain of the calling CPU.\r
81\r
82**/\r
83VOID\r
84EFIAPI\r
85WriteBackInvalidateDataCache (\r
86 VOID\r
87 )\r
88{\r
89 PalCallStatic (NULL, 1, 2, 1, 0);\r
90}\r
91\r
92/**\r
93 Writes Back and Invalidates a range of data cache lines in the cache\r
94 coherency domain of the calling CPU.\r
95\r
96 Writes Back and Invalidate the data cache lines specified by Address and\r
97 Length. If Address is not aligned on a cache line boundary, then entire data\r
98 cache line containing Address is written back and invalidated. If Address +\r
99 Length is not aligned on a cache line boundary, then the entire data cache\r
100 line containing Address + Length -1 is written back and invalidated. This\r
101 function may choose to write back and invalidate the entire data cache if\r
102 that is more efficient than writing back and invalidating the specified\r
103 range. If Length is 0, the no data cache lines are written back and\r
104 invalidated. Address is returned.\r
105\r
106 If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().\r
107\r
108 @param Address The base address of the data cache lines to write back and\r
109 invalidate. If the CPU is in a physical addressing mode, then\r
110 Address is a physical address. If the CPU is in a virtual\r
111 addressing mode, then Address is a virtual address.\r
112 @param Length The number of bytes to write back and invalidate from the\r
113 data cache.\r
114\r
115 @return Address\r
116\r
117**/\r
118VOID *\r
119EFIAPI\r
120WriteBackInvalidateDataCacheRange (\r
121 IN VOID *Address,\r
122 IN UINTN Length\r
123 )\r
124{\r
125 ASSERT (Length <= MAX_ADDRESS - (UINTN)Address + 1);\r
126\r
127 return IpfFlushCacheRange (Address, Length);\r
128}\r
129\r
130/**\r
131 Writes Back the entire data cache in cache coherency domain of the calling\r
132 CPU.\r
133\r
134 Writes Back the entire data cache in cache coherency domain of the calling\r
135 CPU. This function guarantees that all dirty cache lines are written back to\r
136 system memory. This function may also invalidate all the data cache lines in\r
137 the cache coherency domain of the calling CPU.\r
138\r
139**/\r
140VOID\r
141EFIAPI\r
142WriteBackDataCache (\r
143 VOID\r
144 )\r
145{\r
146 PalCallStatic (NULL, 1, 2, 0, 0);\r
147}\r
148\r
149/**\r
150 Writes Back a range of data cache lines in the cache coherency domain of the\r
151 calling CPU.\r
152\r
153 Writes Back the data cache lines specified by Address and Length. If Address\r
154 is not aligned on a cache line boundary, then entire data cache line\r
155 containing Address is written back. If Address + Length is not aligned on a\r
156 cache line boundary, then the entire data cache line containing Address +\r
157 Length -1 is written back. This function may choose to write back the entire\r
158 data cache if that is more efficient than writing back the specified range.\r
159 If Length is 0, the no data cache lines are written back. This function may\r
160 also invalidate all the data cache lines in the specified range of the cache\r
161 coherency domain of the calling CPU. Address is returned.\r
162\r
163 If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().\r
164\r
165 @param Address The base address of the data cache lines to write back. If\r
166 the CPU is in a physical addressing mode, then Address is a\r
167 physical address. If the CPU is in a virtual addressing\r
168 mode, then Address is a virtual address.\r
169 @param Length The number of bytes to write back from the data cache.\r
170\r
171 @return Address\r
172\r
173**/\r
174VOID *\r
175EFIAPI\r
176WriteBackDataCacheRange (\r
177 IN VOID *Address,\r
178 IN UINTN Length\r
179 )\r
180{\r
181 ASSERT (Length <= MAX_ADDRESS - (UINTN)Address + 1);\r
182\r
183 return IpfFlushCacheRange (Address, Length);\r
184}\r
185\r
186/**\r
187 Invalidates the entire data cache in cache coherency domain of the calling\r
188 CPU.\r
189\r
190 Invalidates the entire data cache in cache coherency domain of the calling\r
191 CPU. This function must be used with care because dirty cache lines are not\r
192 written back to system memory. It is typically used for cache diagnostics. If\r
193 the CPU does not support invalidation of the entire data cache, then a write\r
194 back and invalidate operation should be performed on the entire data cache.\r
195\r
196**/\r
197VOID\r
198EFIAPI\r
199InvalidateDataCache (\r
200 VOID\r
201 )\r
202{\r
203 WriteBackInvalidateDataCache ();\r
204}\r
205\r
206/**\r
207 Invalidates a range of data cache lines in the cache coherency domain of the\r
208 calling CPU.\r
209\r
210 Invalidates the data cache lines specified by Address and Length. If Address\r
211 is not aligned on a cache line boundary, then entire data cache line\r
212 containing Address is invalidated. If Address + Length is not aligned on a\r
213 cache line boundary, then the entire data cache line containing Address +\r
214 Length -1 is invalidated. This function must never invalidate any cache lines\r
215 outside the specified range. If Length is 0, the no data cache lines are\r
216 invalidated. Address is returned. This function must be used with care\r
217 because dirty cache lines are not written back to system memory. It is\r
218 typically used for cache diagnostics. If the CPU does not support\r
219 invalidation of a data cache range, then a write back and invalidate\r
220 operation should be performed on the data cache range.\r
221\r
222 If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().\r
223\r
224 @param Address The base address of the data cache lines to invalidate. If\r
225 the CPU is in a physical addressing mode, then Address is a\r
226 physical address. If the CPU is in a virtual addressing mode,\r
227 then Address is a virtual address.\r
228 @param Length The number of bytes to invalidate from the data cache.\r
229\r
230 @return Address\r
231\r
232**/\r
233VOID *\r
234EFIAPI\r
235InvalidateDataCacheRange (\r
236 IN VOID *Address,\r
237 IN UINTN Length\r
238 )\r
239{\r
240 return IpfFlushCacheRange (Address, Length);\r
241}\r