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