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