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