]>
Commit | Line | Data |
---|---|---|
ac644614 | 1 | /** @file\r |
50a64e5b | 2 | Provides string functions, linked list functions, math functions, synchronization\r |
ae591c14 | 3 | functions, file path functions, and CPU architecture-specific functions.\r |
ac644614 | 4 | \r |
ae591c14 | 5 | Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r |
9df063a0 HT |
6 | Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r |
7 | This program and the accompanying materials\r | |
50a64e5b | 8 | are licensed and made available under the terms and conditions of the BSD License\r |
9 | which accompanies this distribution. The full text of the license may be found at\r | |
af2dc6a7 | 10 | http://opensource.org/licenses/bsd-license.php.\r |
ac644614 | 11 | \r |
50a64e5b | 12 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r |
13 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
ac644614 | 14 | \r |
15 | **/\r | |
16 | \r | |
17 | #ifndef __BASE_LIB__\r | |
18 | #define __BASE_LIB__\r | |
19 | \r | |
1106ffe1 | 20 | //\r |
1a2f870c | 21 | // Definitions for architecture-specific types\r |
1106ffe1 | 22 | //\r |
ac644614 | 23 | #if defined (MDE_CPU_IA32)\r |
fc30687f | 24 | ///\r |
af2dc6a7 | 25 | /// The IA-32 architecture context buffer used by SetJump() and LongJump().\r |
fc30687f | 26 | ///\r |
ac644614 | 27 | typedef struct {\r |
28 | UINT32 Ebx;\r | |
29 | UINT32 Esi;\r | |
30 | UINT32 Edi;\r | |
31 | UINT32 Ebp;\r | |
32 | UINT32 Esp;\r | |
33 | UINT32 Eip;\r | |
34 | } BASE_LIBRARY_JUMP_BUFFER;\r | |
35 | \r | |
36 | #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 4\r | |
37 | \r | |
aa4df547 | 38 | #endif // defined (MDE_CPU_IA32)\r |
39 | \r | |
40 | #if defined (MDE_CPU_IPF)\r | |
ac644614 | 41 | \r |
fc30687f | 42 | ///\r |
af2dc6a7 | 43 | /// The Itanium architecture context buffer used by SetJump() and LongJump().\r |
fc30687f | 44 | ///\r |
ac644614 | 45 | typedef struct {\r |
46 | UINT64 F2[2];\r | |
47 | UINT64 F3[2];\r | |
48 | UINT64 F4[2];\r | |
49 | UINT64 F5[2];\r | |
50 | UINT64 F16[2];\r | |
51 | UINT64 F17[2];\r | |
52 | UINT64 F18[2];\r | |
53 | UINT64 F19[2];\r | |
54 | UINT64 F20[2];\r | |
55 | UINT64 F21[2];\r | |
56 | UINT64 F22[2];\r | |
57 | UINT64 F23[2];\r | |
58 | UINT64 F24[2];\r | |
59 | UINT64 F25[2];\r | |
60 | UINT64 F26[2];\r | |
61 | UINT64 F27[2];\r | |
62 | UINT64 F28[2];\r | |
63 | UINT64 F29[2];\r | |
64 | UINT64 F30[2];\r | |
65 | UINT64 F31[2];\r | |
66 | UINT64 R4;\r | |
67 | UINT64 R5;\r | |
68 | UINT64 R6;\r | |
69 | UINT64 R7;\r | |
70 | UINT64 SP;\r | |
71 | UINT64 BR0;\r | |
72 | UINT64 BR1;\r | |
73 | UINT64 BR2;\r | |
74 | UINT64 BR3;\r | |
75 | UINT64 BR4;\r | |
76 | UINT64 BR5;\r | |
77 | UINT64 InitialUNAT;\r | |
78 | UINT64 AfterSpillUNAT;\r | |
79 | UINT64 PFS;\r | |
80 | UINT64 BSP;\r | |
81 | UINT64 Predicates;\r | |
82 | UINT64 LoopCount;\r | |
83 | UINT64 FPSR;\r | |
84 | } BASE_LIBRARY_JUMP_BUFFER;\r | |
85 | \r | |
86 | #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 0x10\r | |
87 | \r | |
aa4df547 | 88 | #endif // defined (MDE_CPU_IPF)\r |
89 | \r | |
90 | #if defined (MDE_CPU_X64)\r | |
fc30687f | 91 | ///\r |
af2dc6a7 | 92 | /// The x64 architecture context buffer used by SetJump() and LongJump().\r |
fc30687f | 93 | ///\r |
ac644614 | 94 | typedef struct {\r |
95 | UINT64 Rbx;\r | |
96 | UINT64 Rsp;\r | |
97 | UINT64 Rbp;\r | |
98 | UINT64 Rdi;\r | |
99 | UINT64 Rsi;\r | |
100 | UINT64 R12;\r | |
101 | UINT64 R13;\r | |
102 | UINT64 R14;\r | |
103 | UINT64 R15;\r | |
104 | UINT64 Rip;\r | |
9b9641c6 | 105 | UINT64 MxCsr;\r |
af2dc6a7 | 106 | UINT8 XmmBuffer[160]; ///< XMM6-XMM15.\r |
ac644614 | 107 | } BASE_LIBRARY_JUMP_BUFFER;\r |
108 | \r | |
109 | #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8\r | |
110 | \r | |
aa4df547 | 111 | #endif // defined (MDE_CPU_X64)\r |
112 | \r | |
113 | #if defined (MDE_CPU_EBC)\r | |
fc30687f | 114 | ///\r |
af2dc6a7 | 115 | /// The EBC context buffer used by SetJump() and LongJump().\r |
fc30687f | 116 | ///\r |
ac644614 | 117 | typedef struct {\r |
118 | UINT64 R0;\r | |
119 | UINT64 R1;\r | |
120 | UINT64 R2;\r | |
121 | UINT64 R3;\r | |
122 | UINT64 IP;\r | |
123 | } BASE_LIBRARY_JUMP_BUFFER;\r | |
124 | \r | |
125 | #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8\r | |
126 | \r | |
aa4df547 | 127 | #endif // defined (MDE_CPU_EBC)\r |
ac644614 | 128 | \r |
ebd04fc2 | 129 | #if defined (MDE_CPU_ARM)\r |
130 | \r | |
131 | typedef struct {\r | |
af2dc6a7 | 132 | UINT32 R3; ///< A copy of R13.\r |
01a54966 | 133 | UINT32 R4;\r |
134 | UINT32 R5;\r | |
135 | UINT32 R6;\r | |
136 | UINT32 R7;\r | |
137 | UINT32 R8;\r | |
138 | UINT32 R9;\r | |
139 | UINT32 R10;\r | |
140 | UINT32 R11;\r | |
141 | UINT32 R12;\r | |
142 | UINT32 R14;\r | |
ebd04fc2 | 143 | } BASE_LIBRARY_JUMP_BUFFER;\r |
144 | \r | |
145 | #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 4\r | |
146 | \r | |
147 | #endif // defined (MDE_CPU_ARM)\r | |
148 | \r | |
807e2604 HL |
149 | #if defined (MDE_CPU_AARCH64)\r |
150 | typedef struct {\r | |
151 | // GP regs\r | |
152 | UINT64 X19;\r | |
153 | UINT64 X20;\r | |
154 | UINT64 X21;\r | |
155 | UINT64 X22;\r | |
156 | UINT64 X23;\r | |
157 | UINT64 X24;\r | |
158 | UINT64 X25;\r | |
159 | UINT64 X26;\r | |
160 | UINT64 X27;\r | |
161 | UINT64 X28;\r | |
162 | UINT64 FP;\r | |
163 | UINT64 LR;\r | |
164 | UINT64 IP0;\r | |
165 | \r | |
166 | // FP regs\r | |
167 | UINT64 D8;\r | |
168 | UINT64 D9;\r | |
169 | UINT64 D10;\r | |
170 | UINT64 D11;\r | |
171 | UINT64 D12;\r | |
172 | UINT64 D13;\r | |
173 | UINT64 D14;\r | |
174 | UINT64 D15;\r | |
175 | } BASE_LIBRARY_JUMP_BUFFER;\r | |
176 | \r | |
177 | #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8\r | |
178 | \r | |
179 | #endif // defined (MDE_CPU_AARCH64)\r | |
180 | \r | |
181 | \r | |
ac644614 | 182 | //\r |
183 | // String Services\r | |
184 | //\r | |
185 | \r | |
c058d59f JY |
186 | \r |
187 | /**\r | |
188 | Returns the length of a Null-terminated Unicode string.\r | |
189 | \r | |
328f84b1 JY |
190 | This function is similar as strlen_s defined in C11.\r |
191 | \r | |
c058d59f JY |
192 | If String is not aligned on a 16-bit boundary, then ASSERT().\r |
193 | \r | |
194 | @param String A pointer to a Null-terminated Unicode string.\r | |
195 | @param MaxSize The maximum number of Destination Unicode\r | |
196 | char, including terminating null char.\r | |
197 | \r | |
198 | @retval 0 If String is NULL.\r | |
199 | @retval MaxSize If there is no null character in the first MaxSize characters of String.\r | |
200 | @return The number of characters that percede the terminating null character.\r | |
201 | \r | |
202 | **/\r | |
203 | UINTN\r | |
204 | EFIAPI\r | |
205 | StrnLenS (\r | |
206 | IN CONST CHAR16 *String,\r | |
207 | IN UINTN MaxSize\r | |
208 | );\r | |
209 | \r | |
210 | /**\r | |
211 | Copies the string pointed to by Source (including the terminating null char)\r | |
212 | to the array pointed to by Destination.\r | |
213 | \r | |
328f84b1 JY |
214 | This function is similar as strcpy_s defined in C11.\r |
215 | \r | |
c058d59f JY |
216 | If Destination is not aligned on a 16-bit boundary, then ASSERT().\r |
217 | If Source is not aligned on a 16-bit boundary, then ASSERT().\r | |
0e93edbb | 218 | If an error would be returned, then the function will also ASSERT().\r |
c058d59f | 219 | \r |
328f84b1 JY |
220 | If an error is returned, then the Destination is unmodified.\r |
221 | \r | |
c058d59f JY |
222 | @param Destination A pointer to a Null-terminated Unicode string.\r |
223 | @param DestMax The maximum number of Destination Unicode\r | |
224 | char, including terminating null char.\r | |
225 | @param Source A pointer to a Null-terminated Unicode string.\r | |
226 | \r | |
227 | @retval RETURN_SUCCESS String is copied.\r | |
228 | @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).\r | |
229 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r | |
230 | If Source is NULL.\r | |
231 | If PcdMaximumUnicodeStringLength is not zero,\r | |
232 | and DestMax is greater than \r | |
233 | PcdMaximumUnicodeStringLength.\r | |
234 | If DestMax is 0.\r | |
235 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.\r | |
236 | **/\r | |
237 | RETURN_STATUS\r | |
238 | EFIAPI\r | |
239 | StrCpyS (\r | |
240 | OUT CHAR16 *Destination,\r | |
241 | IN UINTN DestMax,\r | |
242 | IN CONST CHAR16 *Source\r | |
243 | );\r | |
244 | \r | |
245 | /**\r | |
246 | Copies not more than Length successive char from the string pointed to by\r | |
247 | Source to the array pointed to by Destination. If no null char is copied from\r | |
248 | Source, then Destination[Length] is always set to null.\r | |
249 | \r | |
328f84b1 JY |
250 | This function is similar as strncpy_s defined in C11.\r |
251 | \r | |
c058d59f JY |
252 | If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().\r |
253 | If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().\r | |
0e93edbb | 254 | If an error would be returned, then the function will also ASSERT().\r |
c058d59f | 255 | \r |
328f84b1 JY |
256 | If an error is returned, then the Destination is unmodified.\r |
257 | \r | |
c058d59f JY |
258 | @param Destination A pointer to a Null-terminated Unicode string.\r |
259 | @param DestMax The maximum number of Destination Unicode\r | |
260 | char, including terminating null char.\r | |
261 | @param Source A pointer to a Null-terminated Unicode string.\r | |
262 | @param Length The maximum number of Unicode characters to copy.\r | |
263 | \r | |
264 | @retval RETURN_SUCCESS String is copied.\r | |
265 | @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than \r | |
266 | MIN(StrLen(Source), Length).\r | |
267 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r | |
268 | If Source is NULL.\r | |
269 | If PcdMaximumUnicodeStringLength is not zero,\r | |
270 | and DestMax is greater than \r | |
271 | PcdMaximumUnicodeStringLength.\r | |
272 | If DestMax is 0.\r | |
273 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.\r | |
274 | **/\r | |
275 | RETURN_STATUS\r | |
276 | EFIAPI\r | |
277 | StrnCpyS (\r | |
278 | OUT CHAR16 *Destination,\r | |
279 | IN UINTN DestMax,\r | |
280 | IN CONST CHAR16 *Source,\r | |
281 | IN UINTN Length\r | |
282 | );\r | |
283 | \r | |
284 | /**\r | |
285 | Appends a copy of the string pointed to by Source (including the terminating\r | |
286 | null char) to the end of the string pointed to by Destination.\r | |
287 | \r | |
328f84b1 JY |
288 | This function is similar as strcat_s defined in C11.\r |
289 | \r | |
c058d59f JY |
290 | If Destination is not aligned on a 16-bit boundary, then ASSERT().\r |
291 | If Source is not aligned on a 16-bit boundary, then ASSERT().\r | |
0e93edbb | 292 | If an error would be returned, then the function will also ASSERT().\r |
c058d59f | 293 | \r |
328f84b1 JY |
294 | If an error is returned, then the Destination is unmodified.\r |
295 | \r | |
c058d59f JY |
296 | @param Destination A pointer to a Null-terminated Unicode string.\r |
297 | @param DestMax The maximum number of Destination Unicode\r | |
298 | char, including terminating null char.\r | |
299 | @param Source A pointer to a Null-terminated Unicode string.\r | |
300 | \r | |
301 | @retval RETURN_SUCCESS String is appended.\r | |
302 | @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than \r | |
303 | StrLen(Destination).\r | |
304 | @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT\r | |
305 | greater than StrLen(Source).\r | |
306 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r | |
307 | If Source is NULL.\r | |
308 | If PcdMaximumUnicodeStringLength is not zero,\r | |
309 | and DestMax is greater than \r | |
310 | PcdMaximumUnicodeStringLength.\r | |
311 | If DestMax is 0.\r | |
312 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.\r | |
313 | **/\r | |
314 | RETURN_STATUS\r | |
315 | EFIAPI\r | |
316 | StrCatS (\r | |
317 | IN OUT CHAR16 *Destination,\r | |
318 | IN UINTN DestMax,\r | |
319 | IN CONST CHAR16 *Source\r | |
320 | );\r | |
321 | \r | |
322 | /**\r | |
323 | Appends not more than Length successive char from the string pointed to by\r | |
324 | Source to the end of the string pointed to by Destination. If no null char is\r | |
325 | copied from Source, then Destination[StrLen(Destination) + Length] is always\r | |
326 | set to null.\r | |
327 | \r | |
328f84b1 JY |
328 | This function is similar as strncat_s defined in C11.\r |
329 | \r | |
c058d59f | 330 | If Destination is not aligned on a 16-bit boundary, then ASSERT().\r |
0e93edbb JY |
331 | If Source is not aligned on a 16-bit boundary, then ASSERT().\r |
332 | If an error would be returned, then the function will also ASSERT().\r | |
c058d59f | 333 | \r |
328f84b1 JY |
334 | If an error is returned, then the Destination is unmodified.\r |
335 | \r | |
c058d59f JY |
336 | @param Destination A pointer to a Null-terminated Unicode string.\r |
337 | @param DestMax The maximum number of Destination Unicode\r | |
338 | char, including terminating null char.\r | |
339 | @param Source A pointer to a Null-terminated Unicode string.\r | |
340 | @param Length The maximum number of Unicode characters to copy.\r | |
341 | \r | |
342 | @retval RETURN_SUCCESS String is appended.\r | |
343 | @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than\r | |
344 | StrLen(Destination).\r | |
345 | @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT\r | |
346 | greater than MIN(StrLen(Source), Length).\r | |
347 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r | |
348 | If Source is NULL.\r | |
349 | If PcdMaximumUnicodeStringLength is not zero,\r | |
350 | and DestMax is greater than \r | |
351 | PcdMaximumUnicodeStringLength.\r | |
352 | If DestMax is 0.\r | |
353 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.\r | |
354 | **/\r | |
355 | RETURN_STATUS\r | |
356 | EFIAPI\r | |
357 | StrnCatS (\r | |
358 | IN OUT CHAR16 *Destination,\r | |
359 | IN UINTN DestMax,\r | |
360 | IN CONST CHAR16 *Source,\r | |
361 | IN UINTN Length\r | |
362 | );\r | |
363 | \r | |
364 | /**\r | |
365 | Returns the length of a Null-terminated Ascii string.\r | |
366 | \r | |
328f84b1 JY |
367 | This function is similar as strlen_s defined in C11.\r |
368 | \r | |
c058d59f JY |
369 | @param String A pointer to a Null-terminated Ascii string.\r |
370 | @param MaxSize The maximum number of Destination Ascii\r | |
371 | char, including terminating null char.\r | |
372 | \r | |
373 | @retval 0 If String is NULL.\r | |
374 | @retval MaxSize If there is no null character in the first MaxSize characters of String.\r | |
375 | @return The number of characters that percede the terminating null character.\r | |
376 | \r | |
377 | **/\r | |
378 | UINTN\r | |
379 | EFIAPI\r | |
380 | AsciiStrnLenS (\r | |
381 | IN CONST CHAR8 *String,\r | |
382 | IN UINTN MaxSize\r | |
383 | );\r | |
384 | \r | |
385 | /**\r | |
386 | Copies the string pointed to by Source (including the terminating null char)\r | |
387 | to the array pointed to by Destination.\r | |
388 | \r | |
328f84b1 JY |
389 | This function is similar as strcpy_s defined in C11.\r |
390 | \r | |
0e93edbb JY |
391 | If an error would be returned, then the function will also ASSERT().\r |
392 | \r | |
328f84b1 JY |
393 | If an error is returned, then the Destination is unmodified.\r |
394 | \r | |
c058d59f JY |
395 | @param Destination A pointer to a Null-terminated Ascii string.\r |
396 | @param DestMax The maximum number of Destination Ascii\r | |
397 | char, including terminating null char.\r | |
398 | @param Source A pointer to a Null-terminated Ascii string.\r | |
399 | \r | |
400 | @retval RETURN_SUCCESS String is copied.\r | |
401 | @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).\r | |
402 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r | |
403 | If Source is NULL.\r | |
404 | If PcdMaximumAsciiStringLength is not zero,\r | |
405 | and DestMax is greater than \r | |
406 | PcdMaximumAsciiStringLength.\r | |
407 | If DestMax is 0.\r | |
408 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.\r | |
409 | **/\r | |
410 | RETURN_STATUS\r | |
411 | EFIAPI\r | |
412 | AsciiStrCpyS (\r | |
413 | OUT CHAR8 *Destination,\r | |
414 | IN UINTN DestMax,\r | |
415 | IN CONST CHAR8 *Source\r | |
416 | );\r | |
417 | \r | |
418 | /**\r | |
419 | Copies not more than Length successive char from the string pointed to by\r | |
420 | Source to the array pointed to by Destination. If no null char is copied from\r | |
421 | Source, then Destination[Length] is always set to null.\r | |
422 | \r | |
328f84b1 JY |
423 | This function is similar as strncpy_s defined in C11.\r |
424 | \r | |
0e93edbb JY |
425 | If an error would be returned, then the function will also ASSERT().\r |
426 | \r | |
328f84b1 JY |
427 | If an error is returned, then the Destination is unmodified.\r |
428 | \r | |
c058d59f JY |
429 | @param Destination A pointer to a Null-terminated Ascii string.\r |
430 | @param DestMax The maximum number of Destination Ascii\r | |
431 | char, including terminating null char.\r | |
432 | @param Source A pointer to a Null-terminated Ascii string.\r | |
433 | @param Length The maximum number of Ascii characters to copy.\r | |
434 | \r | |
435 | @retval RETURN_SUCCESS String is copied.\r | |
436 | @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than \r | |
437 | MIN(StrLen(Source), Length).\r | |
438 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r | |
439 | If Source is NULL.\r | |
440 | If PcdMaximumAsciiStringLength is not zero,\r | |
441 | and DestMax is greater than \r | |
442 | PcdMaximumAsciiStringLength.\r | |
443 | If DestMax is 0.\r | |
444 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.\r | |
445 | **/\r | |
446 | RETURN_STATUS\r | |
447 | EFIAPI\r | |
448 | AsciiStrnCpyS (\r | |
449 | OUT CHAR8 *Destination,\r | |
450 | IN UINTN DestMax,\r | |
451 | IN CONST CHAR8 *Source,\r | |
452 | IN UINTN Length\r | |
453 | );\r | |
454 | \r | |
455 | /**\r | |
456 | Appends a copy of the string pointed to by Source (including the terminating\r | |
457 | null char) to the end of the string pointed to by Destination.\r | |
458 | \r | |
328f84b1 JY |
459 | This function is similar as strcat_s defined in C11.\r |
460 | \r | |
0e93edbb JY |
461 | If an error would be returned, then the function will also ASSERT().\r |
462 | \r | |
328f84b1 JY |
463 | If an error is returned, then the Destination is unmodified.\r |
464 | \r | |
c058d59f JY |
465 | @param Destination A pointer to a Null-terminated Ascii string.\r |
466 | @param DestMax The maximum number of Destination Ascii\r | |
467 | char, including terminating null char.\r | |
468 | @param Source A pointer to a Null-terminated Ascii string.\r | |
469 | \r | |
470 | @retval RETURN_SUCCESS String is appended.\r | |
471 | @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than \r | |
472 | StrLen(Destination).\r | |
473 | @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT\r | |
474 | greater than StrLen(Source).\r | |
475 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r | |
476 | If Source is NULL.\r | |
477 | If PcdMaximumAsciiStringLength is not zero,\r | |
478 | and DestMax is greater than \r | |
479 | PcdMaximumAsciiStringLength.\r | |
480 | If DestMax is 0.\r | |
481 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.\r | |
482 | **/\r | |
483 | RETURN_STATUS\r | |
484 | EFIAPI\r | |
485 | AsciiStrCatS (\r | |
486 | IN OUT CHAR8 *Destination,\r | |
487 | IN UINTN DestMax,\r | |
488 | IN CONST CHAR8 *Source\r | |
489 | );\r | |
490 | \r | |
491 | /**\r | |
492 | Appends not more than Length successive char from the string pointed to by\r | |
493 | Source to the end of the string pointed to by Destination. If no null char is\r | |
494 | copied from Source, then Destination[StrLen(Destination) + Length] is always\r | |
495 | set to null.\r | |
496 | \r | |
328f84b1 JY |
497 | This function is similar as strncat_s defined in C11.\r |
498 | \r | |
0e93edbb JY |
499 | If an error would be returned, then the function will also ASSERT().\r |
500 | \r | |
328f84b1 JY |
501 | If an error is returned, then the Destination is unmodified.\r |
502 | \r | |
c058d59f JY |
503 | @param Destination A pointer to a Null-terminated Ascii string.\r |
504 | @param DestMax The maximum number of Destination Ascii\r | |
505 | char, including terminating null char.\r | |
506 | @param Source A pointer to a Null-terminated Ascii string.\r | |
507 | @param Length The maximum number of Ascii characters to copy.\r | |
508 | \r | |
509 | @retval RETURN_SUCCESS String is appended.\r | |
510 | @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than\r | |
511 | StrLen(Destination).\r | |
512 | @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT\r | |
513 | greater than MIN(StrLen(Source), Length).\r | |
514 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r | |
515 | If Source is NULL.\r | |
516 | If PcdMaximumAsciiStringLength is not zero,\r | |
517 | and DestMax is greater than \r | |
518 | PcdMaximumAsciiStringLength.\r | |
519 | If DestMax is 0.\r | |
520 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.\r | |
521 | **/\r | |
522 | RETURN_STATUS\r | |
523 | EFIAPI\r | |
524 | AsciiStrnCatS (\r | |
525 | IN OUT CHAR8 *Destination,\r | |
526 | IN UINTN DestMax,\r | |
527 | IN CONST CHAR8 *Source,\r | |
528 | IN UINTN Length\r | |
529 | );\r | |
530 | \r | |
531 | \r | |
1bb390f1 ED |
532 | #ifndef DISABLE_NEW_DEPRECATED_INTERFACES\r |
533 | \r | |
ac644614 | 534 | /**\r |
ae591c14 | 535 | [ATTENTION] This function is deprecated for security reason.\r |
1bb390f1 | 536 | \r |
ac644614 | 537 | Copies one Null-terminated Unicode string to another Null-terminated Unicode\r |
538 | string and returns the new Unicode string.\r | |
539 | \r | |
540 | This function copies the contents of the Unicode string Source to the Unicode\r | |
541 | string Destination, and returns Destination. If Source and Destination\r | |
542 | overlap, then the results are undefined.\r | |
543 | \r | |
544 | If Destination is NULL, then ASSERT().\r | |
545 | If Destination is not aligned on a 16-bit boundary, then ASSERT().\r | |
546 | If Source is NULL, then ASSERT().\r | |
547 | If Source is not aligned on a 16-bit boundary, then ASSERT().\r | |
548 | If Source and Destination overlap, then ASSERT().\r | |
549 | If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r | |
550 | PcdMaximumUnicodeStringLength Unicode characters not including the\r | |
551 | Null-terminator, then ASSERT().\r | |
552 | \r | |
af2dc6a7 | 553 | @param Destination The pointer to a Null-terminated Unicode string.\r |
554 | @param Source The pointer to a Null-terminated Unicode string.\r | |
ac644614 | 555 | \r |
9aa049d9 | 556 | @return Destination.\r |
ac644614 | 557 | \r |
558 | **/\r | |
559 | CHAR16 *\r | |
560 | EFIAPI\r | |
561 | StrCpy (\r | |
562 | OUT CHAR16 *Destination,\r | |
563 | IN CONST CHAR16 *Source\r | |
564 | );\r | |
565 | \r | |
566 | \r | |
567 | /**\r | |
ae591c14 | 568 | [ATTENTION] This function is deprecated for security reason.\r |
1bb390f1 | 569 | \r |
af2dc6a7 | 570 | Copies up to a specified length from one Null-terminated Unicode string to \r |
17f695ed | 571 | another Null-terminated Unicode string and returns the new Unicode string.\r |
ac644614 | 572 | \r |
573 | This function copies the contents of the Unicode string Source to the Unicode\r | |
574 | string Destination, and returns Destination. At most, Length Unicode\r | |
575 | characters are copied from Source to Destination. If Length is 0, then\r | |
576 | Destination is returned unmodified. If Length is greater that the number of\r | |
577 | Unicode characters in Source, then Destination is padded with Null Unicode\r | |
578 | characters. If Source and Destination overlap, then the results are\r | |
579 | undefined.\r | |
580 | \r | |
581 | If Length > 0 and Destination is NULL, then ASSERT().\r | |
582 | If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().\r | |
583 | If Length > 0 and Source is NULL, then ASSERT().\r | |
77f863ee | 584 | If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().\r |
ac644614 | 585 | If Source and Destination overlap, then ASSERT().\r |
50c247fd | 586 | If PcdMaximumUnicodeStringLength is not zero, and Length is greater than \r |
587 | PcdMaximumUnicodeStringLength, then ASSERT().\r | |
ac644614 | 588 | If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r |
50c247fd | 589 | PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,\r |
590 | then ASSERT().\r | |
ac644614 | 591 | \r |
af2dc6a7 | 592 | @param Destination The pointer to a Null-terminated Unicode string.\r |
593 | @param Source The pointer to a Null-terminated Unicode string.\r | |
594 | @param Length The maximum number of Unicode characters to copy.\r | |
ac644614 | 595 | \r |
9aa049d9 | 596 | @return Destination.\r |
ac644614 | 597 | \r |
598 | **/\r | |
599 | CHAR16 *\r | |
600 | EFIAPI\r | |
601 | StrnCpy (\r | |
602 | OUT CHAR16 *Destination,\r | |
603 | IN CONST CHAR16 *Source,\r | |
604 | IN UINTN Length\r | |
605 | );\r | |
1bb390f1 | 606 | #endif\r |
ac644614 | 607 | \r |
608 | /**\r | |
609 | Returns the length of a Null-terminated Unicode string.\r | |
610 | \r | |
611 | This function returns the number of Unicode characters in the Null-terminated\r | |
612 | Unicode string specified by String.\r | |
613 | \r | |
614 | If String is NULL, then ASSERT().\r | |
615 | If String is not aligned on a 16-bit boundary, then ASSERT().\r | |
616 | If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r | |
617 | PcdMaximumUnicodeStringLength Unicode characters not including the\r | |
618 | Null-terminator, then ASSERT().\r | |
619 | \r | |
620 | @param String Pointer to a Null-terminated Unicode string.\r | |
621 | \r | |
622 | @return The length of String.\r | |
623 | \r | |
624 | **/\r | |
625 | UINTN\r | |
626 | EFIAPI\r | |
627 | StrLen (\r | |
628 | IN CONST CHAR16 *String\r | |
629 | );\r | |
630 | \r | |
631 | \r | |
632 | /**\r | |
633 | Returns the size of a Null-terminated Unicode string in bytes, including the\r | |
634 | Null terminator.\r | |
635 | \r | |
17f695ed | 636 | This function returns the size, in bytes, of the Null-terminated Unicode string \r |
637 | specified by String.\r | |
ac644614 | 638 | \r |
639 | If String is NULL, then ASSERT().\r | |
640 | If String is not aligned on a 16-bit boundary, then ASSERT().\r | |
641 | If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r | |
642 | PcdMaximumUnicodeStringLength Unicode characters not including the\r | |
643 | Null-terminator, then ASSERT().\r | |
644 | \r | |
af2dc6a7 | 645 | @param String The pointer to a Null-terminated Unicode string.\r |
ac644614 | 646 | \r |
647 | @return The size of String.\r | |
648 | \r | |
649 | **/\r | |
650 | UINTN\r | |
651 | EFIAPI\r | |
652 | StrSize (\r | |
653 | IN CONST CHAR16 *String\r | |
654 | );\r | |
655 | \r | |
656 | \r | |
657 | /**\r | |
658 | Compares two Null-terminated Unicode strings, and returns the difference\r | |
659 | between the first mismatched Unicode characters.\r | |
660 | \r | |
661 | This function compares the Null-terminated Unicode string FirstString to the\r | |
662 | Null-terminated Unicode string SecondString. If FirstString is identical to\r | |
663 | SecondString, then 0 is returned. Otherwise, the value returned is the first\r | |
664 | mismatched Unicode character in SecondString subtracted from the first\r | |
665 | mismatched Unicode character in FirstString.\r | |
666 | \r | |
667 | If FirstString is NULL, then ASSERT().\r | |
668 | If FirstString is not aligned on a 16-bit boundary, then ASSERT().\r | |
669 | If SecondString is NULL, then ASSERT().\r | |
670 | If SecondString is not aligned on a 16-bit boundary, then ASSERT().\r | |
671 | If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more\r | |
672 | than PcdMaximumUnicodeStringLength Unicode characters not including the\r | |
673 | Null-terminator, then ASSERT().\r | |
674 | If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more\r | |
af2dc6a7 | 675 | than PcdMaximumUnicodeStringLength Unicode characters, not including the\r |
ac644614 | 676 | Null-terminator, then ASSERT().\r |
677 | \r | |
af2dc6a7 | 678 | @param FirstString The pointer to a Null-terminated Unicode string.\r |
679 | @param SecondString The pointer to a Null-terminated Unicode string.\r | |
ac644614 | 680 | \r |
1106ffe1 | 681 | @retval 0 FirstString is identical to SecondString.\r |
682 | @return others FirstString is not identical to SecondString.\r | |
ac644614 | 683 | \r |
684 | **/\r | |
685 | INTN\r | |
686 | EFIAPI\r | |
687 | StrCmp (\r | |
688 | IN CONST CHAR16 *FirstString,\r | |
689 | IN CONST CHAR16 *SecondString\r | |
690 | );\r | |
691 | \r | |
692 | \r | |
693 | /**\r | |
17f695ed | 694 | Compares up to a specified length the contents of two Null-terminated Unicode strings,\r |
695 | and returns the difference between the first mismatched Unicode characters.\r | |
696 | \r | |
ac644614 | 697 | This function compares the Null-terminated Unicode string FirstString to the\r |
698 | Null-terminated Unicode string SecondString. At most, Length Unicode\r | |
699 | characters will be compared. If Length is 0, then 0 is returned. If\r | |
700 | FirstString is identical to SecondString, then 0 is returned. Otherwise, the\r | |
701 | value returned is the first mismatched Unicode character in SecondString\r | |
702 | subtracted from the first mismatched Unicode character in FirstString.\r | |
703 | \r | |
704 | If Length > 0 and FirstString is NULL, then ASSERT().\r | |
77f863ee | 705 | If Length > 0 and FirstString is not aligned on a 16-bit boundary, then ASSERT().\r |
ac644614 | 706 | If Length > 0 and SecondString is NULL, then ASSERT().\r |
77f863ee | 707 | If Length > 0 and SecondString is not aligned on a 16-bit boundary, then ASSERT().\r |
50c247fd | 708 | If PcdMaximumUnicodeStringLength is not zero, and Length is greater than\r |
709 | PcdMaximumUnicodeStringLength, then ASSERT().\r | |
710 | If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more than\r | |
711 | PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,\r | |
712 | then ASSERT().\r | |
713 | If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more than\r | |
714 | PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,\r | |
715 | then ASSERT().\r | |
ac644614 | 716 | \r |
af2dc6a7 | 717 | @param FirstString The pointer to a Null-terminated Unicode string.\r |
718 | @param SecondString The pointer to a Null-terminated Unicode string.\r | |
719 | @param Length The maximum number of Unicode characters to compare.\r | |
ac644614 | 720 | \r |
1106ffe1 | 721 | @retval 0 FirstString is identical to SecondString.\r |
722 | @return others FirstString is not identical to SecondString.\r | |
ac644614 | 723 | \r |
724 | **/\r | |
725 | INTN\r | |
726 | EFIAPI\r | |
727 | StrnCmp (\r | |
728 | IN CONST CHAR16 *FirstString,\r | |
729 | IN CONST CHAR16 *SecondString,\r | |
730 | IN UINTN Length\r | |
731 | );\r | |
732 | \r | |
733 | \r | |
1bb390f1 ED |
734 | #ifndef DISABLE_NEW_DEPRECATED_INTERFACES\r |
735 | \r | |
ac644614 | 736 | /**\r |
ae591c14 | 737 | [ATTENTION] This function is deprecated for security reason.\r |
1bb390f1 | 738 | \r |
ac644614 | 739 | Concatenates one Null-terminated Unicode string to another Null-terminated\r |
740 | Unicode string, and returns the concatenated Unicode string.\r | |
741 | \r | |
742 | This function concatenates two Null-terminated Unicode strings. The contents\r | |
743 | of Null-terminated Unicode string Source are concatenated to the end of\r | |
744 | Null-terminated Unicode string Destination. The Null-terminated concatenated\r | |
745 | Unicode String is returned. If Source and Destination overlap, then the\r | |
746 | results are undefined.\r | |
747 | \r | |
748 | If Destination is NULL, then ASSERT().\r | |
77f863ee | 749 | If Destination is not aligned on a 16-bit boundary, then ASSERT().\r |
ac644614 | 750 | If Source is NULL, then ASSERT().\r |
77f863ee | 751 | If Source is not aligned on a 16-bit boundary, then ASSERT().\r |
ac644614 | 752 | If Source and Destination overlap, then ASSERT().\r |
753 | If PcdMaximumUnicodeStringLength is not zero, and Destination contains more\r | |
af2dc6a7 | 754 | than PcdMaximumUnicodeStringLength Unicode characters, not including the\r |
ac644614 | 755 | Null-terminator, then ASSERT().\r |
756 | If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r | |
af2dc6a7 | 757 | PcdMaximumUnicodeStringLength Unicode characters, not including the\r |
ac644614 | 758 | Null-terminator, then ASSERT().\r |
759 | If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination\r | |
760 | and Source results in a Unicode string with more than\r | |
af2dc6a7 | 761 | PcdMaximumUnicodeStringLength Unicode characters, not including the\r |
ac644614 | 762 | Null-terminator, then ASSERT().\r |
763 | \r | |
af2dc6a7 | 764 | @param Destination The pointer to a Null-terminated Unicode string.\r |
765 | @param Source The pointer to a Null-terminated Unicode string.\r | |
ac644614 | 766 | \r |
9aa049d9 | 767 | @return Destination.\r |
ac644614 | 768 | \r |
769 | **/\r | |
770 | CHAR16 *\r | |
771 | EFIAPI\r | |
772 | StrCat (\r | |
773 | IN OUT CHAR16 *Destination,\r | |
774 | IN CONST CHAR16 *Source\r | |
775 | );\r | |
776 | \r | |
777 | \r | |
778 | /**\r | |
ae591c14 | 779 | [ATTENTION] This function is deprecated for security reason.\r |
1bb390f1 | 780 | \r |
17f695ed | 781 | Concatenates up to a specified length one Null-terminated Unicode to the end \r |
782 | of another Null-terminated Unicode string, and returns the concatenated \r | |
ac644614 | 783 | Unicode string.\r |
784 | \r | |
785 | This function concatenates two Null-terminated Unicode strings. The contents\r | |
786 | of Null-terminated Unicode string Source are concatenated to the end of\r | |
787 | Null-terminated Unicode string Destination, and Destination is returned. At\r | |
788 | most, Length Unicode characters are concatenated from Source to the end of\r | |
789 | Destination, and Destination is always Null-terminated. If Length is 0, then\r | |
790 | Destination is returned unmodified. If Source and Destination overlap, then\r | |
791 | the results are undefined.\r | |
792 | \r | |
793 | If Destination is NULL, then ASSERT().\r | |
794 | If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().\r | |
795 | If Length > 0 and Source is NULL, then ASSERT().\r | |
796 | If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().\r | |
797 | If Source and Destination overlap, then ASSERT().\r | |
50c247fd | 798 | If PcdMaximumUnicodeStringLength is not zero, and Length is greater than \r |
799 | PcdMaximumUnicodeStringLength, then ASSERT().\r | |
ac644614 | 800 | If PcdMaximumUnicodeStringLength is not zero, and Destination contains more\r |
50c247fd | 801 | than PcdMaximumUnicodeStringLength Unicode characters, not including the\r |
ac644614 | 802 | Null-terminator, then ASSERT().\r |
803 | If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r | |
50c247fd | 804 | PcdMaximumUnicodeStringLength Unicode characters, not including the\r |
ac644614 | 805 | Null-terminator, then ASSERT().\r |
806 | If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination\r | |
50c247fd | 807 | and Source results in a Unicode string with more than PcdMaximumUnicodeStringLength\r |
808 | Unicode characters, not including the Null-terminator, then ASSERT().\r | |
ac644614 | 809 | \r |
af2dc6a7 | 810 | @param Destination The pointer to a Null-terminated Unicode string.\r |
811 | @param Source The pointer to a Null-terminated Unicode string.\r | |
812 | @param Length The maximum number of Unicode characters to concatenate from\r | |
ac644614 | 813 | Source.\r |
814 | \r | |
9aa049d9 | 815 | @return Destination.\r |
ac644614 | 816 | \r |
817 | **/\r | |
818 | CHAR16 *\r | |
819 | EFIAPI\r | |
820 | StrnCat (\r | |
821 | IN OUT CHAR16 *Destination,\r | |
822 | IN CONST CHAR16 *Source,\r | |
823 | IN UINTN Length\r | |
824 | );\r | |
1bb390f1 | 825 | #endif\r |
ac644614 | 826 | \r |
827 | /**\r | |
9aa049d9 | 828 | Returns the first occurrence of a Null-terminated Unicode sub-string\r |
ac644614 | 829 | in a Null-terminated Unicode string.\r |
830 | \r | |
831 | This function scans the contents of the Null-terminated Unicode string\r | |
832 | specified by String and returns the first occurrence of SearchString.\r | |
833 | If SearchString is not found in String, then NULL is returned. If\r | |
af2dc6a7 | 834 | the length of SearchString is zero, then String is returned.\r |
ac644614 | 835 | \r |
836 | If String is NULL, then ASSERT().\r | |
837 | If String is not aligned on a 16-bit boundary, then ASSERT().\r | |
838 | If SearchString is NULL, then ASSERT().\r | |
839 | If SearchString is not aligned on a 16-bit boundary, then ASSERT().\r | |
840 | \r | |
841 | If PcdMaximumUnicodeStringLength is not zero, and SearchString\r | |
842 | or String contains more than PcdMaximumUnicodeStringLength Unicode\r | |
af2dc6a7 | 843 | characters, not including the Null-terminator, then ASSERT().\r |
ac644614 | 844 | \r |
af2dc6a7 | 845 | @param String The pointer to a Null-terminated Unicode string.\r |
846 | @param SearchString The pointer to a Null-terminated Unicode string to search for.\r | |
ac644614 | 847 | \r |
848 | @retval NULL If the SearchString does not appear in String.\r | |
1106ffe1 | 849 | @return others If there is a match.\r |
ac644614 | 850 | \r |
851 | **/\r | |
852 | CHAR16 *\r | |
853 | EFIAPI\r | |
854 | StrStr (\r | |
17f695ed | 855 | IN CONST CHAR16 *String,\r |
856 | IN CONST CHAR16 *SearchString\r | |
ac644614 | 857 | );\r |
858 | \r | |
859 | /**\r | |
860 | Convert a Null-terminated Unicode decimal string to a value of\r | |
861 | type UINTN.\r | |
862 | \r | |
863 | This function returns a value of type UINTN by interpreting the contents\r | |
864 | of the Unicode string specified by String as a decimal number. The format\r | |
865 | of the input Unicode string String is:\r | |
866 | \r | |
867 | [spaces] [decimal digits].\r | |
868 | \r | |
869 | The valid decimal digit character is in the range [0-9]. The\r | |
870 | function will ignore the pad space, which includes spaces or\r | |
871 | tab characters, before [decimal digits]. The running zero in the\r | |
872 | beginning of [decimal digits] will be ignored. Then, the function\r | |
873 | stops at the first character that is a not a valid decimal character\r | |
874 | or a Null-terminator, whichever one comes first.\r | |
875 | \r | |
876 | If String is NULL, then ASSERT().\r | |
877 | If String is not aligned in a 16-bit boundary, then ASSERT().\r | |
878 | If String has only pad spaces, then 0 is returned.\r | |
879 | If String has no pad spaces or valid decimal digits,\r | |
880 | then 0 is returned.\r | |
881 | If the number represented by String overflows according\r | |
882 | to the range defined by UINTN, then ASSERT().\r | |
883 | \r | |
884 | If PcdMaximumUnicodeStringLength is not zero, and String contains\r | |
885 | more than PcdMaximumUnicodeStringLength Unicode characters not including\r | |
886 | the Null-terminator, then ASSERT().\r | |
887 | \r | |
af2dc6a7 | 888 | @param String The pointer to a Null-terminated Unicode string.\r |
ac644614 | 889 | \r |
38bbd3d9 | 890 | @retval Value translated from String.\r |
ac644614 | 891 | \r |
892 | **/\r | |
893 | UINTN\r | |
894 | EFIAPI\r | |
895 | StrDecimalToUintn (\r | |
17f695ed | 896 | IN CONST CHAR16 *String\r |
ac644614 | 897 | );\r |
898 | \r | |
899 | /**\r | |
900 | Convert a Null-terminated Unicode decimal string to a value of\r | |
901 | type UINT64.\r | |
902 | \r | |
903 | This function returns a value of type UINT64 by interpreting the contents\r | |
904 | of the Unicode string specified by String as a decimal number. The format\r | |
905 | of the input Unicode string String is:\r | |
906 | \r | |
907 | [spaces] [decimal digits].\r | |
908 | \r | |
909 | The valid decimal digit character is in the range [0-9]. The\r | |
910 | function will ignore the pad space, which includes spaces or\r | |
911 | tab characters, before [decimal digits]. The running zero in the\r | |
912 | beginning of [decimal digits] will be ignored. Then, the function\r | |
913 | stops at the first character that is a not a valid decimal character\r | |
914 | or a Null-terminator, whichever one comes first.\r | |
915 | \r | |
916 | If String is NULL, then ASSERT().\r | |
917 | If String is not aligned in a 16-bit boundary, then ASSERT().\r | |
918 | If String has only pad spaces, then 0 is returned.\r | |
919 | If String has no pad spaces or valid decimal digits,\r | |
920 | then 0 is returned.\r | |
921 | If the number represented by String overflows according\r | |
922 | to the range defined by UINT64, then ASSERT().\r | |
923 | \r | |
924 | If PcdMaximumUnicodeStringLength is not zero, and String contains\r | |
925 | more than PcdMaximumUnicodeStringLength Unicode characters not including\r | |
926 | the Null-terminator, then ASSERT().\r | |
927 | \r | |
af2dc6a7 | 928 | @param String The pointer to a Null-terminated Unicode string.\r |
ac644614 | 929 | \r |
38bbd3d9 | 930 | @retval Value translated from String.\r |
ac644614 | 931 | \r |
932 | **/\r | |
933 | UINT64\r | |
934 | EFIAPI\r | |
935 | StrDecimalToUint64 (\r | |
17f695ed | 936 | IN CONST CHAR16 *String\r |
ac644614 | 937 | );\r |
938 | \r | |
939 | \r | |
940 | /**\r | |
941 | Convert a Null-terminated Unicode hexadecimal string to a value of type UINTN.\r | |
942 | \r | |
943 | This function returns a value of type UINTN by interpreting the contents\r | |
944 | of the Unicode string specified by String as a hexadecimal number.\r | |
945 | The format of the input Unicode string String is:\r | |
946 | \r | |
947 | [spaces][zeros][x][hexadecimal digits].\r | |
948 | \r | |
949 | The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].\r | |
950 | The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.\r | |
951 | If "x" appears in the input string, it must be prefixed with at least one 0.\r | |
952 | The function will ignore the pad space, which includes spaces or tab characters,\r | |
953 | before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or\r | |
954 | [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the\r | |
af2dc6a7 | 955 | first valid hexadecimal digit. Then, the function stops at the first character \r |
956 | that is a not a valid hexadecimal character or NULL, whichever one comes first.\r | |
ac644614 | 957 | \r |
958 | If String is NULL, then ASSERT().\r | |
959 | If String is not aligned in a 16-bit boundary, then ASSERT().\r | |
960 | If String has only pad spaces, then zero is returned.\r | |
961 | If String has no leading pad spaces, leading zeros or valid hexadecimal digits,\r | |
962 | then zero is returned.\r | |
963 | If the number represented by String overflows according to the range defined by\r | |
964 | UINTN, then ASSERT().\r | |
965 | \r | |
966 | If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r | |
967 | PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,\r | |
968 | then ASSERT().\r | |
969 | \r | |
af2dc6a7 | 970 | @param String The pointer to a Null-terminated Unicode string.\r |
ac644614 | 971 | \r |
38bbd3d9 | 972 | @retval Value translated from String.\r |
ac644614 | 973 | \r |
974 | **/\r | |
975 | UINTN\r | |
976 | EFIAPI\r | |
977 | StrHexToUintn (\r | |
17f695ed | 978 | IN CONST CHAR16 *String\r |
ac644614 | 979 | );\r |
980 | \r | |
981 | \r | |
982 | /**\r | |
983 | Convert a Null-terminated Unicode hexadecimal string to a value of type UINT64.\r | |
984 | \r | |
985 | This function returns a value of type UINT64 by interpreting the contents\r | |
986 | of the Unicode string specified by String as a hexadecimal number.\r | |
987 | The format of the input Unicode string String is\r | |
988 | \r | |
989 | [spaces][zeros][x][hexadecimal digits].\r | |
990 | \r | |
991 | The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].\r | |
992 | The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.\r | |
993 | If "x" appears in the input string, it must be prefixed with at least one 0.\r | |
994 | The function will ignore the pad space, which includes spaces or tab characters,\r | |
995 | before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or\r | |
996 | [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the\r | |
997 | first valid hexadecimal digit. Then, the function stops at the first character that is\r | |
998 | a not a valid hexadecimal character or NULL, whichever one comes first.\r | |
999 | \r | |
1000 | If String is NULL, then ASSERT().\r | |
1001 | If String is not aligned in a 16-bit boundary, then ASSERT().\r | |
1002 | If String has only pad spaces, then zero is returned.\r | |
1003 | If String has no leading pad spaces, leading zeros or valid hexadecimal digits,\r | |
1004 | then zero is returned.\r | |
1005 | If the number represented by String overflows according to the range defined by\r | |
1006 | UINT64, then ASSERT().\r | |
1007 | \r | |
1008 | If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r | |
1009 | PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,\r | |
1010 | then ASSERT().\r | |
1011 | \r | |
af2dc6a7 | 1012 | @param String The pointer to a Null-terminated Unicode string.\r |
ac644614 | 1013 | \r |
38bbd3d9 | 1014 | @retval Value translated from String.\r |
ac644614 | 1015 | \r |
1016 | **/\r | |
1017 | UINT64\r | |
1018 | EFIAPI\r | |
1019 | StrHexToUint64 (\r | |
17f695ed | 1020 | IN CONST CHAR16 *String\r |
ac644614 | 1021 | );\r |
1022 | \r | |
ac644614 | 1023 | /**\r |
17f695ed | 1024 | Convert a Null-terminated Unicode string to a Null-terminated\r |
ac644614 | 1025 | ASCII string and returns the ASCII string.\r |
1026 | \r | |
1027 | This function converts the content of the Unicode string Source\r | |
1028 | to the ASCII string Destination by copying the lower 8 bits of\r | |
1029 | each Unicode character. It returns Destination.\r | |
1030 | \r | |
d3e0289c | 1031 | The caller is responsible to make sure Destination points to a buffer with size\r |
1032 | equal or greater than ((StrLen (Source) + 1) * sizeof (CHAR8)) in bytes.\r | |
1033 | \r | |
ac644614 | 1034 | If any Unicode characters in Source contain non-zero value in\r |
1035 | the upper 8 bits, then ASSERT().\r | |
1036 | \r | |
1037 | If Destination is NULL, then ASSERT().\r | |
1038 | If Source is NULL, then ASSERT().\r | |
1039 | If Source is not aligned on a 16-bit boundary, then ASSERT().\r | |
1040 | If Source and Destination overlap, then ASSERT().\r | |
1041 | \r | |
1042 | If PcdMaximumUnicodeStringLength is not zero, and Source contains\r | |
1043 | more than PcdMaximumUnicodeStringLength Unicode characters not including\r | |
1044 | the Null-terminator, then ASSERT().\r | |
1045 | \r | |
1046 | If PcdMaximumAsciiStringLength is not zero, and Source contains more\r | |
1047 | than PcdMaximumAsciiStringLength Unicode characters not including the\r | |
1048 | Null-terminator, then ASSERT().\r | |
1049 | \r | |
af2dc6a7 | 1050 | @param Source The pointer to a Null-terminated Unicode string.\r |
1051 | @param Destination The pointer to a Null-terminated ASCII string.\r | |
ac644614 | 1052 | \r |
9aa049d9 | 1053 | @return Destination.\r |
ac644614 | 1054 | \r |
1055 | **/\r | |
1056 | CHAR8 *\r | |
1057 | EFIAPI\r | |
1058 | UnicodeStrToAsciiStr (\r | |
17f695ed | 1059 | IN CONST CHAR16 *Source,\r |
1060 | OUT CHAR8 *Destination\r | |
ac644614 | 1061 | );\r |
1062 | \r | |
1063 | \r | |
1bb390f1 ED |
1064 | #ifndef DISABLE_NEW_DEPRECATED_INTERFACES\r |
1065 | \r | |
ac644614 | 1066 | /**\r |
ae591c14 | 1067 | [ATTENTION] This function is deprecated for security reason.\r |
1bb390f1 | 1068 | \r |
ac644614 | 1069 | Copies one Null-terminated ASCII string to another Null-terminated ASCII\r |
1070 | string and returns the new ASCII string.\r | |
1071 | \r | |
1072 | This function copies the contents of the ASCII string Source to the ASCII\r | |
1073 | string Destination, and returns Destination. If Source and Destination\r | |
1074 | overlap, then the results are undefined.\r | |
1075 | \r | |
1076 | If Destination is NULL, then ASSERT().\r | |
1077 | If Source is NULL, then ASSERT().\r | |
1078 | If Source and Destination overlap, then ASSERT().\r | |
1079 | If PcdMaximumAsciiStringLength is not zero and Source contains more than\r | |
1080 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r | |
1081 | then ASSERT().\r | |
1082 | \r | |
af2dc6a7 | 1083 | @param Destination The pointer to a Null-terminated ASCII string.\r |
1084 | @param Source The pointer to a Null-terminated ASCII string.\r | |
ac644614 | 1085 | \r |
1086 | @return Destination\r | |
1087 | \r | |
1088 | **/\r | |
1089 | CHAR8 *\r | |
1090 | EFIAPI\r | |
1091 | AsciiStrCpy (\r | |
1092 | OUT CHAR8 *Destination,\r | |
1093 | IN CONST CHAR8 *Source\r | |
1094 | );\r | |
1095 | \r | |
1096 | \r | |
1097 | /**\r | |
ae591c14 | 1098 | [ATTENTION] This function is deprecated for security reason.\r |
1bb390f1 | 1099 | \r |
17f695ed | 1100 | Copies up to a specified length one Null-terminated ASCII string to another \r |
1101 | Null-terminated ASCII string and returns the new ASCII string.\r | |
ac644614 | 1102 | \r |
1103 | This function copies the contents of the ASCII string Source to the ASCII\r | |
1104 | string Destination, and returns Destination. At most, Length ASCII characters\r | |
1105 | are copied from Source to Destination. If Length is 0, then Destination is\r | |
1106 | returned unmodified. If Length is greater that the number of ASCII characters\r | |
1107 | in Source, then Destination is padded with Null ASCII characters. If Source\r | |
1108 | and Destination overlap, then the results are undefined.\r | |
1109 | \r | |
1110 | If Destination is NULL, then ASSERT().\r | |
1111 | If Source is NULL, then ASSERT().\r | |
1112 | If Source and Destination overlap, then ASSERT().\r | |
50c247fd | 1113 | If PcdMaximumAsciiStringLength is not zero, and Length is greater than \r |
1114 | PcdMaximumAsciiStringLength, then ASSERT().\r | |
ac644614 | 1115 | If PcdMaximumAsciiStringLength is not zero, and Source contains more than\r |
50c247fd | 1116 | PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,\r |
ac644614 | 1117 | then ASSERT().\r |
1118 | \r | |
af2dc6a7 | 1119 | @param Destination The pointer to a Null-terminated ASCII string.\r |
1120 | @param Source The pointer to a Null-terminated ASCII string.\r | |
1121 | @param Length The maximum number of ASCII characters to copy.\r | |
ac644614 | 1122 | \r |
1123 | @return Destination\r | |
1124 | \r | |
1125 | **/\r | |
1126 | CHAR8 *\r | |
1127 | EFIAPI\r | |
1128 | AsciiStrnCpy (\r | |
1129 | OUT CHAR8 *Destination,\r | |
1130 | IN CONST CHAR8 *Source,\r | |
1131 | IN UINTN Length\r | |
1132 | );\r | |
1bb390f1 | 1133 | #endif\r |
ac644614 | 1134 | \r |
1135 | /**\r | |
1136 | Returns the length of a Null-terminated ASCII string.\r | |
1137 | \r | |
1138 | This function returns the number of ASCII characters in the Null-terminated\r | |
1139 | ASCII string specified by String.\r | |
1140 | \r | |
1141 | If Length > 0 and Destination is NULL, then ASSERT().\r | |
1142 | If Length > 0 and Source is NULL, then ASSERT().\r | |
1143 | If PcdMaximumAsciiStringLength is not zero and String contains more than\r | |
1144 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r | |
1145 | then ASSERT().\r | |
1146 | \r | |
af2dc6a7 | 1147 | @param String The pointer to a Null-terminated ASCII string.\r |
ac644614 | 1148 | \r |
1149 | @return The length of String.\r | |
1150 | \r | |
1151 | **/\r | |
1152 | UINTN\r | |
1153 | EFIAPI\r | |
1154 | AsciiStrLen (\r | |
1155 | IN CONST CHAR8 *String\r | |
1156 | );\r | |
1157 | \r | |
1158 | \r | |
1159 | /**\r | |
1160 | Returns the size of a Null-terminated ASCII string in bytes, including the\r | |
1161 | Null terminator.\r | |
1162 | \r | |
1163 | This function returns the size, in bytes, of the Null-terminated ASCII string\r | |
1164 | specified by String.\r | |
1165 | \r | |
1166 | If String is NULL, then ASSERT().\r | |
1167 | If PcdMaximumAsciiStringLength is not zero and String contains more than\r | |
1168 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r | |
1169 | then ASSERT().\r | |
1170 | \r | |
af2dc6a7 | 1171 | @param String The pointer to a Null-terminated ASCII string.\r |
ac644614 | 1172 | \r |
1173 | @return The size of String.\r | |
1174 | \r | |
1175 | **/\r | |
1176 | UINTN\r | |
1177 | EFIAPI\r | |
1178 | AsciiStrSize (\r | |
1179 | IN CONST CHAR8 *String\r | |
1180 | );\r | |
1181 | \r | |
1182 | \r | |
1183 | /**\r | |
1184 | Compares two Null-terminated ASCII strings, and returns the difference\r | |
1185 | between the first mismatched ASCII characters.\r | |
1186 | \r | |
1187 | This function compares the Null-terminated ASCII string FirstString to the\r | |
1188 | Null-terminated ASCII string SecondString. If FirstString is identical to\r | |
1189 | SecondString, then 0 is returned. Otherwise, the value returned is the first\r | |
1190 | mismatched ASCII character in SecondString subtracted from the first\r | |
1191 | mismatched ASCII character in FirstString.\r | |
1192 | \r | |
1193 | If FirstString is NULL, then ASSERT().\r | |
1194 | If SecondString is NULL, then ASSERT().\r | |
1195 | If PcdMaximumAsciiStringLength is not zero and FirstString contains more than\r | |
1196 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r | |
1197 | then ASSERT().\r | |
1198 | If PcdMaximumAsciiStringLength is not zero and SecondString contains more\r | |
1199 | than PcdMaximumAsciiStringLength ASCII characters not including the\r | |
1200 | Null-terminator, then ASSERT().\r | |
1201 | \r | |
af2dc6a7 | 1202 | @param FirstString The pointer to a Null-terminated ASCII string.\r |
1203 | @param SecondString The pointer to a Null-terminated ASCII string.\r | |
ac644614 | 1204 | \r |
17f695ed | 1205 | @retval ==0 FirstString is identical to SecondString.\r |
1206 | @retval !=0 FirstString is not identical to SecondString.\r | |
ac644614 | 1207 | \r |
1208 | **/\r | |
1209 | INTN\r | |
1210 | EFIAPI\r | |
1211 | AsciiStrCmp (\r | |
1212 | IN CONST CHAR8 *FirstString,\r | |
1213 | IN CONST CHAR8 *SecondString\r | |
1214 | );\r | |
1215 | \r | |
1216 | \r | |
1217 | /**\r | |
1218 | Performs a case insensitive comparison of two Null-terminated ASCII strings,\r | |
1219 | and returns the difference between the first mismatched ASCII characters.\r | |
1220 | \r | |
1221 | This function performs a case insensitive comparison of the Null-terminated\r | |
1222 | ASCII string FirstString to the Null-terminated ASCII string SecondString. If\r | |
1223 | FirstString is identical to SecondString, then 0 is returned. Otherwise, the\r | |
1224 | value returned is the first mismatched lower case ASCII character in\r | |
1225 | SecondString subtracted from the first mismatched lower case ASCII character\r | |
1226 | in FirstString.\r | |
1227 | \r | |
1228 | If FirstString is NULL, then ASSERT().\r | |
1229 | If SecondString is NULL, then ASSERT().\r | |
1230 | If PcdMaximumAsciiStringLength is not zero and FirstString contains more than\r | |
1231 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r | |
1232 | then ASSERT().\r | |
1233 | If PcdMaximumAsciiStringLength is not zero and SecondString contains more\r | |
1234 | than PcdMaximumAsciiStringLength ASCII characters not including the\r | |
1235 | Null-terminator, then ASSERT().\r | |
1236 | \r | |
af2dc6a7 | 1237 | @param FirstString The pointer to a Null-terminated ASCII string.\r |
1238 | @param SecondString The pointer to a Null-terminated ASCII string.\r | |
ac644614 | 1239 | \r |
17f695ed | 1240 | @retval ==0 FirstString is identical to SecondString using case insensitive\r |
1106ffe1 | 1241 | comparisons.\r |
17f695ed | 1242 | @retval !=0 FirstString is not identical to SecondString using case\r |
1106ffe1 | 1243 | insensitive comparisons.\r |
ac644614 | 1244 | \r |
1245 | **/\r | |
1246 | INTN\r | |
1247 | EFIAPI\r | |
1248 | AsciiStriCmp (\r | |
1249 | IN CONST CHAR8 *FirstString,\r | |
1250 | IN CONST CHAR8 *SecondString\r | |
1251 | );\r | |
1252 | \r | |
1253 | \r | |
1254 | /**\r | |
1255 | Compares two Null-terminated ASCII strings with maximum lengths, and returns\r | |
1256 | the difference between the first mismatched ASCII characters.\r | |
1257 | \r | |
1258 | This function compares the Null-terminated ASCII string FirstString to the\r | |
1259 | Null-terminated ASCII string SecondString. At most, Length ASCII characters\r | |
1260 | will be compared. If Length is 0, then 0 is returned. If FirstString is\r | |
1261 | identical to SecondString, then 0 is returned. Otherwise, the value returned\r | |
1262 | is the first mismatched ASCII character in SecondString subtracted from the\r | |
1263 | first mismatched ASCII character in FirstString.\r | |
1264 | \r | |
1265 | If Length > 0 and FirstString is NULL, then ASSERT().\r | |
1266 | If Length > 0 and SecondString is NULL, then ASSERT().\r | |
50c247fd | 1267 | If PcdMaximumAsciiStringLength is not zero, and Length is greater than \r |
1268 | PcdMaximumAsciiStringLength, then ASSERT().\r | |
1269 | If PcdMaximumAsciiStringLength is not zero, and FirstString contains more than\r | |
1270 | PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,\r | |
ac644614 | 1271 | then ASSERT().\r |
50c247fd | 1272 | If PcdMaximumAsciiStringLength is not zero, and SecondString contains more than\r |
1273 | PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,\r | |
ac644614 | 1274 | then ASSERT().\r |
1275 | \r | |
af2dc6a7 | 1276 | @param FirstString The pointer to a Null-terminated ASCII string.\r |
1277 | @param SecondString The pointer to a Null-terminated ASCII string.\r | |
1278 | @param Length The maximum number of ASCII characters for compare.\r | |
ac644614 | 1279 | \r |
17f695ed | 1280 | @retval ==0 FirstString is identical to SecondString.\r |
1281 | @retval !=0 FirstString is not identical to SecondString.\r | |
ac644614 | 1282 | \r |
1283 | **/\r | |
1284 | INTN\r | |
1285 | EFIAPI\r | |
1286 | AsciiStrnCmp (\r | |
1287 | IN CONST CHAR8 *FirstString,\r | |
1288 | IN CONST CHAR8 *SecondString,\r | |
1289 | IN UINTN Length\r | |
1290 | );\r | |
1291 | \r | |
1292 | \r | |
1bb390f1 ED |
1293 | #ifndef DISABLE_NEW_DEPRECATED_INTERFACES\r |
1294 | \r | |
ac644614 | 1295 | /**\r |
ae591c14 | 1296 | [ATTENTION] This function is deprecated for security reason.\r |
1bb390f1 | 1297 | \r |
ac644614 | 1298 | Concatenates one Null-terminated ASCII string to another Null-terminated\r |
1299 | ASCII string, and returns the concatenated ASCII string.\r | |
1300 | \r | |
1301 | This function concatenates two Null-terminated ASCII strings. The contents of\r | |
1302 | Null-terminated ASCII string Source are concatenated to the end of Null-\r | |
1303 | terminated ASCII string Destination. The Null-terminated concatenated ASCII\r | |
1304 | String is returned.\r | |
1305 | \r | |
1306 | If Destination is NULL, then ASSERT().\r | |
1307 | If Source is NULL, then ASSERT().\r | |
1308 | If PcdMaximumAsciiStringLength is not zero and Destination contains more than\r | |
1309 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r | |
1310 | then ASSERT().\r | |
1311 | If PcdMaximumAsciiStringLength is not zero and Source contains more than\r | |
1312 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r | |
1313 | then ASSERT().\r | |
1314 | If PcdMaximumAsciiStringLength is not zero and concatenating Destination and\r | |
1315 | Source results in a ASCII string with more than PcdMaximumAsciiStringLength\r | |
1316 | ASCII characters, then ASSERT().\r | |
1317 | \r | |
af2dc6a7 | 1318 | @param Destination The pointer to a Null-terminated ASCII string.\r |
1319 | @param Source The pointer to a Null-terminated ASCII string.\r | |
ac644614 | 1320 | \r |
1321 | @return Destination\r | |
1322 | \r | |
1323 | **/\r | |
1324 | CHAR8 *\r | |
1325 | EFIAPI\r | |
1326 | AsciiStrCat (\r | |
1327 | IN OUT CHAR8 *Destination,\r | |
1328 | IN CONST CHAR8 *Source\r | |
1329 | );\r | |
1330 | \r | |
1331 | \r | |
1332 | /**\r | |
ae591c14 | 1333 | [ATTENTION] This function is deprecated for security reason.\r |
1bb390f1 | 1334 | \r |
17f695ed | 1335 | Concatenates up to a specified length one Null-terminated ASCII string to \r |
1336 | the end of another Null-terminated ASCII string, and returns the \r | |
1337 | concatenated ASCII string.\r | |
ac644614 | 1338 | \r |
1339 | This function concatenates two Null-terminated ASCII strings. The contents\r | |
1340 | of Null-terminated ASCII string Source are concatenated to the end of Null-\r | |
1341 | terminated ASCII string Destination, and Destination is returned. At most,\r | |
1342 | Length ASCII characters are concatenated from Source to the end of\r | |
1343 | Destination, and Destination is always Null-terminated. If Length is 0, then\r | |
1344 | Destination is returned unmodified. If Source and Destination overlap, then\r | |
1345 | the results are undefined.\r | |
1346 | \r | |
1347 | If Length > 0 and Destination is NULL, then ASSERT().\r | |
1348 | If Length > 0 and Source is NULL, then ASSERT().\r | |
1349 | If Source and Destination overlap, then ASSERT().\r | |
50c247fd | 1350 | If PcdMaximumAsciiStringLength is not zero, and Length is greater than\r |
1351 | PcdMaximumAsciiStringLength, then ASSERT().\r | |
ac644614 | 1352 | If PcdMaximumAsciiStringLength is not zero, and Destination contains more than\r |
50c247fd | 1353 | PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,\r |
ac644614 | 1354 | then ASSERT().\r |
1355 | If PcdMaximumAsciiStringLength is not zero, and Source contains more than\r | |
50c247fd | 1356 | PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,\r |
ac644614 | 1357 | then ASSERT().\r |
1358 | If PcdMaximumAsciiStringLength is not zero, and concatenating Destination and\r | |
1359 | Source results in a ASCII string with more than PcdMaximumAsciiStringLength\r | |
50c247fd | 1360 | ASCII characters, not including the Null-terminator, then ASSERT().\r |
ac644614 | 1361 | \r |
af2dc6a7 | 1362 | @param Destination The pointer to a Null-terminated ASCII string.\r |
1363 | @param Source The pointer to a Null-terminated ASCII string.\r | |
1364 | @param Length The maximum number of ASCII characters to concatenate from\r | |
ac644614 | 1365 | Source.\r |
1366 | \r | |
1367 | @return Destination\r | |
1368 | \r | |
1369 | **/\r | |
1370 | CHAR8 *\r | |
1371 | EFIAPI\r | |
1372 | AsciiStrnCat (\r | |
1373 | IN OUT CHAR8 *Destination,\r | |
1374 | IN CONST CHAR8 *Source,\r | |
1375 | IN UINTN Length\r | |
1376 | );\r | |
1bb390f1 | 1377 | #endif\r |
ac644614 | 1378 | \r |
1379 | /**\r | |
9aa049d9 | 1380 | Returns the first occurrence of a Null-terminated ASCII sub-string\r |
ac644614 | 1381 | in a Null-terminated ASCII string.\r |
1382 | \r | |
1383 | This function scans the contents of the ASCII string specified by String\r | |
1384 | and returns the first occurrence of SearchString. If SearchString is not\r | |
1385 | found in String, then NULL is returned. If the length of SearchString is zero,\r | |
1386 | then String is returned.\r | |
1387 | \r | |
1388 | If String is NULL, then ASSERT().\r | |
1389 | If SearchString is NULL, then ASSERT().\r | |
1390 | \r | |
1391 | If PcdMaximumAsciiStringLength is not zero, and SearchString or\r | |
1392 | String contains more than PcdMaximumAsciiStringLength Unicode characters\r | |
1393 | not including the Null-terminator, then ASSERT().\r | |
1394 | \r | |
af2dc6a7 | 1395 | @param String The pointer to a Null-terminated ASCII string.\r |
1396 | @param SearchString The pointer to a Null-terminated ASCII string to search for.\r | |
ac644614 | 1397 | \r |
1398 | @retval NULL If the SearchString does not appear in String.\r | |
17f695ed | 1399 | @retval others If there is a match return the first occurrence of SearchingString.\r |
9aa049d9 | 1400 | If the length of SearchString is zero,return String.\r |
ac644614 | 1401 | \r |
1402 | **/\r | |
1403 | CHAR8 *\r | |
1404 | EFIAPI\r | |
1405 | AsciiStrStr (\r | |
17f695ed | 1406 | IN CONST CHAR8 *String,\r |
1407 | IN CONST CHAR8 *SearchString\r | |
ac644614 | 1408 | );\r |
1409 | \r | |
1410 | \r | |
1411 | /**\r | |
1412 | Convert a Null-terminated ASCII decimal string to a value of type\r | |
1413 | UINTN.\r | |
1414 | \r | |
1415 | This function returns a value of type UINTN by interpreting the contents\r | |
1416 | of the ASCII string String as a decimal number. The format of the input\r | |
1417 | ASCII string String is:\r | |
1418 | \r | |
1419 | [spaces] [decimal digits].\r | |
1420 | \r | |
1421 | The valid decimal digit character is in the range [0-9]. The function will\r | |
1422 | ignore the pad space, which includes spaces or tab characters, before the digits.\r | |
1423 | The running zero in the beginning of [decimal digits] will be ignored. Then, the\r | |
1424 | function stops at the first character that is a not a valid decimal character or\r | |
1425 | Null-terminator, whichever on comes first.\r | |
1426 | \r | |
1427 | If String has only pad spaces, then 0 is returned.\r | |
1428 | If String has no pad spaces or valid decimal digits, then 0 is returned.\r | |
1429 | If the number represented by String overflows according to the range defined by\r | |
1430 | UINTN, then ASSERT().\r | |
1431 | If String is NULL, then ASSERT().\r | |
1432 | If PcdMaximumAsciiStringLength is not zero, and String contains more than\r | |
1433 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r | |
1434 | then ASSERT().\r | |
1435 | \r | |
af2dc6a7 | 1436 | @param String The pointer to a Null-terminated ASCII string.\r |
ac644614 | 1437 | \r |
af2dc6a7 | 1438 | @retval The value translated from String.\r |
ac644614 | 1439 | \r |
1440 | **/\r | |
1441 | UINTN\r | |
1442 | EFIAPI\r | |
1443 | AsciiStrDecimalToUintn (\r | |
1444 | IN CONST CHAR8 *String\r | |
1445 | );\r | |
1446 | \r | |
1447 | \r | |
1448 | /**\r | |
1449 | Convert a Null-terminated ASCII decimal string to a value of type\r | |
1450 | UINT64.\r | |
1451 | \r | |
1452 | This function returns a value of type UINT64 by interpreting the contents\r | |
1453 | of the ASCII string String as a decimal number. The format of the input\r | |
1454 | ASCII string String is:\r | |
1455 | \r | |
1456 | [spaces] [decimal digits].\r | |
1457 | \r | |
1458 | The valid decimal digit character is in the range [0-9]. The function will\r | |
1459 | ignore the pad space, which includes spaces or tab characters, before the digits.\r | |
1460 | The running zero in the beginning of [decimal digits] will be ignored. Then, the\r | |
1461 | function stops at the first character that is a not a valid decimal character or\r | |
1462 | Null-terminator, whichever on comes first.\r | |
1463 | \r | |
1464 | If String has only pad spaces, then 0 is returned.\r | |
1465 | If String has no pad spaces or valid decimal digits, then 0 is returned.\r | |
1466 | If the number represented by String overflows according to the range defined by\r | |
1467 | UINT64, then ASSERT().\r | |
1468 | If String is NULL, then ASSERT().\r | |
1469 | If PcdMaximumAsciiStringLength is not zero, and String contains more than\r | |
1470 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r | |
1471 | then ASSERT().\r | |
1472 | \r | |
af2dc6a7 | 1473 | @param String The pointer to a Null-terminated ASCII string.\r |
ac644614 | 1474 | \r |
38bbd3d9 | 1475 | @retval Value translated from String.\r |
ac644614 | 1476 | \r |
1477 | **/\r | |
1478 | UINT64\r | |
1479 | EFIAPI\r | |
1480 | AsciiStrDecimalToUint64 (\r | |
17f695ed | 1481 | IN CONST CHAR8 *String\r |
ac644614 | 1482 | );\r |
1483 | \r | |
1484 | \r | |
1485 | /**\r | |
1486 | Convert a Null-terminated ASCII hexadecimal string to a value of type UINTN.\r | |
1487 | \r | |
1488 | This function returns a value of type UINTN by interpreting the contents of\r | |
1489 | the ASCII string String as a hexadecimal number. The format of the input ASCII\r | |
1490 | string String is:\r | |
1491 | \r | |
1492 | [spaces][zeros][x][hexadecimal digits].\r | |
1493 | \r | |
1494 | The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].\r | |
1495 | The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"\r | |
1496 | appears in the input string, it must be prefixed with at least one 0. The function\r | |
1497 | will ignore the pad space, which includes spaces or tab characters, before [zeros],\r | |
1498 | [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]\r | |
1499 | will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal\r | |
1500 | digit. Then, the function stops at the first character that is a not a valid\r | |
1501 | hexadecimal character or Null-terminator, whichever on comes first.\r | |
1502 | \r | |
1503 | If String has only pad spaces, then 0 is returned.\r | |
1504 | If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then\r | |
1505 | 0 is returned.\r | |
1506 | \r | |
1507 | If the number represented by String overflows according to the range defined by UINTN,\r | |
1508 | then ASSERT().\r | |
1509 | If String is NULL, then ASSERT().\r | |
1510 | If PcdMaximumAsciiStringLength is not zero,\r | |
1511 | and String contains more than PcdMaximumAsciiStringLength ASCII characters not including\r | |
1512 | the Null-terminator, then ASSERT().\r | |
1513 | \r | |
af2dc6a7 | 1514 | @param String The pointer to a Null-terminated ASCII string.\r |
ac644614 | 1515 | \r |
38bbd3d9 | 1516 | @retval Value translated from String.\r |
ac644614 | 1517 | \r |
1518 | **/\r | |
1519 | UINTN\r | |
1520 | EFIAPI\r | |
1521 | AsciiStrHexToUintn (\r | |
17f695ed | 1522 | IN CONST CHAR8 *String\r |
ac644614 | 1523 | );\r |
1524 | \r | |
1525 | \r | |
1526 | /**\r | |
1527 | Convert a Null-terminated ASCII hexadecimal string to a value of type UINT64.\r | |
1528 | \r | |
1529 | This function returns a value of type UINT64 by interpreting the contents of\r | |
1530 | the ASCII string String as a hexadecimal number. The format of the input ASCII\r | |
1531 | string String is:\r | |
1532 | \r | |
1533 | [spaces][zeros][x][hexadecimal digits].\r | |
1534 | \r | |
1535 | The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].\r | |
1536 | The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"\r | |
1537 | appears in the input string, it must be prefixed with at least one 0. The function\r | |
1538 | will ignore the pad space, which includes spaces or tab characters, before [zeros],\r | |
1539 | [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]\r | |
1540 | will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal\r | |
1541 | digit. Then, the function stops at the first character that is a not a valid\r | |
1542 | hexadecimal character or Null-terminator, whichever on comes first.\r | |
1543 | \r | |
1544 | If String has only pad spaces, then 0 is returned.\r | |
1545 | If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then\r | |
1546 | 0 is returned.\r | |
1547 | \r | |
1548 | If the number represented by String overflows according to the range defined by UINT64,\r | |
1549 | then ASSERT().\r | |
1550 | If String is NULL, then ASSERT().\r | |
1551 | If PcdMaximumAsciiStringLength is not zero,\r | |
1552 | and String contains more than PcdMaximumAsciiStringLength ASCII characters not including\r | |
1553 | the Null-terminator, then ASSERT().\r | |
1554 | \r | |
af2dc6a7 | 1555 | @param String The pointer to a Null-terminated ASCII string.\r |
ac644614 | 1556 | \r |
38bbd3d9 | 1557 | @retval Value translated from String.\r |
ac644614 | 1558 | \r |
1559 | **/\r | |
1560 | UINT64\r | |
1561 | EFIAPI\r | |
1562 | AsciiStrHexToUint64 (\r | |
17f695ed | 1563 | IN CONST CHAR8 *String\r |
ac644614 | 1564 | );\r |
1565 | \r | |
1566 | \r | |
1567 | /**\r | |
1568 | Convert one Null-terminated ASCII string to a Null-terminated\r | |
1569 | Unicode string and returns the Unicode string.\r | |
1570 | \r | |
1571 | This function converts the contents of the ASCII string Source to the Unicode\r | |
1572 | string Destination, and returns Destination. The function terminates the\r | |
1573 | Unicode string Destination by appending a Null-terminator character at the end.\r | |
1574 | The caller is responsible to make sure Destination points to a buffer with size\r | |
1575 | equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.\r | |
1576 | \r | |
1577 | If Destination is NULL, then ASSERT().\r | |
1578 | If Destination is not aligned on a 16-bit boundary, then ASSERT().\r | |
1579 | If Source is NULL, then ASSERT().\r | |
1580 | If Source and Destination overlap, then ASSERT().\r | |
1581 | If PcdMaximumAsciiStringLength is not zero, and Source contains more than\r | |
1582 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r | |
1583 | then ASSERT().\r | |
1584 | If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r | |
1585 | PcdMaximumUnicodeStringLength ASCII characters not including the\r | |
1586 | Null-terminator, then ASSERT().\r | |
1587 | \r | |
af2dc6a7 | 1588 | @param Source The pointer to a Null-terminated ASCII string.\r |
1589 | @param Destination The pointer to a Null-terminated Unicode string.\r | |
ac644614 | 1590 | \r |
9aa049d9 | 1591 | @return Destination.\r |
ac644614 | 1592 | \r |
1593 | **/\r | |
1594 | CHAR16 *\r | |
1595 | EFIAPI\r | |
1596 | AsciiStrToUnicodeStr (\r | |
17f695ed | 1597 | IN CONST CHAR8 *Source,\r |
1598 | OUT CHAR16 *Destination\r | |
ac644614 | 1599 | );\r |
1600 | \r | |
1601 | \r | |
1602 | /**\r | |
1603 | Converts an 8-bit value to an 8-bit BCD value.\r | |
1604 | \r | |
1605 | Converts the 8-bit value specified by Value to BCD. The BCD value is\r | |
1606 | returned.\r | |
1607 | \r | |
1608 | If Value >= 100, then ASSERT().\r | |
1609 | \r | |
1610 | @param Value The 8-bit value to convert to BCD. Range 0..99.\r | |
1611 | \r | |
9aa049d9 | 1612 | @return The BCD value.\r |
ac644614 | 1613 | \r |
1614 | **/\r | |
1615 | UINT8\r | |
1616 | EFIAPI\r | |
1617 | DecimalToBcd8 (\r | |
1618 | IN UINT8 Value\r | |
1619 | );\r | |
1620 | \r | |
1621 | \r | |
1622 | /**\r | |
1623 | Converts an 8-bit BCD value to an 8-bit value.\r | |
1624 | \r | |
1625 | Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit\r | |
1626 | value is returned.\r | |
1627 | \r | |
1628 | If Value >= 0xA0, then ASSERT().\r | |
1629 | If (Value & 0x0F) >= 0x0A, then ASSERT().\r | |
1630 | \r | |
1631 | @param Value The 8-bit BCD value to convert to an 8-bit value.\r | |
1632 | \r | |
1633 | @return The 8-bit value is returned.\r | |
1634 | \r | |
1635 | **/\r | |
1636 | UINT8\r | |
1637 | EFIAPI\r | |
1638 | BcdToDecimal8 (\r | |
1639 | IN UINT8 Value\r | |
1640 | );\r | |
1641 | \r | |
ae591c14 DM |
1642 | //\r |
1643 | // File Path Manipulation Functions\r | |
1644 | //\r | |
1645 | \r | |
1646 | /**\r | |
1647 | Removes the last directory or file entry in a path by changing the last\r | |
1648 | L'\' to a CHAR_NULL.\r | |
1649 | \r | |
1650 | @param[in, out] Path The pointer to the path to modify.\r | |
1651 | \r | |
1652 | @retval FALSE Nothing was found to remove.\r | |
1653 | @retval TRUE A directory or file was removed.\r | |
1654 | **/\r | |
1655 | BOOLEAN\r | |
1656 | EFIAPI\r | |
1657 | PathRemoveLastItem(\r | |
1658 | IN OUT CHAR16 *Path\r | |
1659 | );\r | |
1660 | \r | |
1661 | /**\r | |
1662 | Function to clean up paths.\r | |
1663 | - Single periods in the path are removed.\r | |
1664 | - Double periods in the path are removed along with a single parent directory.\r | |
1665 | - Forward slashes L'/' are converted to backward slashes L'\'.\r | |
1666 | \r | |
1667 | This will be done inline and the existing buffer may be larger than required\r | |
1668 | upon completion.\r | |
1669 | \r | |
1670 | @param[in] Path The pointer to the string containing the path.\r | |
1671 | \r | |
1672 | @return Returns Path, otherwise returns NULL to indicate that an error has occured.\r | |
1673 | **/\r | |
1674 | CHAR16*\r | |
1675 | EFIAPI\r | |
1676 | PathCleanUpDirectories(\r | |
1677 | IN CHAR16 *Path\r | |
909ac47b | 1678 | );\r |
ac644614 | 1679 | \r |
1680 | //\r | |
1681 | // Linked List Functions and Macros\r | |
1682 | //\r | |
1683 | \r | |
1684 | /**\r | |
1685 | Initializes the head node of a doubly linked list that is declared as a\r | |
1686 | global variable in a module.\r | |
1687 | \r | |
1688 | Initializes the forward and backward links of a new linked list. After\r | |
1689 | initializing a linked list with this macro, the other linked list functions\r | |
1690 | may be used to add and remove nodes from the linked list. This macro results\r | |
1691 | in smaller executables by initializing the linked list in the data section,\r | |
1692 | instead if calling the InitializeListHead() function to perform the\r | |
1693 | equivalent operation.\r | |
1694 | \r | |
77f863ee | 1695 | @param ListHead The head note of a list to initialize.\r |
ac644614 | 1696 | \r |
1697 | **/\r | |
17f695ed | 1698 | #define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&(ListHead), &(ListHead)}\r |
ac644614 | 1699 | \r |
1700 | \r | |
1701 | /**\r | |
1702 | Initializes the head node of a doubly linked list, and returns the pointer to\r | |
1703 | the head node of the doubly linked list.\r | |
1704 | \r | |
1705 | Initializes the forward and backward links of a new linked list. After\r | |
1706 | initializing a linked list with this function, the other linked list\r | |
1707 | functions may be used to add and remove nodes from the linked list. It is up\r | |
1708 | to the caller of this function to allocate the memory for ListHead.\r | |
1709 | \r | |
1710 | If ListHead is NULL, then ASSERT().\r | |
1711 | \r | |
1712 | @param ListHead A pointer to the head node of a new doubly linked list.\r | |
1713 | \r | |
1714 | @return ListHead\r | |
1715 | \r | |
1716 | **/\r | |
1717 | LIST_ENTRY *\r | |
1718 | EFIAPI\r | |
1719 | InitializeListHead (\r | |
aa0583c7 | 1720 | IN OUT LIST_ENTRY *ListHead\r |
ac644614 | 1721 | );\r |
1722 | \r | |
1723 | \r | |
1724 | /**\r | |
1725 | Adds a node to the beginning of a doubly linked list, and returns the pointer\r | |
1726 | to the head node of the doubly linked list.\r | |
1727 | \r | |
1728 | Adds the node Entry at the beginning of the doubly linked list denoted by\r | |
1729 | ListHead, and returns ListHead.\r | |
1730 | \r | |
1731 | If ListHead is NULL, then ASSERT().\r | |
1732 | If Entry is NULL, then ASSERT().\r | |
17f695ed | 1733 | If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or\r |
1734 | InitializeListHead(), then ASSERT().\r | |
a71865b1 | 1735 | If PcdMaximumLinkedListLength is not zero, and prior to insertion the number\r |
ac644614 | 1736 | of nodes in ListHead, including the ListHead node, is greater than or\r |
1737 | equal to PcdMaximumLinkedListLength, then ASSERT().\r | |
1738 | \r | |
1739 | @param ListHead A pointer to the head node of a doubly linked list.\r | |
1740 | @param Entry A pointer to a node that is to be inserted at the beginning\r | |
1741 | of a doubly linked list.\r | |
1742 | \r | |
1743 | @return ListHead\r | |
1744 | \r | |
1745 | **/\r | |
1746 | LIST_ENTRY *\r | |
1747 | EFIAPI\r | |
1748 | InsertHeadList (\r | |
aa0583c7 | 1749 | IN OUT LIST_ENTRY *ListHead,\r |
1750 | IN OUT LIST_ENTRY *Entry\r | |
ac644614 | 1751 | );\r |
1752 | \r | |
1753 | \r | |
1754 | /**\r | |
1755 | Adds a node to the end of a doubly linked list, and returns the pointer to\r | |
1756 | the head node of the doubly linked list.\r | |
1757 | \r | |
1758 | Adds the node Entry to the end of the doubly linked list denoted by ListHead,\r | |
1759 | and returns ListHead.\r | |
1760 | \r | |
1761 | If ListHead is NULL, then ASSERT().\r | |
1762 | If Entry is NULL, then ASSERT().\r | |
17f695ed | 1763 | If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or \r |
1764 | InitializeListHead(), then ASSERT().\r | |
a71865b1 | 1765 | If PcdMaximumLinkedListLength is not zero, and prior to insertion the number\r |
ac644614 | 1766 | of nodes in ListHead, including the ListHead node, is greater than or\r |
1767 | equal to PcdMaximumLinkedListLength, then ASSERT().\r | |
1768 | \r | |
1769 | @param ListHead A pointer to the head node of a doubly linked list.\r | |
1770 | @param Entry A pointer to a node that is to be added at the end of the\r | |
1771 | doubly linked list.\r | |
1772 | \r | |
1773 | @return ListHead\r | |
1774 | \r | |
1775 | **/\r | |
1776 | LIST_ENTRY *\r | |
1777 | EFIAPI\r | |
1778 | InsertTailList (\r | |
aa0583c7 | 1779 | IN OUT LIST_ENTRY *ListHead,\r |
1780 | IN OUT LIST_ENTRY *Entry\r | |
ac644614 | 1781 | );\r |
1782 | \r | |
1783 | \r | |
1784 | /**\r | |
1785 | Retrieves the first node of a doubly linked list.\r | |
1786 | \r | |
17f695ed | 1787 | Returns the first node of a doubly linked list. List must have been \r |
1788 | initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().\r | |
1789 | If List is empty, then List is returned.\r | |
ac644614 | 1790 | \r |
1791 | If List is NULL, then ASSERT().\r | |
17f695ed | 1792 | If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or \r |
1793 | InitializeListHead(), then ASSERT().\r | |
a71865b1 | 1794 | If PcdMaximumLinkedListLength is not zero, and the number of nodes\r |
ac644614 | 1795 | in List, including the List node, is greater than or equal to\r |
1796 | PcdMaximumLinkedListLength, then ASSERT().\r | |
1797 | \r | |
1798 | @param List A pointer to the head node of a doubly linked list.\r | |
1799 | \r | |
1800 | @return The first node of a doubly linked list.\r | |
e01a125f | 1801 | @retval List The list is empty.\r |
ac644614 | 1802 | \r |
1803 | **/\r | |
1804 | LIST_ENTRY *\r | |
1805 | EFIAPI\r | |
1806 | GetFirstNode (\r | |
1807 | IN CONST LIST_ENTRY *List\r | |
1808 | );\r | |
1809 | \r | |
1810 | \r | |
1811 | /**\r | |
1812 | Retrieves the next node of a doubly linked list.\r | |
1813 | \r | |
17f695ed | 1814 | Returns the node of a doubly linked list that follows Node. \r |
1815 | List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()\r | |
1816 | or InitializeListHead(). If List is empty, then List is returned.\r | |
ac644614 | 1817 | \r |
1818 | If List is NULL, then ASSERT().\r | |
1819 | If Node is NULL, then ASSERT().\r | |
17f695ed | 1820 | If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or \r |
1821 | InitializeListHead(), then ASSERT().\r | |
a71865b1 LG |
1822 | If PcdMaximumLinkedListLength is not zero, and List contains more than\r |
1823 | PcdMaximumLinkedListLength nodes, then ASSERT().\r | |
1081f624 | 1824 | If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().\r |
ac644614 | 1825 | \r |
1826 | @param List A pointer to the head node of a doubly linked list.\r | |
1827 | @param Node A pointer to a node in the doubly linked list.\r | |
1828 | \r | |
af2dc6a7 | 1829 | @return The pointer to the next node if one exists. Otherwise List is returned.\r |
ac644614 | 1830 | \r |
1831 | **/\r | |
1832 | LIST_ENTRY *\r | |
1833 | EFIAPI\r | |
1834 | GetNextNode (\r | |
1835 | IN CONST LIST_ENTRY *List,\r | |
1836 | IN CONST LIST_ENTRY *Node\r | |
1837 | );\r | |
1838 | \r | |
cbca8de5 | 1839 | \r |
1840 | /**\r | |
1841 | Retrieves the previous node of a doubly linked list.\r | |
1842 | \r | |
1843 | Returns the node of a doubly linked list that precedes Node. \r | |
1844 | List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()\r | |
1845 | or InitializeListHead(). If List is empty, then List is returned.\r | |
1846 | \r | |
1847 | If List is NULL, then ASSERT().\r | |
1848 | If Node is NULL, then ASSERT().\r | |
1849 | If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or \r | |
1850 | InitializeListHead(), then ASSERT().\r | |
a71865b1 LG |
1851 | If PcdMaximumLinkedListLength is not zero, and List contains more than\r |
1852 | PcdMaximumLinkedListLength nodes, then ASSERT().\r | |
cbca8de5 | 1853 | If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().\r |
1854 | \r | |
1855 | @param List A pointer to the head node of a doubly linked list.\r | |
1856 | @param Node A pointer to a node in the doubly linked list.\r | |
1857 | \r | |
af2dc6a7 | 1858 | @return The pointer to the previous node if one exists. Otherwise List is returned.\r |
cbca8de5 | 1859 | \r |
1860 | **/\r | |
1861 | LIST_ENTRY *\r | |
1862 | EFIAPI\r | |
1863 | GetPreviousNode (\r | |
1864 | IN CONST LIST_ENTRY *List,\r | |
1865 | IN CONST LIST_ENTRY *Node\r | |
1866 | );\r | |
ac644614 | 1867 | \r |
cbca8de5 | 1868 | \r |
ac644614 | 1869 | /**\r |
1870 | Checks to see if a doubly linked list is empty or not.\r | |
1871 | \r | |
1872 | Checks to see if the doubly linked list is empty. If the linked list contains\r | |
1873 | zero nodes, this function returns TRUE. Otherwise, it returns FALSE.\r | |
1874 | \r | |
1875 | If ListHead is NULL, then ASSERT().\r | |
17f695ed | 1876 | If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or \r |
1877 | InitializeListHead(), then ASSERT().\r | |
a71865b1 | 1878 | If PcdMaximumLinkedListLength is not zero, and the number of nodes\r |
ac644614 | 1879 | in List, including the List node, is greater than or equal to\r |
1880 | PcdMaximumLinkedListLength, then ASSERT().\r | |
1881 | \r | |
1882 | @param ListHead A pointer to the head node of a doubly linked list.\r | |
1883 | \r | |
1884 | @retval TRUE The linked list is empty.\r | |
1885 | @retval FALSE The linked list is not empty.\r | |
1886 | \r | |
1887 | **/\r | |
1888 | BOOLEAN\r | |
1889 | EFIAPI\r | |
1890 | IsListEmpty (\r | |
1891 | IN CONST LIST_ENTRY *ListHead\r | |
1892 | );\r | |
1893 | \r | |
1894 | \r | |
1895 | /**\r | |
aa0583c7 | 1896 | Determines if a node in a doubly linked list is the head node of a the same\r |
1897 | doubly linked list. This function is typically used to terminate a loop that\r | |
1898 | traverses all the nodes in a doubly linked list starting with the head node.\r | |
ac644614 | 1899 | \r |
aa0583c7 | 1900 | Returns TRUE if Node is equal to List. Returns FALSE if Node is one of the\r |
1901 | nodes in the doubly linked list specified by List. List must have been\r | |
17f695ed | 1902 | initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().\r |
ac644614 | 1903 | \r |
1904 | If List is NULL, then ASSERT().\r | |
1905 | If Node is NULL, then ASSERT().\r | |
17f695ed | 1906 | If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead(), \r |
1907 | then ASSERT().\r | |
a71865b1 | 1908 | If PcdMaximumLinkedListLength is not zero, and the number of nodes\r |
ac644614 | 1909 | in List, including the List node, is greater than or equal to\r |
1910 | PcdMaximumLinkedListLength, then ASSERT().\r | |
1081f624 | 1911 | If PcdVerifyNodeInList is TRUE and Node is not a node in List the and Node is not equal \r |
1912 | to List, then ASSERT().\r | |
ac644614 | 1913 | \r |
1914 | @param List A pointer to the head node of a doubly linked list.\r | |
1915 | @param Node A pointer to a node in the doubly linked list.\r | |
1916 | \r | |
1955808d LG |
1917 | @retval TRUE Node is the head of the doubly-linked list pointed by List.\r |
1918 | @retval FALSE Node is not the head of the doubly-linked list pointed by List.\r | |
ac644614 | 1919 | \r |
1920 | **/\r | |
1921 | BOOLEAN\r | |
1922 | EFIAPI\r | |
1923 | IsNull (\r | |
1924 | IN CONST LIST_ENTRY *List,\r | |
1925 | IN CONST LIST_ENTRY *Node\r | |
1926 | );\r | |
1927 | \r | |
1928 | \r | |
1929 | /**\r | |
1930 | Determines if a node the last node in a doubly linked list.\r | |
1931 | \r | |
1932 | Returns TRUE if Node is the last node in the doubly linked list specified by\r | |
1933 | List. Otherwise, FALSE is returned. List must have been initialized with\r | |
17f695ed | 1934 | INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().\r |
ac644614 | 1935 | \r |
1936 | If List is NULL, then ASSERT().\r | |
1937 | If Node is NULL, then ASSERT().\r | |
17f695ed | 1938 | If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or\r |
1939 | InitializeListHead(), then ASSERT().\r | |
a71865b1 | 1940 | If PcdMaximumLinkedListLength is not zero, and the number of nodes\r |
ac644614 | 1941 | in List, including the List node, is greater than or equal to\r |
1942 | PcdMaximumLinkedListLength, then ASSERT().\r | |
1081f624 | 1943 | If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().\r |
ac644614 | 1944 | \r |
1945 | @param List A pointer to the head node of a doubly linked list.\r | |
1946 | @param Node A pointer to a node in the doubly linked list.\r | |
1947 | \r | |
1948 | @retval TRUE Node is the last node in the linked list.\r | |
1949 | @retval FALSE Node is not the last node in the linked list.\r | |
1950 | \r | |
1951 | **/\r | |
1952 | BOOLEAN\r | |
1953 | EFIAPI\r | |
1954 | IsNodeAtEnd (\r | |
1955 | IN CONST LIST_ENTRY *List,\r | |
1956 | IN CONST LIST_ENTRY *Node\r | |
1957 | );\r | |
1958 | \r | |
1959 | \r | |
1960 | /**\r | |
1961 | Swaps the location of two nodes in a doubly linked list, and returns the\r | |
1962 | first node after the swap.\r | |
1963 | \r | |
1964 | If FirstEntry is identical to SecondEntry, then SecondEntry is returned.\r | |
1965 | Otherwise, the location of the FirstEntry node is swapped with the location\r | |
1966 | of the SecondEntry node in a doubly linked list. SecondEntry must be in the\r | |
1967 | same double linked list as FirstEntry and that double linked list must have\r | |
17f695ed | 1968 | been initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead(). \r |
1969 | SecondEntry is returned after the nodes are swapped.\r | |
ac644614 | 1970 | \r |
1971 | If FirstEntry is NULL, then ASSERT().\r | |
1972 | If SecondEntry is NULL, then ASSERT().\r | |
1081f624 | 1973 | If PcdVerifyNodeInList is TRUE and SecondEntry and FirstEntry are not in the \r |
1974 | same linked list, then ASSERT().\r | |
ac644614 | 1975 | If PcdMaximumLinkedListLength is not zero, and the number of nodes in the\r |
1976 | linked list containing the FirstEntry and SecondEntry nodes, including\r | |
1977 | the FirstEntry and SecondEntry nodes, is greater than or equal to\r | |
1978 | PcdMaximumLinkedListLength, then ASSERT().\r | |
1979 | \r | |
1980 | @param FirstEntry A pointer to a node in a linked list.\r | |
1981 | @param SecondEntry A pointer to another node in the same linked list.\r | |
38bbd3d9 | 1982 | \r |
9aa049d9 | 1983 | @return SecondEntry.\r |
ac644614 | 1984 | \r |
1985 | **/\r | |
1986 | LIST_ENTRY *\r | |
1987 | EFIAPI\r | |
1988 | SwapListEntries (\r | |
aa0583c7 | 1989 | IN OUT LIST_ENTRY *FirstEntry,\r |
1990 | IN OUT LIST_ENTRY *SecondEntry\r | |
ac644614 | 1991 | );\r |
1992 | \r | |
1993 | \r | |
1994 | /**\r | |
1995 | Removes a node from a doubly linked list, and returns the node that follows\r | |
1996 | the removed node.\r | |
1997 | \r | |
1998 | Removes the node Entry from a doubly linked list. It is up to the caller of\r | |
1999 | this function to release the memory used by this node if that is required. On\r | |
2000 | exit, the node following Entry in the doubly linked list is returned. If\r | |
2001 | Entry is the only node in the linked list, then the head node of the linked\r | |
2002 | list is returned.\r | |
2003 | \r | |
2004 | If Entry is NULL, then ASSERT().\r | |
2005 | If Entry is the head node of an empty list, then ASSERT().\r | |
2006 | If PcdMaximumLinkedListLength is not zero, and the number of nodes in the\r | |
2007 | linked list containing Entry, including the Entry node, is greater than\r | |
2008 | or equal to PcdMaximumLinkedListLength, then ASSERT().\r | |
2009 | \r | |
9aa049d9 | 2010 | @param Entry A pointer to a node in a linked list.\r |
ac644614 | 2011 | \r |
9aa049d9 | 2012 | @return Entry.\r |
ac644614 | 2013 | \r |
2014 | **/\r | |
2015 | LIST_ENTRY *\r | |
2016 | EFIAPI\r | |
2017 | RemoveEntryList (\r | |
2018 | IN CONST LIST_ENTRY *Entry\r | |
2019 | );\r | |
2020 | \r | |
2021 | //\r | |
2022 | // Math Services\r | |
2023 | //\r | |
2024 | \r | |
2025 | /**\r | |
2026 | Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled\r | |
2027 | with zeros. The shifted value is returned.\r | |
2028 | \r | |
2029 | This function shifts the 64-bit value Operand to the left by Count bits. The\r | |
2030 | low Count bits are set to zero. The shifted value is returned.\r | |
2031 | \r | |
2032 | If Count is greater than 63, then ASSERT().\r | |
2033 | \r | |
2034 | @param Operand The 64-bit operand to shift left.\r | |
2035 | @param Count The number of bits to shift left.\r | |
2036 | \r | |
9aa049d9 | 2037 | @return Operand << Count.\r |
ac644614 | 2038 | \r |
2039 | **/\r | |
2040 | UINT64\r | |
2041 | EFIAPI\r | |
2042 | LShiftU64 (\r | |
2043 | IN UINT64 Operand,\r | |
2044 | IN UINTN Count\r | |
2045 | );\r | |
2046 | \r | |
2047 | \r | |
2048 | /**\r | |
2049 | Shifts a 64-bit integer right between 0 and 63 bits. This high bits are\r | |
2050 | filled with zeros. The shifted value is returned.\r | |
2051 | \r | |
2052 | This function shifts the 64-bit value Operand to the right by Count bits. The\r | |
2053 | high Count bits are set to zero. The shifted value is returned.\r | |
2054 | \r | |
2055 | If Count is greater than 63, then ASSERT().\r | |
2056 | \r | |
2057 | @param Operand The 64-bit operand to shift right.\r | |
2058 | @param Count The number of bits to shift right.\r | |
2059 | \r | |
2060 | @return Operand >> Count\r | |
2061 | \r | |
2062 | **/\r | |
2063 | UINT64\r | |
2064 | EFIAPI\r | |
2065 | RShiftU64 (\r | |
2066 | IN UINT64 Operand,\r | |
2067 | IN UINTN Count\r | |
2068 | );\r | |
2069 | \r | |
2070 | \r | |
2071 | /**\r | |
2072 | Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled\r | |
2073 | with original integer's bit 63. The shifted value is returned.\r | |
2074 | \r | |
2075 | This function shifts the 64-bit value Operand to the right by Count bits. The\r | |
2076 | high Count bits are set to bit 63 of Operand. The shifted value is returned.\r | |
2077 | \r | |
2078 | If Count is greater than 63, then ASSERT().\r | |
2079 | \r | |
2080 | @param Operand The 64-bit operand to shift right.\r | |
2081 | @param Count The number of bits to shift right.\r | |
2082 | \r | |
2083 | @return Operand >> Count\r | |
2084 | \r | |
2085 | **/\r | |
2086 | UINT64\r | |
2087 | EFIAPI\r | |
2088 | ARShiftU64 (\r | |
2089 | IN UINT64 Operand,\r | |
2090 | IN UINTN Count\r | |
2091 | );\r | |
2092 | \r | |
2093 | \r | |
2094 | /**\r | |
2095 | Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits\r | |
2096 | with the high bits that were rotated.\r | |
2097 | \r | |
2098 | This function rotates the 32-bit value Operand to the left by Count bits. The\r | |
2099 | low Count bits are fill with the high Count bits of Operand. The rotated\r | |
2100 | value is returned.\r | |
2101 | \r | |
2102 | If Count is greater than 31, then ASSERT().\r | |
2103 | \r | |
2104 | @param Operand The 32-bit operand to rotate left.\r | |
2105 | @param Count The number of bits to rotate left.\r | |
2106 | \r | |
17f695ed | 2107 | @return Operand << Count\r |
ac644614 | 2108 | \r |
2109 | **/\r | |
2110 | UINT32\r | |
2111 | EFIAPI\r | |
2112 | LRotU32 (\r | |
2113 | IN UINT32 Operand,\r | |
2114 | IN UINTN Count\r | |
2115 | );\r | |
2116 | \r | |
2117 | \r | |
2118 | /**\r | |
2119 | Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits\r | |
2120 | with the low bits that were rotated.\r | |
2121 | \r | |
2122 | This function rotates the 32-bit value Operand to the right by Count bits.\r | |
2123 | The high Count bits are fill with the low Count bits of Operand. The rotated\r | |
2124 | value is returned.\r | |
2125 | \r | |
2126 | If Count is greater than 31, then ASSERT().\r | |
2127 | \r | |
2128 | @param Operand The 32-bit operand to rotate right.\r | |
2129 | @param Count The number of bits to rotate right.\r | |
2130 | \r | |
2fe241a2 | 2131 | @return Operand >> Count\r |
ac644614 | 2132 | \r |
2133 | **/\r | |
2134 | UINT32\r | |
2135 | EFIAPI\r | |
2136 | RRotU32 (\r | |
2137 | IN UINT32 Operand,\r | |
2138 | IN UINTN Count\r | |
2139 | );\r | |
2140 | \r | |
2141 | \r | |
2142 | /**\r | |
2143 | Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits\r | |
2144 | with the high bits that were rotated.\r | |
2145 | \r | |
2146 | This function rotates the 64-bit value Operand to the left by Count bits. The\r | |
2147 | low Count bits are fill with the high Count bits of Operand. The rotated\r | |
2148 | value is returned.\r | |
2149 | \r | |
2150 | If Count is greater than 63, then ASSERT().\r | |
2151 | \r | |
2152 | @param Operand The 64-bit operand to rotate left.\r | |
2153 | @param Count The number of bits to rotate left.\r | |
2154 | \r | |
17f695ed | 2155 | @return Operand << Count\r |
ac644614 | 2156 | \r |
2157 | **/\r | |
2158 | UINT64\r | |
2159 | EFIAPI\r | |
2160 | LRotU64 (\r | |
2161 | IN UINT64 Operand,\r | |
2162 | IN UINTN Count\r | |
2163 | );\r | |
2164 | \r | |
2165 | \r | |
2166 | /**\r | |
2167 | Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits\r | |
2168 | with the high low bits that were rotated.\r | |
2169 | \r | |
2170 | This function rotates the 64-bit value Operand to the right by Count bits.\r | |
2171 | The high Count bits are fill with the low Count bits of Operand. The rotated\r | |
2172 | value is returned.\r | |
2173 | \r | |
2174 | If Count is greater than 63, then ASSERT().\r | |
2175 | \r | |
2176 | @param Operand The 64-bit operand to rotate right.\r | |
2177 | @param Count The number of bits to rotate right.\r | |
2178 | \r | |
17f695ed | 2179 | @return Operand >> Count\r |
ac644614 | 2180 | \r |
2181 | **/\r | |
2182 | UINT64\r | |
2183 | EFIAPI\r | |
2184 | RRotU64 (\r | |
2185 | IN UINT64 Operand,\r | |
2186 | IN UINTN Count\r | |
2187 | );\r | |
2188 | \r | |
2189 | \r | |
2190 | /**\r | |
2191 | Returns the bit position of the lowest bit set in a 32-bit value.\r | |
2192 | \r | |
2193 | This function computes the bit position of the lowest bit set in the 32-bit\r | |
2194 | value specified by Operand. If Operand is zero, then -1 is returned.\r | |
2195 | Otherwise, a value between 0 and 31 is returned.\r | |
2196 | \r | |
2197 | @param Operand The 32-bit operand to evaluate.\r | |
2198 | \r | |
9aa049d9 | 2199 | @retval 0..31 The lowest bit set in Operand was found.\r |
17f695ed | 2200 | @retval -1 Operand is zero.\r |
ac644614 | 2201 | \r |
2202 | **/\r | |
2203 | INTN\r | |
2204 | EFIAPI\r | |
2205 | LowBitSet32 (\r | |
2206 | IN UINT32 Operand\r | |
2207 | );\r | |
2208 | \r | |
2209 | \r | |
2210 | /**\r | |
2211 | Returns the bit position of the lowest bit set in a 64-bit value.\r | |
2212 | \r | |
2213 | This function computes the bit position of the lowest bit set in the 64-bit\r | |
2214 | value specified by Operand. If Operand is zero, then -1 is returned.\r | |
2215 | Otherwise, a value between 0 and 63 is returned.\r | |
2216 | \r | |
2217 | @param Operand The 64-bit operand to evaluate.\r | |
2218 | \r | |
9aa049d9 | 2219 | @retval 0..63 The lowest bit set in Operand was found.\r |
17f695ed | 2220 | @retval -1 Operand is zero.\r |
2221 | \r | |
ac644614 | 2222 | \r |
2223 | **/\r | |
2224 | INTN\r | |
2225 | EFIAPI\r | |
2226 | LowBitSet64 (\r | |
2227 | IN UINT64 Operand\r | |
2228 | );\r | |
2229 | \r | |
2230 | \r | |
2231 | /**\r | |
2232 | Returns the bit position of the highest bit set in a 32-bit value. Equivalent\r | |
2233 | to log2(x).\r | |
2234 | \r | |
2235 | This function computes the bit position of the highest bit set in the 32-bit\r | |
2236 | value specified by Operand. If Operand is zero, then -1 is returned.\r | |
2237 | Otherwise, a value between 0 and 31 is returned.\r | |
2238 | \r | |
2239 | @param Operand The 32-bit operand to evaluate.\r | |
2240 | \r | |
9aa049d9 | 2241 | @retval 0..31 Position of the highest bit set in Operand if found.\r |
17f695ed | 2242 | @retval -1 Operand is zero.\r |
ac644614 | 2243 | \r |
2244 | **/\r | |
2245 | INTN\r | |
2246 | EFIAPI\r | |
2247 | HighBitSet32 (\r | |
2248 | IN UINT32 Operand\r | |
2249 | );\r | |
2250 | \r | |
2251 | \r | |
2252 | /**\r | |
2253 | Returns the bit position of the highest bit set in a 64-bit value. Equivalent\r | |
2254 | to log2(x).\r | |
2255 | \r | |
2256 | This function computes the bit position of the highest bit set in the 64-bit\r | |
2257 | value specified by Operand. If Operand is zero, then -1 is returned.\r | |
2258 | Otherwise, a value between 0 and 63 is returned.\r | |
2259 | \r | |
2260 | @param Operand The 64-bit operand to evaluate.\r | |
2261 | \r | |
9aa049d9 | 2262 | @retval 0..63 Position of the highest bit set in Operand if found.\r |
17f695ed | 2263 | @retval -1 Operand is zero.\r |
ac644614 | 2264 | \r |
2265 | **/\r | |
2266 | INTN\r | |
2267 | EFIAPI\r | |
2268 | HighBitSet64 (\r | |
2269 | IN UINT64 Operand\r | |
2270 | );\r | |
2271 | \r | |
2272 | \r | |
2273 | /**\r | |
2274 | Returns the value of the highest bit set in a 32-bit value. Equivalent to\r | |
17f695ed | 2275 | 1 << log2(x).\r |
ac644614 | 2276 | \r |
2277 | This function computes the value of the highest bit set in the 32-bit value\r | |
2278 | specified by Operand. If Operand is zero, then zero is returned.\r | |
2279 | \r | |
2280 | @param Operand The 32-bit operand to evaluate.\r | |
2281 | \r | |
2282 | @return 1 << HighBitSet32(Operand)\r | |
2283 | @retval 0 Operand is zero.\r | |
2284 | \r | |
2285 | **/\r | |
2286 | UINT32\r | |
2287 | EFIAPI\r | |
2288 | GetPowerOfTwo32 (\r | |
2289 | IN UINT32 Operand\r | |
2290 | );\r | |
2291 | \r | |
2292 | \r | |
2293 | /**\r | |
2294 | Returns the value of the highest bit set in a 64-bit value. Equivalent to\r | |
17f695ed | 2295 | 1 << log2(x).\r |
ac644614 | 2296 | \r |
2297 | This function computes the value of the highest bit set in the 64-bit value\r | |
2298 | specified by Operand. If Operand is zero, then zero is returned.\r | |
2299 | \r | |
2300 | @param Operand The 64-bit operand to evaluate.\r | |
2301 | \r | |
2302 | @return 1 << HighBitSet64(Operand)\r | |
2303 | @retval 0 Operand is zero.\r | |
2304 | \r | |
2305 | **/\r | |
2306 | UINT64\r | |
2307 | EFIAPI\r | |
2308 | GetPowerOfTwo64 (\r | |
2309 | IN UINT64 Operand\r | |
2310 | );\r | |
2311 | \r | |
2312 | \r | |
2313 | /**\r | |
af2dc6a7 | 2314 | Switches the endianness of a 16-bit integer.\r |
ac644614 | 2315 | \r |
2316 | This function swaps the bytes in a 16-bit unsigned value to switch the value\r | |
2317 | from little endian to big endian or vice versa. The byte swapped value is\r | |
2318 | returned.\r | |
2319 | \r | |
2a53dabf | 2320 | @param Value A 16-bit unsigned value.\r |
ac644614 | 2321 | \r |
efb23117 | 2322 | @return The byte swapped Value.\r |
ac644614 | 2323 | \r |
2324 | **/\r | |
2325 | UINT16\r | |
2326 | EFIAPI\r | |
2327 | SwapBytes16 (\r | |
2328 | IN UINT16 Value\r | |
2329 | );\r | |
2330 | \r | |
2331 | \r | |
2332 | /**\r | |
af2dc6a7 | 2333 | Switches the endianness of a 32-bit integer.\r |
ac644614 | 2334 | \r |
2335 | This function swaps the bytes in a 32-bit unsigned value to switch the value\r | |
2336 | from little endian to big endian or vice versa. The byte swapped value is\r | |
2337 | returned.\r | |
2338 | \r | |
2a53dabf | 2339 | @param Value A 32-bit unsigned value.\r |
ac644614 | 2340 | \r |
efb23117 | 2341 | @return The byte swapped Value.\r |
ac644614 | 2342 | \r |
2343 | **/\r | |
2344 | UINT32\r | |
2345 | EFIAPI\r | |
2346 | SwapBytes32 (\r | |
2347 | IN UINT32 Value\r | |
2348 | );\r | |
2349 | \r | |
2350 | \r | |
2351 | /**\r | |
af2dc6a7 | 2352 | Switches the endianness of a 64-bit integer.\r |
ac644614 | 2353 | \r |
2354 | This function swaps the bytes in a 64-bit unsigned value to switch the value\r | |
2355 | from little endian to big endian or vice versa. The byte swapped value is\r | |
2356 | returned.\r | |
2357 | \r | |
2a53dabf | 2358 | @param Value A 64-bit unsigned value.\r |
ac644614 | 2359 | \r |
efb23117 | 2360 | @return The byte swapped Value.\r |
ac644614 | 2361 | \r |
2362 | **/\r | |
2363 | UINT64\r | |
2364 | EFIAPI\r | |
2365 | SwapBytes64 (\r | |
2366 | IN UINT64 Value\r | |
2367 | );\r | |
2368 | \r | |
2369 | \r | |
2370 | /**\r | |
2371 | Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and\r | |
2372 | generates a 64-bit unsigned result.\r | |
2373 | \r | |
2374 | This function multiples the 64-bit unsigned value Multiplicand by the 32-bit\r | |
2375 | unsigned value Multiplier and generates a 64-bit unsigned result. This 64-\r | |
2376 | bit unsigned result is returned.\r | |
2377 | \r | |
ac644614 | 2378 | @param Multiplicand A 64-bit unsigned value.\r |
2379 | @param Multiplier A 32-bit unsigned value.\r | |
2380 | \r | |
2381 | @return Multiplicand * Multiplier\r | |
2382 | \r | |
2383 | **/\r | |
2384 | UINT64\r | |
2385 | EFIAPI\r | |
2386 | MultU64x32 (\r | |
2387 | IN UINT64 Multiplicand,\r | |
2388 | IN UINT32 Multiplier\r | |
2389 | );\r | |
2390 | \r | |
2391 | \r | |
2392 | /**\r | |
2393 | Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and\r | |
2394 | generates a 64-bit unsigned result.\r | |
2395 | \r | |
2396 | This function multiples the 64-bit unsigned value Multiplicand by the 64-bit\r | |
2397 | unsigned value Multiplier and generates a 64-bit unsigned result. This 64-\r | |
2398 | bit unsigned result is returned.\r | |
2399 | \r | |
ac644614 | 2400 | @param Multiplicand A 64-bit unsigned value.\r |
2401 | @param Multiplier A 64-bit unsigned value.\r | |
2402 | \r | |
af2dc6a7 | 2403 | @return Multiplicand * Multiplier.\r |
ac644614 | 2404 | \r |
2405 | **/\r | |
2406 | UINT64\r | |
2407 | EFIAPI\r | |
2408 | MultU64x64 (\r | |
2409 | IN UINT64 Multiplicand,\r | |
2410 | IN UINT64 Multiplier\r | |
2411 | );\r | |
2412 | \r | |
2413 | \r | |
2414 | /**\r | |
2415 | Multiples a 64-bit signed integer by a 64-bit signed integer and generates a\r | |
2416 | 64-bit signed result.\r | |
2417 | \r | |
2418 | This function multiples the 64-bit signed value Multiplicand by the 64-bit\r | |
2419 | signed value Multiplier and generates a 64-bit signed result. This 64-bit\r | |
2420 | signed result is returned.\r | |
2421 | \r | |
ac644614 | 2422 | @param Multiplicand A 64-bit signed value.\r |
2423 | @param Multiplier A 64-bit signed value.\r | |
2424 | \r | |
2425 | @return Multiplicand * Multiplier\r | |
2426 | \r | |
2427 | **/\r | |
2428 | INT64\r | |
2429 | EFIAPI\r | |
2430 | MultS64x64 (\r | |
2431 | IN INT64 Multiplicand,\r | |
2432 | IN INT64 Multiplier\r | |
2433 | );\r | |
2434 | \r | |
2435 | \r | |
2436 | /**\r | |
2437 | Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates\r | |
2438 | a 64-bit unsigned result.\r | |
2439 | \r | |
2440 | This function divides the 64-bit unsigned value Dividend by the 32-bit\r | |
2441 | unsigned value Divisor and generates a 64-bit unsigned quotient. This\r | |
2442 | function returns the 64-bit unsigned quotient.\r | |
2443 | \r | |
2444 | If Divisor is 0, then ASSERT().\r | |
2445 | \r | |
2446 | @param Dividend A 64-bit unsigned value.\r | |
2447 | @param Divisor A 32-bit unsigned value.\r | |
2448 | \r | |
af2dc6a7 | 2449 | @return Dividend / Divisor.\r |
ac644614 | 2450 | \r |
2451 | **/\r | |
2452 | UINT64\r | |
2453 | EFIAPI\r | |
2454 | DivU64x32 (\r | |
2455 | IN UINT64 Dividend,\r | |
2456 | IN UINT32 Divisor\r | |
2457 | );\r | |
2458 | \r | |
2459 | \r | |
2460 | /**\r | |
2461 | Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates\r | |
2462 | a 32-bit unsigned remainder.\r | |
2463 | \r | |
2464 | This function divides the 64-bit unsigned value Dividend by the 32-bit\r | |
2465 | unsigned value Divisor and generates a 32-bit remainder. This function\r | |
2466 | returns the 32-bit unsigned remainder.\r | |
2467 | \r | |
2468 | If Divisor is 0, then ASSERT().\r | |
2469 | \r | |
2470 | @param Dividend A 64-bit unsigned value.\r | |
2471 | @param Divisor A 32-bit unsigned value.\r | |
2472 | \r | |
af2dc6a7 | 2473 | @return Dividend % Divisor.\r |
ac644614 | 2474 | \r |
2475 | **/\r | |
2476 | UINT32\r | |
2477 | EFIAPI\r | |
2478 | ModU64x32 (\r | |
2479 | IN UINT64 Dividend,\r | |
2480 | IN UINT32 Divisor\r | |
2481 | );\r | |
2482 | \r | |
2483 | \r | |
2484 | /**\r | |
2485 | Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates\r | |
2486 | a 64-bit unsigned result and an optional 32-bit unsigned remainder.\r | |
2487 | \r | |
2488 | This function divides the 64-bit unsigned value Dividend by the 32-bit\r | |
2489 | unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder\r | |
2490 | is not NULL, then the 32-bit unsigned remainder is returned in Remainder.\r | |
2491 | This function returns the 64-bit unsigned quotient.\r | |
2492 | \r | |
2493 | If Divisor is 0, then ASSERT().\r | |
2494 | \r | |
2495 | @param Dividend A 64-bit unsigned value.\r | |
2496 | @param Divisor A 32-bit unsigned value.\r | |
2497 | @param Remainder A pointer to a 32-bit unsigned value. This parameter is\r | |
2498 | optional and may be NULL.\r | |
2499 | \r | |
af2dc6a7 | 2500 | @return Dividend / Divisor.\r |
ac644614 | 2501 | \r |
2502 | **/\r | |
2503 | UINT64\r | |
2504 | EFIAPI\r | |
2505 | DivU64x32Remainder (\r | |
2506 | IN UINT64 Dividend,\r | |
2507 | IN UINT32 Divisor,\r | |
2508 | OUT UINT32 *Remainder OPTIONAL\r | |
2509 | );\r | |
2510 | \r | |
2511 | \r | |
2512 | /**\r | |
2513 | Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates\r | |
2514 | a 64-bit unsigned result and an optional 64-bit unsigned remainder.\r | |
2515 | \r | |
2516 | This function divides the 64-bit unsigned value Dividend by the 64-bit\r | |
2517 | unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder\r | |
2518 | is not NULL, then the 64-bit unsigned remainder is returned in Remainder.\r | |
2519 | This function returns the 64-bit unsigned quotient.\r | |
2520 | \r | |
2521 | If Divisor is 0, then ASSERT().\r | |
2522 | \r | |
2523 | @param Dividend A 64-bit unsigned value.\r | |
2524 | @param Divisor A 64-bit unsigned value.\r | |
2525 | @param Remainder A pointer to a 64-bit unsigned value. This parameter is\r | |
2526 | optional and may be NULL.\r | |
2527 | \r | |
af2dc6a7 | 2528 | @return Dividend / Divisor.\r |
ac644614 | 2529 | \r |
2530 | **/\r | |
2531 | UINT64\r | |
2532 | EFIAPI\r | |
2533 | DivU64x64Remainder (\r | |
2534 | IN UINT64 Dividend,\r | |
2535 | IN UINT64 Divisor,\r | |
2536 | OUT UINT64 *Remainder OPTIONAL\r | |
2537 | );\r | |
2538 | \r | |
2539 | \r | |
2540 | /**\r | |
2541 | Divides a 64-bit signed integer by a 64-bit signed integer and generates a\r | |
2542 | 64-bit signed result and a optional 64-bit signed remainder.\r | |
2543 | \r | |
2544 | This function divides the 64-bit signed value Dividend by the 64-bit signed\r | |
2545 | value Divisor and generates a 64-bit signed quotient. If Remainder is not\r | |
2546 | NULL, then the 64-bit signed remainder is returned in Remainder. This\r | |
2547 | function returns the 64-bit signed quotient.\r | |
2548 | \r | |
9aa049d9 | 2549 | It is the caller's responsibility to not call this function with a Divisor of 0.\r |
17f695ed | 2550 | If Divisor is 0, then the quotient and remainder should be assumed to be \r |
2551 | the largest negative integer.\r | |
2552 | \r | |
ac644614 | 2553 | If Divisor is 0, then ASSERT().\r |
2554 | \r | |
2555 | @param Dividend A 64-bit signed value.\r | |
2556 | @param Divisor A 64-bit signed value.\r | |
2557 | @param Remainder A pointer to a 64-bit signed value. This parameter is\r | |
2558 | optional and may be NULL.\r | |
2559 | \r | |
af2dc6a7 | 2560 | @return Dividend / Divisor.\r |
ac644614 | 2561 | \r |
2562 | **/\r | |
2563 | INT64\r | |
2564 | EFIAPI\r | |
2565 | DivS64x64Remainder (\r | |
2566 | IN INT64 Dividend,\r | |
2567 | IN INT64 Divisor,\r | |
2568 | OUT INT64 *Remainder OPTIONAL\r | |
2569 | );\r | |
2570 | \r | |
2571 | \r | |
2572 | /**\r | |
2573 | Reads a 16-bit value from memory that may be unaligned.\r | |
2574 | \r | |
2575 | This function returns the 16-bit value pointed to by Buffer. The function\r | |
2576 | guarantees that the read operation does not produce an alignment fault.\r | |
2577 | \r | |
2578 | If the Buffer is NULL, then ASSERT().\r | |
2579 | \r | |
af2dc6a7 | 2580 | @param Buffer The pointer to a 16-bit value that may be unaligned.\r |
ac644614 | 2581 | \r |
5385a579 | 2582 | @return The 16-bit value read from Buffer.\r |
ac644614 | 2583 | \r |
2584 | **/\r | |
2585 | UINT16\r | |
2586 | EFIAPI\r | |
2587 | ReadUnaligned16 (\r | |
5385a579 | 2588 | IN CONST UINT16 *Buffer\r |
ac644614 | 2589 | );\r |
2590 | \r | |
2591 | \r | |
2592 | /**\r | |
2593 | Writes a 16-bit value to memory that may be unaligned.\r | |
2594 | \r | |
2595 | This function writes the 16-bit value specified by Value to Buffer. Value is\r | |
2596 | returned. The function guarantees that the write operation does not produce\r | |
2597 | an alignment fault.\r | |
2598 | \r | |
2599 | If the Buffer is NULL, then ASSERT().\r | |
2600 | \r | |
af2dc6a7 | 2601 | @param Buffer The pointer to a 16-bit value that may be unaligned.\r |
ac644614 | 2602 | @param Value 16-bit value to write to Buffer.\r |
2603 | \r | |
5385a579 | 2604 | @return The 16-bit value to write to Buffer.\r |
ac644614 | 2605 | \r |
2606 | **/\r | |
2607 | UINT16\r | |
2608 | EFIAPI\r | |
2609 | WriteUnaligned16 (\r | |
5385a579 | 2610 | OUT UINT16 *Buffer,\r |
2611 | IN UINT16 Value\r | |
ac644614 | 2612 | );\r |
2613 | \r | |
2614 | \r | |
2615 | /**\r | |
2616 | Reads a 24-bit value from memory that may be unaligned.\r | |
2617 | \r | |
2618 | This function returns the 24-bit value pointed to by Buffer. The function\r | |
2619 | guarantees that the read operation does not produce an alignment fault.\r | |
2620 | \r | |
2621 | If the Buffer is NULL, then ASSERT().\r | |
2622 | \r | |
af2dc6a7 | 2623 | @param Buffer The pointer to a 24-bit value that may be unaligned.\r |
ac644614 | 2624 | \r |
5385a579 | 2625 | @return The 24-bit value read from Buffer.\r |
ac644614 | 2626 | \r |
2627 | **/\r | |
2628 | UINT32\r | |
2629 | EFIAPI\r | |
2630 | ReadUnaligned24 (\r | |
5385a579 | 2631 | IN CONST UINT32 *Buffer\r |
ac644614 | 2632 | );\r |
2633 | \r | |
2634 | \r | |
2635 | /**\r | |
2636 | Writes a 24-bit value to memory that may be unaligned.\r | |
2637 | \r | |
2638 | This function writes the 24-bit value specified by Value to Buffer. Value is\r | |
2639 | returned. The function guarantees that the write operation does not produce\r | |
2640 | an alignment fault.\r | |
2641 | \r | |
2642 | If the Buffer is NULL, then ASSERT().\r | |
2643 | \r | |
af2dc6a7 | 2644 | @param Buffer The pointer to a 24-bit value that may be unaligned.\r |
ac644614 | 2645 | @param Value 24-bit value to write to Buffer.\r |
2646 | \r | |
5385a579 | 2647 | @return The 24-bit value to write to Buffer.\r |
ac644614 | 2648 | \r |
2649 | **/\r | |
2650 | UINT32\r | |
2651 | EFIAPI\r | |
2652 | WriteUnaligned24 (\r | |
5385a579 | 2653 | OUT UINT32 *Buffer,\r |
2654 | IN UINT32 Value\r | |
ac644614 | 2655 | );\r |
2656 | \r | |
2657 | \r | |
2658 | /**\r | |
2659 | Reads a 32-bit value from memory that may be unaligned.\r | |
2660 | \r | |
2661 | This function returns the 32-bit value pointed to by Buffer. The function\r | |
2662 | guarantees that the read operation does not produce an alignment fault.\r | |
2663 | \r | |
2664 | If the Buffer is NULL, then ASSERT().\r | |
2665 | \r | |
af2dc6a7 | 2666 | @param Buffer The pointer to a 32-bit value that may be unaligned.\r |
ac644614 | 2667 | \r |
5385a579 | 2668 | @return The 32-bit value read from Buffer.\r |
ac644614 | 2669 | \r |
2670 | **/\r | |
2671 | UINT32\r | |
2672 | EFIAPI\r | |
2673 | ReadUnaligned32 (\r | |
5385a579 | 2674 | IN CONST UINT32 *Buffer\r |
ac644614 | 2675 | );\r |
2676 | \r | |
2677 | \r | |
2678 | /**\r | |
2679 | Writes a 32-bit value to memory that may be unaligned.\r | |
2680 | \r | |
2681 | This function writes the 32-bit value specified by Value to Buffer. Value is\r | |
2682 | returned. The function guarantees that the write operation does not produce\r | |
2683 | an alignment fault.\r | |
2684 | \r | |
2685 | If the Buffer is NULL, then ASSERT().\r | |
2686 | \r | |
af2dc6a7 | 2687 | @param Buffer The pointer to a 32-bit value that may be unaligned.\r |
ac644614 | 2688 | @param Value 32-bit value to write to Buffer.\r |
2689 | \r | |
5385a579 | 2690 | @return The 32-bit value to write to Buffer.\r |
ac644614 | 2691 | \r |
2692 | **/\r | |
2693 | UINT32\r | |
2694 | EFIAPI\r | |
2695 | WriteUnaligned32 (\r | |
5385a579 | 2696 | OUT UINT32 *Buffer,\r |
2697 | IN UINT32 Value\r | |
ac644614 | 2698 | );\r |
2699 | \r | |
2700 | \r | |
2701 | /**\r | |
2702 | Reads a 64-bit value from memory that may be unaligned.\r | |
2703 | \r | |
2704 | This function returns the 64-bit value pointed to by Buffer. The function\r | |
2705 | guarantees that the read operation does not produce an alignment fault.\r | |
2706 | \r | |
2707 | If the Buffer is NULL, then ASSERT().\r | |
2708 | \r | |
af2dc6a7 | 2709 | @param Buffer The pointer to a 64-bit value that may be unaligned.\r |
ac644614 | 2710 | \r |
5385a579 | 2711 | @return The 64-bit value read from Buffer.\r |
ac644614 | 2712 | \r |
2713 | **/\r | |
2714 | UINT64\r | |
2715 | EFIAPI\r | |
2716 | ReadUnaligned64 (\r | |
5385a579 | 2717 | IN CONST UINT64 *Buffer\r |
ac644614 | 2718 | );\r |
2719 | \r | |
2720 | \r | |
2721 | /**\r | |
2722 | Writes a 64-bit value to memory that may be unaligned.\r | |
2723 | \r | |
2724 | This function writes the 64-bit value specified by Value to Buffer. Value is\r | |
2725 | returned. The function guarantees that the write operation does not produce\r | |
2726 | an alignment fault.\r | |
2727 | \r | |
2728 | If the Buffer is NULL, then ASSERT().\r | |
2729 | \r | |
af2dc6a7 | 2730 | @param Buffer The pointer to a 64-bit value that may be unaligned.\r |
ac644614 | 2731 | @param Value 64-bit value to write to Buffer.\r |
2732 | \r | |
5385a579 | 2733 | @return The 64-bit value to write to Buffer.\r |
ac644614 | 2734 | \r |
2735 | **/\r | |
2736 | UINT64\r | |
2737 | EFIAPI\r | |
2738 | WriteUnaligned64 (\r | |
5385a579 | 2739 | OUT UINT64 *Buffer,\r |
2740 | IN UINT64 Value\r | |
ac644614 | 2741 | );\r |
2742 | \r | |
2743 | \r | |
2744 | //\r | |
2745 | // Bit Field Functions\r | |
2746 | //\r | |
2747 | \r | |
2748 | /**\r | |
2749 | Returns a bit field from an 8-bit value.\r | |
2750 | \r | |
2751 | Returns the bitfield specified by the StartBit and the EndBit from Operand.\r | |
2752 | \r | |
2753 | If 8-bit operations are not supported, then ASSERT().\r | |
2754 | If StartBit is greater than 7, then ASSERT().\r | |
2755 | If EndBit is greater than 7, then ASSERT().\r | |
2756 | If EndBit is less than StartBit, then ASSERT().\r | |
2757 | \r | |
2758 | @param Operand Operand on which to perform the bitfield operation.\r | |
2759 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
2760 | Range 0..7.\r | |
2761 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2762 | Range 0..7.\r | |
2763 | \r | |
2764 | @return The bit field read.\r | |
2765 | \r | |
2766 | **/\r | |
2767 | UINT8\r | |
2768 | EFIAPI\r | |
2769 | BitFieldRead8 (\r | |
2770 | IN UINT8 Operand,\r | |
2771 | IN UINTN StartBit,\r | |
2772 | IN UINTN EndBit\r | |
2773 | );\r | |
2774 | \r | |
2775 | \r | |
2776 | /**\r | |
2777 | Writes a bit field to an 8-bit value, and returns the result.\r | |
2778 | \r | |
2779 | Writes Value to the bit field specified by the StartBit and the EndBit in\r | |
2780 | Operand. All other bits in Operand are preserved. The new 8-bit value is\r | |
2781 | returned.\r | |
2782 | \r | |
2783 | If 8-bit operations are not supported, then ASSERT().\r | |
2784 | If StartBit is greater than 7, then ASSERT().\r | |
2785 | If EndBit is greater than 7, then ASSERT().\r | |
2786 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 2787 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 2788 | \r |
2789 | @param Operand Operand on which to perform the bitfield operation.\r | |
2790 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
2791 | Range 0..7.\r | |
2792 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2793 | Range 0..7.\r | |
2794 | @param Value New value of the bit field.\r | |
2795 | \r | |
2796 | @return The new 8-bit value.\r | |
2797 | \r | |
2798 | **/\r | |
2799 | UINT8\r | |
2800 | EFIAPI\r | |
2801 | BitFieldWrite8 (\r | |
2802 | IN UINT8 Operand,\r | |
2803 | IN UINTN StartBit,\r | |
2804 | IN UINTN EndBit,\r | |
2805 | IN UINT8 Value\r | |
2806 | );\r | |
2807 | \r | |
2808 | \r | |
2809 | /**\r | |
2810 | Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the\r | |
2811 | result.\r | |
2812 | \r | |
62991af2 | 2813 | Performs a bitwise OR between the bit field specified by StartBit\r |
ac644614 | 2814 | and EndBit in Operand and the value specified by OrData. All other bits in\r |
2815 | Operand are preserved. The new 8-bit value is returned.\r | |
2816 | \r | |
2817 | If 8-bit operations are not supported, then ASSERT().\r | |
2818 | If StartBit is greater than 7, then ASSERT().\r | |
2819 | If EndBit is greater than 7, then ASSERT().\r | |
2820 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 2821 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 2822 | \r |
2823 | @param Operand Operand on which to perform the bitfield operation.\r | |
2824 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
2825 | Range 0..7.\r | |
2826 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2827 | Range 0..7.\r | |
2828 | @param OrData The value to OR with the read value from the value\r | |
2829 | \r | |
2830 | @return The new 8-bit value.\r | |
2831 | \r | |
2832 | **/\r | |
2833 | UINT8\r | |
2834 | EFIAPI\r | |
2835 | BitFieldOr8 (\r | |
2836 | IN UINT8 Operand,\r | |
2837 | IN UINTN StartBit,\r | |
2838 | IN UINTN EndBit,\r | |
2839 | IN UINT8 OrData\r | |
2840 | );\r | |
2841 | \r | |
2842 | \r | |
2843 | /**\r | |
2844 | Reads a bit field from an 8-bit value, performs a bitwise AND, and returns\r | |
2845 | the result.\r | |
2846 | \r | |
2847 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
2848 | in Operand and the value specified by AndData. All other bits in Operand are\r | |
2849 | preserved. The new 8-bit value is returned.\r | |
2850 | \r | |
2851 | If 8-bit operations are not supported, then ASSERT().\r | |
2852 | If StartBit is greater than 7, then ASSERT().\r | |
2853 | If EndBit is greater than 7, then ASSERT().\r | |
2854 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 2855 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 2856 | \r |
2857 | @param Operand Operand on which to perform the bitfield operation.\r | |
2858 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
2859 | Range 0..7.\r | |
2860 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2861 | Range 0..7.\r | |
2862 | @param AndData The value to AND with the read value from the value.\r | |
2863 | \r | |
2864 | @return The new 8-bit value.\r | |
2865 | \r | |
2866 | **/\r | |
2867 | UINT8\r | |
2868 | EFIAPI\r | |
2869 | BitFieldAnd8 (\r | |
2870 | IN UINT8 Operand,\r | |
2871 | IN UINTN StartBit,\r | |
2872 | IN UINTN EndBit,\r | |
2873 | IN UINT8 AndData\r | |
2874 | );\r | |
2875 | \r | |
2876 | \r | |
2877 | /**\r | |
2878 | Reads a bit field from an 8-bit value, performs a bitwise AND followed by a\r | |
2879 | bitwise OR, and returns the result.\r | |
2880 | \r | |
2881 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
62991af2 | 2882 | in Operand and the value specified by AndData, followed by a bitwise \r |
2883 | OR with value specified by OrData. All other bits in Operand are\r | |
ac644614 | 2884 | preserved. The new 8-bit value is returned.\r |
2885 | \r | |
2886 | If 8-bit operations are not supported, then ASSERT().\r | |
2887 | If StartBit is greater than 7, then ASSERT().\r | |
2888 | If EndBit is greater than 7, then ASSERT().\r | |
2889 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 LG |
2890 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
2891 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
ac644614 | 2892 | \r |
2893 | @param Operand Operand on which to perform the bitfield operation.\r | |
2894 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
2895 | Range 0..7.\r | |
2896 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2897 | Range 0..7.\r | |
2898 | @param AndData The value to AND with the read value from the value.\r | |
2899 | @param OrData The value to OR with the result of the AND operation.\r | |
2900 | \r | |
2901 | @return The new 8-bit value.\r | |
2902 | \r | |
2903 | **/\r | |
2904 | UINT8\r | |
2905 | EFIAPI\r | |
2906 | BitFieldAndThenOr8 (\r | |
2907 | IN UINT8 Operand,\r | |
2908 | IN UINTN StartBit,\r | |
2909 | IN UINTN EndBit,\r | |
2910 | IN UINT8 AndData,\r | |
2911 | IN UINT8 OrData\r | |
2912 | );\r | |
2913 | \r | |
2914 | \r | |
2915 | /**\r | |
2916 | Returns a bit field from a 16-bit value.\r | |
2917 | \r | |
2918 | Returns the bitfield specified by the StartBit and the EndBit from Operand.\r | |
2919 | \r | |
2920 | If 16-bit operations are not supported, then ASSERT().\r | |
2921 | If StartBit is greater than 15, then ASSERT().\r | |
2922 | If EndBit is greater than 15, then ASSERT().\r | |
2923 | If EndBit is less than StartBit, then ASSERT().\r | |
2924 | \r | |
2925 | @param Operand Operand on which to perform the bitfield operation.\r | |
2926 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
2927 | Range 0..15.\r | |
2928 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2929 | Range 0..15.\r | |
2930 | \r | |
2931 | @return The bit field read.\r | |
2932 | \r | |
2933 | **/\r | |
2934 | UINT16\r | |
2935 | EFIAPI\r | |
2936 | BitFieldRead16 (\r | |
2937 | IN UINT16 Operand,\r | |
2938 | IN UINTN StartBit,\r | |
2939 | IN UINTN EndBit\r | |
2940 | );\r | |
2941 | \r | |
2942 | \r | |
2943 | /**\r | |
2944 | Writes a bit field to a 16-bit value, and returns the result.\r | |
2945 | \r | |
2946 | Writes Value to the bit field specified by the StartBit and the EndBit in\r | |
2947 | Operand. All other bits in Operand are preserved. The new 16-bit value is\r | |
2948 | returned.\r | |
2949 | \r | |
2950 | If 16-bit operations are not supported, then ASSERT().\r | |
2951 | If StartBit is greater than 15, then ASSERT().\r | |
2952 | If EndBit is greater than 15, then ASSERT().\r | |
2953 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 2954 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 2955 | \r |
2956 | @param Operand Operand on which to perform the bitfield operation.\r | |
2957 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
2958 | Range 0..15.\r | |
2959 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2960 | Range 0..15.\r | |
2961 | @param Value New value of the bit field.\r | |
2962 | \r | |
2963 | @return The new 16-bit value.\r | |
2964 | \r | |
2965 | **/\r | |
2966 | UINT16\r | |
2967 | EFIAPI\r | |
2968 | BitFieldWrite16 (\r | |
2969 | IN UINT16 Operand,\r | |
2970 | IN UINTN StartBit,\r | |
2971 | IN UINTN EndBit,\r | |
2972 | IN UINT16 Value\r | |
2973 | );\r | |
2974 | \r | |
2975 | \r | |
2976 | /**\r | |
2977 | Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the\r | |
2978 | result.\r | |
2979 | \r | |
62991af2 | 2980 | Performs a bitwise OR between the bit field specified by StartBit\r |
ac644614 | 2981 | and EndBit in Operand and the value specified by OrData. All other bits in\r |
2982 | Operand are preserved. The new 16-bit value is returned.\r | |
2983 | \r | |
2984 | If 16-bit operations are not supported, then ASSERT().\r | |
2985 | If StartBit is greater than 15, then ASSERT().\r | |
2986 | If EndBit is greater than 15, then ASSERT().\r | |
2987 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 2988 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 2989 | \r |
2990 | @param Operand Operand on which to perform the bitfield operation.\r | |
2991 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
2992 | Range 0..15.\r | |
2993 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2994 | Range 0..15.\r | |
2995 | @param OrData The value to OR with the read value from the value\r | |
2996 | \r | |
2997 | @return The new 16-bit value.\r | |
2998 | \r | |
2999 | **/\r | |
3000 | UINT16\r | |
3001 | EFIAPI\r | |
3002 | BitFieldOr16 (\r | |
3003 | IN UINT16 Operand,\r | |
3004 | IN UINTN StartBit,\r | |
3005 | IN UINTN EndBit,\r | |
3006 | IN UINT16 OrData\r | |
3007 | );\r | |
3008 | \r | |
3009 | \r | |
3010 | /**\r | |
3011 | Reads a bit field from a 16-bit value, performs a bitwise AND, and returns\r | |
3012 | the result.\r | |
3013 | \r | |
3014 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
3015 | in Operand and the value specified by AndData. All other bits in Operand are\r | |
3016 | preserved. The new 16-bit value is returned.\r | |
3017 | \r | |
3018 | If 16-bit operations are not supported, then ASSERT().\r | |
3019 | If StartBit is greater than 15, then ASSERT().\r | |
3020 | If EndBit is greater than 15, then ASSERT().\r | |
3021 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 3022 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 3023 | \r |
3024 | @param Operand Operand on which to perform the bitfield operation.\r | |
3025 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
3026 | Range 0..15.\r | |
3027 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
3028 | Range 0..15.\r | |
3029 | @param AndData The value to AND with the read value from the value\r | |
3030 | \r | |
3031 | @return The new 16-bit value.\r | |
3032 | \r | |
3033 | **/\r | |
3034 | UINT16\r | |
3035 | EFIAPI\r | |
3036 | BitFieldAnd16 (\r | |
3037 | IN UINT16 Operand,\r | |
3038 | IN UINTN StartBit,\r | |
3039 | IN UINTN EndBit,\r | |
3040 | IN UINT16 AndData\r | |
3041 | );\r | |
3042 | \r | |
3043 | \r | |
3044 | /**\r | |
3045 | Reads a bit field from a 16-bit value, performs a bitwise AND followed by a\r | |
3046 | bitwise OR, and returns the result.\r | |
3047 | \r | |
3048 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
62991af2 | 3049 | in Operand and the value specified by AndData, followed by a bitwise \r |
3050 | OR with value specified by OrData. All other bits in Operand are\r | |
ac644614 | 3051 | preserved. The new 16-bit value is returned.\r |
3052 | \r | |
3053 | If 16-bit operations are not supported, then ASSERT().\r | |
3054 | If StartBit is greater than 15, then ASSERT().\r | |
3055 | If EndBit is greater than 15, then ASSERT().\r | |
3056 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 LG |
3057 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
3058 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
ac644614 | 3059 | \r |
3060 | @param Operand Operand on which to perform the bitfield operation.\r | |
3061 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
3062 | Range 0..15.\r | |
3063 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
3064 | Range 0..15.\r | |
3065 | @param AndData The value to AND with the read value from the value.\r | |
3066 | @param OrData The value to OR with the result of the AND operation.\r | |
3067 | \r | |
3068 | @return The new 16-bit value.\r | |
3069 | \r | |
3070 | **/\r | |
3071 | UINT16\r | |
3072 | EFIAPI\r | |
3073 | BitFieldAndThenOr16 (\r | |
3074 | IN UINT16 Operand,\r | |
3075 | IN UINTN StartBit,\r | |
3076 | IN UINTN EndBit,\r | |
3077 | IN UINT16 AndData,\r | |
3078 | IN UINT16 OrData\r | |
3079 | );\r | |
3080 | \r | |
3081 | \r | |
3082 | /**\r | |
3083 | Returns a bit field from a 32-bit value.\r | |
3084 | \r | |
3085 | Returns the bitfield specified by the StartBit and the EndBit from Operand.\r | |
3086 | \r | |
3087 | If 32-bit operations are not supported, then ASSERT().\r | |
3088 | If StartBit is greater than 31, then ASSERT().\r | |
3089 | If EndBit is greater than 31, then ASSERT().\r | |
3090 | If EndBit is less than StartBit, then ASSERT().\r | |
3091 | \r | |
3092 | @param Operand Operand on which to perform the bitfield operation.\r | |
3093 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
3094 | Range 0..31.\r | |
3095 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
3096 | Range 0..31.\r | |
3097 | \r | |
3098 | @return The bit field read.\r | |
3099 | \r | |
3100 | **/\r | |
3101 | UINT32\r | |
3102 | EFIAPI\r | |
3103 | BitFieldRead32 (\r | |
3104 | IN UINT32 Operand,\r | |
3105 | IN UINTN StartBit,\r | |
3106 | IN UINTN EndBit\r | |
3107 | );\r | |
3108 | \r | |
3109 | \r | |
3110 | /**\r | |
3111 | Writes a bit field to a 32-bit value, and returns the result.\r | |
3112 | \r | |
3113 | Writes Value to the bit field specified by the StartBit and the EndBit in\r | |
3114 | Operand. All other bits in Operand are preserved. The new 32-bit value is\r | |
3115 | returned.\r | |
3116 | \r | |
3117 | If 32-bit operations are not supported, then ASSERT().\r | |
3118 | If StartBit is greater than 31, then ASSERT().\r | |
3119 | If EndBit is greater than 31, then ASSERT().\r | |
3120 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 3121 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 3122 | \r |
3123 | @param Operand Operand on which to perform the bitfield operation.\r | |
3124 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
3125 | Range 0..31.\r | |
3126 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
3127 | Range 0..31.\r | |
3128 | @param Value New value of the bit field.\r | |
3129 | \r | |
3130 | @return The new 32-bit value.\r | |
3131 | \r | |
3132 | **/\r | |
3133 | UINT32\r | |
3134 | EFIAPI\r | |
3135 | BitFieldWrite32 (\r | |
3136 | IN UINT32 Operand,\r | |
3137 | IN UINTN StartBit,\r | |
3138 | IN UINTN EndBit,\r | |
3139 | IN UINT32 Value\r | |
3140 | );\r | |
3141 | \r | |
3142 | \r | |
3143 | /**\r | |
3144 | Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the\r | |
3145 | result.\r | |
3146 | \r | |
62991af2 | 3147 | Performs a bitwise OR between the bit field specified by StartBit\r |
ac644614 | 3148 | and EndBit in Operand and the value specified by OrData. All other bits in\r |
3149 | Operand are preserved. The new 32-bit value is returned.\r | |
3150 | \r | |
3151 | If 32-bit operations are not supported, then ASSERT().\r | |
3152 | If StartBit is greater than 31, then ASSERT().\r | |
3153 | If EndBit is greater than 31, then ASSERT().\r | |
3154 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 3155 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 3156 | \r |
3157 | @param Operand Operand on which to perform the bitfield operation.\r | |
3158 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
3159 | Range 0..31.\r | |
3160 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
3161 | Range 0..31.\r | |
af2dc6a7 | 3162 | @param OrData The value to OR with the read value from the value.\r |
ac644614 | 3163 | \r |
3164 | @return The new 32-bit value.\r | |
3165 | \r | |
3166 | **/\r | |
3167 | UINT32\r | |
3168 | EFIAPI\r | |
3169 | BitFieldOr32 (\r | |
3170 | IN UINT32 Operand,\r | |
3171 | IN UINTN StartBit,\r | |
3172 | IN UINTN EndBit,\r | |
3173 | IN UINT32 OrData\r | |
3174 | );\r | |
3175 | \r | |
3176 | \r | |
3177 | /**\r | |
3178 | Reads a bit field from a 32-bit value, performs a bitwise AND, and returns\r | |
3179 | the result.\r | |
3180 | \r | |
3181 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
3182 | in Operand and the value specified by AndData. All other bits in Operand are\r | |
3183 | preserved. The new 32-bit value is returned.\r | |
3184 | \r | |
3185 | If 32-bit operations are not supported, then ASSERT().\r | |
3186 | If StartBit is greater than 31, then ASSERT().\r | |
3187 | If EndBit is greater than 31, then ASSERT().\r | |
3188 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 3189 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 3190 | \r |
3191 | @param Operand Operand on which to perform the bitfield operation.\r | |
3192 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
3193 | Range 0..31.\r | |
3194 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
3195 | Range 0..31.\r | |
3196 | @param AndData The value to AND with the read value from the value\r | |
3197 | \r | |
3198 | @return The new 32-bit value.\r | |
3199 | \r | |
3200 | **/\r | |
3201 | UINT32\r | |
3202 | EFIAPI\r | |
3203 | BitFieldAnd32 (\r | |
3204 | IN UINT32 Operand,\r | |
3205 | IN UINTN StartBit,\r | |
3206 | IN UINTN EndBit,\r | |
3207 | IN UINT32 AndData\r | |
3208 | );\r | |
3209 | \r | |
3210 | \r | |
3211 | /**\r | |
3212 | Reads a bit field from a 32-bit value, performs a bitwise AND followed by a\r | |
3213 | bitwise OR, and returns the result.\r | |
3214 | \r | |
3215 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
62991af2 | 3216 | in Operand and the value specified by AndData, followed by a bitwise \r |
3217 | OR with value specified by OrData. All other bits in Operand are\r | |
ac644614 | 3218 | preserved. The new 32-bit value is returned.\r |
3219 | \r | |
3220 | If 32-bit operations are not supported, then ASSERT().\r | |
3221 | If StartBit is greater than 31, then ASSERT().\r | |
3222 | If EndBit is greater than 31, then ASSERT().\r | |
3223 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 LG |
3224 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
3225 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
ac644614 | 3226 | \r |
3227 | @param Operand Operand on which to perform the bitfield operation.\r | |
3228 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
3229 | Range 0..31.\r | |
3230 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
3231 | Range 0..31.\r | |
3232 | @param AndData The value to AND with the read value from the value.\r | |
3233 | @param OrData The value to OR with the result of the AND operation.\r | |
3234 | \r | |
3235 | @return The new 32-bit value.\r | |
3236 | \r | |
3237 | **/\r | |
3238 | UINT32\r | |
3239 | EFIAPI\r | |
3240 | BitFieldAndThenOr32 (\r | |
3241 | IN UINT32 Operand,\r | |
3242 | IN UINTN StartBit,\r | |
3243 | IN UINTN EndBit,\r | |
3244 | IN UINT32 AndData,\r | |
3245 | IN UINT32 OrData\r | |
3246 | );\r | |
3247 | \r | |
3248 | \r | |
3249 | /**\r | |
3250 | Returns a bit field from a 64-bit value.\r | |
3251 | \r | |
3252 | Returns the bitfield specified by the StartBit and the EndBit from Operand.\r | |
3253 | \r | |
3254 | If 64-bit operations are not supported, then ASSERT().\r | |
3255 | If StartBit is greater than 63, then ASSERT().\r | |
3256 | If EndBit is greater than 63, then ASSERT().\r | |
3257 | If EndBit is less than StartBit, then ASSERT().\r | |
3258 | \r | |
3259 | @param Operand Operand on which to perform the bitfield operation.\r | |
3260 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
3261 | Range 0..63.\r | |
3262 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
3263 | Range 0..63.\r | |
3264 | \r | |
3265 | @return The bit field read.\r | |
3266 | \r | |
3267 | **/\r | |
3268 | UINT64\r | |
3269 | EFIAPI\r | |
3270 | BitFieldRead64 (\r | |
3271 | IN UINT64 Operand,\r | |
3272 | IN UINTN StartBit,\r | |
3273 | IN UINTN EndBit\r | |
3274 | );\r | |
3275 | \r | |
3276 | \r | |
3277 | /**\r | |
3278 | Writes a bit field to a 64-bit value, and returns the result.\r | |
3279 | \r | |
3280 | Writes Value to the bit field specified by the StartBit and the EndBit in\r | |
3281 | Operand. All other bits in Operand are preserved. The new 64-bit value is\r | |
3282 | returned.\r | |
3283 | \r | |
3284 | If 64-bit operations are not supported, then ASSERT().\r | |
3285 | If StartBit is greater than 63, then ASSERT().\r | |
3286 | If EndBit is greater than 63, then ASSERT().\r | |
3287 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 3288 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 3289 | \r |
3290 | @param Operand Operand on which to perform the bitfield operation.\r | |
3291 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
3292 | Range 0..63.\r | |
3293 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
3294 | Range 0..63.\r | |
3295 | @param Value New value of the bit field.\r | |
3296 | \r | |
3297 | @return The new 64-bit value.\r | |
3298 | \r | |
3299 | **/\r | |
3300 | UINT64\r | |
3301 | EFIAPI\r | |
3302 | BitFieldWrite64 (\r | |
3303 | IN UINT64 Operand,\r | |
3304 | IN UINTN StartBit,\r | |
3305 | IN UINTN EndBit,\r | |
3306 | IN UINT64 Value\r | |
3307 | );\r | |
3308 | \r | |
3309 | \r | |
3310 | /**\r | |
3311 | Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the\r | |
3312 | result.\r | |
3313 | \r | |
62991af2 | 3314 | Performs a bitwise OR between the bit field specified by StartBit\r |
ac644614 | 3315 | and EndBit in Operand and the value specified by OrData. All other bits in\r |
3316 | Operand are preserved. The new 64-bit value is returned.\r | |
3317 | \r | |
3318 | If 64-bit operations are not supported, then ASSERT().\r | |
3319 | If StartBit is greater than 63, then ASSERT().\r | |
3320 | If EndBit is greater than 63, then ASSERT().\r | |
3321 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 3322 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 3323 | \r |
3324 | @param Operand Operand on which to perform the bitfield operation.\r | |
3325 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
3326 | Range 0..63.\r | |
3327 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
3328 | Range 0..63.\r | |
3329 | @param OrData The value to OR with the read value from the value\r | |
3330 | \r | |
3331 | @return The new 64-bit value.\r | |
3332 | \r | |
3333 | **/\r | |
3334 | UINT64\r | |
3335 | EFIAPI\r | |
3336 | BitFieldOr64 (\r | |
3337 | IN UINT64 Operand,\r | |
3338 | IN UINTN StartBit,\r | |
3339 | IN UINTN EndBit,\r | |
3340 | IN UINT64 OrData\r | |
3341 | );\r | |
3342 | \r | |
3343 | \r | |
3344 | /**\r | |
3345 | Reads a bit field from a 64-bit value, performs a bitwise AND, and returns\r | |
3346 | the result.\r | |
3347 | \r | |
3348 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
3349 | in Operand and the value specified by AndData. All other bits in Operand are\r | |
3350 | preserved. The new 64-bit value is returned.\r | |
3351 | \r | |
3352 | If 64-bit operations are not supported, then ASSERT().\r | |
3353 | If StartBit is greater than 63, then ASSERT().\r | |
3354 | If EndBit is greater than 63, then ASSERT().\r | |
3355 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 3356 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 3357 | \r |
3358 | @param Operand Operand on which to perform the bitfield operation.\r | |
3359 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
3360 | Range 0..63.\r | |
3361 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
3362 | Range 0..63.\r | |
3363 | @param AndData The value to AND with the read value from the value\r | |
3364 | \r | |
3365 | @return The new 64-bit value.\r | |
3366 | \r | |
3367 | **/\r | |
3368 | UINT64\r | |
3369 | EFIAPI\r | |
3370 | BitFieldAnd64 (\r | |
3371 | IN UINT64 Operand,\r | |
3372 | IN UINTN StartBit,\r | |
3373 | IN UINTN EndBit,\r | |
3374 | IN UINT64 AndData\r | |
3375 | );\r | |
3376 | \r | |
3377 | \r | |
3378 | /**\r | |
3379 | Reads a bit field from a 64-bit value, performs a bitwise AND followed by a\r | |
3380 | bitwise OR, and returns the result.\r | |
3381 | \r | |
3382 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
62991af2 | 3383 | in Operand and the value specified by AndData, followed by a bitwise \r |
3384 | OR with value specified by OrData. All other bits in Operand are\r | |
ac644614 | 3385 | preserved. The new 64-bit value is returned.\r |
3386 | \r | |
3387 | If 64-bit operations are not supported, then ASSERT().\r | |
3388 | If StartBit is greater than 63, then ASSERT().\r | |
3389 | If EndBit is greater than 63, then ASSERT().\r | |
3390 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 LG |
3391 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
3392 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
ac644614 | 3393 | \r |
3394 | @param Operand Operand on which to perform the bitfield operation.\r | |
3395 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
3396 | Range 0..63.\r | |
3397 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
3398 | Range 0..63.\r | |
3399 | @param AndData The value to AND with the read value from the value.\r | |
3400 | @param OrData The value to OR with the result of the AND operation.\r | |
3401 | \r | |
3402 | @return The new 64-bit value.\r | |
3403 | \r | |
3404 | **/\r | |
3405 | UINT64\r | |
3406 | EFIAPI\r | |
3407 | BitFieldAndThenOr64 (\r | |
3408 | IN UINT64 Operand,\r | |
3409 | IN UINTN StartBit,\r | |
3410 | IN UINTN EndBit,\r | |
3411 | IN UINT64 AndData,\r | |
3412 | IN UINT64 OrData\r | |
3413 | );\r | |
3414 | \r | |
ac644614 | 3415 | //\r |
3416 | // Base Library Checksum Functions\r | |
3417 | //\r | |
3418 | \r | |
3419 | /**\r | |
17f695ed | 3420 | Returns the sum of all elements in a buffer in unit of UINT8.\r |
ac644614 | 3421 | During calculation, the carry bits are dropped.\r |
3422 | \r | |
3423 | This function calculates the sum of all elements in a buffer\r | |
3424 | in unit of UINT8. The carry bits in result of addition are dropped.\r | |
3425 | The result is returned as UINT8. If Length is Zero, then Zero is\r | |
3426 | returned.\r | |
3427 | \r | |
3428 | If Buffer is NULL, then ASSERT().\r | |
3429 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
3430 | \r | |
af2dc6a7 | 3431 | @param Buffer The pointer to the buffer to carry out the sum operation.\r |
17f695ed | 3432 | @param Length The size, in bytes, of Buffer.\r |
ac644614 | 3433 | \r |
3434 | @return Sum The sum of Buffer with carry bits dropped during additions.\r | |
3435 | \r | |
3436 | **/\r | |
3437 | UINT8\r | |
3438 | EFIAPI\r | |
3439 | CalculateSum8 (\r | |
ee6c452c | 3440 | IN CONST UINT8 *Buffer,\r |
3441 | IN UINTN Length\r | |
ac644614 | 3442 | );\r |
3443 | \r | |
3444 | \r | |
3445 | /**\r | |
3446 | Returns the two's complement checksum of all elements in a buffer\r | |
3447 | of 8-bit values.\r | |
3448 | \r | |
3449 | This function first calculates the sum of the 8-bit values in the\r | |
3450 | buffer specified by Buffer and Length. The carry bits in the result\r | |
3451 | of addition are dropped. Then, the two's complement of the sum is\r | |
3452 | returned. If Length is 0, then 0 is returned.\r | |
3453 | \r | |
3454 | If Buffer is NULL, then ASSERT().\r | |
3455 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
3456 | \r | |
af2dc6a7 | 3457 | @param Buffer The pointer to the buffer to carry out the checksum operation.\r |
1106ffe1 | 3458 | @param Length The size, in bytes, of Buffer.\r |
ac644614 | 3459 | \r |
af2dc6a7 | 3460 | @return Checksum The two's complement checksum of Buffer.\r |
ac644614 | 3461 | \r |
3462 | **/\r | |
3463 | UINT8\r | |
3464 | EFIAPI\r | |
3465 | CalculateCheckSum8 (\r | |
ee6c452c | 3466 | IN CONST UINT8 *Buffer,\r |
3467 | IN UINTN Length\r | |
ac644614 | 3468 | );\r |
3469 | \r | |
3470 | \r | |
3471 | /**\r | |
3472 | Returns the sum of all elements in a buffer of 16-bit values. During\r | |
3473 | calculation, the carry bits are dropped.\r | |
3474 | \r | |
3475 | This function calculates the sum of the 16-bit values in the buffer\r | |
3476 | specified by Buffer and Length. The carry bits in result of addition are dropped.\r | |
3477 | The 16-bit result is returned. If Length is 0, then 0 is returned.\r | |
3478 | \r | |
3479 | If Buffer is NULL, then ASSERT().\r | |
3480 | If Buffer is not aligned on a 16-bit boundary, then ASSERT().\r | |
3481 | If Length is not aligned on a 16-bit boundary, then ASSERT().\r | |
3482 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
3483 | \r | |
af2dc6a7 | 3484 | @param Buffer The pointer to the buffer to carry out the sum operation.\r |
1106ffe1 | 3485 | @param Length The size, in bytes, of Buffer.\r |
ac644614 | 3486 | \r |
3487 | @return Sum The sum of Buffer with carry bits dropped during additions.\r | |
3488 | \r | |
3489 | **/\r | |
3490 | UINT16\r | |
3491 | EFIAPI\r | |
3492 | CalculateSum16 (\r | |
ee6c452c | 3493 | IN CONST UINT16 *Buffer,\r |
3494 | IN UINTN Length\r | |
ac644614 | 3495 | );\r |
3496 | \r | |
3497 | \r | |
3498 | /**\r | |
3499 | Returns the two's complement checksum of all elements in a buffer of\r | |
3500 | 16-bit values.\r | |
3501 | \r | |
3502 | This function first calculates the sum of the 16-bit values in the buffer\r | |
3503 | specified by Buffer and Length. The carry bits in the result of addition\r | |
3504 | are dropped. Then, the two's complement of the sum is returned. If Length\r | |
3505 | is 0, then 0 is returned.\r | |
3506 | \r | |
3507 | If Buffer is NULL, then ASSERT().\r | |
3508 | If Buffer is not aligned on a 16-bit boundary, then ASSERT().\r | |
3509 | If Length is not aligned on a 16-bit boundary, then ASSERT().\r | |
3510 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
3511 | \r | |
af2dc6a7 | 3512 | @param Buffer The pointer to the buffer to carry out the checksum operation.\r |
1106ffe1 | 3513 | @param Length The size, in bytes, of Buffer.\r |
ac644614 | 3514 | \r |
af2dc6a7 | 3515 | @return Checksum The two's complement checksum of Buffer.\r |
ac644614 | 3516 | \r |
3517 | **/\r | |
3518 | UINT16\r | |
3519 | EFIAPI\r | |
3520 | CalculateCheckSum16 (\r | |
ee6c452c | 3521 | IN CONST UINT16 *Buffer,\r |
3522 | IN UINTN Length\r | |
ac644614 | 3523 | );\r |
3524 | \r | |
3525 | \r | |
3526 | /**\r | |
17f695ed | 3527 | Returns the sum of all elements in a buffer of 32-bit values. During\r |
ac644614 | 3528 | calculation, the carry bits are dropped.\r |
3529 | \r | |
3530 | This function calculates the sum of the 32-bit values in the buffer\r | |
3531 | specified by Buffer and Length. The carry bits in result of addition are dropped.\r | |
17f695ed | 3532 | The 32-bit result is returned. If Length is 0, then 0 is returned.\r |
ac644614 | 3533 | \r |
3534 | If Buffer is NULL, then ASSERT().\r | |
3535 | If Buffer is not aligned on a 32-bit boundary, then ASSERT().\r | |
3536 | If Length is not aligned on a 32-bit boundary, then ASSERT().\r | |
3537 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
3538 | \r | |
af2dc6a7 | 3539 | @param Buffer The pointer to the buffer to carry out the sum operation.\r |
1106ffe1 | 3540 | @param Length The size, in bytes, of Buffer.\r |
ac644614 | 3541 | \r |
3542 | @return Sum The sum of Buffer with carry bits dropped during additions.\r | |
3543 | \r | |
3544 | **/\r | |
3545 | UINT32\r | |
3546 | EFIAPI\r | |
3547 | CalculateSum32 (\r | |
ee6c452c | 3548 | IN CONST UINT32 *Buffer,\r |
3549 | IN UINTN Length\r | |
ac644614 | 3550 | );\r |
3551 | \r | |
3552 | \r | |
3553 | /**\r | |
3554 | Returns the two's complement checksum of all elements in a buffer of\r | |
3555 | 32-bit values.\r | |
3556 | \r | |
3557 | This function first calculates the sum of the 32-bit values in the buffer\r | |
3558 | specified by Buffer and Length. The carry bits in the result of addition\r | |
3559 | are dropped. Then, the two's complement of the sum is returned. If Length\r | |
3560 | is 0, then 0 is returned.\r | |
3561 | \r | |
3562 | If Buffer is NULL, then ASSERT().\r | |
3563 | If Buffer is not aligned on a 32-bit boundary, then ASSERT().\r | |
3564 | If Length is not aligned on a 32-bit boundary, then ASSERT().\r | |
3565 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
3566 | \r | |
af2dc6a7 | 3567 | @param Buffer The pointer to the buffer to carry out the checksum operation.\r |
1106ffe1 | 3568 | @param Length The size, in bytes, of Buffer.\r |
ac644614 | 3569 | \r |
af2dc6a7 | 3570 | @return Checksum The two's complement checksum of Buffer.\r |
ac644614 | 3571 | \r |
3572 | **/\r | |
3573 | UINT32\r | |
3574 | EFIAPI\r | |
3575 | CalculateCheckSum32 (\r | |
ee6c452c | 3576 | IN CONST UINT32 *Buffer,\r |
3577 | IN UINTN Length\r | |
ac644614 | 3578 | );\r |
3579 | \r | |
3580 | \r | |
3581 | /**\r | |
3582 | Returns the sum of all elements in a buffer of 64-bit values. During\r | |
3583 | calculation, the carry bits are dropped.\r | |
3584 | \r | |
3585 | This function calculates the sum of the 64-bit values in the buffer\r | |
3586 | specified by Buffer and Length. The carry bits in result of addition are dropped.\r | |
3587 | The 64-bit result is returned. If Length is 0, then 0 is returned.\r | |
3588 | \r | |
3589 | If Buffer is NULL, then ASSERT().\r | |
3590 | If Buffer is not aligned on a 64-bit boundary, then ASSERT().\r | |
3591 | If Length is not aligned on a 64-bit boundary, then ASSERT().\r | |
3592 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
3593 | \r | |
af2dc6a7 | 3594 | @param Buffer The pointer to the buffer to carry out the sum operation.\r |
1106ffe1 | 3595 | @param Length The size, in bytes, of Buffer.\r |
ac644614 | 3596 | \r |
3597 | @return Sum The sum of Buffer with carry bits dropped during additions.\r | |
3598 | \r | |
3599 | **/\r | |
3600 | UINT64\r | |
3601 | EFIAPI\r | |
3602 | CalculateSum64 (\r | |
ee6c452c | 3603 | IN CONST UINT64 *Buffer,\r |
3604 | IN UINTN Length\r | |
ac644614 | 3605 | );\r |
3606 | \r | |
3607 | \r | |
3608 | /**\r | |
3609 | Returns the two's complement checksum of all elements in a buffer of\r | |
3610 | 64-bit values.\r | |
3611 | \r | |
3612 | This function first calculates the sum of the 64-bit values in the buffer\r | |
3613 | specified by Buffer and Length. The carry bits in the result of addition\r | |
3614 | are dropped. Then, the two's complement of the sum is returned. If Length\r | |
3615 | is 0, then 0 is returned.\r | |
3616 | \r | |
3617 | If Buffer is NULL, then ASSERT().\r | |
3618 | If Buffer is not aligned on a 64-bit boundary, then ASSERT().\r | |
3619 | If Length is not aligned on a 64-bit boundary, then ASSERT().\r | |
3620 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
3621 | \r | |
af2dc6a7 | 3622 | @param Buffer The pointer to the buffer to carry out the checksum operation.\r |
1106ffe1 | 3623 | @param Length The size, in bytes, of Buffer.\r |
ac644614 | 3624 | \r |
af2dc6a7 | 3625 | @return Checksum The two's complement checksum of Buffer.\r |
ac644614 | 3626 | \r |
3627 | **/\r | |
3628 | UINT64\r | |
3629 | EFIAPI\r | |
3630 | CalculateCheckSum64 (\r | |
ee6c452c | 3631 | IN CONST UINT64 *Buffer,\r |
3632 | IN UINTN Length\r | |
ac644614 | 3633 | );\r |
3634 | \r | |
3635 | \r | |
d75f9fc2 | 3636 | //\r |
3637 | // Base Library CPU Functions\r | |
3638 | //\r | |
3639 | \r | |
3640 | /**\r | |
3641 | Function entry point used when a stack switch is requested with SwitchStack()\r | |
3642 | \r | |
3643 | @param Context1 Context1 parameter passed into SwitchStack().\r | |
3644 | @param Context2 Context2 parameter passed into SwitchStack().\r | |
3645 | \r | |
3646 | **/\r | |
ac644614 | 3647 | typedef\r |
3648 | VOID\r | |
9810cdd8 | 3649 | (EFIAPI *SWITCH_STACK_ENTRY_POINT)(\r |
ac644614 | 3650 | IN VOID *Context1, OPTIONAL\r |
3651 | IN VOID *Context2 OPTIONAL\r | |
3652 | );\r | |
3653 | \r | |
3654 | \r | |
3655 | /**\r | |
3656 | Used to serialize load and store operations.\r | |
3657 | \r | |
3658 | All loads and stores that proceed calls to this function are guaranteed to be\r | |
3659 | globally visible when this function returns.\r | |
3660 | \r | |
3661 | **/\r | |
3662 | VOID\r | |
3663 | EFIAPI\r | |
3664 | MemoryFence (\r | |
3665 | VOID\r | |
3666 | );\r | |
3667 | \r | |
3668 | \r | |
3669 | /**\r | |
3670 | Saves the current CPU context that can be restored with a call to LongJump()\r | |
3671 | and returns 0.\r | |
3672 | \r | |
3673 | Saves the current CPU context in the buffer specified by JumpBuffer and\r | |
3674 | returns 0. The initial call to SetJump() must always return 0. Subsequent\r | |
3675 | calls to LongJump() cause a non-zero value to be returned by SetJump().\r | |
3676 | \r | |
3677 | If JumpBuffer is NULL, then ASSERT().\r | |
1a2f870c | 3678 | For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().\r |
17f695ed | 3679 | \r |
3680 | NOTE: The structure BASE_LIBRARY_JUMP_BUFFER is CPU architecture specific.\r | |
3681 | The same structure must never be used for more than one CPU architecture context.\r | |
3682 | For example, a BASE_LIBRARY_JUMP_BUFFER allocated by an IA-32 module must never be used from an x64 module. \r | |
3683 | SetJump()/LongJump() is not currently supported for the EBC processor type. \r | |
ac644614 | 3684 | \r |
3685 | @param JumpBuffer A pointer to CPU context buffer.\r | |
3686 | \r | |
3687 | @retval 0 Indicates a return from SetJump().\r | |
3688 | \r | |
3689 | **/\r | |
3690 | UINTN\r | |
3691 | EFIAPI\r | |
3692 | SetJump (\r | |
3693 | OUT BASE_LIBRARY_JUMP_BUFFER *JumpBuffer\r | |
3694 | );\r | |
3695 | \r | |
3696 | \r | |
3697 | /**\r | |
3698 | Restores the CPU context that was saved with SetJump().\r | |
3699 | \r | |
3700 | Restores the CPU context from the buffer specified by JumpBuffer. This\r | |
3701 | function never returns to the caller. Instead is resumes execution based on\r | |
3702 | the state of JumpBuffer.\r | |
3703 | \r | |
3704 | If JumpBuffer is NULL, then ASSERT().\r | |
1a2f870c | 3705 | For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().\r |
ac644614 | 3706 | If Value is 0, then ASSERT().\r |
3707 | \r | |
3708 | @param JumpBuffer A pointer to CPU context buffer.\r | |
3709 | @param Value The value to return when the SetJump() context is\r | |
3710 | restored and must be non-zero.\r | |
3711 | \r | |
3712 | **/\r | |
3713 | VOID\r | |
3714 | EFIAPI\r | |
3715 | LongJump (\r | |
3716 | IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer,\r | |
3717 | IN UINTN Value\r | |
3718 | );\r | |
3719 | \r | |
3720 | \r | |
3721 | /**\r | |
3722 | Enables CPU interrupts.\r | |
3723 | \r | |
ac644614 | 3724 | **/\r |
3725 | VOID\r | |
3726 | EFIAPI\r | |
3727 | EnableInterrupts (\r | |
3728 | VOID\r | |
3729 | );\r | |
3730 | \r | |
3731 | \r | |
3732 | /**\r | |
3733 | Disables CPU interrupts.\r | |
3734 | \r | |
ac644614 | 3735 | **/\r |
3736 | VOID\r | |
3737 | EFIAPI\r | |
3738 | DisableInterrupts (\r | |
3739 | VOID\r | |
3740 | );\r | |
3741 | \r | |
3742 | \r | |
3743 | /**\r | |
3744 | Disables CPU interrupts and returns the interrupt state prior to the disable\r | |
3745 | operation.\r | |
3746 | \r | |
ac644614 | 3747 | @retval TRUE CPU interrupts were enabled on entry to this call.\r |
3748 | @retval FALSE CPU interrupts were disabled on entry to this call.\r | |
3749 | \r | |
3750 | **/\r | |
3751 | BOOLEAN\r | |
3752 | EFIAPI\r | |
3753 | SaveAndDisableInterrupts (\r | |
3754 | VOID\r | |
3755 | );\r | |
3756 | \r | |
3757 | \r | |
3758 | /**\r | |
3759 | Enables CPU interrupts for the smallest window required to capture any\r | |
3760 | pending interrupts.\r | |
3761 | \r | |
ac644614 | 3762 | **/\r |
3763 | VOID\r | |
3764 | EFIAPI\r | |
3765 | EnableDisableInterrupts (\r | |
3766 | VOID\r | |
3767 | );\r | |
3768 | \r | |
3769 | \r | |
3770 | /**\r | |
3771 | Retrieves the current CPU interrupt state.\r | |
3772 | \r | |
af2dc6a7 | 3773 | Returns TRUE if interrupts are currently enabled. Otherwise\r |
38bbd3d9 | 3774 | returns FALSE.\r |
ac644614 | 3775 | \r |
3776 | @retval TRUE CPU interrupts are enabled.\r | |
3777 | @retval FALSE CPU interrupts are disabled.\r | |
3778 | \r | |
3779 | **/\r | |
3780 | BOOLEAN\r | |
3781 | EFIAPI\r | |
3782 | GetInterruptState (\r | |
3783 | VOID\r | |
3784 | );\r | |
3785 | \r | |
3786 | \r | |
3787 | /**\r | |
3788 | Set the current CPU interrupt state.\r | |
3789 | \r | |
3790 | Sets the current CPU interrupt state to the state specified by\r | |
3791 | InterruptState. If InterruptState is TRUE, then interrupts are enabled. If\r | |
3792 | InterruptState is FALSE, then interrupts are disabled. InterruptState is\r | |
3793 | returned.\r | |
3794 | \r | |
3795 | @param InterruptState TRUE if interrupts should enabled. FALSE if\r | |
3796 | interrupts should be disabled.\r | |
3797 | \r | |
3798 | @return InterruptState\r | |
3799 | \r | |
3800 | **/\r | |
3801 | BOOLEAN\r | |
3802 | EFIAPI\r | |
3803 | SetInterruptState (\r | |
3804 | IN BOOLEAN InterruptState\r | |
3805 | );\r | |
3806 | \r | |
3807 | \r | |
3808 | /**\r | |
3809 | Requests CPU to pause for a short period of time.\r | |
3810 | \r | |
3811 | Requests CPU to pause for a short period of time. Typically used in MP\r | |
3812 | systems to prevent memory starvation while waiting for a spin lock.\r | |
3813 | \r | |
3814 | **/\r | |
3815 | VOID\r | |
3816 | EFIAPI\r | |
3817 | CpuPause (\r | |
3818 | VOID\r | |
3819 | );\r | |
3820 | \r | |
3821 | \r | |
3822 | /**\r | |
3823 | Transfers control to a function starting with a new stack.\r | |
3824 | \r | |
3825 | Transfers control to the function specified by EntryPoint using the\r | |
3826 | new stack specified by NewStack and passing in the parameters specified\r | |
3827 | by Context1 and Context2. Context1 and Context2 are optional and may\r | |
3828 | be NULL. The function EntryPoint must never return. This function\r | |
3829 | supports a variable number of arguments following the NewStack parameter.\r | |
1a2f870c | 3830 | These additional arguments are ignored on IA-32, x64, and EBC architectures.\r |
3831 | Itanium processors expect one additional parameter of type VOID * that specifies\r | |
ac644614 | 3832 | the new backing store pointer.\r |
3833 | \r | |
3834 | If EntryPoint is NULL, then ASSERT().\r | |
3835 | If NewStack is NULL, then ASSERT().\r | |
3836 | \r | |
3837 | @param EntryPoint A pointer to function to call with the new stack.\r | |
3838 | @param Context1 A pointer to the context to pass into the EntryPoint\r | |
3839 | function.\r | |
3840 | @param Context2 A pointer to the context to pass into the EntryPoint\r | |
3841 | function.\r | |
3842 | @param NewStack A pointer to the new stack to use for the EntryPoint\r | |
3843 | function.\r | |
af2dc6a7 | 3844 | @param ... This variable argument list is ignored for IA-32, x64, and \r |
3845 | EBC architectures. For Itanium processors, this variable \r | |
3846 | argument list is expected to contain a single parameter of \r | |
3847 | type VOID * that specifies the new backing store pointer.\r | |
42eedea9 | 3848 | \r |
ac644614 | 3849 | \r |
3850 | **/\r | |
3851 | VOID\r | |
3852 | EFIAPI\r | |
3853 | SwitchStack (\r | |
3854 | IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r | |
3855 | IN VOID *Context1, OPTIONAL\r | |
3856 | IN VOID *Context2, OPTIONAL\r | |
3857 | IN VOID *NewStack,\r | |
3858 | ...\r | |
3859 | );\r | |
3860 | \r | |
3861 | \r | |
3862 | /**\r | |
3863 | Generates a breakpoint on the CPU.\r | |
3864 | \r | |
3865 | Generates a breakpoint on the CPU. The breakpoint must be implemented such\r | |
3866 | that code can resume normal execution after the breakpoint.\r | |
3867 | \r | |
3868 | **/\r | |
3869 | VOID\r | |
3870 | EFIAPI\r | |
3871 | CpuBreakpoint (\r | |
3872 | VOID\r | |
3873 | );\r | |
3874 | \r | |
3875 | \r | |
3876 | /**\r | |
3877 | Executes an infinite loop.\r | |
3878 | \r | |
3879 | Forces the CPU to execute an infinite loop. A debugger may be used to skip\r | |
3880 | past the loop and the code that follows the loop must execute properly. This\r | |
3881 | implies that the infinite loop must not cause the code that follow it to be\r | |
3882 | optimized away.\r | |
3883 | \r | |
3884 | **/\r | |
3885 | VOID\r | |
3886 | EFIAPI\r | |
3887 | CpuDeadLoop (\r | |
3888 | VOID\r | |
3889 | );\r | |
2fe241a2 | 3890 | \r |
ac644614 | 3891 | #if defined (MDE_CPU_IPF)\r |
3892 | \r | |
3893 | /**\r | |
3894 | Flush a range of cache lines in the cache coherency domain of the calling\r | |
3895 | CPU.\r | |
3896 | \r | |
cc39b88b | 3897 | Flushes the cache lines specified by Address and Length. If Address is not aligned \r |
3898 | on a cache line boundary, then entire cache line containing Address is flushed. \r | |
3899 | If Address + Length is not aligned on a cache line boundary, then the entire cache \r | |
3900 | line containing Address + Length - 1 is flushed. This function may choose to flush \r | |
3901 | the entire cache if that is more efficient than flushing the specified range. If \r | |
3902 | Length is 0, the no cache lines are flushed. Address is returned. \r | |
1a2f870c | 3903 | This function is only available on Itanium processors.\r |
ac644614 | 3904 | \r |
3905 | If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().\r | |
3906 | \r | |
3907 | @param Address The base address of the instruction lines to invalidate. If\r | |
3908 | the CPU is in a physical addressing mode, then Address is a\r | |
3909 | physical address. If the CPU is in a virtual addressing mode,\r | |
3910 | then Address is a virtual address.\r | |
3911 | \r | |
3912 | @param Length The number of bytes to invalidate from the instruction cache.\r | |
3913 | \r | |
cc39b88b | 3914 | @return Address.\r |
ac644614 | 3915 | \r |
3916 | **/\r | |
3917 | VOID *\r | |
3918 | EFIAPI\r | |
cc39b88b | 3919 | AsmFlushCacheRange (\r |
ac644614 | 3920 | IN VOID *Address,\r |
3921 | IN UINTN Length\r | |
3922 | );\r | |
3923 | \r | |
3924 | \r | |
3925 | /**\r | |
af2dc6a7 | 3926 | Executes an FC instruction.\r |
3927 | Executes an FC instruction on the cache line specified by Address.\r | |
ac644614 | 3928 | The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).\r |
1a2f870c | 3929 | An implementation may flush a larger region. This function is only available on Itanium processors.\r |
ac644614 | 3930 | \r |
ee6c452c | 3931 | @param Address The Address of cache line to be flushed.\r |
ac644614 | 3932 | \r |
3933 | @return The address of FC instruction executed.\r | |
3934 | \r | |
3935 | **/\r | |
3936 | UINT64\r | |
3937 | EFIAPI\r | |
3938 | AsmFc (\r | |
3939 | IN UINT64 Address\r | |
3940 | );\r | |
3941 | \r | |
3942 | \r | |
3943 | /**\r | |
af2dc6a7 | 3944 | Executes an FC.I instruction.\r |
3945 | Executes an FC.I instruction on the cache line specified by Address.\r | |
ac644614 | 3946 | The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).\r |
1a2f870c | 3947 | An implementation may flush a larger region. This function is only available on Itanium processors.\r |
ac644614 | 3948 | \r |
ee6c452c | 3949 | @param Address The Address of cache line to be flushed.\r |
ac644614 | 3950 | \r |
af2dc6a7 | 3951 | @return The address of the FC.I instruction executed.\r |
ac644614 | 3952 | \r |
3953 | **/\r | |
3954 | UINT64\r | |
3955 | EFIAPI\r | |
3956 | AsmFci (\r | |
3957 | IN UINT64 Address\r | |
3958 | );\r | |
3959 | \r | |
3960 | \r | |
3961 | /**\r | |
3962 | Reads the current value of a Processor Identifier Register (CPUID).\r | |
17f695ed | 3963 | \r |
3964 | Reads and returns the current value of Processor Identifier Register specified by Index. \r | |
ac644614 | 3965 | The Index of largest implemented CPUID (One less than the number of implemented CPUID\r |
3966 | registers) is determined by CPUID [3] bits {7:0}.\r | |
3967 | No parameter checking is performed on Index. If the Index value is beyond the\r | |
3968 | implemented CPUID register range, a Reserved Register/Field fault may occur. The caller\r | |
3969 | must either guarantee that Index is valid, or the caller must set up fault handlers to\r | |
1a2f870c | 3970 | catch the faults. This function is only available on Itanium processors.\r |
ac644614 | 3971 | \r |
ee6c452c | 3972 | @param Index The 8-bit Processor Identifier Register index to read.\r |
ac644614 | 3973 | \r |
3974 | @return The current value of Processor Identifier Register specified by Index.\r | |
3975 | \r | |
3976 | **/\r | |
3977 | UINT64\r | |
3978 | EFIAPI\r | |
3979 | AsmReadCpuid (\r | |
3980 | IN UINT8 Index\r | |
3981 | );\r | |
3982 | \r | |
3983 | \r | |
3984 | /**\r | |
3985 | Reads the current value of 64-bit Processor Status Register (PSR).\r | |
1a2f870c | 3986 | This function is only available on Itanium processors.\r |
ac644614 | 3987 | \r |
3988 | @return The current value of PSR.\r | |
3989 | \r | |
3990 | **/\r | |
3991 | UINT64\r | |
3992 | EFIAPI\r | |
3993 | AsmReadPsr (\r | |
3994 | VOID\r | |
3995 | );\r | |
3996 | \r | |
3997 | \r | |
3998 | /**\r | |
3999 | Writes the current value of 64-bit Processor Status Register (PSR).\r | |
22388319 | 4000 | \r |
ac644614 | 4001 | No parameter checking is performed on Value. All bits of Value corresponding to\r |
22388319 | 4002 | reserved fields of PSR must be 0 or a Reserved Register/Field fault may occur.\r |
4003 | The caller must either guarantee that Value is valid, or the caller must set up\r | |
1a2f870c | 4004 | fault handlers to catch the faults. This function is only available on Itanium processors.\r |
ac644614 | 4005 | \r |
ee6c452c | 4006 | @param Value The 64-bit value to write to PSR.\r |
ac644614 | 4007 | \r |
4008 | @return The 64-bit value written to the PSR.\r | |
4009 | \r | |
4010 | **/\r | |
4011 | UINT64\r | |
4012 | EFIAPI\r | |
4013 | AsmWritePsr (\r | |
4014 | IN UINT64 Value\r | |
4015 | );\r | |
4016 | \r | |
4017 | \r | |
4018 | /**\r | |
4019 | Reads the current value of 64-bit Kernel Register #0 (KR0).\r | |
2fe241a2 | 4020 | \r |
4021 | Reads and returns the current value of KR0. \r | |
1a2f870c | 4022 | This function is only available on Itanium processors.\r |
ac644614 | 4023 | \r |
4024 | @return The current value of KR0.\r | |
4025 | \r | |
4026 | **/\r | |
4027 | UINT64\r | |
4028 | EFIAPI\r | |
4029 | AsmReadKr0 (\r | |
4030 | VOID\r | |
4031 | );\r | |
4032 | \r | |
4033 | \r | |
4034 | /**\r | |
4035 | Reads the current value of 64-bit Kernel Register #1 (KR1).\r | |
2fe241a2 | 4036 | \r |
4037 | Reads and returns the current value of KR1. \r | |
1a2f870c | 4038 | This function is only available on Itanium processors.\r |
ac644614 | 4039 | \r |
4040 | @return The current value of KR1.\r | |
4041 | \r | |
4042 | **/\r | |
4043 | UINT64\r | |
4044 | EFIAPI\r | |
4045 | AsmReadKr1 (\r | |
4046 | VOID\r | |
4047 | );\r | |
4048 | \r | |
4049 | \r | |
4050 | /**\r | |
4051 | Reads the current value of 64-bit Kernel Register #2 (KR2).\r | |
2fe241a2 | 4052 | \r |
4053 | Reads and returns the current value of KR2. \r | |
1a2f870c | 4054 | This function is only available on Itanium processors.\r |
ac644614 | 4055 | \r |
4056 | @return The current value of KR2.\r | |
4057 | \r | |
4058 | **/\r | |
4059 | UINT64\r | |
4060 | EFIAPI\r | |
4061 | AsmReadKr2 (\r | |
4062 | VOID\r | |
4063 | );\r | |
4064 | \r | |
4065 | \r | |
4066 | /**\r | |
4067 | Reads the current value of 64-bit Kernel Register #3 (KR3).\r | |
2fe241a2 | 4068 | \r |
4069 | Reads and returns the current value of KR3. \r | |
1a2f870c | 4070 | This function is only available on Itanium processors.\r |
ac644614 | 4071 | \r |
4072 | @return The current value of KR3.\r | |
4073 | \r | |
4074 | **/\r | |
4075 | UINT64\r | |
4076 | EFIAPI\r | |
4077 | AsmReadKr3 (\r | |
4078 | VOID\r | |
4079 | );\r | |
4080 | \r | |
4081 | \r | |
4082 | /**\r | |
4083 | Reads the current value of 64-bit Kernel Register #4 (KR4).\r | |
ac644614 | 4084 | \r |
2fe241a2 | 4085 | Reads and returns the current value of KR4. \r |
1a2f870c | 4086 | This function is only available on Itanium processors.\r |
2fe241a2 | 4087 | \r |
ac644614 | 4088 | @return The current value of KR4.\r |
4089 | \r | |
4090 | **/\r | |
4091 | UINT64\r | |
4092 | EFIAPI\r | |
4093 | AsmReadKr4 (\r | |
4094 | VOID\r | |
4095 | );\r | |
4096 | \r | |
4097 | \r | |
4098 | /**\r | |
4099 | Reads the current value of 64-bit Kernel Register #5 (KR5).\r | |
2fe241a2 | 4100 | \r |
4101 | Reads and returns the current value of KR5. \r | |
1a2f870c | 4102 | This function is only available on Itanium processors.\r |
ac644614 | 4103 | \r |
4104 | @return The current value of KR5.\r | |
4105 | \r | |
4106 | **/\r | |
4107 | UINT64\r | |
4108 | EFIAPI\r | |
4109 | AsmReadKr5 (\r | |
4110 | VOID\r | |
4111 | );\r | |
4112 | \r | |
4113 | \r | |
4114 | /**\r | |
4115 | Reads the current value of 64-bit Kernel Register #6 (KR6).\r | |
2fe241a2 | 4116 | \r |
4117 | Reads and returns the current value of KR6. \r | |
1a2f870c | 4118 | This function is only available on Itanium processors.\r |
ac644614 | 4119 | \r |
4120 | @return The current value of KR6.\r | |
4121 | \r | |
4122 | **/\r | |
4123 | UINT64\r | |
4124 | EFIAPI\r | |
4125 | AsmReadKr6 (\r | |
4126 | VOID\r | |
4127 | );\r | |
4128 | \r | |
4129 | \r | |
4130 | /**\r | |
4131 | Reads the current value of 64-bit Kernel Register #7 (KR7).\r | |
2fe241a2 | 4132 | \r |
4133 | Reads and returns the current value of KR7. \r | |
1a2f870c | 4134 | This function is only available on Itanium processors.\r |
ac644614 | 4135 | \r |
4136 | @return The current value of KR7.\r | |
4137 | \r | |
4138 | **/\r | |
4139 | UINT64\r | |
4140 | EFIAPI\r | |
4141 | AsmReadKr7 (\r | |
4142 | VOID\r | |
4143 | );\r | |
4144 | \r | |
4145 | \r | |
4146 | /**\r | |
4147 | Write the current value of 64-bit Kernel Register #0 (KR0).\r | |
2fe241a2 | 4148 | \r |
4149 | Writes the current value of KR0. The 64-bit value written to \r | |
1a2f870c | 4150 | the KR0 is returned. This function is only available on Itanium processors.\r |
ac644614 | 4151 | \r |
ee6c452c | 4152 | @param Value The 64-bit value to write to KR0.\r |
ac644614 | 4153 | \r |
4154 | @return The 64-bit value written to the KR0.\r | |
4155 | \r | |
4156 | **/\r | |
4157 | UINT64\r | |
4158 | EFIAPI\r | |
4159 | AsmWriteKr0 (\r | |
4160 | IN UINT64 Value\r | |
4161 | );\r | |
4162 | \r | |
4163 | \r | |
4164 | /**\r | |
4165 | Write the current value of 64-bit Kernel Register #1 (KR1).\r | |
2fe241a2 | 4166 | \r |
4167 | Writes the current value of KR1. The 64-bit value written to \r | |
1a2f870c | 4168 | the KR1 is returned. This function is only available on Itanium processors.\r |
ac644614 | 4169 | \r |
ee6c452c | 4170 | @param Value The 64-bit value to write to KR1.\r |
ac644614 | 4171 | \r |
4172 | @return The 64-bit value written to the KR1.\r | |
4173 | \r | |
4174 | **/\r | |
4175 | UINT64\r | |
4176 | EFIAPI\r | |
4177 | AsmWriteKr1 (\r | |
4178 | IN UINT64 Value\r | |
4179 | );\r | |
4180 | \r | |
4181 | \r | |
4182 | /**\r | |
4183 | Write the current value of 64-bit Kernel Register #2 (KR2).\r | |
2fe241a2 | 4184 | \r |
4185 | Writes the current value of KR2. The 64-bit value written to \r | |
1a2f870c | 4186 | the KR2 is returned. This function is only available on Itanium processors.\r |
ac644614 | 4187 | \r |
ee6c452c | 4188 | @param Value The 64-bit value to write to KR2.\r |
ac644614 | 4189 | \r |
4190 | @return The 64-bit value written to the KR2.\r | |
4191 | \r | |
4192 | **/\r | |
4193 | UINT64\r | |
4194 | EFIAPI\r | |
4195 | AsmWriteKr2 (\r | |
4196 | IN UINT64 Value\r | |
4197 | );\r | |
4198 | \r | |
4199 | \r | |
4200 | /**\r | |
4201 | Write the current value of 64-bit Kernel Register #3 (KR3).\r | |
2fe241a2 | 4202 | \r |
4203 | Writes the current value of KR3. The 64-bit value written to \r | |
1a2f870c | 4204 | the KR3 is returned. This function is only available on Itanium processors.\r |
ac644614 | 4205 | \r |
ee6c452c | 4206 | @param Value The 64-bit value to write to KR3.\r |
ac644614 | 4207 | \r |
4208 | @return The 64-bit value written to the KR3.\r | |
4209 | \r | |
4210 | **/\r | |
4211 | UINT64\r | |
4212 | EFIAPI\r | |
4213 | AsmWriteKr3 (\r | |
4214 | IN UINT64 Value\r | |
4215 | );\r | |
4216 | \r | |
4217 | \r | |
4218 | /**\r | |
4219 | Write the current value of 64-bit Kernel Register #4 (KR4).\r | |
2fe241a2 | 4220 | \r |
4221 | Writes the current value of KR4. The 64-bit value written to \r | |
1a2f870c | 4222 | the KR4 is returned. This function is only available on Itanium processors.\r |
ac644614 | 4223 | \r |
ee6c452c | 4224 | @param Value The 64-bit value to write to KR4.\r |
ac644614 | 4225 | \r |
4226 | @return The 64-bit value written to the KR4.\r | |
4227 | \r | |
4228 | **/\r | |
4229 | UINT64\r | |
4230 | EFIAPI\r | |
4231 | AsmWriteKr4 (\r | |
4232 | IN UINT64 Value\r | |
4233 | );\r | |
4234 | \r | |
4235 | \r | |
4236 | /**\r | |
4237 | Write the current value of 64-bit Kernel Register #5 (KR5).\r | |
2fe241a2 | 4238 | \r |
4239 | Writes the current value of KR5. The 64-bit value written to \r | |
1a2f870c | 4240 | the KR5 is returned. This function is only available on Itanium processors.\r |
ac644614 | 4241 | \r |
ee6c452c | 4242 | @param Value The 64-bit value to write to KR5.\r |
ac644614 | 4243 | \r |
4244 | @return The 64-bit value written to the KR5.\r | |
4245 | \r | |
4246 | **/\r | |
4247 | UINT64\r | |
4248 | EFIAPI\r | |
4249 | AsmWriteKr5 (\r | |
4250 | IN UINT64 Value\r | |
4251 | );\r | |
4252 | \r | |
4253 | \r | |
4254 | /**\r | |
4255 | Write the current value of 64-bit Kernel Register #6 (KR6).\r | |
2fe241a2 | 4256 | \r |
4257 | Writes the current value of KR6. The 64-bit value written to \r | |
1a2f870c | 4258 | the KR6 is returned. This function is only available on Itanium processors.\r |
ac644614 | 4259 | \r |
ee6c452c | 4260 | @param Value The 64-bit value to write to KR6.\r |
ac644614 | 4261 | \r |
4262 | @return The 64-bit value written to the KR6.\r | |
4263 | \r | |
4264 | **/\r | |
4265 | UINT64\r | |
4266 | EFIAPI\r | |
4267 | AsmWriteKr6 (\r | |
4268 | IN UINT64 Value\r | |
4269 | );\r | |
4270 | \r | |
4271 | \r | |
4272 | /**\r | |
4273 | Write the current value of 64-bit Kernel Register #7 (KR7).\r | |
2fe241a2 | 4274 | \r |
4275 | Writes the current value of KR7. The 64-bit value written to \r | |
1a2f870c | 4276 | the KR7 is returned. This function is only available on Itanium processors.\r |
ac644614 | 4277 | \r |
ee6c452c | 4278 | @param Value The 64-bit value to write to KR7.\r |
ac644614 | 4279 | \r |
4280 | @return The 64-bit value written to the KR7.\r | |
4281 | \r | |
4282 | **/\r | |
4283 | UINT64\r | |
4284 | EFIAPI\r | |
4285 | AsmWriteKr7 (\r | |
4286 | IN UINT64 Value\r | |
4287 | );\r | |
4288 | \r | |
4289 | \r | |
4290 | /**\r | |
4291 | Reads the current value of Interval Timer Counter Register (ITC).\r | |
2fe241a2 | 4292 | \r |
4293 | Reads and returns the current value of ITC.\r | |
1a2f870c | 4294 | This function is only available on Itanium processors.\r |
ac644614 | 4295 | \r |
4296 | @return The current value of ITC.\r | |
4297 | \r | |
4298 | **/\r | |
4299 | UINT64\r | |
4300 | EFIAPI\r | |
4301 | AsmReadItc (\r | |
4302 | VOID\r | |
4303 | );\r | |
4304 | \r | |
4305 | \r | |
4306 | /**\r | |
4307 | Reads the current value of Interval Timer Vector Register (ITV).\r | |
2fe241a2 | 4308 | \r |
4309 | Reads and returns the current value of ITV. \r | |
1a2f870c | 4310 | This function is only available on Itanium processors.\r |
ac644614 | 4311 | \r |
4312 | @return The current value of ITV.\r | |
4313 | \r | |
4314 | **/\r | |
4315 | UINT64\r | |
4316 | EFIAPI\r | |
4317 | AsmReadItv (\r | |
4318 | VOID\r | |
4319 | );\r | |
4320 | \r | |
4321 | \r | |
4322 | /**\r | |
4323 | Reads the current value of Interval Timer Match Register (ITM).\r | |
2fe241a2 | 4324 | \r |
4325 | Reads and returns the current value of ITM.\r | |
1a2f870c | 4326 | This function is only available on Itanium processors.\r |
ac644614 | 4327 | \r |
4328 | @return The current value of ITM.\r | |
4329 | **/\r | |
4330 | UINT64\r | |
4331 | EFIAPI\r | |
4332 | AsmReadItm (\r | |
4333 | VOID\r | |
4334 | );\r | |
4335 | \r | |
4336 | \r | |
4337 | /**\r | |
4338 | Writes the current value of 64-bit Interval Timer Counter Register (ITC).\r | |
2fe241a2 | 4339 | \r |
4340 | Writes the current value of ITC. The 64-bit value written to the ITC is returned. \r | |
1a2f870c | 4341 | This function is only available on Itanium processors.\r |
ac644614 | 4342 | \r |
ee6c452c | 4343 | @param Value The 64-bit value to write to ITC.\r |
ac644614 | 4344 | \r |
4345 | @return The 64-bit value written to the ITC.\r | |
4346 | \r | |
4347 | **/\r | |
4348 | UINT64\r | |
4349 | EFIAPI\r | |
4350 | AsmWriteItc (\r | |
4351 | IN UINT64 Value\r | |
4352 | );\r | |
4353 | \r | |
4354 | \r | |
4355 | /**\r | |
4356 | Writes the current value of 64-bit Interval Timer Match Register (ITM).\r | |
2fe241a2 | 4357 | \r |
4358 | Writes the current value of ITM. The 64-bit value written to the ITM is returned. \r | |
1a2f870c | 4359 | This function is only available on Itanium processors.\r |
ac644614 | 4360 | \r |
ee6c452c | 4361 | @param Value The 64-bit value to write to ITM.\r |
ac644614 | 4362 | \r |
4363 | @return The 64-bit value written to the ITM.\r | |
4364 | \r | |
4365 | **/\r | |
4366 | UINT64\r | |
4367 | EFIAPI\r | |
4368 | AsmWriteItm (\r | |
4369 | IN UINT64 Value\r | |
4370 | );\r | |
4371 | \r | |
4372 | \r | |
4373 | /**\r | |
4374 | Writes the current value of 64-bit Interval Timer Vector Register (ITV).\r | |
2fe241a2 | 4375 | \r |
4376 | Writes the current value of ITV. The 64-bit value written to the ITV is returned. \r | |
ac644614 | 4377 | No parameter checking is performed on Value. All bits of Value corresponding to\r |
4378 | reserved fields of ITV must be 0 or a Reserved Register/Field fault may occur.\r | |
4379 | The caller must either guarantee that Value is valid, or the caller must set up\r | |
4380 | fault handlers to catch the faults.\r | |
1a2f870c | 4381 | This function is only available on Itanium processors.\r |
ac644614 | 4382 | \r |
ee6c452c | 4383 | @param Value The 64-bit value to write to ITV.\r |
ac644614 | 4384 | \r |
4385 | @return The 64-bit value written to the ITV.\r | |
4386 | \r | |
4387 | **/\r | |
4388 | UINT64\r | |
4389 | EFIAPI\r | |
4390 | AsmWriteItv (\r | |
4391 | IN UINT64 Value\r | |
4392 | );\r | |
4393 | \r | |
4394 | \r | |
4395 | /**\r | |
4396 | Reads the current value of Default Control Register (DCR).\r | |
2fe241a2 | 4397 | \r |
1a2f870c | 4398 | Reads and returns the current value of DCR. This function is only available on Itanium processors.\r |
ac644614 | 4399 | \r |
4400 | @return The current value of DCR.\r | |
4401 | \r | |
4402 | **/\r | |
4403 | UINT64\r | |
4404 | EFIAPI\r | |
4405 | AsmReadDcr (\r | |
4406 | VOID\r | |
4407 | );\r | |
4408 | \r | |
4409 | \r | |
4410 | /**\r | |
4411 | Reads the current value of Interruption Vector Address Register (IVA).\r | |
2fe241a2 | 4412 | \r |
1a2f870c | 4413 | Reads and returns the current value of IVA. This function is only available on Itanium processors.\r |
ac644614 | 4414 | \r |
4415 | @return The current value of IVA.\r | |
4416 | **/\r | |
4417 | UINT64\r | |
4418 | EFIAPI\r | |
4419 | AsmReadIva (\r | |
4420 | VOID\r | |
4421 | );\r | |
4422 | \r | |
4423 | \r | |
4424 | /**\r | |
4425 | Reads the current value of Page Table Address Register (PTA).\r | |
2fe241a2 | 4426 | \r |
1a2f870c | 4427 | Reads and returns the current value of PTA. This function is only available on Itanium processors.\r |
ac644614 | 4428 | \r |
4429 | @return The current value of PTA.\r | |
4430 | \r | |
4431 | **/\r | |
4432 | UINT64\r | |
4433 | EFIAPI\r | |
4434 | AsmReadPta (\r | |
4435 | VOID\r | |
4436 | );\r | |
4437 | \r | |
4438 | \r | |
4439 | /**\r | |
4440 | Writes the current value of 64-bit Default Control Register (DCR).\r | |
2fe241a2 | 4441 | \r |
4442 | Writes the current value of DCR. The 64-bit value written to the DCR is returned. \r | |
ac644614 | 4443 | No parameter checking is performed on Value. All bits of Value corresponding to\r |
4444 | reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.\r | |
4445 | The caller must either guarantee that Value is valid, or the caller must set up\r | |
4446 | fault handlers to catch the faults.\r | |
1a2f870c | 4447 | This function is only available on Itanium processors.\r |
ac644614 | 4448 | \r |
ee6c452c | 4449 | @param Value The 64-bit value to write to DCR.\r |
ac644614 | 4450 | \r |
4451 | @return The 64-bit value written to the DCR.\r | |
4452 | \r | |
4453 | **/\r | |
4454 | UINT64\r | |
4455 | EFIAPI\r | |
4456 | AsmWriteDcr (\r | |
4457 | IN UINT64 Value\r | |
4458 | );\r | |
4459 | \r | |
4460 | \r | |
4461 | /**\r | |
4462 | Writes the current value of 64-bit Interruption Vector Address Register (IVA).\r | |
2fe241a2 | 4463 | \r |
4464 | Writes the current value of IVA. The 64-bit value written to the IVA is returned. \r | |
ac644614 | 4465 | The size of vector table is 32 K bytes and is 32 K bytes aligned\r |
4466 | the low 15 bits of Value is ignored when written.\r | |
1a2f870c | 4467 | This function is only available on Itanium processors.\r |
ac644614 | 4468 | \r |
ee6c452c | 4469 | @param Value The 64-bit value to write to IVA.\r |
ac644614 | 4470 | \r |
4471 | @return The 64-bit value written to the IVA.\r | |
4472 | \r | |
4473 | **/\r | |
4474 | UINT64\r | |
4475 | EFIAPI\r | |
4476 | AsmWriteIva (\r | |
4477 | IN UINT64 Value\r | |
4478 | );\r | |
4479 | \r | |
4480 | \r | |
4481 | /**\r | |
4482 | Writes the current value of 64-bit Page Table Address Register (PTA).\r | |
2fe241a2 | 4483 | \r |
4484 | Writes the current value of PTA. The 64-bit value written to the PTA is returned. \r | |
ac644614 | 4485 | No parameter checking is performed on Value. All bits of Value corresponding to\r |
4486 | reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.\r | |
4487 | The caller must either guarantee that Value is valid, or the caller must set up\r | |
4488 | fault handlers to catch the faults.\r | |
1a2f870c | 4489 | This function is only available on Itanium processors.\r |
ac644614 | 4490 | \r |
ee6c452c | 4491 | @param Value The 64-bit value to write to PTA.\r |
ac644614 | 4492 | \r |
4493 | @return The 64-bit value written to the PTA.\r | |
4494 | **/\r | |
4495 | UINT64\r | |
4496 | EFIAPI\r | |
4497 | AsmWritePta (\r | |
4498 | IN UINT64 Value\r | |
4499 | );\r | |
4500 | \r | |
4501 | \r | |
4502 | /**\r | |
4503 | Reads the current value of Local Interrupt ID Register (LID).\r | |
2fe241a2 | 4504 | \r |
1a2f870c | 4505 | Reads and returns the current value of LID. This function is only available on Itanium processors.\r |
ac644614 | 4506 | \r |
4507 | @return The current value of LID.\r | |
4508 | \r | |
4509 | **/\r | |
4510 | UINT64\r | |
4511 | EFIAPI\r | |
4512 | AsmReadLid (\r | |
4513 | VOID\r | |
4514 | );\r | |
4515 | \r | |
4516 | \r | |
4517 | /**\r | |
4518 | Reads the current value of External Interrupt Vector Register (IVR).\r | |
2fe241a2 | 4519 | \r |
1a2f870c | 4520 | Reads and returns the current value of IVR. This function is only available on Itanium processors. \r |
ac644614 | 4521 | \r |
4522 | @return The current value of IVR.\r | |
4523 | \r | |
4524 | **/\r | |
4525 | UINT64\r | |
4526 | EFIAPI\r | |
4527 | AsmReadIvr (\r | |
4528 | VOID\r | |
4529 | );\r | |
4530 | \r | |
4531 | \r | |
4532 | /**\r | |
4533 | Reads the current value of Task Priority Register (TPR).\r | |
2fe241a2 | 4534 | \r |
1a2f870c | 4535 | Reads and returns the current value of TPR. This function is only available on Itanium processors. \r |
ac644614 | 4536 | \r |
4537 | @return The current value of TPR.\r | |
4538 | \r | |
4539 | **/\r | |
4540 | UINT64\r | |
4541 | EFIAPI\r | |
4542 | AsmReadTpr (\r | |
4543 | VOID\r | |
4544 | );\r | |
4545 | \r | |
4546 | \r | |
4547 | /**\r | |
4548 | Reads the current value of External Interrupt Request Register #0 (IRR0).\r | |
2fe241a2 | 4549 | \r |
1a2f870c | 4550 | Reads and returns the current value of IRR0. This function is only available on Itanium processors. \r |
ac644614 | 4551 | \r |
4552 | @return The current value of IRR0.\r | |
4553 | \r | |
4554 | **/\r | |
4555 | UINT64\r | |
4556 | EFIAPI\r | |
4557 | AsmReadIrr0 (\r | |
4558 | VOID\r | |
4559 | );\r | |
4560 | \r | |
4561 | \r | |
4562 | /**\r | |
4563 | Reads the current value of External Interrupt Request Register #1 (IRR1).\r | |
2fe241a2 | 4564 | \r |
1a2f870c | 4565 | Reads and returns the current value of IRR1. This function is only available on Itanium processors. \r |
ac644614 | 4566 | \r |
4567 | @return The current value of IRR1.\r | |
4568 | \r | |
4569 | **/\r | |
4570 | UINT64\r | |
4571 | EFIAPI\r | |
4572 | AsmReadIrr1 (\r | |
4573 | VOID\r | |
4574 | );\r | |
4575 | \r | |
4576 | \r | |
4577 | /**\r | |
4578 | Reads the current value of External Interrupt Request Register #2 (IRR2).\r | |
2fe241a2 | 4579 | \r |
1a2f870c | 4580 | Reads and returns the current value of IRR2. This function is only available on Itanium processors.\r |
ac644614 | 4581 | \r |
4582 | @return The current value of IRR2.\r | |
4583 | \r | |
4584 | **/\r | |
4585 | UINT64\r | |
4586 | EFIAPI\r | |
4587 | AsmReadIrr2 (\r | |
4588 | VOID\r | |
4589 | );\r | |
4590 | \r | |
4591 | \r | |
4592 | /**\r | |
4593 | Reads the current value of External Interrupt Request Register #3 (IRR3).\r | |
2fe241a2 | 4594 | \r |
1a2f870c | 4595 | Reads and returns the current value of IRR3. This function is only available on Itanium processors. \r |
ac644614 | 4596 | \r |
4597 | @return The current value of IRR3.\r | |
4598 | \r | |
4599 | **/\r | |
4600 | UINT64\r | |
4601 | EFIAPI\r | |
4602 | AsmReadIrr3 (\r | |
4603 | VOID\r | |
4604 | );\r | |
4605 | \r | |
4606 | \r | |
4607 | /**\r | |
4608 | Reads the current value of Performance Monitor Vector Register (PMV).\r | |
2fe241a2 | 4609 | \r |
1a2f870c | 4610 | Reads and returns the current value of PMV. This function is only available on Itanium processors. \r |
ac644614 | 4611 | \r |
4612 | @return The current value of PMV.\r | |
4613 | \r | |
4614 | **/\r | |
4615 | UINT64\r | |
4616 | EFIAPI\r | |
4617 | AsmReadPmv (\r | |
4618 | VOID\r | |
4619 | );\r | |
4620 | \r | |
4621 | \r | |
4622 | /**\r | |
4623 | Reads the current value of Corrected Machine Check Vector Register (CMCV).\r | |
2fe241a2 | 4624 | \r |
1a2f870c | 4625 | Reads and returns the current value of CMCV. This function is only available on Itanium processors.\r |
ac644614 | 4626 | \r |
4627 | @return The current value of CMCV.\r | |
4628 | \r | |
4629 | **/\r | |
4630 | UINT64\r | |
4631 | EFIAPI\r | |
4632 | AsmReadCmcv (\r | |
4633 | VOID\r | |
4634 | );\r | |
4635 | \r | |
4636 | \r | |
4637 | /**\r | |
4638 | Reads the current value of Local Redirection Register #0 (LRR0).\r | |
2fe241a2 | 4639 | \r |
1a2f870c | 4640 | Reads and returns the current value of LRR0. This function is only available on Itanium processors. \r |
ac644614 | 4641 | \r |
4642 | @return The current value of LRR0.\r | |
4643 | \r | |
4644 | **/\r | |
4645 | UINT64\r | |
4646 | EFIAPI\r | |
4647 | AsmReadLrr0 (\r | |
4648 | VOID\r | |
4649 | );\r | |
4650 | \r | |
4651 | \r | |
4652 | /**\r | |
4653 | Reads the current value of Local Redirection Register #1 (LRR1).\r | |
2fe241a2 | 4654 | \r |
1a2f870c | 4655 | Reads and returns the current value of LRR1. This function is only available on Itanium processors.\r |
ac644614 | 4656 | \r |
4657 | @return The current value of LRR1.\r | |
4658 | \r | |
4659 | **/\r | |
4660 | UINT64\r | |
4661 | EFIAPI\r | |
4662 | AsmReadLrr1 (\r | |
4663 | VOID\r | |
4664 | );\r | |
4665 | \r | |
4666 | \r | |
4667 | /**\r | |
4668 | Writes the current value of 64-bit Page Local Interrupt ID Register (LID).\r | |
2fe241a2 | 4669 | \r |
4670 | Writes the current value of LID. The 64-bit value written to the LID is returned. \r | |
ac644614 | 4671 | No parameter checking is performed on Value. All bits of Value corresponding to\r |
4672 | reserved fields of LID must be 0 or a Reserved Register/Field fault may occur.\r | |
4673 | The caller must either guarantee that Value is valid, or the caller must set up\r | |
4674 | fault handlers to catch the faults.\r | |
1a2f870c | 4675 | This function is only available on Itanium processors.\r |
ac644614 | 4676 | \r |
ee6c452c | 4677 | @param Value The 64-bit value to write to LID.\r |
ac644614 | 4678 | \r |
4679 | @return The 64-bit value written to the LID.\r | |
4680 | \r | |
4681 | **/\r | |
4682 | UINT64\r | |
4683 | EFIAPI\r | |
4684 | AsmWriteLid (\r | |
4685 | IN UINT64 Value\r | |
4686 | );\r | |
4687 | \r | |
4688 | \r | |
4689 | /**\r | |
4690 | Writes the current value of 64-bit Task Priority Register (TPR).\r | |
2fe241a2 | 4691 | \r |
4692 | Writes the current value of TPR. The 64-bit value written to the TPR is returned. \r | |
ac644614 | 4693 | No parameter checking is performed on Value. All bits of Value corresponding to\r |
4694 | reserved fields of TPR must be 0 or a Reserved Register/Field fault may occur.\r | |
4695 | The caller must either guarantee that Value is valid, or the caller must set up\r | |
4696 | fault handlers to catch the faults.\r | |
1a2f870c | 4697 | This function is only available on Itanium processors.\r |
ac644614 | 4698 | \r |
ee6c452c | 4699 | @param Value The 64-bit value to write to TPR.\r |
ac644614 | 4700 | \r |
4701 | @return The 64-bit value written to the TPR.\r | |
4702 | \r | |
4703 | **/\r | |
4704 | UINT64\r | |
4705 | EFIAPI\r | |
4706 | AsmWriteTpr (\r | |
4707 | IN UINT64 Value\r | |
4708 | );\r | |
4709 | \r | |
4710 | \r | |
4711 | /**\r | |
4712 | Performs a write operation on End OF External Interrupt Register (EOI).\r | |
2fe241a2 | 4713 | \r |
1a2f870c | 4714 | Writes a value of 0 to the EOI Register. This function is only available on Itanium processors.\r |
ac644614 | 4715 | \r |
4716 | **/\r | |
4717 | VOID\r | |
4718 | EFIAPI\r | |
4719 | AsmWriteEoi (\r | |
4720 | VOID\r | |
4721 | );\r | |
4722 | \r | |
4723 | \r | |
4724 | /**\r | |
4725 | Writes the current value of 64-bit Performance Monitor Vector Register (PMV).\r | |
2fe241a2 | 4726 | \r |
4727 | Writes the current value of PMV. The 64-bit value written to the PMV is returned. \r | |
ac644614 | 4728 | No parameter checking is performed on Value. All bits of Value corresponding\r |
4729 | to reserved fields of PMV must be 0 or a Reserved Register/Field fault may occur.\r | |
4730 | The caller must either guarantee that Value is valid, or the caller must set up\r | |
4731 | fault handlers to catch the faults.\r | |
1a2f870c | 4732 | This function is only available on Itanium processors.\r |
ac644614 | 4733 | \r |
ee6c452c | 4734 | @param Value The 64-bit value to write to PMV.\r |
ac644614 | 4735 | \r |
4736 | @return The 64-bit value written to the PMV.\r | |
4737 | \r | |
4738 | **/\r | |
4739 | UINT64\r | |
4740 | EFIAPI\r | |
4741 | AsmWritePmv (\r | |
4742 | IN UINT64 Value\r | |
4743 | );\r | |
4744 | \r | |
4745 | \r | |
4746 | /**\r | |
4747 | Writes the current value of 64-bit Corrected Machine Check Vector Register (CMCV).\r | |
2fe241a2 | 4748 | \r |
4749 | Writes the current value of CMCV. The 64-bit value written to the CMCV is returned. \r | |
ac644614 | 4750 | No parameter checking is performed on Value. All bits of Value corresponding\r |
4751 | to reserved fields of CMCV must be 0 or a Reserved Register/Field fault may occur.\r | |
4752 | The caller must either guarantee that Value is valid, or the caller must set up\r | |
4753 | fault handlers to catch the faults.\r | |
1a2f870c | 4754 | This function is only available on Itanium processors.\r |
ac644614 | 4755 | \r |
ee6c452c | 4756 | @param Value The 64-bit value to write to CMCV.\r |
ac644614 | 4757 | \r |
4758 | @return The 64-bit value written to the CMCV.\r | |
4759 | \r | |
4760 | **/\r | |
4761 | UINT64\r | |
4762 | EFIAPI\r | |
4763 | AsmWriteCmcv (\r | |
4764 | IN UINT64 Value\r | |
4765 | );\r | |
4766 | \r | |
4767 | \r | |
4768 | /**\r | |
4769 | Writes the current value of 64-bit Local Redirection Register #0 (LRR0).\r | |
2fe241a2 | 4770 | \r |
4771 | Writes the current value of LRR0. The 64-bit value written to the LRR0 is returned. \r | |
ac644614 | 4772 | No parameter checking is performed on Value. All bits of Value corresponding\r |
4773 | to reserved fields of LRR0 must be 0 or a Reserved Register/Field fault may occur.\r | |
4774 | The caller must either guarantee that Value is valid, or the caller must set up\r | |
4775 | fault handlers to catch the faults.\r | |
1a2f870c | 4776 | This function is only available on Itanium processors.\r |
ac644614 | 4777 | \r |
ee6c452c | 4778 | @param Value The 64-bit value to write to LRR0.\r |
ac644614 | 4779 | \r |
4780 | @return The 64-bit value written to the LRR0.\r | |
4781 | \r | |
4782 | **/\r | |
4783 | UINT64\r | |
4784 | EFIAPI\r | |
4785 | AsmWriteLrr0 (\r | |
4786 | IN UINT64 Value\r | |
4787 | );\r | |
4788 | \r | |
4789 | \r | |
4790 | /**\r | |
4791 | Writes the current value of 64-bit Local Redirection Register #1 (LRR1).\r | |
2fe241a2 | 4792 | \r |
4793 | Writes the current value of LRR1. The 64-bit value written to the LRR1 is returned. \r | |
ac644614 | 4794 | No parameter checking is performed on Value. All bits of Value corresponding\r |
4795 | to reserved fields of LRR1 must be 0 or a Reserved Register/Field fault may occur.\r | |
4796 | The caller must either guarantee that Value is valid, or the caller must\r | |
4797 | set up fault handlers to catch the faults.\r | |
1a2f870c | 4798 | This function is only available on Itanium processors.\r |
ac644614 | 4799 | \r |
ee6c452c | 4800 | @param Value The 64-bit value to write to LRR1.\r |
ac644614 | 4801 | \r |
4802 | @return The 64-bit value written to the LRR1.\r | |
4803 | \r | |
4804 | **/\r | |
4805 | UINT64\r | |
4806 | EFIAPI\r | |
4807 | AsmWriteLrr1 (\r | |
4808 | IN UINT64 Value\r | |
4809 | );\r | |
4810 | \r | |
4811 | \r | |
4812 | /**\r | |
4813 | Reads the current value of Instruction Breakpoint Register (IBR).\r | |
4814 | \r | |
4815 | The Instruction Breakpoint Registers are used in pairs. The even numbered\r | |
4816 | registers contain breakpoint addresses, and the odd numbered registers contain\r | |
af2dc6a7 | 4817 | breakpoint mask conditions. At least four instruction registers pairs are implemented\r |
ac644614 | 4818 | on all processor models. Implemented registers are contiguous starting with\r |
4819 | register 0. No parameter checking is performed on Index, and if the Index value\r | |
4820 | is beyond the implemented IBR register range, a Reserved Register/Field fault may\r | |
4821 | occur. The caller must either guarantee that Index is valid, or the caller must\r | |
4822 | set up fault handlers to catch the faults.\r | |
1a2f870c | 4823 | This function is only available on Itanium processors.\r |
ac644614 | 4824 | \r |
ee6c452c | 4825 | @param Index The 8-bit Instruction Breakpoint Register index to read.\r |
ac644614 | 4826 | \r |
4827 | @return The current value of Instruction Breakpoint Register specified by Index.\r | |
4828 | \r | |
4829 | **/\r | |
4830 | UINT64\r | |
4831 | EFIAPI\r | |
4832 | AsmReadIbr (\r | |
4833 | IN UINT8 Index\r | |
4834 | );\r | |
4835 | \r | |
4836 | \r | |
4837 | /**\r | |
4838 | Reads the current value of Data Breakpoint Register (DBR).\r | |
4839 | \r | |
4840 | The Data Breakpoint Registers are used in pairs. The even numbered registers\r | |
4841 | contain breakpoint addresses, and odd numbered registers contain breakpoint\r | |
af2dc6a7 | 4842 | mask conditions. At least four data registers pairs are implemented on all processor\r |
ac644614 | 4843 | models. Implemented registers are contiguous starting with register 0.\r |
4844 | No parameter checking is performed on Index. If the Index value is beyond\r | |
4845 | the implemented DBR register range, a Reserved Register/Field fault may occur.\r | |
4846 | The caller must either guarantee that Index is valid, or the caller must set up\r | |
4847 | fault handlers to catch the faults.\r | |
1a2f870c | 4848 | This function is only available on Itanium processors.\r |
ac644614 | 4849 | \r |
ee6c452c | 4850 | @param Index The 8-bit Data Breakpoint Register index to read.\r |
ac644614 | 4851 | \r |
4852 | @return The current value of Data Breakpoint Register specified by Index.\r | |
4853 | \r | |
4854 | **/\r | |
4855 | UINT64\r | |
4856 | EFIAPI\r | |
4857 | AsmReadDbr (\r | |
4858 | IN UINT8 Index\r | |
4859 | );\r | |
4860 | \r | |
4861 | \r | |
4862 | /**\r | |
4863 | Reads the current value of Performance Monitor Configuration Register (PMC).\r | |
4864 | \r | |
af2dc6a7 | 4865 | All processor implementations provide at least four performance counters\r |
4866 | (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow\r | |
ac644614 | 4867 | status registers (PMC [0]... PMC [3]). Processor implementations may provide\r |
4868 | additional implementation-dependent PMC and PMD to increase the number of\r | |
4869 | 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD\r | |
4870 | register set is implementation dependent. No parameter checking is performed\r | |
4871 | on Index. If the Index value is beyond the implemented PMC register range,\r | |
4872 | zero value will be returned.\r | |
1a2f870c | 4873 | This function is only available on Itanium processors.\r |
ac644614 | 4874 | \r |
ee6c452c | 4875 | @param Index The 8-bit Performance Monitor Configuration Register index to read.\r |
ac644614 | 4876 | \r |
2fe241a2 | 4877 | @return The current value of Performance Monitor Configuration Register\r |
4878 | specified by Index.\r | |
ac644614 | 4879 | \r |
4880 | **/\r | |
4881 | UINT64\r | |
4882 | EFIAPI\r | |
4883 | AsmReadPmc (\r | |
4884 | IN UINT8 Index\r | |
4885 | );\r | |
4886 | \r | |
4887 | \r | |
4888 | /**\r | |
4889 | Reads the current value of Performance Monitor Data Register (PMD).\r | |
4890 | \r | |
4891 | All processor implementations provide at least 4 performance counters\r | |
4892 | (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter\r | |
4893 | overflow status registers (PMC [0]... PMC [3]). Processor implementations may\r | |
4894 | provide additional implementation-dependent PMC and PMD to increase the number\r | |
4895 | of 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD\r | |
4896 | register set is implementation dependent. No parameter checking is performed\r | |
4897 | on Index. If the Index value is beyond the implemented PMD register range,\r | |
4898 | zero value will be returned.\r | |
1a2f870c | 4899 | This function is only available on Itanium processors.\r |
ac644614 | 4900 | \r |
ee6c452c | 4901 | @param Index The 8-bit Performance Monitor Data Register index to read.\r |
ac644614 | 4902 | \r |
4903 | @return The current value of Performance Monitor Data Register specified by Index.\r | |
4904 | \r | |
4905 | **/\r | |
4906 | UINT64\r | |
4907 | EFIAPI\r | |
4908 | AsmReadPmd (\r | |
4909 | IN UINT8 Index\r | |
4910 | );\r | |
4911 | \r | |
4912 | \r | |
4913 | /**\r | |
4914 | Writes the current value of 64-bit Instruction Breakpoint Register (IBR).\r | |
4915 | \r | |
4916 | Writes current value of Instruction Breakpoint Register specified by Index.\r | |
4917 | The Instruction Breakpoint Registers are used in pairs. The even numbered\r | |
4918 | registers contain breakpoint addresses, and odd numbered registers contain\r | |
af2dc6a7 | 4919 | breakpoint mask conditions. At least four instruction registers pairs are implemented\r |
ac644614 | 4920 | on all processor models. Implemented registers are contiguous starting with\r |
4921 | register 0. No parameter checking is performed on Index. If the Index value\r | |
4922 | is beyond the implemented IBR register range, a Reserved Register/Field fault may\r | |
4923 | occur. The caller must either guarantee that Index is valid, or the caller must\r | |
4924 | set up fault handlers to catch the faults.\r | |
1a2f870c | 4925 | This function is only available on Itanium processors.\r |
ac644614 | 4926 | \r |
ee6c452c | 4927 | @param Index The 8-bit Instruction Breakpoint Register index to write.\r |
4928 | @param Value The 64-bit value to write to IBR.\r | |
ac644614 | 4929 | \r |
4930 | @return The 64-bit value written to the IBR.\r | |
4931 | \r | |
4932 | **/\r | |
4933 | UINT64\r | |
4934 | EFIAPI\r | |
4935 | AsmWriteIbr (\r | |
4936 | IN UINT8 Index,\r | |
4937 | IN UINT64 Value\r | |
4938 | );\r | |
4939 | \r | |
4940 | \r | |
4941 | /**\r | |
4942 | Writes the current value of 64-bit Data Breakpoint Register (DBR).\r | |
4943 | \r | |
4944 | Writes current value of Data Breakpoint Register specified by Index.\r | |
4945 | The Data Breakpoint Registers are used in pairs. The even numbered registers\r | |
4946 | contain breakpoint addresses, and odd numbered registers contain breakpoint\r | |
af2dc6a7 | 4947 | mask conditions. At least four data registers pairs are implemented on all processor\r |
ac644614 | 4948 | models. Implemented registers are contiguous starting with register 0. No parameter\r |
4949 | checking is performed on Index. If the Index value is beyond the implemented\r | |
4950 | DBR register range, a Reserved Register/Field fault may occur. The caller must\r | |
4951 | either guarantee that Index is valid, or the caller must set up fault handlers to\r | |
4952 | catch the faults.\r | |
1a2f870c | 4953 | This function is only available on Itanium processors.\r |
ac644614 | 4954 | \r |
ee6c452c | 4955 | @param Index The 8-bit Data Breakpoint Register index to write.\r |
4956 | @param Value The 64-bit value to write to DBR.\r | |
ac644614 | 4957 | \r |
4958 | @return The 64-bit value written to the DBR.\r | |
4959 | \r | |
4960 | **/\r | |
4961 | UINT64\r | |
4962 | EFIAPI\r | |
4963 | AsmWriteDbr (\r | |
4964 | IN UINT8 Index,\r | |
4965 | IN UINT64 Value\r | |
4966 | );\r | |
4967 | \r | |
4968 | \r | |
4969 | /**\r | |
4970 | Writes the current value of 64-bit Performance Monitor Configuration Register (PMC).\r | |
4971 | \r | |
4972 | Writes current value of Performance Monitor Configuration Register specified by Index.\r | |
af2dc6a7 | 4973 | All processor implementations provide at least four performance counters\r |
4974 | (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow status\r | |
ac644614 | 4975 | registers (PMC [0]... PMC [3]). Processor implementations may provide additional\r |
4976 | implementation-dependent PMC and PMD to increase the number of 'generic' performance\r | |
4977 | counters (PMC/PMD pairs). The remainder of PMC and PMD register set is implementation\r | |
4978 | dependent. No parameter checking is performed on Index. If the Index value is\r | |
4979 | beyond the implemented PMC register range, the write is ignored.\r | |
1a2f870c | 4980 | This function is only available on Itanium processors.\r |
ac644614 | 4981 | \r |
ee6c452c | 4982 | @param Index The 8-bit Performance Monitor Configuration Register index to write.\r |
4983 | @param Value The 64-bit value to write to PMC.\r | |
ac644614 | 4984 | \r |
4985 | @return The 64-bit value written to the PMC.\r | |
4986 | \r | |
4987 | **/\r | |
4988 | UINT64\r | |
4989 | EFIAPI\r | |
4990 | AsmWritePmc (\r | |
4991 | IN UINT8 Index,\r | |
4992 | IN UINT64 Value\r | |
4993 | );\r | |
4994 | \r | |
4995 | \r | |
4996 | /**\r | |
4997 | Writes the current value of 64-bit Performance Monitor Data Register (PMD).\r | |
4998 | \r | |
4999 | Writes current value of Performance Monitor Data Register specified by Index.\r | |
af2dc6a7 | 5000 | All processor implementations provide at least four performance counters\r |
5001 | (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow\r | |
ac644614 | 5002 | status registers (PMC [0]... PMC [3]). Processor implementations may provide\r |
5003 | additional implementation-dependent PMC and PMD to increase the number of 'generic'\r | |
5004 | performance counters (PMC/PMD pairs). The remainder of PMC and PMD register set\r | |
5005 | is implementation dependent. No parameter checking is performed on Index. If the\r | |
5006 | Index value is beyond the implemented PMD register range, the write is ignored.\r | |
1a2f870c | 5007 | This function is only available on Itanium processors.\r |
ac644614 | 5008 | \r |
ee6c452c | 5009 | @param Index The 8-bit Performance Monitor Data Register index to write.\r |
5010 | @param Value The 64-bit value to write to PMD.\r | |
ac644614 | 5011 | \r |
5012 | @return The 64-bit value written to the PMD.\r | |
5013 | \r | |
5014 | **/\r | |
5015 | UINT64\r | |
5016 | EFIAPI\r | |
5017 | AsmWritePmd (\r | |
5018 | IN UINT8 Index,\r | |
5019 | IN UINT64 Value\r | |
5020 | );\r | |
5021 | \r | |
5022 | \r | |
5023 | /**\r | |
5024 | Reads the current value of 64-bit Global Pointer (GP).\r | |
5025 | \r | |
5026 | Reads and returns the current value of GP.\r | |
1a2f870c | 5027 | This function is only available on Itanium processors.\r |
ac644614 | 5028 | \r |
5029 | @return The current value of GP.\r | |
5030 | \r | |
5031 | **/\r | |
5032 | UINT64\r | |
5033 | EFIAPI\r | |
5034 | AsmReadGp (\r | |
5035 | VOID\r | |
5036 | );\r | |
5037 | \r | |
5038 | \r | |
5039 | /**\r | |
5040 | Write the current value of 64-bit Global Pointer (GP).\r | |
5041 | \r | |
5042 | Writes the current value of GP. The 64-bit value written to the GP is returned.\r | |
5043 | No parameter checking is performed on Value.\r | |
1a2f870c | 5044 | This function is only available on Itanium processors.\r |
ac644614 | 5045 | \r |
5046 | @param Value The 64-bit value to write to GP.\r | |
5047 | \r | |
5048 | @return The 64-bit value written to the GP.\r | |
5049 | \r | |
5050 | **/\r | |
5051 | UINT64\r | |
5052 | EFIAPI\r | |
5053 | AsmWriteGp (\r | |
5054 | IN UINT64 Value\r | |
5055 | );\r | |
5056 | \r | |
5057 | \r | |
5058 | /**\r | |
5059 | Reads the current value of 64-bit Stack Pointer (SP).\r | |
5060 | \r | |
5061 | Reads and returns the current value of SP.\r | |
1a2f870c | 5062 | This function is only available on Itanium processors.\r |
ac644614 | 5063 | \r |
5064 | @return The current value of SP.\r | |
5065 | \r | |
5066 | **/\r | |
5067 | UINT64\r | |
5068 | EFIAPI\r | |
5069 | AsmReadSp (\r | |
5070 | VOID\r | |
5071 | );\r | |
5072 | \r | |
5073 | \r | |
aad6137d | 5074 | ///\r |
af2dc6a7 | 5075 | /// Valid Index value for AsmReadControlRegister().\r |
aad6137d | 5076 | ///\r |
5077 | #define IPF_CONTROL_REGISTER_DCR 0\r | |
5078 | #define IPF_CONTROL_REGISTER_ITM 1\r | |
5079 | #define IPF_CONTROL_REGISTER_IVA 2\r | |
5080 | #define IPF_CONTROL_REGISTER_PTA 8\r | |
5081 | #define IPF_CONTROL_REGISTER_IPSR 16\r | |
5082 | #define IPF_CONTROL_REGISTER_ISR 17\r | |
5083 | #define IPF_CONTROL_REGISTER_IIP 19\r | |
5084 | #define IPF_CONTROL_REGISTER_IFA 20\r | |
5085 | #define IPF_CONTROL_REGISTER_ITIR 21\r | |
5086 | #define IPF_CONTROL_REGISTER_IIPA 22\r | |
5087 | #define IPF_CONTROL_REGISTER_IFS 23\r | |
5088 | #define IPF_CONTROL_REGISTER_IIM 24\r | |
5089 | #define IPF_CONTROL_REGISTER_IHA 25\r | |
5090 | #define IPF_CONTROL_REGISTER_LID 64\r | |
5091 | #define IPF_CONTROL_REGISTER_IVR 65\r | |
5092 | #define IPF_CONTROL_REGISTER_TPR 66\r | |
5093 | #define IPF_CONTROL_REGISTER_EOI 67\r | |
5094 | #define IPF_CONTROL_REGISTER_IRR0 68\r | |
5095 | #define IPF_CONTROL_REGISTER_IRR1 69\r | |
5096 | #define IPF_CONTROL_REGISTER_IRR2 70\r | |
5097 | #define IPF_CONTROL_REGISTER_IRR3 71\r | |
5098 | #define IPF_CONTROL_REGISTER_ITV 72\r | |
5099 | #define IPF_CONTROL_REGISTER_PMV 73\r | |
5100 | #define IPF_CONTROL_REGISTER_CMCV 74\r | |
5101 | #define IPF_CONTROL_REGISTER_LRR0 80\r | |
5102 | #define IPF_CONTROL_REGISTER_LRR1 81\r | |
5103 | \r | |
5104 | /**\r | |
5105 | Reads a 64-bit control register.\r | |
5106 | \r | |
af2dc6a7 | 5107 | Reads and returns the control register specified by Index. The valid Index valued \r |
5108 | are defined above in "Related Definitions".\r | |
5109 | If Index is invalid then 0xFFFFFFFFFFFFFFFF is returned. This function is only \r | |
5110 | available on Itanium processors.\r | |
aad6137d | 5111 | \r |
5112 | @param Index The index of the control register to read.\r | |
5113 | \r | |
5114 | @return The control register specified by Index.\r | |
5115 | \r | |
5116 | **/\r | |
5117 | UINT64\r | |
5118 | EFIAPI\r | |
5119 | AsmReadControlRegister (\r | |
5120 | IN UINT64 Index\r | |
5121 | );\r | |
5122 | \r | |
5123 | \r | |
5124 | ///\r | |
af2dc6a7 | 5125 | /// Valid Index value for AsmReadApplicationRegister().\r |
aad6137d | 5126 | ///\r |
5127 | #define IPF_APPLICATION_REGISTER_K0 0\r | |
5128 | #define IPF_APPLICATION_REGISTER_K1 1\r | |
5129 | #define IPF_APPLICATION_REGISTER_K2 2\r | |
5130 | #define IPF_APPLICATION_REGISTER_K3 3\r | |
5131 | #define IPF_APPLICATION_REGISTER_K4 4\r | |
5132 | #define IPF_APPLICATION_REGISTER_K5 5\r | |
5133 | #define IPF_APPLICATION_REGISTER_K6 6\r | |
5134 | #define IPF_APPLICATION_REGISTER_K7 7\r | |
5135 | #define IPF_APPLICATION_REGISTER_RSC 16\r | |
5136 | #define IPF_APPLICATION_REGISTER_BSP 17\r | |
5137 | #define IPF_APPLICATION_REGISTER_BSPSTORE 18\r | |
5138 | #define IPF_APPLICATION_REGISTER_RNAT 19\r | |
5139 | #define IPF_APPLICATION_REGISTER_FCR 21\r | |
5140 | #define IPF_APPLICATION_REGISTER_EFLAG 24\r | |
5141 | #define IPF_APPLICATION_REGISTER_CSD 25\r | |
5142 | #define IPF_APPLICATION_REGISTER_SSD 26\r | |
5143 | #define IPF_APPLICATION_REGISTER_CFLG 27\r | |
5144 | #define IPF_APPLICATION_REGISTER_FSR 28\r | |
5145 | #define IPF_APPLICATION_REGISTER_FIR 29\r | |
5146 | #define IPF_APPLICATION_REGISTER_FDR 30\r | |
5147 | #define IPF_APPLICATION_REGISTER_CCV 32\r | |
5148 | #define IPF_APPLICATION_REGISTER_UNAT 36\r | |
5149 | #define IPF_APPLICATION_REGISTER_FPSR 40\r | |
5150 | #define IPF_APPLICATION_REGISTER_ITC 44\r | |
5151 | #define IPF_APPLICATION_REGISTER_PFS 64\r | |
5152 | #define IPF_APPLICATION_REGISTER_LC 65\r | |
5153 | #define IPF_APPLICATION_REGISTER_EC 66\r | |
5154 | \r | |
5155 | /**\r | |
5156 | Reads a 64-bit application register.\r | |
5157 | \r | |
af2dc6a7 | 5158 | Reads and returns the application register specified by Index. The valid Index \r |
5159 | valued are defined above in "Related Definitions".\r | |
5160 | If Index is invalid then 0xFFFFFFFFFFFFFFFF is returned. This function is only \r | |
5161 | available on Itanium processors.\r | |
aad6137d | 5162 | \r |
5163 | @param Index The index of the application register to read.\r | |
5164 | \r | |
5165 | @return The application register specified by Index.\r | |
5166 | \r | |
5167 | **/\r | |
5168 | UINT64\r | |
5169 | EFIAPI\r | |
5170 | AsmReadApplicationRegister (\r | |
5171 | IN UINT64 Index\r | |
5172 | );\r | |
5173 | \r | |
5174 | \r | |
59e0bb0c | 5175 | /**\r |
5176 | Reads the current value of a Machine Specific Register (MSR).\r | |
5177 | \r | |
5178 | Reads and returns the current value of the Machine Specific Register specified by Index. No\r | |
5179 | parameter checking is performed on Index, and if the Index value is beyond the implemented MSR\r | |
5180 | register range, a Reserved Register/Field fault may occur. The caller must either guarantee that\r | |
5181 | Index is valid, or the caller must set up fault handlers to catch the faults. This function is\r | |
1a2f870c | 5182 | only available on Itanium processors.\r |
59e0bb0c | 5183 | \r |
5184 | @param Index The 8-bit Machine Specific Register index to read.\r | |
5185 | \r | |
5186 | @return The current value of the Machine Specific Register specified by Index. \r | |
5187 | \r | |
5188 | **/\r | |
5189 | UINT64\r | |
5190 | EFIAPI\r | |
5191 | AsmReadMsr (\r | |
5192 | IN UINT8 Index \r | |
5193 | );\r | |
5194 | \r | |
5195 | \r | |
5196 | /**\r | |
5197 | Writes the current value of a Machine Specific Register (MSR).\r | |
5198 | \r | |
5199 | Writes Value to the Machine Specific Register specified by Index. Value is returned. No\r | |
5200 | parameter checking is performed on Index, and if the Index value is beyond the implemented MSR\r | |
5201 | register range, a Reserved Register/Field fault may occur. The caller must either guarantee that\r | |
5202 | Index is valid, or the caller must set up fault handlers to catch the faults. This function is\r | |
1a2f870c | 5203 | only available on Itanium processors.\r |
59e0bb0c | 5204 | \r |
5205 | @param Index The 8-bit Machine Specific Register index to write.\r | |
5206 | @param Value The 64-bit value to write to the Machine Specific Register.\r | |
5207 | \r | |
5208 | @return The 64-bit value to write to the Machine Specific Register. \r | |
5209 | \r | |
5210 | **/\r | |
5211 | UINT64\r | |
5212 | EFIAPI\r | |
5213 | AsmWriteMsr (\r | |
5214 | IN UINT8 Index, \r | |
5215 | IN UINT64 Value \r | |
5216 | );\r | |
5217 | \r | |
5218 | \r | |
ac644614 | 5219 | /**\r |
5220 | Determines if the CPU is currently executing in virtual, physical, or mixed mode.\r | |
5221 | \r | |
5222 | Determines the current execution mode of the CPU.\r | |
5223 | If the CPU is in virtual mode(PSR.RT=1, PSR.DT=1, PSR.IT=1), then 1 is returned.\r | |
5224 | If the CPU is in physical mode(PSR.RT=0, PSR.DT=0, PSR.IT=0), then 0 is returned.\r | |
5225 | If the CPU is not in physical mode or virtual mode, then it is in mixed mode,\r | |
5226 | and -1 is returned.\r | |
1a2f870c | 5227 | This function is only available on Itanium processors.\r |
ac644614 | 5228 | \r |
17f695ed | 5229 | @retval 1 The CPU is in virtual mode.\r |
5230 | @retval 0 The CPU is in physical mode.\r | |
5231 | @retval -1 The CPU is in mixed mode.\r | |
ac644614 | 5232 | \r |
5233 | **/\r | |
5234 | INT64\r | |
5235 | EFIAPI\r | |
5236 | AsmCpuVirtual (\r | |
5237 | VOID\r | |
5238 | );\r | |
5239 | \r | |
5240 | \r | |
5241 | /**\r | |
5242 | Makes a PAL procedure call.\r | |
5243 | \r | |
5244 | This is a wrapper function to make a PAL procedure call. Based on the Index\r | |
5245 | value this API will make static or stacked PAL call. The following table\r | |
5246 | describes the usage of PAL Procedure Index Assignment. Architected procedures\r | |
5247 | may be designated as required or optional. If a PAL procedure is specified\r | |
5248 | as optional, a unique return code of 0xFFFFFFFFFFFFFFFF is returned in the\r | |
5249 | Status field of the PAL_CALL_RETURN structure.\r | |
5250 | This indicates that the procedure is not present in this PAL implementation.\r | |
5251 | It is the caller's responsibility to check for this return code after calling\r | |
5252 | any optional PAL procedure.\r | |
5253 | No parameter checking is performed on the 5 input parameters, but there are\r | |
5254 | some common rules that the caller should follow when making a PAL call. Any\r | |
5255 | address passed to PAL as buffers for return parameters must be 8-byte aligned.\r | |
5256 | Unaligned addresses may cause undefined results. For those parameters defined\r | |
5257 | as reserved or some fields defined as reserved must be zero filled or the invalid\r | |
5258 | argument return value may be returned or undefined result may occur during the\r | |
5259 | execution of the procedure. If the PalEntryPoint does not point to a valid\r | |
5260 | PAL entry point then the system behavior is undefined. This function is only\r | |
1a2f870c | 5261 | available on Itanium processors.\r |
ac644614 | 5262 | \r |
ee6c452c | 5263 | @param PalEntryPoint The PAL procedure calls entry point.\r |
5264 | @param Index The PAL procedure Index number.\r | |
5265 | @param Arg2 The 2nd parameter for PAL procedure calls.\r | |
5266 | @param Arg3 The 3rd parameter for PAL procedure calls.\r | |
5267 | @param Arg4 The 4th parameter for PAL procedure calls.\r | |
ac644614 | 5268 | \r |
5269 | @return structure returned from the PAL Call procedure, including the status and return value.\r | |
5270 | \r | |
5271 | **/\r | |
5272 | PAL_CALL_RETURN\r | |
5273 | EFIAPI\r | |
5274 | AsmPalCall (\r | |
5275 | IN UINT64 PalEntryPoint,\r | |
5276 | IN UINT64 Index,\r | |
5277 | IN UINT64 Arg2,\r | |
5278 | IN UINT64 Arg3,\r | |
5279 | IN UINT64 Arg4\r | |
5280 | );\r | |
fd163050 | 5281 | #endif\r |
ac644614 | 5282 | \r |
fd163050 | 5283 | #if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)\r |
1106ffe1 | 5284 | ///\r |
af2dc6a7 | 5285 | /// IA32 and x64 Specific Functions.\r |
5286 | /// Byte packed structure for 16-bit Real Mode EFLAGS.\r | |
1106ffe1 | 5287 | ///\r |
ac644614 | 5288 | typedef union {\r |
5289 | struct {\r | |
af2dc6a7 | 5290 | UINT32 CF:1; ///< Carry Flag.\r |
5291 | UINT32 Reserved_0:1; ///< Reserved.\r | |
5292 | UINT32 PF:1; ///< Parity Flag.\r | |
5293 | UINT32 Reserved_1:1; ///< Reserved.\r | |
5294 | UINT32 AF:1; ///< Auxiliary Carry Flag.\r | |
5295 | UINT32 Reserved_2:1; ///< Reserved.\r | |
5296 | UINT32 ZF:1; ///< Zero Flag.\r | |
5297 | UINT32 SF:1; ///< Sign Flag.\r | |
5298 | UINT32 TF:1; ///< Trap Flag.\r | |
5299 | UINT32 IF:1; ///< Interrupt Enable Flag.\r | |
5300 | UINT32 DF:1; ///< Direction Flag.\r | |
5301 | UINT32 OF:1; ///< Overflow Flag.\r | |
5302 | UINT32 IOPL:2; ///< I/O Privilege Level.\r | |
5303 | UINT32 NT:1; ///< Nested Task.\r | |
5304 | UINT32 Reserved_3:1; ///< Reserved.\r | |
ac644614 | 5305 | } Bits;\r |
5306 | UINT16 Uint16;\r | |
5307 | } IA32_FLAGS16;\r | |
5308 | \r | |
1106ffe1 | 5309 | ///\r |
af2dc6a7 | 5310 | /// Byte packed structure for EFLAGS/RFLAGS.\r |
5311 | /// 32-bits on IA-32.\r | |
5312 | /// 64-bits on x64. The upper 32-bits on x64 are reserved.\r | |
1106ffe1 | 5313 | ///\r |
ac644614 | 5314 | typedef union {\r |
5315 | struct {\r | |
af2dc6a7 | 5316 | UINT32 CF:1; ///< Carry Flag.\r |
5317 | UINT32 Reserved_0:1; ///< Reserved.\r | |
5318 | UINT32 PF:1; ///< Parity Flag.\r | |
5319 | UINT32 Reserved_1:1; ///< Reserved.\r | |
5320 | UINT32 AF:1; ///< Auxiliary Carry Flag.\r | |
5321 | UINT32 Reserved_2:1; ///< Reserved.\r | |
5322 | UINT32 ZF:1; ///< Zero Flag.\r | |
5323 | UINT32 SF:1; ///< Sign Flag.\r | |
5324 | UINT32 TF:1; ///< Trap Flag.\r | |
5325 | UINT32 IF:1; ///< Interrupt Enable Flag.\r | |
5326 | UINT32 DF:1; ///< Direction Flag.\r | |
5327 | UINT32 OF:1; ///< Overflow Flag.\r | |
5328 | UINT32 IOPL:2; ///< I/O Privilege Level.\r | |
5329 | UINT32 NT:1; ///< Nested Task.\r | |
5330 | UINT32 Reserved_3:1; ///< Reserved.\r | |
5331 | UINT32 RF:1; ///< Resume Flag.\r | |
5332 | UINT32 VM:1; ///< Virtual 8086 Mode.\r | |
5333 | UINT32 AC:1; ///< Alignment Check.\r | |
5334 | UINT32 VIF:1; ///< Virtual Interrupt Flag.\r | |
5335 | UINT32 VIP:1; ///< Virtual Interrupt Pending.\r | |
5336 | UINT32 ID:1; ///< ID Flag.\r | |
5337 | UINT32 Reserved_4:10; ///< Reserved.\r | |
ac644614 | 5338 | } Bits;\r |
5339 | UINTN UintN;\r | |
5340 | } IA32_EFLAGS32;\r | |
5341 | \r | |
1106ffe1 | 5342 | ///\r |
af2dc6a7 | 5343 | /// Byte packed structure for Control Register 0 (CR0).\r |
5344 | /// 32-bits on IA-32.\r | |
5345 | /// 64-bits on x64. The upper 32-bits on x64 are reserved.\r | |
1106ffe1 | 5346 | ///\r |
ac644614 | 5347 | typedef union {\r |
5348 | struct {\r | |
af2dc6a7 | 5349 | UINT32 PE:1; ///< Protection Enable.\r |
5350 | UINT32 MP:1; ///< Monitor Coprocessor.\r | |
5351 | UINT32 EM:1; ///< Emulation.\r | |
5352 | UINT32 TS:1; ///< Task Switched.\r | |
5353 | UINT32 ET:1; ///< Extension Type.\r | |
5354 | UINT32 NE:1; ///< Numeric Error.\r | |
5355 | UINT32 Reserved_0:10; ///< Reserved.\r | |
5356 | UINT32 WP:1; ///< Write Protect.\r | |
5357 | UINT32 Reserved_1:1; ///< Reserved.\r | |
5358 | UINT32 AM:1; ///< Alignment Mask.\r | |
5359 | UINT32 Reserved_2:10; ///< Reserved.\r | |
5360 | UINT32 NW:1; ///< Mot Write-through.\r | |
5361 | UINT32 CD:1; ///< Cache Disable.\r | |
5362 | UINT32 PG:1; ///< Paging.\r | |
ac644614 | 5363 | } Bits;\r |
5364 | UINTN UintN;\r | |
5365 | } IA32_CR0;\r | |
5366 | \r | |
1106ffe1 | 5367 | ///\r |
af2dc6a7 | 5368 | /// Byte packed structure for Control Register 4 (CR4).\r |
5369 | /// 32-bits on IA-32.\r | |
5370 | /// 64-bits on x64. The upper 32-bits on x64 are reserved.\r | |
1106ffe1 | 5371 | ///\r |
ac644614 | 5372 | typedef union {\r |
5373 | struct {\r | |
af2dc6a7 | 5374 | UINT32 VME:1; ///< Virtual-8086 Mode Extensions.\r |
5375 | UINT32 PVI:1; ///< Protected-Mode Virtual Interrupts.\r | |
5376 | UINT32 TSD:1; ///< Time Stamp Disable.\r | |
5377 | UINT32 DE:1; ///< Debugging Extensions.\r | |
5378 | UINT32 PSE:1; ///< Page Size Extensions.\r | |
5379 | UINT32 PAE:1; ///< Physical Address Extension.\r | |
5380 | UINT32 MCE:1; ///< Machine Check Enable.\r | |
5381 | UINT32 PGE:1; ///< Page Global Enable.\r | |
2a53dabf | 5382 | UINT32 PCE:1; ///< Performance Monitoring Counter\r |
af2dc6a7 | 5383 | ///< Enable.\r |
2a53dabf LG |
5384 | UINT32 OSFXSR:1; ///< Operating System Support for\r |
5385 | ///< FXSAVE and FXRSTOR instructions\r | |
5386 | UINT32 OSXMMEXCPT:1; ///< Operating System Support for\r | |
5387 | ///< Unmasked SIMD Floating Point\r | |
af2dc6a7 | 5388 | ///< Exceptions.\r |
5389 | UINT32 Reserved_0:2; ///< Reserved.\r | |
2a53dabf | 5390 | UINT32 VMXE:1; ///< VMX Enable\r |
af2dc6a7 | 5391 | UINT32 Reserved_1:18; ///< Reserved.\r |
ac644614 | 5392 | } Bits;\r |
5393 | UINTN UintN;\r | |
5394 | } IA32_CR4;\r | |
5395 | \r | |
6088db38 | 5396 | ///\r |
5397 | /// Byte packed structure for a segment descriptor in a GDT/LDT.\r | |
5398 | ///\r | |
5399 | typedef union {\r | |
5400 | struct {\r | |
5401 | UINT32 LimitLow:16;\r | |
5402 | UINT32 BaseLow:16;\r | |
5403 | UINT32 BaseMid:8;\r | |
5404 | UINT32 Type:4;\r | |
5405 | UINT32 S:1;\r | |
5406 | UINT32 DPL:2;\r | |
5407 | UINT32 P:1;\r | |
5408 | UINT32 LimitHigh:4;\r | |
5409 | UINT32 AVL:1;\r | |
5410 | UINT32 L:1;\r | |
5411 | UINT32 DB:1;\r | |
5412 | UINT32 G:1;\r | |
5413 | UINT32 BaseHigh:8;\r | |
5414 | } Bits;\r | |
5415 | UINT64 Uint64;\r | |
5416 | } IA32_SEGMENT_DESCRIPTOR;\r | |
5417 | \r | |
1106ffe1 | 5418 | ///\r |
af2dc6a7 | 5419 | /// Byte packed structure for an IDTR, GDTR, LDTR descriptor.\r |
1106ffe1 | 5420 | ///\r |
ac644614 | 5421 | #pragma pack (1)\r |
5422 | typedef struct {\r | |
5423 | UINT16 Limit;\r | |
5424 | UINTN Base;\r | |
5425 | } IA32_DESCRIPTOR;\r | |
5426 | #pragma pack ()\r | |
5427 | \r | |
5428 | #define IA32_IDT_GATE_TYPE_TASK 0x85\r | |
5429 | #define IA32_IDT_GATE_TYPE_INTERRUPT_16 0x86\r | |
5430 | #define IA32_IDT_GATE_TYPE_TRAP_16 0x87\r | |
5431 | #define IA32_IDT_GATE_TYPE_INTERRUPT_32 0x8E\r | |
5432 | #define IA32_IDT_GATE_TYPE_TRAP_32 0x8F\r | |
5433 | \r | |
6f4aad3b | 5434 | \r |
5435 | #if defined (MDE_CPU_IA32)\r | |
1106ffe1 | 5436 | ///\r |
af2dc6a7 | 5437 | /// Byte packed structure for an IA-32 Interrupt Gate Descriptor.\r |
1106ffe1 | 5438 | ///\r |
dc317713 | 5439 | typedef union {\r |
5440 | struct {\r | |
af2dc6a7 | 5441 | UINT32 OffsetLow:16; ///< Offset bits 15..0.\r |
5442 | UINT32 Selector:16; ///< Selector.\r | |
5443 | UINT32 Reserved_0:8; ///< Reserved.\r | |
5444 | UINT32 GateType:8; ///< Gate Type. See #defines above.\r | |
5445 | UINT32 OffsetHigh:16; ///< Offset bits 31..16.\r | |
dc317713 | 5446 | } Bits;\r |
5447 | UINT64 Uint64;\r | |
5448 | } IA32_IDT_GATE_DESCRIPTOR;\r | |
5449 | \r | |
5450 | #endif\r | |
5451 | \r | |
5452 | #if defined (MDE_CPU_X64)\r | |
6f4aad3b | 5453 | ///\r |
af2dc6a7 | 5454 | /// Byte packed structure for an x64 Interrupt Gate Descriptor.\r |
6f4aad3b | 5455 | ///\r |
ac644614 | 5456 | typedef union {\r |
5457 | struct {\r | |
af2dc6a7 | 5458 | UINT32 OffsetLow:16; ///< Offset bits 15..0.\r |
5459 | UINT32 Selector:16; ///< Selector.\r | |
5460 | UINT32 Reserved_0:8; ///< Reserved.\r | |
5461 | UINT32 GateType:8; ///< Gate Type. See #defines above.\r | |
5462 | UINT32 OffsetHigh:16; ///< Offset bits 31..16.\r | |
5463 | UINT32 OffsetUpper:32; ///< Offset bits 63..32.\r | |
5464 | UINT32 Reserved_1:32; ///< Reserved.\r | |
ac644614 | 5465 | } Bits;\r |
6f4aad3b | 5466 | struct {\r |
5467 | UINT64 Uint64;\r | |
5468 | UINT64 Uint64_1;\r | |
5469 | } Uint128; \r | |
ac644614 | 5470 | } IA32_IDT_GATE_DESCRIPTOR;\r |
5471 | \r | |
dc317713 | 5472 | #endif\r |
5473 | \r | |
1106ffe1 | 5474 | ///\r |
af2dc6a7 | 5475 | /// Byte packed structure for an FP/SSE/SSE2 context.\r |
1106ffe1 | 5476 | ///\r |
ac644614 | 5477 | typedef struct {\r |
5478 | UINT8 Buffer[512];\r | |
5479 | } IA32_FX_BUFFER;\r | |
5480 | \r | |
1106ffe1 | 5481 | ///\r |
af2dc6a7 | 5482 | /// Structures for the 16-bit real mode thunks.\r |
1106ffe1 | 5483 | ///\r |
ac644614 | 5484 | typedef struct {\r |
5485 | UINT32 Reserved1;\r | |
5486 | UINT32 Reserved2;\r | |
5487 | UINT32 Reserved3;\r | |
5488 | UINT32 Reserved4;\r | |
5489 | UINT8 BL;\r | |
5490 | UINT8 BH;\r | |
5491 | UINT16 Reserved5;\r | |
5492 | UINT8 DL;\r | |
5493 | UINT8 DH;\r | |
5494 | UINT16 Reserved6;\r | |
5495 | UINT8 CL;\r | |
5496 | UINT8 CH;\r | |
5497 | UINT16 Reserved7;\r | |
5498 | UINT8 AL;\r | |
5499 | UINT8 AH;\r | |
5500 | UINT16 Reserved8;\r | |
5501 | } IA32_BYTE_REGS;\r | |
5502 | \r | |
5503 | typedef struct {\r | |
5504 | UINT16 DI;\r | |
5505 | UINT16 Reserved1;\r | |
5506 | UINT16 SI;\r | |
5507 | UINT16 Reserved2;\r | |
5508 | UINT16 BP;\r | |
5509 | UINT16 Reserved3;\r | |
5510 | UINT16 SP;\r | |
5511 | UINT16 Reserved4;\r | |
5512 | UINT16 BX;\r | |
5513 | UINT16 Reserved5;\r | |
5514 | UINT16 DX;\r | |
5515 | UINT16 Reserved6;\r | |
5516 | UINT16 CX;\r | |
5517 | UINT16 Reserved7;\r | |
5518 | UINT16 AX;\r | |
5519 | UINT16 Reserved8;\r | |
5520 | } IA32_WORD_REGS;\r | |
5521 | \r | |
5522 | typedef struct {\r | |
5523 | UINT32 EDI;\r | |
5524 | UINT32 ESI;\r | |
5525 | UINT32 EBP;\r | |
5526 | UINT32 ESP;\r | |
5527 | UINT32 EBX;\r | |
5528 | UINT32 EDX;\r | |
5529 | UINT32 ECX;\r | |
5530 | UINT32 EAX;\r | |
5531 | UINT16 DS;\r | |
5532 | UINT16 ES;\r | |
5533 | UINT16 FS;\r | |
5534 | UINT16 GS;\r | |
5535 | IA32_EFLAGS32 EFLAGS;\r | |
5536 | UINT32 Eip;\r | |
5537 | UINT16 CS;\r | |
5538 | UINT16 SS;\r | |
5539 | } IA32_DWORD_REGS;\r | |
5540 | \r | |
5541 | typedef union {\r | |
5542 | IA32_DWORD_REGS E;\r | |
5543 | IA32_WORD_REGS X;\r | |
5544 | IA32_BYTE_REGS H;\r | |
5545 | } IA32_REGISTER_SET;\r | |
5546 | \r | |
1106ffe1 | 5547 | ///\r |
af2dc6a7 | 5548 | /// Byte packed structure for an 16-bit real mode thunks.\r |
1106ffe1 | 5549 | ///\r |
ac644614 | 5550 | typedef struct {\r |
5551 | IA32_REGISTER_SET *RealModeState;\r | |
5552 | VOID *RealModeBuffer;\r | |
5553 | UINT32 RealModeBufferSize;\r | |
5554 | UINT32 ThunkAttributes;\r | |
5555 | } THUNK_CONTEXT;\r | |
5556 | \r | |
5557 | #define THUNK_ATTRIBUTE_BIG_REAL_MODE 0x00000001\r | |
5558 | #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 0x00000002\r | |
5559 | #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004\r | |
5560 | \r | |
5561 | /**\r | |
5562 | Retrieves CPUID information.\r | |
5563 | \r | |
5564 | Executes the CPUID instruction with EAX set to the value specified by Index.\r | |
5565 | This function always returns Index.\r | |
5566 | If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.\r | |
5567 | If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.\r | |
5568 | If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.\r | |
5569 | If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.\r | |
030cd1a2 | 5570 | This function is only available on IA-32 and x64.\r |
ac644614 | 5571 | \r |
5572 | @param Index The 32-bit value to load into EAX prior to invoking the CPUID\r | |
5573 | instruction.\r | |
af2dc6a7 | 5574 | @param Eax The pointer to the 32-bit EAX value returned by the CPUID\r |
ac644614 | 5575 | instruction. This is an optional parameter that may be NULL.\r |
af2dc6a7 | 5576 | @param Ebx The pointer to the 32-bit EBX value returned by the CPUID\r |
ac644614 | 5577 | instruction. This is an optional parameter that may be NULL.\r |
af2dc6a7 | 5578 | @param Ecx The pointer to the 32-bit ECX value returned by the CPUID\r |
ac644614 | 5579 | instruction. This is an optional parameter that may be NULL.\r |
af2dc6a7 | 5580 | @param Edx The pointer to the 32-bit EDX value returned by the CPUID\r |
ac644614 | 5581 | instruction. This is an optional parameter that may be NULL.\r |
5582 | \r | |
2fe241a2 | 5583 | @return Index.\r |
ac644614 | 5584 | \r |
5585 | **/\r | |
5586 | UINT32\r | |
5587 | EFIAPI\r | |
5588 | AsmCpuid (\r | |
5589 | IN UINT32 Index,\r | |
5590 | OUT UINT32 *Eax, OPTIONAL\r | |
5591 | OUT UINT32 *Ebx, OPTIONAL\r | |
5592 | OUT UINT32 *Ecx, OPTIONAL\r | |
5593 | OUT UINT32 *Edx OPTIONAL\r | |
5594 | );\r | |
5595 | \r | |
5596 | \r | |
5597 | /**\r | |
5598 | Retrieves CPUID information using an extended leaf identifier.\r | |
5599 | \r | |
5600 | Executes the CPUID instruction with EAX set to the value specified by Index\r | |
5601 | and ECX set to the value specified by SubIndex. This function always returns\r | |
5602 | Index. This function is only available on IA-32 and x64.\r | |
5603 | \r | |
5604 | If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.\r | |
5605 | If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.\r | |
5606 | If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.\r | |
5607 | If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.\r | |
5608 | \r | |
5609 | @param Index The 32-bit value to load into EAX prior to invoking the\r | |
5610 | CPUID instruction.\r | |
5611 | @param SubIndex The 32-bit value to load into ECX prior to invoking the\r | |
5612 | CPUID instruction.\r | |
af2dc6a7 | 5613 | @param Eax The pointer to the 32-bit EAX value returned by the CPUID\r |
ac644614 | 5614 | instruction. This is an optional parameter that may be\r |
5615 | NULL.\r | |
af2dc6a7 | 5616 | @param Ebx The pointer to the 32-bit EBX value returned by the CPUID\r |
ac644614 | 5617 | instruction. This is an optional parameter that may be\r |
5618 | NULL.\r | |
af2dc6a7 | 5619 | @param Ecx The pointer to the 32-bit ECX value returned by the CPUID\r |
ac644614 | 5620 | instruction. This is an optional parameter that may be\r |
5621 | NULL.\r | |
af2dc6a7 | 5622 | @param Edx The pointer to the 32-bit EDX value returned by the CPUID\r |
ac644614 | 5623 | instruction. This is an optional parameter that may be\r |
5624 | NULL.\r | |
5625 | \r | |
2fe241a2 | 5626 | @return Index.\r |
ac644614 | 5627 | \r |
5628 | **/\r | |
5629 | UINT32\r | |
5630 | EFIAPI\r | |
5631 | AsmCpuidEx (\r | |
5632 | IN UINT32 Index,\r | |
5633 | IN UINT32 SubIndex,\r | |
5634 | OUT UINT32 *Eax, OPTIONAL\r | |
5635 | OUT UINT32 *Ebx, OPTIONAL\r | |
5636 | OUT UINT32 *Ecx, OPTIONAL\r | |
5637 | OUT UINT32 *Edx OPTIONAL\r | |
5638 | );\r | |
5639 | \r | |
5640 | \r | |
be5f1614 | 5641 | /**\r |
5642 | Set CD bit and clear NW bit of CR0 followed by a WBINVD.\r | |
5643 | \r | |
5644 | Disables the caches by setting the CD bit of CR0 to 1, clearing the NW bit of CR0 to 0,\r | |
5645 | and executing a WBINVD instruction. This function is only available on IA-32 and x64.\r | |
5646 | \r | |
5647 | **/\r | |
5648 | VOID\r | |
5649 | EFIAPI\r | |
5650 | AsmDisableCache (\r | |
5651 | VOID\r | |
5652 | );\r | |
5653 | \r | |
5654 | \r | |
5655 | /**\r | |
5656 | Perform a WBINVD and clear both the CD and NW bits of CR0.\r | |
5657 | \r | |
5658 | Enables the caches by executing a WBINVD instruction and then clear both the CD and NW\r | |
5659 | bits of CR0 to 0. This function is only available on IA-32 and x64.\r | |
5660 | \r | |
5661 | **/\r | |
5662 | VOID\r | |
5663 | EFIAPI\r | |
5664 | AsmEnableCache (\r | |
5665 | VOID\r | |
5666 | );\r | |
5667 | \r | |
5668 | \r | |
ac644614 | 5669 | /**\r |
5670 | Returns the lower 32-bits of a Machine Specific Register(MSR).\r | |
5671 | \r | |
5672 | Reads and returns the lower 32-bits of the MSR specified by Index.\r | |
5673 | No parameter checking is performed on Index, and some Index values may cause\r | |
5674 | CPU exceptions. The caller must either guarantee that Index is valid, or the\r | |
5675 | caller must set up exception handlers to catch the exceptions. This function\r | |
030cd1a2 | 5676 | is only available on IA-32 and x64.\r |
ac644614 | 5677 | \r |
5678 | @param Index The 32-bit MSR index to read.\r | |
5679 | \r | |
5680 | @return The lower 32 bits of the MSR identified by Index.\r | |
5681 | \r | |
5682 | **/\r | |
5683 | UINT32\r | |
5684 | EFIAPI\r | |
5685 | AsmReadMsr32 (\r | |
5686 | IN UINT32 Index\r | |
5687 | );\r | |
5688 | \r | |
5689 | \r | |
5690 | /**\r | |
17f695ed | 5691 | Writes a 32-bit value to a Machine Specific Register(MSR), and returns the value.\r |
5692 | The upper 32-bits of the MSR are set to zero.\r | |
ac644614 | 5693 | \r |
5694 | Writes the 32-bit value specified by Value to the MSR specified by Index. The\r | |
5695 | upper 32-bits of the MSR write are set to zero. The 32-bit value written to\r | |
5696 | the MSR is returned. No parameter checking is performed on Index or Value,\r | |
5697 | and some of these may cause CPU exceptions. The caller must either guarantee\r | |
5698 | that Index and Value are valid, or the caller must establish proper exception\r | |
030cd1a2 | 5699 | handlers. This function is only available on IA-32 and x64.\r |
ac644614 | 5700 | \r |
5701 | @param Index The 32-bit MSR index to write.\r | |
5702 | @param Value The 32-bit value to write to the MSR.\r | |
5703 | \r | |
5704 | @return Value\r | |
5705 | \r | |
5706 | **/\r | |
5707 | UINT32\r | |
5708 | EFIAPI\r | |
5709 | AsmWriteMsr32 (\r | |
5710 | IN UINT32 Index,\r | |
5711 | IN UINT32 Value\r | |
5712 | );\r | |
5713 | \r | |
5714 | \r | |
5715 | /**\r | |
62991af2 | 5716 | Reads a 64-bit MSR, performs a bitwise OR on the lower 32-bits, and\r |
ac644614 | 5717 | writes the result back to the 64-bit MSR.\r |
5718 | \r | |
62991af2 | 5719 | Reads the 64-bit MSR specified by Index, performs a bitwise OR\r |
ac644614 | 5720 | between the lower 32-bits of the read result and the value specified by\r |
5721 | OrData, and writes the result to the 64-bit MSR specified by Index. The lower\r | |
5722 | 32-bits of the value written to the MSR is returned. No parameter checking is\r | |
5723 | performed on Index or OrData, and some of these may cause CPU exceptions. The\r | |
5724 | caller must either guarantee that Index and OrData are valid, or the caller\r | |
5725 | must establish proper exception handlers. This function is only available on\r | |
030cd1a2 | 5726 | IA-32 and x64.\r |
ac644614 | 5727 | \r |
5728 | @param Index The 32-bit MSR index to write.\r | |
5729 | @param OrData The value to OR with the read value from the MSR.\r | |
5730 | \r | |
5731 | @return The lower 32-bit value written to the MSR.\r | |
5732 | \r | |
5733 | **/\r | |
5734 | UINT32\r | |
5735 | EFIAPI\r | |
5736 | AsmMsrOr32 (\r | |
5737 | IN UINT32 Index,\r | |
5738 | IN UINT32 OrData\r | |
5739 | );\r | |
5740 | \r | |
5741 | \r | |
5742 | /**\r | |
5743 | Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes\r | |
5744 | the result back to the 64-bit MSR.\r | |
5745 | \r | |
5746 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r | |
5747 | lower 32-bits of the read result and the value specified by AndData, and\r | |
5748 | writes the result to the 64-bit MSR specified by Index. The lower 32-bits of\r | |
5749 | the value written to the MSR is returned. No parameter checking is performed\r | |
5750 | on Index or AndData, and some of these may cause CPU exceptions. The caller\r | |
5751 | must either guarantee that Index and AndData are valid, or the caller must\r | |
5752 | establish proper exception handlers. This function is only available on IA-32\r | |
030cd1a2 | 5753 | and x64.\r |
ac644614 | 5754 | \r |
5755 | @param Index The 32-bit MSR index to write.\r | |
5756 | @param AndData The value to AND with the read value from the MSR.\r | |
5757 | \r | |
5758 | @return The lower 32-bit value written to the MSR.\r | |
5759 | \r | |
5760 | **/\r | |
5761 | UINT32\r | |
5762 | EFIAPI\r | |
5763 | AsmMsrAnd32 (\r | |
5764 | IN UINT32 Index,\r | |
5765 | IN UINT32 AndData\r | |
5766 | );\r | |
5767 | \r | |
5768 | \r | |
5769 | /**\r | |
62991af2 | 5770 | Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise OR\r |
ac644614 | 5771 | on the lower 32-bits, and writes the result back to the 64-bit MSR.\r |
5772 | \r | |
5773 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r | |
5774 | lower 32-bits of the read result and the value specified by AndData\r | |
62991af2 | 5775 | preserving the upper 32-bits, performs a bitwise OR between the\r |
ac644614 | 5776 | result of the AND operation and the value specified by OrData, and writes the\r |
5777 | result to the 64-bit MSR specified by Address. The lower 32-bits of the value\r | |
5778 | written to the MSR is returned. No parameter checking is performed on Index,\r | |
5779 | AndData, or OrData, and some of these may cause CPU exceptions. The caller\r | |
5780 | must either guarantee that Index, AndData, and OrData are valid, or the\r | |
5781 | caller must establish proper exception handlers. This function is only\r | |
030cd1a2 | 5782 | available on IA-32 and x64.\r |
ac644614 | 5783 | \r |
5784 | @param Index The 32-bit MSR index to write.\r | |
5785 | @param AndData The value to AND with the read value from the MSR.\r | |
5786 | @param OrData The value to OR with the result of the AND operation.\r | |
5787 | \r | |
5788 | @return The lower 32-bit value written to the MSR.\r | |
5789 | \r | |
5790 | **/\r | |
5791 | UINT32\r | |
5792 | EFIAPI\r | |
5793 | AsmMsrAndThenOr32 (\r | |
5794 | IN UINT32 Index,\r | |
5795 | IN UINT32 AndData,\r | |
5796 | IN UINT32 OrData\r | |
5797 | );\r | |
5798 | \r | |
5799 | \r | |
5800 | /**\r | |
5801 | Reads a bit field of an MSR.\r | |
5802 | \r | |
5803 | Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is\r | |
5804 | specified by the StartBit and the EndBit. The value of the bit field is\r | |
5805 | returned. The caller must either guarantee that Index is valid, or the caller\r | |
5806 | must set up exception handlers to catch the exceptions. This function is only\r | |
030cd1a2 | 5807 | available on IA-32 and x64.\r |
ac644614 | 5808 | \r |
5809 | If StartBit is greater than 31, then ASSERT().\r | |
5810 | If EndBit is greater than 31, then ASSERT().\r | |
5811 | If EndBit is less than StartBit, then ASSERT().\r | |
5812 | \r | |
5813 | @param Index The 32-bit MSR index to read.\r | |
5814 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
5815 | Range 0..31.\r | |
5816 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
5817 | Range 0..31.\r | |
5818 | \r | |
5819 | @return The bit field read from the MSR.\r | |
5820 | \r | |
5821 | **/\r | |
5822 | UINT32\r | |
5823 | EFIAPI\r | |
5824 | AsmMsrBitFieldRead32 (\r | |
5825 | IN UINT32 Index,\r | |
5826 | IN UINTN StartBit,\r | |
5827 | IN UINTN EndBit\r | |
5828 | );\r | |
5829 | \r | |
5830 | \r | |
5831 | /**\r | |
5832 | Writes a bit field to an MSR.\r | |
5833 | \r | |
2fe241a2 | 5834 | Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit\r |
ac644614 | 5835 | field is specified by the StartBit and the EndBit. All other bits in the\r |
5836 | destination MSR are preserved. The lower 32-bits of the MSR written is\r | |
62991af2 | 5837 | returned. The caller must either guarantee that Index and the data written \r |
5838 | is valid, or the caller must set up exception handlers to catch the exceptions. \r | |
5839 | This function is only available on IA-32 and x64.\r | |
ac644614 | 5840 | \r |
5841 | If StartBit is greater than 31, then ASSERT().\r | |
5842 | If EndBit is greater than 31, then ASSERT().\r | |
5843 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 5844 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 5845 | \r |
5846 | @param Index The 32-bit MSR index to write.\r | |
5847 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
5848 | Range 0..31.\r | |
5849 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
5850 | Range 0..31.\r | |
5851 | @param Value New value of the bit field.\r | |
5852 | \r | |
5853 | @return The lower 32-bit of the value written to the MSR.\r | |
5854 | \r | |
5855 | **/\r | |
5856 | UINT32\r | |
5857 | EFIAPI\r | |
5858 | AsmMsrBitFieldWrite32 (\r | |
5859 | IN UINT32 Index,\r | |
5860 | IN UINTN StartBit,\r | |
5861 | IN UINTN EndBit,\r | |
5862 | IN UINT32 Value\r | |
5863 | );\r | |
5864 | \r | |
5865 | \r | |
5866 | /**\r | |
5867 | Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the\r | |
5868 | result back to the bit field in the 64-bit MSR.\r | |
5869 | \r | |
62991af2 | 5870 | Reads the 64-bit MSR specified by Index, performs a bitwise OR\r |
ac644614 | 5871 | between the read result and the value specified by OrData, and writes the\r |
5872 | result to the 64-bit MSR specified by Index. The lower 32-bits of the value\r | |
5873 | written to the MSR are returned. Extra left bits in OrData are stripped. The\r | |
5874 | caller must either guarantee that Index and the data written is valid, or\r | |
5875 | the caller must set up exception handlers to catch the exceptions. This\r | |
030cd1a2 | 5876 | function is only available on IA-32 and x64.\r |
ac644614 | 5877 | \r |
5878 | If StartBit is greater than 31, then ASSERT().\r | |
5879 | If EndBit is greater than 31, then ASSERT().\r | |
5880 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 5881 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 5882 | \r |
5883 | @param Index The 32-bit MSR index to write.\r | |
5884 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
5885 | Range 0..31.\r | |
5886 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
5887 | Range 0..31.\r | |
5888 | @param OrData The value to OR with the read value from the MSR.\r | |
5889 | \r | |
5890 | @return The lower 32-bit of the value written to the MSR.\r | |
5891 | \r | |
5892 | **/\r | |
5893 | UINT32\r | |
5894 | EFIAPI\r | |
5895 | AsmMsrBitFieldOr32 (\r | |
5896 | IN UINT32 Index,\r | |
5897 | IN UINTN StartBit,\r | |
5898 | IN UINTN EndBit,\r | |
5899 | IN UINT32 OrData\r | |
5900 | );\r | |
5901 | \r | |
5902 | \r | |
5903 | /**\r | |
5904 | Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the\r | |
5905 | result back to the bit field in the 64-bit MSR.\r | |
5906 | \r | |
5907 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r | |
5908 | read result and the value specified by AndData, and writes the result to the\r | |
5909 | 64-bit MSR specified by Index. The lower 32-bits of the value written to the\r | |
5910 | MSR are returned. Extra left bits in AndData are stripped. The caller must\r | |
5911 | either guarantee that Index and the data written is valid, or the caller must\r | |
5912 | set up exception handlers to catch the exceptions. This function is only\r | |
030cd1a2 | 5913 | available on IA-32 and x64.\r |
ac644614 | 5914 | \r |
5915 | If StartBit is greater than 31, then ASSERT().\r | |
5916 | If EndBit is greater than 31, then ASSERT().\r | |
5917 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 5918 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 5919 | \r |
5920 | @param Index The 32-bit MSR index to write.\r | |
5921 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
5922 | Range 0..31.\r | |
5923 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
5924 | Range 0..31.\r | |
5925 | @param AndData The value to AND with the read value from the MSR.\r | |
5926 | \r | |
5927 | @return The lower 32-bit of the value written to the MSR.\r | |
5928 | \r | |
5929 | **/\r | |
5930 | UINT32\r | |
5931 | EFIAPI\r | |
5932 | AsmMsrBitFieldAnd32 (\r | |
5933 | IN UINT32 Index,\r | |
5934 | IN UINTN StartBit,\r | |
5935 | IN UINTN EndBit,\r | |
5936 | IN UINT32 AndData\r | |
5937 | );\r | |
5938 | \r | |
5939 | \r | |
5940 | /**\r | |
5941 | Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a\r | |
62991af2 | 5942 | bitwise OR, and writes the result back to the bit field in the\r |
ac644614 | 5943 | 64-bit MSR.\r |
5944 | \r | |
5945 | Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a\r | |
62991af2 | 5946 | bitwise OR between the read result and the value specified by\r |
ac644614 | 5947 | AndData, and writes the result to the 64-bit MSR specified by Index. The\r |
5948 | lower 32-bits of the value written to the MSR are returned. Extra left bits\r | |
5949 | in both AndData and OrData are stripped. The caller must either guarantee\r | |
5950 | that Index and the data written is valid, or the caller must set up exception\r | |
5951 | handlers to catch the exceptions. This function is only available on IA-32\r | |
030cd1a2 | 5952 | and x64.\r |
ac644614 | 5953 | \r |
5954 | If StartBit is greater than 31, then ASSERT().\r | |
5955 | If EndBit is greater than 31, then ASSERT().\r | |
5956 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 LG |
5957 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
5958 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
ac644614 | 5959 | \r |
5960 | @param Index The 32-bit MSR index to write.\r | |
5961 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
5962 | Range 0..31.\r | |
5963 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
5964 | Range 0..31.\r | |
5965 | @param AndData The value to AND with the read value from the MSR.\r | |
5966 | @param OrData The value to OR with the result of the AND operation.\r | |
5967 | \r | |
5968 | @return The lower 32-bit of the value written to the MSR.\r | |
5969 | \r | |
5970 | **/\r | |
5971 | UINT32\r | |
5972 | EFIAPI\r | |
5973 | AsmMsrBitFieldAndThenOr32 (\r | |
5974 | IN UINT32 Index,\r | |
5975 | IN UINTN StartBit,\r | |
5976 | IN UINTN EndBit,\r | |
5977 | IN UINT32 AndData,\r | |
5978 | IN UINT32 OrData\r | |
5979 | );\r | |
5980 | \r | |
5981 | \r | |
5982 | /**\r | |
5983 | Returns a 64-bit Machine Specific Register(MSR).\r | |
5984 | \r | |
5985 | Reads and returns the 64-bit MSR specified by Index. No parameter checking is\r | |
5986 | performed on Index, and some Index values may cause CPU exceptions. The\r | |
5987 | caller must either guarantee that Index is valid, or the caller must set up\r | |
5988 | exception handlers to catch the exceptions. This function is only available\r | |
030cd1a2 | 5989 | on IA-32 and x64.\r |
ac644614 | 5990 | \r |
5991 | @param Index The 32-bit MSR index to read.\r | |
5992 | \r | |
5993 | @return The value of the MSR identified by Index.\r | |
5994 | \r | |
5995 | **/\r | |
5996 | UINT64\r | |
5997 | EFIAPI\r | |
5998 | AsmReadMsr64 (\r | |
5999 | IN UINT32 Index\r | |
6000 | );\r | |
6001 | \r | |
6002 | \r | |
6003 | /**\r | |
6004 | Writes a 64-bit value to a Machine Specific Register(MSR), and returns the\r | |
6005 | value.\r | |
6006 | \r | |
6007 | Writes the 64-bit value specified by Value to the MSR specified by Index. The\r | |
6008 | 64-bit value written to the MSR is returned. No parameter checking is\r | |
6009 | performed on Index or Value, and some of these may cause CPU exceptions. The\r | |
6010 | caller must either guarantee that Index and Value are valid, or the caller\r | |
6011 | must establish proper exception handlers. This function is only available on\r | |
030cd1a2 | 6012 | IA-32 and x64.\r |
ac644614 | 6013 | \r |
6014 | @param Index The 32-bit MSR index to write.\r | |
6015 | @param Value The 64-bit value to write to the MSR.\r | |
6016 | \r | |
6017 | @return Value\r | |
6018 | \r | |
6019 | **/\r | |
6020 | UINT64\r | |
6021 | EFIAPI\r | |
6022 | AsmWriteMsr64 (\r | |
6023 | IN UINT32 Index,\r | |
6024 | IN UINT64 Value\r | |
6025 | );\r | |
6026 | \r | |
6027 | \r | |
6028 | /**\r | |
62991af2 | 6029 | Reads a 64-bit MSR, performs a bitwise OR, and writes the result\r |
ac644614 | 6030 | back to the 64-bit MSR.\r |
6031 | \r | |
62991af2 | 6032 | Reads the 64-bit MSR specified by Index, performs a bitwise OR\r |
ac644614 | 6033 | between the read result and the value specified by OrData, and writes the\r |
6034 | result to the 64-bit MSR specified by Index. The value written to the MSR is\r | |
6035 | returned. No parameter checking is performed on Index or OrData, and some of\r | |
6036 | these may cause CPU exceptions. The caller must either guarantee that Index\r | |
6037 | and OrData are valid, or the caller must establish proper exception handlers.\r | |
030cd1a2 | 6038 | This function is only available on IA-32 and x64.\r |
ac644614 | 6039 | \r |
6040 | @param Index The 32-bit MSR index to write.\r | |
6041 | @param OrData The value to OR with the read value from the MSR.\r | |
6042 | \r | |
6043 | @return The value written back to the MSR.\r | |
6044 | \r | |
6045 | **/\r | |
6046 | UINT64\r | |
6047 | EFIAPI\r | |
6048 | AsmMsrOr64 (\r | |
6049 | IN UINT32 Index,\r | |
6050 | IN UINT64 OrData\r | |
6051 | );\r | |
6052 | \r | |
6053 | \r | |
6054 | /**\r | |
6055 | Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the\r | |
6056 | 64-bit MSR.\r | |
6057 | \r | |
6058 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r | |
6059 | read result and the value specified by OrData, and writes the result to the\r | |
6060 | 64-bit MSR specified by Index. The value written to the MSR is returned. No\r | |
6061 | parameter checking is performed on Index or OrData, and some of these may\r | |
6062 | cause CPU exceptions. The caller must either guarantee that Index and OrData\r | |
6063 | are valid, or the caller must establish proper exception handlers. This\r | |
030cd1a2 | 6064 | function is only available on IA-32 and x64.\r |
ac644614 | 6065 | \r |
6066 | @param Index The 32-bit MSR index to write.\r | |
6067 | @param AndData The value to AND with the read value from the MSR.\r | |
6068 | \r | |
6069 | @return The value written back to the MSR.\r | |
6070 | \r | |
6071 | **/\r | |
6072 | UINT64\r | |
6073 | EFIAPI\r | |
6074 | AsmMsrAnd64 (\r | |
6075 | IN UINT32 Index,\r | |
6076 | IN UINT64 AndData\r | |
6077 | );\r | |
6078 | \r | |
6079 | \r | |
6080 | /**\r | |
62991af2 | 6081 | Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise \r |
ac644614 | 6082 | OR, and writes the result back to the 64-bit MSR.\r |
6083 | \r | |
6084 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between read\r | |
62991af2 | 6085 | result and the value specified by AndData, performs a bitwise OR\r |
ac644614 | 6086 | between the result of the AND operation and the value specified by OrData,\r |
6087 | and writes the result to the 64-bit MSR specified by Index. The value written\r | |
6088 | to the MSR is returned. No parameter checking is performed on Index, AndData,\r | |
6089 | or OrData, and some of these may cause CPU exceptions. The caller must either\r | |
6090 | guarantee that Index, AndData, and OrData are valid, or the caller must\r | |
6091 | establish proper exception handlers. This function is only available on IA-32\r | |
030cd1a2 | 6092 | and x64.\r |
ac644614 | 6093 | \r |
6094 | @param Index The 32-bit MSR index to write.\r | |
6095 | @param AndData The value to AND with the read value from the MSR.\r | |
6096 | @param OrData The value to OR with the result of the AND operation.\r | |
6097 | \r | |
6098 | @return The value written back to the MSR.\r | |
6099 | \r | |
6100 | **/\r | |
6101 | UINT64\r | |
6102 | EFIAPI\r | |
6103 | AsmMsrAndThenOr64 (\r | |
6104 | IN UINT32 Index,\r | |
6105 | IN UINT64 AndData,\r | |
6106 | IN UINT64 OrData\r | |
6107 | );\r | |
6108 | \r | |
6109 | \r | |
6110 | /**\r | |
6111 | Reads a bit field of an MSR.\r | |
6112 | \r | |
6113 | Reads the bit field in the 64-bit MSR. The bit field is specified by the\r | |
6114 | StartBit and the EndBit. The value of the bit field is returned. The caller\r | |
6115 | must either guarantee that Index is valid, or the caller must set up\r | |
6116 | exception handlers to catch the exceptions. This function is only available\r | |
030cd1a2 | 6117 | on IA-32 and x64.\r |
ac644614 | 6118 | \r |
6119 | If StartBit is greater than 63, then ASSERT().\r | |
6120 | If EndBit is greater than 63, then ASSERT().\r | |
6121 | If EndBit is less than StartBit, then ASSERT().\r | |
6122 | \r | |
6123 | @param Index The 32-bit MSR index to read.\r | |
6124 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
6125 | Range 0..63.\r | |
6126 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
6127 | Range 0..63.\r | |
6128 | \r | |
6129 | @return The value read from the MSR.\r | |
6130 | \r | |
6131 | **/\r | |
6132 | UINT64\r | |
6133 | EFIAPI\r | |
6134 | AsmMsrBitFieldRead64 (\r | |
6135 | IN UINT32 Index,\r | |
6136 | IN UINTN StartBit,\r | |
6137 | IN UINTN EndBit\r | |
6138 | );\r | |
6139 | \r | |
6140 | \r | |
6141 | /**\r | |
6142 | Writes a bit field to an MSR.\r | |
6143 | \r | |
6144 | Writes Value to a bit field in a 64-bit MSR. The bit field is specified by\r | |
6145 | the StartBit and the EndBit. All other bits in the destination MSR are\r | |
62991af2 | 6146 | preserved. The MSR written is returned. The caller must either guarantee \r |
6147 | that Index and the data written is valid, or the caller must set up exception \r | |
6148 | handlers to catch the exceptions. This function is only available on IA-32 and x64.\r | |
ac644614 | 6149 | \r |
6150 | If StartBit is greater than 63, then ASSERT().\r | |
6151 | If EndBit is greater than 63, then ASSERT().\r | |
6152 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 6153 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 6154 | \r |
6155 | @param Index The 32-bit MSR index to write.\r | |
6156 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
6157 | Range 0..63.\r | |
6158 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
6159 | Range 0..63.\r | |
6160 | @param Value New value of the bit field.\r | |
6161 | \r | |
6162 | @return The value written back to the MSR.\r | |
6163 | \r | |
6164 | **/\r | |
6165 | UINT64\r | |
6166 | EFIAPI\r | |
6167 | AsmMsrBitFieldWrite64 (\r | |
6168 | IN UINT32 Index,\r | |
6169 | IN UINTN StartBit,\r | |
6170 | IN UINTN EndBit,\r | |
6171 | IN UINT64 Value\r | |
6172 | );\r | |
6173 | \r | |
6174 | \r | |
6175 | /**\r | |
62991af2 | 6176 | Reads a bit field in a 64-bit MSR, performs a bitwise OR, and\r |
ac644614 | 6177 | writes the result back to the bit field in the 64-bit MSR.\r |
6178 | \r | |
62991af2 | 6179 | Reads the 64-bit MSR specified by Index, performs a bitwise OR\r |
ac644614 | 6180 | between the read result and the value specified by OrData, and writes the\r |
6181 | result to the 64-bit MSR specified by Index. The value written to the MSR is\r | |
6182 | returned. Extra left bits in OrData are stripped. The caller must either\r | |
6183 | guarantee that Index and the data written is valid, or the caller must set up\r | |
6184 | exception handlers to catch the exceptions. This function is only available\r | |
030cd1a2 | 6185 | on IA-32 and x64.\r |
ac644614 | 6186 | \r |
6187 | If StartBit is greater than 63, then ASSERT().\r | |
6188 | If EndBit is greater than 63, then ASSERT().\r | |
6189 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 6190 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 6191 | \r |
6192 | @param Index The 32-bit MSR index to write.\r | |
6193 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
6194 | Range 0..63.\r | |
6195 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
6196 | Range 0..63.\r | |
6197 | @param OrData The value to OR with the read value from the bit field.\r | |
6198 | \r | |
6199 | @return The value written back to the MSR.\r | |
6200 | \r | |
6201 | **/\r | |
6202 | UINT64\r | |
6203 | EFIAPI\r | |
6204 | AsmMsrBitFieldOr64 (\r | |
6205 | IN UINT32 Index,\r | |
6206 | IN UINTN StartBit,\r | |
6207 | IN UINTN EndBit,\r | |
6208 | IN UINT64 OrData\r | |
6209 | );\r | |
6210 | \r | |
6211 | \r | |
6212 | /**\r | |
6213 | Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the\r | |
6214 | result back to the bit field in the 64-bit MSR.\r | |
6215 | \r | |
6216 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r | |
6217 | read result and the value specified by AndData, and writes the result to the\r | |
6218 | 64-bit MSR specified by Index. The value written to the MSR is returned.\r | |
6219 | Extra left bits in AndData are stripped. The caller must either guarantee\r | |
6220 | that Index and the data written is valid, or the caller must set up exception\r | |
6221 | handlers to catch the exceptions. This function is only available on IA-32\r | |
030cd1a2 | 6222 | and x64.\r |
ac644614 | 6223 | \r |
6224 | If StartBit is greater than 63, then ASSERT().\r | |
6225 | If EndBit is greater than 63, then ASSERT().\r | |
6226 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 6227 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 6228 | \r |
6229 | @param Index The 32-bit MSR index to write.\r | |
6230 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
6231 | Range 0..63.\r | |
6232 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
6233 | Range 0..63.\r | |
6234 | @param AndData The value to AND with the read value from the bit field.\r | |
6235 | \r | |
6236 | @return The value written back to the MSR.\r | |
6237 | \r | |
6238 | **/\r | |
6239 | UINT64\r | |
6240 | EFIAPI\r | |
6241 | AsmMsrBitFieldAnd64 (\r | |
6242 | IN UINT32 Index,\r | |
6243 | IN UINTN StartBit,\r | |
6244 | IN UINTN EndBit,\r | |
6245 | IN UINT64 AndData\r | |
6246 | );\r | |
6247 | \r | |
6248 | \r | |
6249 | /**\r | |
6250 | Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a\r | |
62991af2 | 6251 | bitwise OR, and writes the result back to the bit field in the\r |
ac644614 | 6252 | 64-bit MSR.\r |
6253 | \r | |
6254 | Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by\r | |
62991af2 | 6255 | a bitwise OR between the read result and the value specified by\r |
ac644614 | 6256 | AndData, and writes the result to the 64-bit MSR specified by Index. The\r |
6257 | value written to the MSR is returned. Extra left bits in both AndData and\r | |
6258 | OrData are stripped. The caller must either guarantee that Index and the data\r | |
6259 | written is valid, or the caller must set up exception handlers to catch the\r | |
030cd1a2 | 6260 | exceptions. This function is only available on IA-32 and x64.\r |
ac644614 | 6261 | \r |
6262 | If StartBit is greater than 63, then ASSERT().\r | |
6263 | If EndBit is greater than 63, then ASSERT().\r | |
6264 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 LG |
6265 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
6266 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
ac644614 | 6267 | \r |
6268 | @param Index The 32-bit MSR index to write.\r | |
6269 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
6270 | Range 0..63.\r | |
6271 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
6272 | Range 0..63.\r | |
6273 | @param AndData The value to AND with the read value from the bit field.\r | |
6274 | @param OrData The value to OR with the result of the AND operation.\r | |
6275 | \r | |
6276 | @return The value written back to the MSR.\r | |
6277 | \r | |
6278 | **/\r | |
6279 | UINT64\r | |
6280 | EFIAPI\r | |
6281 | AsmMsrBitFieldAndThenOr64 (\r | |
6282 | IN UINT32 Index,\r | |
6283 | IN UINTN StartBit,\r | |
6284 | IN UINTN EndBit,\r | |
6285 | IN UINT64 AndData,\r | |
6286 | IN UINT64 OrData\r | |
6287 | );\r | |
6288 | \r | |
6289 | \r | |
6290 | /**\r | |
6291 | Reads the current value of the EFLAGS register.\r | |
6292 | \r | |
6293 | Reads and returns the current value of the EFLAGS register. This function is\r | |
030cd1a2 | 6294 | only available on IA-32 and x64. This returns a 32-bit value on IA-32 and a\r |
6295 | 64-bit value on x64.\r | |
ac644614 | 6296 | \r |
030cd1a2 | 6297 | @return EFLAGS on IA-32 or RFLAGS on x64.\r |
ac644614 | 6298 | \r |
6299 | **/\r | |
6300 | UINTN\r | |
6301 | EFIAPI\r | |
6302 | AsmReadEflags (\r | |
6303 | VOID\r | |
6304 | );\r | |
6305 | \r | |
6306 | \r | |
6307 | /**\r | |
6308 | Reads the current value of the Control Register 0 (CR0).\r | |
6309 | \r | |
6310 | Reads and returns the current value of CR0. This function is only available\r | |
030cd1a2 | 6311 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
6312 | x64.\r | |
ac644614 | 6313 | \r |
6314 | @return The value of the Control Register 0 (CR0).\r | |
6315 | \r | |
6316 | **/\r | |
6317 | UINTN\r | |
6318 | EFIAPI\r | |
6319 | AsmReadCr0 (\r | |
6320 | VOID\r | |
6321 | );\r | |
6322 | \r | |
6323 | \r | |
6324 | /**\r | |
6325 | Reads the current value of the Control Register 2 (CR2).\r | |
6326 | \r | |
6327 | Reads and returns the current value of CR2. This function is only available\r | |
030cd1a2 | 6328 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
6329 | x64.\r | |
ac644614 | 6330 | \r |
6331 | @return The value of the Control Register 2 (CR2).\r | |
6332 | \r | |
6333 | **/\r | |
6334 | UINTN\r | |
6335 | EFIAPI\r | |
6336 | AsmReadCr2 (\r | |
6337 | VOID\r | |
6338 | );\r | |
6339 | \r | |
6340 | \r | |
6341 | /**\r | |
6342 | Reads the current value of the Control Register 3 (CR3).\r | |
6343 | \r | |
6344 | Reads and returns the current value of CR3. This function is only available\r | |
030cd1a2 | 6345 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
6346 | x64.\r | |
ac644614 | 6347 | \r |
6348 | @return The value of the Control Register 3 (CR3).\r | |
6349 | \r | |
6350 | **/\r | |
6351 | UINTN\r | |
6352 | EFIAPI\r | |
6353 | AsmReadCr3 (\r | |
6354 | VOID\r | |
6355 | );\r | |
6356 | \r | |
6357 | \r | |
6358 | /**\r | |
6359 | Reads the current value of the Control Register 4 (CR4).\r | |
6360 | \r | |
6361 | Reads and returns the current value of CR4. This function is only available\r | |
030cd1a2 | 6362 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
6363 | x64.\r | |
ac644614 | 6364 | \r |
6365 | @return The value of the Control Register 4 (CR4).\r | |
6366 | \r | |
6367 | **/\r | |
6368 | UINTN\r | |
6369 | EFIAPI\r | |
6370 | AsmReadCr4 (\r | |
6371 | VOID\r | |
6372 | );\r | |
6373 | \r | |
6374 | \r | |
6375 | /**\r | |
6376 | Writes a value to Control Register 0 (CR0).\r | |
6377 | \r | |
6378 | Writes and returns a new value to CR0. This function is only available on\r | |
030cd1a2 | 6379 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 6380 | \r |
6381 | @param Cr0 The value to write to CR0.\r | |
6382 | \r | |
6383 | @return The value written to CR0.\r | |
6384 | \r | |
6385 | **/\r | |
6386 | UINTN\r | |
6387 | EFIAPI\r | |
6388 | AsmWriteCr0 (\r | |
6389 | UINTN Cr0\r | |
6390 | );\r | |
6391 | \r | |
6392 | \r | |
6393 | /**\r | |
6394 | Writes a value to Control Register 2 (CR2).\r | |
6395 | \r | |
6396 | Writes and returns a new value to CR2. This function is only available on\r | |
030cd1a2 | 6397 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 6398 | \r |
6399 | @param Cr2 The value to write to CR2.\r | |
6400 | \r | |
6401 | @return The value written to CR2.\r | |
6402 | \r | |
6403 | **/\r | |
6404 | UINTN\r | |
6405 | EFIAPI\r | |
6406 | AsmWriteCr2 (\r | |
6407 | UINTN Cr2\r | |
6408 | );\r | |
6409 | \r | |
6410 | \r | |
6411 | /**\r | |
6412 | Writes a value to Control Register 3 (CR3).\r | |
6413 | \r | |
6414 | Writes and returns a new value to CR3. This function is only available on\r | |
030cd1a2 | 6415 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 6416 | \r |
6417 | @param Cr3 The value to write to CR3.\r | |
6418 | \r | |
6419 | @return The value written to CR3.\r | |
6420 | \r | |
6421 | **/\r | |
6422 | UINTN\r | |
6423 | EFIAPI\r | |
6424 | AsmWriteCr3 (\r | |
6425 | UINTN Cr3\r | |
6426 | );\r | |
6427 | \r | |
6428 | \r | |
6429 | /**\r | |
6430 | Writes a value to Control Register 4 (CR4).\r | |
6431 | \r | |
6432 | Writes and returns a new value to CR4. This function is only available on\r | |
030cd1a2 | 6433 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 6434 | \r |
6435 | @param Cr4 The value to write to CR4.\r | |
6436 | \r | |
6437 | @return The value written to CR4.\r | |
6438 | \r | |
6439 | **/\r | |
6440 | UINTN\r | |
6441 | EFIAPI\r | |
6442 | AsmWriteCr4 (\r | |
6443 | UINTN Cr4\r | |
6444 | );\r | |
6445 | \r | |
6446 | \r | |
6447 | /**\r | |
6448 | Reads the current value of Debug Register 0 (DR0).\r | |
6449 | \r | |
6450 | Reads and returns the current value of DR0. This function is only available\r | |
030cd1a2 | 6451 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
6452 | x64.\r | |
ac644614 | 6453 | \r |
6454 | @return The value of Debug Register 0 (DR0).\r | |
6455 | \r | |
6456 | **/\r | |
6457 | UINTN\r | |
6458 | EFIAPI\r | |
6459 | AsmReadDr0 (\r | |
6460 | VOID\r | |
6461 | );\r | |
6462 | \r | |
6463 | \r | |
6464 | /**\r | |
6465 | Reads the current value of Debug Register 1 (DR1).\r | |
6466 | \r | |
6467 | Reads and returns the current value of DR1. This function is only available\r | |
030cd1a2 | 6468 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
6469 | x64.\r | |
ac644614 | 6470 | \r |
6471 | @return The value of Debug Register 1 (DR1).\r | |
6472 | \r | |
6473 | **/\r | |
6474 | UINTN\r | |
6475 | EFIAPI\r | |
6476 | AsmReadDr1 (\r | |
6477 | VOID\r | |
6478 | );\r | |
6479 | \r | |
6480 | \r | |
6481 | /**\r | |
6482 | Reads the current value of Debug Register 2 (DR2).\r | |
6483 | \r | |
6484 | Reads and returns the current value of DR2. This function is only available\r | |
030cd1a2 | 6485 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
6486 | x64.\r | |
ac644614 | 6487 | \r |
6488 | @return The value of Debug Register 2 (DR2).\r | |
6489 | \r | |
6490 | **/\r | |
6491 | UINTN\r | |
6492 | EFIAPI\r | |
6493 | AsmReadDr2 (\r | |
6494 | VOID\r | |
6495 | );\r | |
6496 | \r | |
6497 | \r | |
6498 | /**\r | |
6499 | Reads the current value of Debug Register 3 (DR3).\r | |
6500 | \r | |
6501 | Reads and returns the current value of DR3. This function is only available\r | |
030cd1a2 | 6502 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
6503 | x64.\r | |
ac644614 | 6504 | \r |
6505 | @return The value of Debug Register 3 (DR3).\r | |
6506 | \r | |
6507 | **/\r | |
6508 | UINTN\r | |
6509 | EFIAPI\r | |
6510 | AsmReadDr3 (\r | |
6511 | VOID\r | |
6512 | );\r | |
6513 | \r | |
6514 | \r | |
6515 | /**\r | |
6516 | Reads the current value of Debug Register 4 (DR4).\r | |
6517 | \r | |
6518 | Reads and returns the current value of DR4. This function is only available\r | |
030cd1a2 | 6519 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
6520 | x64.\r | |
ac644614 | 6521 | \r |
6522 | @return The value of Debug Register 4 (DR4).\r | |
6523 | \r | |
6524 | **/\r | |
6525 | UINTN\r | |
6526 | EFIAPI\r | |
6527 | AsmReadDr4 (\r | |
6528 | VOID\r | |
6529 | );\r | |
6530 | \r | |
6531 | \r | |
6532 | /**\r | |
6533 | Reads the current value of Debug Register 5 (DR5).\r | |
6534 | \r | |
6535 | Reads and returns the current value of DR5. This function is only available\r | |
030cd1a2 | 6536 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
6537 | x64.\r | |
ac644614 | 6538 | \r |
6539 | @return The value of Debug Register 5 (DR5).\r | |
6540 | \r | |
6541 | **/\r | |
6542 | UINTN\r | |
6543 | EFIAPI\r | |
6544 | AsmReadDr5 (\r | |
6545 | VOID\r | |
6546 | );\r | |
6547 | \r | |
6548 | \r | |
6549 | /**\r | |
6550 | Reads the current value of Debug Register 6 (DR6).\r | |
6551 | \r | |
6552 | Reads and returns the current value of DR6. This function is only available\r | |
030cd1a2 | 6553 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
6554 | x64.\r | |
ac644614 | 6555 | \r |
6556 | @return The value of Debug Register 6 (DR6).\r | |
6557 | \r | |
6558 | **/\r | |
6559 | UINTN\r | |
6560 | EFIAPI\r | |
6561 | AsmReadDr6 (\r | |
6562 | VOID\r | |
6563 | );\r | |
6564 | \r | |
6565 | \r | |
6566 | /**\r | |
6567 | Reads the current value of Debug Register 7 (DR7).\r | |
6568 | \r | |
6569 | Reads and returns the current value of DR7. This function is only available\r | |
030cd1a2 | 6570 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
6571 | x64.\r | |
ac644614 | 6572 | \r |
6573 | @return The value of Debug Register 7 (DR7).\r | |
6574 | \r | |
6575 | **/\r | |
6576 | UINTN\r | |
6577 | EFIAPI\r | |
6578 | AsmReadDr7 (\r | |
6579 | VOID\r | |
6580 | );\r | |
6581 | \r | |
6582 | \r | |
6583 | /**\r | |
6584 | Writes a value to Debug Register 0 (DR0).\r | |
6585 | \r | |
6586 | Writes and returns a new value to DR0. This function is only available on\r | |
030cd1a2 | 6587 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 6588 | \r |
6589 | @param Dr0 The value to write to Dr0.\r | |
6590 | \r | |
6591 | @return The value written to Debug Register 0 (DR0).\r | |
6592 | \r | |
6593 | **/\r | |
6594 | UINTN\r | |
6595 | EFIAPI\r | |
6596 | AsmWriteDr0 (\r | |
6597 | UINTN Dr0\r | |
6598 | );\r | |
6599 | \r | |
6600 | \r | |
6601 | /**\r | |
6602 | Writes a value to Debug Register 1 (DR1).\r | |
6603 | \r | |
6604 | Writes and returns a new value to DR1. This function is only available on\r | |
030cd1a2 | 6605 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 6606 | \r |
6607 | @param Dr1 The value to write to Dr1.\r | |
6608 | \r | |
6609 | @return The value written to Debug Register 1 (DR1).\r | |
6610 | \r | |
6611 | **/\r | |
6612 | UINTN\r | |
6613 | EFIAPI\r | |
6614 | AsmWriteDr1 (\r | |
6615 | UINTN Dr1\r | |
6616 | );\r | |
6617 | \r | |
6618 | \r | |
6619 | /**\r | |
6620 | Writes a value to Debug Register 2 (DR2).\r | |
6621 | \r | |
6622 | Writes and returns a new value to DR2. This function is only available on\r | |
030cd1a2 | 6623 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 6624 | \r |
6625 | @param Dr2 The value to write to Dr2.\r | |
6626 | \r | |
6627 | @return The value written to Debug Register 2 (DR2).\r | |
6628 | \r | |
6629 | **/\r | |
6630 | UINTN\r | |
6631 | EFIAPI\r | |
6632 | AsmWriteDr2 (\r | |
6633 | UINTN Dr2\r | |
6634 | );\r | |
6635 | \r | |
6636 | \r | |
6637 | /**\r | |
6638 | Writes a value to Debug Register 3 (DR3).\r | |
6639 | \r | |
6640 | Writes and returns a new value to DR3. This function is only available on\r | |
030cd1a2 | 6641 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 6642 | \r |
6643 | @param Dr3 The value to write to Dr3.\r | |
6644 | \r | |
6645 | @return The value written to Debug Register 3 (DR3).\r | |
6646 | \r | |
6647 | **/\r | |
6648 | UINTN\r | |
6649 | EFIAPI\r | |
6650 | AsmWriteDr3 (\r | |
6651 | UINTN Dr3\r | |
6652 | );\r | |
6653 | \r | |
6654 | \r | |
6655 | /**\r | |
6656 | Writes a value to Debug Register 4 (DR4).\r | |
6657 | \r | |
6658 | Writes and returns a new value to DR4. This function is only available on\r | |
030cd1a2 | 6659 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 6660 | \r |
6661 | @param Dr4 The value to write to Dr4.\r | |
6662 | \r | |
6663 | @return The value written to Debug Register 4 (DR4).\r | |
6664 | \r | |
6665 | **/\r | |
6666 | UINTN\r | |
6667 | EFIAPI\r | |
6668 | AsmWriteDr4 (\r | |
6669 | UINTN Dr4\r | |
6670 | );\r | |
6671 | \r | |
6672 | \r | |
6673 | /**\r | |
6674 | Writes a value to Debug Register 5 (DR5).\r | |
6675 | \r | |
6676 | Writes and returns a new value to DR5. This function is only available on\r | |
030cd1a2 | 6677 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 6678 | \r |
6679 | @param Dr5 The value to write to Dr5.\r | |
6680 | \r | |
6681 | @return The value written to Debug Register 5 (DR5).\r | |
6682 | \r | |
6683 | **/\r | |
6684 | UINTN\r | |
6685 | EFIAPI\r | |
6686 | AsmWriteDr5 (\r | |
6687 | UINTN Dr5\r | |
6688 | );\r | |
6689 | \r | |
6690 | \r | |
6691 | /**\r | |
6692 | Writes a value to Debug Register 6 (DR6).\r | |
6693 | \r | |
6694 | Writes and returns a new value to DR6. This function is only available on\r | |
030cd1a2 | 6695 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 6696 | \r |
6697 | @param Dr6 The value to write to Dr6.\r | |
6698 | \r | |
6699 | @return The value written to Debug Register 6 (DR6).\r | |
6700 | \r | |
6701 | **/\r | |
6702 | UINTN\r | |
6703 | EFIAPI\r | |
6704 | AsmWriteDr6 (\r | |
6705 | UINTN Dr6\r | |
6706 | );\r | |
6707 | \r | |
6708 | \r | |
6709 | /**\r | |
6710 | Writes a value to Debug Register 7 (DR7).\r | |
6711 | \r | |
6712 | Writes and returns a new value to DR7. This function is only available on\r | |
030cd1a2 | 6713 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 6714 | \r |
6715 | @param Dr7 The value to write to Dr7.\r | |
6716 | \r | |
6717 | @return The value written to Debug Register 7 (DR7).\r | |
6718 | \r | |
6719 | **/\r | |
6720 | UINTN\r | |
6721 | EFIAPI\r | |
6722 | AsmWriteDr7 (\r | |
6723 | UINTN Dr7\r | |
6724 | );\r | |
6725 | \r | |
6726 | \r | |
6727 | /**\r | |
6728 | Reads the current value of Code Segment Register (CS).\r | |
6729 | \r | |
6730 | Reads and returns the current value of CS. This function is only available on\r | |
030cd1a2 | 6731 | IA-32 and x64.\r |
ac644614 | 6732 | \r |
6733 | @return The current value of CS.\r | |
6734 | \r | |
6735 | **/\r | |
6736 | UINT16\r | |
6737 | EFIAPI\r | |
6738 | AsmReadCs (\r | |
6739 | VOID\r | |
6740 | );\r | |
6741 | \r | |
6742 | \r | |
6743 | /**\r | |
6744 | Reads the current value of Data Segment Register (DS).\r | |
6745 | \r | |
6746 | Reads and returns the current value of DS. This function is only available on\r | |
030cd1a2 | 6747 | IA-32 and x64.\r |
ac644614 | 6748 | \r |
6749 | @return The current value of DS.\r | |
6750 | \r | |
6751 | **/\r | |
6752 | UINT16\r | |
6753 | EFIAPI\r | |
6754 | AsmReadDs (\r | |
6755 | VOID\r | |
6756 | );\r | |
6757 | \r | |
6758 | \r | |
6759 | /**\r | |
6760 | Reads the current value of Extra Segment Register (ES).\r | |
6761 | \r | |
6762 | Reads and returns the current value of ES. This function is only available on\r | |
030cd1a2 | 6763 | IA-32 and x64.\r |
ac644614 | 6764 | \r |
6765 | @return The current value of ES.\r | |
6766 | \r | |
6767 | **/\r | |
6768 | UINT16\r | |
6769 | EFIAPI\r | |
6770 | AsmReadEs (\r | |
6771 | VOID\r | |
6772 | );\r | |
6773 | \r | |
6774 | \r | |
6775 | /**\r | |
6776 | Reads the current value of FS Data Segment Register (FS).\r | |
6777 | \r | |
6778 | Reads and returns the current value of FS. This function is only available on\r | |
030cd1a2 | 6779 | IA-32 and x64.\r |
ac644614 | 6780 | \r |
6781 | @return The current value of FS.\r | |
6782 | \r | |
6783 | **/\r | |
6784 | UINT16\r | |
6785 | EFIAPI\r | |
6786 | AsmReadFs (\r | |
6787 | VOID\r | |
6788 | );\r | |
6789 | \r | |
6790 | \r | |
6791 | /**\r | |
6792 | Reads the current value of GS Data Segment Register (GS).\r | |
6793 | \r | |
6794 | Reads and returns the current value of GS. This function is only available on\r | |
030cd1a2 | 6795 | IA-32 and x64.\r |
ac644614 | 6796 | \r |
6797 | @return The current value of GS.\r | |
6798 | \r | |
6799 | **/\r | |
6800 | UINT16\r | |
6801 | EFIAPI\r | |
6802 | AsmReadGs (\r | |
6803 | VOID\r | |
6804 | );\r | |
6805 | \r | |
6806 | \r | |
6807 | /**\r | |
6808 | Reads the current value of Stack Segment Register (SS).\r | |
6809 | \r | |
6810 | Reads and returns the current value of SS. This function is only available on\r | |
030cd1a2 | 6811 | IA-32 and x64.\r |
ac644614 | 6812 | \r |
6813 | @return The current value of SS.\r | |
6814 | \r | |
6815 | **/\r | |
6816 | UINT16\r | |
6817 | EFIAPI\r | |
6818 | AsmReadSs (\r | |
6819 | VOID\r | |
6820 | );\r | |
6821 | \r | |
6822 | \r | |
6823 | /**\r | |
6824 | Reads the current value of Task Register (TR).\r | |
6825 | \r | |
6826 | Reads and returns the current value of TR. This function is only available on\r | |
030cd1a2 | 6827 | IA-32 and x64.\r |
ac644614 | 6828 | \r |
6829 | @return The current value of TR.\r | |
6830 | \r | |
6831 | **/\r | |
6832 | UINT16\r | |
6833 | EFIAPI\r | |
6834 | AsmReadTr (\r | |
6835 | VOID\r | |
6836 | );\r | |
6837 | \r | |
6838 | \r | |
6839 | /**\r | |
6840 | Reads the current Global Descriptor Table Register(GDTR) descriptor.\r | |
6841 | \r | |
6842 | Reads and returns the current GDTR descriptor and returns it in Gdtr. This\r | |
030cd1a2 | 6843 | function is only available on IA-32 and x64.\r |
ac644614 | 6844 | \r |
6845 | If Gdtr is NULL, then ASSERT().\r | |
6846 | \r | |
af2dc6a7 | 6847 | @param Gdtr The pointer to a GDTR descriptor.\r |
ac644614 | 6848 | \r |
6849 | **/\r | |
6850 | VOID\r | |
6851 | EFIAPI\r | |
6852 | AsmReadGdtr (\r | |
6853 | OUT IA32_DESCRIPTOR *Gdtr\r | |
6854 | );\r | |
6855 | \r | |
6856 | \r | |
6857 | /**\r | |
6858 | Writes the current Global Descriptor Table Register (GDTR) descriptor.\r | |
6859 | \r | |
6860 | Writes and the current GDTR descriptor specified by Gdtr. This function is\r | |
030cd1a2 | 6861 | only available on IA-32 and x64.\r |
ac644614 | 6862 | \r |
6863 | If Gdtr is NULL, then ASSERT().\r | |
6864 | \r | |
af2dc6a7 | 6865 | @param Gdtr The pointer to a GDTR descriptor.\r |
ac644614 | 6866 | \r |
6867 | **/\r | |
6868 | VOID\r | |
6869 | EFIAPI\r | |
6870 | AsmWriteGdtr (\r | |
6871 | IN CONST IA32_DESCRIPTOR *Gdtr\r | |
6872 | );\r | |
6873 | \r | |
6874 | \r | |
6875 | /**\r | |
17f695ed | 6876 | Reads the current Interrupt Descriptor Table Register(IDTR) descriptor.\r |
ac644614 | 6877 | \r |
6878 | Reads and returns the current IDTR descriptor and returns it in Idtr. This\r | |
030cd1a2 | 6879 | function is only available on IA-32 and x64.\r |
ac644614 | 6880 | \r |
6881 | If Idtr is NULL, then ASSERT().\r | |
6882 | \r | |
af2dc6a7 | 6883 | @param Idtr The pointer to a IDTR descriptor.\r |
ac644614 | 6884 | \r |
6885 | **/\r | |
6886 | VOID\r | |
6887 | EFIAPI\r | |
6888 | AsmReadIdtr (\r | |
6889 | OUT IA32_DESCRIPTOR *Idtr\r | |
6890 | );\r | |
6891 | \r | |
6892 | \r | |
6893 | /**\r | |
17f695ed | 6894 | Writes the current Interrupt Descriptor Table Register(IDTR) descriptor.\r |
ac644614 | 6895 | \r |
6896 | Writes the current IDTR descriptor and returns it in Idtr. This function is\r | |
030cd1a2 | 6897 | only available on IA-32 and x64.\r |
ac644614 | 6898 | \r |
6899 | If Idtr is NULL, then ASSERT().\r | |
6900 | \r | |
af2dc6a7 | 6901 | @param Idtr The pointer to a IDTR descriptor.\r |
ac644614 | 6902 | \r |
6903 | **/\r | |
6904 | VOID\r | |
6905 | EFIAPI\r | |
6906 | AsmWriteIdtr (\r | |
6907 | IN CONST IA32_DESCRIPTOR *Idtr\r | |
6908 | );\r | |
6909 | \r | |
6910 | \r | |
6911 | /**\r | |
6912 | Reads the current Local Descriptor Table Register(LDTR) selector.\r | |
6913 | \r | |
6914 | Reads and returns the current 16-bit LDTR descriptor value. This function is\r | |
030cd1a2 | 6915 | only available on IA-32 and x64.\r |
ac644614 | 6916 | \r |
6917 | @return The current selector of LDT.\r | |
6918 | \r | |
6919 | **/\r | |
6920 | UINT16\r | |
6921 | EFIAPI\r | |
6922 | AsmReadLdtr (\r | |
6923 | VOID\r | |
6924 | );\r | |
6925 | \r | |
6926 | \r | |
6927 | /**\r | |
17f695ed | 6928 | Writes the current Local Descriptor Table Register (LDTR) selector.\r |
ac644614 | 6929 | \r |
6930 | Writes and the current LDTR descriptor specified by Ldtr. This function is\r | |
030cd1a2 | 6931 | only available on IA-32 and x64.\r |
ac644614 | 6932 | \r |
6933 | @param Ldtr 16-bit LDTR selector value.\r | |
6934 | \r | |
6935 | **/\r | |
6936 | VOID\r | |
6937 | EFIAPI\r | |
6938 | AsmWriteLdtr (\r | |
6939 | IN UINT16 Ldtr\r | |
6940 | );\r | |
6941 | \r | |
6942 | \r | |
6943 | /**\r | |
6944 | Save the current floating point/SSE/SSE2 context to a buffer.\r | |
6945 | \r | |
6946 | Saves the current floating point/SSE/SSE2 state to the buffer specified by\r | |
6947 | Buffer. Buffer must be aligned on a 16-byte boundary. This function is only\r | |
030cd1a2 | 6948 | available on IA-32 and x64.\r |
ac644614 | 6949 | \r |
6950 | If Buffer is NULL, then ASSERT().\r | |
6951 | If Buffer is not aligned on a 16-byte boundary, then ASSERT().\r | |
6952 | \r | |
af2dc6a7 | 6953 | @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.\r |
ac644614 | 6954 | \r |
6955 | **/\r | |
6956 | VOID\r | |
6957 | EFIAPI\r | |
6958 | AsmFxSave (\r | |
6959 | OUT IA32_FX_BUFFER *Buffer\r | |
6960 | );\r | |
6961 | \r | |
6962 | \r | |
6963 | /**\r | |
6964 | Restores the current floating point/SSE/SSE2 context from a buffer.\r | |
6965 | \r | |
6966 | Restores the current floating point/SSE/SSE2 state from the buffer specified\r | |
6967 | by Buffer. Buffer must be aligned on a 16-byte boundary. This function is\r | |
030cd1a2 | 6968 | only available on IA-32 and x64.\r |
ac644614 | 6969 | \r |
6970 | If Buffer is NULL, then ASSERT().\r | |
6971 | If Buffer is not aligned on a 16-byte boundary, then ASSERT().\r | |
6972 | If Buffer was not saved with AsmFxSave(), then ASSERT().\r | |
6973 | \r | |
af2dc6a7 | 6974 | @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.\r |
ac644614 | 6975 | \r |
6976 | **/\r | |
6977 | VOID\r | |
6978 | EFIAPI\r | |
6979 | AsmFxRestore (\r | |
6980 | IN CONST IA32_FX_BUFFER *Buffer\r | |
6981 | );\r | |
6982 | \r | |
6983 | \r | |
6984 | /**\r | |
6985 | Reads the current value of 64-bit MMX Register #0 (MM0).\r | |
6986 | \r | |
6987 | Reads and returns the current value of MM0. This function is only available\r | |
030cd1a2 | 6988 | on IA-32 and x64.\r |
ac644614 | 6989 | \r |
6990 | @return The current value of MM0.\r | |
6991 | \r | |
6992 | **/\r | |
6993 | UINT64\r | |
6994 | EFIAPI\r | |
6995 | AsmReadMm0 (\r | |
6996 | VOID\r | |
6997 | );\r | |
6998 | \r | |
6999 | \r | |
7000 | /**\r | |
7001 | Reads the current value of 64-bit MMX Register #1 (MM1).\r | |
7002 | \r | |
7003 | Reads and returns the current value of MM1. This function is only available\r | |
030cd1a2 | 7004 | on IA-32 and x64.\r |
ac644614 | 7005 | \r |
7006 | @return The current value of MM1.\r | |
7007 | \r | |
7008 | **/\r | |
7009 | UINT64\r | |
7010 | EFIAPI\r | |
7011 | AsmReadMm1 (\r | |
7012 | VOID\r | |
7013 | );\r | |
7014 | \r | |
7015 | \r | |
7016 | /**\r | |
7017 | Reads the current value of 64-bit MMX Register #2 (MM2).\r | |
7018 | \r | |
7019 | Reads and returns the current value of MM2. This function is only available\r | |
030cd1a2 | 7020 | on IA-32 and x64.\r |
ac644614 | 7021 | \r |
7022 | @return The current value of MM2.\r | |
7023 | \r | |
7024 | **/\r | |
7025 | UINT64\r | |
7026 | EFIAPI\r | |
7027 | AsmReadMm2 (\r | |
7028 | VOID\r | |
7029 | );\r | |
7030 | \r | |
7031 | \r | |
7032 | /**\r | |
7033 | Reads the current value of 64-bit MMX Register #3 (MM3).\r | |
7034 | \r | |
7035 | Reads and returns the current value of MM3. This function is only available\r | |
030cd1a2 | 7036 | on IA-32 and x64.\r |
ac644614 | 7037 | \r |
7038 | @return The current value of MM3.\r | |
7039 | \r | |
7040 | **/\r | |
7041 | UINT64\r | |
7042 | EFIAPI\r | |
7043 | AsmReadMm3 (\r | |
7044 | VOID\r | |
7045 | );\r | |
7046 | \r | |
7047 | \r | |
7048 | /**\r | |
7049 | Reads the current value of 64-bit MMX Register #4 (MM4).\r | |
7050 | \r | |
7051 | Reads and returns the current value of MM4. This function is only available\r | |
030cd1a2 | 7052 | on IA-32 and x64.\r |
ac644614 | 7053 | \r |
7054 | @return The current value of MM4.\r | |
7055 | \r | |
7056 | **/\r | |
7057 | UINT64\r | |
7058 | EFIAPI\r | |
7059 | AsmReadMm4 (\r | |
7060 | VOID\r | |
7061 | );\r | |
7062 | \r | |
7063 | \r | |
7064 | /**\r | |
7065 | Reads the current value of 64-bit MMX Register #5 (MM5).\r | |
7066 | \r | |
7067 | Reads and returns the current value of MM5. This function is only available\r | |
030cd1a2 | 7068 | on IA-32 and x64.\r |
ac644614 | 7069 | \r |
7070 | @return The current value of MM5.\r | |
7071 | \r | |
7072 | **/\r | |
7073 | UINT64\r | |
7074 | EFIAPI\r | |
7075 | AsmReadMm5 (\r | |
7076 | VOID\r | |
7077 | );\r | |
7078 | \r | |
7079 | \r | |
7080 | /**\r | |
7081 | Reads the current value of 64-bit MMX Register #6 (MM6).\r | |
7082 | \r | |
7083 | Reads and returns the current value of MM6. This function is only available\r | |
030cd1a2 | 7084 | on IA-32 and x64.\r |
ac644614 | 7085 | \r |
7086 | @return The current value of MM6.\r | |
7087 | \r | |
7088 | **/\r | |
7089 | UINT64\r | |
7090 | EFIAPI\r | |
7091 | AsmReadMm6 (\r | |
7092 | VOID\r | |
7093 | );\r | |
7094 | \r | |
7095 | \r | |
7096 | /**\r | |
7097 | Reads the current value of 64-bit MMX Register #7 (MM7).\r | |
7098 | \r | |
7099 | Reads and returns the current value of MM7. This function is only available\r | |
030cd1a2 | 7100 | on IA-32 and x64.\r |
ac644614 | 7101 | \r |
7102 | @return The current value of MM7.\r | |
7103 | \r | |
7104 | **/\r | |
7105 | UINT64\r | |
7106 | EFIAPI\r | |
7107 | AsmReadMm7 (\r | |
7108 | VOID\r | |
7109 | );\r | |
7110 | \r | |
7111 | \r | |
7112 | /**\r | |
7113 | Writes the current value of 64-bit MMX Register #0 (MM0).\r | |
7114 | \r | |
7115 | Writes the current value of MM0. This function is only available on IA32 and\r | |
030cd1a2 | 7116 | x64.\r |
ac644614 | 7117 | \r |
7118 | @param Value The 64-bit value to write to MM0.\r | |
7119 | \r | |
7120 | **/\r | |
7121 | VOID\r | |
7122 | EFIAPI\r | |
7123 | AsmWriteMm0 (\r | |
7124 | IN UINT64 Value\r | |
7125 | );\r | |
7126 | \r | |
7127 | \r | |
7128 | /**\r | |
7129 | Writes the current value of 64-bit MMX Register #1 (MM1).\r | |
7130 | \r | |
7131 | Writes the current value of MM1. This function is only available on IA32 and\r | |
030cd1a2 | 7132 | x64.\r |
ac644614 | 7133 | \r |
7134 | @param Value The 64-bit value to write to MM1.\r | |
7135 | \r | |
7136 | **/\r | |
7137 | VOID\r | |
7138 | EFIAPI\r | |
7139 | AsmWriteMm1 (\r | |
7140 | IN UINT64 Value\r | |
7141 | );\r | |
7142 | \r | |
7143 | \r | |
7144 | /**\r | |
7145 | Writes the current value of 64-bit MMX Register #2 (MM2).\r | |
7146 | \r | |
7147 | Writes the current value of MM2. This function is only available on IA32 and\r | |
030cd1a2 | 7148 | x64.\r |
ac644614 | 7149 | \r |
7150 | @param Value The 64-bit value to write to MM2.\r | |
7151 | \r | |
7152 | **/\r | |
7153 | VOID\r | |
7154 | EFIAPI\r | |
7155 | AsmWriteMm2 (\r | |
7156 | IN UINT64 Value\r | |
7157 | );\r | |
7158 | \r | |
7159 | \r | |
7160 | /**\r | |
7161 | Writes the current value of 64-bit MMX Register #3 (MM3).\r | |
7162 | \r | |
7163 | Writes the current value of MM3. This function is only available on IA32 and\r | |
030cd1a2 | 7164 | x64.\r |
ac644614 | 7165 | \r |
7166 | @param Value The 64-bit value to write to MM3.\r | |
7167 | \r | |
7168 | **/\r | |
7169 | VOID\r | |
7170 | EFIAPI\r | |
7171 | AsmWriteMm3 (\r | |
7172 | IN UINT64 Value\r | |
7173 | );\r | |
7174 | \r | |
7175 | \r | |
7176 | /**\r | |
7177 | Writes the current value of 64-bit MMX Register #4 (MM4).\r | |
7178 | \r | |
7179 | Writes the current value of MM4. This function is only available on IA32 and\r | |
030cd1a2 | 7180 | x64.\r |
ac644614 | 7181 | \r |
7182 | @param Value The 64-bit value to write to MM4.\r | |
7183 | \r | |
7184 | **/\r | |
7185 | VOID\r | |
7186 | EFIAPI\r | |
7187 | AsmWriteMm4 (\r | |
7188 | IN UINT64 Value\r | |
7189 | );\r | |
7190 | \r | |
7191 | \r | |
7192 | /**\r | |
7193 | Writes the current value of 64-bit MMX Register #5 (MM5).\r | |
7194 | \r | |
7195 | Writes the current value of MM5. This function is only available on IA32 and\r | |
030cd1a2 | 7196 | x64.\r |
ac644614 | 7197 | \r |
7198 | @param Value The 64-bit value to write to MM5.\r | |
7199 | \r | |
7200 | **/\r | |
7201 | VOID\r | |
7202 | EFIAPI\r | |
7203 | AsmWriteMm5 (\r | |
7204 | IN UINT64 Value\r | |
7205 | );\r | |
7206 | \r | |
7207 | \r | |
7208 | /**\r | |
7209 | Writes the current value of 64-bit MMX Register #6 (MM6).\r | |
7210 | \r | |
7211 | Writes the current value of MM6. This function is only available on IA32 and\r | |
030cd1a2 | 7212 | x64.\r |
ac644614 | 7213 | \r |
7214 | @param Value The 64-bit value to write to MM6.\r | |
7215 | \r | |
7216 | **/\r | |
7217 | VOID\r | |
7218 | EFIAPI\r | |
7219 | AsmWriteMm6 (\r | |
7220 | IN UINT64 Value\r | |
7221 | );\r | |
7222 | \r | |
7223 | \r | |
7224 | /**\r | |
7225 | Writes the current value of 64-bit MMX Register #7 (MM7).\r | |
7226 | \r | |
7227 | Writes the current value of MM7. This function is only available on IA32 and\r | |
030cd1a2 | 7228 | x64.\r |
ac644614 | 7229 | \r |
7230 | @param Value The 64-bit value to write to MM7.\r | |
7231 | \r | |
7232 | **/\r | |
7233 | VOID\r | |
7234 | EFIAPI\r | |
7235 | AsmWriteMm7 (\r | |
7236 | IN UINT64 Value\r | |
7237 | );\r | |
7238 | \r | |
7239 | \r | |
7240 | /**\r | |
7241 | Reads the current value of Time Stamp Counter (TSC).\r | |
7242 | \r | |
7243 | Reads and returns the current value of TSC. This function is only available\r | |
030cd1a2 | 7244 | on IA-32 and x64.\r |
ac644614 | 7245 | \r |
7246 | @return The current value of TSC\r | |
7247 | \r | |
7248 | **/\r | |
7249 | UINT64\r | |
7250 | EFIAPI\r | |
7251 | AsmReadTsc (\r | |
7252 | VOID\r | |
7253 | );\r | |
7254 | \r | |
7255 | \r | |
7256 | /**\r | |
7257 | Reads the current value of a Performance Counter (PMC).\r | |
7258 | \r | |
7259 | Reads and returns the current value of performance counter specified by\r | |
030cd1a2 | 7260 | Index. This function is only available on IA-32 and x64.\r |
ac644614 | 7261 | \r |
7262 | @param Index The 32-bit Performance Counter index to read.\r | |
7263 | \r | |
7264 | @return The value of the PMC specified by Index.\r | |
7265 | \r | |
7266 | **/\r | |
7267 | UINT64\r | |
7268 | EFIAPI\r | |
7269 | AsmReadPmc (\r | |
7270 | IN UINT32 Index\r | |
7271 | );\r | |
7272 | \r | |
7273 | \r | |
7274 | /**\r | |
7275 | Sets up a monitor buffer that is used by AsmMwait().\r | |
7276 | \r | |
7277 | Executes a MONITOR instruction with the register state specified by Eax, Ecx\r | |
030cd1a2 | 7278 | and Edx. Returns Eax. This function is only available on IA-32 and x64.\r |
ac644614 | 7279 | \r |
7280 | @param Eax The value to load into EAX or RAX before executing the MONITOR\r | |
7281 | instruction.\r | |
7282 | @param Ecx The value to load into ECX or RCX before executing the MONITOR\r | |
7283 | instruction.\r | |
7284 | @param Edx The value to load into EDX or RDX before executing the MONITOR\r | |
7285 | instruction.\r | |
7286 | \r | |
7287 | @return Eax\r | |
7288 | \r | |
7289 | **/\r | |
7290 | UINTN\r | |
7291 | EFIAPI\r | |
7292 | AsmMonitor (\r | |
7293 | IN UINTN Eax,\r | |
7294 | IN UINTN Ecx,\r | |
7295 | IN UINTN Edx\r | |
7296 | );\r | |
7297 | \r | |
7298 | \r | |
7299 | /**\r | |
7300 | Executes an MWAIT instruction.\r | |
7301 | \r | |
7302 | Executes an MWAIT instruction with the register state specified by Eax and\r | |
030cd1a2 | 7303 | Ecx. Returns Eax. This function is only available on IA-32 and x64.\r |
ac644614 | 7304 | \r |
7305 | @param Eax The value to load into EAX or RAX before executing the MONITOR\r | |
7306 | instruction.\r | |
7307 | @param Ecx The value to load into ECX or RCX before executing the MONITOR\r | |
7308 | instruction.\r | |
7309 | \r | |
7310 | @return Eax\r | |
7311 | \r | |
7312 | **/\r | |
7313 | UINTN\r | |
7314 | EFIAPI\r | |
7315 | AsmMwait (\r | |
7316 | IN UINTN Eax,\r | |
7317 | IN UINTN Ecx\r | |
7318 | );\r | |
7319 | \r | |
7320 | \r | |
7321 | /**\r | |
7322 | Executes a WBINVD instruction.\r | |
7323 | \r | |
7324 | Executes a WBINVD instruction. This function is only available on IA-32 and\r | |
030cd1a2 | 7325 | x64.\r |
ac644614 | 7326 | \r |
7327 | **/\r | |
7328 | VOID\r | |
7329 | EFIAPI\r | |
7330 | AsmWbinvd (\r | |
7331 | VOID\r | |
7332 | );\r | |
7333 | \r | |
7334 | \r | |
7335 | /**\r | |
7336 | Executes a INVD instruction.\r | |
7337 | \r | |
7338 | Executes a INVD instruction. This function is only available on IA-32 and\r | |
030cd1a2 | 7339 | x64.\r |
ac644614 | 7340 | \r |
7341 | **/\r | |
7342 | VOID\r | |
7343 | EFIAPI\r | |
7344 | AsmInvd (\r | |
7345 | VOID\r | |
7346 | );\r | |
7347 | \r | |
7348 | \r | |
7349 | /**\r | |
7350 | Flushes a cache line from all the instruction and data caches within the\r | |
7351 | coherency domain of the CPU.\r | |
7352 | \r | |
7353 | Flushed the cache line specified by LinearAddress, and returns LinearAddress.\r | |
030cd1a2 | 7354 | This function is only available on IA-32 and x64.\r |
ac644614 | 7355 | \r |
7356 | @param LinearAddress The address of the cache line to flush. If the CPU is\r | |
7357 | in a physical addressing mode, then LinearAddress is a\r | |
7358 | physical address. If the CPU is in a virtual\r | |
7359 | addressing mode, then LinearAddress is a virtual\r | |
7360 | address.\r | |
7361 | \r | |
af2dc6a7 | 7362 | @return LinearAddress.\r |
ac644614 | 7363 | **/\r |
7364 | VOID *\r | |
7365 | EFIAPI\r | |
7366 | AsmFlushCacheLine (\r | |
7367 | IN VOID *LinearAddress\r | |
7368 | );\r | |
7369 | \r | |
7370 | \r | |
7371 | /**\r | |
7372 | Enables the 32-bit paging mode on the CPU.\r | |
7373 | \r | |
7374 | Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables\r | |
7375 | must be properly initialized prior to calling this service. This function\r | |
7376 | assumes the current execution mode is 32-bit protected mode. This function is\r | |
7377 | only available on IA-32. After the 32-bit paging mode is enabled, control is\r | |
7378 | transferred to the function specified by EntryPoint using the new stack\r | |
7379 | specified by NewStack and passing in the parameters specified by Context1 and\r | |
7380 | Context2. Context1 and Context2 are optional and may be NULL. The function\r | |
7381 | EntryPoint must never return.\r | |
7382 | \r | |
7383 | If the current execution mode is not 32-bit protected mode, then ASSERT().\r | |
7384 | If EntryPoint is NULL, then ASSERT().\r | |
7385 | If NewStack is NULL, then ASSERT().\r | |
7386 | \r | |
7387 | There are a number of constraints that must be followed before calling this\r | |
7388 | function:\r | |
7389 | 1) Interrupts must be disabled.\r | |
7390 | 2) The caller must be in 32-bit protected mode with flat descriptors. This\r | |
7391 | means all descriptors must have a base of 0 and a limit of 4GB.\r | |
7392 | 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat\r | |
7393 | descriptors.\r | |
7394 | 4) CR3 must point to valid page tables that will be used once the transition\r | |
7395 | is complete, and those page tables must guarantee that the pages for this\r | |
7396 | function and the stack are identity mapped.\r | |
7397 | \r | |
7398 | @param EntryPoint A pointer to function to call with the new stack after\r | |
7399 | paging is enabled.\r | |
7400 | @param Context1 A pointer to the context to pass into the EntryPoint\r | |
7401 | function as the first parameter after paging is enabled.\r | |
7402 | @param Context2 A pointer to the context to pass into the EntryPoint\r | |
7403 | function as the second parameter after paging is enabled.\r | |
7404 | @param NewStack A pointer to the new stack to use for the EntryPoint\r | |
7405 | function after paging is enabled.\r | |
7406 | \r | |
7407 | **/\r | |
7408 | VOID\r | |
7409 | EFIAPI\r | |
7410 | AsmEnablePaging32 (\r | |
7411 | IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r | |
7412 | IN VOID *Context1, OPTIONAL\r | |
7413 | IN VOID *Context2, OPTIONAL\r | |
7414 | IN VOID *NewStack\r | |
7415 | );\r | |
7416 | \r | |
7417 | \r | |
7418 | /**\r | |
7419 | Disables the 32-bit paging mode on the CPU.\r | |
7420 | \r | |
7421 | Disables the 32-bit paging mode on the CPU and returns to 32-bit protected\r | |
7422 | mode. This function assumes the current execution mode is 32-paged protected\r | |
7423 | mode. This function is only available on IA-32. After the 32-bit paging mode\r | |
7424 | is disabled, control is transferred to the function specified by EntryPoint\r | |
7425 | using the new stack specified by NewStack and passing in the parameters\r | |
7426 | specified by Context1 and Context2. Context1 and Context2 are optional and\r | |
7427 | may be NULL. The function EntryPoint must never return.\r | |
7428 | \r | |
7429 | If the current execution mode is not 32-bit paged mode, then ASSERT().\r | |
7430 | If EntryPoint is NULL, then ASSERT().\r | |
7431 | If NewStack is NULL, then ASSERT().\r | |
7432 | \r | |
7433 | There are a number of constraints that must be followed before calling this\r | |
7434 | function:\r | |
7435 | 1) Interrupts must be disabled.\r | |
7436 | 2) The caller must be in 32-bit paged mode.\r | |
7437 | 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.\r | |
7438 | 4) CR3 must point to valid page tables that guarantee that the pages for\r | |
7439 | this function and the stack are identity mapped.\r | |
7440 | \r | |
7441 | @param EntryPoint A pointer to function to call with the new stack after\r | |
7442 | paging is disabled.\r | |
7443 | @param Context1 A pointer to the context to pass into the EntryPoint\r | |
7444 | function as the first parameter after paging is disabled.\r | |
7445 | @param Context2 A pointer to the context to pass into the EntryPoint\r | |
7446 | function as the second parameter after paging is\r | |
7447 | disabled.\r | |
7448 | @param NewStack A pointer to the new stack to use for the EntryPoint\r | |
7449 | function after paging is disabled.\r | |
7450 | \r | |
7451 | **/\r | |
7452 | VOID\r | |
7453 | EFIAPI\r | |
7454 | AsmDisablePaging32 (\r | |
7455 | IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r | |
7456 | IN VOID *Context1, OPTIONAL\r | |
7457 | IN VOID *Context2, OPTIONAL\r | |
7458 | IN VOID *NewStack\r | |
7459 | );\r | |
7460 | \r | |
7461 | \r | |
7462 | /**\r | |
7463 | Enables the 64-bit paging mode on the CPU.\r | |
7464 | \r | |
7465 | Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables\r | |
7466 | must be properly initialized prior to calling this service. This function\r | |
7467 | assumes the current execution mode is 32-bit protected mode with flat\r | |
7468 | descriptors. This function is only available on IA-32. After the 64-bit\r | |
7469 | paging mode is enabled, control is transferred to the function specified by\r | |
7470 | EntryPoint using the new stack specified by NewStack and passing in the\r | |
7471 | parameters specified by Context1 and Context2. Context1 and Context2 are\r | |
7472 | optional and may be 0. The function EntryPoint must never return.\r | |
7473 | \r | |
7474 | If the current execution mode is not 32-bit protected mode with flat\r | |
7475 | descriptors, then ASSERT().\r | |
7476 | If EntryPoint is 0, then ASSERT().\r | |
7477 | If NewStack is 0, then ASSERT().\r | |
7478 | \r | |
17f695ed | 7479 | @param Cs The 16-bit selector to load in the CS before EntryPoint\r |
ac644614 | 7480 | is called. The descriptor in the GDT that this selector\r |
7481 | references must be setup for long mode.\r | |
7482 | @param EntryPoint The 64-bit virtual address of the function to call with\r | |
7483 | the new stack after paging is enabled.\r | |
7484 | @param Context1 The 64-bit virtual address of the context to pass into\r | |
7485 | the EntryPoint function as the first parameter after\r | |
7486 | paging is enabled.\r | |
7487 | @param Context2 The 64-bit virtual address of the context to pass into\r | |
7488 | the EntryPoint function as the second parameter after\r | |
7489 | paging is enabled.\r | |
7490 | @param NewStack The 64-bit virtual address of the new stack to use for\r | |
7491 | the EntryPoint function after paging is enabled.\r | |
7492 | \r | |
7493 | **/\r | |
7494 | VOID\r | |
7495 | EFIAPI\r | |
7496 | AsmEnablePaging64 (\r | |
17f695ed | 7497 | IN UINT16 Cs,\r |
ac644614 | 7498 | IN UINT64 EntryPoint,\r |
7499 | IN UINT64 Context1, OPTIONAL\r | |
7500 | IN UINT64 Context2, OPTIONAL\r | |
7501 | IN UINT64 NewStack\r | |
7502 | );\r | |
7503 | \r | |
7504 | \r | |
7505 | /**\r | |
7506 | Disables the 64-bit paging mode on the CPU.\r | |
7507 | \r | |
7508 | Disables the 64-bit paging mode on the CPU and returns to 32-bit protected\r | |
7509 | mode. This function assumes the current execution mode is 64-paging mode.\r | |
030cd1a2 | 7510 | This function is only available on x64. After the 64-bit paging mode is\r |
ac644614 | 7511 | disabled, control is transferred to the function specified by EntryPoint\r |
7512 | using the new stack specified by NewStack and passing in the parameters\r | |
7513 | specified by Context1 and Context2. Context1 and Context2 are optional and\r | |
7514 | may be 0. The function EntryPoint must never return.\r | |
7515 | \r | |
7516 | If the current execution mode is not 64-bit paged mode, then ASSERT().\r | |
7517 | If EntryPoint is 0, then ASSERT().\r | |
7518 | If NewStack is 0, then ASSERT().\r | |
7519 | \r | |
17f695ed | 7520 | @param Cs The 16-bit selector to load in the CS before EntryPoint\r |
ac644614 | 7521 | is called. The descriptor in the GDT that this selector\r |
7522 | references must be setup for 32-bit protected mode.\r | |
7523 | @param EntryPoint The 64-bit virtual address of the function to call with\r | |
7524 | the new stack after paging is disabled.\r | |
7525 | @param Context1 The 64-bit virtual address of the context to pass into\r | |
7526 | the EntryPoint function as the first parameter after\r | |
7527 | paging is disabled.\r | |
7528 | @param Context2 The 64-bit virtual address of the context to pass into\r | |
7529 | the EntryPoint function as the second parameter after\r | |
7530 | paging is disabled.\r | |
7531 | @param NewStack The 64-bit virtual address of the new stack to use for\r | |
7532 | the EntryPoint function after paging is disabled.\r | |
7533 | \r | |
7534 | **/\r | |
7535 | VOID\r | |
7536 | EFIAPI\r | |
7537 | AsmDisablePaging64 (\r | |
17f695ed | 7538 | IN UINT16 Cs,\r |
ac644614 | 7539 | IN UINT32 EntryPoint,\r |
7540 | IN UINT32 Context1, OPTIONAL\r | |
7541 | IN UINT32 Context2, OPTIONAL\r | |
7542 | IN UINT32 NewStack\r | |
7543 | );\r | |
7544 | \r | |
7545 | \r | |
7546 | //\r | |
7547 | // 16-bit thunking services\r | |
7548 | //\r | |
7549 | \r | |
7550 | /**\r | |
7551 | Retrieves the properties for 16-bit thunk functions.\r | |
7552 | \r | |
7553 | Computes the size of the buffer and stack below 1MB required to use the\r | |
7554 | AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This\r | |
7555 | buffer size is returned in RealModeBufferSize, and the stack size is returned\r | |
7556 | in ExtraStackSize. If parameters are passed to the 16-bit real mode code,\r | |
7557 | then the actual minimum stack size is ExtraStackSize plus the maximum number\r | |
7558 | of bytes that need to be passed to the 16-bit real mode code.\r | |
52fa075c | 7559 | \r |
ac644614 | 7560 | If RealModeBufferSize is NULL, then ASSERT().\r |
7561 | If ExtraStackSize is NULL, then ASSERT().\r | |
7562 | \r | |
7563 | @param RealModeBufferSize A pointer to the size of the buffer below 1MB\r | |
7564 | required to use the 16-bit thunk functions.\r | |
7565 | @param ExtraStackSize A pointer to the extra size of stack below 1MB\r | |
7566 | that the 16-bit thunk functions require for\r | |
7567 | temporary storage in the transition to and from\r | |
7568 | 16-bit real mode.\r | |
7569 | \r | |
7570 | **/\r | |
7571 | VOID\r | |
7572 | EFIAPI\r | |
7573 | AsmGetThunk16Properties (\r | |
7574 | OUT UINT32 *RealModeBufferSize,\r | |
7575 | OUT UINT32 *ExtraStackSize\r | |
7576 | );\r | |
7577 | \r | |
7578 | \r | |
7579 | /**\r | |
7580 | Prepares all structures a code required to use AsmThunk16().\r | |
7581 | \r | |
7582 | Prepares all structures and code required to use AsmThunk16().\r | |
52fa075c | 7583 | \r |
8243b089 | 7584 | This interface is limited to be used in either physical mode or virtual modes with paging enabled where the\r |
7585 | virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.\r | |
ac644614 | 7586 | \r |
7587 | If ThunkContext is NULL, then ASSERT().\r | |
7588 | \r | |
7589 | @param ThunkContext A pointer to the context structure that describes the\r | |
7590 | 16-bit real mode code to call.\r | |
7591 | \r | |
7592 | **/\r | |
7593 | VOID\r | |
7594 | EFIAPI\r | |
7595 | AsmPrepareThunk16 (\r | |
1445300f | 7596 | IN OUT THUNK_CONTEXT *ThunkContext\r |
ac644614 | 7597 | );\r |
7598 | \r | |
7599 | \r | |
7600 | /**\r | |
7601 | Transfers control to a 16-bit real mode entry point and returns the results.\r | |
7602 | \r | |
7603 | Transfers control to a 16-bit real mode entry point and returns the results.\r | |
17f695ed | 7604 | AsmPrepareThunk16() must be called with ThunkContext before this function is used.\r |
7605 | This function must be called with interrupts disabled.\r | |
7606 | \r | |
7607 | The register state from the RealModeState field of ThunkContext is restored just prior \r | |
7608 | to calling the 16-bit real mode entry point. This includes the EFLAGS field of RealModeState, \r | |
7609 | which is used to set the interrupt state when a 16-bit real mode entry point is called.\r | |
7610 | Control is transferred to the 16-bit real mode entry point specified by the CS and Eip fields of RealModeState.\r | |
7611 | The stack is initialized to the SS and ESP fields of RealModeState. Any parameters passed to \r | |
7612 | the 16-bit real mode code must be populated by the caller at SS:ESP prior to calling this function. \r | |
7613 | The 16-bit real mode entry point is invoked with a 16-bit CALL FAR instruction,\r | |
7614 | so when accessing stack contents, the 16-bit real mode code must account for the 16-bit segment \r | |
7615 | and 16-bit offset of the return address that were pushed onto the stack. The 16-bit real mode entry \r | |
7616 | point must exit with a RETF instruction. The register state is captured into RealModeState immediately \r | |
7617 | after the RETF instruction is executed.\r | |
7618 | \r | |
7619 | If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts, \r | |
7620 | or any of the 16-bit real mode code makes a SW interrupt, then the caller is responsible for making sure \r | |
7621 | the IDT at address 0 is initialized to handle any HW or SW interrupts that may occur while in 16-bit real mode. \r | |
7622 | \r | |
7623 | If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts, \r | |
7624 | then the caller is responsible for making sure the 8259 PIC is in a state compatible with 16-bit real mode. \r | |
7625 | This includes the base vectors, the interrupt masks, and the edge/level trigger mode.\r | |
7626 | \r | |
7627 | If THUNK_ATTRIBUTE_BIG_REAL_MODE is set in the ThunkAttributes field of ThunkContext, then the user code \r | |
7628 | is invoked in big real mode. Otherwise, the user code is invoked in 16-bit real mode with 64KB segment limits.\r | |
7629 | \r | |
7630 | If neither THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 nor THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in \r | |
7631 | ThunkAttributes, then it is assumed that the user code did not enable the A20 mask, and no attempt is made to \r | |
7632 | disable the A20 mask.\r | |
7633 | \r | |
7634 | If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is set and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is clear in \r | |
7635 | ThunkAttributes, then attempt to use the INT 15 service to disable the A20 mask. If this INT 15 call fails, \r | |
7636 | then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.\r | |
7637 | \r | |
7638 | If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is clear and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is set in \r | |
7639 | ThunkAttributes, then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.\r | |
7640 | \r | |
ac644614 | 7641 | If ThunkContext is NULL, then ASSERT().\r |
7642 | If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().\r | |
17f695ed | 7643 | If both THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in \r |
7644 | ThunkAttributes, then ASSERT().\r | |
ac644614 | 7645 | \r |
8243b089 | 7646 | This interface is limited to be used in either physical mode or virtual modes with paging enabled where the\r |
af2dc6a7 | 7647 | virtual to physical mappings for ThunkContext.RealModeBuffer are mapped 1:1.\r |
52fa075c | 7648 | \r |
ac644614 | 7649 | @param ThunkContext A pointer to the context structure that describes the\r |
7650 | 16-bit real mode code to call.\r | |
7651 | \r | |
7652 | **/\r | |
7653 | VOID\r | |
7654 | EFIAPI\r | |
7655 | AsmThunk16 (\r | |
7656 | IN OUT THUNK_CONTEXT *ThunkContext\r | |
7657 | );\r | |
7658 | \r | |
7659 | \r | |
7660 | /**\r | |
7661 | Prepares all structures and code for a 16-bit real mode thunk, transfers\r | |
7662 | control to a 16-bit real mode entry point, and returns the results.\r | |
7663 | \r | |
7664 | Prepares all structures and code for a 16-bit real mode thunk, transfers\r | |
7665 | control to a 16-bit real mode entry point, and returns the results. If the\r | |
7666 | caller only need to perform a single 16-bit real mode thunk, then this\r | |
7667 | service should be used. If the caller intends to make more than one 16-bit\r | |
7668 | real mode thunk, then it is more efficient if AsmPrepareThunk16() is called\r | |
7669 | once and AsmThunk16() can be called for each 16-bit real mode thunk.\r | |
7670 | \r | |
8243b089 | 7671 | This interface is limited to be used in either physical mode or virtual modes with paging enabled where the\r |
7672 | virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.\r | |
52fa075c | 7673 | \r |
17f695ed | 7674 | See AsmPrepareThunk16() and AsmThunk16() for the detailed description and ASSERT() conditions.\r |
ac644614 | 7675 | \r |
7676 | @param ThunkContext A pointer to the context structure that describes the\r | |
7677 | 16-bit real mode code to call.\r | |
7678 | \r | |
7679 | **/\r | |
7680 | VOID\r | |
7681 | EFIAPI\r | |
7682 | AsmPrepareAndThunk16 (\r | |
7683 | IN OUT THUNK_CONTEXT *ThunkContext\r | |
7684 | );\r | |
7685 | \r | |
3cfc7813 QL |
7686 | /**\r |
7687 | Generates a 16-bit random number through RDRAND instruction.\r | |
7688 | \r | |
7689 | if Rand is NULL, then ASSERT().\r | |
7690 | \r | |
7691 | @param[out] Rand Buffer pointer to store the random result.\r | |
7692 | \r | |
7693 | @retval TRUE RDRAND call was successful.\r | |
7694 | @retval FALSE Failed attempts to call RDRAND.\r | |
7695 | \r | |
7696 | **/\r | |
7697 | BOOLEAN\r | |
7698 | EFIAPI\r | |
7699 | AsmRdRand16 (\r | |
7700 | OUT UINT16 *Rand\r | |
7701 | );\r | |
7702 | \r | |
7703 | /**\r | |
7704 | Generates a 32-bit random number through RDRAND instruction.\r | |
7705 | \r | |
7706 | if Rand is NULL, then ASSERT().\r | |
7707 | \r | |
7708 | @param[out] Rand Buffer pointer to store the random result.\r | |
7709 | \r | |
7710 | @retval TRUE RDRAND call was successful.\r | |
7711 | @retval FALSE Failed attempts to call RDRAND.\r | |
7712 | \r | |
7713 | **/\r | |
7714 | BOOLEAN\r | |
7715 | EFIAPI\r | |
7716 | AsmRdRand32 (\r | |
7717 | OUT UINT32 *Rand\r | |
7718 | );\r | |
7719 | \r | |
7720 | /**\r | |
7721 | Generates a 64-bit random number through RDRAND instruction.\r | |
7722 | \r | |
7723 | if Rand is NULL, then ASSERT().\r | |
7724 | \r | |
7725 | @param[out] Rand Buffer pointer to store the random result.\r | |
7726 | \r | |
7727 | @retval TRUE RDRAND call was successful.\r | |
7728 | @retval FALSE Failed attempts to call RDRAND.\r | |
7729 | \r | |
7730 | **/\r | |
7731 | BOOLEAN\r | |
7732 | EFIAPI\r | |
7733 | AsmRdRand64 (\r | |
7734 | OUT UINT64 *Rand\r | |
7735 | );\r | |
7736 | \r | |
ac644614 | 7737 | #endif\r |
e3a7917f | 7738 | #endif\r |
ac644614 | 7739 | \r |
7740 | \r |