]>
Commit | Line | Data |
---|---|---|
fb3df220 | 1 | /** @file\r |
50a64e5b | 2 | Provides services to maintain instruction and data caches.\r |
9095d37b | 3 | \r |
d80b2f71 | 4 | The Cache Maintenance Library provides abstractions for basic processor cache operations.\r |
5 | It removes the need to use assembly in C code.\r | |
9095d37b LG |
6 | \r |
7 | Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r | |
9344f092 | 8 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
fb3df220 | 9 | \r |
fb3df220 | 10 | **/\r |
11 | \r | |
12 | #ifndef __CACHE_MAINTENANCE_LIB__\r | |
13 | #define __CACHE_MAINTENANCE_LIB__\r | |
14 | \r | |
15 | /**\r | |
16 | Invalidates the entire instruction cache in cache coherency domain of the\r | |
17 | calling CPU.\r | |
18 | \r | |
fb3df220 | 19 | **/\r |
20 | VOID\r | |
21 | EFIAPI\r | |
22 | InvalidateInstructionCache (\r | |
23 | VOID\r | |
24 | );\r | |
25 | \r | |
26 | /**\r | |
27 | Invalidates a range of instruction cache lines in the cache coherency domain\r | |
28 | of the calling CPU.\r | |
29 | \r | |
30 | Invalidates the instruction cache lines specified by Address and Length. If\r | |
31 | Address is not aligned on a cache line boundary, then entire instruction\r | |
32 | cache line containing Address is invalidated. If Address + Length is not\r | |
33 | aligned on a cache line boundary, then the entire instruction cache line\r | |
34 | containing Address + Length -1 is invalidated. This function may choose to\r | |
35 | invalidate the entire instruction cache if that is more efficient than\r | |
1a2f870c | 36 | invalidating the specified range. If Length is 0, then no instruction cache\r |
fb3df220 | 37 | lines are invalidated. Address is returned.\r |
38 | \r | |
39 | If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().\r | |
40 | \r | |
41 | @param Address The base address of the instruction cache lines to\r | |
42 | invalidate. If the CPU is in a physical addressing mode, then\r | |
43 | Address is a physical address. If the CPU is in a virtual\r | |
44 | addressing mode, then Address is a virtual address.\r | |
45 | \r | |
46 | @param Length The number of bytes to invalidate from the instruction cache.\r | |
47 | \r | |
eb1c78db | 48 | @return Address.\r |
fb3df220 | 49 | \r |
50 | **/\r | |
51 | VOID *\r | |
52 | EFIAPI\r | |
53 | InvalidateInstructionCacheRange (\r | |
54 | IN VOID *Address,\r | |
55 | IN UINTN Length\r | |
56 | );\r | |
57 | \r | |
58 | /**\r | |
59 | Writes Back and Invalidates the entire data cache in cache coherency domain\r | |
60 | of the calling CPU.\r | |
61 | \r | |
62 | Writes Back and Invalidates the entire data cache in cache coherency domain\r | |
63 | of the calling CPU. This function guarantees that all dirty cache lines are\r | |
64 | written back to system memory, and also invalidates all the data cache lines\r | |
65 | in the cache coherency domain of the calling CPU.\r | |
66 | \r | |
67 | **/\r | |
68 | VOID\r | |
69 | EFIAPI\r | |
70 | WriteBackInvalidateDataCache (\r | |
71 | VOID\r | |
72 | );\r | |
73 | \r | |
74 | /**\r | |
75 | Writes Back and Invalidates a range of data cache lines in the cache\r | |
76 | coherency domain of the calling CPU.\r | |
77 | \r | |
78 | Writes Back and Invalidate the data cache lines specified by Address and\r | |
79 | Length. If Address is not aligned on a cache line boundary, then entire data\r | |
80 | cache line containing Address is written back and invalidated. If Address +\r | |
81 | Length is not aligned on a cache line boundary, then the entire data cache\r | |
82 | line containing Address + Length -1 is written back and invalidated. This\r | |
83 | function may choose to write back and invalidate the entire data cache if\r | |
84 | that is more efficient than writing back and invalidating the specified\r | |
1a2f870c | 85 | range. If Length is 0, then no data cache lines are written back and\r |
fb3df220 | 86 | invalidated. Address is returned.\r |
87 | \r | |
88 | If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().\r | |
89 | \r | |
90 | @param Address The base address of the data cache lines to write back and\r | |
91 | invalidate. If the CPU is in a physical addressing mode, then\r | |
92 | Address is a physical address. If the CPU is in a virtual\r | |
93 | addressing mode, then Address is a virtual address.\r | |
94 | @param Length The number of bytes to write back and invalidate from the\r | |
95 | data cache.\r | |
96 | \r | |
eb1c78db | 97 | @return Address of cache invalidation.\r |
fb3df220 | 98 | \r |
99 | **/\r | |
100 | VOID *\r | |
101 | EFIAPI\r | |
102 | WriteBackInvalidateDataCacheRange (\r | |
103 | IN VOID *Address,\r | |
104 | IN UINTN Length\r | |
105 | );\r | |
106 | \r | |
107 | /**\r | |
108 | Writes Back the entire data cache in cache coherency domain of the calling\r | |
109 | CPU.\r | |
110 | \r | |
111 | Writes Back the entire data cache in cache coherency domain of the calling\r | |
112 | CPU. This function guarantees that all dirty cache lines are written back to\r | |
113 | system memory. This function may also invalidate all the data cache lines in\r | |
114 | the cache coherency domain of the calling CPU.\r | |
115 | \r | |
116 | **/\r | |
117 | VOID\r | |
118 | EFIAPI\r | |
119 | WriteBackDataCache (\r | |
120 | VOID\r | |
121 | );\r | |
122 | \r | |
123 | /**\r | |
124 | Writes Back a range of data cache lines in the cache coherency domain of the\r | |
125 | calling CPU.\r | |
126 | \r | |
127 | Writes Back the data cache lines specified by Address and Length. If Address\r | |
128 | is not aligned on a cache line boundary, then entire data cache line\r | |
129 | containing Address is written back. If Address + Length is not aligned on a\r | |
130 | cache line boundary, then the entire data cache line containing Address +\r | |
131 | Length -1 is written back. This function may choose to write back the entire\r | |
132 | data cache if that is more efficient than writing back the specified range.\r | |
1a2f870c | 133 | If Length is 0, then no data cache lines are written back. This function may\r |
fb3df220 | 134 | also invalidate all the data cache lines in the specified range of the cache\r |
135 | coherency domain of the calling CPU. Address is returned.\r | |
136 | \r | |
137 | If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().\r | |
138 | \r | |
139 | @param Address The base address of the data cache lines to write back. If\r | |
140 | the CPU is in a physical addressing mode, then Address is a\r | |
141 | physical address. If the CPU is in a virtual addressing\r | |
142 | mode, then Address is a virtual address.\r | |
143 | @param Length The number of bytes to write back from the data cache.\r | |
144 | \r | |
eb1c78db | 145 | @return Address of cache written in main memory.\r |
fb3df220 | 146 | \r |
147 | **/\r | |
148 | VOID *\r | |
149 | EFIAPI\r | |
150 | WriteBackDataCacheRange (\r | |
151 | IN VOID *Address,\r | |
152 | IN UINTN Length\r | |
153 | );\r | |
154 | \r | |
155 | /**\r | |
156 | Invalidates the entire data cache in cache coherency domain of the calling\r | |
157 | CPU.\r | |
158 | \r | |
159 | Invalidates the entire data cache in cache coherency domain of the calling\r | |
160 | CPU. This function must be used with care because dirty cache lines are not\r | |
161 | written back to system memory. It is typically used for cache diagnostics. If\r | |
162 | the CPU does not support invalidation of the entire data cache, then a write\r | |
163 | back and invalidate operation should be performed on the entire data cache.\r | |
164 | \r | |
165 | **/\r | |
166 | VOID\r | |
167 | EFIAPI\r | |
168 | InvalidateDataCache (\r | |
169 | VOID\r | |
170 | );\r | |
171 | \r | |
172 | /**\r | |
173 | Invalidates a range of data cache lines in the cache coherency domain of the\r | |
174 | calling CPU.\r | |
175 | \r | |
176 | Invalidates the data cache lines specified by Address and Length. If Address\r | |
177 | is not aligned on a cache line boundary, then entire data cache line\r | |
178 | containing Address is invalidated. If Address + Length is not aligned on a\r | |
179 | cache line boundary, then the entire data cache line containing Address +\r | |
180 | Length -1 is invalidated. This function must never invalidate any cache lines\r | |
181 | outside the specified range. If Length is 0, the no data cache lines are\r | |
182 | invalidated. Address is returned. This function must be used with care\r | |
183 | because dirty cache lines are not written back to system memory. It is\r | |
184 | typically used for cache diagnostics. If the CPU does not support\r | |
185 | invalidation of a data cache range, then a write back and invalidate\r | |
186 | operation should be performed on the data cache range.\r | |
187 | \r | |
188 | If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().\r | |
189 | \r | |
190 | @param Address The base address of the data cache lines to invalidate. If\r | |
191 | the CPU is in a physical addressing mode, then Address is a\r | |
192 | physical address. If the CPU is in a virtual addressing mode,\r | |
193 | then Address is a virtual address.\r | |
194 | @param Length The number of bytes to invalidate from the data cache.\r | |
195 | \r | |
eb1c78db | 196 | @return Address.\r |
fb3df220 | 197 | \r |
198 | **/\r | |
199 | VOID *\r | |
200 | EFIAPI\r | |
201 | InvalidateDataCacheRange (\r | |
202 | IN VOID *Address,\r | |
203 | IN UINTN Length\r | |
204 | );\r | |
205 | \r | |
206 | #endif\r |