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