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