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