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