Second set of changes based on a review of the code comments in the Include directory...
[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 /// IA-32 architecture 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 /// Itanium architecture 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 architecture 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 Itanium processors, 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 Itanium processors, 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 architectures.
3315 Itanium processors 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 IA-32, x64, and EBC architectures.
3329 For Itanium processors, 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 Itanium processors.
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 Itanium processors.
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 Itanium processors.
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 Itanium processors.
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 Itanium processors.
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 Itanium processors.
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 Itanium processors.
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 Itanium processors.
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 Itanium processors.
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 Itanium processors.
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 Itanium processors.
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 Itanium processors.
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 Itanium processors.
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 Itanium processors.
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 Itanium processors.
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 Itanium processors.
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 Itanium processors.
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 Itanium processors.
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 Itanium processors.
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 Itanium processors.
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