]>
git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
2 RISC-V specific functionality for cache.
4 Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #include <Library/BaseLib.h>
11 #include <Library/DebugLib.h>
14 RISC-V invalidate instruction cache.
19 RiscVInvalidateInstCacheAsm (
24 RISC-V invalidate data cache.
29 RiscVInvalidateDataCacheAsm (
34 Invalidates the entire instruction cache in cache coherency domain of the
40 InvalidateInstructionCache (
44 RiscVInvalidateInstCacheAsm ();
48 Invalidates a range of instruction cache lines in the cache coherency domain
51 Invalidates the instruction cache lines specified by Address and Length. If
52 Address is not aligned on a cache line boundary, then entire instruction
53 cache line containing Address is invalidated. If Address + Length is not
54 aligned on a cache line boundary, then the entire instruction cache line
55 containing Address + Length -1 is invalidated. This function may choose to
56 invalidate the entire instruction cache if that is more efficient than
57 invalidating the specified range. If Length is 0, then no instruction cache
58 lines are invalidated. Address is returned.
60 If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().
62 @param Address The base address of the instruction cache lines to
63 invalidate. If the CPU is in a physical addressing mode, then
64 Address is a physical address. If the CPU is in a virtual
65 addressing mode, then Address is a virtual address.
67 @param Length The number of bytes to invalidate from the instruction cache.
74 InvalidateInstructionCacheRange (
79 DEBUG ((DEBUG_ERROR
, "%a:RISC-V unsupported function.\n", __FUNCTION__
));
84 Writes back and invalidates the entire data cache in cache coherency domain
87 Writes back and invalidates the entire data cache in cache coherency domain
88 of the calling CPU. This function guarantees that all dirty cache lines are
89 written back to system memory, and also invalidates all the data cache lines
90 in the cache coherency domain of the calling CPU.
95 WriteBackInvalidateDataCache (
99 DEBUG ((DEBUG_ERROR
, "%a:RISC-V unsupported function.\n", __FUNCTION__
));
103 Writes back and invalidates a range of data cache lines in the cache
104 coherency domain of the calling CPU.
106 Writes back and invalidates the data cache lines specified by Address and
107 Length. If Address is not aligned on a cache line boundary, then entire data
108 cache line containing Address is written back and invalidated. If Address +
109 Length is not aligned on a cache line boundary, then the entire data cache
110 line containing Address + Length -1 is written back and invalidated. This
111 function may choose to write back and invalidate the entire data cache if
112 that is more efficient than writing back and invalidating the specified
113 range. If Length is 0, then no data cache lines are written back and
114 invalidated. Address is returned.
116 If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().
118 @param Address The base address of the data cache lines to write back and
119 invalidate. If the CPU is in a physical addressing mode, then
120 Address is a physical address. If the CPU is in a virtual
121 addressing mode, then Address is a virtual address.
122 @param Length The number of bytes to write back and invalidate from the
125 @return Address of cache invalidation.
130 WriteBackInvalidateDataCacheRange (
135 DEBUG ((DEBUG_ERROR
, "%a:RISC-V unsupported function.\n", __FUNCTION__
));
140 Writes back the entire data cache in cache coherency domain of the calling
143 Writes back the entire data cache in cache coherency domain of the calling
144 CPU. This function guarantees that all dirty cache lines are written back to
145 system memory. This function may also invalidate all the data cache lines in
146 the cache coherency domain of the calling CPU.
155 DEBUG ((DEBUG_ERROR
, "%a:RISC-V unsupported function.\n", __FUNCTION__
));
159 Writes back a range of data cache lines in the cache coherency domain of the
162 Writes back the data cache lines specified by Address and Length. If Address
163 is not aligned on a cache line boundary, then entire data cache line
164 containing Address is written back. If Address + Length is not aligned on a
165 cache line boundary, then the entire data cache line containing Address +
166 Length -1 is written back. This function may choose to write back the entire
167 data cache if that is more efficient than writing back the specified range.
168 If Length is 0, then no data cache lines are written back. This function may
169 also invalidate all the data cache lines in the specified range of the cache
170 coherency domain of the calling CPU. Address is returned.
172 If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().
174 @param Address The base address of the data cache lines to write back. If
175 the CPU is in a physical addressing mode, then Address is a
176 physical address. If the CPU is in a virtual addressing
177 mode, then Address is a virtual address.
178 @param Length The number of bytes to write back from the data cache.
180 @return Address of cache written in main memory.
185 WriteBackDataCacheRange (
190 DEBUG ((DEBUG_ERROR
, "%a:RISC-V unsupported function.\n", __FUNCTION__
));
195 Invalidates the entire data cache in cache coherency domain of the calling
198 Invalidates the entire data cache in cache coherency domain of the calling
199 CPU. This function must be used with care because dirty cache lines are not
200 written back to system memory. It is typically used for cache diagnostics. If
201 the CPU does not support invalidation of the entire data cache, then a write
202 back and invalidate operation should be performed on the entire data cache.
207 InvalidateDataCache (
211 RiscVInvalidateDataCacheAsm ();
215 Invalidates a range of data cache lines in the cache coherency domain of the
218 Invalidates the data cache lines specified by Address and Length. If Address
219 is not aligned on a cache line boundary, then entire data cache line
220 containing Address is invalidated. If Address + Length is not aligned on a
221 cache line boundary, then the entire data cache line containing Address +
222 Length -1 is invalidated. This function must never invalidate any cache lines
223 outside the specified range. If Length is 0, then no data cache lines are
224 invalidated. Address is returned. This function must be used with care
225 because dirty cache lines are not written back to system memory. It is
226 typically used for cache diagnostics. If the CPU does not support
227 invalidation of a data cache range, then a write back and invalidate
228 operation should be performed on the data cache range.
230 If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().
232 @param Address The base address of the data cache lines to invalidate. If
233 the CPU is in a physical addressing mode, then Address is a
234 physical address. If the CPU is in a virtual addressing mode,
235 then Address is a virtual address.
236 @param Length The number of bytes to invalidate from the data cache.
243 InvalidateDataCacheRange (
248 DEBUG ((DEBUG_ERROR
, "%a:RISC-V unsupported function.\n", __FUNCTION__
));