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