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