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