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