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