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