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