e042ccb712641e0809b66793e3bb04b5ed610717
[mirror_edk2.git] / MdePkg / Include / Library / BaseLib.h
1 /** @file
2 Memory-only library functions with no library constructor/destructor
3
4 Copyright (c) 2006, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 Module Name: BaseLib.h
14
15 **/
16
17 #ifndef __BASE_LIB__
18 #define __BASE_LIB__
19
20 //
21 // Definitions for architecture specific types
22 // These include SPIN_LOCK and BASE_LIBRARY_JUMP_BUFFER
23 //
24
25 //
26 // SPIN_LOCK
27 //
28 typedef UINTN SPIN_LOCK;
29
30 #if defined (MDE_CPU_IA32)
31 //
32 // IA32 context buffer used by SetJump() and LongJump()
33 //
34 typedef struct {
35 UINT32 Ebx;
36 UINT32 Esi;
37 UINT32 Edi;
38 UINT32 Ebp;
39 UINT32 Esp;
40 UINT32 Eip;
41 } BASE_LIBRARY_JUMP_BUFFER;
42
43 #elif defined (MDE_CPU_IPF)
44 //
45 // IPF context buffer used by SetJump() and LongJump()
46 //
47 typedef struct {
48 UINT64 F2[2];
49 UINT64 F3[2];
50 UINT64 F4[2];
51 UINT64 F5[2];
52 UINT64 F16[2];
53 UINT64 F17[2];
54 UINT64 F18[2];
55 UINT64 F19[2];
56 UINT64 F20[2];
57 UINT64 F21[2];
58 UINT64 F22[2];
59 UINT64 F23[2];
60 UINT64 F24[2];
61 UINT64 F25[2];
62 UINT64 F26[2];
63 UINT64 F27[2];
64 UINT64 F28[2];
65 UINT64 F29[2];
66 UINT64 F30[2];
67 UINT64 F31[2];
68 UINT64 R4;
69 UINT64 R5;
70 UINT64 R6;
71 UINT64 R7;
72 UINT64 SP;
73 UINT64 BR0;
74 UINT64 BR1;
75 UINT64 BR2;
76 UINT64 BR3;
77 UINT64 BR4;
78 UINT64 BR5;
79 UINT64 InitialUNAT;
80 UINT64 AfterSpillUNAT;
81 UINT64 PFS;
82 UINT64 BSP;
83 UINT64 Predicates;
84 UINT64 LoopCount;
85 UINT64 FPSR;
86 } BASE_LIBRARY_JUMP_BUFFER;
87
88 #elif defined (MDE_CPU_X64)
89 //
90 // X64 context buffer used by SetJump() and LongJump()
91 //
92 typedef struct {
93 UINT64 Rbx;
94 UINT64 Rsp;
95 UINT64 Rbp;
96 UINT64 Rdi;
97 UINT64 Rsi;
98 UINT64 R12;
99 UINT64 R13;
100 UINT64 R14;
101 UINT64 R15;
102 UINT64 Rip;
103 } BASE_LIBRARY_JUMP_BUFFER;
104
105 #elif defined (MDE_CPU_EBC)
106 //
107 // EBC context buffer used by SetJump() and LongJump()
108 //
109 typedef struct {
110 UINT64 R0;
111 UINT64 R1;
112 UINT64 R2;
113 UINT64 R3;
114 UINT64 IP;
115 } BASE_LIBRARY_JUMP_BUFFER;
116
117 #else
118 #error Unknown Processor Type
119 #endif
120
121 //
122 // String Services
123 //
124
125 /**
126 Copies one Null-terminated Unicode string to another Null-terminated Unicode
127 string and returns the new Unicode string.
128
129 This function copies the contents of the Unicode string Source to the Unicode
130 string Destination, and returns Destination. If Source and Destination
131 overlap, then the results are undefined.
132
133 If Destination is NULL, then ASSERT().
134 If Source is NULL, then ASSERT().
135 If Source and Destination overlap, then ASSERT().
136 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
137 PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
138
139 @param Destination Pointer to a Null-terminated Unicode string.
140 @param Source Pointer to a Null-terminated Unicode string.
141
142 @return Destiantion
143
144 **/
145 CHAR16 *
146 EFIAPI
147 StrCpy (
148 OUT CHAR16 *Destination,
149 IN CONST CHAR16 *Source
150 );
151
152 /**
153 Copies one Null-terminated Unicode string with a maximum length to another
154 Null-terminated Unicode string with a maximum length and returns the new
155 Unicode string.
156
157 This function copies the contents of the Unicode string Source to the Unicode
158 string Destination, and returns Destination. At most, Length Unicode
159 characters are copied from Source to Destination. If Length is 0, then
160 Destination is returned unmodified. If Length is greater that the number of
161 Unicode characters in Source, then Destination is padded with Null Unicode
162 characters. If Source and Destination overlap, then the results are
163 undefined.
164
165 If Destination is NULL, then ASSERT().
166 If Source is NULL, then ASSERT().
167 If Source and Destination overlap, then ASSERT().
168 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
169 PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
170
171 @param Destination Pointer to a Null-terminated Unicode string.
172 @param Source Pointer to a Null-terminated Unicode string.
173 @param Length Maximum number of Unicode characters to copy.
174
175 @return Destination
176
177 **/
178 CHAR16 *
179 EFIAPI
180 StrnCpy (
181 OUT CHAR16 *Destination,
182 IN CONST CHAR16 *Source,
183 IN UINTN Length
184 );
185
186 /**
187 Returns the length of a Null-terminated Unicode string.
188
189 This function returns the number of Unicode characters in the Null-terminated
190 Unicode string specified by String.
191
192 If String is NULL, then ASSERT().
193 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
194 PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
195
196 @param String Pointer to a Null-terminated Unicode string.
197
198 @return The length of String.
199
200 **/
201 UINTN
202 EFIAPI
203 StrLen (
204 IN CONST CHAR16 *String
205 );
206
207 /**
208 Returns the size of a Null-terminated Unicode string in bytes, including the
209 Null terminator.
210
211 This function returns the size, in bytes, of the Null-terminated Unicode
212 string specified by String.
213
214 If String is NULL, then ASSERT().
215 If PcdMaximumUnicodeStringLength is not zero, and String contains more than
216 PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
217
218 @param String Pointer to a Null-terminated Unicode string.
219
220 @return The size of String.
221
222 **/
223 UINTN
224 EFIAPI
225 StrSize (
226 IN CONST CHAR16 *String
227 );
228
229 /**
230 Compares two Null-terminated Unicode strings, and returns the difference
231 between the first mismatched Unicode characters.
232
233 This function compares the Null-terminated Unicode string FirstString to the
234 Null-terminated Unicode string SecondString. If FirstString is identical to
235 SecondString, then 0 is returned. Otherwise, the value returned is the first
236 mismatched Unicode character in SecondString subtracted from the first
237 mismatched Unicode character in FirstString.
238
239 If FirstString is NULL, then ASSERT().
240 If SecondString is NULL, then ASSERT().
241 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more
242 than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
243 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more
244 than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
245
246 @param FirstString Pointer to a Null-terminated Unicode string.
247 @param SecondString Pointer to a Null-terminated Unicode string.
248
249 @retval 0 FirstString is identical to SecondString.
250 @retval !=0 FirstString is not identical to SecondString.
251
252 **/
253 INTN
254 EFIAPI
255 StrCmp (
256 IN CONST CHAR16 *FirstString,
257 IN CONST CHAR16 *SecondString
258 );
259
260 /**
261 Compares two Null-terminated Unicode strings with maximum lengths, and
262 returns the difference between the first mismatched Unicode characters.
263
264 This function compares the Null-terminated Unicode string FirstString to the
265 Null-terminated Unicode string SecondString. At most, Length Unicode
266 characters will be compared. If Length is 0, then 0 is returned. If
267 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
268 value returned is the first mismatched Unicode character in SecondString
269 subtracted from the first mismatched Unicode character in FirstString.
270
271 If FirstString is NULL, then ASSERT().
272 If SecondString is NULL, then ASSERT().
273 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more
274 than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
275 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more
276 than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
277
278 @param FirstString Pointer to a Null-terminated Unicode string.
279 @param SecondString Pointer to a Null-terminated Unicode string.
280 @param Length Maximum number of Unicode characters to compare.
281
282 @retval 0 FirstString is identical to SecondString.
283 @retval !=0 FirstString is not identical to SecondString.
284
285 **/
286 INTN
287 EFIAPI
288 StrnCmp (
289 IN CONST CHAR16 *FirstString,
290 IN CONST CHAR16 *SecondString,
291 IN UINTN Length
292 );
293
294 /**
295 Concatenates one Null-terminated Unicode string to another Null-terminated
296 Unicode string, and returns the concatenated Unicode string.
297
298 This function concatenates two Null-terminated Unicode strings. The contents
299 of Null-terminated Unicode string Source are concatenated to the end of
300 Null-terminated Unicode string Destination. The Null-terminated concatenated
301 Unicode String is returned. If Source and Destination overlap, then the
302 results are undefined.
303
304 If Destination is NULL, then ASSERT().
305 If Source is NULL, then ASSERT().
306 If Source and Destination overlap, then ASSERT().
307 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
308 than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
309 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
310 PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
311 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
312 and Source results in a Unicode string with more than
313 PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
314
315 @param Destination Pointer to a Null-terminated Unicode string.
316 @param Source Pointer to a Null-terminated Unicode string.
317
318 @return Destination
319
320 **/
321 CHAR16 *
322 EFIAPI
323 StrCat (
324 IN OUT CHAR16 *Destination,
325 IN CONST CHAR16 *Source
326 );
327
328 /**
329 Concatenates one Null-terminated Unicode string with a maximum length to the
330 end of another Null-terminated Unicode string, and returns the concatenated
331 Unicode string.
332
333 This function concatenates two Null-terminated Unicode strings. The contents
334 of Null-terminated Unicode string Source are concatenated to the end of
335 Null-terminated Unicode string Destination, and Destination is returned. At
336 most, Length Unicode characters are concatenated from Source to the end of
337 Destination, and Destination is always Null-terminated. If Length is 0, then
338 Destination is returned unmodified. If Source and Destination overlap, then
339 the results are undefined.
340
341 If Destination is NULL, then ASSERT().
342 If Source is NULL, then ASSERT().
343 If Source and Destination overlap, then ASSERT().
344 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
345 than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
346 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
347 PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
348 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
349 and Source results in a Unicode string with more than
350 PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().
351
352 @param Destination Pointer to a Null-terminated Unicode string.
353 @param Source Pointer to a Null-terminated Unicode string.
354 @param Length Maximum number of Unicode characters to concatenate from
355 Source.
356
357 @return Destination
358
359 **/
360 CHAR16 *
361 EFIAPI
362 StrnCat (
363 IN OUT CHAR16 *Destination,
364 IN CONST CHAR16 *Source,
365 IN UINTN Length
366 );
367
368 /**
369 Copies one Null-terminated ASCII string to another Null-terminated ASCII
370 string and returns the new ASCII string.
371
372 This function copies the contents of the ASCII string Source to the ASCII
373 string Destination, and returns Destination. If Source and Destination
374 overlap, then the results are undefined.
375
376 If Destination is NULL, then ASSERT().
377 If Source is NULL, then ASSERT().
378 If Source and Destination overlap, then ASSERT().
379 If PcdMaximumAsciiStringLength is not zero and Source contains more than
380 PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
381
382 @param Destination Pointer to a Null-terminated ASCII string.
383 @param Source Pointer to a Null-terminated ASCII string.
384
385 @return Destination
386
387 **/
388 CHAR8 *
389 EFIAPI
390 AsciiStrCpy (
391 OUT CHAR8 *Destination,
392 IN CONST CHAR8 *Source
393 );
394
395 /**
396 Copies one Null-terminated ASCII string with a maximum length to another
397 Null-terminated ASCII string with a maximum length and returns the new ASCII
398 string.
399
400 This function copies the contents of the ASCII string Source to the ASCII
401 string Destination, and returns Destination. At most, Length ASCII characters
402 are copied from Source to Destination. If Length is 0, then Destination is
403 returned unmodified. If Length is greater that the number of ASCII characters
404 in Source, then Destination is padded with Null ASCII characters. If Source
405 and Destination overlap, then the results are undefined.
406
407 If Destination is NULL, then ASSERT().
408 If Source is NULL, then ASSERT().
409 If Source and Destination overlap, then ASSERT().
410 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
411 PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
412
413 @param Destination Pointer to a Null-terminated ASCII string.
414 @param Source Pointer to a Null-terminated ASCII string.
415 @param Length Maximum number of ASCII characters to copy.
416
417 @return Destination
418
419 **/
420 CHAR8 *
421 EFIAPI
422 AsciiStrnCpy (
423 OUT CHAR8 *Destination,
424 IN CONST CHAR8 *Source,
425 IN UINTN Length
426 );
427
428 /**
429 Returns the length of a Null-terminated ASCII string.
430
431 This function returns the number of ASCII characters in the Null-terminated
432 ASCII string specified by String.
433
434 If String is NULL, then ASSERT().
435 If PcdMaximumAsciiStringLength is not zero and String contains more than
436 PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
437
438 @param String Pointer to a Null-terminated ASCII string.
439
440 @return The length of String.
441
442 **/
443 UINTN
444 EFIAPI
445 AsciiStrLen (
446 IN CONST CHAR8 *String
447 );
448
449 /**
450 Returns the size of a Null-terminated ASCII string in bytes, including the
451 Null terminator.
452
453 This function returns the size, in bytes, of the Null-terminated ASCII string
454 specified by String.
455
456 If String is NULL, then ASSERT().
457 If PcdMaximumAsciiStringLength is not zero and String contains more than
458 PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
459
460 @param String Pointer to a Null-terminated ASCII string.
461
462 @return The size of String.
463
464 **/
465 UINTN
466 EFIAPI
467 AsciiStrSize (
468 IN CONST CHAR8 *String
469 );
470
471 /**
472 Compares two Null-terminated ASCII strings, and returns the difference
473 between the first mismatched ASCII characters.
474
475 This function compares the Null-terminated ASCII string FirstString to the
476 Null-terminated ASCII string SecondString. If FirstString is identical to
477 SecondString, then 0 is returned. Otherwise, the value returned is the first
478 mismatched ASCII character in SecondString subtracted from the first
479 mismatched ASCII character in FirstString.
480
481 If FirstString is NULL, then ASSERT().
482 If SecondString is NULL, then ASSERT().
483 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
484 PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
485 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
486 than PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
487
488 @param FirstString Pointer to a Null-terminated ASCII string.
489 @param SecondString Pointer to a Null-terminated ASCII string.
490
491 @retval 0 FirstString is identical to SecondString.
492 @retval !=0 FirstString is not identical to SecondString.
493
494 **/
495 INTN
496 EFIAPI
497 AsciiStrCmp (
498 IN CONST CHAR8 *FirstString,
499 IN CONST CHAR8 *SecondString
500 );
501
502 /**
503 Performs a case insensitive comparison of two Null-terminated ASCII strings,
504 and returns the difference between the first mismatched ASCII characters.
505
506 This function performs a case insensitive comparison of the Null-terminated
507 ASCII string FirstString to the Null-terminated ASCII string SecondString. If
508 FirstString is identical to SecondString, then 0 is returned. Otherwise, the
509 value returned is the first mismatched lower case ASCII character in
510 SecondString subtracted from the first mismatched lower case ASCII character
511 in FirstString.
512
513 If FirstString is NULL, then ASSERT().
514 If SecondString is NULL, then ASSERT().
515 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
516 PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
517 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
518 than PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
519
520 @param FirstString Pointer to a Null-terminated ASCII string.
521 @param SecondString Pointer to a Null-terminated ASCII string.
522
523 @retval 0 FirstString is identical to SecondString using case insensitive
524 comparisons.
525 @retval !=0 FirstString is not identical to SecondString using case
526 insensitive comparisons.
527
528 **/
529 INTN
530 EFIAPI
531 AsciiStriCmp (
532 IN CONST CHAR8 *FirstString,
533 IN CONST CHAR8 *SecondString
534 );
535
536 /**
537 Compares two Null-terminated ASCII strings with maximum lengths, and returns
538 the difference between the first mismatched ASCII characters.
539
540 This function compares the Null-terminated ASCII string FirstString to the
541 Null-terminated ASCII string SecondString. At most, Length ASCII characters
542 will be compared. If Length is 0, then 0 is returned. If FirstString is
543 identical to SecondString, then 0 is returned. Otherwise, the value returned
544 is the first mismatched ASCII character in SecondString subtracted from the
545 first mismatched ASCII character in FirstString.
546
547 If FirstString is NULL, then ASSERT().
548 If SecondString is NULL, then ASSERT().
549 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
550 PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
551 If PcdMaximumAsciiStringLength is not zero and SecondString contains more
552 than PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
553
554 @param FirstString Pointer to a Null-terminated ASCII string.
555 @param SecondString Pointer to a Null-terminated ASCII string.
556
557 @retval 0 FirstString is identical to SecondString.
558 @retval !=0 FirstString is not identical to SecondString.
559
560 **/
561 INTN
562 EFIAPI
563 AsciiStrnCmp (
564 IN CONST CHAR8 *FirstString,
565 IN CONST CHAR8 *SecondString,
566 IN UINTN Length
567 );
568
569 /**
570 Concatenates one Null-terminated ASCII string to another Null-terminated
571 ASCII string, and returns the concatenated ASCII string.
572
573 This function concatenates two Null-terminated ASCII strings. The contents of
574 Null-terminated ASCII string Source are concatenated to the end of Null-
575 terminated ASCII string Destination. The Null-terminated concatenated ASCII
576 String is returned.
577
578 If Destination is NULL, then ASSERT().
579 If Source is NULL, then ASSERT().
580 If PcdMaximumAsciiStringLength is not zero and Destination contains more than
581 PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
582 If PcdMaximumAsciiStringLength is not zero and Source contains more than
583 PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
584 If PcdMaximumAsciiStringLength is not zero and concatenating Destination and
585 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
586 ASCII characters, then ASSERT().
587
588 @param Destination Pointer to a Null-terminated ASCII string.
589 @param Source Pointer to a Null-terminated ASCII string.
590
591 @return Destination
592
593 **/
594 CHAR8 *
595 EFIAPI
596 AsciiStrCat (
597 IN OUT CHAR8 *Destination,
598 IN CONST CHAR8 *Source
599 );
600
601 /**
602 Concatenates one Null-terminated ASCII string with a maximum length to the
603 end of another Null-terminated ASCII string, and returns the concatenated
604 ASCII string.
605
606 This function concatenates two Null-terminated ASCII strings. The contents
607 of Null-terminated ASCII string Source are concatenated to the end of Null-
608 terminated ASCII string Destination, and Destination is returned. At most,
609 Length ASCII characters are concatenated from Source to the end of
610 Destination, and Destination is always Null-terminated. If Length is 0, then
611 Destination is returned unmodified. If Source and Destination overlap, then
612 the results are undefined.
613
614 If Destination is NULL, then ASSERT().
615 If Source is NULL, then ASSERT().
616 If Source and Destination overlap, then ASSERT().
617 If PcdMaximumAsciiStringLength is not zero, and Destination contains more
618 than PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
619 If PcdMaximumAsciiStringLength is not zero, and Source contains more than
620 PcdMaximumAsciiStringLength ASCII characters, then ASSERT().
621 If PcdMaximumAsciiStringLength is not zero, and concatenating Destination and
622 Source results in a ASCII string with more than PcdMaximumAsciiStringLength
623 ASCII characters, then ASSERT().
624
625 @param Destination Pointer to a Null-terminated ASCII string.
626 @param Source Pointer to a Null-terminated ASCII string.
627 @param Length Maximum number of ASCII characters to concatenate from
628 Source.
629
630 @return Destination
631
632 **/
633 CHAR8 *
634 EFIAPI
635 AsciiStrnCat (
636 IN OUT CHAR8 *Destination,
637 IN CONST CHAR8 *Source,
638 IN UINTN Length
639 );
640
641 //
642 // LIST_ENTRY definition
643 //
644 typedef struct _LIST_ENTRY LIST_ENTRY;
645
646 struct _LIST_ENTRY {
647 LIST_ENTRY *ForwardLink;
648 LIST_ENTRY *BackLink;
649 };
650
651 //
652 // Linked List Functions and Macros
653 //
654
655 /**
656 Initializes the head node of a doubly linked list that is declared as a
657 global variable in a module.
658
659 Initializes the forward and backward links of a new linked list. After
660 initializing a linked list with this macro, the other linked list functions
661 may be used to add and remove nodes from the linked list. This macro results
662 in smaller executables by initializing the linked list in the data section,
663 instead if calling the InitializeListHead() function to perform the
664 equivalent operation.
665
666 @param ListHead The head note of a list to initiailize.
667
668 **/
669 #define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&ListHead, &ListHead}
670
671 /**
672 Initializes the head node of a doubly linked list, and returns the pointer to
673 the head node of the doubly linked list.
674
675 Initializes the forward and backward links of a new linked list. After
676 initializing a linked list with this function, the other linked list
677 functions may be used to add and remove nodes from the linked list. It is up
678 to the caller of this function to allocate the memory for ListHead.
679
680 If ListHead is NULL, then ASSERT().
681
682 @param ListHead A pointer to the head node of a new doubly linked list.
683
684 @return ListHead
685
686 **/
687 LIST_ENTRY *
688 EFIAPI
689 InitializeListHead (
690 IN LIST_ENTRY *ListHead
691 );
692
693 /**
694 Adds a node to the beginning of a doubly linked list, and returns the pointer
695 to the head node of the doubly linked list.
696
697 Adds the node Entry at the beginning of the doubly linked list denoted by
698 ListHead, and returns ListHead.
699
700 If ListHead is NULL, then ASSERT().
701 If Entry is NULL, then ASSERT().
702 If ListHead was not initialized with InitializeListHead(), then ASSERT().
703 If PcdMaximumLinkedListLenth is not zero, and ListHead contains more than
704 PcdMaximumLinkedListLenth nodes, then ASSERT().
705
706 @param ListHead A pointer to the head node of a doubly linked list.
707 @param Entry A pointer to a node that is to be inserted at the beginning
708 of a doubly linked list.
709
710 @return ListHead
711
712 **/
713 LIST_ENTRY *
714 EFIAPI
715 InsertHeadList (
716 IN LIST_ENTRY *ListHead,
717 IN LIST_ENTRY *Entry
718 );
719
720 /**
721 Adds a node to the end of a doubly linked list, and returns the pointer to
722 the head node of the doubly linked list.
723
724 Adds the node Entry to the end of the doubly linked list denoted by ListHead,
725 and returns ListHead.
726
727 If ListHead is NULL, then ASSERT().
728 If Entry is NULL, then ASSERT().
729 If ListHead was not initialized with InitializeListHead(), then ASSERT().
730 If PcdMaximumLinkedListLenth is not zero, and ListHead contains more than
731 PcdMaximumLinkedListLenth nodes, then ASSERT().
732
733 @param ListHead A pointer to the head node of a doubly linked list.
734 @param Entry A pointer to a node that is to be added at the end of the
735 doubly linked list.
736
737 @return ListHead
738
739 **/
740 LIST_ENTRY *
741 EFIAPI
742 InsertTailList (
743 IN LIST_ENTRY *ListHead,
744 IN LIST_ENTRY *Entry
745 );
746
747 /**
748 Retrieves the first node of a doubly linked list.
749
750 Returns the first node of a doubly linked list. List must have been
751 initialized with InitializeListHead(). If List is empty, then NULL is
752 returned.
753
754 If List is NULL, then ASSERT().
755 If List was not initialized with InitializeListHead(), then ASSERT().
756 If PcdMaximumLinkedListLenth is not zero, and List contains more than
757 PcdMaximumLinkedListLenth nodes, then ASSERT().
758
759 @param List A pointer to the head node of a doubly linked list.
760
761 @return The first node of a doubly linked list.
762 @retval NULL The list is empty.
763
764 **/
765 LIST_ENTRY *
766 EFIAPI
767 GetFirstNode (
768 IN CONST LIST_ENTRY *List
769 );
770
771 /**
772 Retrieves the next node of a doubly linked list.
773
774 Returns the node of a doubly linked list that follows Node. List must have
775 been initialized with InitializeListHead(). If List is empty, then List is
776 returned.
777
778 If List is NULL, then ASSERT().
779 If Node is NULL, then ASSERT().
780 If List was not initialized with InitializeListHead(), then ASSERT().
781 If PcdMaximumLinkedListLenth is not zero, and List contains more than
782 PcdMaximumLinkedListLenth nodes, then ASSERT().
783 If Node is not a node in List, then ASSERT().
784
785 @param List A pointer to the head node of a doubly linked list.
786 @param Node A pointer to a node in the doubly linked list.
787
788 @return Pointer to the next node if one exists. Otherwise a null value which
789 is actually List is returned.
790
791 **/
792 LIST_ENTRY *
793 EFIAPI
794 GetNextNode (
795 IN CONST LIST_ENTRY *List,
796 IN CONST LIST_ENTRY *Node
797 );
798
799 /**
800 Checks to see if a doubly linked list is empty or not.
801
802 Checks to see if the doubly linked list is empty. If the linked list contains
803 zero nodes, this function returns TRUE. Otherwise, it returns FALSE.
804
805 If ListHead is NULL, then ASSERT().
806 If ListHead was not initialized with InitializeListHead(), then ASSERT().
807 If PcdMaximumLinkedListLenth is not zero, and List contains more than
808 PcdMaximumLinkedListLenth nodes, then ASSERT().
809
810 @param ListHead A pointer to the head node of a doubly linked list.
811
812 @retval TRUE The linked list is empty.
813 @retval FALSE The linked list is not empty.
814
815 **/
816 BOOLEAN
817 EFIAPI
818 IsListEmpty (
819 IN CONST LIST_ENTRY *ListHead
820 );
821
822 /**
823 Determines if a node in a doubly linked list is null.
824
825 Returns FALSE if Node is one of the nodes in the doubly linked list specified
826 by List. Otherwise, TRUE is returned. List must have been initialized with
827 InitializeListHead().
828
829 If List is NULL, then ASSERT().
830 If Node is NULL, then ASSERT().
831 If List was not initialized with InitializeListHead(), then ASSERT().
832 If PcdMaximumLinkedListLenth is not zero, and List contains more than
833 PcdMaximumLinkedListLenth nodes, then ASSERT().
834 If Node is not a node in List and Node is not equal to List, then ASSERT().
835
836 @param List A pointer to the head node of a doubly linked list.
837 @param Node A pointer to a node in the doubly linked list.
838
839 @retval TRUE Node is one of the nodes in the doubly linked list.
840 @retval FALSE Node is not one of the nodes in the doubly linked list.
841
842 **/
843 BOOLEAN
844 EFIAPI
845 IsNull (
846 IN CONST LIST_ENTRY *List,
847 IN CONST LIST_ENTRY *Node
848 );
849
850 /**
851 Determines if a node the last node in a doubly linked list.
852
853 Returns TRUE if Node is the last node in the doubly linked list specified by
854 List. Otherwise, FALSE is returned. List must have been initialized with
855 InitializeListHead().
856
857 If List is NULL, then ASSERT().
858 If Node is NULL, then ASSERT().
859 If List was not initialized with InitializeListHead(), then ASSERT().
860 If PcdMaximumLinkedListLenth is not zero, and List contains more than
861 PcdMaximumLinkedListLenth nodes, then ASSERT().
862 If Node is not a node in List, then ASSERT().
863
864 @param List A pointer to the head node of a doubly linked list.
865 @param Node A pointer to a node in the doubly linked list.
866
867 @retval TRUE Node is the last node in the linked list.
868 @retval FALSE Node is not the last node in the linked list.
869
870 **/
871 BOOLEAN
872 EFIAPI
873 IsNodeAtEnd (
874 IN CONST LIST_ENTRY *List,
875 IN CONST LIST_ENTRY *Node
876 );
877
878 /**
879 Swaps the location of two nodes in a doubly linked list, and returns the
880 first node after the swap.
881
882 If FirstEntry is identical to SecondEntry, then SecondEntry is returned.
883 Otherwise, the location of the FirstEntry node is swapped with the location
884 of the SecondEntry node in a doubly linked list. SecondEntry must be in the
885 same double linked list as FirstEntry and that double linked list must have
886 been initialized with InitializeListHead(). SecondEntry is returned after the
887 nodes are swapped.
888
889 If FirstEntry is NULL, then ASSERT().
890 If SecondEntry is NULL, then ASSERT().
891 If SecondEntry and FirstEntry are not in the same linked list, then ASSERT().
892 If PcdMaximumLinkedListLenth is not zero, and the linked list containing
893 FirstEntry and SecondEntry contains more than PcdMaximumLinkedListLenth
894 nodes, then ASSERT().
895
896 @param FirstEntry A pointer to a node in a linked list.
897 @param SecondEntry A pointer to another node in the same linked list.
898
899 **/
900 LIST_ENTRY *
901 EFIAPI
902 SwapListEntries (
903 IN LIST_ENTRY *FirstEntry,
904 IN LIST_ENTRY *SecondEntry
905 );
906
907 /**
908 Removes a node from a doubly linked list, and returns the node that follows
909 the removed node.
910
911 Removes the node Entry from a doubly linked list. It is up to the caller of
912 this function to release the memory used by this node if that is required. On
913 exit, the node following Entry in the doubly linked list is returned. If
914 Entry is the only node in the linked list, then the head node of the linked
915 list is returned.
916
917 If Entry is NULL, then ASSERT().
918 If Entry is the head node of an empty list, then ASSERT().
919 If PcdMaximumLinkedListLenth is not zero, and the linked list containing
920 Entry contains more than PcdMaximumLinkedListLenth nodes, then ASSERT().
921
922 @param Entry A pointer to a node in a linked list
923
924 @return Entry
925
926 **/
927 LIST_ENTRY *
928 EFIAPI
929 RemoveEntryList (
930 IN CONST LIST_ENTRY *Entry
931 );
932
933 //
934 // Math Services
935 //
936
937 /**
938 Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled
939 with zeros. The shifted value is returned.
940
941 This function shifts the 64-bit value Operand to the left by Count bits. The
942 low Count bits are set to zero. The shifted value is returned.
943
944 If Count is greater than 63, then ASSERT().
945
946 @param Operand The 64-bit operand to shift left.
947 @param Count The number of bits to shift left.
948
949 @return Operand << Count
950
951 **/
952 UINT64
953 EFIAPI
954 LShiftU64 (
955 IN UINT64 Operand,
956 IN UINTN Count
957 );
958
959 /**
960 Shifts a 64-bit integer right between 0 and 63 bits. This high bits are
961 filled with zeros. The shifted value is returned.
962
963 This function shifts the 64-bit value Operand to the right by Count bits. The
964 high Count bits are set to zero. The shifted value is returned.
965
966 If Count is greater than 63, then ASSERT().
967
968 @param Operand The 64-bit operand to shift right.
969 @param Count The number of bits to shift right.
970
971 @return Operand >> Count
972
973 **/
974 UINT64
975 EFIAPI
976 RShiftU64 (
977 IN UINT64 Operand,
978 IN UINTN Count
979 );
980
981 /**
982 Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled
983 with original integer's bit 63. The shifted value is returned.
984
985 This function shifts the 64-bit value Operand to the right by Count bits. The
986 high Count bits are set to bit 63 of Operand. The shifted value is returned.
987
988 If Count is greater than 63, then ASSERT().
989
990 @param Operand The 64-bit operand to shift right.
991 @param Count The number of bits to shift right.
992
993 @return Operand >> Count
994
995 **/
996 UINT64
997 EFIAPI
998 ARShiftU64 (
999 IN UINT64 Operand,
1000 IN UINTN Count
1001 );
1002
1003 /**
1004 Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits
1005 with the high bits that were rotated.
1006
1007 This function rotates the 32-bit value Operand to the left by Count bits. The
1008 low Count bits are fill with the high Count bits of Operand. The rotated
1009 value is returned.
1010
1011 If Count is greater than 31, then ASSERT().
1012
1013 @param Operand The 32-bit operand to rotate left.
1014 @param Count The number of bits to rotate left.
1015
1016 @return Operand <<< Count
1017
1018 **/
1019 UINT32
1020 EFIAPI
1021 LRotU32 (
1022 IN UINT32 Operand,
1023 IN UINTN Count
1024 );
1025
1026 /**
1027 Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits
1028 with the low bits that were rotated.
1029
1030 This function rotates the 32-bit value Operand to the right by Count bits.
1031 The high Count bits are fill with the low Count bits of Operand. The rotated
1032 value is returned.
1033
1034 If Count is greater than 31, then ASSERT().
1035
1036 @param Operand The 32-bit operand to rotate right.
1037 @param Count The number of bits to rotate right.
1038
1039 @return Operand >>> Count
1040
1041 **/
1042 UINT32
1043 EFIAPI
1044 RRotU32 (
1045 IN UINT32 Operand,
1046 IN UINTN Count
1047 );
1048
1049 /**
1050 Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits
1051 with the high bits that were rotated.
1052
1053 This function rotates the 64-bit value Operand to the left by Count bits. The
1054 low Count bits are fill with the high Count bits of Operand. The rotated
1055 value is returned.
1056
1057 If Count is greater than 63, then ASSERT().
1058
1059 @param Operand The 64-bit operand to rotate left.
1060 @param Count The number of bits to rotate left.
1061
1062 @return Operand <<< Count
1063
1064 **/
1065 UINT64
1066 EFIAPI
1067 LRotU64 (
1068 IN UINT64 Operand,
1069 IN UINTN Count
1070 );
1071
1072 /**
1073 Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits
1074 with the high low bits that were rotated.
1075
1076 This function rotates the 64-bit value Operand to the right by Count bits.
1077 The high Count bits are fill with the low Count bits of Operand. The rotated
1078 value is returned.
1079
1080 If Count is greater than 63, then ASSERT().
1081
1082 @param Operand The 64-bit operand to rotate right.
1083 @param Count The number of bits to rotate right.
1084
1085 @return Operand >>> Count
1086
1087 **/
1088 UINT64
1089 EFIAPI
1090 RRotU64 (
1091 IN UINT64 Operand,
1092 IN UINTN Count
1093 );
1094
1095 /**
1096 Returns the bit position of the lowest bit set in a 32-bit value.
1097
1098 This function computes the bit position of the lowest bit set in the 32-bit
1099 value specified by Operand. If Operand is zero, then -1 is returned.
1100 Otherwise, a value between 0 and 31 is returned.
1101
1102 @param Operand The 32-bit operand to evaluate.
1103
1104 @return Position of the lowest bit set in Operand if found.
1105 @retval -1 Operand is zero.
1106
1107 **/
1108 INTN
1109 EFIAPI
1110 LowBitSet32 (
1111 IN UINT32 Operand
1112 );
1113
1114 /**
1115 Returns the bit position of the lowest bit set in a 64-bit value.
1116
1117 This function computes the bit position of the lowest bit set in the 64-bit
1118 value specified by Operand. If Operand is zero, then -1 is returned.
1119 Otherwise, a value between 0 and 63 is returned.
1120
1121 @param Operand The 64-bit operand to evaluate.
1122
1123 @return Position of the lowest bit set in Operand if found.
1124 @retval -1 Operand is zero.
1125
1126 **/
1127 INTN
1128 EFIAPI
1129 LowBitSet64 (
1130 IN UINT64 Operand
1131 );
1132
1133 /**
1134 Returns the bit position of the highest bit set in a 32-bit value. Equivalent
1135 to log2(x).
1136
1137 This function computes the bit position of the highest bit set in the 32-bit
1138 value specified by Operand. If Operand is zero, then -1 is returned.
1139 Otherwise, a value between 0 and 31 is returned.
1140
1141 @param Operand The 32-bit operand to evaluate.
1142
1143 @return Position of the highest bit set in Operand if found.
1144 @retval -1 Operand is zero.
1145
1146 **/
1147 INTN
1148 EFIAPI
1149 HighBitSet32 (
1150 IN UINT32 Operand
1151 );
1152
1153 /**
1154 Returns the bit position of the highest bit set in a 64-bit value. Equivalent
1155 to log2(x).
1156
1157 This function computes the bit position of the highest bit set in the 64-bit
1158 value specified by Operand. If Operand is zero, then -1 is returned.
1159 Otherwise, a value between 0 and 63 is returned.
1160
1161 @param Operand The 64-bit operand to evaluate.
1162
1163 @return Position of the highest bit set in Operand if found.
1164 @retval -1 Operand is zero.
1165
1166 **/
1167 INTN
1168 EFIAPI
1169 HighBitSet64 (
1170 IN UINT64 Operand
1171 );
1172
1173 /**
1174 Returns the value of the highest bit set in a 32-bit value. Equivalent to
1175 1 << HighBitSet32(x).
1176
1177 This function computes the value of the highest bit set in the 32-bit value
1178 specified by Operand. If Operand is zero, then zero is returned.
1179
1180 @param Operand The 32-bit operand to evaluate.
1181
1182 @return 1 << HighBitSet32(Operand)
1183 @retval 0 Operand is zero.
1184
1185 **/
1186 UINT32
1187 EFIAPI
1188 GetPowerOfTwo32 (
1189 IN UINT32 Operand
1190 );
1191
1192 /**
1193 Returns the value of the highest bit set in a 64-bit value. Equivalent to
1194 1 << HighBitSet64(x).
1195
1196 This function computes the value of the highest bit set in the 64-bit value
1197 specified by Operand. If Operand is zero, then zero is returned.
1198
1199 @param Operand The 64-bit operand to evaluate.
1200
1201 @return 1 << HighBitSet64(Operand)
1202 @retval 0 Operand is zero.
1203
1204 **/
1205 UINT64
1206 EFIAPI
1207 GetPowerOfTwo64 (
1208 IN UINT64 Operand
1209 );
1210
1211 /**
1212 Switches the endianess of a 16-bit integer.
1213
1214 This function swaps the bytes in a 16-bit unsigned value to switch the value
1215 from little endian to big endian or vice versa. The byte swapped value is
1216 returned.
1217
1218 @param Operand A 16-bit unsigned value.
1219
1220 @return The byte swaped Operand.
1221
1222 **/
1223 UINT16
1224 EFIAPI
1225 SwapBytes16 (
1226 IN UINT16 Value
1227 );
1228
1229 /**
1230 Switches the endianess of a 32-bit integer.
1231
1232 This function swaps the bytes in a 32-bit unsigned value to switch the value
1233 from little endian to big endian or vice versa. The byte swapped value is
1234 returned.
1235
1236 @param Operand A 32-bit unsigned value.
1237
1238 @return The byte swaped Operand.
1239
1240 **/
1241 UINT32
1242 EFIAPI
1243 SwapBytes32 (
1244 IN UINT32 Value
1245 );
1246
1247 /**
1248 Switches the endianess of a 64-bit integer.
1249
1250 This function swaps the bytes in a 64-bit unsigned value to switch the value
1251 from little endian to big endian or vice versa. The byte swapped value is
1252 returned.
1253
1254 @param Operand A 64-bit unsigned value.
1255
1256 @return The byte swaped Operand.
1257
1258 **/
1259 UINT64
1260 EFIAPI
1261 SwapBytes64 (
1262 IN UINT64 Value
1263 );
1264
1265 /**
1266 Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and
1267 generates a 64-bit unsigned result.
1268
1269 This function multiples the 64-bit unsigned value Multiplicand by the 32-bit
1270 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
1271 bit unsigned result is returned.
1272
1273 If the result overflows, then ASSERT().
1274
1275 @param Multiplicand A 64-bit unsigned value.
1276 @param Multiplier A 32-bit unsigned value.
1277
1278 @return Multiplicand * Multiplier
1279
1280 **/
1281 UINT64
1282 EFIAPI
1283 MultU64x32 (
1284 IN UINT64 Multiplicand,
1285 IN UINT32 Multiplier
1286 );
1287
1288 /**
1289 Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and
1290 generates a 64-bit unsigned result.
1291
1292 This function multiples the 64-bit unsigned value Multiplicand by the 64-bit
1293 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
1294 bit unsigned result is returned.
1295
1296 If the result overflows, then ASSERT().
1297
1298 @param Multiplicand A 64-bit unsigned value.
1299 @param Multiplier A 64-bit unsigned value.
1300
1301 @return Multiplicand * Multiplier
1302
1303 **/
1304 UINT64
1305 EFIAPI
1306 MultU64x64 (
1307 IN UINT64 Multiplicand,
1308 IN UINT64 Multiplier
1309 );
1310
1311 /**
1312 Multiples a 64-bit signed integer by a 64-bit signed integer and generates a
1313 64-bit signed result.
1314
1315 This function multiples the 64-bit signed value Multiplicand by the 64-bit
1316 signed value Multiplier and generates a 64-bit signed result. This 64-bit
1317 signed result is returned.
1318
1319 If the result overflows, then ASSERT().
1320
1321 @param Multiplicand A 64-bit signed value.
1322 @param Multiplier A 64-bit signed value.
1323
1324 @return Multiplicand * Multiplier
1325
1326 **/
1327 INT64
1328 EFIAPI
1329 MultS64x64 (
1330 IN INT64 Multiplicand,
1331 IN INT64 Multiplier
1332 );
1333
1334 /**
1335 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
1336 a 64-bit unsigned result.
1337
1338 This function divides the 64-bit unsigned value Dividend by the 32-bit
1339 unsigned value Divisor and generates a 64-bit unsigned quotient. This
1340 function returns the 64-bit unsigned quotient.
1341
1342 If Divisor is 0, then ASSERT().
1343
1344 @param Dividend A 64-bit unsigned value.
1345 @param Divisor A 32-bit unsigned value.
1346
1347 @return Dividend / Divisor
1348
1349 **/
1350 UINT64
1351 EFIAPI
1352 DivU64x32 (
1353 IN UINT64 Dividend,
1354 IN UINT32 Divisor
1355 );
1356
1357 /**
1358 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
1359 a 32-bit unsigned remainder.
1360
1361 This function divides the 64-bit unsigned value Dividend by the 32-bit
1362 unsigned value Divisor and generates a 32-bit remainder. This function
1363 returns the 32-bit unsigned remainder.
1364
1365 If Divisor is 0, then ASSERT().
1366
1367 @param Dividend A 64-bit unsigned value.
1368 @param Divisor A 32-bit unsigned value.
1369
1370 @return Dividend % Divisor
1371
1372 **/
1373 UINT32
1374 EFIAPI
1375 ModU64x32 (
1376 IN UINT64 Dividend,
1377 IN UINT32 Divisor
1378 );
1379
1380 /**
1381 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
1382 a 64-bit unsigned result and an optional 32-bit unsigned remainder.
1383
1384 This function divides the 64-bit unsigned value Dividend by the 32-bit
1385 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
1386 is not NULL, then the 32-bit unsigned remainder is returned in Remainder.
1387 This function returns the 64-bit unsigned quotient.
1388
1389 If Divisor is 0, then ASSERT().
1390
1391 @param Dividend A 64-bit unsigned value.
1392 @param Divisor A 32-bit unsigned value.
1393 @param Remainder A pointer to a 32-bit unsigned value. This parameter is
1394 optional and may be NULL.
1395
1396 @return Dividend / Divisor
1397
1398 **/
1399 UINT64
1400 EFIAPI
1401 DivU64x32Remainder (
1402 IN UINT64 Dividend,
1403 IN UINT32 Divisor,
1404 OUT UINT32 *Remainder OPTIONAL
1405 );
1406
1407 /**
1408 Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates
1409 a 64-bit unsigned result and an optional 64-bit unsigned remainder.
1410
1411 This function divides the 64-bit unsigned value Dividend by the 64-bit
1412 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
1413 is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
1414 This function returns the 64-bit unsigned quotient.
1415
1416 If Divisor is 0, then ASSERT().
1417
1418 @param Dividend A 64-bit unsigned value.
1419 @param Divisor A 64-bit unsigned value.
1420 @param Remainder A pointer to a 64-bit unsigned value. This parameter is
1421 optional and may be NULL.
1422
1423 @return Dividend / Divisor
1424
1425 **/
1426 UINT64
1427 EFIAPI
1428 DivU64x64Remainder (
1429 IN UINT64 Dividend,
1430 IN UINT64 Divisor,
1431 OUT UINT64 *Remainder OPTIONAL
1432 );
1433
1434 /**
1435 Divides a 64-bit signed integer by a 64-bit signed integer and generates a
1436 64-bit signed result and a optional 64-bit signed remainder.
1437
1438 This function divides the 64-bit signed value Dividend by the 64-bit signed
1439 value Divisor and generates a 64-bit signed quotient. If Remainder is not
1440 NULL, then the 64-bit signed remainder is returned in Remainder. This
1441 function returns the 64-bit signed quotient.
1442
1443 If Divisor is 0, then ASSERT().
1444
1445 @param Dividend A 64-bit signed value.
1446 @param Divisor A 64-bit signed value.
1447 @param Remainder A pointer to a 64-bit signed value. This parameter is
1448 optional and may be NULL.
1449
1450 @return Dividend / Divisor
1451
1452 **/
1453 INT64
1454 EFIAPI
1455 DivS64x64Remainder (
1456 IN INT64 Dividend,
1457 IN INT64 Divisor,
1458 OUT INT64 *Remainder OPTIONAL
1459 );
1460
1461 /**
1462 Reads a 16-bit value from memory that may be unaligned.
1463
1464 This function returns the 16-bit value pointed to by Buffer. The function
1465 guarantees that the read operation does not produce an alignment fault.
1466
1467 If the Buffer is NULL, then ASSERT().
1468
1469 @param Buffer Pointer to a 16-bit value that may be unaligned.
1470
1471 @return *Uint16
1472
1473 **/
1474 UINT16
1475 EFIAPI
1476 ReadUnaligned16 (
1477 IN CONST UINT16 *Uint16
1478 );
1479
1480 /**
1481 Writes a 16-bit value to memory that may be unaligned.
1482
1483 This function writes the 16-bit value specified by Value to Buffer. Value is
1484 returned. The function guarantees that the write operation does not produce
1485 an alignment fault.
1486
1487 If the Buffer is NULL, then ASSERT().
1488
1489 @param Buffer Pointer to a 16-bit value that may be unaligned.
1490 @param Value 16-bit value to write to Buffer.
1491
1492 @return Value
1493
1494 **/
1495 UINT16
1496 EFIAPI
1497 WriteUnaligned16 (
1498 OUT UINT16 *Uint16,
1499 IN UINT16 Value
1500 );
1501
1502 /**
1503 Reads a 24-bit value from memory that may be unaligned.
1504
1505 This function returns the 24-bit value pointed to by Buffer. The function
1506 guarantees that the read operation does not produce an alignment fault.
1507
1508 If the Buffer is NULL, then ASSERT().
1509
1510 @param Buffer Pointer to a 24-bit value that may be unaligned.
1511
1512 @return The value read.
1513
1514 **/
1515 UINT32
1516 EFIAPI
1517 ReadUnaligned24 (
1518 IN CONST UINT32 *Buffer
1519 );
1520
1521 /**
1522 Writes a 24-bit value to memory that may be unaligned.
1523
1524 This function writes the 24-bit value specified by Value to Buffer. Value is
1525 returned. The function guarantees that the write operation does not produce
1526 an alignment fault.
1527
1528 If the Buffer is NULL, then ASSERT().
1529
1530 @param Buffer Pointer to a 24-bit value that may be unaligned.
1531 @param Value 24-bit value to write to Buffer.
1532
1533 @return The value written.
1534
1535 **/
1536 UINT32
1537 EFIAPI
1538 WriteUnaligned24 (
1539 OUT UINT32 *Buffer,
1540 IN UINT32 Value
1541 );
1542
1543 /**
1544 Reads a 32-bit value from memory that may be unaligned.
1545
1546 This function returns the 32-bit value pointed to by Buffer. The function
1547 guarantees that the read operation does not produce an alignment fault.
1548
1549 If the Buffer is NULL, then ASSERT().
1550
1551 @param Buffer Pointer to a 32-bit value that may be unaligned.
1552
1553 @return *Uint32
1554
1555 **/
1556 UINT32
1557 EFIAPI
1558 ReadUnaligned32 (
1559 IN CONST UINT32 *Uint32
1560 );
1561
1562 /**
1563 Writes a 32-bit value to memory that may be unaligned.
1564
1565 This function writes the 32-bit value specified by Value to Buffer. Value is
1566 returned. The function guarantees that the write operation does not produce
1567 an alignment fault.
1568
1569 If the Buffer is NULL, then ASSERT().
1570
1571 @param Buffer Pointer to a 32-bit value that may be unaligned.
1572 @param Value 32-bit value to write to Buffer.
1573
1574 @return Value
1575
1576 **/
1577 UINT32
1578 EFIAPI
1579 WriteUnaligned32 (
1580 OUT UINT32 *Uint32,
1581 IN UINT32 Value
1582 );
1583
1584 /**
1585 Reads a 64-bit value from memory that may be unaligned.
1586
1587 This function returns the 64-bit value pointed to by Buffer. The function
1588 guarantees that the read operation does not produce an alignment fault.
1589
1590 If the Buffer is NULL, then ASSERT().
1591
1592 @param Buffer Pointer to a 64-bit value that may be unaligned.
1593
1594 @return *Uint64
1595
1596 **/
1597 UINT64
1598 EFIAPI
1599 ReadUnaligned64 (
1600 IN CONST UINT64 *Uint64
1601 );
1602
1603 /**
1604 Writes a 64-bit value to memory that may be unaligned.
1605
1606 This function writes the 64-bit value specified by Value to Buffer. Value is
1607 returned. The function guarantees that the write operation does not produce
1608 an alignment fault.
1609
1610 If the Buffer is NULL, then ASSERT().
1611
1612 @param Buffer Pointer to a 64-bit value that may be unaligned.
1613 @param Value 64-bit value to write to Buffer.
1614
1615 @return Value
1616
1617 **/
1618 UINT64
1619 EFIAPI
1620 WriteUnaligned64 (
1621 OUT UINT64 *Uint64,
1622 IN UINT64 Value
1623 );
1624
1625 //
1626 // Bit Field Functions
1627 //
1628
1629 /**
1630 Returns a bit field from an 8-bit value.
1631
1632 Returns the bitfield specified by the StartBit and the EndBit from Operand.
1633
1634 If 8-bit operations are not supported, then ASSERT().
1635 If StartBit is greater than 7, then ASSERT().
1636 If EndBit is greater than 7, then ASSERT().
1637 If EndBit is less than or equal to StartBit, then ASSERT().
1638
1639 @param Operand Operand on which to perform the bitfield operation.
1640 @param StartBit The ordinal of the least significant bit in the bit field.
1641 Range 0..7.
1642 @param EndBit The ordinal of the most significant bit in the bit field.
1643 Range 0..7.
1644
1645 @return The bit field read.
1646
1647 **/
1648 UINT8
1649 EFIAPI
1650 BitFieldRead8 (
1651 IN UINT8 Operand,
1652 IN UINTN StartBit,
1653 IN UINTN EndBit
1654 );
1655
1656 /**
1657 Writes a bit field to an 8-bit value, and returns the result.
1658
1659 Writes Value to the bit field specified by the StartBit and the EndBit in
1660 Operand. All other bits in Operand are preserved. The new 8-bit value is
1661 returned.
1662
1663 If 8-bit operations are not supported, then ASSERT().
1664 If StartBit is greater than 7, then ASSERT().
1665 If EndBit is greater than 7, then ASSERT().
1666 If EndBit is less than or equal to StartBit, then ASSERT().
1667
1668 @param Operand Operand on which to perform the bitfield operation.
1669 @param StartBit The ordinal of the least significant bit in the bit field.
1670 Range 0..7.
1671 @param EndBit The ordinal of the most significant bit in the bit field.
1672 Range 0..7.
1673 @param Value New value of the bit field.
1674
1675 @return The new 8-bit value.
1676
1677 **/
1678 UINT8
1679 EFIAPI
1680 BitFieldWrite8 (
1681 IN UINT8 Operand,
1682 IN UINTN StartBit,
1683 IN UINTN EndBit,
1684 IN UINT8 Value
1685 );
1686
1687 /**
1688 Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the
1689 result.
1690
1691 Performs a bitwise inclusive OR between the bit field specified by StartBit
1692 and EndBit in Operand and the value specified by OrData. All other bits in
1693 Operand are preserved. The new 8-bit value is returned.
1694
1695 If 8-bit operations are not supported, then ASSERT().
1696 If StartBit is greater than 7, then ASSERT().
1697 If EndBit is greater than 7, then ASSERT().
1698 If EndBit is less than or equal to StartBit, then ASSERT().
1699
1700 @param Operand Operand on which to perform the bitfield operation.
1701 @param StartBit The ordinal of the least significant bit in the bit field.
1702 Range 0..7.
1703 @param EndBit The ordinal of the most significant bit in the bit field.
1704 Range 0..7.
1705 @param OrData The value to OR with the read value from the value
1706
1707 @return The new 8-bit value.
1708
1709 **/
1710 UINT8
1711 EFIAPI
1712 BitFieldOr8 (
1713 IN UINT8 Operand,
1714 IN UINTN StartBit,
1715 IN UINTN EndBit,
1716 IN UINT8 OrData
1717 );
1718
1719 /**
1720 Reads a bit field from an 8-bit value, performs a bitwise AND, and returns
1721 the result.
1722
1723 Performs a bitwise AND between the bit field specified by StartBit and EndBit
1724 in Operand and the value specified by AndData. All other bits in Operand are
1725 preserved. The new 8-bit value is returned.
1726
1727 If 8-bit operations are not supported, then ASSERT().
1728 If StartBit is greater than 7, then ASSERT().
1729 If EndBit is greater than 7, then ASSERT().
1730 If EndBit is less than or equal to StartBit, then ASSERT().
1731
1732 @param Operand Operand on which to perform the bitfield operation.
1733 @param StartBit The ordinal of the least significant bit in the bit field.
1734 Range 0..7.
1735 @param EndBit The ordinal of the most significant bit in the bit field.
1736 Range 0..7.
1737 @param AndData The value to AND with the read value from the value.
1738
1739 @return The new 8-bit value.
1740
1741 **/
1742 UINT8
1743 EFIAPI
1744 BitFieldAnd8 (
1745 IN UINT8 Operand,
1746 IN UINTN StartBit,
1747 IN UINTN EndBit,
1748 IN UINT8 AndData
1749 );
1750
1751 /**
1752 Reads a bit field from an 8-bit value, performs a bitwise AND followed by a
1753 bitwise OR, and returns the result.
1754
1755 Performs a bitwise AND between the bit field specified by StartBit and EndBit
1756 in Operand and the value specified by AndData, followed by a bitwise
1757 inclusive OR with value specified by OrData. All other bits in Operand are
1758 preserved. The new 8-bit value is returned.
1759
1760 If 8-bit operations are not supported, then ASSERT().
1761 If StartBit is greater than 7, then ASSERT().
1762 If EndBit is greater than 7, then ASSERT().
1763 If EndBit is less than or equal to StartBit, then ASSERT().
1764
1765 @param Operand Operand on which to perform the bitfield operation.
1766 @param StartBit The ordinal of the least significant bit in the bit field.
1767 Range 0..7.
1768 @param EndBit The ordinal of the most significant bit in the bit field.
1769 Range 0..7.
1770 @param AndData The value to AND with the read value from the value.
1771 @param OrData The value to OR with the result of the AND operation.
1772
1773 @return The new 8-bit value.
1774
1775 **/
1776 UINT8
1777 EFIAPI
1778 BitFieldAndThenOr8 (
1779 IN UINT8 Operand,
1780 IN UINTN StartBit,
1781 IN UINTN EndBit,
1782 IN UINT8 AndData,
1783 IN UINT8 OrData
1784 );
1785
1786 /**
1787 Returns a bit field from a 16-bit value.
1788
1789 Returns the bitfield specified by the StartBit and the EndBit from Operand.
1790
1791 If 16-bit operations are not supported, then ASSERT().
1792 If StartBit is greater than 15, then ASSERT().
1793 If EndBit is greater than 15, then ASSERT().
1794 If EndBit is less than or equal to StartBit, then ASSERT().
1795
1796 @param Operand Operand on which to perform the bitfield operation.
1797 @param StartBit The ordinal of the least significant bit in the bit field.
1798 Range 0..15.
1799 @param EndBit The ordinal of the most significant bit in the bit field.
1800 Range 0..15.
1801
1802 @return The bit field read.
1803
1804 **/
1805 UINT16
1806 EFIAPI
1807 BitFieldRead16 (
1808 IN UINT16 Operand,
1809 IN UINTN StartBit,
1810 IN UINTN EndBit
1811 );
1812
1813 /**
1814 Writes a bit field to a 16-bit value, and returns the result.
1815
1816 Writes Value to the bit field specified by the StartBit and the EndBit in
1817 Operand. All other bits in Operand are preserved. The new 16-bit value is
1818 returned.
1819
1820 If 16-bit operations are not supported, then ASSERT().
1821 If StartBit is greater than 15, then ASSERT().
1822 If EndBit is greater than 15, then ASSERT().
1823 If EndBit is less than or equal to StartBit, then ASSERT().
1824
1825 @param Operand Operand on which to perform the bitfield operation.
1826 @param StartBit The ordinal of the least significant bit in the bit field.
1827 Range 0..15.
1828 @param EndBit The ordinal of the most significant bit in the bit field.
1829 Range 0..15.
1830 @param Value New value of the bit field.
1831
1832 @return The new 16-bit value.
1833
1834 **/
1835 UINT16
1836 EFIAPI
1837 BitFieldWrite16 (
1838 IN UINT16 Operand,
1839 IN UINTN StartBit,
1840 IN UINTN EndBit,
1841 IN UINT16 Value
1842 );
1843
1844 /**
1845 Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the
1846 result.
1847
1848 Performs a bitwise inclusive OR between the bit field specified by StartBit
1849 and EndBit in Operand and the value specified by OrData. All other bits in
1850 Operand are preserved. The new 16-bit value is returned.
1851
1852 If 16-bit operations are not supported, then ASSERT().
1853 If StartBit is greater than 15, then ASSERT().
1854 If EndBit is greater than 15, then ASSERT().
1855 If EndBit is less than or equal to StartBit, then ASSERT().
1856
1857 @param Operand Operand on which to perform the bitfield operation.
1858 @param StartBit The ordinal of the least significant bit in the bit field.
1859 Range 0..15.
1860 @param EndBit The ordinal of the most significant bit in the bit field.
1861 Range 0..15.
1862 @param OrData The value to OR with the read value from the value
1863
1864 @return The new 16-bit value.
1865
1866 **/
1867 UINT16
1868 EFIAPI
1869 BitFieldOr16 (
1870 IN UINT16 Operand,
1871 IN UINTN StartBit,
1872 IN UINTN EndBit,
1873 IN UINT16 OrData
1874 );
1875
1876 /**
1877 Reads a bit field from a 16-bit value, performs a bitwise AND, and returns
1878 the result.
1879
1880 Performs a bitwise AND between the bit field specified by StartBit and EndBit
1881 in Operand and the value specified by AndData. All other bits in Operand are
1882 preserved. The new 16-bit value is returned.
1883
1884 If 16-bit operations are not supported, then ASSERT().
1885 If StartBit is greater than 15, then ASSERT().
1886 If EndBit is greater than 15, then ASSERT().
1887 If EndBit is less than or equal to StartBit, then ASSERT().
1888
1889 @param Operand Operand on which to perform the bitfield operation.
1890 @param StartBit The ordinal of the least significant bit in the bit field.
1891 Range 0..15.
1892 @param EndBit The ordinal of the most significant bit in the bit field.
1893 Range 0..15.
1894 @param AndData The value to AND with the read value from the value
1895
1896 @return The new 16-bit value.
1897
1898 **/
1899 UINT16
1900 EFIAPI
1901 BitFieldAnd16 (
1902 IN UINT16 Operand,
1903 IN UINTN StartBit,
1904 IN UINTN EndBit,
1905 IN UINT16 AndData
1906 );
1907
1908 /**
1909 Reads a bit field from a 16-bit value, performs a bitwise AND followed by a
1910 bitwise OR, and returns the result.
1911
1912 Performs a bitwise AND between the bit field specified by StartBit and EndBit
1913 in Operand and the value specified by AndData, followed by a bitwise
1914 inclusive OR with value specified by OrData. All other bits in Operand are
1915 preserved. The new 16-bit value is returned.
1916
1917 If 16-bit operations are not supported, then ASSERT().
1918 If StartBit is greater than 15, then ASSERT().
1919 If EndBit is greater than 15, then ASSERT().
1920 If EndBit is less than or equal to StartBit, then ASSERT().
1921
1922 @param Operand Operand on which to perform the bitfield operation.
1923 @param StartBit The ordinal of the least significant bit in the bit field.
1924 Range 0..15.
1925 @param EndBit The ordinal of the most significant bit in the bit field.
1926 Range 0..15.
1927 @param AndData The value to AND with the read value from the value.
1928 @param OrData The value to OR with the result of the AND operation.
1929
1930 @return The new 16-bit value.
1931
1932 **/
1933 UINT16
1934 EFIAPI
1935 BitFieldAndThenOr16 (
1936 IN UINT16 Operand,
1937 IN UINTN StartBit,
1938 IN UINTN EndBit,
1939 IN UINT16 AndData,
1940 IN UINT16 OrData
1941 );
1942
1943 /**
1944 Returns a bit field from a 32-bit value.
1945
1946 Returns the bitfield specified by the StartBit and the EndBit from Operand.
1947
1948 If 32-bit operations are not supported, then ASSERT().
1949 If StartBit is greater than 31, then ASSERT().
1950 If EndBit is greater than 31, then ASSERT().
1951 If EndBit is less than or equal to StartBit, then ASSERT().
1952
1953 @param Operand Operand on which to perform the bitfield operation.
1954 @param StartBit The ordinal of the least significant bit in the bit field.
1955 Range 0..31.
1956 @param EndBit The ordinal of the most significant bit in the bit field.
1957 Range 0..31.
1958
1959 @return The bit field read.
1960
1961 **/
1962 UINT32
1963 EFIAPI
1964 BitFieldRead32 (
1965 IN UINT32 Operand,
1966 IN UINTN StartBit,
1967 IN UINTN EndBit
1968 );
1969
1970 /**
1971 Writes a bit field to a 32-bit value, and returns the result.
1972
1973 Writes Value to the bit field specified by the StartBit and the EndBit in
1974 Operand. All other bits in Operand are preserved. The new 32-bit value is
1975 returned.
1976
1977 If 32-bit operations are not supported, then ASSERT().
1978 If StartBit is greater than 31, then ASSERT().
1979 If EndBit is greater than 31, then ASSERT().
1980 If EndBit is less than or equal to StartBit, then ASSERT().
1981
1982 @param Operand Operand on which to perform the bitfield operation.
1983 @param StartBit The ordinal of the least significant bit in the bit field.
1984 Range 0..31.
1985 @param EndBit The ordinal of the most significant bit in the bit field.
1986 Range 0..31.
1987 @param Value New value of the bit field.
1988
1989 @return The new 32-bit value.
1990
1991 **/
1992 UINT32
1993 EFIAPI
1994 BitFieldWrite32 (
1995 IN UINT32 Operand,
1996 IN UINTN StartBit,
1997 IN UINTN EndBit,
1998 IN UINT32 Value
1999 );
2000
2001 /**
2002 Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the
2003 result.
2004
2005 Performs a bitwise inclusive OR between the bit field specified by StartBit
2006 and EndBit in Operand and the value specified by OrData. All other bits in
2007 Operand are preserved. The new 32-bit value is returned.
2008
2009 If 32-bit operations are not supported, then ASSERT().
2010 If StartBit is greater than 31, then ASSERT().
2011 If EndBit is greater than 31, then ASSERT().
2012 If EndBit is less than or equal to StartBit, then ASSERT().
2013
2014 @param Operand Operand on which to perform the bitfield operation.
2015 @param StartBit The ordinal of the least significant bit in the bit field.
2016 Range 0..31.
2017 @param EndBit The ordinal of the most significant bit in the bit field.
2018 Range 0..31.
2019 @param OrData The value to OR with the read value from the value
2020
2021 @return The new 32-bit value.
2022
2023 **/
2024 UINT32
2025 EFIAPI
2026 BitFieldOr32 (
2027 IN UINT32 Operand,
2028 IN UINTN StartBit,
2029 IN UINTN EndBit,
2030 IN UINT32 OrData
2031 );
2032
2033 /**
2034 Reads a bit field from a 32-bit value, performs a bitwise AND, and returns
2035 the result.
2036
2037 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2038 in Operand and the value specified by AndData. All other bits in Operand are
2039 preserved. The new 32-bit value is returned.
2040
2041 If 32-bit operations are not supported, then ASSERT().
2042 If StartBit is greater than 31, then ASSERT().
2043 If EndBit is greater than 31, then ASSERT().
2044 If EndBit is less than or equal to StartBit, then ASSERT().
2045
2046 @param Operand Operand on which to perform the bitfield operation.
2047 @param StartBit The ordinal of the least significant bit in the bit field.
2048 Range 0..31.
2049 @param EndBit The ordinal of the most significant bit in the bit field.
2050 Range 0..31.
2051 @param AndData The value to AND with the read value from the value
2052
2053 @return The new 32-bit value.
2054
2055 **/
2056 UINT32
2057 EFIAPI
2058 BitFieldAnd32 (
2059 IN UINT32 Operand,
2060 IN UINTN StartBit,
2061 IN UINTN EndBit,
2062 IN UINT32 AndData
2063 );
2064
2065 /**
2066 Reads a bit field from a 32-bit value, performs a bitwise AND followed by a
2067 bitwise OR, and returns the result.
2068
2069 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2070 in Operand and the value specified by AndData, followed by a bitwise
2071 inclusive OR with value specified by OrData. All other bits in Operand are
2072 preserved. The new 32-bit value is returned.
2073
2074 If 32-bit operations are not supported, then ASSERT().
2075 If StartBit is greater than 31, then ASSERT().
2076 If EndBit is greater than 31, then ASSERT().
2077 If EndBit is less than or equal to StartBit, then ASSERT().
2078
2079 @param Operand Operand on which to perform the bitfield operation.
2080 @param StartBit The ordinal of the least significant bit in the bit field.
2081 Range 0..31.
2082 @param EndBit The ordinal of the most significant bit in the bit field.
2083 Range 0..31.
2084 @param AndData The value to AND with the read value from the value.
2085 @param OrData The value to OR with the result of the AND operation.
2086
2087 @return The new 32-bit value.
2088
2089 **/
2090 UINT32
2091 EFIAPI
2092 BitFieldAndThenOr32 (
2093 IN UINT32 Operand,
2094 IN UINTN StartBit,
2095 IN UINTN EndBit,
2096 IN UINT32 AndData,
2097 IN UINT32 OrData
2098 );
2099
2100 /**
2101 Returns a bit field from a 64-bit value.
2102
2103 Returns the bitfield specified by the StartBit and the EndBit from Operand.
2104
2105 If 64-bit operations are not supported, then ASSERT().
2106 If StartBit is greater than 63, then ASSERT().
2107 If EndBit is greater than 63, then ASSERT().
2108 If EndBit is less than or equal to StartBit, then ASSERT().
2109
2110 @param Operand Operand on which to perform the bitfield operation.
2111 @param StartBit The ordinal of the least significant bit in the bit field.
2112 Range 0..63.
2113 @param EndBit The ordinal of the most significant bit in the bit field.
2114 Range 0..63.
2115
2116 @return The bit field read.
2117
2118 **/
2119 UINT64
2120 EFIAPI
2121 BitFieldRead64 (
2122 IN UINT64 Operand,
2123 IN UINTN StartBit,
2124 IN UINTN EndBit
2125 );
2126
2127 /**
2128 Writes a bit field to a 64-bit value, and returns the result.
2129
2130 Writes Value to the bit field specified by the StartBit and the EndBit in
2131 Operand. All other bits in Operand are preserved. The new 64-bit value is
2132 returned.
2133
2134 If 64-bit operations are not supported, then ASSERT().
2135 If StartBit is greater than 63, then ASSERT().
2136 If EndBit is greater than 63, then ASSERT().
2137 If EndBit is less than or equal to StartBit, then ASSERT().
2138
2139 @param Operand Operand on which to perform the bitfield operation.
2140 @param StartBit The ordinal of the least significant bit in the bit field.
2141 Range 0..63.
2142 @param EndBit The ordinal of the most significant bit in the bit field.
2143 Range 0..63.
2144 @param Value New value of the bit field.
2145
2146 @return The new 64-bit value.
2147
2148 **/
2149 UINT64
2150 EFIAPI
2151 BitFieldWrite64 (
2152 IN UINT64 Operand,
2153 IN UINTN StartBit,
2154 IN UINTN EndBit,
2155 IN UINT64 Value
2156 );
2157
2158 /**
2159 Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the
2160 result.
2161
2162 Performs a bitwise inclusive OR between the bit field specified by StartBit
2163 and EndBit in Operand and the value specified by OrData. All other bits in
2164 Operand are preserved. The new 64-bit value is returned.
2165
2166 If 64-bit operations are not supported, then ASSERT().
2167 If StartBit is greater than 63, then ASSERT().
2168 If EndBit is greater than 63, then ASSERT().
2169 If EndBit is less than or equal to StartBit, then ASSERT().
2170
2171 @param Operand Operand on which to perform the bitfield operation.
2172 @param StartBit The ordinal of the least significant bit in the bit field.
2173 Range 0..63.
2174 @param EndBit The ordinal of the most significant bit in the bit field.
2175 Range 0..63.
2176 @param OrData The value to OR with the read value from the value
2177
2178 @return The new 64-bit value.
2179
2180 **/
2181 UINT64
2182 EFIAPI
2183 BitFieldOr64 (
2184 IN UINT64 Operand,
2185 IN UINTN StartBit,
2186 IN UINTN EndBit,
2187 IN UINT64 OrData
2188 );
2189
2190 /**
2191 Reads a bit field from a 64-bit value, performs a bitwise AND, and returns
2192 the result.
2193
2194 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2195 in Operand and the value specified by AndData. All other bits in Operand are
2196 preserved. The new 64-bit value is returned.
2197
2198 If 64-bit operations are not supported, then ASSERT().
2199 If StartBit is greater than 63, then ASSERT().
2200 If EndBit is greater than 63, then ASSERT().
2201 If EndBit is less than or equal to StartBit, then ASSERT().
2202
2203 @param Operand Operand on which to perform the bitfield operation.
2204 @param StartBit The ordinal of the least significant bit in the bit field.
2205 Range 0..63.
2206 @param EndBit The ordinal of the most significant bit in the bit field.
2207 Range 0..63.
2208 @param AndData The value to AND with the read value from the value
2209
2210 @return The new 64-bit value.
2211
2212 **/
2213 UINT64
2214 EFIAPI
2215 BitFieldAnd64 (
2216 IN UINT64 Operand,
2217 IN UINTN StartBit,
2218 IN UINTN EndBit,
2219 IN UINT64 AndData
2220 );
2221
2222 /**
2223 Reads a bit field from a 64-bit value, performs a bitwise AND followed by a
2224 bitwise OR, and returns the result.
2225
2226 Performs a bitwise AND between the bit field specified by StartBit and EndBit
2227 in Operand and the value specified by AndData, followed by a bitwise
2228 inclusive OR with value specified by OrData. All other bits in Operand are
2229 preserved. The new 64-bit value is returned.
2230
2231 If 64-bit operations are not supported, then ASSERT().
2232 If StartBit is greater than 63, then ASSERT().
2233 If EndBit is greater than 63, then ASSERT().
2234 If EndBit is less than or equal to StartBit, then ASSERT().
2235
2236 @param Operand Operand on which to perform the bitfield operation.
2237 @param StartBit The ordinal of the least significant bit in the bit field.
2238 Range 0..63.
2239 @param EndBit The ordinal of the most significant bit in the bit field.
2240 Range 0..63.
2241 @param AndData The value to AND with the read value from the value.
2242 @param OrData The value to OR with the result of the AND operation.
2243
2244 @return The new 64-bit value.
2245
2246 **/
2247 UINT64
2248 EFIAPI
2249 BitFieldAndThenOr64 (
2250 IN UINT64 Operand,
2251 IN UINTN StartBit,
2252 IN UINTN EndBit,
2253 IN UINT64 AndData,
2254 IN UINT64 OrData
2255 );
2256
2257 //
2258 // Base Library Synchronization Functions
2259 //
2260
2261 /**
2262 Retrieves the architecture specific spin lock alignment requirements for
2263 optimal spin lock performance.
2264
2265 This function retrieves the spin lock alignment requirements for optimal
2266 performance on a given CPU architecture. The spin lock alignment must be a
2267 power of two and is returned by this function. If there are no alignment
2268 requirements, then 1 must be returned. The spin lock synchronization
2269 functions must function correctly if the spin lock size and alignment values
2270 returned by this function are not used at all. These values are hints to the
2271 consumers of the spin lock synchronization functions to obtain optimal spin
2272 lock performance.
2273
2274 @return The architecture specific spin lock alignment.
2275
2276 **/
2277 UINTN
2278 EFIAPI
2279 GetSpinLockProperties (
2280 VOID
2281 );
2282
2283 /**
2284 Initializes a spin lock to the released state and returns the spin lock.
2285
2286 This function initializes the spin lock specified by SpinLock to the released
2287 state, and returns SpinLock. Optimal performance can be achieved by calling
2288 GetSpinLockProperties() to determine the size and alignment requirements for
2289 SpinLock.
2290
2291 If SpinLock is NULL, then ASSERT().
2292
2293 @param SpinLock A pointer to the spin lock to initialize to the released
2294 state.
2295
2296 @return SpinLock
2297
2298 **/
2299 SPIN_LOCK *
2300 EFIAPI
2301 InitializeSpinLock (
2302 IN SPIN_LOCK *SpinLock
2303 );
2304
2305 /**
2306 Waits until a spin lock can be placed in the acquired state.
2307
2308 This function checks the state of the spin lock specified by SpinLock. If
2309 SpinLock is in the released state, then this function places SpinLock in the
2310 acquired state and returns SpinLock. Otherwise, this function waits
2311 indefinitely for the spin lock to be released, and then places it in the
2312 acquired state and returns SpinLock. All state transitions of SpinLock must
2313 be performed using MP safe mechanisms.
2314
2315 If SpinLock is NULL, then ASSERT().
2316 If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().
2317 If PcdSpinLockTimeout is not zero, and SpinLock is can not be acquired in
2318 PcdSpinLockTimeout microseconds, then ASSERT().
2319
2320 @param SpinLock A pointer to the spin lock to place in the acquired state.
2321
2322 @return SpinLock
2323
2324 **/
2325 SPIN_LOCK *
2326 EFIAPI
2327 AcquireSpinLock (
2328 IN SPIN_LOCK *SpinLock
2329 );
2330
2331 /**
2332 Attempts to place a spin lock in the acquired state.
2333
2334 This function checks the state of the spin lock specified by SpinLock. If
2335 SpinLock is in the released state, then this function places SpinLock in the
2336 acquired state and returns TRUE. Otherwise, FALSE is returned. All state
2337 transitions of SpinLock must be performed using MP safe mechanisms.
2338
2339 If SpinLock is NULL, then ASSERT().
2340 If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().
2341
2342 @param SpinLock A pointer to the spin lock to place in the acquired state.
2343
2344 @retval TRUE SpinLock was placed in the acquired state.
2345 @retval FALSE SpinLock could not be acquired.
2346
2347 **/
2348 BOOLEAN
2349 EFIAPI
2350 AcquireSpinLockOrFail (
2351 IN SPIN_LOCK *SpinLock
2352 );
2353
2354 /**
2355 Releases a spin lock.
2356
2357 This function places the spin lock specified by SpinLock in the release state
2358 and returns SpinLock.
2359
2360 If SpinLock is NULL, then ASSERT().
2361 If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().
2362
2363 @param SpinLock A pointer to the spin lock to release.
2364
2365 @return SpinLock
2366
2367 **/
2368 SPIN_LOCK *
2369 EFIAPI
2370 ReleaseSpinLock (
2371 IN SPIN_LOCK *SpinLock
2372 );
2373
2374 /**
2375 Performs an atomic increment of an 32-bit unsigned integer.
2376
2377 Performs an atomic increment of the 32-bit unsigned integer specified by
2378 Value and returns the incremented value. The increment operation must be
2379 performed using MP safe mechanisms. The state of the return value is not
2380 guaranteed to be MP safe.
2381
2382 If Value is NULL, then ASSERT().
2383
2384 @param Value A pointer to the 32-bit value to increment.
2385
2386 @return The incremented value.
2387
2388 **/
2389 UINT32
2390 EFIAPI
2391 InterlockedIncrement (
2392 IN UINT32 *Value
2393 );
2394
2395 /**
2396 Performs an atomic decrement of an 32-bit unsigned integer.
2397
2398 Performs an atomic decrement of the 32-bit unsigned integer specified by
2399 Value and returns the decremented value. The decrement operation must be
2400 performed using MP safe mechanisms. The state of the return value is not
2401 guaranteed to be MP safe.
2402
2403 If Value is NULL, then ASSERT().
2404
2405 @param Value A pointer to the 32-bit value to decrement.
2406
2407 @return The decremented value.
2408
2409 **/
2410 UINT32
2411 EFIAPI
2412 InterlockedDecrement (
2413 IN UINT32 *Value
2414 );
2415
2416 /**
2417 Performs an atomic compare exchange operation on a 32-bit unsigned integer.
2418
2419 @param Value A pointer to the 32-bit value for the compare exchange
2420 operation.
2421 @param CompareValue 32-bit value used in compare operation.
2422 @param ExchangeValue 32-bit value used in exchange operation.
2423
2424 @return The original *Value before exchange.
2425
2426 **/
2427 UINT32
2428 EFIAPI
2429 InterlockedCompareExchange32 (
2430 IN UINT32 *Value,
2431 IN UINT32 CompareValue,
2432 IN UINT32 ExchangeValue
2433 );
2434
2435 /**
2436 Performs an atomic compare exchange operation on a 64-bit unsigned integer.
2437
2438 @param Value A pointer to the 64-bit value for the compare exchange
2439 operation.
2440 @param CompareValue 64-bit value used in compare operation.
2441 @param ExchangeValue 64-bit value used in exchange operation.
2442
2443 @return The original *Value before exchange.
2444
2445 **/
2446 UINT64
2447 EFIAPI
2448 InterlockedCompareExchange64 (
2449 IN UINT64 *Value,
2450 IN UINT64 CompareValue,
2451 IN UINT64 ExchangeValue
2452 );
2453
2454 /**
2455 Performs an atomic compare exchange operation on a pointer value.
2456
2457 Performs an atomic compare exchange operation on the pointer value specified
2458 by Value. If Value is equal to CompareValue, then Value is set to
2459 ExchangeValue and CompareValue is returned. If Value is not equal to
2460 CompareValue, then Value is returned. The compare exchange operation must be
2461 performed using MP safe mechanisms.
2462
2463 If Value is NULL, then ASSERT().
2464
2465 @param Value A pointer to the pointer value for the compare exchange
2466 operation.
2467 @param CompareValue Pointer value used in compare operation.
2468 @param ExchangeValue Pointer value used in exchange operation.
2469
2470 **/
2471 VOID *
2472 EFIAPI
2473 InterlockedCompareExchangePointer (
2474 IN VOID **Value,
2475 IN VOID *CompareValue,
2476 IN VOID *ExchangeValue
2477 );
2478
2479 //
2480 // Base Library CPU Functions
2481 //
2482 typedef
2483 VOID
2484 (EFIAPI *SWITCH_STACK_ENTRY_POINT) (
2485 IN VOID *Context1, OPTIONAL
2486 IN VOID *Context2 OPTIONAL
2487 );
2488
2489 /**
2490 Used to serialize load and store operations.
2491
2492 All loads and stores that proceed calls to this function are guaranteed to be
2493 globally visible when this function returns.
2494
2495 **/
2496 VOID
2497 EFIAPI
2498 MemoryFence (
2499 VOID
2500 );
2501
2502 /**
2503 Saves the current CPU context that can be restored with a call to LongJump()
2504 and returns 0.
2505
2506 Saves the current CPU context in the buffer specified by JumpBuffer and
2507 returns 0. The initial call to SetJump() must always return 0. Subsequent
2508 calls to LongJump() cause a non-zero value to be returned by SetJump().
2509
2510 If JumpBuffer is NULL, then ASSERT().
2511
2512 @param JumpBuffer A pointer to CPU context buffer.
2513
2514 @retval 0 Indicates a return from SetJump().
2515
2516 **/
2517 UINTN
2518 EFIAPI
2519 SetJump (
2520 OUT BASE_LIBRARY_JUMP_BUFFER *JumpBuffer
2521 );
2522
2523 /**
2524 Restores the CPU context that was saved with SetJump().
2525
2526 Restores the CPU context from the buffer specified by JumpBuffer. This
2527 function never returns to the caller. Instead is resumes execution based on
2528 the state of JumpBuffer.
2529
2530 If JumpBuffer is NULL, then ASSERT().
2531 If Value is 0, then ASSERT().
2532
2533 @param JumpBuffer A pointer to CPU context buffer.
2534 @param Value The value to return when the SetJump() context is
2535 restored and must be non-zero.
2536
2537 **/
2538 VOID
2539 EFIAPI
2540 LongJump (
2541 IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer,
2542 IN UINTN Value
2543 );
2544
2545 /**
2546 Enables CPU interrupts.
2547
2548 Enables CPU interrupts.
2549
2550 **/
2551 VOID
2552 EFIAPI
2553 EnableInterrupts (
2554 VOID
2555 );
2556
2557 /**
2558 Disables CPU interrupts.
2559
2560 Disables CPU interrupts.
2561
2562 **/
2563 VOID
2564 EFIAPI
2565 DisableInterrupts (
2566 VOID
2567 );
2568
2569 /**
2570 Disables CPU interrupts and returns the interrupt state prior to the disable
2571 operation.
2572
2573 Disables CPU interrupts and returns the interrupt state prior to the disable
2574 operation.
2575
2576 @retval TRUE CPU interrupts were enabled on entry to this call.
2577 @retval FALSE CPU interrupts were disabled on entry to this call.
2578
2579 **/
2580 BOOLEAN
2581 EFIAPI
2582 SaveAndDisableInterrupts (
2583 VOID
2584 );
2585
2586 /**
2587 Enables CPU interrupts for the smallest window required to capture any
2588 pending interrupts.
2589
2590 Enables CPU interrupts for the smallest window required to capture any
2591 pending interrupts.
2592
2593 **/
2594 VOID
2595 EFIAPI
2596 EnableDisableInterrupts (
2597 VOID
2598 );
2599
2600 /**
2601 Retrieves the current CPU interrupt state.
2602
2603 Retrieves the current CPU interrupt state. Returns TRUE is interrupts are
2604 currently enabled. Otherwise returns FALSE.
2605
2606 @retval TRUE CPU interrupts are enabled.
2607 @retval FALSE CPU interrupts are disabled.
2608
2609 **/
2610 BOOLEAN
2611 EFIAPI
2612 GetInterruptState (
2613 VOID
2614 );
2615
2616 /**
2617 Set the current CPU interrupt state.
2618
2619 Sets the current CPU interrupt state to the state specified by
2620 InterruptState. If InterruptState is TRUE, then interrupts are enabled. If
2621 InterruptState is FALSE, then interrupts are disabled. InterruptState is
2622 returned.
2623
2624 @param InterruptState TRUE if interrupts should enabled. FALSE if
2625 interrupts should be disabled.
2626
2627 @return InterruptState
2628
2629 **/
2630 BOOLEAN
2631 EFIAPI
2632 SetInterruptState (
2633 IN BOOLEAN InterruptState
2634 );
2635
2636 /**
2637 Places the CPU in a sleep state until an interrupt is received.
2638
2639 Places the CPU in a sleep state until an interrupt is received. If interrupts
2640 are disabled prior to calling this function, then the CPU will be placed in a
2641 sleep state indefinitely.
2642
2643 **/
2644 VOID
2645 EFIAPI
2646 CpuSleep (
2647 VOID
2648 );
2649
2650 /**
2651 Requests CPU to pause for a short period of time.
2652
2653 Requests CPU to pause for a short period of time. Typically used in MP
2654 systems to prevent memory starvation while waiting for a spin lock.
2655
2656 **/
2657 VOID
2658 EFIAPI
2659 CpuPause (
2660 VOID
2661 );
2662
2663 /**
2664 Flushes all the Translation Lookaside Buffers(TLB) entries in a CPU.
2665
2666 Flushes all the Translation Lookaside Buffers(TLB) entries in a CPU.
2667
2668 **/
2669 VOID
2670 EFIAPI
2671 CpuFlushTlb (
2672 VOID
2673 );
2674
2675 /**
2676 Transfers control to a function starting with a new stack.
2677
2678 Transfers control to the function specified by EntryPoint using the new stack
2679 specified by NewStack and passing in the parameters specified by Context1 and
2680 Context2. Context1 and Context2 are optional and may be NULL. The function
2681 EntryPoint must never return.
2682
2683 If EntryPoint is NULL, then ASSERT().
2684 If NewStack is NULL, then ASSERT().
2685
2686 @param EntryPoint A pointer to function to call with the new stack.
2687 @param Context1 A pointer to the context to pass into the EntryPoint
2688 function.
2689 @param Context2 A pointer to the context to pass into the EntryPoint
2690 function.
2691 @param NewStack A pointer to the new stack to use for the EntryPoint
2692 function.
2693
2694 **/
2695 VOID
2696 EFIAPI
2697 SwitchStack (
2698 IN SWITCH_STACK_ENTRY_POINT EntryPoint,
2699 IN VOID *Context1, OPTIONAL
2700 IN VOID *Context2, OPTIONAL
2701 IN VOID *NewStack
2702 );
2703
2704 /**
2705 Generates a breakpoint on the CPU.
2706
2707 Generates a breakpoint on the CPU. The breakpoint must be implemented such
2708 that code can resume normal execution after the breakpoint.
2709
2710 **/
2711 VOID
2712 EFIAPI
2713 CpuBreakpoint (
2714 VOID
2715 );
2716
2717 /**
2718 Executes an infinite loop.
2719
2720 Forces the CPU to execute an infinite loop. A debugger may be used to skip
2721 past the loop and the code that follows the loop must execute properly. This
2722 implies that the infinite loop must not cause the code that follow it to be
2723 optimized away.
2724
2725 **/
2726 VOID
2727 EFIAPI
2728 CpuDeadLoop (
2729 VOID
2730 );
2731
2732 //
2733 // IA32 and X64 Specific Functions
2734 //
2735 //
2736 // Byte packed structure for 16-bit Real Mode EFLAGS
2737 //
2738 typedef union {
2739 struct {
2740 UINT32 CF:1; // Carry Flag
2741 UINT32 Reserved_0:1; // Reserved
2742 UINT32 PF:1; // Parity Flag
2743 UINT32 Reserved_1:1; // Reserved
2744 UINT32 AF:1; // Auxiliary Carry Flag
2745 UINT32 Reserved_2:1; // Reserved
2746 UINT32 ZF:1; // Zero Flag
2747 UINT32 SF:1; // Sign Flag
2748 UINT32 TF:1; // Trap Flag
2749 UINT32 IF:1; // Interrupt Enable Flag
2750 UINT32 DF:1; // Direction Flag
2751 UINT32 OF:1; // Overflow Flag
2752 UINT32 IOPL:2; // I/O Privilege Level
2753 UINT32 NT:1; // Nested Task
2754 UINT32 Reserved_3:1; // Reserved
2755 } Bits;
2756 UINT16 Uint16;
2757 } IA32_FLAGS16;
2758
2759 //
2760 // Byte packed structure for EFLAGS/RFLAGS
2761 // 32-bits on IA-32
2762 // 64-bits on X64. The upper 32-bits on X64 are reserved
2763 //
2764 typedef union {
2765 struct {
2766 UINT32 CF:1; // Carry Flag
2767 UINT32 Reserved_0:1; // Reserved
2768 UINT32 PF:1; // Parity Flag
2769 UINT32 Reserved_1:1; // Reserved
2770 UINT32 AF:1; // Auxiliary Carry Flag
2771 UINT32 Reserved_2:1; // Reserved
2772 UINT32 ZF:1; // Zero Flag
2773 UINT32 SF:1; // Sign Flag
2774 UINT32 TF:1; // Trap Flag
2775 UINT32 IF:1; // Interrupt Enable Flag
2776 UINT32 DF:1; // Direction Flag
2777 UINT32 OF:1; // Overflow Flag
2778 UINT32 IOPL:2; // I/O Privilege Level
2779 UINT32 NT:1; // Nested Task
2780 UINT32 Reserved_3:1; // Reserved
2781 UINT32 RF:1; // Resume Flag
2782 UINT32 VM:1; // Virtual 8086 Mode
2783 UINT32 AC:1; // Alignment Check
2784 UINT32 VIF:1; // Virtual Interrupt Flag
2785 UINT32 VIP:1; // Virtual Interrupt Pending
2786 UINT32 ID:1; // ID Flag
2787 UINT32 Reserved_4:10; // Reserved
2788 } Bits;
2789 UINTN UintN;
2790 } IA32_EFLAGS32;
2791
2792 //
2793 // Byte packed structure for Control Register 0 (CR0)
2794 // 32-bits on IA-32
2795 // 64-bits on X64. The upper 32-bits on X64 are reserved
2796 //
2797 typedef union {
2798 struct {
2799 UINT32 PE:1; // Protection Enable
2800 UINT32 MP:1; // Monitor Coprocessor
2801 UINT32 EM:1; // Emulation
2802 UINT32 TS:1; // Task Switched
2803 UINT32 ET:1; // Extension Type
2804 UINT32 NE:1; // Numeric Error
2805 UINT32 Reserved_0:10; // Reserved
2806 UINT32 WP:1; // Write Protect
2807 UINT32 Reserved_1:1; // Reserved
2808 UINT32 AM:1; // Alignment Mask
2809 UINT32 Reserved_2:10; // Reserved
2810 UINT32 NW:1; // Mot Write-through
2811 UINT32 CD:1; // Cache Disable
2812 UINT32 PG:1; // Paging
2813 } Bits;
2814 UINTN UintN;
2815 } IA32_CR0;
2816
2817 //
2818 // Byte packed structure for Control Register 4 (CR4)
2819 // 32-bits on IA-32
2820 // 64-bits on X64. The upper 32-bits on X64 are reserved
2821 //
2822 typedef union {
2823 struct {
2824 UINT32 VME:1; // Virtual-8086 Mode Extensions
2825 UINT32 PVI:1; // Protected-Mode Virtual Interrupts
2826 UINT32 TSD:1; // Time Stamp Disable
2827 UINT32 DE:1; // Debugging Extensions
2828 UINT32 PSE:1; // Page Size Extensions
2829 UINT32 PAE:1; // Physical Address Extension
2830 UINT32 MCE:1; // Machine Check Enable
2831 UINT32 PGE:1; // Page Global Enable
2832 UINT32 PCE:1; // Performance Monitoring Counter
2833 // Enable
2834 UINT32 OSFXSR:1; // Operating System Support for
2835 // FXSAVE and FXRSTOR instructions
2836 UINT32 OSXMMEXCPT:1; // Operating System Support for
2837 // Unmasked SIMD Floating Point
2838 // Exceptions
2839 UINT32 Reserved_0:2; // Reserved
2840 UINT32 VMXE:1; // VMX Enable
2841 UINT32 Reserved_1:18; // Reseved
2842 } Bits;
2843 UINTN UintN;
2844 } IA32_CR4;
2845
2846 //
2847 // Byte packed structure for an IDTR, GDTR, LDTR descriptor
2848 /// @bug How to make this structure byte-packed in a compiler independent way?
2849 //
2850 typedef struct {
2851 UINT16 Limit;
2852 UINTN Base;
2853 } IA32_DESCRIPTOR;
2854
2855 #define IA32_IDT_GATE_TYPE_TASK 0x85
2856 #define IA32_IDT_GATE_TYPE_INTERRUPT_16 0x86
2857 #define IA32_IDT_GATE_TYPE_TRAP_16 0x87
2858 #define IA32_IDT_GATE_TYPE_INTERRUPT_32 0x8E
2859 #define IA32_IDT_GATE_TYPE_TRAP_32 0x8F
2860
2861 //
2862 // Byte packed structure for an Interrupt Gate Descriptor
2863 //
2864 typedef union {
2865 struct {
2866 UINT32 OffsetLow:16; // Offset bits 15..0
2867 UINT32 Selector:16; // Selector
2868 UINT32 Reserved_0:8; // Reserved
2869 UINT32 GateType:8; // Gate Type. See #defines above
2870 UINT32 OffsetHigh:16; // Offset bits 31..16
2871 } Bits;
2872 UINT64 Uint64;
2873 } IA32_IDT_GATE_DESCRIPTOR;
2874
2875 //
2876 // Byte packed structure for an FP/SSE/SSE2 context
2877 //
2878 typedef struct {
2879 UINT8 Buffer[512];
2880 } IA32_FX_BUFFER;
2881
2882 //
2883 // Structures for the 16-bit real mode thunks
2884 //
2885 typedef struct {
2886 UINT32 Reserved1;
2887 UINT32 Reserved2;
2888 UINT32 Reserved3;
2889 UINT32 Reserved4;
2890 UINT8 BL;
2891 UINT8 BH;
2892 UINT16 Reserved5;
2893 UINT8 DL;
2894 UINT8 DH;
2895 UINT16 Reserved6;
2896 UINT8 CL;
2897 UINT8 CH;
2898 UINT16 Reserved7;
2899 UINT8 AL;
2900 UINT8 AH;
2901 UINT16 Reserved8;
2902 } IA32_BYTE_REGS;
2903
2904 typedef struct {
2905 UINT16 DI;
2906 UINT16 Reserved1;
2907 UINT16 SI;
2908 UINT16 Reserved2;
2909 UINT16 BP;
2910 UINT16 Reserved3;
2911 UINT16 SP;
2912 UINT16 Reserved4;
2913 UINT16 BX;
2914 UINT16 Reserved5;
2915 UINT16 DX;
2916 UINT16 Reserved6;
2917 UINT16 CX;
2918 UINT16 Reserved7;
2919 UINT16 AX;
2920 UINT16 Reserved8;
2921 } IA32_WORD_REGS;
2922
2923 typedef struct {
2924 UINT32 EDI;
2925 UINT32 ESI;
2926 UINT32 EBP;
2927 UINT32 ESP;
2928 UINT32 EBX;
2929 UINT32 EDX;
2930 UINT32 ECX;
2931 UINT32 EAX;
2932 UINT16 DS;
2933 UINT16 ES;
2934 UINT16 FS;
2935 UINT16 GS;
2936 IA32_EFLAGS32 EFLAGS;
2937 UINT32 Eip;
2938 UINT16 CS;
2939 UINT16 SS;
2940 } IA32_DWORD_REGS;
2941
2942 typedef union {
2943 IA32_DWORD_REGS E;
2944 IA32_WORD_REGS X;
2945 IA32_BYTE_REGS H;
2946 } IA32_REGISTER_SET;
2947
2948 //
2949 // Byte packed structure for an 16-bit real mode thunks
2950 //
2951 typedef struct {
2952 IA32_REGISTER_SET *RealModeState;
2953 VOID *RealModeBuffer;
2954 UINT32 RealModeBufferSize;
2955 UINT32 ThunkAttributes;
2956 } THUNK_CONTEXT;
2957
2958 #define THUNK_ATTRIBUTE_BIG_REAL_MODE 0x00000001
2959 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 0x00000002
2960 #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004
2961
2962 /**
2963 Retrieves CPUID information.
2964
2965 Executes the CPUID instruction with EAX set to the value specified by Index.
2966 This function always returns Index.
2967 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
2968 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
2969 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
2970 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
2971 This function is only available on IA-32 and X64.
2972
2973 @param Index The 32-bit value to load into EAX prior to invoking the CPUID
2974 instruction.
2975 @param Eax Pointer to the 32-bit EAX value returned by the CPUID
2976 instruction. This is an optional parameter that may be NULL.
2977 @param Ebx Pointer to the 32-bit EBX value returned by the CPUID
2978 instruction. This is an optional parameter that may be NULL.
2979 @param Ecx Pointer to the 32-bit ECX value returned by the CPUID
2980 instruction. This is an optional parameter that may be NULL.
2981 @param Edx Pointer to the 32-bit EDX value returned by the CPUID
2982 instruction. This is an optional parameter that may be NULL.
2983
2984 @return Index
2985
2986 **/
2987 UINT32
2988 EFIAPI
2989 AsmCpuid (
2990 IN UINT32 Index,
2991 OUT UINT32 *Eax, OPTIONAL
2992 OUT UINT32 *Ebx, OPTIONAL
2993 OUT UINT32 *Ecx, OPTIONAL
2994 OUT UINT32 *Edx OPTIONAL
2995 );
2996
2997 /**
2998 Returns the lower 32-bits of a Machine Specific Register(MSR).
2999
3000 Reads and returns the lower 32-bits of the MSR specified by Index.
3001 No parameter checking is performed on Index, and some Index values may cause
3002 CPU exceptions. The caller must either guarantee that Index is valid, or the
3003 caller must set up exception handlers to catch the exceptions. This function
3004 is only available on IA-32 and X64.
3005
3006 @param Index The 32-bit MSR index to read.
3007
3008 @return The lower 32 bits of the MSR identified by Index.
3009
3010 **/
3011 UINT32
3012 EFIAPI
3013 AsmReadMsr32 (
3014 IN UINT32 Index
3015 );
3016
3017 /**
3018 Zero-extend a 32-bit value and writes it to a Machine Specific Register(MSR).
3019
3020 Writes the 32-bit value specified by Value to the MSR specified by Index. The
3021 upper 32-bits of the MSR write are set to zero. The 32-bit value written to
3022 the MSR is returned. No parameter checking is performed on Index or Value,
3023 and some of these may cause CPU exceptions. The caller must either guarantee
3024 that Index and Value are valid, or the caller must establish proper exception
3025 handlers. This function is only available on IA-32 and X64.
3026
3027 @param Index The 32-bit MSR index to write.
3028 @param Value The 32-bit value to write to the MSR.
3029
3030 @return Value
3031
3032 **/
3033 UINT32
3034 EFIAPI
3035 AsmWriteMsr32 (
3036 IN UINT32 Index,
3037 IN UINT32 Value
3038 );
3039
3040 /**
3041 Reads a 64-bit MSR, performs a bitwise inclusive OR on the lower 32-bits, and
3042 writes the result back to the 64-bit MSR.
3043
3044 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
3045 between the lower 32-bits of the read result and the value specified by
3046 OrData, and writes the result to the 64-bit MSR specified by Index. The lower
3047 32-bits of the value written to the MSR is returned. No parameter checking is
3048 performed on Index or OrData, and some of these may cause CPU exceptions. The
3049 caller must either guarantee that Index and OrData are valid, or the caller
3050 must establish proper exception handlers. This function is only available on
3051 IA-32 and X64.
3052
3053 @param Index The 32-bit MSR index to write.
3054 @param OrData The value to OR with the read value from the MSR.
3055
3056 @return The lower 32-bit value written to the MSR.
3057
3058 **/
3059 UINT32
3060 EFIAPI
3061 AsmMsrOr32 (
3062 IN UINT32 Index,
3063 IN UINT32 OrData
3064 );
3065
3066 /**
3067 Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes
3068 the result back to the 64-bit MSR.
3069
3070 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
3071 lower 32-bits of the read result and the value specified by AndData, and
3072 writes the result to the 64-bit MSR specified by Index. The lower 32-bits of
3073 the value written to the MSR is returned. No parameter checking is performed
3074 on Index or AndData, and some of these may cause CPU exceptions. The caller
3075 must either guarantee that Index and AndData are valid, or the caller must
3076 establish proper exception handlers. This function is only available on IA-32
3077 and X64.
3078
3079 @param Index The 32-bit MSR index to write.
3080 @param AndData The value to AND with the read value from the MSR.
3081
3082 @return The lower 32-bit value written to the MSR.
3083
3084 **/
3085 UINT32
3086 EFIAPI
3087 AsmMsrAnd32 (
3088 IN UINT32 Index,
3089 IN UINT32 AndData
3090 );
3091
3092 /**
3093 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive OR
3094 on the lower 32-bits, and writes the result back to the 64-bit MSR.
3095
3096 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
3097 lower 32-bits of the read result and the value specified by AndData
3098 preserving the upper 32-bits, performs a bitwise inclusive OR between the
3099 result of the AND operation and the value specified by OrData, and writes the
3100 result to the 64-bit MSR specified by Address. The lower 32-bits of the value
3101 written to the MSR is returned. No parameter checking is performed on Index,
3102 AndData, or OrData, and some of these may cause CPU exceptions. The caller
3103 must either guarantee that Index, AndData, and OrData are valid, or the
3104 caller must establish proper exception handlers. This function is only
3105 available on IA-32 and X64.
3106
3107 @param Index The 32-bit MSR index to write.
3108 @param AndData The value to AND with the read value from the MSR.
3109 @param OrData The value to OR with the result of the AND operation.
3110
3111 @return The lower 32-bit value written to the MSR.
3112
3113 **/
3114 UINT32
3115 EFIAPI
3116 AsmMsrAndThenOr32 (
3117 IN UINT32 Index,
3118 IN UINT32 AndData,
3119 IN UINT32 OrData
3120 );
3121
3122 /**
3123 Reads a bit field of an MSR.
3124
3125 Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is
3126 specified by the StartBit and the EndBit. The value of the bit field is
3127 returned. The caller must either guarantee that Index is valid, or the caller
3128 must set up exception handlers to catch the exceptions. This function is only
3129 available on IA-32 and X64.
3130
3131 If StartBit is greater than 31, then ASSERT().
3132 If EndBit is greater than 31, then ASSERT().
3133 If EndBit is less than or equal to StartBit, then ASSERT().
3134
3135 @param Index The 32-bit MSR index to read.
3136 @param StartBit The ordinal of the least significant bit in the bit field.
3137 Range 0..31.
3138 @param EndBit The ordinal of the most significant bit in the bit field.
3139 Range 0..31.
3140
3141 @return The bit field read from the MSR.
3142
3143 **/
3144 UINT32
3145 EFIAPI
3146 AsmMsrBitFieldRead32 (
3147 IN UINT32 Index,
3148 IN UINTN StartBit,
3149 IN UINTN EndBit
3150 );
3151
3152 /**
3153 Writes a bit field to an MSR.
3154
3155 Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit
3156 field is specified by the StartBit and the EndBit. All other bits in the
3157 destination MSR are preserved. The lower 32-bits of the MSR written is
3158 returned. Extra left bits in Value are stripped. The caller must either
3159 guarantee that Index and the data written is valid, or the caller must set up
3160 exception handlers to catch the exceptions. This function is only available
3161 on IA-32 and X64.
3162
3163 If StartBit is greater than 31, then ASSERT().
3164 If EndBit is greater than 31, then ASSERT().
3165 If EndBit is less than or equal to StartBit, then ASSERT().
3166
3167 @param Index The 32-bit MSR index to write.
3168 @param StartBit The ordinal of the least significant bit in the bit field.
3169 Range 0..31.
3170 @param EndBit The ordinal of the most significant bit in the bit field.
3171 Range 0..31.
3172 @param Value New value of the bit field.
3173
3174 @return The lower 32-bit of the value written to the MSR.
3175
3176 **/
3177 UINT32
3178 EFIAPI
3179 AsmMsrBitFieldWrite32 (
3180 IN UINT32 Index,
3181 IN UINTN StartBit,
3182 IN UINTN EndBit,
3183 IN UINT32 Value
3184 );
3185
3186 /**
3187 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the
3188 result back to the bit field in the 64-bit MSR.
3189
3190 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
3191 between the read result and the value specified by OrData, and writes the
3192 result to the 64-bit MSR specified by Index. The lower 32-bits of the value
3193 written to the MSR are returned. Extra left bits in OrData are stripped. The
3194 caller must either guarantee that Index and the data written is valid, or
3195 the caller must set up exception handlers to catch the exceptions. This
3196 function is only available on IA-32 and X64.
3197
3198 If StartBit is greater than 31, then ASSERT().
3199 If EndBit is greater than 31, then ASSERT().
3200 If EndBit is less than or equal to StartBit, then ASSERT().
3201
3202 @param Index The 32-bit MSR index to write.
3203 @param StartBit The ordinal of the least significant bit in the bit field.
3204 Range 0..31.
3205 @param EndBit The ordinal of the most significant bit in the bit field.
3206 Range 0..31.
3207 @param OrData The value to OR with the read value from the MSR.
3208
3209 @return The lower 32-bit of the value written to the MSR.
3210
3211 **/
3212 UINT32
3213 EFIAPI
3214 AsmMsrBitFieldOr32 (
3215 IN UINT32 Index,
3216 IN UINTN StartBit,
3217 IN UINTN EndBit,
3218 IN UINT32 OrData
3219 );
3220
3221 /**
3222 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
3223 result back to the bit field in the 64-bit MSR.
3224
3225 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
3226 read result and the value specified by AndData, and writes the result to the
3227 64-bit MSR specified by Index. The lower 32-bits of the value written to the
3228 MSR are returned. Extra left bits in AndData are stripped. The caller must
3229 either guarantee that Index and the data written is valid, or the caller must
3230 set up exception handlers to catch the exceptions. This function is only
3231 available on IA-32 and X64.
3232
3233 If StartBit is greater than 31, then ASSERT().
3234 If EndBit is greater than 31, then ASSERT().
3235 If EndBit is less than or equal to StartBit, then ASSERT().
3236
3237 @param Index The 32-bit MSR index to write.
3238 @param StartBit The ordinal of the least significant bit in the bit field.
3239 Range 0..31.
3240 @param EndBit The ordinal of the most significant bit in the bit field.
3241 Range 0..31.
3242 @param AndData The value to AND with the read value from the MSR.
3243
3244 @return The lower 32-bit of the value written to the MSR.
3245
3246 **/
3247 UINT32
3248 EFIAPI
3249 AsmMsrBitFieldAnd32 (
3250 IN UINT32 Index,
3251 IN UINTN StartBit,
3252 IN UINTN EndBit,
3253 IN UINT32 AndData
3254 );
3255
3256 /**
3257 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
3258 bitwise inclusive OR, and writes the result back to the bit field in the
3259 64-bit MSR.
3260
3261 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a
3262 bitwise inclusive OR between the read result and the value specified by
3263 AndData, and writes the result to the 64-bit MSR specified by Index. The
3264 lower 32-bits of the value written to the MSR are returned. Extra left bits
3265 in both AndData and OrData are stripped. The caller must either guarantee
3266 that Index and the data written is valid, or the caller must set up exception
3267 handlers to catch the exceptions. This function is only available on IA-32
3268 and X64.
3269
3270 If StartBit is greater than 31, then ASSERT().
3271 If EndBit is greater than 31, then ASSERT().
3272 If EndBit is less than or equal to StartBit, then ASSERT().
3273
3274 @param Index The 32-bit MSR index to write.
3275 @param StartBit The ordinal of the least significant bit in the bit field.
3276 Range 0..31.
3277 @param EndBit The ordinal of the most significant bit in the bit field.
3278 Range 0..31.
3279 @param AndData The value to AND with the read value from the MSR.
3280 @param OrData The value to OR with the result of the AND operation.
3281
3282 @return The lower 32-bit of the value written to the MSR.
3283
3284 **/
3285 UINT32
3286 EFIAPI
3287 AsmMsrBitFieldAndThenOr32 (
3288 IN UINT32 Index,
3289 IN UINTN StartBit,
3290 IN UINTN EndBit,
3291 IN UINT32 AndData,
3292 IN UINT32 OrData
3293 );
3294
3295 /**
3296 Returns a 64-bit Machine Specific Register(MSR).
3297
3298 Reads and returns the 64-bit MSR specified by Index. No parameter checking is
3299 performed on Index, and some Index values may cause CPU exceptions. The
3300 caller must either guarantee that Index is valid, or the caller must set up
3301 exception handlers to catch the exceptions. This function is only available
3302 on IA-32 and X64.
3303
3304 @param Index The 32-bit MSR index to read.
3305
3306 @return The value of the MSR identified by Index.
3307
3308 **/
3309 UINT64
3310 EFIAPI
3311 AsmReadMsr64 (
3312 IN UINT32 Index
3313 );
3314
3315 /**
3316 Writes a 64-bit value to a Machine Specific Register(MSR), and returns the
3317 value.
3318
3319 Writes the 64-bit value specified by Value to the MSR specified by Index. The
3320 64-bit value written to the MSR is returned. No parameter checking is
3321 performed on Index or Value, and some of these may cause CPU exceptions. The
3322 caller must either guarantee that Index and Value are valid, or the caller
3323 must establish proper exception handlers. This function is only available on
3324 IA-32 and X64.
3325
3326 @param Index The 32-bit MSR index to write.
3327 @param Value The 64-bit value to write to the MSR.
3328
3329 @return Value
3330
3331 **/
3332 UINT64
3333 EFIAPI
3334 AsmWriteMsr64 (
3335 IN UINT32 Index,
3336 IN UINT64 Value
3337 );
3338
3339 /**
3340 Reads a 64-bit MSR, performs a bitwise inclusive OR, and writes the result
3341 back to the 64-bit MSR.
3342
3343 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
3344 between the read result and the value specified by OrData, and writes the
3345 result to the 64-bit MSR specified by Index. The value written to the MSR is
3346 returned. No parameter checking is performed on Index or OrData, and some of
3347 these may cause CPU exceptions. The caller must either guarantee that Index
3348 and OrData are valid, or the caller must establish proper exception handlers.
3349 This function is only available on IA-32 and X64.
3350
3351 @param Index The 32-bit MSR index to write.
3352 @param OrData The value to OR with the read value from the MSR.
3353
3354 @return The value written back to the MSR.
3355
3356 **/
3357 UINT64
3358 EFIAPI
3359 AsmMsrOr64 (
3360 IN UINT32 Index,
3361 IN UINT64 OrData
3362 );
3363
3364 /**
3365 Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the
3366 64-bit MSR.
3367
3368 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
3369 read result and the value specified by OrData, and writes the result to the
3370 64-bit MSR specified by Index. The value written to the MSR is returned. No
3371 parameter checking is performed on Index or OrData, and some of these may
3372 cause CPU exceptions. The caller must either guarantee that Index and OrData
3373 are valid, or the caller must establish proper exception handlers. This
3374 function is only available on IA-32 and X64.
3375
3376 @param Index The 32-bit MSR index to write.
3377 @param AndData The value to AND with the read value from the MSR.
3378
3379 @return The value written back to the MSR.
3380
3381 **/
3382 UINT64
3383 EFIAPI
3384 AsmMsrAnd64 (
3385 IN UINT32 Index,
3386 IN UINT64 AndData
3387 );
3388
3389 /**
3390 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive
3391 OR, and writes the result back to the 64-bit MSR.
3392
3393 Reads the 64-bit MSR specified by Index, performs a bitwise AND between read
3394 result and the value specified by AndData, performs a bitwise inclusive OR
3395 between the result of the AND operation and the value specified by OrData,
3396 and writes the result to the 64-bit MSR specified by Index. The value written
3397 to the MSR is returned. No parameter checking is performed on Index, AndData,
3398 or OrData, and some of these may cause CPU exceptions. The caller must either
3399 guarantee that Index, AndData, and OrData are valid, or the caller must
3400 establish proper exception handlers. This function is only available on IA-32
3401 and X64.
3402
3403 @param Index The 32-bit MSR index to write.
3404 @param AndData The value to AND with the read value from the MSR.
3405 @param OrData The value to OR with the result of the AND operation.
3406
3407 @return The value written back to the MSR.
3408
3409 **/
3410 UINT64
3411 EFIAPI
3412 AsmMsrAndThenOr64 (
3413 IN UINT32 Index,
3414 IN UINT64 AndData,
3415 IN UINT64 OrData
3416 );
3417
3418 /**
3419 Reads a bit field of an MSR.
3420
3421 Reads the bit field in the 64-bit MSR. The bit field is specified by the
3422 StartBit and the EndBit. The value of the bit field is returned. The caller
3423 must either guarantee that Index is valid, or the caller must set up
3424 exception handlers to catch the exceptions. This function is only available
3425 on IA-32 and X64.
3426
3427 If StartBit is greater than 63, then ASSERT().
3428 If EndBit is greater than 63, then ASSERT().
3429 If EndBit is less than or equal to StartBit, then ASSERT().
3430
3431 @param Index The 32-bit MSR index to read.
3432 @param StartBit The ordinal of the least significant bit in the bit field.
3433 Range 0..63.
3434 @param EndBit The ordinal of the most significant bit in the bit field.
3435 Range 0..63.
3436
3437 @return The value read from the MSR.
3438
3439 **/
3440 UINT64
3441 EFIAPI
3442 AsmMsrBitFieldRead64 (
3443 IN UINT32 Index,
3444 IN UINTN StartBit,
3445 IN UINTN EndBit
3446 );
3447
3448 /**
3449 Writes a bit field to an MSR.
3450
3451 Writes Value to a bit field in a 64-bit MSR. The bit field is specified by
3452 the StartBit and the EndBit. All other bits in the destination MSR are
3453 preserved. The MSR written is returned. Extra left bits in Value are
3454 stripped. The caller must either guarantee that Index and the data written is
3455 valid, or the caller must set up exception handlers to catch the exceptions.
3456 This function is only available on IA-32 and X64.
3457
3458 If StartBit is greater than 63, then ASSERT().
3459 If EndBit is greater than 63, then ASSERT().
3460 If EndBit is less than or equal to StartBit, then ASSERT().
3461
3462 @param Index The 32-bit MSR index to write.
3463 @param StartBit The ordinal of the least significant bit in the bit field.
3464 Range 0..63.
3465 @param EndBit The ordinal of the most significant bit in the bit field.
3466 Range 0..63.
3467 @param Value New value of the bit field.
3468
3469 @return The value written back to the MSR.
3470
3471 **/
3472 UINT64
3473 EFIAPI
3474 AsmMsrBitFieldWrite64 (
3475 IN UINT32 Index,
3476 IN UINTN StartBit,
3477 IN UINTN EndBit,
3478 IN UINT64 Value
3479 );
3480
3481 /**
3482 Reads a bit field in a 64-bit MSR, performs a bitwise inclusive OR, and
3483 writes the result back to the bit field in the 64-bit MSR.
3484
3485 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
3486 between the read result and the value specified by OrData, and writes the
3487 result to the 64-bit MSR specified by Index. The value written to the MSR is
3488 returned. Extra left bits in OrData are stripped. The caller must either
3489 guarantee that Index and the data written is valid, or the caller must set up
3490 exception handlers to catch the exceptions. This function is only available
3491 on IA-32 and X64.
3492
3493 If StartBit is greater than 63, then ASSERT().
3494 If EndBit is greater than 63, then ASSERT().
3495 If EndBit is less than or equal to StartBit, then ASSERT().
3496
3497 @param Index The 32-bit MSR index to write.
3498 @param StartBit The ordinal of the least significant bit in the bit field.
3499 Range 0..63.
3500 @param EndBit The ordinal of the most significant bit in the bit field.
3501 Range 0..63.
3502 @param OrData The value to OR with the read value from the bit field.
3503
3504 @return The value written back to the MSR.
3505
3506 **/
3507 UINT64
3508 EFIAPI
3509 AsmMsrBitFieldOr64 (
3510 IN UINT32 Index,
3511 IN UINTN StartBit,
3512 IN UINTN EndBit,
3513 IN UINT64 OrData
3514 );
3515
3516 /**
3517 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
3518 result back to the bit field in the 64-bit MSR.
3519
3520 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
3521 read result and the value specified by AndData, and writes the result to the
3522 64-bit MSR specified by Index. The value written to the MSR is returned.
3523 Extra left bits in AndData are stripped. The caller must either guarantee
3524 that Index and the data written is valid, or the caller must set up exception
3525 handlers to catch the exceptions. This function is only available on IA-32
3526 and X64.
3527
3528 If StartBit is greater than 63, then ASSERT().
3529 If EndBit is greater than 63, then ASSERT().
3530 If EndBit is less than or equal to StartBit, then ASSERT().
3531
3532 @param Index The 32-bit MSR index to write.
3533 @param StartBit The ordinal of the least significant bit in the bit field.
3534 Range 0..63.
3535 @param EndBit The ordinal of the most significant bit in the bit field.
3536 Range 0..63.
3537 @param AndData The value to AND with the read value from the bit field.
3538
3539 @return The value written back to the MSR.
3540
3541 **/
3542 UINT64
3543 EFIAPI
3544 AsmMsrBitFieldAnd64 (
3545 IN UINT32 Index,
3546 IN UINTN StartBit,
3547 IN UINTN EndBit,
3548 IN UINT64 AndData
3549 );
3550
3551 /**
3552 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
3553 bitwise inclusive OR, and writes the result back to the bit field in the
3554 64-bit MSR.
3555
3556 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by
3557 a bitwise inclusive OR between the read result and the value specified by
3558 AndData, and writes the result to the 64-bit MSR specified by Index. The
3559 value written to the MSR is returned. Extra left bits in both AndData and
3560 OrData are stripped. The caller must either guarantee that Index and the data
3561 written is valid, or the caller must set up exception handlers to catch the
3562 exceptions. This function is only available on IA-32 and X64.
3563
3564 If StartBit is greater than 63, then ASSERT().
3565 If EndBit is greater than 63, then ASSERT().
3566 If EndBit is less than or equal to StartBit, then ASSERT().
3567
3568 @param Index The 32-bit MSR index to write.
3569 @param StartBit The ordinal of the least significant bit in the bit field.
3570 Range 0..63.
3571 @param EndBit The ordinal of the most significant bit in the bit field.
3572 Range 0..63.
3573 @param AndData The value to AND with the read value from the bit field.
3574 @param OrData The value to OR with the result of the AND operation.
3575
3576 @return The value written back to the MSR.
3577
3578 **/
3579 UINT64
3580 EFIAPI
3581 AsmMsrBitFieldAndThenOr64 (
3582 IN UINT32 Index,
3583 IN UINTN StartBit,
3584 IN UINTN EndBit,
3585 IN UINT64 AndData,
3586 IN UINT64 OrData
3587 );
3588
3589 /**
3590 Reads the current value of the EFLAGS register.
3591
3592 Reads and returns the current value of the EFLAGS register. This function is
3593 only available on IA-32 and X64. This returns a 32-bit value on IA-32 and a
3594 64-bit value on X64.
3595
3596 @return EFLAGS on IA-32 or RFLAGS on X64.
3597
3598 **/
3599 UINTN
3600 EFIAPI
3601 AsmReadEflags (
3602 VOID
3603 );
3604
3605 /**
3606 Reads the current value of the Control Register 0 (CR0).
3607
3608 Reads and returns the current value of CR0. This function is only available
3609 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
3610 X64.
3611
3612 @return The value of the Control Register 0 (CR0).
3613
3614 **/
3615 UINTN
3616 EFIAPI
3617 AsmReadCr0 (
3618 VOID
3619 );
3620
3621 /**
3622 Reads the current value of the Control Register 2 (CR2).
3623
3624 Reads and returns the current value of CR2. This function is only available
3625 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
3626 X64.
3627
3628 @return The value of the Control Register 2 (CR2).
3629
3630 **/
3631 UINTN
3632 EFIAPI
3633 AsmReadCr2 (
3634 VOID
3635 );
3636
3637 /**
3638 Reads the current value of the Control Register 3 (CR3).
3639
3640 Reads and returns the current value of CR3. This function is only available
3641 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
3642 X64.
3643
3644 @return The value of the Control Register 3 (CR3).
3645
3646 **/
3647 UINTN
3648 EFIAPI
3649 AsmReadCr3 (
3650 VOID
3651 );
3652
3653 /**
3654 Reads the current value of the Control Register 4 (CR4).
3655
3656 Reads and returns the current value of CR4. This function is only available
3657 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
3658 X64.
3659
3660 @return The value of the Control Register 4 (CR4).
3661
3662 **/
3663 UINTN
3664 EFIAPI
3665 AsmReadCr4 (
3666 VOID
3667 );
3668
3669 /**
3670 Writes a value to Control Register 0 (CR0).
3671
3672 Writes and returns a new value to CR0. This function is only available on
3673 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
3674
3675 @param Cr0 The value to write to CR0.
3676
3677 @return The value written to CR0.
3678
3679 **/
3680 UINTN
3681 EFIAPI
3682 AsmWriteCr0 (
3683 UINTN Cr0
3684 );
3685
3686 /**
3687 Writes a value to Control Register 2 (CR2).
3688
3689 Writes and returns a new value to CR2. This function is only available on
3690 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
3691
3692 @param Cr2 The value to write to CR2.
3693
3694 @return The value written to CR2.
3695
3696 **/
3697 UINTN
3698 EFIAPI
3699 AsmWriteCr2 (
3700 UINTN Cr2
3701 );
3702
3703 /**
3704 Writes a value to Control Register 3 (CR3).
3705
3706 Writes and returns a new value to CR3. This function is only available on
3707 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
3708
3709 @param Cr3 The value to write to CR3.
3710
3711 @return The value written to CR3.
3712
3713 **/
3714 UINTN
3715 EFIAPI
3716 AsmWriteCr3 (
3717 UINTN Cr3
3718 );
3719
3720 /**
3721 Writes a value to Control Register 4 (CR4).
3722
3723 Writes and returns a new value to CR4. This function is only available on
3724 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
3725
3726 @param Cr4 The value to write to CR4.
3727
3728 @return The value written to CR4.
3729
3730 **/
3731 UINTN
3732 EFIAPI
3733 AsmWriteCr4 (
3734 UINTN Cr4
3735 );
3736
3737 /**
3738 Reads the current value of Debug Register 0 (DR0).
3739
3740 Reads and returns the current value of DR0. This function is only available
3741 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
3742 X64.
3743
3744 @return The value of Debug Register 0 (DR0).
3745
3746 **/
3747 UINTN
3748 EFIAPI
3749 AsmReadDr0 (
3750 VOID
3751 );
3752
3753 /**
3754 Reads the current value of Debug Register 1 (DR1).
3755
3756 Reads and returns the current value of DR1. This function is only available
3757 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
3758 X64.
3759
3760 @return The value of Debug Register 1 (DR1).
3761
3762 **/
3763 UINTN
3764 EFIAPI
3765 AsmReadDr1 (
3766 VOID
3767 );
3768
3769 /**
3770 Reads the current value of Debug Register 2 (DR2).
3771
3772 Reads and returns the current value of DR2. This function is only available
3773 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
3774 X64.
3775
3776 @return The value of Debug Register 2 (DR2).
3777
3778 **/
3779 UINTN
3780 EFIAPI
3781 AsmReadDr2 (
3782 VOID
3783 );
3784
3785 /**
3786 Reads the current value of Debug Register 3 (DR3).
3787
3788 Reads and returns the current value of DR3. This function is only available
3789 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
3790 X64.
3791
3792 @return The value of Debug Register 3 (DR3).
3793
3794 **/
3795 UINTN
3796 EFIAPI
3797 AsmReadDr3 (
3798 VOID
3799 );
3800
3801 /**
3802 Reads the current value of Debug Register 4 (DR4).
3803
3804 Reads and returns the current value of DR4. This function is only available
3805 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
3806 X64.
3807
3808 @return The value of Debug Register 4 (DR4).
3809
3810 **/
3811 UINTN
3812 EFIAPI
3813 AsmReadDr4 (
3814 VOID
3815 );
3816
3817 /**
3818 Reads the current value of Debug Register 5 (DR5).
3819
3820 Reads and returns the current value of DR5. This function is only available
3821 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
3822 X64.
3823
3824 @return The value of Debug Register 5 (DR5).
3825
3826 **/
3827 UINTN
3828 EFIAPI
3829 AsmReadDr5 (
3830 VOID
3831 );
3832
3833 /**
3834 Reads the current value of Debug Register 6 (DR6).
3835
3836 Reads and returns the current value of DR6. This function is only available
3837 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
3838 X64.
3839
3840 @return The value of Debug Register 6 (DR6).
3841
3842 **/
3843 UINTN
3844 EFIAPI
3845 AsmReadDr6 (
3846 VOID
3847 );
3848
3849 /**
3850 Reads the current value of Debug Register 7 (DR7).
3851
3852 Reads and returns the current value of DR7. This function is only available
3853 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
3854 X64.
3855
3856 @return The value of Debug Register 7 (DR7).
3857
3858 **/
3859 UINTN
3860 EFIAPI
3861 AsmReadDr7 (
3862 VOID
3863 );
3864
3865 /**
3866 Writes a value to Debug Register 0 (DR0).
3867
3868 Writes and returns a new value to DR0. This function is only available on
3869 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
3870
3871 @param Dr0 The value to write to Dr0.
3872
3873 @return The value written to Debug Register 0 (DR0).
3874
3875 **/
3876 UINTN
3877 EFIAPI
3878 AsmWriteDr0 (
3879 UINTN Dr0
3880 );
3881
3882 /**
3883 Writes a value to Debug Register 1 (DR1).
3884
3885 Writes and returns a new value to DR1. This function is only available on
3886 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
3887
3888 @param Dr1 The value to write to Dr1.
3889
3890 @return The value written to Debug Register 1 (DR1).
3891
3892 **/
3893 UINTN
3894 EFIAPI
3895 AsmWriteDr1 (
3896 UINTN Dr1
3897 );
3898
3899 /**
3900 Writes a value to Debug Register 2 (DR2).
3901
3902 Writes and returns a new value to DR2. This function is only available on
3903 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
3904
3905 @param Dr2 The value to write to Dr2.
3906
3907 @return The value written to Debug Register 2 (DR2).
3908
3909 **/
3910 UINTN
3911 EFIAPI
3912 AsmWriteDr2 (
3913 UINTN Dr2
3914 );
3915
3916 /**
3917 Writes a value to Debug Register 3 (DR3).
3918
3919 Writes and returns a new value to DR3. This function is only available on
3920 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
3921
3922 @param Dr3 The value to write to Dr3.
3923
3924 @return The value written to Debug Register 3 (DR3).
3925
3926 **/
3927 UINTN
3928 EFIAPI
3929 AsmWriteDr3 (
3930 UINTN Dr3
3931 );
3932
3933 /**
3934 Writes a value to Debug Register 4 (DR4).
3935
3936 Writes and returns a new value to DR4. This function is only available on
3937 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
3938
3939 @param Dr4 The value to write to Dr4.
3940
3941 @return The value written to Debug Register 4 (DR4).
3942
3943 **/
3944 UINTN
3945 EFIAPI
3946 AsmWriteDr4 (
3947 UINTN Dr4
3948 );
3949
3950 /**
3951 Writes a value to Debug Register 5 (DR5).
3952
3953 Writes and returns a new value to DR5. This function is only available on
3954 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
3955
3956 @param Dr5 The value to write to Dr5.
3957
3958 @return The value written to Debug Register 5 (DR5).
3959
3960 **/
3961 UINTN
3962 EFIAPI
3963 AsmWriteDr5 (
3964 UINTN Dr5
3965 );
3966
3967 /**
3968 Writes a value to Debug Register 6 (DR6).
3969
3970 Writes and returns a new value to DR6. This function is only available on
3971 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
3972
3973 @param Dr6 The value to write to Dr6.
3974
3975 @return The value written to Debug Register 6 (DR6).
3976
3977 **/
3978 UINTN
3979 EFIAPI
3980 AsmWriteDr6 (
3981 UINTN Dr6
3982 );
3983
3984 /**
3985 Writes a value to Debug Register 7 (DR7).
3986
3987 Writes and returns a new value to DR7. This function is only available on
3988 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
3989
3990 @param Dr7 The value to write to Dr7.
3991
3992 @return The value written to Debug Register 7 (DR7).
3993
3994 **/
3995 UINTN
3996 EFIAPI
3997 AsmWriteDr7 (
3998 UINTN Dr7
3999 );
4000
4001 /**
4002 Reads the current value of Code Segment Register (CS).
4003
4004 Reads and returns the current value of CS. This function is only available on
4005 IA-32 and X64.
4006
4007 @return The current value of CS.
4008
4009 **/
4010 UINT16
4011 EFIAPI
4012 AsmReadCs (
4013 VOID
4014 );
4015
4016 /**
4017 Reads the current value of Data Segment Register (DS).
4018
4019 Reads and returns the current value of DS. This function is only available on
4020 IA-32 and X64.
4021
4022 @return The current value of DS.
4023
4024 **/
4025 UINT16
4026 EFIAPI
4027 AsmReadDs (
4028 VOID
4029 );
4030
4031 /**
4032 Reads the current value of Extra Segment Register (ES).
4033
4034 Reads and returns the current value of ES. This function is only available on
4035 IA-32 and X64.
4036
4037 @return The current value of ES.
4038
4039 **/
4040 UINT16
4041 EFIAPI
4042 AsmReadEs (
4043 VOID
4044 );
4045
4046 /**
4047 Reads the current value of FS Data Segment Register (FS).
4048
4049 Reads and returns the current value of FS. This function is only available on
4050 IA-32 and X64.
4051
4052 @return The current value of FS.
4053
4054 **/
4055 UINT16
4056 EFIAPI
4057 AsmReadFs (
4058 VOID
4059 );
4060
4061 /**
4062 Reads the current value of GS Data Segment Register (GS).
4063
4064 Reads and returns the current value of GS. This function is only available on
4065 IA-32 and X64.
4066
4067 @return The current value of GS.
4068
4069 **/
4070 UINT16
4071 EFIAPI
4072 AsmReadGs (
4073 VOID
4074 );
4075
4076 /**
4077 Reads the current value of Stack Segment Register (SS).
4078
4079 Reads and returns the current value of SS. This function is only available on
4080 IA-32 and X64.
4081
4082 @return The current value of SS.
4083
4084 **/
4085 UINT16
4086 EFIAPI
4087 AsmReadSs (
4088 VOID
4089 );
4090
4091 /**
4092 Reads the current value of Task Register (TR).
4093
4094 Reads and returns the current value of TR. This function is only available on
4095 IA-32 and X64.
4096
4097 @return The current value of TR.
4098
4099 **/
4100 UINT16
4101 EFIAPI
4102 AsmReadTr (
4103 VOID
4104 );
4105
4106 /**
4107 Reads the current Global Descriptor Table Register(GDTR) descriptor.
4108
4109 Reads and returns the current GDTR descriptor and returns it in Gdtr. This
4110 function is only available on IA-32 and X64.
4111
4112 If Gdtr is NULL, then ASSERT().
4113
4114 @param Gdtr Pointer to a GDTR descriptor.
4115
4116 **/
4117 VOID
4118 EFIAPI
4119 AsmReadGdtr (
4120 OUT IA32_DESCRIPTOR *Gdtr
4121 );
4122
4123 /**
4124 Writes the current Global Descriptor Table Register (GDTR) descriptor.
4125
4126 Writes and the current GDTR descriptor specified by Gdtr. This function is
4127 only available on IA-32 and X64.
4128
4129 If Gdtr is NULL, then ASSERT().
4130
4131 @param Gdtr Pointer to a GDTR descriptor.
4132
4133 **/
4134 VOID
4135 EFIAPI
4136 AsmWriteGdtr (
4137 IN CONST IA32_DESCRIPTOR *Gdtr
4138 );
4139
4140 /**
4141 Reads the current Interrupt Descriptor Table Register(GDTR) descriptor.
4142
4143 Reads and returns the current IDTR descriptor and returns it in Idtr. This
4144 function is only available on IA-32 and X64.
4145
4146 If Idtr is NULL, then ASSERT().
4147
4148 @param Idtr Pointer to a IDTR descriptor.
4149
4150 **/
4151 VOID
4152 EFIAPI
4153 AsmReadIdtr (
4154 OUT IA32_DESCRIPTOR *Idtr
4155 );
4156
4157 /**
4158 Writes the current Interrupt Descriptor Table Register(GDTR) descriptor.
4159
4160 Writes the current IDTR descriptor and returns it in Idtr. This function is
4161 only available on IA-32 and X64.
4162
4163 If Idtr is NULL, then ASSERT().
4164
4165 @param Idtr Pointer to a IDTR descriptor.
4166
4167 **/
4168 VOID
4169 EFIAPI
4170 AsmWriteIdtr (
4171 IN CONST IA32_DESCRIPTOR *Idtr
4172 );
4173
4174 /**
4175 Reads the current Local Descriptor Table Register(LDTR) selector.
4176
4177 Reads and returns the current 16-bit LDTR descriptor value. This function is
4178 only available on IA-32 and X64.
4179
4180 @return The current selector of LDT.
4181
4182 **/
4183 UINT16
4184 EFIAPI
4185 AsmReadLdtr (
4186 VOID
4187 );
4188
4189 /**
4190 Writes the current Local Descriptor Table Register (GDTR) selector.
4191
4192 Writes and the current LDTR descriptor specified by Ldtr. This function is
4193 only available on IA-32 and X64.
4194
4195 @param Ldtr 16-bit LDTR selector value.
4196
4197 **/
4198 VOID
4199 EFIAPI
4200 AsmWriteLdtr (
4201 IN UINT16 Ldtr
4202 );
4203
4204 /**
4205 Save the current floating point/SSE/SSE2 context to a buffer.
4206
4207 Saves the current floating point/SSE/SSE2 state to the buffer specified by
4208 Buffer. Buffer must be aligned on a 16-byte boundary. This function is only
4209 available on IA-32 and X64.
4210
4211 If Buffer is NULL, then ASSERT().
4212 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
4213
4214 @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.
4215
4216 **/
4217 VOID
4218 EFIAPI
4219 AsmFxSave (
4220 OUT IA32_FX_BUFFER *Buffer
4221 );
4222
4223 /**
4224 Restores the current floating point/SSE/SSE2 context from a buffer.
4225
4226 Restores the current floating point/SSE/SSE2 state from the buffer specified
4227 by Buffer. Buffer must be aligned on a 16-byte boundary. This function is
4228 only available on IA-32 and X64.
4229
4230 If Buffer is NULL, then ASSERT().
4231 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
4232 If Buffer was not saved with AsmFxSave(), then ASSERT().
4233
4234 @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.
4235
4236 **/
4237 VOID
4238 EFIAPI
4239 AsmFxRestore (
4240 IN CONST IA32_FX_BUFFER *Buffer
4241 );
4242
4243 /**
4244 Reads the current value of 64-bit MMX Register #0 (MM0).
4245
4246 Reads and returns the current value of MM0. This function is only available
4247 on IA-32 and X64.
4248
4249 @return The current value of MM0.
4250
4251 **/
4252 UINT64
4253 EFIAPI
4254 AsmReadMm0 (
4255 VOID
4256 );
4257
4258 /**
4259 Reads the current value of 64-bit MMX Register #1 (MM1).
4260
4261 Reads and returns the current value of MM1. This function is only available
4262 on IA-32 and X64.
4263
4264 @return The current value of MM1.
4265
4266 **/
4267 UINT64
4268 EFIAPI
4269 AsmReadMm1 (
4270 VOID
4271 );
4272
4273 /**
4274 Reads the current value of 64-bit MMX Register #2 (MM2).
4275
4276 Reads and returns the current value of MM2. This function is only available
4277 on IA-32 and X64.
4278
4279 @return The current value of MM2.
4280
4281 **/
4282 UINT64
4283 EFIAPI
4284 AsmReadMm2 (
4285 VOID
4286 );
4287
4288 /**
4289 Reads the current value of 64-bit MMX Register #3 (MM3).
4290
4291 Reads and returns the current value of MM3. This function is only available
4292 on IA-32 and X64.
4293
4294 @return The current value of MM3.
4295
4296 **/
4297 UINT64
4298 EFIAPI
4299 AsmReadMm3 (
4300 VOID
4301 );
4302
4303 /**
4304 Reads the current value of 64-bit MMX Register #4 (MM4).
4305
4306 Reads and returns the current value of MM4. This function is only available
4307 on IA-32 and X64.
4308
4309 @return The current value of MM4.
4310
4311 **/
4312 UINT64
4313 EFIAPI
4314 AsmReadMm4 (
4315 VOID
4316 );
4317
4318 /**
4319 Reads the current value of 64-bit MMX Register #5 (MM5).
4320
4321 Reads and returns the current value of MM5. This function is only available
4322 on IA-32 and X64.
4323
4324 @return The current value of MM5.
4325
4326 **/
4327 UINT64
4328 EFIAPI
4329 AsmReadMm5 (
4330 VOID
4331 );
4332
4333 /**
4334 Reads the current value of 64-bit MMX Register #6 (MM6).
4335
4336 Reads and returns the current value of MM6. This function is only available
4337 on IA-32 and X64.
4338
4339 @return The current value of MM6.
4340
4341 **/
4342 UINT64
4343 EFIAPI
4344 AsmReadMm6 (
4345 VOID
4346 );
4347
4348 /**
4349 Reads the current value of 64-bit MMX Register #7 (MM7).
4350
4351 Reads and returns the current value of MM7. This function is only available
4352 on IA-32 and X64.
4353
4354 @return The current value of MM7.
4355
4356 **/
4357 UINT64
4358 EFIAPI
4359 AsmReadMm7 (
4360 VOID
4361 );
4362
4363 /**
4364 Writes the current value of 64-bit MMX Register #0 (MM0).
4365
4366 Writes the current value of MM0. This function is only available on IA32 and
4367 X64.
4368
4369 @param Value The 64-bit value to write to MM0.
4370
4371 **/
4372 VOID
4373 EFIAPI
4374 AsmWriteMm0 (
4375 IN UINT64 Value
4376 );
4377
4378 /**
4379 Writes the current value of 64-bit MMX Register #1 (MM1).
4380
4381 Writes the current value of MM1. This function is only available on IA32 and
4382 X64.
4383
4384 @param Value The 64-bit value to write to MM1.
4385
4386 **/
4387 VOID
4388 EFIAPI
4389 AsmWriteMm1 (
4390 IN UINT64 Value
4391 );
4392
4393 /**
4394 Writes the current value of 64-bit MMX Register #2 (MM2).
4395
4396 Writes the current value of MM2. This function is only available on IA32 and
4397 X64.
4398
4399 @param Value The 64-bit value to write to MM2.
4400
4401 **/
4402 VOID
4403 EFIAPI
4404 AsmWriteMm2 (
4405 IN UINT64 Value
4406 );
4407
4408 /**
4409 Writes the current value of 64-bit MMX Register #3 (MM3).
4410
4411 Writes the current value of MM3. This function is only available on IA32 and
4412 X64.
4413
4414 @param Value The 64-bit value to write to MM3.
4415
4416 **/
4417 VOID
4418 EFIAPI
4419 AsmWriteMm3 (
4420 IN UINT64 Value
4421 );
4422
4423 /**
4424 Writes the current value of 64-bit MMX Register #4 (MM4).
4425
4426 Writes the current value of MM4. This function is only avail