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