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