]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Library/BaseLib.h
Modify MDE source code according to MDE library update.
[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
5385a579 4 Copyright (c) 2006 - 2008, Intel Corporation\r
ac644614 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
fc30687f 18///\r
1106ffe1 19/// Definitions for SPIN_LOCK\r
fc30687f 20///\r
ac644614 21typedef volatile UINTN SPIN_LOCK;\r
22\r
1106ffe1 23//\r
24// Definitions for architecture specific types\r
25//\r
ac644614 26#if defined (MDE_CPU_IA32)\r
fc30687f 27///\r
28/// IA32 context buffer used by SetJump() and LongJump()\r
29///\r
ac644614 30typedef struct {\r
31 UINT32 Ebx;\r
32 UINT32 Esi;\r
33 UINT32 Edi;\r
34 UINT32 Ebp;\r
35 UINT32 Esp;\r
36 UINT32 Eip;\r
37} BASE_LIBRARY_JUMP_BUFFER;\r
38\r
39#define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 4\r
40\r
41#elif defined (MDE_CPU_IPF)\r
42\r
fc30687f 43///\r
44/// IPF context buffer used by SetJump() and LongJump()\r
45///\r
ac644614 46typedef struct {\r
47 UINT64 F2[2];\r
48 UINT64 F3[2];\r
49 UINT64 F4[2];\r
50 UINT64 F5[2];\r
51 UINT64 F16[2];\r
52 UINT64 F17[2];\r
53 UINT64 F18[2];\r
54 UINT64 F19[2];\r
55 UINT64 F20[2];\r
56 UINT64 F21[2];\r
57 UINT64 F22[2];\r
58 UINT64 F23[2];\r
59 UINT64 F24[2];\r
60 UINT64 F25[2];\r
61 UINT64 F26[2];\r
62 UINT64 F27[2];\r
63 UINT64 F28[2];\r
64 UINT64 F29[2];\r
65 UINT64 F30[2];\r
66 UINT64 F31[2];\r
67 UINT64 R4;\r
68 UINT64 R5;\r
69 UINT64 R6;\r
70 UINT64 R7;\r
71 UINT64 SP;\r
72 UINT64 BR0;\r
73 UINT64 BR1;\r
74 UINT64 BR2;\r
75 UINT64 BR3;\r
76 UINT64 BR4;\r
77 UINT64 BR5;\r
78 UINT64 InitialUNAT;\r
79 UINT64 AfterSpillUNAT;\r
80 UINT64 PFS;\r
81 UINT64 BSP;\r
82 UINT64 Predicates;\r
83 UINT64 LoopCount;\r
84 UINT64 FPSR;\r
85} BASE_LIBRARY_JUMP_BUFFER;\r
86\r
87#define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 0x10\r
88\r
89#elif defined (MDE_CPU_X64)\r
fc30687f 90///\r
91/// X64 context buffer used by SetJump() and LongJump()\r
92///\r
ac644614 93typedef struct {\r
94 UINT64 Rbx;\r
95 UINT64 Rsp;\r
96 UINT64 Rbp;\r
97 UINT64 Rdi;\r
98 UINT64 Rsi;\r
99 UINT64 R12;\r
100 UINT64 R13;\r
101 UINT64 R14;\r
102 UINT64 R15;\r
103 UINT64 Rip;\r
104} BASE_LIBRARY_JUMP_BUFFER;\r
105\r
106#define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8\r
107\r
108#elif defined (MDE_CPU_EBC)\r
fc30687f 109///\r
110/// EBC context buffer used by SetJump() and LongJump()\r
111///\r
ac644614 112typedef struct {\r
113 UINT64 R0;\r
114 UINT64 R1;\r
115 UINT64 R2;\r
116 UINT64 R3;\r
117 UINT64 IP;\r
118} BASE_LIBRARY_JUMP_BUFFER;\r
119\r
120#define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8\r
121\r
122#else\r
123#error Unknown Processor Type\r
124#endif\r
125\r
126//\r
127// String Services\r
128//\r
129\r
130/**\r
131 Copies one Null-terminated Unicode string to another Null-terminated Unicode\r
132 string and returns the new Unicode string.\r
133\r
134 This function copies the contents of the Unicode string Source to the Unicode\r
135 string Destination, and returns Destination. If Source and Destination\r
136 overlap, then the results are undefined.\r
137\r
138 If Destination is NULL, then ASSERT().\r
139 If Destination is not aligned on a 16-bit boundary, then ASSERT().\r
140 If Source is NULL, then ASSERT().\r
141 If Source is not aligned on a 16-bit boundary, then ASSERT().\r
142 If Source and Destination overlap, then ASSERT().\r
143 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r
144 PcdMaximumUnicodeStringLength Unicode characters not including the\r
145 Null-terminator, then ASSERT().\r
146\r
147 @param Destination Pointer to a Null-terminated Unicode string.\r
148 @param Source Pointer to a Null-terminated Unicode string.\r
149\r
150 @return Destiantion\r
151\r
152**/\r
153CHAR16 *\r
154EFIAPI\r
155StrCpy (\r
156 OUT CHAR16 *Destination,\r
157 IN CONST CHAR16 *Source\r
158 );\r
159\r
160\r
161/**\r
162 Copies one Null-terminated Unicode string with a maximum length to another\r
163 Null-terminated Unicode string with a maximum length and returns the new\r
164 Unicode string.\r
165\r
166 This function copies the contents of the Unicode string Source to the Unicode\r
167 string Destination, and returns Destination. At most, Length Unicode\r
168 characters are copied from Source to Destination. If Length is 0, then\r
169 Destination is returned unmodified. If Length is greater that the number of\r
170 Unicode characters in Source, then Destination is padded with Null Unicode\r
171 characters. If Source and Destination overlap, then the results are\r
172 undefined.\r
173\r
174 If Length > 0 and Destination is NULL, then ASSERT().\r
175 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().\r
176 If Length > 0 and Source is NULL, then ASSERT().\r
177 If Length > 0 and Source is not aligned on a 16-bit bounadry, then ASSERT().\r
178 If Source and Destination overlap, then ASSERT().\r
179 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r
180 PcdMaximumUnicodeStringLength Unicode characters not including the\r
181 Null-terminator, then ASSERT().\r
182\r
183 @param Destination Pointer to a Null-terminated Unicode string.\r
184 @param Source Pointer to a Null-terminated Unicode string.\r
185 @param Length Maximum number of Unicode characters to copy.\r
186\r
187 @return Destination\r
188\r
189**/\r
190CHAR16 *\r
191EFIAPI\r
192StrnCpy (\r
193 OUT CHAR16 *Destination,\r
194 IN CONST CHAR16 *Source,\r
195 IN UINTN Length\r
196 );\r
197\r
198\r
199/**\r
200 Returns the length of a Null-terminated Unicode string.\r
201\r
202 This function returns the number of Unicode characters in the Null-terminated\r
203 Unicode string specified by String.\r
204\r
205 If String is NULL, then ASSERT().\r
206 If String is not aligned on a 16-bit boundary, then ASSERT().\r
207 If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r
208 PcdMaximumUnicodeStringLength Unicode characters not including the\r
209 Null-terminator, then ASSERT().\r
210\r
211 @param String Pointer to a Null-terminated Unicode string.\r
212\r
213 @return The length of String.\r
214\r
215**/\r
216UINTN\r
217EFIAPI\r
218StrLen (\r
219 IN CONST CHAR16 *String\r
220 );\r
221\r
222\r
223/**\r
224 Returns the size of a Null-terminated Unicode string in bytes, including the\r
225 Null terminator.\r
226\r
227 This function returns the size, in bytes, of the Null-terminated Unicode\r
228 string specified by String.\r
229\r
230 If String is NULL, then ASSERT().\r
231 If String is not aligned on a 16-bit boundary, then ASSERT().\r
232 If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r
233 PcdMaximumUnicodeStringLength Unicode characters not including the\r
234 Null-terminator, then ASSERT().\r
235\r
236 @param String Pointer to a Null-terminated Unicode string.\r
237\r
238 @return The size of String.\r
239\r
240**/\r
241UINTN\r
242EFIAPI\r
243StrSize (\r
244 IN CONST CHAR16 *String\r
245 );\r
246\r
247\r
248/**\r
249 Compares two Null-terminated Unicode strings, and returns the difference\r
250 between the first mismatched Unicode characters.\r
251\r
252 This function compares the Null-terminated Unicode string FirstString to the\r
253 Null-terminated Unicode string SecondString. If FirstString is identical to\r
254 SecondString, then 0 is returned. Otherwise, the value returned is the first\r
255 mismatched Unicode character in SecondString subtracted from the first\r
256 mismatched Unicode character in FirstString.\r
257\r
258 If FirstString is NULL, then ASSERT().\r
259 If FirstString is not aligned on a 16-bit boundary, then ASSERT().\r
260 If SecondString is NULL, then ASSERT().\r
261 If SecondString is not aligned on a 16-bit boundary, then ASSERT().\r
262 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more\r
263 than PcdMaximumUnicodeStringLength Unicode characters not including the\r
264 Null-terminator, then ASSERT().\r
265 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more\r
266 than PcdMaximumUnicodeStringLength Unicode characters not including the\r
267 Null-terminator, then ASSERT().\r
268\r
269 @param FirstString Pointer to a Null-terminated Unicode string.\r
270 @param SecondString Pointer to a Null-terminated Unicode string.\r
271\r
1106ffe1 272 @retval 0 FirstString is identical to SecondString.\r
273 @return others FirstString is not identical to SecondString.\r
ac644614 274\r
275**/\r
276INTN\r
277EFIAPI\r
278StrCmp (\r
279 IN CONST CHAR16 *FirstString,\r
280 IN CONST CHAR16 *SecondString\r
281 );\r
282\r
283\r
284/**\r
285 Compares two Null-terminated Unicode strings with maximum lengths, and\r
286 returns the difference between the first mismatched Unicode characters.\r
287\r
288 This function compares the Null-terminated Unicode string FirstString to the\r
289 Null-terminated Unicode string SecondString. At most, Length Unicode\r
290 characters will be compared. If Length is 0, then 0 is returned. If\r
291 FirstString is identical to SecondString, then 0 is returned. Otherwise, the\r
292 value returned is the first mismatched Unicode character in SecondString\r
293 subtracted from the first mismatched Unicode character in FirstString.\r
294\r
295 If Length > 0 and FirstString is NULL, then ASSERT().\r
296 If Length > 0 and FirstString is not aligned on a 16-bit bounadary, then ASSERT().\r
297 If Length > 0 and SecondString is NULL, then ASSERT().\r
298 If Length > 0 and SecondString is not aligned on a 16-bit bounadary, then ASSERT().\r
299 If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more\r
300 than PcdMaximumUnicodeStringLength Unicode characters not including the\r
301 Null-terminator, then ASSERT().\r
302 If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more\r
303 than PcdMaximumUnicodeStringLength Unicode characters not including the\r
304 Null-terminator, then ASSERT().\r
305\r
306 @param FirstString Pointer to a Null-terminated Unicode string.\r
307 @param SecondString Pointer to a Null-terminated Unicode string.\r
308 @param Length Maximum number of Unicode characters to compare.\r
309\r
1106ffe1 310 @retval 0 FirstString is identical to SecondString.\r
311 @return others FirstString is not identical to SecondString.\r
ac644614 312\r
313**/\r
314INTN\r
315EFIAPI\r
316StrnCmp (\r
317 IN CONST CHAR16 *FirstString,\r
318 IN CONST CHAR16 *SecondString,\r
319 IN UINTN Length\r
320 );\r
321\r
322\r
323/**\r
324 Concatenates one Null-terminated Unicode string to another Null-terminated\r
325 Unicode string, and returns the concatenated Unicode string.\r
326\r
327 This function concatenates two Null-terminated Unicode strings. The contents\r
328 of Null-terminated Unicode string Source are concatenated to the end of\r
329 Null-terminated Unicode string Destination. The Null-terminated concatenated\r
330 Unicode String is returned. If Source and Destination overlap, then the\r
331 results are undefined.\r
332\r
333 If Destination is NULL, then ASSERT().\r
334 If Destination is not aligned on a 16-bit bounadary, then ASSERT().\r
335 If Source is NULL, then ASSERT().\r
336 If Source is not aligned on a 16-bit bounadary, then ASSERT().\r
337 If Source and Destination overlap, then ASSERT().\r
338 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more\r
339 than PcdMaximumUnicodeStringLength Unicode characters not including the\r
340 Null-terminator, then ASSERT().\r
341 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r
342 PcdMaximumUnicodeStringLength Unicode characters not including the\r
343 Null-terminator, then ASSERT().\r
344 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination\r
345 and Source results in a Unicode string with more than\r
346 PcdMaximumUnicodeStringLength Unicode characters not including the\r
347 Null-terminator, then ASSERT().\r
348\r
349 @param Destination Pointer to a Null-terminated Unicode string.\r
350 @param Source Pointer to a Null-terminated Unicode string.\r
351\r
352 @return Destination\r
353\r
354**/\r
355CHAR16 *\r
356EFIAPI\r
357StrCat (\r
358 IN OUT CHAR16 *Destination,\r
359 IN CONST CHAR16 *Source\r
360 );\r
361\r
362\r
363/**\r
364 Concatenates one Null-terminated Unicode string with a maximum length to the\r
365 end of another Null-terminated Unicode string, and returns the concatenated\r
366 Unicode string.\r
367\r
368 This function concatenates two Null-terminated Unicode strings. The contents\r
369 of Null-terminated Unicode string Source are concatenated to the end of\r
370 Null-terminated Unicode string Destination, and Destination is returned. At\r
371 most, Length Unicode characters are concatenated from Source to the end of\r
372 Destination, and Destination is always Null-terminated. If Length is 0, then\r
373 Destination is returned unmodified. If Source and Destination overlap, then\r
374 the results are undefined.\r
375\r
376 If Destination is NULL, then ASSERT().\r
377 If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().\r
378 If Length > 0 and Source is NULL, then ASSERT().\r
379 If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().\r
380 If Source and Destination overlap, then ASSERT().\r
381 If PcdMaximumUnicodeStringLength is not zero, and Destination contains more\r
382 than PcdMaximumUnicodeStringLength Unicode characters not including the\r
383 Null-terminator, then ASSERT().\r
384 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r
385 PcdMaximumUnicodeStringLength Unicode characters not including the\r
386 Null-terminator, then ASSERT().\r
387 If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination\r
388 and Source results in a Unicode string with more than\r
389 PcdMaximumUnicodeStringLength Unicode characters not including the\r
390 Null-terminator, then ASSERT().\r
391\r
392 @param Destination Pointer to a Null-terminated Unicode string.\r
393 @param Source Pointer to a Null-terminated Unicode string.\r
394 @param Length Maximum number of Unicode characters to concatenate from\r
395 Source.\r
396\r
397 @return Destination\r
398\r
399**/\r
400CHAR16 *\r
401EFIAPI\r
402StrnCat (\r
403 IN OUT CHAR16 *Destination,\r
404 IN CONST CHAR16 *Source,\r
405 IN UINTN Length\r
406 );\r
407\r
408/**\r
409 Returns the first occurance of a Null-terminated Unicode sub-string\r
410 in a Null-terminated Unicode string.\r
411\r
412 This function scans the contents of the Null-terminated Unicode string\r
413 specified by String and returns the first occurrence of SearchString.\r
414 If SearchString is not found in String, then NULL is returned. If\r
415 the length of SearchString is zero, then String is\r
416 returned.\r
417\r
418 If String is NULL, then ASSERT().\r
419 If String is not aligned on a 16-bit boundary, then ASSERT().\r
420 If SearchString is NULL, then ASSERT().\r
421 If SearchString is not aligned on a 16-bit boundary, then ASSERT().\r
422\r
423 If PcdMaximumUnicodeStringLength is not zero, and SearchString\r
424 or String contains more than PcdMaximumUnicodeStringLength Unicode\r
425 characters not including the Null-terminator, then ASSERT().\r
426\r
427 @param String Pointer to a Null-terminated Unicode string.\r
428 @param SearchString Pointer to a Null-terminated Unicode string to search for.\r
429\r
430 @retval NULL If the SearchString does not appear in String.\r
1106ffe1 431 @return others If there is a match.\r
ac644614 432\r
433**/\r
434CHAR16 *\r
435EFIAPI\r
436StrStr (\r
437 IN CONST CHAR16 *String,\r
438 IN CONST CHAR16 *SearchString\r
439 );\r
440\r
441/**\r
442 Convert a Null-terminated Unicode decimal string to a value of\r
443 type UINTN.\r
444\r
445 This function returns a value of type UINTN by interpreting the contents\r
446 of the Unicode string specified by String as a decimal number. The format\r
447 of the input Unicode string String is:\r
448\r
449 [spaces] [decimal digits].\r
450\r
451 The valid decimal digit character is in the range [0-9]. The\r
452 function will ignore the pad space, which includes spaces or\r
453 tab characters, before [decimal digits]. The running zero in the\r
454 beginning of [decimal digits] will be ignored. Then, the function\r
455 stops at the first character that is a not a valid decimal character\r
456 or a Null-terminator, whichever one comes first.\r
457\r
458 If String is NULL, then ASSERT().\r
459 If String is not aligned in a 16-bit boundary, then ASSERT().\r
460 If String has only pad spaces, then 0 is returned.\r
461 If String has no pad spaces or valid decimal digits,\r
462 then 0 is returned.\r
463 If the number represented by String overflows according\r
464 to the range defined by UINTN, then ASSERT().\r
465\r
466 If PcdMaximumUnicodeStringLength is not zero, and String contains\r
467 more than PcdMaximumUnicodeStringLength Unicode characters not including\r
468 the Null-terminator, then ASSERT().\r
469\r
470 @param String Pointer to a Null-terminated Unicode string.\r
471\r
38bbd3d9 472 @retval Value translated from String.\r
ac644614 473\r
474**/\r
475UINTN\r
476EFIAPI\r
477StrDecimalToUintn (\r
478 IN CONST CHAR16 *String\r
479 );\r
480\r
481/**\r
482 Convert a Null-terminated Unicode decimal string to a value of\r
483 type UINT64.\r
484\r
485 This function returns a value of type UINT64 by interpreting the contents\r
486 of the Unicode string specified by String as a decimal number. The format\r
487 of the input Unicode string String is:\r
488\r
489 [spaces] [decimal digits].\r
490\r
491 The valid decimal digit character is in the range [0-9]. The\r
492 function will ignore the pad space, which includes spaces or\r
493 tab characters, before [decimal digits]. The running zero in the\r
494 beginning of [decimal digits] will be ignored. Then, the function\r
495 stops at the first character that is a not a valid decimal character\r
496 or a Null-terminator, whichever one comes first.\r
497\r
498 If String is NULL, then ASSERT().\r
499 If String is not aligned in a 16-bit boundary, then ASSERT().\r
500 If String has only pad spaces, then 0 is returned.\r
501 If String has no pad spaces or valid decimal digits,\r
502 then 0 is returned.\r
503 If the number represented by String overflows according\r
504 to the range defined by UINT64, then ASSERT().\r
505\r
506 If PcdMaximumUnicodeStringLength is not zero, and String contains\r
507 more than PcdMaximumUnicodeStringLength Unicode characters not including\r
508 the Null-terminator, then ASSERT().\r
509\r
510 @param String Pointer to a Null-terminated Unicode string.\r
511\r
38bbd3d9 512 @retval Value translated from String.\r
ac644614 513\r
514**/\r
515UINT64\r
516EFIAPI\r
517StrDecimalToUint64 (\r
518 IN CONST CHAR16 *String\r
519 );\r
520 \r
521\r
522/**\r
523 Convert a Null-terminated Unicode hexadecimal string to a value of type UINTN.\r
524\r
525 This function returns a value of type UINTN by interpreting the contents\r
526 of the Unicode string specified by String as a hexadecimal number.\r
527 The format of the input Unicode string String is:\r
528\r
529 [spaces][zeros][x][hexadecimal digits].\r
530\r
531 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].\r
532 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.\r
533 If "x" appears in the input string, it must be prefixed with at least one 0.\r
534 The function will ignore the pad space, which includes spaces or tab characters,\r
535 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or\r
536 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the\r
537 first valid hexadecimal digit. Then, the function stops at the first character that is\r
538 a not a valid hexadecimal character or NULL, whichever one comes first.\r
539\r
540 If String is NULL, then ASSERT().\r
541 If String is not aligned in a 16-bit boundary, then ASSERT().\r
542 If String has only pad spaces, then zero is returned.\r
543 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,\r
544 then zero is returned.\r
545 If the number represented by String overflows according to the range defined by\r
546 UINTN, then ASSERT().\r
547\r
548 If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r
549 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,\r
550 then ASSERT().\r
551\r
552 @param String Pointer to a Null-terminated Unicode string.\r
553\r
38bbd3d9 554 @retval Value translated from String.\r
ac644614 555\r
556**/\r
557UINTN\r
558EFIAPI\r
559StrHexToUintn (\r
560 IN CONST CHAR16 *String\r
561 );\r
562\r
563\r
564/**\r
565 Convert a Null-terminated Unicode hexadecimal string to a value of type UINT64.\r
566\r
567 This function returns a value of type UINT64 by interpreting the contents\r
568 of the Unicode string specified by String as a hexadecimal number.\r
569 The format of the input Unicode string String is\r
570\r
571 [spaces][zeros][x][hexadecimal digits].\r
572\r
573 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].\r
574 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.\r
575 If "x" appears in the input string, it must be prefixed with at least one 0.\r
576 The function will ignore the pad space, which includes spaces or tab characters,\r
577 before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or\r
578 [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the\r
579 first valid hexadecimal digit. Then, the function stops at the first character that is\r
580 a not a valid hexadecimal character or NULL, whichever one comes first.\r
581\r
582 If String is NULL, then ASSERT().\r
583 If String is not aligned in a 16-bit boundary, then ASSERT().\r
584 If String has only pad spaces, then zero is returned.\r
585 If String has no leading pad spaces, leading zeros or valid hexadecimal digits,\r
586 then zero is returned.\r
587 If the number represented by String overflows according to the range defined by\r
588 UINT64, then ASSERT().\r
589\r
590 If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r
591 PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,\r
592 then ASSERT().\r
593\r
594 @param String Pointer to a Null-terminated Unicode string.\r
595\r
38bbd3d9 596 @retval Value translated from String.\r
ac644614 597\r
598**/\r
599UINT64\r
600EFIAPI\r
601StrHexToUint64 (\r
602 IN CONST CHAR16 *String\r
603 );\r
604\r
605/**\r
606 Convert a nibble in the low 4 bits of a byte to a Unicode hexadecimal character.\r
607\r
608 This function converts a nibble in the low 4 bits of a byte to a Unicode hexadecimal \r
609 character For example, the nibble 0x01 and 0x0A will converted to L'1' and L'A' \r
610 respectively.\r
611\r
612 The upper nibble in the input byte will be masked off.\r
613\r
614 @param Nibble The nibble which is in the low 4 bits of the input byte.\r
615\r
616 @retval CHAR16 The Unicode hexadecimal character.\r
617 \r
618**/\r
619CHAR16\r
620EFIAPI\r
621NibbleToHexChar (\r
622 IN UINT8 Nibble\r
ed66e1bc 623 );\r
ac644614 624\r
625/** \r
626 Convert binary buffer to a Unicode String in a specified sequence. \r
627\r
1106ffe1 628 This function converts bytes in the memory block pointed by Buffer to a Unicode String Str. \r
ac644614 629 Each byte will be represented by two Unicode characters. For example, byte 0xA1 will \r
630 be converted into two Unicode character L'A' and L'1'. In the output String, the Unicode Character \r
631 for the Most Significant Nibble will be put before the Unicode Character for the Least Significant\r
632 Nibble. The output string for the buffer containing a single byte 0xA1 will be L"A1". \r
633 For a buffer with multiple bytes, the Unicode character produced by the first byte will be put into the \r
634 the last character in the output string. The one next to first byte will be put into the\r
635 character before the last character. This rules applies to the rest of the bytes. The Unicode\r
636 character by the last byte will be put into the first character in the output string. For example,\r
637 the input buffer for a 64-bits unsigned integrer 0x12345678abcdef1234 will be converted to\r
638 a Unicode string equal to L"12345678abcdef1234".\r
639\r
640 @param String On input, String is pointed to the buffer allocated for the convertion.\r
641 @param StringLen The Length of String buffer to hold the output String. The length must include the tailing '\0' character.\r
642 The StringLen required to convert a N bytes Buffer will be a least equal to or greater \r
643 than 2*N + 1.\r
644 @param Buffer The pointer to a input buffer.\r
645 @param BufferSizeInBytes Lenth in bytes of the input buffer.\r
646 \r
647\r
648 @retval EFI_SUCCESS The convertion is successfull. All bytes in Buffer has been convert to the corresponding\r
649 Unicode character and placed into the right place in String.\r
650 @retval EFI_BUFFER_TOO_SMALL StringSizeInBytes is smaller than 2 * N + 1the number of bytes required to\r
651 complete the convertion. \r
652**/\r
653RETURN_STATUS\r
654EFIAPI\r
655BufToHexString (\r
656 IN OUT CHAR16 *String,\r
657 IN OUT UINTN *StringLen,\r
658 IN CONST UINT8 *Buffer,\r
659 IN UINTN BufferSizeInBytes\r
ed66e1bc 660 );\r
ac644614 661\r
662\r
663/**\r
664 Convert a Unicode string consisting of hexadecimal characters to a output byte buffer.\r
665\r
666 This function converts a Unicode string consisting of characters in the range of Hexadecimal\r
667 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
668 at the first non-hexadecimal character or the NULL character. The convertion process can be\r
669 simply viewed as the reverse operations defined by BufToHexString. Two Unicode characters will be \r
670 converted into one byte. The first Unicode character represents the Most Significant Nibble and the\r
671 second Unicode character represents the Least Significant Nibble in the output byte. \r
672 The first pair of Unicode characters represents the last byte in the output buffer. The second pair of Unicode \r
673 characters represent the the byte preceding the last byte. This rule applies to the rest pairs of bytes. \r
674 The last pair represent the first byte in the output buffer. \r
675\r
676 For example, a Unciode String L"12345678" will be converted into a buffer wil the following bytes \r
677 (first byte is the byte in the lowest memory address): "0x78, 0x56, 0x34, 0x12".\r
678\r
679 If String has N valid hexadecimal characters for conversion, the caller must make sure Buffer is at least \r
680 N/2 (if N is even) or (N+1)/2 (if N if odd) bytes. \r
681\r
682 @param Buffer The output buffer allocated by the caller.\r
683 @param BufferSizeInBytes On input, the size in bytes of Buffer. On output, it is updated to \r
684 contain the size of the Buffer which is actually used for the converstion.\r
685 For Unicode string with 2*N hexadecimal characters (not including the \r
686 tailing NULL character), N bytes of Buffer will be used for the output.\r
687 @param String The input hexadecimal string.\r
688 @param ConvertedStrLen The number of hexadecimal characters used to produce content in output\r
689 buffer Buffer.\r
690\r
691 @retval RETURN_BUFFER_TOO_SMALL The input BufferSizeInBytes is too small to hold the output. BufferSizeInBytes\r
692 will be updated to the size required for the converstion.\r
693 @retval RETURN_SUCCESS The convertion is successful or the first Unicode character from String\r
694 is hexadecimal. If ConvertedStrLen is not NULL, it is updated\r
695 to the number of hexadecimal character used for the converstion.\r
696**/\r
697RETURN_STATUS\r
698EFIAPI\r
699HexStringToBuf (\r
700 OUT UINT8 *Buffer, \r
701 IN OUT UINTN *BufferSizeInBytes,\r
702 IN CONST CHAR16 *String,\r
703 OUT UINTN *ConvertedStrLen OPTIONAL\r
ed66e1bc 704 );\r
ac644614 705\r
706\r
707/**\r
708 Test if a Unicode character is a hexadecimal digit. If true, the input\r
709 Unicode character is converted to a byte. \r
710\r
711 This function tests if a Unicode character is a hexadecimal digit. If true, the input\r
712 Unicode character is converted to a byte. For example, Unicode character\r
713 L'A' will be converted to 0x0A. \r
714\r
715 If Digit is NULL, then ASSERT.\r
716\r
1106ffe1 717 @param Digit The output hexadecimal digit.\r
718\r
719 @param Char The input Unicode character.\r
720\r
ac644614 721 @retval TRUE Char is in the range of Hexadecimal number. Digit is updated\r
722 to the byte value of the number.\r
723 @retval FALSE Char is not in the range of Hexadecimal number. Digit is keep\r
724 intact.\r
725 \r
726**/\r
727BOOLEAN\r
728EFIAPI\r
729IsHexDigit (\r
730 OUT UINT8 *Digit,\r
731 IN CHAR16 Char\r
ed66e1bc 732 );\r
ac644614 733\r
734/**\r
735 Convert one Null-terminated Unicode string to a Null-terminated\r
736 ASCII string and returns the ASCII string.\r
737\r
738 This function converts the content of the Unicode string Source\r
739 to the ASCII string Destination by copying the lower 8 bits of\r
740 each Unicode character. It returns Destination.\r
741\r
742 If any Unicode characters in Source contain non-zero value in\r
743 the upper 8 bits, then ASSERT().\r
744\r
745 If Destination is NULL, then ASSERT().\r
746 If Source is NULL, then ASSERT().\r
747 If Source is not aligned on a 16-bit boundary, then ASSERT().\r
748 If Source and Destination overlap, then ASSERT().\r
749\r
750 If PcdMaximumUnicodeStringLength is not zero, and Source contains\r
751 more than PcdMaximumUnicodeStringLength Unicode characters not including\r
752 the Null-terminator, then ASSERT().\r
753\r
754 If PcdMaximumAsciiStringLength is not zero, and Source contains more\r
755 than PcdMaximumAsciiStringLength Unicode characters not including the\r
756 Null-terminator, then ASSERT().\r
757\r
758 @param Source Pointer to a Null-terminated Unicode string.\r
759 @param Destination Pointer to a Null-terminated ASCII string.\r
760\r
761 @return Destination\r
762\r
763**/\r
764CHAR8 *\r
765EFIAPI\r
766UnicodeStrToAsciiStr (\r
767 IN CONST CHAR16 *Source,\r
768 OUT CHAR8 *Destination\r
769 );\r
770\r
771\r
772/**\r
773 Copies one Null-terminated ASCII string to another Null-terminated ASCII\r
774 string and returns the new ASCII string.\r
775\r
776 This function copies the contents of the ASCII string Source to the ASCII\r
777 string Destination, and returns Destination. If Source and Destination\r
778 overlap, then the results are undefined.\r
779\r
780 If Destination is NULL, then ASSERT().\r
781 If Source is NULL, then ASSERT().\r
782 If Source and Destination overlap, then ASSERT().\r
783 If PcdMaximumAsciiStringLength is not zero and Source contains more than\r
784 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
785 then ASSERT().\r
786\r
787 @param Destination Pointer to a Null-terminated ASCII string.\r
788 @param Source Pointer to a Null-terminated ASCII string.\r
789\r
790 @return Destination\r
791\r
792**/\r
793CHAR8 *\r
794EFIAPI\r
795AsciiStrCpy (\r
796 OUT CHAR8 *Destination,\r
797 IN CONST CHAR8 *Source\r
798 );\r
799\r
800\r
801/**\r
802 Copies one Null-terminated ASCII string with a maximum length to another\r
803 Null-terminated ASCII string with a maximum length and returns the new ASCII\r
804 string.\r
805\r
806 This function copies the contents of the ASCII string Source to the ASCII\r
807 string Destination, and returns Destination. At most, Length ASCII characters\r
808 are copied from Source to Destination. If Length is 0, then Destination is\r
809 returned unmodified. If Length is greater that the number of ASCII characters\r
810 in Source, then Destination is padded with Null ASCII characters. If Source\r
811 and Destination overlap, then the results are undefined.\r
812\r
813 If Destination is NULL, then ASSERT().\r
814 If Source is NULL, then ASSERT().\r
815 If Source and Destination overlap, then ASSERT().\r
816 If PcdMaximumAsciiStringLength is not zero, and Source contains more than\r
817 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
818 then ASSERT().\r
819\r
820 @param Destination Pointer to a Null-terminated ASCII string.\r
821 @param Source Pointer to a Null-terminated ASCII string.\r
822 @param Length Maximum number of ASCII characters to copy.\r
823\r
824 @return Destination\r
825\r
826**/\r
827CHAR8 *\r
828EFIAPI\r
829AsciiStrnCpy (\r
830 OUT CHAR8 *Destination,\r
831 IN CONST CHAR8 *Source,\r
832 IN UINTN Length\r
833 );\r
834\r
835\r
836/**\r
837 Returns the length of a Null-terminated ASCII string.\r
838\r
839 This function returns the number of ASCII characters in the Null-terminated\r
840 ASCII string specified by String.\r
841\r
842 If Length > 0 and Destination is NULL, then ASSERT().\r
843 If Length > 0 and Source is NULL, then ASSERT().\r
844 If PcdMaximumAsciiStringLength is not zero and String contains more than\r
845 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
846 then ASSERT().\r
847\r
848 @param String Pointer to a Null-terminated ASCII string.\r
849\r
850 @return The length of String.\r
851\r
852**/\r
853UINTN\r
854EFIAPI\r
855AsciiStrLen (\r
856 IN CONST CHAR8 *String\r
857 );\r
858\r
859\r
860/**\r
861 Returns the size of a Null-terminated ASCII string in bytes, including the\r
862 Null terminator.\r
863\r
864 This function returns the size, in bytes, of the Null-terminated ASCII string\r
865 specified by String.\r
866\r
867 If String is NULL, then ASSERT().\r
868 If PcdMaximumAsciiStringLength is not zero and String contains more than\r
869 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
870 then ASSERT().\r
871\r
872 @param String Pointer to a Null-terminated ASCII string.\r
873\r
874 @return The size of String.\r
875\r
876**/\r
877UINTN\r
878EFIAPI\r
879AsciiStrSize (\r
880 IN CONST CHAR8 *String\r
881 );\r
882\r
883\r
884/**\r
885 Compares two Null-terminated ASCII strings, and returns the difference\r
886 between the first mismatched ASCII characters.\r
887\r
888 This function compares the Null-terminated ASCII string FirstString to the\r
889 Null-terminated ASCII string SecondString. If FirstString is identical to\r
890 SecondString, then 0 is returned. Otherwise, the value returned is the first\r
891 mismatched ASCII character in SecondString subtracted from the first\r
892 mismatched ASCII character in FirstString.\r
893\r
894 If FirstString is NULL, then ASSERT().\r
895 If SecondString is NULL, then ASSERT().\r
896 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than\r
897 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
898 then ASSERT().\r
899 If PcdMaximumAsciiStringLength is not zero and SecondString contains more\r
900 than PcdMaximumAsciiStringLength ASCII characters not including the\r
901 Null-terminator, then ASSERT().\r
902\r
903 @param FirstString Pointer to a Null-terminated ASCII string.\r
904 @param SecondString Pointer to a Null-terminated ASCII string.\r
905\r
1106ffe1 906 @retval 0 FirstString is identical to SecondString.\r
907 @return others FirstString is not identical to SecondString.\r
ac644614 908\r
909**/\r
910INTN\r
911EFIAPI\r
912AsciiStrCmp (\r
913 IN CONST CHAR8 *FirstString,\r
914 IN CONST CHAR8 *SecondString\r
915 );\r
916\r
917\r
918/**\r
919 Performs a case insensitive comparison of two Null-terminated ASCII strings,\r
920 and returns the difference between the first mismatched ASCII characters.\r
921\r
922 This function performs a case insensitive comparison of the Null-terminated\r
923 ASCII string FirstString to the Null-terminated ASCII string SecondString. If\r
924 FirstString is identical to SecondString, then 0 is returned. Otherwise, the\r
925 value returned is the first mismatched lower case ASCII character in\r
926 SecondString subtracted from the first mismatched lower case ASCII character\r
927 in FirstString.\r
928\r
929 If FirstString is NULL, then ASSERT().\r
930 If SecondString is NULL, then ASSERT().\r
931 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than\r
932 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
933 then ASSERT().\r
934 If PcdMaximumAsciiStringLength is not zero and SecondString contains more\r
935 than PcdMaximumAsciiStringLength ASCII characters not including the\r
936 Null-terminator, then ASSERT().\r
937\r
938 @param FirstString Pointer to a Null-terminated ASCII string.\r
939 @param SecondString Pointer to a Null-terminated ASCII string.\r
940\r
1106ffe1 941 @retval 0 FirstString is identical to SecondString using case insensitive\r
942 comparisons.\r
943 @return others FirstString is not identical to SecondString using case\r
944 insensitive comparisons.\r
ac644614 945\r
946**/\r
947INTN\r
948EFIAPI\r
949AsciiStriCmp (\r
950 IN CONST CHAR8 *FirstString,\r
951 IN CONST CHAR8 *SecondString\r
952 );\r
953\r
954\r
955/**\r
956 Compares two Null-terminated ASCII strings with maximum lengths, and returns\r
957 the difference between the first mismatched ASCII characters.\r
958\r
959 This function compares the Null-terminated ASCII string FirstString to the\r
960 Null-terminated ASCII string SecondString. At most, Length ASCII characters\r
961 will be compared. If Length is 0, then 0 is returned. If FirstString is\r
962 identical to SecondString, then 0 is returned. Otherwise, the value returned\r
963 is the first mismatched ASCII character in SecondString subtracted from the\r
964 first mismatched ASCII character in FirstString.\r
965\r
966 If Length > 0 and FirstString is NULL, then ASSERT().\r
967 If Length > 0 and SecondString is NULL, then ASSERT().\r
968 If PcdMaximumAsciiStringLength is not zero and FirstString contains more than\r
969 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
970 then ASSERT().\r
971 If PcdMaximumAsciiStringLength is not zero and SecondString contains more than\r
972 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
973 then ASSERT().\r
974\r
975 @param FirstString Pointer to a Null-terminated ASCII string.\r
976 @param SecondString Pointer to a Null-terminated ASCII string.\r
977 @param Length Maximum number of ASCII characters for compare.\r
978 \r
1106ffe1 979 @retval 0 FirstString is identical to SecondString.\r
980 @return others FirstString is not identical to SecondString.\r
ac644614 981\r
982**/\r
983INTN\r
984EFIAPI\r
985AsciiStrnCmp (\r
986 IN CONST CHAR8 *FirstString,\r
987 IN CONST CHAR8 *SecondString,\r
988 IN UINTN Length\r
989 );\r
990\r
991\r
992/**\r
993 Concatenates one Null-terminated ASCII string to another Null-terminated\r
994 ASCII string, and returns the concatenated ASCII string.\r
995\r
996 This function concatenates two Null-terminated ASCII strings. The contents of\r
997 Null-terminated ASCII string Source are concatenated to the end of Null-\r
998 terminated ASCII string Destination. The Null-terminated concatenated ASCII\r
999 String is returned.\r
1000\r
1001 If Destination is NULL, then ASSERT().\r
1002 If Source is NULL, then ASSERT().\r
1003 If PcdMaximumAsciiStringLength is not zero and Destination contains more than\r
1004 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
1005 then ASSERT().\r
1006 If PcdMaximumAsciiStringLength is not zero and Source contains more than\r
1007 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
1008 then ASSERT().\r
1009 If PcdMaximumAsciiStringLength is not zero and concatenating Destination and\r
1010 Source results in a ASCII string with more than PcdMaximumAsciiStringLength\r
1011 ASCII characters, then ASSERT().\r
1012\r
1013 @param Destination Pointer to a Null-terminated ASCII string.\r
1014 @param Source Pointer to a Null-terminated ASCII string.\r
1015\r
1016 @return Destination\r
1017\r
1018**/\r
1019CHAR8 *\r
1020EFIAPI\r
1021AsciiStrCat (\r
1022 IN OUT CHAR8 *Destination,\r
1023 IN CONST CHAR8 *Source\r
1024 );\r
1025\r
1026\r
1027/**\r
1028 Concatenates one Null-terminated ASCII string with a maximum length to the\r
1029 end of another Null-terminated ASCII string, and returns the concatenated\r
1030 ASCII string.\r
1031\r
1032 This function concatenates two Null-terminated ASCII strings. The contents\r
1033 of Null-terminated ASCII string Source are concatenated to the end of Null-\r
1034 terminated ASCII string Destination, and Destination is returned. At most,\r
1035 Length ASCII characters are concatenated from Source to the end of\r
1036 Destination, and Destination is always Null-terminated. If Length is 0, then\r
1037 Destination is returned unmodified. If Source and Destination overlap, then\r
1038 the results are undefined.\r
1039\r
1040 If Length > 0 and Destination is NULL, then ASSERT().\r
1041 If Length > 0 and Source is NULL, then ASSERT().\r
1042 If Source and Destination overlap, then ASSERT().\r
1043 If PcdMaximumAsciiStringLength is not zero, and Destination contains more than\r
1044 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
1045 then ASSERT().\r
1046 If PcdMaximumAsciiStringLength is not zero, and Source contains more than\r
1047 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
1048 then ASSERT().\r
1049 If PcdMaximumAsciiStringLength is not zero, and concatenating Destination and\r
1050 Source results in a ASCII string with more than PcdMaximumAsciiStringLength\r
1051 ASCII characters not including the Null-terminator, then ASSERT().\r
1052\r
1053 @param Destination Pointer to a Null-terminated ASCII string.\r
1054 @param Source Pointer to a Null-terminated ASCII string.\r
1055 @param Length Maximum number of ASCII characters to concatenate from\r
1056 Source.\r
1057\r
1058 @return Destination\r
1059\r
1060**/\r
1061CHAR8 *\r
1062EFIAPI\r
1063AsciiStrnCat (\r
1064 IN OUT CHAR8 *Destination,\r
1065 IN CONST CHAR8 *Source,\r
1066 IN UINTN Length\r
1067 );\r
1068\r
1069\r
1070/**\r
1071 Returns the first occurance of a Null-terminated ASCII sub-string\r
1072 in a Null-terminated ASCII string.\r
1073\r
1074 This function scans the contents of the ASCII string specified by String\r
1075 and returns the first occurrence of SearchString. If SearchString is not\r
1076 found in String, then NULL is returned. If the length of SearchString is zero,\r
1077 then String is returned.\r
1078\r
1079 If String is NULL, then ASSERT().\r
1080 If SearchString is NULL, then ASSERT().\r
1081\r
1082 If PcdMaximumAsciiStringLength is not zero, and SearchString or\r
1083 String contains more than PcdMaximumAsciiStringLength Unicode characters\r
1084 not including the Null-terminator, then ASSERT().\r
1085\r
1106ffe1 1086 @param String Pointer to a Null-terminated ASCII string.\r
1087 @param SearchString Pointer to a Null-terminated ASCII string to search for.\r
ac644614 1088\r
1089 @retval NULL If the SearchString does not appear in String.\r
1106ffe1 1090 @return others If there is a match.\r
ac644614 1091\r
1092**/\r
1093CHAR8 *\r
1094EFIAPI\r
1095AsciiStrStr (\r
1096 IN CONST CHAR8 *String,\r
1097 IN CONST CHAR8 *SearchString\r
1098 );\r
1099\r
1100\r
1101/**\r
1102 Convert a Null-terminated ASCII decimal string to a value of type\r
1103 UINTN.\r
1104\r
1105 This function returns a value of type UINTN by interpreting the contents\r
1106 of the ASCII string String as a decimal number. The format of the input\r
1107 ASCII string String is:\r
1108\r
1109 [spaces] [decimal digits].\r
1110\r
1111 The valid decimal digit character is in the range [0-9]. The function will\r
1112 ignore the pad space, which includes spaces or tab characters, before the digits.\r
1113 The running zero in the beginning of [decimal digits] will be ignored. Then, the\r
1114 function stops at the first character that is a not a valid decimal character or\r
1115 Null-terminator, whichever on comes first.\r
1116\r
1117 If String has only pad spaces, then 0 is returned.\r
1118 If String has no pad spaces or valid decimal digits, then 0 is returned.\r
1119 If the number represented by String overflows according to the range defined by\r
1120 UINTN, then ASSERT().\r
1121 If String is NULL, then ASSERT().\r
1122 If PcdMaximumAsciiStringLength is not zero, and String contains more than\r
1123 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
1124 then ASSERT().\r
1125\r
1126 @param String Pointer to a Null-terminated ASCII string.\r
1127\r
38bbd3d9 1128 @retval Value translated from String.\r
ac644614 1129\r
1130**/\r
1131UINTN\r
1132EFIAPI\r
1133AsciiStrDecimalToUintn (\r
1134 IN CONST CHAR8 *String\r
1135 );\r
1136\r
1137\r
1138/**\r
1139 Convert a Null-terminated ASCII decimal string to a value of type\r
1140 UINT64.\r
1141\r
1142 This function returns a value of type UINT64 by interpreting the contents\r
1143 of the ASCII string String as a decimal number. The format of the input\r
1144 ASCII string String is:\r
1145\r
1146 [spaces] [decimal digits].\r
1147\r
1148 The valid decimal digit character is in the range [0-9]. The function will\r
1149 ignore the pad space, which includes spaces or tab characters, before the digits.\r
1150 The running zero in the beginning of [decimal digits] will be ignored. Then, the\r
1151 function stops at the first character that is a not a valid decimal character or\r
1152 Null-terminator, whichever on comes first.\r
1153\r
1154 If String has only pad spaces, then 0 is returned.\r
1155 If String has no pad spaces or valid decimal digits, then 0 is returned.\r
1156 If the number represented by String overflows according to the range defined by\r
1157 UINT64, then ASSERT().\r
1158 If String is NULL, then ASSERT().\r
1159 If PcdMaximumAsciiStringLength is not zero, and String contains more than\r
1160 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
1161 then ASSERT().\r
1162\r
1163 @param String Pointer to a Null-terminated ASCII string.\r
1164\r
38bbd3d9 1165 @retval Value translated from String.\r
ac644614 1166\r
1167**/\r
1168UINT64\r
1169EFIAPI\r
1170AsciiStrDecimalToUint64 (\r
1171 IN CONST CHAR8 *String\r
1172 );\r
1173\r
1174\r
1175/**\r
1176 Convert a Null-terminated ASCII hexadecimal string to a value of type UINTN.\r
1177\r
1178 This function returns a value of type UINTN by interpreting the contents of\r
1179 the ASCII string String as a hexadecimal number. The format of the input ASCII\r
1180 string String is:\r
1181\r
1182 [spaces][zeros][x][hexadecimal digits].\r
1183\r
1184 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].\r
1185 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"\r
1186 appears in the input string, it must be prefixed with at least one 0. The function\r
1187 will ignore the pad space, which includes spaces or tab characters, before [zeros],\r
1188 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]\r
1189 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal\r
1190 digit. Then, the function stops at the first character that is a not a valid\r
1191 hexadecimal character or Null-terminator, whichever on comes first.\r
1192\r
1193 If String has only pad spaces, then 0 is returned.\r
1194 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then\r
1195 0 is returned.\r
1196\r
1197 If the number represented by String overflows according to the range defined by UINTN,\r
1198 then ASSERT().\r
1199 If String is NULL, then ASSERT().\r
1200 If PcdMaximumAsciiStringLength is not zero,\r
1201 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including\r
1202 the Null-terminator, then ASSERT().\r
1203\r
1204 @param String Pointer to a Null-terminated ASCII string.\r
1205\r
38bbd3d9 1206 @retval Value translated from String.\r
ac644614 1207\r
1208**/\r
1209UINTN\r
1210EFIAPI\r
1211AsciiStrHexToUintn (\r
1212 IN CONST CHAR8 *String\r
1213 );\r
1214\r
1215\r
1216/**\r
1217 Convert a Null-terminated ASCII hexadecimal string to a value of type UINT64.\r
1218\r
1219 This function returns a value of type UINT64 by interpreting the contents of\r
1220 the ASCII string String as a hexadecimal number. The format of the input ASCII\r
1221 string String is:\r
1222\r
1223 [spaces][zeros][x][hexadecimal digits].\r
1224\r
1225 The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].\r
1226 The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"\r
1227 appears in the input string, it must be prefixed with at least one 0. The function\r
1228 will ignore the pad space, which includes spaces or tab characters, before [zeros],\r
1229 [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]\r
1230 will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal\r
1231 digit. Then, the function stops at the first character that is a not a valid\r
1232 hexadecimal character or Null-terminator, whichever on comes first.\r
1233\r
1234 If String has only pad spaces, then 0 is returned.\r
1235 If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then\r
1236 0 is returned.\r
1237\r
1238 If the number represented by String overflows according to the range defined by UINT64,\r
1239 then ASSERT().\r
1240 If String is NULL, then ASSERT().\r
1241 If PcdMaximumAsciiStringLength is not zero,\r
1242 and String contains more than PcdMaximumAsciiStringLength ASCII characters not including\r
1243 the Null-terminator, then ASSERT().\r
1244\r
1245 @param String Pointer to a Null-terminated ASCII string.\r
1246\r
38bbd3d9 1247 @retval Value translated from String.\r
ac644614 1248\r
1249**/\r
1250UINT64\r
1251EFIAPI\r
1252AsciiStrHexToUint64 (\r
1253 IN CONST CHAR8 *String\r
1254 );\r
1255\r
1256\r
1257/**\r
1258 Convert one Null-terminated ASCII string to a Null-terminated\r
1259 Unicode string and returns the Unicode string.\r
1260\r
1261 This function converts the contents of the ASCII string Source to the Unicode\r
1262 string Destination, and returns Destination. The function terminates the\r
1263 Unicode string Destination by appending a Null-terminator character at the end.\r
1264 The caller is responsible to make sure Destination points to a buffer with size\r
1265 equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.\r
1266\r
1267 If Destination is NULL, then ASSERT().\r
1268 If Destination is not aligned on a 16-bit boundary, then ASSERT().\r
1269 If Source is NULL, then ASSERT().\r
1270 If Source and Destination overlap, then ASSERT().\r
1271 If PcdMaximumAsciiStringLength is not zero, and Source contains more than\r
1272 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
1273 then ASSERT().\r
1274 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r
1275 PcdMaximumUnicodeStringLength ASCII characters not including the\r
1276 Null-terminator, then ASSERT().\r
1277\r
1278 @param Source Pointer to a Null-terminated ASCII string.\r
1279 @param Destination Pointer to a Null-terminated Unicode string.\r
1280\r
1281 @return Destination\r
1282\r
1283**/\r
1284CHAR16 *\r
1285EFIAPI\r
1286AsciiStrToUnicodeStr (\r
1287 IN CONST CHAR8 *Source,\r
1288 OUT CHAR16 *Destination\r
1289 );\r
1290\r
1291\r
1292/**\r
1293 Converts an 8-bit value to an 8-bit BCD value.\r
1294\r
1295 Converts the 8-bit value specified by Value to BCD. The BCD value is\r
1296 returned.\r
1297\r
1298 If Value >= 100, then ASSERT().\r
1299\r
1300 @param Value The 8-bit value to convert to BCD. Range 0..99.\r
1301\r
1302 @return The BCD value\r
1303\r
1304**/\r
1305UINT8\r
1306EFIAPI\r
1307DecimalToBcd8 (\r
1308 IN UINT8 Value\r
1309 );\r
1310\r
1311\r
1312/**\r
1313 Converts an 8-bit BCD value to an 8-bit value.\r
1314\r
1315 Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit\r
1316 value is returned.\r
1317\r
1318 If Value >= 0xA0, then ASSERT().\r
1319 If (Value & 0x0F) >= 0x0A, then ASSERT().\r
1320\r
1321 @param Value The 8-bit BCD value to convert to an 8-bit value.\r
1322\r
1323 @return The 8-bit value is returned.\r
1324\r
1325**/\r
1326UINT8\r
1327EFIAPI\r
1328BcdToDecimal8 (\r
1329 IN UINT8 Value\r
1330 );\r
1331\r
1332\r
1333//\r
1334// Linked List Functions and Macros\r
1335//\r
1336\r
1337/**\r
1338 Initializes the head node of a doubly linked list that is declared as a\r
1339 global variable in a module.\r
1340\r
1341 Initializes the forward and backward links of a new linked list. After\r
1342 initializing a linked list with this macro, the other linked list functions\r
1343 may be used to add and remove nodes from the linked list. This macro results\r
1344 in smaller executables by initializing the linked list in the data section,\r
1345 instead if calling the InitializeListHead() function to perform the\r
1346 equivalent operation.\r
1347\r
1348 @param ListHead The head note of a list to initiailize.\r
1349\r
1350**/\r
1351#define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&ListHead, &ListHead}\r
1352\r
1353\r
1354/**\r
1355 Initializes the head node of a doubly linked list, and returns the pointer to\r
1356 the head node of the doubly linked list.\r
1357\r
1358 Initializes the forward and backward links of a new linked list. After\r
1359 initializing a linked list with this function, the other linked list\r
1360 functions may be used to add and remove nodes from the linked list. It is up\r
1361 to the caller of this function to allocate the memory for ListHead.\r
1362\r
1363 If ListHead is NULL, then ASSERT().\r
1364\r
1365 @param ListHead A pointer to the head node of a new doubly linked list.\r
1366\r
1367 @return ListHead\r
1368\r
1369**/\r
1370LIST_ENTRY *\r
1371EFIAPI\r
1372InitializeListHead (\r
aa0583c7 1373 IN OUT LIST_ENTRY *ListHead\r
ac644614 1374 );\r
1375\r
1376\r
1377/**\r
1378 Adds a node to the beginning of a doubly linked list, and returns the pointer\r
1379 to the head node of the doubly linked list.\r
1380\r
1381 Adds the node Entry at the beginning of the doubly linked list denoted by\r
1382 ListHead, and returns ListHead.\r
1383\r
1384 If ListHead is NULL, then ASSERT().\r
1385 If Entry is NULL, then ASSERT().\r
1386 If ListHead was not initialized with InitializeListHead(), then ASSERT().\r
1387 If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number\r
1388 of nodes in ListHead, including the ListHead node, is greater than or\r
1389 equal to PcdMaximumLinkedListLength, then ASSERT().\r
1390\r
1391 @param ListHead A pointer to the head node of a doubly linked list.\r
1392 @param Entry A pointer to a node that is to be inserted at the beginning\r
1393 of a doubly linked list.\r
1394\r
1395 @return ListHead\r
1396\r
1397**/\r
1398LIST_ENTRY *\r
1399EFIAPI\r
1400InsertHeadList (\r
aa0583c7 1401 IN OUT LIST_ENTRY *ListHead,\r
1402 IN OUT LIST_ENTRY *Entry\r
ac644614 1403 );\r
1404\r
1405\r
1406/**\r
1407 Adds a node to the end of a doubly linked list, and returns the pointer to\r
1408 the head node of the doubly linked list.\r
1409\r
1410 Adds the node Entry to the end of the doubly linked list denoted by ListHead,\r
1411 and returns ListHead.\r
1412\r
1413 If ListHead is NULL, then ASSERT().\r
1414 If Entry is NULL, then ASSERT().\r
1415 If ListHead was not initialized with InitializeListHead(), then ASSERT().\r
1416 If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number\r
1417 of nodes in ListHead, including the ListHead node, is greater than or\r
1418 equal to PcdMaximumLinkedListLength, then ASSERT().\r
1419\r
1420 @param ListHead A pointer to the head node of a doubly linked list.\r
1421 @param Entry A pointer to a node that is to be added at the end of the\r
1422 doubly linked list.\r
1423\r
1424 @return ListHead\r
1425\r
1426**/\r
1427LIST_ENTRY *\r
1428EFIAPI\r
1429InsertTailList (\r
aa0583c7 1430 IN OUT LIST_ENTRY *ListHead,\r
1431 IN OUT LIST_ENTRY *Entry\r
ac644614 1432 );\r
1433\r
1434\r
1435/**\r
1436 Retrieves the first node of a doubly linked list.\r
1437\r
1438 Returns the first node of a doubly linked list. List must have been\r
1439 initialized with InitializeListHead(). If List is empty, then NULL is\r
1440 returned.\r
1441\r
1442 If List is NULL, then ASSERT().\r
1443 If List was not initialized with InitializeListHead(), then ASSERT().\r
1444 If PcdMaximumLinkedListLenth is not zero, and the number of nodes\r
1445 in List, including the List node, is greater than or equal to\r
1446 PcdMaximumLinkedListLength, then ASSERT().\r
1447\r
1448 @param List A pointer to the head node of a doubly linked list.\r
1449\r
1450 @return The first node of a doubly linked list.\r
1451 @retval NULL The list is empty.\r
1452\r
1453**/\r
1454LIST_ENTRY *\r
1455EFIAPI\r
1456GetFirstNode (\r
1457 IN CONST LIST_ENTRY *List\r
1458 );\r
1459\r
1460\r
1461/**\r
1462 Retrieves the next node of a doubly linked list.\r
1463\r
1464 Returns the node of a doubly linked list that follows Node. List must have\r
1465 been initialized with InitializeListHead(). If List is empty, then List is\r
1466 returned.\r
1467\r
1468 If List is NULL, then ASSERT().\r
1469 If Node is NULL, then ASSERT().\r
1470 If List was not initialized with InitializeListHead(), then ASSERT().\r
1471 If PcdMaximumLinkedListLenth is not zero, and List contains more than\r
1472 PcdMaximumLinkedListLenth nodes, then ASSERT().\r
1473 If Node is not a node in List, then ASSERT().\r
1474\r
1475 @param List A pointer to the head node of a doubly linked list.\r
1476 @param Node A pointer to a node in the doubly linked list.\r
1477\r
1478 @return Pointer to the next node if one exists. Otherwise a null value which\r
1479 is actually List is returned.\r
1480\r
1481**/\r
1482LIST_ENTRY *\r
1483EFIAPI\r
1484GetNextNode (\r
1485 IN CONST LIST_ENTRY *List,\r
1486 IN CONST LIST_ENTRY *Node\r
1487 );\r
1488\r
1489\r
1490/**\r
1491 Checks to see if a doubly linked list is empty or not.\r
1492\r
1493 Checks to see if the doubly linked list is empty. If the linked list contains\r
1494 zero nodes, this function returns TRUE. Otherwise, it returns FALSE.\r
1495\r
1496 If ListHead is NULL, then ASSERT().\r
1497 If ListHead was not initialized with InitializeListHead(), then ASSERT().\r
1498 If PcdMaximumLinkedListLenth is not zero, and the number of nodes\r
1499 in List, including the List node, is greater than or equal to\r
1500 PcdMaximumLinkedListLength, then ASSERT().\r
1501\r
1502 @param ListHead A pointer to the head node of a doubly linked list.\r
1503\r
1504 @retval TRUE The linked list is empty.\r
1505 @retval FALSE The linked list is not empty.\r
1506\r
1507**/\r
1508BOOLEAN\r
1509EFIAPI\r
1510IsListEmpty (\r
1511 IN CONST LIST_ENTRY *ListHead\r
1512 );\r
1513\r
1514\r
1515/**\r
aa0583c7 1516 Determines if a node in a doubly linked list is the head node of a the same\r
1517 doubly linked list. This function is typically used to terminate a loop that\r
1518 traverses all the nodes in a doubly linked list starting with the head node.\r
ac644614 1519\r
aa0583c7 1520 Returns TRUE if Node is equal to List. Returns FALSE if Node is one of the\r
1521 nodes in the doubly linked list specified by List. List must have been\r
1522 initialized with InitializeListHead().\r
ac644614 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
aa0583c7 1605 IN OUT LIST_ENTRY *FirstEntry,\r
1606 IN OUT LIST_ENTRY *SecondEntry\r
ac644614 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
5385a579 2197 @param Buffer Pointer to a 16-bit value that may be unaligned.\r
ac644614 2198\r
5385a579 2199 @return The 16-bit value read from Buffer.\r
ac644614 2200\r
2201**/\r
2202UINT16\r
2203EFIAPI\r
2204ReadUnaligned16 (\r
5385a579 2205 IN CONST UINT16 *Buffer\r
ac644614 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
5385a579 2218 @param Buffer Pointer to a 16-bit value that may be unaligned.\r
ac644614 2219 @param Value 16-bit value to write to Buffer.\r
2220\r
5385a579 2221 @return The 16-bit value to write to Buffer.\r
ac644614 2222\r
2223**/\r
2224UINT16\r
2225EFIAPI\r
2226WriteUnaligned16 (\r
5385a579 2227 OUT UINT16 *Buffer,\r
2228 IN UINT16 Value\r
ac644614 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
5385a579 2242 @return The 24-bit value read from Buffer.\r
ac644614 2243\r
2244**/\r
2245UINT32\r
2246EFIAPI\r
2247ReadUnaligned24 (\r
5385a579 2248 IN CONST UINT32 *Buffer\r
ac644614 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
5385a579 2264 @return The 24-bit value to write to Buffer.\r
ac644614 2265\r
2266**/\r
2267UINT32\r
2268EFIAPI\r
2269WriteUnaligned24 (\r
5385a579 2270 OUT UINT32 *Buffer,\r
2271 IN UINT32 Value\r
ac644614 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
5385a579 2283 @param Buffer Pointer to a 32-bit value that may be unaligned.\r
ac644614 2284\r
5385a579 2285 @return The 32-bit value read from Buffer.\r
ac644614 2286\r
2287**/\r
2288UINT32\r
2289EFIAPI\r
2290ReadUnaligned32 (\r
5385a579 2291 IN CONST UINT32 *Buffer\r
ac644614 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
5385a579 2304 @param Buffer Pointer to a 32-bit value that may be unaligned.\r
ac644614 2305 @param Value 32-bit value to write to Buffer.\r
2306\r
5385a579 2307 @return The 32-bit value to write to Buffer.\r
ac644614 2308\r
2309**/\r
2310UINT32\r
2311EFIAPI\r
2312WriteUnaligned32 (\r
5385a579 2313 OUT UINT32 *Buffer,\r
2314 IN UINT32 Value\r
ac644614 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
5385a579 2326 @param Buffer Pointer to a 64-bit value that may be unaligned.\r
ac644614 2327\r
5385a579 2328 @return The 64-bit value read from Buffer.\r
ac644614 2329\r
2330**/\r
2331UINT64\r
2332EFIAPI\r
2333ReadUnaligned64 (\r
5385a579 2334 IN CONST UINT64 *Buffer\r
ac644614 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
5385a579 2347 @param Buffer Pointer to a 64-bit value that may be unaligned.\r
ac644614 2348 @param Value 64-bit value to write to Buffer.\r
2349\r
5385a579 2350 @return The 64-bit value to write to Buffer.\r
ac644614 2351\r
2352**/\r
2353UINT64\r
2354EFIAPI\r
2355WriteUnaligned64 (\r
5385a579 2356 OUT UINT64 *Buffer,\r
2357 IN UINT64 Value\r
ac644614 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
aa0583c7 3086 IN OUT SPIN_LOCK *SpinLock\r
ac644614 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
aa0583c7 3110 IN OUT SPIN_LOCK *SpinLock\r
ac644614 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
aa0583c7 3131 IN OUT SPIN_LOCK *SpinLock\r
ac644614 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
1106ffe1 3277 @param Buffer Pointer to the buffer to carry out the sum operation.\r
3278 @param Length The size, in bytes, of Buffer .\r
ac644614 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
1106ffe1 3303 @param Buffer Pointer to the buffer to carry out the checksum operation.\r
3304 @param Length The size, in bytes, of Buffer.\r
ac644614 3305\r
3306 @return Checksum The 2's complement checksum of Buffer.\r
3307\r
3308**/\r
3309UINT8\r
3310EFIAPI\r
3311CalculateCheckSum8 (\r
3312 IN CONST UINT8 *Buffer,\r
3313 IN UINTN Length\r
3314 );\r
3315\r
3316\r
3317/**\r
3318 Returns the sum of all elements in a buffer of 16-bit values. During\r
3319 calculation, the carry bits are dropped.\r
3320\r
3321 This function calculates the sum of the 16-bit values in the buffer\r
3322 specified by Buffer and Length. The carry bits in result of addition are dropped.\r
3323 The 16-bit result is returned. If Length is 0, then 0 is returned.\r
3324\r
3325 If Buffer is NULL, then ASSERT().\r
3326 If Buffer is not aligned on a 16-bit boundary, then ASSERT().\r
3327 If Length is not aligned on a 16-bit boundary, then ASSERT().\r
3328 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
3329\r
1106ffe1 3330 @param Buffer Pointer to the buffer to carry out the sum operation.\r
3331 @param Length The size, in bytes, of Buffer.\r
ac644614 3332\r
3333 @return Sum The sum of Buffer with carry bits dropped during additions.\r
3334\r
3335**/\r
3336UINT16\r
3337EFIAPI\r
3338CalculateSum16 (\r
3339 IN CONST UINT16 *Buffer,\r
3340 IN UINTN Length\r
3341 );\r
3342\r
3343\r
3344/**\r
3345 Returns the two's complement checksum of all elements in a buffer of\r
3346 16-bit values.\r
3347\r
3348 This function first calculates the sum of the 16-bit values in the buffer\r
3349 specified by Buffer and Length. The carry bits in the result of addition\r
3350 are dropped. Then, the two's complement of the sum is returned. If Length\r
3351 is 0, then 0 is returned.\r
3352\r
3353 If Buffer is NULL, then ASSERT().\r
3354 If Buffer is not aligned on a 16-bit boundary, then ASSERT().\r
3355 If Length is not aligned on a 16-bit boundary, then ASSERT().\r
3356 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
3357\r
1106ffe1 3358 @param Buffer Pointer to the buffer to carry out the checksum operation.\r
3359 @param Length The size, in bytes, of Buffer.\r
ac644614 3360\r
3361 @return Checksum The 2's complement checksum of Buffer.\r
3362\r
3363**/\r
3364UINT16\r
3365EFIAPI\r
3366CalculateCheckSum16 (\r
3367 IN CONST UINT16 *Buffer,\r
3368 IN UINTN Length\r
3369 );\r
3370\r
3371\r
3372/**\r
3373 Returns the sum of all elements in a buffer of 32-bit values. During\r
3374 calculation, the carry bits are dropped.\r
3375\r
3376 This function calculates the sum of the 32-bit values in the buffer\r
3377 specified by Buffer and Length. The carry bits in result of addition are dropped.\r
3378 The 32-bit result is returned. If Length is 0, then 0 is returned.\r
3379\r
3380 If Buffer is NULL, then ASSERT().\r
3381 If Buffer is not aligned on a 32-bit boundary, then ASSERT().\r
3382 If Length is not aligned on a 32-bit boundary, then ASSERT().\r
3383 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
3384\r
1106ffe1 3385 @param Buffer Pointer to the buffer to carry out the sum operation.\r
3386 @param Length The size, in bytes, of Buffer.\r
ac644614 3387\r
3388 @return Sum The sum of Buffer with carry bits dropped during additions.\r
3389\r
3390**/\r
3391UINT32\r
3392EFIAPI\r
3393CalculateSum32 (\r
3394 IN CONST UINT32 *Buffer,\r
3395 IN UINTN Length\r
3396 );\r
3397\r
3398\r
3399/**\r
3400 Returns the two's complement checksum of all elements in a buffer of\r
3401 32-bit values.\r
3402\r
3403 This function first calculates the sum of the 32-bit values in the buffer\r
3404 specified by Buffer and Length. The carry bits in the result of addition\r
3405 are dropped. Then, the two's complement of the sum is returned. If Length\r
3406 is 0, then 0 is returned.\r
3407\r
3408 If Buffer is NULL, then ASSERT().\r
3409 If Buffer is not aligned on a 32-bit boundary, then ASSERT().\r
3410 If Length is not aligned on a 32-bit boundary, then ASSERT().\r
3411 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
3412\r
1106ffe1 3413 @param Buffer Pointer to the buffer to carry out the checksum operation.\r
3414 @param Length The size, in bytes, of Buffer.\r
ac644614 3415\r
3416 @return Checksum The 2's complement checksum of Buffer.\r
3417\r
3418**/\r
3419UINT32\r
3420EFIAPI\r
3421CalculateCheckSum32 (\r
3422 IN CONST UINT32 *Buffer,\r
3423 IN UINTN Length\r
3424 );\r
3425\r
3426\r
3427/**\r
3428 Returns the sum of all elements in a buffer of 64-bit values. During\r
3429 calculation, the carry bits are dropped.\r
3430\r
3431 This function calculates the sum of the 64-bit values in the buffer\r
3432 specified by Buffer and Length. The carry bits in result of addition are dropped.\r
3433 The 64-bit result is returned. If Length is 0, then 0 is returned.\r
3434\r
3435 If Buffer is NULL, then ASSERT().\r
3436 If Buffer is not aligned on a 64-bit boundary, then ASSERT().\r
3437 If Length is not aligned on a 64-bit boundary, then ASSERT().\r
3438 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
3439\r
1106ffe1 3440 @param Buffer Pointer to the buffer to carry out the sum operation.\r
3441 @param Length The size, in bytes, of Buffer.\r
ac644614 3442\r
3443 @return Sum The sum of Buffer with carry bits dropped during additions.\r
3444\r
3445**/\r
3446UINT64\r
3447EFIAPI\r
3448CalculateSum64 (\r
3449 IN CONST UINT64 *Buffer,\r
3450 IN UINTN Length\r
3451 );\r
3452\r
3453\r
3454/**\r
3455 Returns the two's complement checksum of all elements in a buffer of\r
3456 64-bit values.\r
3457\r
3458 This function first calculates the sum of the 64-bit values in the buffer\r
3459 specified by Buffer and Length. The carry bits in the result of addition\r
3460 are dropped. Then, the two's complement of the sum is returned. If Length\r
3461 is 0, then 0 is returned.\r
3462\r
3463 If Buffer is NULL, then ASSERT().\r
3464 If Buffer is not aligned on a 64-bit boundary, then ASSERT().\r
3465 If Length is not aligned on a 64-bit boundary, then ASSERT().\r
3466 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
3467\r
1106ffe1 3468 @param Buffer Pointer to the buffer to carry out the checksum operation.\r
3469 @param Length The size, in bytes, of Buffer.\r
ac644614 3470\r
3471 @return Checksum The 2's complement checksum of Buffer.\r
3472\r
3473**/\r
3474UINT64\r
3475EFIAPI\r
3476CalculateCheckSum64 (\r
3477 IN CONST UINT64 *Buffer,\r
3478 IN UINTN Length\r
3479 );\r
3480\r
3481\r
1106ffe1 3482///\r
3483/// Base Library CPU Functions\r
3484///\r
ac644614 3485typedef\r
3486VOID\r
9810cdd8 3487(EFIAPI *SWITCH_STACK_ENTRY_POINT)(\r
ac644614 3488 IN VOID *Context1, OPTIONAL\r
3489 IN VOID *Context2 OPTIONAL\r
3490 );\r
3491\r
3492\r
3493/**\r
3494 Used to serialize load and store operations.\r
3495\r
3496 All loads and stores that proceed calls to this function are guaranteed to be\r
3497 globally visible when this function returns.\r
3498\r
3499**/\r
3500VOID\r
3501EFIAPI\r
3502MemoryFence (\r
3503 VOID\r
3504 );\r
3505\r
3506\r
3507/**\r
3508 Saves the current CPU context that can be restored with a call to LongJump()\r
3509 and returns 0.\r
3510\r
3511 Saves the current CPU context in the buffer specified by JumpBuffer and\r
3512 returns 0. The initial call to SetJump() must always return 0. Subsequent\r
3513 calls to LongJump() cause a non-zero value to be returned by SetJump().\r
3514\r
3515 If JumpBuffer is NULL, then ASSERT().\r
3516 For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().\r
3517\r
3518 @param JumpBuffer A pointer to CPU context buffer.\r
3519\r
3520 @retval 0 Indicates a return from SetJump().\r
3521\r
3522**/\r
3523UINTN\r
3524EFIAPI\r
3525SetJump (\r
3526 OUT BASE_LIBRARY_JUMP_BUFFER *JumpBuffer\r
3527 );\r
3528\r
3529\r
3530/**\r
3531 Restores the CPU context that was saved with SetJump().\r
3532\r
3533 Restores the CPU context from the buffer specified by JumpBuffer. This\r
3534 function never returns to the caller. Instead is resumes execution based on\r
3535 the state of JumpBuffer.\r
3536\r
3537 If JumpBuffer is NULL, then ASSERT().\r
3538 For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().\r
3539 If Value is 0, then ASSERT().\r
3540\r
3541 @param JumpBuffer A pointer to CPU context buffer.\r
3542 @param Value The value to return when the SetJump() context is\r
3543 restored and must be non-zero.\r
3544\r
3545**/\r
3546VOID\r
3547EFIAPI\r
3548LongJump (\r
3549 IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer,\r
3550 IN UINTN Value\r
3551 );\r
3552\r
3553\r
3554/**\r
3555 Enables CPU interrupts.\r
3556\r
ac644614 3557**/\r
3558VOID\r
3559EFIAPI\r
3560EnableInterrupts (\r
3561 VOID\r
3562 );\r
3563\r
3564\r
3565/**\r
3566 Disables CPU interrupts.\r
3567\r
ac644614 3568**/\r
3569VOID\r
3570EFIAPI\r
3571DisableInterrupts (\r
3572 VOID\r
3573 );\r
3574\r
3575\r
3576/**\r
3577 Disables CPU interrupts and returns the interrupt state prior to the disable\r
3578 operation.\r
3579\r
ac644614 3580 @retval TRUE CPU interrupts were enabled on entry to this call.\r
3581 @retval FALSE CPU interrupts were disabled on entry to this call.\r
3582\r
3583**/\r
3584BOOLEAN\r
3585EFIAPI\r
3586SaveAndDisableInterrupts (\r
3587 VOID\r
3588 );\r
3589\r
3590\r
3591/**\r
3592 Enables CPU interrupts for the smallest window required to capture any\r
3593 pending interrupts.\r
3594\r
ac644614 3595**/\r
3596VOID\r
3597EFIAPI\r
3598EnableDisableInterrupts (\r
3599 VOID\r
3600 );\r
3601\r
3602\r
3603/**\r
3604 Retrieves the current CPU interrupt state.\r
3605\r
38bbd3d9 3606 Returns TRUE is interrupts are currently enabled. Otherwise\r
3607 returns FALSE.\r
ac644614 3608\r
3609 @retval TRUE CPU interrupts are enabled.\r
3610 @retval FALSE CPU interrupts are disabled.\r
3611\r
3612**/\r
3613BOOLEAN\r
3614EFIAPI\r
3615GetInterruptState (\r
3616 VOID\r
3617 );\r
3618\r
3619\r
3620/**\r
3621 Set the current CPU interrupt state.\r
3622\r
3623 Sets the current CPU interrupt state to the state specified by\r
3624 InterruptState. If InterruptState is TRUE, then interrupts are enabled. If\r
3625 InterruptState is FALSE, then interrupts are disabled. InterruptState is\r
3626 returned.\r
3627\r
3628 @param InterruptState TRUE if interrupts should enabled. FALSE if\r
3629 interrupts should be disabled.\r
3630\r
3631 @return InterruptState\r
3632\r
3633**/\r
3634BOOLEAN\r
3635EFIAPI\r
3636SetInterruptState (\r
3637 IN BOOLEAN InterruptState\r
3638 );\r
3639\r
3640\r
3641/**\r
3642 Requests CPU to pause for a short period of time.\r
3643\r
3644 Requests CPU to pause for a short period of time. Typically used in MP\r
3645 systems to prevent memory starvation while waiting for a spin lock.\r
3646\r
3647**/\r
3648VOID\r
3649EFIAPI\r
3650CpuPause (\r
3651 VOID\r
3652 );\r
3653\r
3654\r
3655/**\r
3656 Transfers control to a function starting with a new stack.\r
3657\r
3658 Transfers control to the function specified by EntryPoint using the\r
3659 new stack specified by NewStack and passing in the parameters specified\r
3660 by Context1 and Context2. Context1 and Context2 are optional and may\r
3661 be NULL. The function EntryPoint must never return. This function\r
3662 supports a variable number of arguments following the NewStack parameter.\r
3663 These additional arguments are ignored on IA-32, x64, and EBC.\r
3664 IPF CPUs expect one additional parameter of type VOID * that specifies\r
3665 the new backing store pointer.\r
3666\r
3667 If EntryPoint is NULL, then ASSERT().\r
3668 If NewStack is NULL, then ASSERT().\r
3669\r
3670 @param EntryPoint A pointer to function to call with the new stack.\r
3671 @param Context1 A pointer to the context to pass into the EntryPoint\r
3672 function.\r
3673 @param Context2 A pointer to the context to pass into the EntryPoint\r
3674 function.\r
3675 @param NewStack A pointer to the new stack to use for the EntryPoint\r
3676 function.\r
42eedea9 3677 @param ... Extended parameters.\r
3678\r
ac644614 3679\r
3680**/\r
3681VOID\r
3682EFIAPI\r
3683SwitchStack (\r
3684 IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r
3685 IN VOID *Context1, OPTIONAL\r
3686 IN VOID *Context2, OPTIONAL\r
3687 IN VOID *NewStack,\r
3688 ...\r
3689 );\r
3690\r
3691\r
3692/**\r
3693 Generates a breakpoint on the CPU.\r
3694\r
3695 Generates a breakpoint on the CPU. The breakpoint must be implemented such\r
3696 that code can resume normal execution after the breakpoint.\r
3697\r
3698**/\r
3699VOID\r
3700EFIAPI\r
3701CpuBreakpoint (\r
3702 VOID\r
3703 );\r
3704\r
3705\r
3706/**\r
3707 Executes an infinite loop.\r
3708\r
3709 Forces the CPU to execute an infinite loop. A debugger may be used to skip\r
3710 past the loop and the code that follows the loop must execute properly. This\r
3711 implies that the infinite loop must not cause the code that follow it to be\r
3712 optimized away.\r
3713\r
3714**/\r
3715VOID\r
3716EFIAPI\r
3717CpuDeadLoop (\r
3718 VOID\r
3719 );\r
3720\r
3721\r
3722#if defined (MDE_CPU_IPF)\r
3723\r
3724/**\r
3725 Flush a range of cache lines in the cache coherency domain of the calling\r
3726 CPU.\r
3727\r
3728 Invalidates the cache lines specified by Address and Length. If Address is\r
3729 not aligned on a cache line boundary, then entire cache line containing\r
3730 Address is invalidated. If Address + Length is not aligned on a cache line\r
3731 boundary, then the entire instruction cache line containing Address + Length\r
3732 -1 is invalidated. This function may choose to invalidate the entire\r
3733 instruction cache if that is more efficient than invalidating the specified\r
3734 range. If Length is 0, the no instruction cache lines are invalidated.\r
3735 Address is returned.\r
3736\r
3737 If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().\r
3738\r
3739 @param Address The base address of the instruction lines to invalidate. If\r
3740 the CPU is in a physical addressing mode, then Address is a\r
3741 physical address. If the CPU is in a virtual addressing mode,\r
3742 then Address is a virtual address.\r
3743\r
3744 @param Length The number of bytes to invalidate from the instruction cache.\r
3745\r
3746 @return Address\r
3747\r
3748**/\r
3749VOID *\r
3750EFIAPI\r
3751IpfFlushCacheRange (\r
3752 IN VOID *Address,\r
3753 IN UINTN Length\r
3754 );\r
3755\r
3756\r
3757/**\r
3758 Executes a FC instruction\r
3759 Executes a FC instruction on the cache line specified by Address.\r
3760 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).\r
3761 An implementation may flush a larger region. This function is only available on IPF.\r
3762\r
3763 @param Address The Address of cache line to be flushed.\r
3764\r
3765 @return The address of FC instruction executed.\r
3766\r
3767**/\r
3768UINT64\r
3769EFIAPI\r
3770AsmFc (\r
3771 IN UINT64 Address\r
3772 );\r
3773\r
3774\r
3775/**\r
3776 Executes a FC.I instruction.\r
3777 Executes a FC.I instruction on the cache line specified by Address.\r
3778 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).\r
3779 An implementation may flush a larger region. This function is only available on IPF.\r
3780\r
3781 @param Address The Address of cache line to be flushed.\r
3782\r
3783 @return The address of FC.I instruction executed.\r
3784\r
3785**/\r
3786UINT64\r
3787EFIAPI\r
3788AsmFci (\r
3789 IN UINT64 Address\r
3790 );\r
3791\r
3792\r
3793/**\r
3794 Reads the current value of a Processor Identifier Register (CPUID).\r
3795 The Index of largest implemented CPUID (One less than the number of implemented CPUID\r
3796 registers) is determined by CPUID [3] bits {7:0}.\r
3797 No parameter checking is performed on Index. If the Index value is beyond the\r
3798 implemented CPUID register range, a Reserved Register/Field fault may occur. The caller\r
3799 must either guarantee that Index is valid, or the caller must set up fault handlers to\r
3800 catch the faults. This function is only available on IPF.\r
3801\r
3802 @param Index The 8-bit Processor Identifier Register index to read.\r
3803\r
3804 @return The current value of Processor Identifier Register specified by Index.\r
3805\r
3806**/\r
3807UINT64\r
3808EFIAPI\r
3809AsmReadCpuid (\r
3810 IN UINT8 Index\r
3811 );\r
3812\r
3813\r
3814/**\r
3815 Reads the current value of 64-bit Processor Status Register (PSR).\r
3816 This function is only available on IPF.\r
3817\r
3818 @return The current value of PSR.\r
3819\r
3820**/\r
3821UINT64\r
3822EFIAPI\r
3823AsmReadPsr (\r
3824 VOID\r
3825 );\r
3826\r
3827\r
3828/**\r
3829 Writes the current value of 64-bit Processor Status Register (PSR).\r
3830 No parameter checking is performed on Value. All bits of Value corresponding to\r
3831 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
3832 This function is only available on IPF.\r
3833\r
3834 @param Value The 64-bit value to write to PSR.\r
3835\r
3836 @return The 64-bit value written to the PSR.\r
3837\r
3838**/\r
3839UINT64\r
3840EFIAPI\r
3841AsmWritePsr (\r
3842 IN UINT64 Value\r
3843 );\r
3844\r
3845\r
3846/**\r
3847 Reads the current value of 64-bit Kernel Register #0 (KR0).\r
3848 This function is only available on IPF.\r
3849\r
3850 @return The current value of KR0.\r
3851\r
3852**/\r
3853UINT64\r
3854EFIAPI\r
3855AsmReadKr0 (\r
3856 VOID\r
3857 );\r
3858\r
3859\r
3860/**\r
3861 Reads the current value of 64-bit Kernel Register #1 (KR1).\r
3862 This function is only available on IPF.\r
3863\r
3864 @return The current value of KR1.\r
3865\r
3866**/\r
3867UINT64\r
3868EFIAPI\r
3869AsmReadKr1 (\r
3870 VOID\r
3871 );\r
3872\r
3873\r
3874/**\r
3875 Reads the current value of 64-bit Kernel Register #2 (KR2).\r
3876 This function is only available on IPF.\r
3877\r
3878 @return The current value of KR2.\r
3879\r
3880**/\r
3881UINT64\r
3882EFIAPI\r
3883AsmReadKr2 (\r
3884 VOID\r
3885 );\r
3886\r
3887\r
3888/**\r
3889 Reads the current value of 64-bit Kernel Register #3 (KR3).\r
3890 This function is only available on IPF.\r
3891\r
3892 @return The current value of KR3.\r
3893\r
3894**/\r
3895UINT64\r
3896EFIAPI\r
3897AsmReadKr3 (\r
3898 VOID\r
3899 );\r
3900\r
3901\r
3902/**\r
3903 Reads the current value of 64-bit Kernel Register #4 (KR4).\r
3904 This function is only available on IPF.\r
3905\r
3906 @return The current value of KR4.\r
3907\r
3908**/\r
3909UINT64\r
3910EFIAPI\r
3911AsmReadKr4 (\r
3912 VOID\r
3913 );\r
3914\r
3915\r
3916/**\r
3917 Reads the current value of 64-bit Kernel Register #5 (KR5).\r
3918 This function is only available on IPF.\r
3919\r
3920 @return The current value of KR5.\r
3921\r
3922**/\r
3923UINT64\r
3924EFIAPI\r
3925AsmReadKr5 (\r
3926 VOID\r
3927 );\r
3928\r
3929\r
3930/**\r
3931 Reads the current value of 64-bit Kernel Register #6 (KR6).\r
3932 This function is only available on IPF.\r
3933\r
3934 @return The current value of KR6.\r
3935\r
3936**/\r
3937UINT64\r
3938EFIAPI\r
3939AsmReadKr6 (\r
3940 VOID\r
3941 );\r
3942\r
3943\r
3944/**\r
3945 Reads the current value of 64-bit Kernel Register #7 (KR7).\r
3946 This function is only available on IPF.\r
3947\r
3948 @return The current value of KR7.\r
3949\r
3950**/\r
3951UINT64\r
3952EFIAPI\r
3953AsmReadKr7 (\r
3954 VOID\r
3955 );\r
3956\r
3957\r
3958/**\r
3959 Write the current value of 64-bit Kernel Register #0 (KR0).\r
3960 This function is only available on IPF.\r
3961\r
3962 @param Value The 64-bit value to write to KR0.\r
3963\r
3964 @return The 64-bit value written to the KR0.\r
3965\r
3966**/\r
3967UINT64\r
3968EFIAPI\r
3969AsmWriteKr0 (\r
3970 IN UINT64 Value\r
3971 );\r
3972\r
3973\r
3974/**\r
3975 Write the current value of 64-bit Kernel Register #1 (KR1).\r
3976 This function is only available on IPF.\r
3977\r
3978 @param Value The 64-bit value to write to KR1.\r
3979\r
3980 @return The 64-bit value written to the KR1.\r
3981\r
3982**/\r
3983UINT64\r
3984EFIAPI\r
3985AsmWriteKr1 (\r
3986 IN UINT64 Value\r
3987 );\r
3988\r
3989\r
3990/**\r
3991 Write the current value of 64-bit Kernel Register #2 (KR2).\r
3992 This function is only available on IPF.\r
3993\r
3994 @param Value The 64-bit value to write to KR2.\r
3995\r
3996 @return The 64-bit value written to the KR2.\r
3997\r
3998**/\r
3999UINT64\r
4000EFIAPI\r
4001AsmWriteKr2 (\r
4002 IN UINT64 Value\r
4003 );\r
4004\r
4005\r
4006/**\r
4007 Write the current value of 64-bit Kernel Register #3 (KR3).\r
4008 This function is only available on IPF.\r
4009\r
4010 @param Value The 64-bit value to write to KR3.\r
4011\r
4012 @return The 64-bit value written to the KR3.\r
4013\r
4014**/\r
4015UINT64\r
4016EFIAPI\r
4017AsmWriteKr3 (\r
4018 IN UINT64 Value\r
4019 );\r
4020\r
4021\r
4022/**\r
4023 Write the current value of 64-bit Kernel Register #4 (KR4).\r
4024 This function is only available on IPF.\r
4025\r
4026 @param Value The 64-bit value to write to KR4.\r
4027\r
4028 @return The 64-bit value written to the KR4.\r
4029\r
4030**/\r
4031UINT64\r
4032EFIAPI\r
4033AsmWriteKr4 (\r
4034 IN UINT64 Value\r
4035 );\r
4036\r
4037\r
4038/**\r
4039 Write the current value of 64-bit Kernel Register #5 (KR5).\r
4040 This function is only available on IPF.\r
4041\r
4042 @param Value The 64-bit value to write to KR5.\r
4043\r
4044 @return The 64-bit value written to the KR5.\r
4045\r
4046**/\r
4047UINT64\r
4048EFIAPI\r
4049AsmWriteKr5 (\r
4050 IN UINT64 Value\r
4051 );\r
4052\r
4053\r
4054/**\r
4055 Write the current value of 64-bit Kernel Register #6 (KR6).\r
4056 This function is only available on IPF.\r
4057\r
4058 @param Value The 64-bit value to write to KR6.\r
4059\r
4060 @return The 64-bit value written to the KR6.\r
4061\r
4062**/\r
4063UINT64\r
4064EFIAPI\r
4065AsmWriteKr6 (\r
4066 IN UINT64 Value\r
4067 );\r
4068\r
4069\r
4070/**\r
4071 Write the current value of 64-bit Kernel Register #7 (KR7).\r
4072 This function is only available on IPF.\r
4073\r
4074 @param Value The 64-bit value to write to KR7.\r
4075\r
4076 @return The 64-bit value written to the KR7.\r
4077\r
4078**/\r
4079UINT64\r
4080EFIAPI\r
4081AsmWriteKr7 (\r
4082 IN UINT64 Value\r
4083 );\r
4084\r
4085\r
4086/**\r
4087 Reads the current value of Interval Timer Counter Register (ITC).\r
4088 This function is only available on IPF.\r
4089\r
4090 @return The current value of ITC.\r
4091\r
4092**/\r
4093UINT64\r
4094EFIAPI\r
4095AsmReadItc (\r
4096 VOID\r
4097 );\r
4098\r
4099\r
4100/**\r
4101 Reads the current value of Interval Timer Vector Register (ITV).\r
4102 This function is only available on IPF.\r
4103\r
4104 @return The current value of ITV.\r
4105\r
4106**/\r
4107UINT64\r
4108EFIAPI\r
4109AsmReadItv (\r
4110 VOID\r
4111 );\r
4112\r
4113\r
4114/**\r
4115 Reads the current value of Interval Timer Match Register (ITM).\r
4116 This function is only available on IPF.\r
4117\r
4118 @return The current value of ITM.\r
4119**/\r
4120UINT64\r
4121EFIAPI\r
4122AsmReadItm (\r
4123 VOID\r
4124 );\r
4125\r
4126\r
4127/**\r
4128 Writes the current value of 64-bit Interval Timer Counter Register (ITC).\r
4129 This function is only available on IPF.\r
4130\r
4131 @param Value The 64-bit value to write to ITC.\r
4132\r
4133 @return The 64-bit value written to the ITC.\r
4134\r
4135**/\r
4136UINT64\r
4137EFIAPI\r
4138AsmWriteItc (\r
4139 IN UINT64 Value\r
4140 );\r
4141\r
4142\r
4143/**\r
4144 Writes the current value of 64-bit Interval Timer Match Register (ITM).\r
4145 This function is only available on IPF.\r
4146\r
4147 @param Value The 64-bit value to write to ITM.\r
4148\r
4149 @return The 64-bit value written to the ITM.\r
4150\r
4151**/\r
4152UINT64\r
4153EFIAPI\r
4154AsmWriteItm (\r
4155 IN UINT64 Value\r
4156 );\r
4157\r
4158\r
4159/**\r
4160 Writes the current value of 64-bit Interval Timer Vector Register (ITV).\r
4161 No parameter checking is performed on Value. All bits of Value corresponding to\r
4162 reserved fields of ITV must be 0 or a Reserved Register/Field fault may occur.\r
4163 The caller must either guarantee that Value is valid, or the caller must set up\r
4164 fault handlers to catch the faults.\r
4165 This function is only available on IPF.\r
4166\r
4167 @param Value The 64-bit value to write to ITV.\r
4168\r
4169 @return The 64-bit value written to the ITV.\r
4170\r
4171**/\r
4172UINT64\r
4173EFIAPI\r
4174AsmWriteItv (\r
4175 IN UINT64 Value\r
4176 );\r
4177\r
4178\r
4179/**\r
4180 Reads the current value of Default Control Register (DCR).\r
4181 This function is only available on IPF.\r
4182\r
4183 @return The current value of DCR.\r
4184\r
4185**/\r
4186UINT64\r
4187EFIAPI\r
4188AsmReadDcr (\r
4189 VOID\r
4190 );\r
4191\r
4192\r
4193/**\r
4194 Reads the current value of Interruption Vector Address Register (IVA).\r
4195 This function is only available on IPF.\r
4196\r
4197 @return The current value of IVA.\r
4198**/\r
4199UINT64\r
4200EFIAPI\r
4201AsmReadIva (\r
4202 VOID\r
4203 );\r
4204\r
4205\r
4206/**\r
4207 Reads the current value of Page Table Address Register (PTA).\r
4208 This function is only available on IPF.\r
4209\r
4210 @return The current value of PTA.\r
4211\r
4212**/\r
4213UINT64\r
4214EFIAPI\r
4215AsmReadPta (\r
4216 VOID\r
4217 );\r
4218\r
4219\r
4220/**\r
4221 Writes the current value of 64-bit Default Control Register (DCR).\r
4222 No parameter checking is performed on Value. All bits of Value corresponding to\r
4223 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.\r
4224 The caller must either guarantee that Value is valid, or the caller must set up\r
4225 fault handlers to catch the faults.\r
4226 This function is only available on IPF.\r
4227\r
4228 @param Value The 64-bit value to write to DCR.\r
4229\r
4230 @return The 64-bit value written to the DCR.\r
4231\r
4232**/\r
4233UINT64\r
4234EFIAPI\r
4235AsmWriteDcr (\r
4236 IN UINT64 Value\r
4237 );\r
4238\r
4239\r
4240/**\r
4241 Writes the current value of 64-bit Interruption Vector Address Register (IVA).\r
4242 The size of vector table is 32 K bytes and is 32 K bytes aligned\r
4243 the low 15 bits of Value is ignored when written.\r
4244 This function is only available on IPF.\r
4245\r
4246 @param Value The 64-bit value to write to IVA.\r
4247\r
4248 @return The 64-bit value written to the IVA.\r
4249\r
4250**/\r
4251UINT64\r
4252EFIAPI\r
4253AsmWriteIva (\r
4254 IN UINT64 Value\r
4255 );\r
4256\r
4257\r
4258/**\r
4259 Writes the current value of 64-bit Page Table Address Register (PTA).\r
4260 No parameter checking is performed on Value. All bits of Value corresponding to\r
4261 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.\r
4262 The caller must either guarantee that Value is valid, or the caller must set up\r
4263 fault handlers to catch the faults.\r
4264 This function is only available on IPF.\r
4265\r
4266 @param Value The 64-bit value to write to PTA.\r
4267\r
4268 @return The 64-bit value written to the PTA.\r
4269**/\r
4270UINT64\r
4271EFIAPI\r
4272AsmWritePta (\r
4273 IN UINT64 Value\r
4274 );\r
4275\r
4276\r
4277/**\r
4278 Reads the current value of Local Interrupt ID Register (LID).\r
4279 This function is only available on IPF.\r
4280\r
4281 @return The current value of LID.\r
4282\r
4283**/\r
4284UINT64\r
4285EFIAPI\r
4286AsmReadLid (\r
4287 VOID\r
4288 );\r
4289\r
4290\r
4291/**\r
4292 Reads the current value of External Interrupt Vector Register (IVR).\r
4293 This function is only available on IPF.\r
4294\r
4295 @return The current value of IVR.\r
4296\r
4297**/\r
4298UINT64\r
4299EFIAPI\r
4300AsmReadIvr (\r
4301 VOID\r
4302 );\r
4303\r
4304\r
4305/**\r
4306 Reads the current value of Task Priority Register (TPR).\r
4307 This function is only available on IPF.\r
4308\r
4309 @return The current value of TPR.\r
4310\r
4311**/\r
4312UINT64\r
4313EFIAPI\r
4314AsmReadTpr (\r
4315 VOID\r
4316 );\r
4317\r
4318\r
4319/**\r
4320 Reads the current value of External Interrupt Request Register #0 (IRR0).\r
4321 This function is only available on IPF.\r
4322\r
4323 @return The current value of IRR0.\r
4324\r
4325**/\r
4326UINT64\r
4327EFIAPI\r
4328AsmReadIrr0 (\r
4329 VOID\r
4330 );\r
4331\r
4332\r
4333/**\r
4334 Reads the current value of External Interrupt Request Register #1 (IRR1).\r
4335 This function is only available on IPF.\r
4336\r
4337 @return The current value of IRR1.\r
4338\r
4339**/\r
4340UINT64\r
4341EFIAPI\r
4342AsmReadIrr1 (\r
4343 VOID\r
4344 );\r
4345\r
4346\r
4347/**\r
4348 Reads the current value of External Interrupt Request Register #2 (IRR2).\r
4349 This function is only available on IPF.\r
4350\r
4351 @return The current value of IRR2.\r
4352\r
4353**/\r
4354UINT64\r
4355EFIAPI\r
4356AsmReadIrr2 (\r
4357 VOID\r
4358 );\r
4359\r
4360\r
4361/**\r
4362 Reads the current value of External Interrupt Request Register #3 (IRR3).\r
4363 This function is only available on IPF.\r
4364\r
4365 @return The current value of IRR3.\r
4366\r
4367**/\r
4368UINT64\r
4369EFIAPI\r
4370AsmReadIrr3 (\r
4371 VOID\r
4372 );\r
4373\r
4374\r
4375/**\r
4376 Reads the current value of Performance Monitor Vector Register (PMV).\r
4377 This function is only available on IPF.\r
4378\r
4379 @return The current value of PMV.\r
4380\r
4381**/\r
4382UINT64\r
4383EFIAPI\r
4384AsmReadPmv (\r
4385 VOID\r
4386 );\r
4387\r
4388\r
4389/**\r
4390 Reads the current value of Corrected Machine Check Vector Register (CMCV).\r
4391 This function is only available on IPF.\r
4392\r
4393 @return The current value of CMCV.\r
4394\r
4395**/\r
4396UINT64\r
4397EFIAPI\r
4398AsmReadCmcv (\r
4399 VOID\r
4400 );\r
4401\r
4402\r
4403/**\r
4404 Reads the current value of Local Redirection Register #0 (LRR0).\r
4405 This function is only available on IPF.\r
4406\r
4407 @return The current value of LRR0.\r
4408\r
4409**/\r
4410UINT64\r
4411EFIAPI\r
4412AsmReadLrr0 (\r
4413 VOID\r
4414 );\r
4415\r
4416\r
4417/**\r
4418 Reads the current value of Local Redirection Register #1 (LRR1).\r
4419 This function is only available on IPF.\r
4420\r
4421 @return The current value of LRR1.\r
4422\r
4423**/\r
4424UINT64\r
4425EFIAPI\r
4426AsmReadLrr1 (\r
4427 VOID\r
4428 );\r
4429\r
4430\r
4431/**\r
4432 Writes the current value of 64-bit Page Local Interrupt ID Register (LID).\r
4433 No parameter checking is performed on Value. All bits of Value corresponding to\r
4434 reserved fields of LID must be 0 or a Reserved Register/Field fault may occur.\r
4435 The caller must either guarantee that Value is valid, or the caller must set up\r
4436 fault handlers to catch the faults.\r
4437 This function is only available on IPF.\r
4438\r
4439 @param Value The 64-bit value to write to LID.\r
4440\r
4441 @return The 64-bit value written to the LID.\r
4442\r
4443**/\r
4444UINT64\r
4445EFIAPI\r
4446AsmWriteLid (\r
4447 IN UINT64 Value\r
4448 );\r
4449\r
4450\r
4451/**\r
4452 Writes the current value of 64-bit Task Priority Register (TPR).\r
4453 No parameter checking is performed on Value. All bits of Value corresponding to\r
4454 reserved fields of TPR must be 0 or a Reserved Register/Field fault may occur.\r
4455 The caller must either guarantee that Value is valid, or the caller must set up\r
4456 fault handlers to catch the faults.\r
4457 This function is only available on IPF.\r
4458\r
4459 @param Value The 64-bit value to write to TPR.\r
4460\r
4461 @return The 64-bit value written to the TPR.\r
4462\r
4463**/\r
4464UINT64\r
4465EFIAPI\r
4466AsmWriteTpr (\r
4467 IN UINT64 Value\r
4468 );\r
4469\r
4470\r
4471/**\r
4472 Performs a write operation on End OF External Interrupt Register (EOI).\r
4473 Writes a value of 0 to the EOI Register. This function is only available on IPF.\r
4474\r
4475**/\r
4476VOID\r
4477EFIAPI\r
4478AsmWriteEoi (\r
4479 VOID\r
4480 );\r
4481\r
4482\r
4483/**\r
4484 Writes the current value of 64-bit Performance Monitor Vector Register (PMV).\r
4485 No parameter checking is performed on Value. All bits of Value corresponding\r
4486 to reserved fields of PMV must be 0 or a Reserved Register/Field fault may occur.\r
4487 The caller must either guarantee that Value is valid, or the caller must set up\r
4488 fault handlers to catch the faults.\r
4489 This function is only available on IPF.\r
4490\r
4491 @param Value The 64-bit value to write to PMV.\r
4492\r
4493 @return The 64-bit value written to the PMV.\r
4494\r
4495**/\r
4496UINT64\r
4497EFIAPI\r
4498AsmWritePmv (\r
4499 IN UINT64 Value\r
4500 );\r
4501\r
4502\r
4503/**\r
4504 Writes the current value of 64-bit Corrected Machine Check Vector Register (CMCV).\r
4505 No parameter checking is performed on Value. All bits of Value corresponding\r
4506 to reserved fields of CMCV must be 0 or a Reserved Register/Field fault may occur.\r
4507 The caller must either guarantee that Value is valid, or the caller must set up\r
4508 fault handlers to catch the faults.\r
4509 This function is only available on IPF.\r
4510\r
4511 @param Value The 64-bit value to write to CMCV.\r
4512\r
4513 @return The 64-bit value written to the CMCV.\r
4514\r
4515**/\r
4516UINT64\r
4517EFIAPI\r
4518AsmWriteCmcv (\r
4519 IN UINT64 Value\r
4520 );\r
4521\r
4522\r
4523/**\r
4524 Writes the current value of 64-bit Local Redirection Register #0 (LRR0).\r
4525 No parameter checking is performed on Value. All bits of Value corresponding\r
4526 to reserved fields of LRR0 must be 0 or a Reserved Register/Field fault may occur.\r
4527 The caller must either guarantee that Value is valid, or the caller must set up\r
4528 fault handlers to catch the faults.\r
4529 This function is only available on IPF.\r
4530\r
4531 @param Value The 64-bit value to write to LRR0.\r
4532\r
4533 @return The 64-bit value written to the LRR0.\r
4534\r
4535**/\r
4536UINT64\r
4537EFIAPI\r
4538AsmWriteLrr0 (\r
4539 IN UINT64 Value\r
4540 );\r
4541\r
4542\r
4543/**\r
4544 Writes the current value of 64-bit Local Redirection Register #1 (LRR1).\r
4545 No parameter checking is performed on Value. All bits of Value corresponding\r
4546 to reserved fields of LRR1 must be 0 or a Reserved Register/Field fault may occur.\r
4547 The caller must either guarantee that Value is valid, or the caller must\r
4548 set up fault handlers to catch the faults.\r
4549 This function is only available on IPF.\r
4550\r
4551 @param Value The 64-bit value to write to LRR1.\r
4552\r
4553 @return The 64-bit value written to the LRR1.\r
4554\r
4555**/\r
4556UINT64\r
4557EFIAPI\r
4558AsmWriteLrr1 (\r
4559 IN UINT64 Value\r
4560 );\r
4561\r
4562\r
4563/**\r
4564 Reads the current value of Instruction Breakpoint Register (IBR).\r
4565 \r
4566 The Instruction Breakpoint Registers are used in pairs. The even numbered\r
4567 registers contain breakpoint addresses, and the odd numbered registers contain\r
4568 breakpoint mask conditions. At least 4 instruction registers pairs are implemented\r
4569 on all processor models. Implemented registers are contiguous starting with\r
4570 register 0. No parameter checking is performed on Index, and if the Index value\r
4571 is beyond the implemented IBR register range, a Reserved Register/Field fault may\r
4572 occur. The caller must either guarantee that Index is valid, or the caller must\r
4573 set up fault handlers to catch the faults.\r
4574 This function is only available on IPF.\r
4575\r
4576 @param Index The 8-bit Instruction Breakpoint Register index to read.\r
4577\r
4578 @return The current value of Instruction Breakpoint Register specified by Index.\r
4579\r
4580**/\r
4581UINT64\r
4582EFIAPI\r
4583AsmReadIbr (\r
4584 IN UINT8 Index\r
4585 );\r
4586\r
4587\r
4588/**\r
4589 Reads the current value of Data Breakpoint Register (DBR).\r
4590\r
4591 The Data Breakpoint Registers are used in pairs. The even numbered registers\r
4592 contain breakpoint addresses, and odd numbered registers contain breakpoint\r
4593 mask conditions. At least 4 data registers pairs are implemented on all processor\r
4594 models. Implemented registers are contiguous starting with register 0.\r
4595 No parameter checking is performed on Index. If the Index value is beyond\r
4596 the implemented DBR register range, a Reserved Register/Field fault may occur.\r
4597 The caller must either guarantee that Index is valid, or the caller must set up\r
4598 fault handlers to catch the faults.\r
4599 This function is only available on IPF.\r
4600\r
4601 @param Index The 8-bit Data Breakpoint Register index to read.\r
4602\r
4603 @return The current value of Data Breakpoint Register specified by Index.\r
4604\r
4605**/\r
4606UINT64\r
4607EFIAPI\r
4608AsmReadDbr (\r
4609 IN UINT8 Index\r
4610 );\r
4611\r
4612\r
4613/**\r
4614 Reads the current value of Performance Monitor Configuration Register (PMC).\r
4615\r
4616 All processor implementations provide at least 4 performance counters\r
4617 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter overflow\r
4618 status registers (PMC [0]... PMC [3]). Processor implementations may provide\r
4619 additional implementation-dependent PMC and PMD to increase the number of\r
4620 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD\r
4621 register set is implementation dependent. No parameter checking is performed\r
4622 on Index. If the Index value is beyond the implemented PMC register range,\r
4623 zero value will be returned.\r
4624 This function is only available on IPF.\r
4625\r
4626 @param Index The 8-bit Performance Monitor Configuration Register index to read.\r
4627\r
4628 @return The current value of Performance Monitor Configuration Register\r
4629 specified by Index.\r
4630\r
4631**/\r
4632UINT64\r
4633EFIAPI\r
4634AsmReadPmc (\r
4635 IN UINT8 Index\r
4636 );\r
4637\r
4638\r
4639/**\r
4640 Reads the current value of Performance Monitor Data Register (PMD).\r
4641\r
4642 All processor implementations provide at least 4 performance counters\r
4643 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter\r
4644 overflow status registers (PMC [0]... PMC [3]). Processor implementations may\r
4645 provide additional implementation-dependent PMC and PMD to increase the number\r
4646 of 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD\r
4647 register set is implementation dependent. No parameter checking is performed\r
4648 on Index. If the Index value is beyond the implemented PMD register range,\r
4649 zero value will be returned.\r
4650 This function is only available on IPF.\r
4651\r
4652 @param Index The 8-bit Performance Monitor Data Register index to read.\r
4653\r
4654 @return The current value of Performance Monitor Data Register specified by Index.\r
4655\r
4656**/\r
4657UINT64\r
4658EFIAPI\r
4659AsmReadPmd (\r
4660 IN UINT8 Index\r
4661 );\r
4662\r
4663\r
4664/**\r
4665 Writes the current value of 64-bit Instruction Breakpoint Register (IBR).\r
4666\r
4667 Writes current value of Instruction Breakpoint Register specified by Index.\r
4668 The Instruction Breakpoint Registers are used in pairs. The even numbered\r
4669 registers contain breakpoint addresses, and odd numbered registers contain\r
4670 breakpoint mask conditions. At least 4 instruction registers pairs are implemented\r
4671 on all processor models. Implemented registers are contiguous starting with\r
4672 register 0. No parameter checking is performed on Index. If the Index value\r
4673 is beyond the implemented IBR register range, a Reserved Register/Field fault may\r
4674 occur. The caller must either guarantee that Index is valid, or the caller must\r
4675 set up fault handlers to catch the faults.\r
4676 This function is only available on IPF.\r
4677\r
4678 @param Index The 8-bit Instruction Breakpoint Register index to write.\r
4679 @param Value The 64-bit value to write to IBR.\r
4680\r
4681 @return The 64-bit value written to the IBR.\r
4682\r
4683**/\r
4684UINT64\r
4685EFIAPI\r
4686AsmWriteIbr (\r
4687 IN UINT8 Index,\r
4688 IN UINT64 Value\r
4689 );\r
4690\r
4691\r
4692/**\r
4693 Writes the current value of 64-bit Data Breakpoint Register (DBR).\r
4694\r
4695 Writes current value of Data Breakpoint Register specified by Index.\r
4696 The Data Breakpoint Registers are used in pairs. The even numbered registers\r
4697 contain breakpoint addresses, and odd numbered registers contain breakpoint\r
4698 mask conditions. At least 4 data registers pairs are implemented on all processor\r
4699 models. Implemented registers are contiguous starting with register 0. No parameter\r
4700 checking is performed on Index. If the Index value is beyond the implemented\r
4701 DBR register range, a Reserved Register/Field fault may occur. The caller must\r
4702 either guarantee that Index is valid, or the caller must set up fault handlers to\r
4703 catch the faults.\r
4704 This function is only available on IPF.\r
4705\r
4706 @param Index The 8-bit Data Breakpoint Register index to write.\r
4707 @param Value The 64-bit value to write to DBR.\r
4708\r
4709 @return The 64-bit value written to the DBR.\r
4710\r
4711**/\r
4712UINT64\r
4713EFIAPI\r
4714AsmWriteDbr (\r
4715 IN UINT8 Index,\r
4716 IN UINT64 Value\r
4717 );\r
4718\r
4719\r
4720/**\r
4721 Writes the current value of 64-bit Performance Monitor Configuration Register (PMC).\r
4722\r
4723 Writes current value of Performance Monitor Configuration Register specified by Index.\r
4724 All processor implementations provide at least 4 performance counters\r
4725 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter overflow status\r
4726 registers (PMC [0]... PMC [3]). Processor implementations may provide additional\r
4727 implementation-dependent PMC and PMD to increase the number of 'generic' performance\r
4728 counters (PMC/PMD pairs). The remainder of PMC and PMD register set is implementation\r
4729 dependent. No parameter checking is performed on Index. If the Index value is\r
4730 beyond the implemented PMC register range, the write is ignored.\r
4731 This function is only available on IPF.\r
4732\r
4733 @param Index The 8-bit Performance Monitor Configuration Register index to write.\r
4734 @param Value The 64-bit value to write to PMC.\r
4735\r
4736 @return The 64-bit value written to the PMC.\r
4737\r
4738**/\r
4739UINT64\r
4740EFIAPI\r
4741AsmWritePmc (\r
4742 IN UINT8 Index,\r
4743 IN UINT64 Value\r
4744 );\r
4745\r
4746\r
4747/**\r
4748 Writes the current value of 64-bit Performance Monitor Data Register (PMD).\r
4749\r
4750 Writes current value of Performance Monitor Data Register specified by Index.\r
4751 All processor implementations provide at least 4 performance counters\r
4752 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter overflow\r
4753 status registers (PMC [0]... PMC [3]). Processor implementations may provide\r
4754 additional implementation-dependent PMC and PMD to increase the number of 'generic'\r
4755 performance counters (PMC/PMD pairs). The remainder of PMC and PMD register set\r
4756 is implementation dependent. No parameter checking is performed on Index. If the\r
4757 Index value is beyond the implemented PMD register range, the write is ignored.\r
4758 This function is only available on IPF.\r
4759\r
4760 @param Index The 8-bit Performance Monitor Data Register index to write.\r
4761 @param Value The 64-bit value to write to PMD.\r
4762\r
4763 @return The 64-bit value written to the PMD.\r
4764\r
4765**/\r
4766UINT64\r
4767EFIAPI\r
4768AsmWritePmd (\r
4769 IN UINT8 Index,\r
4770 IN UINT64 Value\r
4771 );\r
4772\r
4773\r
4774/**\r
4775 Reads the current value of 64-bit Global Pointer (GP).\r
4776\r
4777 Reads and returns the current value of GP.\r
4778 This function is only available on IPF.\r
4779\r
4780 @return The current value of GP.\r
4781\r
4782**/\r
4783UINT64\r
4784EFIAPI\r
4785AsmReadGp (\r
4786 VOID\r
4787 );\r
4788\r
4789\r
4790/**\r
4791 Write the current value of 64-bit Global Pointer (GP).\r
4792\r
4793 Writes the current value of GP. The 64-bit value written to the GP is returned.\r
4794 No parameter checking is performed on Value.\r
4795 This function is only available on IPF.\r
4796\r
4797 @param Value The 64-bit value to write to GP.\r
4798\r
4799 @return The 64-bit value written to the GP.\r
4800\r
4801**/\r
4802UINT64\r
4803EFIAPI\r
4804AsmWriteGp (\r
4805 IN UINT64 Value\r
4806 );\r
4807\r
4808\r
4809/**\r
4810 Reads the current value of 64-bit Stack Pointer (SP).\r
4811\r
4812 Reads and returns the current value of SP.\r
4813 This function is only available on IPF.\r
4814\r
4815 @return The current value of SP.\r
4816\r
4817**/\r
4818UINT64\r
4819EFIAPI\r
4820AsmReadSp (\r
4821 VOID\r
4822 );\r
4823\r
4824\r
4825/**\r
4826 Determines if the CPU is currently executing in virtual, physical, or mixed mode.\r
4827\r
4828 Determines the current execution mode of the CPU.\r
4829 If the CPU is in virtual mode(PSR.RT=1, PSR.DT=1, PSR.IT=1), then 1 is returned.\r
4830 If the CPU is in physical mode(PSR.RT=0, PSR.DT=0, PSR.IT=0), then 0 is returned.\r
4831 If the CPU is not in physical mode or virtual mode, then it is in mixed mode,\r
4832 and -1 is returned.\r
4833 This function is only available on IPF.\r
4834\r
4835 @return 1 The CPU is in virtual mode.\r
4836 @return 0 The CPU is in physical mode.\r
4837 @return -1 The CPU is in mixed mode.\r
4838\r
4839**/\r
4840INT64\r
4841EFIAPI\r
4842AsmCpuVirtual (\r
4843 VOID\r
4844 );\r
4845\r
4846\r
4847/**\r
4848 Makes a PAL procedure call.\r
4849\r
4850 This is a wrapper function to make a PAL procedure call. Based on the Index\r
4851 value this API will make static or stacked PAL call. The following table\r
4852 describes the usage of PAL Procedure Index Assignment. Architected procedures\r
4853 may be designated as required or optional. If a PAL procedure is specified\r
4854 as optional, a unique return code of 0xFFFFFFFFFFFFFFFF is returned in the\r
4855 Status field of the PAL_CALL_RETURN structure.\r
4856 This indicates that the procedure is not present in this PAL implementation.\r
4857 It is the caller's responsibility to check for this return code after calling\r
4858 any optional PAL procedure.\r
4859 No parameter checking is performed on the 5 input parameters, but there are\r
4860 some common rules that the caller should follow when making a PAL call. Any\r
4861 address passed to PAL as buffers for return parameters must be 8-byte aligned.\r
4862 Unaligned addresses may cause undefined results. For those parameters defined\r
4863 as reserved or some fields defined as reserved must be zero filled or the invalid\r
4864 argument return value may be returned or undefined result may occur during the\r
4865 execution of the procedure. If the PalEntryPoint does not point to a valid\r
4866 PAL entry point then the system behavior is undefined. This function is only\r
4867 available on IPF.\r
4868\r
4869 @param PalEntryPoint The PAL procedure calls entry point.\r
4870 @param Index The PAL procedure Index number.\r
4871 @param Arg2 The 2nd parameter for PAL procedure calls.\r
4872 @param Arg3 The 3rd parameter for PAL procedure calls.\r
4873 @param Arg4 The 4th parameter for PAL procedure calls.\r
4874\r
4875 @return structure returned from the PAL Call procedure, including the status and return value.\r
4876\r
4877**/\r
4878PAL_CALL_RETURN\r
4879EFIAPI\r
4880AsmPalCall (\r
4881 IN UINT64 PalEntryPoint,\r
4882 IN UINT64 Index,\r
4883 IN UINT64 Arg2,\r
4884 IN UINT64 Arg3,\r
4885 IN UINT64 Arg4\r
4886 );\r
4887\r
4888\r
4889/**\r
4890 Transfers control to a function starting with a new stack.\r
4891\r
4892 Transfers control to the function specified by EntryPoint using the new stack\r
4893 specified by NewStack and passing in the parameters specified by Context1 and\r
4894 Context2. Context1 and Context2 are optional and may be NULL. The function\r
4895 EntryPoint must never return.\r
4896\r
4897 If EntryPoint is NULL, then ASSERT().\r
4898 If NewStack is NULL, then ASSERT().\r
4899\r
4900 @param EntryPoint A pointer to function to call with the new stack.\r
4901 @param Context1 A pointer to the context to pass into the EntryPoint\r
4902 function.\r
4903 @param Context2 A pointer to the context to pass into the EntryPoint\r
4904 function.\r
4905 @param NewStack A pointer to the new stack to use for the EntryPoint\r
4906 function.\r
4907 @param NewBsp A pointer to the new memory location for RSE backing\r
4908 store.\r
4909\r
4910**/\r
4911VOID\r
4912EFIAPI\r
4913AsmSwitchStackAndBackingStore (\r
4914 IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r
4915 IN VOID *Context1, OPTIONAL\r
4916 IN VOID *Context2, OPTIONAL\r
4917 IN VOID *NewStack,\r
4918 IN VOID *NewBsp\r
4919 );\r
4920\r
ac644614 4921/**\r
1106ffe1 4922 @todo This call should be removed after the PalCall\r
4923 Instance issue has been fixed.\r
4924\r
ac644614 4925 Performs a PAL call using static calling convention.\r
4926\r
4927 An internal function to perform a PAL call using static calling convention.\r
4928\r
4929 @param PalEntryPoint The entry point address of PAL. The address in ar.kr5\r
4930 would be used if this parameter were NULL on input.\r
4931 @param Arg1 The first argument of a PAL call.\r
42eedea9 4932 @param Arg2 The second argument of a PAL call.\r
4933 @param Arg3 The third argument of a PAL call.\r
4934 @param Arg4 The fourth argument of a PAL call.\r
ac644614 4935\r
4936 @return The values returned in r8, r9, r10 and r11.\r
4937\r
4938**/\r
4939PAL_CALL_RETURN\r
4940PalCallStatic (\r
4941 IN CONST VOID *PalEntryPoint,\r
4942 IN UINT64 Arg1,\r
4943 IN UINT64 Arg2,\r
4944 IN UINT64 Arg3,\r
4945 IN UINT64 Arg4\r
4946 );\r
4947\r
4948\r
4949#elif defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)\r
1106ffe1 4950///\r
4951/// IA32 and X64 Specific Functions\r
4952/// Byte packed structure for 16-bit Real Mode EFLAGS\r
4953///\r
ac644614 4954typedef union {\r
4955 struct {\r
1106ffe1 4956 UINT32 CF:1; /// Carry Flag\r
4957 UINT32 Reserved_0:1; /// Reserved\r
4958 UINT32 PF:1; /// Parity Flag\r
4959 UINT32 Reserved_1:1; /// Reserved\r
4960 UINT32 AF:1; /// Auxiliary Carry Flag\r
4961 UINT32 Reserved_2:1; /// Reserved\r
4962 UINT32 ZF:1; /// Zero Flag\r
4963 UINT32 SF:1; /// Sign Flag\r
4964 UINT32 TF:1; /// Trap Flag\r
4965 UINT32 IF:1; /// Interrupt Enable Flag\r
4966 UINT32 DF:1; /// Direction Flag\r
4967 UINT32 OF:1; /// Overflow Flag\r
4968 UINT32 IOPL:2; /// I/O Privilege Level\r
4969 UINT32 NT:1; /// Nested Task\r
4970 UINT32 Reserved_3:1; /// Reserved\r
ac644614 4971 } Bits;\r
4972 UINT16 Uint16;\r
4973} IA32_FLAGS16;\r
4974\r
1106ffe1 4975///\r
4976/// Byte packed structure for EFLAGS/RFLAGS\r
4977/// 32-bits on IA-32\r
4978/// 64-bits on X64. The upper 32-bits on X64 are reserved\r
4979///\r
ac644614 4980typedef union {\r
4981 struct {\r
1106ffe1 4982 UINT32 CF:1; /// Carry Flag\r
4983 UINT32 Reserved_0:1; /// Reserved\r
4984 UINT32 PF:1; /// Parity Flag\r
4985 UINT32 Reserved_1:1; /// Reserved\r
4986 UINT32 AF:1; /// Auxiliary Carry Flag\r
4987 UINT32 Reserved_2:1; /// Reserved\r
4988 UINT32 ZF:1; /// Zero Flag\r
4989 UINT32 SF:1; /// Sign Flag\r
4990 UINT32 TF:1; /// Trap Flag\r
4991 UINT32 IF:1; /// Interrupt Enable Flag\r
4992 UINT32 DF:1; /// Direction Flag\r
4993 UINT32 OF:1; /// Overflow Flag\r
4994 UINT32 IOPL:2; /// I/O Privilege Level\r
4995 UINT32 NT:1; /// Nested Task\r
4996 UINT32 Reserved_3:1; /// Reserved\r
4997 UINT32 RF:1; /// Resume Flag\r
4998 UINT32 VM:1; /// Virtual 8086 Mode\r
4999 UINT32 AC:1; /// Alignment Check\r
5000 UINT32 VIF:1; /// Virtual Interrupt Flag\r
5001 UINT32 VIP:1; /// Virtual Interrupt Pending\r
5002 UINT32 ID:1; /// ID Flag\r
5003 UINT32 Reserved_4:10; /// Reserved\r
ac644614 5004 } Bits;\r
5005 UINTN UintN;\r
5006} IA32_EFLAGS32;\r
5007\r
1106ffe1 5008///\r
5009/// Byte packed structure for Control Register 0 (CR0)\r
5010/// 32-bits on IA-32\r
5011/// 64-bits on X64. The upper 32-bits on X64 are reserved\r
5012///\r
ac644614 5013typedef union {\r
5014 struct {\r
1106ffe1 5015 UINT32 PE:1; /// Protection Enable\r
5016 UINT32 MP:1; /// Monitor Coprocessor\r
5017 UINT32 EM:1; /// Emulation\r
5018 UINT32 TS:1; /// Task Switched\r
5019 UINT32 ET:1; /// Extension Type\r
5020 UINT32 NE:1; /// Numeric Error\r
5021 UINT32 Reserved_0:10; /// Reserved\r
5022 UINT32 WP:1; /// Write Protect\r
5023 UINT32 Reserved_1:1; /// Reserved\r
5024 UINT32 AM:1; /// Alignment Mask\r
5025 UINT32 Reserved_2:10; /// Reserved\r
5026 UINT32 NW:1; /// Mot Write-through\r
5027 UINT32 CD:1; /// Cache Disable\r
5028 UINT32 PG:1; /// Paging\r
ac644614 5029 } Bits;\r
5030 UINTN UintN;\r
5031} IA32_CR0;\r
5032\r
1106ffe1 5033///\r
5034/// Byte packed structure for Control Register 4 (CR4)\r
5035/// 32-bits on IA-32\r
5036/// 64-bits on X64. The upper 32-bits on X64 are reserved\r
5037///\r
ac644614 5038typedef union {\r
5039 struct {\r
1106ffe1 5040 UINT32 VME:1; /// Virtual-8086 Mode Extensions\r
5041 UINT32 PVI:1; /// Protected-Mode Virtual Interrupts\r
5042 UINT32 TSD:1; /// Time Stamp Disable\r
5043 UINT32 DE:1; /// Debugging Extensions\r
5044 UINT32 PSE:1; /// Page Size Extensions\r
5045 UINT32 PAE:1; /// Physical Address Extension\r
5046 UINT32 MCE:1; /// Machine Check Enable\r
5047 UINT32 PGE:1; /// Page Global Enable\r
5048 UINT32 PCE:1; /// Performance Monitoring Counter\r
5049 /// Enable\r
5050 UINT32 OSFXSR:1; /// Operating System Support for\r
5051 /// FXSAVE and FXRSTOR instructions\r
5052 UINT32 OSXMMEXCPT:1; /// Operating System Support for\r
5053 /// Unmasked SIMD Floating Point\r
5054 /// Exceptions\r
5055 UINT32 Reserved_0:2; /// Reserved\r
5056 UINT32 VMXE:1; /// VMX Enable\r
5057 UINT32 Reserved_1:18; /// Reseved\r
ac644614 5058 } Bits;\r
5059 UINTN UintN;\r
5060} IA32_CR4;\r
5061\r
1106ffe1 5062///\r
5063/// Byte packed structure for an IDTR, GDTR, LDTR descriptor\r
5064/// @todo How to make this structure byte-packed in a compiler independent way?\r
5065///\r
ac644614 5066#pragma pack (1)\r
5067typedef struct {\r
5068 UINT16 Limit;\r
5069 UINTN Base;\r
5070} IA32_DESCRIPTOR;\r
5071#pragma pack ()\r
5072\r
5073#define IA32_IDT_GATE_TYPE_TASK 0x85\r
5074#define IA32_IDT_GATE_TYPE_INTERRUPT_16 0x86\r
5075#define IA32_IDT_GATE_TYPE_TRAP_16 0x87\r
5076#define IA32_IDT_GATE_TYPE_INTERRUPT_32 0x8E\r
5077#define IA32_IDT_GATE_TYPE_TRAP_32 0x8F\r
5078\r
1106ffe1 5079///\r
5080/// Byte packed structure for an Interrupt Gate Descriptor\r
5081///\r
ac644614 5082typedef union {\r
5083 struct {\r
1106ffe1 5084 UINT32 OffsetLow:16; /// Offset bits 15..0\r
5085 UINT32 Selector:16; /// Selector\r
5086 UINT32 Reserved_0:8; /// Reserved\r
5087 UINT32 GateType:8; /// Gate Type. See #defines above\r
5088 UINT32 OffsetHigh:16; /// Offset bits 31..16\r
ac644614 5089 } Bits;\r
5090 UINT64 Uint64;\r
5091} IA32_IDT_GATE_DESCRIPTOR;\r
5092\r
1106ffe1 5093///\r
5094/// Byte packed structure for an FP/SSE/SSE2 context\r
5095///\r
ac644614 5096typedef struct {\r
5097 UINT8 Buffer[512];\r
5098} IA32_FX_BUFFER;\r
5099\r
1106ffe1 5100///\r
5101/// Structures for the 16-bit real mode thunks\r
5102///\r
ac644614 5103typedef struct {\r
5104 UINT32 Reserved1;\r
5105 UINT32 Reserved2;\r
5106 UINT32 Reserved3;\r
5107 UINT32 Reserved4;\r
5108 UINT8 BL;\r
5109 UINT8 BH;\r
5110 UINT16 Reserved5;\r
5111 UINT8 DL;\r
5112 UINT8 DH;\r
5113 UINT16 Reserved6;\r
5114 UINT8 CL;\r
5115 UINT8 CH;\r
5116 UINT16 Reserved7;\r
5117 UINT8 AL;\r
5118 UINT8 AH;\r
5119 UINT16 Reserved8;\r
5120} IA32_BYTE_REGS;\r
5121\r
5122typedef struct {\r
5123 UINT16 DI;\r
5124 UINT16 Reserved1;\r
5125 UINT16 SI;\r
5126 UINT16 Reserved2;\r
5127 UINT16 BP;\r
5128 UINT16 Reserved3;\r
5129 UINT16 SP;\r
5130 UINT16 Reserved4;\r
5131 UINT16 BX;\r
5132 UINT16 Reserved5;\r
5133 UINT16 DX;\r
5134 UINT16 Reserved6;\r
5135 UINT16 CX;\r
5136 UINT16 Reserved7;\r
5137 UINT16 AX;\r
5138 UINT16 Reserved8;\r
5139} IA32_WORD_REGS;\r
5140\r
5141typedef struct {\r
5142 UINT32 EDI;\r
5143 UINT32 ESI;\r
5144 UINT32 EBP;\r
5145 UINT32 ESP;\r
5146 UINT32 EBX;\r
5147 UINT32 EDX;\r
5148 UINT32 ECX;\r
5149 UINT32 EAX;\r
5150 UINT16 DS;\r
5151 UINT16 ES;\r
5152 UINT16 FS;\r
5153 UINT16 GS;\r
5154 IA32_EFLAGS32 EFLAGS;\r
5155 UINT32 Eip;\r
5156 UINT16 CS;\r
5157 UINT16 SS;\r
5158} IA32_DWORD_REGS;\r
5159\r
5160typedef union {\r
5161 IA32_DWORD_REGS E;\r
5162 IA32_WORD_REGS X;\r
5163 IA32_BYTE_REGS H;\r
5164} IA32_REGISTER_SET;\r
5165\r
1106ffe1 5166///\r
5167/// Byte packed structure for an 16-bit real mode thunks\r
5168///\r
ac644614 5169typedef struct {\r
5170 IA32_REGISTER_SET *RealModeState;\r
5171 VOID *RealModeBuffer;\r
5172 UINT32 RealModeBufferSize;\r
5173 UINT32 ThunkAttributes;\r
5174} THUNK_CONTEXT;\r
5175\r
5176#define THUNK_ATTRIBUTE_BIG_REAL_MODE 0x00000001\r
5177#define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 0x00000002\r
5178#define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004\r
5179\r
5180/**\r
5181 Retrieves CPUID information.\r
5182\r
5183 Executes the CPUID instruction with EAX set to the value specified by Index.\r
5184 This function always returns Index.\r
5185 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.\r
5186 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.\r
5187 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.\r
5188 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.\r
5189 This function is only available on IA-32 and X64.\r
5190\r
5191 @param Index The 32-bit value to load into EAX prior to invoking the CPUID\r
5192 instruction.\r
5193 @param Eax Pointer to the 32-bit EAX value returned by the CPUID\r
5194 instruction. This is an optional parameter that may be NULL.\r
5195 @param Ebx Pointer to the 32-bit EBX value returned by the CPUID\r
5196 instruction. This is an optional parameter that may be NULL.\r
5197 @param Ecx Pointer to the 32-bit ECX value returned by the CPUID\r
5198 instruction. This is an optional parameter that may be NULL.\r
5199 @param Edx Pointer to the 32-bit EDX value returned by the CPUID\r
5200 instruction. This is an optional parameter that may be NULL.\r
5201\r
5202 @return Index\r
5203\r
5204**/\r
5205UINT32\r
5206EFIAPI\r
5207AsmCpuid (\r
5208 IN UINT32 Index,\r
5209 OUT UINT32 *Eax, OPTIONAL\r
5210 OUT UINT32 *Ebx, OPTIONAL\r
5211 OUT UINT32 *Ecx, OPTIONAL\r
5212 OUT UINT32 *Edx OPTIONAL\r
5213 );\r
5214\r
5215\r
5216/**\r
5217 Retrieves CPUID information using an extended leaf identifier.\r
5218\r
5219 Executes the CPUID instruction with EAX set to the value specified by Index\r
5220 and ECX set to the value specified by SubIndex. This function always returns\r
5221 Index. This function is only available on IA-32 and x64.\r
5222\r
5223 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.\r
5224 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.\r
5225 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.\r
5226 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.\r
5227\r
5228 @param Index The 32-bit value to load into EAX prior to invoking the\r
5229 CPUID instruction.\r
5230 @param SubIndex The 32-bit value to load into ECX prior to invoking the\r
5231 CPUID instruction.\r
5232 @param Eax Pointer to the 32-bit EAX value returned by the CPUID\r
5233 instruction. This is an optional parameter that may be\r
5234 NULL.\r
5235 @param Ebx Pointer to the 32-bit EBX value returned by the CPUID\r
5236 instruction. This is an optional parameter that may be\r
5237 NULL.\r
5238 @param Ecx Pointer to the 32-bit ECX value returned by the CPUID\r
5239 instruction. This is an optional parameter that may be\r
5240 NULL.\r
5241 @param Edx Pointer to the 32-bit EDX value returned by the CPUID\r
5242 instruction. This is an optional parameter that may be\r
5243 NULL.\r
5244\r
5245 @return Index\r
5246\r
5247**/\r
5248UINT32\r
5249EFIAPI\r
5250AsmCpuidEx (\r
5251 IN UINT32 Index,\r
5252 IN UINT32 SubIndex,\r
5253 OUT UINT32 *Eax, OPTIONAL\r
5254 OUT UINT32 *Ebx, OPTIONAL\r
5255 OUT UINT32 *Ecx, OPTIONAL\r
5256 OUT UINT32 *Edx OPTIONAL\r
5257 );\r
5258\r
5259\r
5260/**\r
5261 Returns the lower 32-bits of a Machine Specific Register(MSR).\r
5262\r
5263 Reads and returns the lower 32-bits of the MSR specified by Index.\r
5264 No parameter checking is performed on Index, and some Index values may cause\r
5265 CPU exceptions. The caller must either guarantee that Index is valid, or the\r
5266 caller must set up exception handlers to catch the exceptions. This function\r
5267 is only available on IA-32 and X64.\r
5268\r
5269 @param Index The 32-bit MSR index to read.\r
5270\r
5271 @return The lower 32 bits of the MSR identified by Index.\r
5272\r
5273**/\r
5274UINT32\r
5275EFIAPI\r
5276AsmReadMsr32 (\r
5277 IN UINT32 Index\r
5278 );\r
5279\r
5280\r
5281/**\r
5282 Zero-extend a 32-bit value and writes it to a Machine Specific Register(MSR).\r
5283\r
5284 Writes the 32-bit value specified by Value to the MSR specified by Index. The\r
5285 upper 32-bits of the MSR write are set to zero. The 32-bit value written to\r
5286 the MSR is returned. No parameter checking is performed on Index or Value,\r
5287 and some of these may cause CPU exceptions. The caller must either guarantee\r
5288 that Index and Value are valid, or the caller must establish proper exception\r
5289 handlers. This function is only available on IA-32 and X64.\r
5290\r
5291 @param Index The 32-bit MSR index to write.\r
5292 @param Value The 32-bit value to write to the MSR.\r
5293\r
5294 @return Value\r
5295\r
5296**/\r
5297UINT32\r
5298EFIAPI\r
5299AsmWriteMsr32 (\r
5300 IN UINT32 Index,\r
5301 IN UINT32 Value\r
5302 );\r
5303\r
5304\r
5305/**\r
5306 Reads a 64-bit MSR, performs a bitwise inclusive OR on the lower 32-bits, and\r
5307 writes the result back to the 64-bit MSR.\r
5308\r
5309 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR\r
5310 between the lower 32-bits of the read result and the value specified by\r
5311 OrData, and writes the result to the 64-bit MSR specified by Index. The lower\r
5312 32-bits of the value written to the MSR is returned. No parameter checking is\r
5313 performed on Index or OrData, and some of these may cause CPU exceptions. The\r
5314 caller must either guarantee that Index and OrData are valid, or the caller\r
5315 must establish proper exception handlers. This function is only available on\r
5316 IA-32 and X64.\r
5317\r
5318 @param Index The 32-bit MSR index to write.\r
5319 @param OrData The value to OR with the read value from the MSR.\r
5320\r
5321 @return The lower 32-bit value written to the MSR.\r
5322\r
5323**/\r
5324UINT32\r
5325EFIAPI\r
5326AsmMsrOr32 (\r
5327 IN UINT32 Index,\r
5328 IN UINT32 OrData\r
5329 );\r
5330\r
5331\r
5332/**\r
5333 Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes\r
5334 the result back to the 64-bit MSR.\r
5335\r
5336 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r
5337 lower 32-bits of the read result and the value specified by AndData, and\r
5338 writes the result to the 64-bit MSR specified by Index. The lower 32-bits of\r
5339 the value written to the MSR is returned. No parameter checking is performed\r
5340 on Index or AndData, and some of these may cause CPU exceptions. The caller\r
5341 must either guarantee that Index and AndData are valid, or the caller must\r
5342 establish proper exception handlers. This function is only available on IA-32\r
5343 and X64.\r
5344\r
5345 @param Index The 32-bit MSR index to write.\r
5346 @param AndData The value to AND with the read value from the MSR.\r
5347\r
5348 @return The lower 32-bit value written to the MSR.\r
5349\r
5350**/\r
5351UINT32\r
5352EFIAPI\r
5353AsmMsrAnd32 (\r
5354 IN UINT32 Index,\r
5355 IN UINT32 AndData\r
5356 );\r
5357\r
5358\r
5359/**\r
5360 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive OR\r
5361 on the lower 32-bits, and writes the result back to the 64-bit MSR.\r
5362\r
5363 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r
5364 lower 32-bits of the read result and the value specified by AndData\r
5365 preserving the upper 32-bits, performs a bitwise inclusive OR between the\r
5366 result of the AND operation and the value specified by OrData, and writes the\r
5367 result to the 64-bit MSR specified by Address. The lower 32-bits of the value\r
5368 written to the MSR is returned. No parameter checking is performed on Index,\r
5369 AndData, or OrData, and some of these may cause CPU exceptions. The caller\r
5370 must either guarantee that Index, AndData, and OrData are valid, or the\r
5371 caller must establish proper exception handlers. This function is only\r
5372 available on IA-32 and X64.\r
5373\r
5374 @param Index The 32-bit MSR index to write.\r
5375 @param AndData The value to AND with the read value from the MSR.\r
5376 @param OrData The value to OR with the result of the AND operation.\r
5377\r
5378 @return The lower 32-bit value written to the MSR.\r
5379\r
5380**/\r
5381UINT32\r
5382EFIAPI\r
5383AsmMsrAndThenOr32 (\r
5384 IN UINT32 Index,\r
5385 IN UINT32 AndData,\r
5386 IN UINT32 OrData\r
5387 );\r
5388\r
5389\r
5390/**\r
5391 Reads a bit field of an MSR.\r
5392\r
5393 Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is\r
5394 specified by the StartBit and the EndBit. The value of the bit field is\r
5395 returned. The caller must either guarantee that Index is valid, or the caller\r
5396 must set up exception handlers to catch the exceptions. This function is only\r
5397 available on IA-32 and X64.\r
5398\r
5399 If StartBit is greater than 31, then ASSERT().\r
5400 If EndBit is greater than 31, then ASSERT().\r
5401 If EndBit is less than StartBit, then ASSERT().\r
5402\r
5403 @param Index The 32-bit MSR index to read.\r
5404 @param StartBit The ordinal of the least significant bit in the bit field.\r
5405 Range 0..31.\r
5406 @param EndBit The ordinal of the most significant bit in the bit field.\r
5407 Range 0..31.\r
5408\r
5409 @return The bit field read from the MSR.\r
5410\r
5411**/\r
5412UINT32\r
5413EFIAPI\r
5414AsmMsrBitFieldRead32 (\r
5415 IN UINT32 Index,\r
5416 IN UINTN StartBit,\r
5417 IN UINTN EndBit\r
5418 );\r
5419\r
5420\r
5421/**\r
5422 Writes a bit field to an MSR.\r
5423\r
5424 Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit\r
5425 field is specified by the StartBit and the EndBit. All other bits in the\r
5426 destination MSR are preserved. The lower 32-bits of the MSR written is\r
5427 returned. Extra left bits in Value are stripped. The caller must either\r
5428 guarantee that Index and the data written is valid, or the caller must set up\r
5429 exception handlers to catch the exceptions. This function is only available\r
5430 on IA-32 and X64.\r
5431\r
5432 If StartBit is greater than 31, then ASSERT().\r
5433 If EndBit is greater than 31, then ASSERT().\r
5434 If EndBit is less than StartBit, then ASSERT().\r
5435\r
5436 @param Index The 32-bit MSR index to write.\r
5437 @param StartBit The ordinal of the least significant bit in the bit field.\r
5438 Range 0..31.\r
5439 @param EndBit The ordinal of the most significant bit in the bit field.\r
5440 Range 0..31.\r
5441 @param Value New value of the bit field.\r
5442\r
5443 @return The lower 32-bit of the value written to the MSR.\r
5444\r
5445**/\r
5446UINT32\r
5447EFIAPI\r
5448AsmMsrBitFieldWrite32 (\r
5449 IN UINT32 Index,\r
5450 IN UINTN StartBit,\r
5451 IN UINTN EndBit,\r
5452 IN UINT32 Value\r
5453 );\r
5454\r
5455\r
5456/**\r
5457 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the\r
5458 result back to the bit field in the 64-bit MSR.\r
5459\r
5460 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR\r
5461 between the read result and the value specified by OrData, and writes the\r
5462 result to the 64-bit MSR specified by Index. The lower 32-bits of the value\r
5463 written to the MSR are returned. Extra left bits in OrData are stripped. The\r
5464 caller must either guarantee that Index and the data written is valid, or\r
5465 the caller must set up exception handlers to catch the exceptions. This\r
5466 function is only available on IA-32 and X64.\r
5467\r
5468 If StartBit is greater than 31, then ASSERT().\r
5469 If EndBit is greater than 31, then ASSERT().\r
5470 If EndBit is less than StartBit, then ASSERT().\r
5471\r
5472 @param Index The 32-bit MSR index to write.\r
5473 @param StartBit The ordinal of the least significant bit in the bit field.\r
5474 Range 0..31.\r
5475 @param EndBit The ordinal of the most significant bit in the bit field.\r
5476 Range 0..31.\r
5477 @param OrData The value to OR with the read value from the MSR.\r
5478\r
5479 @return The lower 32-bit of the value written to the MSR.\r
5480\r
5481**/\r
5482UINT32\r
5483EFIAPI\r
5484AsmMsrBitFieldOr32 (\r
5485 IN UINT32 Index,\r
5486 IN UINTN StartBit,\r
5487 IN UINTN EndBit,\r
5488 IN UINT32 OrData\r
5489 );\r
5490\r
5491\r
5492/**\r
5493 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the\r
5494 result back to the bit field in the 64-bit MSR.\r
5495\r
5496 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r
5497 read result and the value specified by AndData, and writes the result to the\r
5498 64-bit MSR specified by Index. The lower 32-bits of the value written to the\r
5499 MSR are returned. Extra left bits in AndData are stripped. The caller must\r
5500 either guarantee that Index and the data written is valid, or the caller must\r
5501 set up exception handlers to catch the exceptions. This function is only\r
5502 available on IA-32 and X64.\r
5503\r
5504 If StartBit is greater than 31, then ASSERT().\r
5505 If EndBit is greater than 31, then ASSERT().\r
5506 If EndBit is less than StartBit, then ASSERT().\r
5507\r
5508 @param Index The 32-bit MSR index to write.\r
5509 @param StartBit The ordinal of the least significant bit in the bit field.\r
5510 Range 0..31.\r
5511 @param EndBit The ordinal of the most significant bit in the bit field.\r
5512 Range 0..31.\r
5513 @param AndData The value to AND with the read value from the MSR.\r
5514\r
5515 @return The lower 32-bit of the value written to the MSR.\r
5516\r
5517**/\r
5518UINT32\r
5519EFIAPI\r
5520AsmMsrBitFieldAnd32 (\r
5521 IN UINT32 Index,\r
5522 IN UINTN StartBit,\r
5523 IN UINTN EndBit,\r
5524 IN UINT32 AndData\r
5525 );\r
5526\r
5527\r
5528/**\r
5529 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a\r
5530 bitwise inclusive OR, and writes the result back to the bit field in the\r
5531 64-bit MSR.\r
5532\r
5533 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a\r
5534 bitwise inclusive OR between the read result and the value specified by\r
5535 AndData, and writes the result to the 64-bit MSR specified by Index. The\r
5536 lower 32-bits of the value written to the MSR are returned. Extra left bits\r
5537 in both AndData and OrData are stripped. The caller must either guarantee\r
5538 that Index and the data written is valid, or the caller must set up exception\r
5539 handlers to catch the exceptions. This function is only available on IA-32\r
5540 and X64.\r
5541\r
5542 If StartBit is greater than 31, then ASSERT().\r
5543 If EndBit is greater than 31, then ASSERT().\r
5544 If EndBit is less than StartBit, then ASSERT().\r
5545\r
5546 @param Index The 32-bit MSR index to write.\r
5547 @param StartBit The ordinal of the least significant bit in the bit field.\r
5548 Range 0..31.\r
5549 @param EndBit The ordinal of the most significant bit in the bit field.\r
5550 Range 0..31.\r
5551 @param AndData The value to AND with the read value from the MSR.\r
5552 @param OrData The value to OR with the result of the AND operation.\r
5553\r
5554 @return The lower 32-bit of the value written to the MSR.\r
5555\r
5556**/\r
5557UINT32\r
5558EFIAPI\r
5559AsmMsrBitFieldAndThenOr32 (\r
5560 IN UINT32 Index,\r
5561 IN UINTN StartBit,\r
5562 IN UINTN EndBit,\r
5563 IN UINT32 AndData,\r
5564 IN UINT32 OrData\r
5565 );\r
5566\r
5567\r
5568/**\r
5569 Returns a 64-bit Machine Specific Register(MSR).\r
5570\r
5571 Reads and returns the 64-bit MSR specified by Index. No parameter checking is\r
5572 performed on Index, and some Index values may cause CPU exceptions. The\r
5573 caller must either guarantee that Index is valid, or the caller must set up\r
5574 exception handlers to catch the exceptions. This function is only available\r
5575 on IA-32 and X64.\r
5576\r
5577 @param Index The 32-bit MSR index to read.\r
5578\r
5579 @return The value of the MSR identified by Index.\r
5580\r
5581**/\r
5582UINT64\r
5583EFIAPI\r
5584AsmReadMsr64 (\r
5585 IN UINT32 Index\r
5586 );\r
5587\r
5588\r
5589/**\r
5590 Writes a 64-bit value to a Machine Specific Register(MSR), and returns the\r
5591 value.\r
5592\r
5593 Writes the 64-bit value specified by Value to the MSR specified by Index. The\r
5594 64-bit value written to the MSR is returned. No parameter checking is\r
5595 performed on Index or Value, and some of these may cause CPU exceptions. The\r
5596 caller must either guarantee that Index and Value are valid, or the caller\r
5597 must establish proper exception handlers. This function is only available on\r
5598 IA-32 and X64.\r
5599\r
5600 @param Index The 32-bit MSR index to write.\r
5601 @param Value The 64-bit value to write to the MSR.\r
5602\r
5603 @return Value\r
5604\r
5605**/\r
5606UINT64\r
5607EFIAPI\r
5608AsmWriteMsr64 (\r
5609 IN UINT32 Index,\r
5610 IN UINT64 Value\r
5611 );\r
5612\r
5613\r
5614/**\r
5615 Reads a 64-bit MSR, performs a bitwise inclusive OR, and writes the result\r
5616 back to the 64-bit MSR.\r
5617\r
5618 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR\r
5619 between the read result and the value specified by OrData, and writes the\r
5620 result to the 64-bit MSR specified by Index. The value written to the MSR is\r
5621 returned. No parameter checking is performed on Index or OrData, and some of\r
5622 these may cause CPU exceptions. The caller must either guarantee that Index\r
5623 and OrData are valid, or the caller must establish proper exception handlers.\r
5624 This function is only available on IA-32 and X64.\r
5625\r
5626 @param Index The 32-bit MSR index to write.\r
5627 @param OrData The value to OR with the read value from the MSR.\r
5628\r
5629 @return The value written back to the MSR.\r
5630\r
5631**/\r
5632UINT64\r
5633EFIAPI\r
5634AsmMsrOr64 (\r
5635 IN UINT32 Index,\r
5636 IN UINT64 OrData\r
5637 );\r
5638\r
5639\r
5640/**\r
5641 Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the\r
5642 64-bit MSR.\r
5643\r
5644 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r
5645 read result and the value specified by OrData, and writes the result to the\r
5646 64-bit MSR specified by Index. The value written to the MSR is returned. No\r
5647 parameter checking is performed on Index or OrData, and some of these may\r
5648 cause CPU exceptions. The caller must either guarantee that Index and OrData\r
5649 are valid, or the caller must establish proper exception handlers. This\r
5650 function is only available on IA-32 and X64.\r
5651\r
5652 @param Index The 32-bit MSR index to write.\r
5653 @param AndData The value to AND with the read value from the MSR.\r
5654\r
5655 @return The value written back to the MSR.\r
5656\r
5657**/\r
5658UINT64\r
5659EFIAPI\r
5660AsmMsrAnd64 (\r
5661 IN UINT32 Index,\r
5662 IN UINT64 AndData\r
5663 );\r
5664\r
5665\r
5666/**\r
5667 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive\r
5668 OR, and writes the result back to the 64-bit MSR.\r
5669\r
5670 Reads the 64-bit MSR specified by Index, performs a bitwise AND between read\r
5671 result and the value specified by AndData, performs a bitwise inclusive OR\r
5672 between the result of the AND operation and the value specified by OrData,\r
5673 and writes the result to the 64-bit MSR specified by Index. The value written\r
5674 to the MSR is returned. No parameter checking is performed on Index, AndData,\r
5675 or OrData, and some of these may cause CPU exceptions. The caller must either\r
5676 guarantee that Index, AndData, and OrData are valid, or the caller must\r
5677 establish proper exception handlers. This function is only available on IA-32\r
5678 and X64.\r
5679\r
5680 @param Index The 32-bit MSR index to write.\r
5681 @param AndData The value to AND with the read value from the MSR.\r
5682 @param OrData The value to OR with the result of the AND operation.\r
5683\r
5684 @return The value written back to the MSR.\r
5685\r
5686**/\r
5687UINT64\r
5688EFIAPI\r
5689AsmMsrAndThenOr64 (\r
5690 IN UINT32 Index,\r
5691 IN UINT64 AndData,\r
5692 IN UINT64 OrData\r
5693 );\r
5694\r
5695\r
5696/**\r
5697 Reads a bit field of an MSR.\r
5698\r
5699 Reads the bit field in the 64-bit MSR. The bit field is specified by the\r
5700 StartBit and the EndBit. The value of the bit field is returned. The caller\r
5701 must either guarantee that Index is valid, or the caller must set up\r
5702 exception handlers to catch the exceptions. This function is only available\r
5703 on IA-32 and X64.\r
5704\r
5705 If StartBit is greater than 63, then ASSERT().\r
5706 If EndBit is greater than 63, then ASSERT().\r
5707 If EndBit is less than StartBit, then ASSERT().\r
5708\r
5709 @param Index The 32-bit MSR index to read.\r
5710 @param StartBit The ordinal of the least significant bit in the bit field.\r
5711 Range 0..63.\r
5712 @param EndBit The ordinal of the most significant bit in the bit field.\r
5713 Range 0..63.\r
5714\r
5715 @return The value read from the MSR.\r
5716\r
5717**/\r
5718UINT64\r
5719EFIAPI\r
5720AsmMsrBitFieldRead64 (\r
5721 IN UINT32 Index,\r
5722 IN UINTN StartBit,\r
5723 IN UINTN EndBit\r
5724 );\r
5725\r
5726\r
5727/**\r
5728 Writes a bit field to an MSR.\r
5729\r
5730 Writes Value to a bit field in a 64-bit MSR. The bit field is specified by\r
5731 the StartBit and the EndBit. All other bits in the destination MSR are\r
5732 preserved. The MSR written is returned. Extra left bits in Value are\r
5733 stripped. The caller must either guarantee that Index and the data written is\r
5734 valid, or the caller must set up exception handlers to catch the exceptions.\r
5735 This function is only available on IA-32 and X64.\r
5736\r
5737 If StartBit is greater than 63, then ASSERT().\r
5738 If EndBit is greater than 63, then ASSERT().\r
5739 If EndBit is less than StartBit, then ASSERT().\r
5740\r
5741 @param Index The 32-bit MSR index to write.\r
5742 @param StartBit The ordinal of the least significant bit in the bit field.\r
5743 Range 0..63.\r
5744 @param EndBit The ordinal of the most significant bit in the bit field.\r
5745 Range 0..63.\r
5746 @param Value New value of the bit field.\r
5747\r
5748 @return The value written back to the MSR.\r
5749\r
5750**/\r
5751UINT64\r
5752EFIAPI\r
5753AsmMsrBitFieldWrite64 (\r
5754 IN UINT32 Index,\r
5755 IN UINTN StartBit,\r
5756 IN UINTN EndBit,\r
5757 IN UINT64 Value\r
5758 );\r
5759\r
5760\r
5761/**\r
5762 Reads a bit field in a 64-bit MSR, performs a bitwise inclusive OR, and\r
5763 writes the result back to the bit field in the 64-bit MSR.\r
5764\r
5765 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR\r
5766 between the read result and the value specified by OrData, and writes the\r
5767 result to the 64-bit MSR specified by Index. The value written to the MSR is\r
5768 returned. Extra left bits in OrData are stripped. The caller must either\r
5769 guarantee that Index and the data written is valid, or the caller must set up\r
5770 exception handlers to catch the exceptions. This function is only available\r
5771 on IA-32 and X64.\r
5772\r
5773 If StartBit is greater than 63, then ASSERT().\r
5774 If EndBit is greater than 63, then ASSERT().\r
5775 If EndBit is less than StartBit, then ASSERT().\r
5776\r
5777 @param Index The 32-bit MSR index to write.\r
5778 @param StartBit The ordinal of the least significant bit in the bit field.\r
5779 Range 0..63.\r
5780 @param EndBit The ordinal of the most significant bit in the bit field.\r
5781 Range 0..63.\r
5782 @param OrData The value to OR with the read value from the bit field.\r
5783\r
5784 @return The value written back to the MSR.\r
5785\r
5786**/\r
5787UINT64\r
5788EFIAPI\r
5789AsmMsrBitFieldOr64 (\r
5790 IN UINT32 Index,\r
5791 IN UINTN StartBit,\r
5792 IN UINTN EndBit,\r
5793 IN UINT64 OrData\r
5794 );\r
5795\r
5796\r
5797/**\r
5798 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the\r
5799 result back to the bit field in the 64-bit MSR.\r
5800\r
5801 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r
5802 read result and the value specified by AndData, and writes the result to the\r
5803 64-bit MSR specified by Index. The value written to the MSR is returned.\r
5804 Extra left bits in AndData are stripped. The caller must either guarantee\r
5805 that Index and the data written is valid, or the caller must set up exception\r
5806 handlers to catch the exceptions. This function is only available on IA-32\r
5807 and X64.\r
5808\r
5809 If StartBit is greater than 63, then ASSERT().\r
5810 If EndBit is greater than 63, then ASSERT().\r
5811 If EndBit is less than StartBit, then ASSERT().\r
5812\r
5813 @param Index The 32-bit MSR index to write.\r
5814 @param StartBit The ordinal of the least significant bit in the bit field.\r
5815 Range 0..63.\r
5816 @param EndBit The ordinal of the most significant bit in the bit field.\r
5817 Range 0..63.\r
5818 @param AndData The value to AND with the read value from the bit field.\r
5819\r
5820 @return The value written back to the MSR.\r
5821\r
5822**/\r
5823UINT64\r
5824EFIAPI\r
5825AsmMsrBitFieldAnd64 (\r
5826 IN UINT32 Index,\r
5827 IN UINTN StartBit,\r
5828 IN UINTN EndBit,\r
5829 IN UINT64 AndData\r
5830 );\r
5831\r
5832\r
5833/**\r
5834 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a\r
5835 bitwise inclusive OR, and writes the result back to the bit field in the\r
5836 64-bit MSR.\r
5837\r
5838 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by\r
5839 a bitwise inclusive OR between the read result and the value specified by\r
5840 AndData, and writes the result to the 64-bit MSR specified by Index. The\r
5841 value written to the MSR is returned. Extra left bits in both AndData and\r
5842 OrData are stripped. The caller must either guarantee that Index and the data\r
5843 written is valid, or the caller must set up exception handlers to catch the\r
5844 exceptions. This function is only available on IA-32 and X64.\r
5845\r
5846 If StartBit is greater than 63, then ASSERT().\r
5847 If EndBit is greater than 63, then ASSERT().\r
5848 If EndBit is less than StartBit, then ASSERT().\r
5849\r
5850 @param Index The 32-bit MSR index to write.\r
5851 @param StartBit The ordinal of the least significant bit in the bit field.\r
5852 Range 0..63.\r
5853 @param EndBit The ordinal of the most significant bit in the bit field.\r
5854 Range 0..63.\r
5855 @param AndData The value to AND with the read value from the bit field.\r
5856 @param OrData The value to OR with the result of the AND operation.\r
5857\r
5858 @return The value written back to the MSR.\r
5859\r
5860**/\r
5861UINT64\r
5862EFIAPI\r
5863AsmMsrBitFieldAndThenOr64 (\r
5864 IN UINT32 Index,\r
5865 IN UINTN StartBit,\r
5866 IN UINTN EndBit,\r
5867 IN UINT64 AndData,\r
5868 IN UINT64 OrData\r
5869 );\r
5870\r
5871\r
5872/**\r
5873 Reads the current value of the EFLAGS register.\r
5874\r
5875 Reads and returns the current value of the EFLAGS register. This function is\r
5876 only available on IA-32 and X64. This returns a 32-bit value on IA-32 and a\r
5877 64-bit value on X64.\r
5878\r
5879 @return EFLAGS on IA-32 or RFLAGS on X64.\r
5880\r
5881**/\r
5882UINTN\r
5883EFIAPI\r
5884AsmReadEflags (\r
5885 VOID\r
5886 );\r
5887\r
5888\r
5889/**\r
5890 Reads the current value of the Control Register 0 (CR0).\r
5891\r
5892 Reads and returns the current value of CR0. This function is only available\r
5893 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
5894 X64.\r
5895\r
5896 @return The value of the Control Register 0 (CR0).\r
5897\r
5898**/\r
5899UINTN\r
5900EFIAPI\r
5901AsmReadCr0 (\r
5902 VOID\r
5903 );\r
5904\r
5905\r
5906/**\r
5907 Reads the current value of the Control Register 2 (CR2).\r
5908\r
5909 Reads and returns the current value of CR2. This function is only available\r
5910 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
5911 X64.\r
5912\r
5913 @return The value of the Control Register 2 (CR2).\r
5914\r
5915**/\r
5916UINTN\r
5917EFIAPI\r
5918AsmReadCr2 (\r
5919 VOID\r
5920 );\r
5921\r
5922\r
5923/**\r
5924 Reads the current value of the Control Register 3 (CR3).\r
5925\r
5926 Reads and returns the current value of CR3. This function is only available\r
5927 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
5928 X64.\r
5929\r
5930 @return The value of the Control Register 3 (CR3).\r
5931\r
5932**/\r
5933UINTN\r
5934EFIAPI\r
5935AsmReadCr3 (\r
5936 VOID\r
5937 );\r
5938\r
5939\r
5940/**\r
5941 Reads the current value of the Control Register 4 (CR4).\r
5942\r
5943 Reads and returns the current value of CR4. This function is only available\r
5944 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
5945 X64.\r
5946\r
5947 @return The value of the Control Register 4 (CR4).\r
5948\r
5949**/\r
5950UINTN\r
5951EFIAPI\r
5952AsmReadCr4 (\r
5953 VOID\r
5954 );\r
5955\r
5956\r
5957/**\r
5958 Writes a value to Control Register 0 (CR0).\r
5959\r
5960 Writes and returns a new value to CR0. This function is only available on\r
5961 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r
5962\r
5963 @param Cr0 The value to write to CR0.\r
5964\r
5965 @return The value written to CR0.\r
5966\r
5967**/\r
5968UINTN\r
5969EFIAPI\r
5970AsmWriteCr0 (\r
5971 UINTN Cr0\r
5972 );\r
5973\r
5974\r
5975/**\r
5976 Writes a value to Control Register 2 (CR2).\r
5977\r
5978 Writes and returns a new value to CR2. This function is only available on\r
5979 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r
5980\r
5981 @param Cr2 The value to write to CR2.\r
5982\r
5983 @return The value written to CR2.\r
5984\r
5985**/\r
5986UINTN\r
5987EFIAPI\r
5988AsmWriteCr2 (\r
5989 UINTN Cr2\r
5990 );\r
5991\r
5992\r
5993/**\r
5994 Writes a value to Control Register 3 (CR3).\r
5995\r
5996 Writes and returns a new value to CR3. This function is only available on\r
5997 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r
5998\r
5999 @param Cr3 The value to write to CR3.\r
6000\r
6001 @return The value written to CR3.\r
6002\r
6003**/\r
6004UINTN\r
6005EFIAPI\r
6006AsmWriteCr3 (\r
6007 UINTN Cr3\r
6008 );\r
6009\r
6010\r
6011/**\r
6012 Writes a value to Control Register 4 (CR4).\r
6013\r
6014 Writes and returns a new value to CR4. This function is only available on\r
6015 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r
6016\r
6017 @param Cr4 The value to write to CR4.\r
6018\r
6019 @return The value written to CR4.\r
6020\r
6021**/\r
6022UINTN\r
6023EFIAPI\r
6024AsmWriteCr4 (\r
6025 UINTN Cr4\r
6026 );\r
6027\r
6028\r
6029/**\r
6030 Reads the current value of Debug Register 0 (DR0).\r
6031\r
6032 Reads and returns the current value of DR0. This function is only available\r
6033 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
6034 X64.\r
6035\r
6036 @return The value of Debug Register 0 (DR0).\r
6037\r
6038**/\r
6039UINTN\r
6040EFIAPI\r
6041AsmReadDr0 (\r
6042 VOID\r
6043 );\r
6044\r
6045\r
6046/**\r
6047 Reads the current value of Debug Register 1 (DR1).\r
6048\r
6049 Reads and returns the current value of DR1. This function is only available\r
6050 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
6051 X64.\r
6052\r
6053 @return The value of Debug Register 1 (DR1).\r
6054\r
6055**/\r
6056UINTN\r
6057EFIAPI\r
6058AsmReadDr1 (\r
6059 VOID\r
6060 );\r
6061\r
6062\r
6063/**\r
6064 Reads the current value of Debug Register 2 (DR2).\r
6065\r
6066 Reads and returns the current value of DR2. This function is only available\r
6067 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
6068 X64.\r
6069\r
6070 @return The value of Debug Register 2 (DR2).\r
6071\r
6072**/\r
6073UINTN\r
6074EFIAPI\r
6075AsmReadDr2 (\r
6076 VOID\r
6077 );\r
6078\r
6079\r
6080/**\r
6081 Reads the current value of Debug Register 3 (DR3).\r
6082\r
6083 Reads and returns the current value of DR3. This function is only available\r
6084 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
6085 X64.\r
6086\r
6087 @return The value of Debug Register 3 (DR3).\r
6088\r
6089**/\r
6090UINTN\r
6091EFIAPI\r
6092AsmReadDr3 (\r
6093 VOID\r
6094 );\r
6095\r
6096\r
6097/**\r
6098 Reads the current value of Debug Register 4 (DR4).\r
6099\r
6100 Reads and returns the current value of DR4. This function is only available\r
6101 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
6102 X64.\r
6103\r
6104 @return The value of Debug Register 4 (DR4).\r
6105\r
6106**/\r
6107UINTN\r
6108EFIAPI\r
6109AsmReadDr4 (\r
6110 VOID\r
6111 );\r
6112\r
6113\r
6114/**\r
6115 Reads the current value of Debug Register 5 (DR5).\r
6116\r
6117 Reads and returns the current value of DR5. This function is only available\r
6118 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
6119 X64.\r
6120\r
6121 @return The value of Debug Register 5 (DR5).\r
6122\r
6123**/\r
6124UINTN\r
6125EFIAPI\r
6126AsmReadDr5 (\r
6127 VOID\r
6128 );\r
6129\r
6130\r
6131/**\r
6132 Reads the current value of Debug Register 6 (DR6).\r
6133\r
6134 Reads and returns the current value of DR6. This function is only available\r
6135 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
6136 X64.\r
6137\r
6138 @return The value of Debug Register 6 (DR6).\r
6139\r
6140**/\r
6141UINTN\r
6142EFIAPI\r
6143AsmReadDr6 (\r
6144 VOID\r
6145 );\r
6146\r
6147\r
6148/**\r
6149 Reads the current value of Debug Register 7 (DR7).\r
6150\r
6151 Reads and returns the current value of DR7. This function is only available\r
6152 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
6153 X64.\r
6154\r
6155 @return The value of Debug Register 7 (DR7).\r
6156\r
6157**/\r
6158UINTN\r
6159EFIAPI\r
6160AsmReadDr7 (\r
6161 VOID\r
6162 );\r
6163\r
6164\r
6165/**\r
6166 Writes a value to Debug Register 0 (DR0).\r
6167\r
6168 Writes and returns a new value to DR0. This function is only available on\r
6169 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r
6170\r
6171 @param Dr0 The value to write to Dr0.\r
6172\r
6173 @return The value written to Debug Register 0 (DR0).\r
6174\r
6175**/\r
6176UINTN\r
6177EFIAPI\r
6178AsmWriteDr0 (\r
6179 UINTN Dr0\r
6180 );\r
6181\r
6182\r
6183/**\r
6184 Writes a value to Debug Register 1 (DR1).\r
6185\r
6186 Writes and returns a new value to DR1. This function is only available on\r
6187 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r
6188\r
6189 @param Dr1 The value to write to Dr1.\r
6190\r
6191 @return The value written to Debug Register 1 (DR1).\r
6192\r
6193**/\r
6194UINTN\r
6195EFIAPI\r
6196AsmWriteDr1 (\r
6197 UINTN Dr1\r
6198 );\r
6199\r
6200\r
6201/**\r
6202 Writes a value to Debug Register 2 (DR2).\r
6203\r
6204 Writes and returns a new value to DR2. This function is only available on\r
6205 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r
6206\r
6207 @param Dr2 The value to write to Dr2.\r
6208\r
6209 @return The value written to Debug Register 2 (DR2).\r
6210\r
6211**/\r
6212UINTN\r
6213EFIAPI\r
6214AsmWriteDr2 (\r
6215 UINTN Dr2\r
6216 );\r
6217\r
6218\r
6219/**\r
6220 Writes a value to Debug Register 3 (DR3).\r
6221\r
6222 Writes and returns a new value to DR3. This function is only available on\r
6223 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r
6224\r
6225 @param Dr3 The value to write to Dr3.\r
6226\r
6227 @return The value written to Debug Register 3 (DR3).\r
6228\r
6229**/\r
6230UINTN\r
6231EFIAPI\r
6232AsmWriteDr3 (\r
6233 UINTN Dr3\r
6234 );\r
6235\r
6236\r
6237/**\r
6238 Writes a value to Debug Register 4 (DR4).\r
6239\r
6240 Writes and returns a new value to DR4. This function is only available on\r
6241 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r
6242\r
6243 @param Dr4 The value to write to Dr4.\r
6244\r
6245 @return The value written to Debug Register 4 (DR4).\r
6246\r
6247**/\r
6248UINTN\r
6249EFIAPI\r
6250AsmWriteDr4 (\r
6251 UINTN Dr4\r
6252 );\r
6253\r
6254\r
6255/**\r
6256 Writes a value to Debug Register 5 (DR5).\r
6257\r
6258 Writes and returns a new value to DR5. This function is only available on\r
6259 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r
6260\r
6261 @param Dr5 The value to write to Dr5.\r
6262\r
6263 @return The value written to Debug Register 5 (DR5).\r
6264\r
6265**/\r
6266UINTN\r
6267EFIAPI\r
6268AsmWriteDr5 (\r
6269 UINTN Dr5\r
6270 );\r
6271\r
6272\r
6273/**\r
6274 Writes a value to Debug Register 6 (DR6).\r
6275\r
6276 Writes and returns a new value to DR6. This function is only available on\r
6277 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r
6278\r
6279 @param Dr6 The value to write to Dr6.\r
6280\r
6281 @return The value written to Debug Register 6 (DR6).\r
6282\r
6283**/\r
6284UINTN\r
6285EFIAPI\r
6286AsmWriteDr6 (\r
6287 UINTN Dr6\r
6288 );\r
6289\r
6290\r
6291/**\r
6292 Writes a value to Debug Register 7 (DR7).\r
6293\r
6294 Writes and returns a new value to DR7. This function is only available on\r
6295 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r
6296\r
6297 @param Dr7 The value to write to Dr7.\r
6298\r
6299 @return The value written to Debug Register 7 (DR7).\r
6300\r
6301**/\r
6302UINTN\r
6303EFIAPI\r
6304AsmWriteDr7 (\r
6305 UINTN Dr7\r
6306 );\r
6307\r
6308\r
6309/**\r
6310 Reads the current value of Code Segment Register (CS).\r
6311\r
6312 Reads and returns the current value of CS. This function is only available on\r
6313 IA-32 and X64.\r
6314\r
6315 @return The current value of CS.\r
6316\r
6317**/\r
6318UINT16\r
6319EFIAPI\r
6320AsmReadCs (\r
6321 VOID\r
6322 );\r
6323\r
6324\r
6325/**\r
6326 Reads the current value of Data Segment Register (DS).\r
6327\r
6328 Reads and returns the current value of DS. This function is only available on\r
6329 IA-32 and X64.\r
6330\r
6331 @return The current value of DS.\r
6332\r
6333**/\r
6334UINT16\r
6335EFIAPI\r
6336AsmReadDs (\r
6337 VOID\r
6338 );\r
6339\r
6340\r
6341/**\r
6342 Reads the current value of Extra Segment Register (ES).\r
6343\r
6344 Reads and returns the current value of ES. This function is only available on\r
6345 IA-32 and X64.\r
6346\r
6347 @return The current value of ES.\r
6348\r
6349**/\r
6350UINT16\r
6351EFIAPI\r
6352AsmReadEs (\r
6353 VOID\r
6354 );\r
6355\r
6356\r
6357/**\r
6358 Reads the current value of FS Data Segment Register (FS).\r
6359\r
6360 Reads and returns the current value of FS. This function is only available on\r
6361 IA-32 and X64.\r
6362\r
6363 @return The current value of FS.\r
6364\r
6365**/\r
6366UINT16\r
6367EFIAPI\r
6368AsmReadFs (\r
6369 VOID\r
6370 );\r
6371\r
6372\r
6373/**\r
6374 Reads the current value of GS Data Segment Register (GS).\r
6375\r
6376 Reads and returns the current value of GS. This function is only available on\r
6377 IA-32 and X64.\r
6378\r
6379 @return The current value of GS.\r
6380\r
6381**/\r
6382UINT16\r
6383EFIAPI\r
6384AsmReadGs (\r
6385 VOID\r
6386 );\r
6387\r
6388\r
6389/**\r
6390 Reads the current value of Stack Segment Register (SS).\r
6391\r
6392 Reads and returns the current value of SS. This function is only available on\r
6393 IA-32 and X64.\r
6394\r
6395 @return The current value of SS.\r
6396\r
6397**/\r
6398UINT16\r
6399EFIAPI\r
6400AsmReadSs (\r
6401 VOID\r
6402 );\r
6403\r
6404\r
6405/**\r
6406 Reads the current value of Task Register (TR).\r
6407\r
6408 Reads and returns the current value of TR. This function is only available on\r
6409 IA-32 and X64.\r
6410\r
6411 @return The current value of TR.\r
6412\r
6413**/\r
6414UINT16\r
6415EFIAPI\r
6416AsmReadTr (\r
6417 VOID\r
6418 );\r
6419\r
6420\r
6421/**\r
6422 Reads the current Global Descriptor Table Register(GDTR) descriptor.\r
6423\r
6424 Reads and returns the current GDTR descriptor and returns it in Gdtr. This\r
6425 function is only available on IA-32 and X64.\r
6426\r
6427 If Gdtr is NULL, then ASSERT().\r
6428\r
6429 @param Gdtr Pointer to a GDTR descriptor.\r
6430\r
6431**/\r
6432VOID\r
6433EFIAPI\r
6434AsmReadGdtr (\r
6435 OUT IA32_DESCRIPTOR *Gdtr\r
6436 );\r
6437\r
6438\r
6439/**\r
6440 Writes the current Global Descriptor Table Register (GDTR) descriptor.\r
6441\r
6442 Writes and the current GDTR descriptor specified by Gdtr. This function is\r
6443 only available on IA-32 and X64.\r
6444\r
6445 If Gdtr is NULL, then ASSERT().\r
6446\r
6447 @param Gdtr Pointer to a GDTR descriptor.\r
6448\r
6449**/\r
6450VOID\r
6451EFIAPI\r
6452AsmWriteGdtr (\r
6453 IN CONST IA32_DESCRIPTOR *Gdtr\r
6454 );\r
6455\r
6456\r
6457/**\r
6458 Reads the current Interrupt Descriptor Table Register(GDTR) descriptor.\r
6459\r
6460 Reads and returns the current IDTR descriptor and returns it in Idtr. This\r
6461 function is only available on IA-32 and X64.\r
6462\r
6463 If Idtr is NULL, then ASSERT().\r
6464\r
6465 @param Idtr Pointer to a IDTR descriptor.\r
6466\r
6467**/\r
6468VOID\r
6469EFIAPI\r
6470AsmReadIdtr (\r
6471 OUT IA32_DESCRIPTOR *Idtr\r
6472 );\r
6473\r
6474\r
6475/**\r
6476 Writes the current Interrupt Descriptor Table Register(GDTR) descriptor.\r
6477\r
6478 Writes the current IDTR descriptor and returns it in Idtr. This function is\r
6479 only available on IA-32 and X64.\r
6480\r
6481 If Idtr is NULL, then ASSERT().\r
6482\r
6483 @param Idtr Pointer to a IDTR descriptor.\r
6484\r
6485**/\r
6486VOID\r
6487EFIAPI\r
6488AsmWriteIdtr (\r
6489 IN CONST IA32_DESCRIPTOR *Idtr\r
6490 );\r
6491\r
6492\r
6493/**\r
6494 Reads the current Local Descriptor Table Register(LDTR) selector.\r
6495\r
6496 Reads and returns the current 16-bit LDTR descriptor value. This function is\r
6497 only available on IA-32 and X64.\r
6498\r
6499 @return The current selector of LDT.\r
6500\r
6501**/\r
6502UINT16\r
6503EFIAPI\r
6504AsmReadLdtr (\r
6505 VOID\r
6506 );\r
6507\r
6508\r
6509/**\r
6510 Writes the current Local Descriptor Table Register (GDTR) selector.\r
6511\r
6512 Writes and the current LDTR descriptor specified by Ldtr. This function is\r
6513 only available on IA-32 and X64.\r
6514\r
6515 @param Ldtr 16-bit LDTR selector value.\r
6516\r
6517**/\r
6518VOID\r
6519EFIAPI\r
6520AsmWriteLdtr (\r
6521 IN UINT16 Ldtr\r
6522 );\r
6523\r
6524\r
6525/**\r
6526 Save the current floating point/SSE/SSE2 context to a buffer.\r
6527\r
6528 Saves the current floating point/SSE/SSE2 state to the buffer specified by\r
6529 Buffer. Buffer must be aligned on a 16-byte boundary. This function is only\r
6530 available on IA-32 and X64.\r
6531\r
6532 If Buffer is NULL, then ASSERT().\r
6533 If Buffer is not aligned on a 16-byte boundary, then ASSERT().\r
6534\r
6535 @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.\r
6536\r
6537**/\r
6538VOID\r
6539EFIAPI\r
6540AsmFxSave (\r
6541 OUT IA32_FX_BUFFER *Buffer\r
6542 );\r
6543\r
6544\r
6545/**\r
6546 Restores the current floating point/SSE/SSE2 context from a buffer.\r
6547\r
6548 Restores the current floating point/SSE/SSE2 state from the buffer specified\r
6549 by Buffer. Buffer must be aligned on a 16-byte boundary. This function is\r
6550 only available on IA-32 and X64.\r
6551\r
6552 If Buffer is NULL, then ASSERT().\r
6553 If Buffer is not aligned on a 16-byte boundary, then ASSERT().\r
6554 If Buffer was not saved with AsmFxSave(), then ASSERT().\r
6555\r
6556 @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.\r
6557\r
6558**/\r
6559VOID\r
6560EFIAPI\r
6561AsmFxRestore (\r
6562 IN CONST IA32_FX_BUFFER *Buffer\r
6563 );\r
6564\r
6565\r
6566/**\r
6567 Reads the current value of 64-bit MMX Register #0 (MM0).\r
6568\r
6569 Reads and returns the current value of MM0. This function is only available\r
6570 on IA-32 and X64.\r
6571\r
6572 @return The current value of MM0.\r
6573\r
6574**/\r
6575UINT64\r
6576EFIAPI\r
6577AsmReadMm0 (\r
6578 VOID\r
6579 );\r
6580\r
6581\r
6582/**\r
6583 Reads the current value of 64-bit MMX Register #1 (MM1).\r
6584\r
6585 Reads and returns the current value of MM1. This function is only available\r
6586 on IA-32 and X64.\r
6587\r
6588 @return The current value of MM1.\r
6589\r
6590**/\r
6591UINT64\r
6592EFIAPI\r
6593AsmReadMm1 (\r
6594 VOID\r
6595 );\r
6596\r
6597\r
6598/**\r
6599 Reads the current value of 64-bit MMX Register #2 (MM2).\r
6600\r
6601 Reads and returns the current value of MM2. This function is only available\r
6602 on IA-32 and X64.\r
6603\r
6604 @return The current value of MM2.\r
6605\r
6606**/\r
6607UINT64\r
6608EFIAPI\r
6609AsmReadMm2 (\r
6610 VOID\r
6611 );\r
6612\r
6613\r
6614/**\r
6615 Reads the current value of 64-bit MMX Register #3 (MM3).\r
6616\r
6617 Reads and returns the current value of MM3. This function is only available\r
6618 on IA-32 and X64.\r
6619\r
6620 @return The current value of MM3.\r
6621\r
6622**/\r
6623UINT64\r
6624EFIAPI\r
6625AsmReadMm3 (\r
6626 VOID\r
6627 );\r
6628\r
6629\r
6630/**\r
6631 Reads the current value of 64-bit MMX Register #4 (MM4).\r
6632\r
6633 Reads and returns the current value of MM4. This function is only available\r
6634 on IA-32 and X64.\r
6635\r
6636 @return The current value of MM4.\r
6637\r
6638**/\r
6639UINT64\r
6640EFIAPI\r
6641AsmReadMm4 (\r
6642 VOID\r
6643 );\r
6644\r
6645\r
6646/**\r
6647 Reads the current value of 64-bit MMX Register #5 (MM5).\r
6648\r
6649 Reads and returns the current value of MM5. This function is only available\r
6650 on IA-32 and X64.\r
6651\r
6652 @return The current value of MM5.\r
6653\r
6654**/\r
6655UINT64\r
6656EFIAPI\r
6657AsmReadMm5 (\r
6658 VOID\r
6659 );\r
6660\r
6661\r
6662/**\r
6663 Reads the current value of 64-bit MMX Register #6 (MM6).\r
6664\r
6665 Reads and returns the current value of MM6. This function is only available\r
6666 on IA-32 and X64.\r
6667\r
6668 @return The current value of MM6.\r
6669\r
6670**/\r
6671UINT64\r
6672EFIAPI\r
6673AsmReadMm6 (\r
6674 VOID\r
6675 );\r
6676\r
6677\r
6678/**\r
6679 Reads the current value of 64-bit MMX Register #7 (MM7).\r
6680\r
6681 Reads and returns the current value of MM7. This function is only available\r
6682 on IA-32 and X64.\r
6683\r
6684 @return The current value of MM7.\r
6685\r
6686**/\r
6687UINT64\r
6688EFIAPI\r
6689AsmReadMm7 (\r
6690 VOID\r
6691 );\r
6692\r
6693\r
6694/**\r
6695 Writes the current value of 64-bit MMX Register #0 (MM0).\r
6696\r
6697 Writes the current value of MM0. This function is only available on IA32 and\r
6698 X64.\r
6699\r
6700 @param Value The 64-bit value to write to MM0.\r
6701\r
6702**/\r
6703VOID\r
6704EFIAPI\r
6705AsmWriteMm0 (\r
6706 IN UINT64 Value\r
6707 );\r
6708\r
6709\r
6710/**\r
6711 Writes the current value of 64-bit MMX Register #1 (MM1).\r
6712\r
6713 Writes the current value of MM1. This function is only available on IA32 and\r
6714 X64.\r
6715\r
6716 @param Value The 64-bit value to write to MM1.\r
6717\r
6718**/\r
6719VOID\r
6720EFIAPI\r
6721AsmWriteMm1 (\r
6722 IN UINT64 Value\r
6723 );\r
6724\r
6725\r
6726/**\r
6727 Writes the current value of 64-bit MMX Register #2 (MM2).\r
6728\r
6729 Writes the current value of MM2. This function is only available on IA32 and\r
6730 X64.\r
6731\r
6732 @param Value The 64-bit value to write to MM2.\r
6733\r
6734**/\r
6735VOID\r
6736EFIAPI\r
6737AsmWriteMm2 (\r
6738 IN UINT64 Value\r
6739 );\r
6740\r
6741\r
6742/**\r
6743 Writes the current value of 64-bit MMX Register #3 (MM3).\r
6744\r
6745 Writes the current value of MM3. This function is only available on IA32 and\r
6746 X64.\r
6747\r
6748 @param Value The 64-bit value to write to MM3.\r
6749\r
6750**/\r
6751VOID\r
6752EFIAPI\r
6753AsmWriteMm3 (\r
6754 IN UINT64 Value\r
6755 );\r
6756\r
6757\r
6758/**\r
6759 Writes the current value of 64-bit MMX Register #4 (MM4).\r
6760\r
6761 Writes the current value of MM4. This function is only available on IA32 and\r
6762 X64.\r
6763\r
6764 @param Value The 64-bit value to write to MM4.\r
6765\r
6766**/\r
6767VOID\r
6768EFIAPI\r
6769AsmWriteMm4 (\r
6770 IN UINT64 Value\r
6771 );\r
6772\r
6773\r
6774/**\r
6775 Writes the current value of 64-bit MMX Register #5 (MM5).\r
6776\r
6777 Writes the current value of MM5. This function is only available on IA32 and\r
6778 X64.\r
6779\r
6780 @param Value The 64-bit value to write to MM5.\r
6781\r
6782**/\r
6783VOID\r
6784EFIAPI\r
6785AsmWriteMm5 (\r
6786 IN UINT64 Value\r
6787 );\r
6788\r
6789\r
6790/**\r
6791 Writes the current value of 64-bit MMX Register #6 (MM6).\r
6792\r
6793 Writes the current value of MM6. This function is only available on IA32 and\r
6794 X64.\r
6795\r
6796 @param Value The 64-bit value to write to MM6.\r
6797\r
6798**/\r
6799VOID\r
6800EFIAPI\r
6801AsmWriteMm6 (\r
6802 IN UINT64 Value\r
6803 );\r
6804\r
6805\r
6806/**\r
6807 Writes the current value of 64-bit MMX Register #7 (MM7).\r
6808\r
6809 Writes the current value of MM7. This function is only available on IA32 and\r
6810 X64.\r
6811\r
6812 @param Value The 64-bit value to write to MM7.\r
6813\r
6814**/\r
6815VOID\r
6816EFIAPI\r
6817AsmWriteMm7 (\r
6818 IN UINT64 Value\r
6819 );\r
6820\r
6821\r
6822/**\r
6823 Reads the current value of Time Stamp Counter (TSC).\r
6824\r
6825 Reads and returns the current value of TSC. This function is only available\r
6826 on IA-32 and X64.\r
6827\r
6828 @return The current value of TSC\r
6829\r
6830**/\r
6831UINT64\r
6832EFIAPI\r
6833AsmReadTsc (\r
6834 VOID\r
6835 );\r
6836\r
6837\r
6838/**\r
6839 Reads the current value of a Performance Counter (PMC).\r
6840\r
6841 Reads and returns the current value of performance counter specified by\r
6842 Index. This function is only available on IA-32 and X64.\r
6843\r
6844 @param Index The 32-bit Performance Counter index to read.\r
6845\r
6846 @return The value of the PMC specified by Index.\r
6847\r
6848**/\r
6849UINT64\r
6850EFIAPI\r
6851AsmReadPmc (\r
6852 IN UINT32 Index\r
6853 );\r
6854\r
6855\r
6856/**\r
6857 Sets up a monitor buffer that is used by AsmMwait().\r
6858\r
6859 Executes a MONITOR instruction with the register state specified by Eax, Ecx\r
6860 and Edx. Returns Eax. This function is only available on IA-32 and X64.\r
6861\r
6862 @param Eax The value to load into EAX or RAX before executing the MONITOR\r
6863 instruction.\r
6864 @param Ecx The value to load into ECX or RCX before executing the MONITOR\r
6865 instruction.\r
6866 @param Edx The value to load into EDX or RDX before executing the MONITOR\r
6867 instruction.\r
6868\r
6869 @return Eax\r
6870\r
6871**/\r
6872UINTN\r
6873EFIAPI\r
6874AsmMonitor (\r
6875 IN UINTN Eax,\r
6876 IN UINTN Ecx,\r
6877 IN UINTN Edx\r
6878 );\r
6879\r
6880\r
6881/**\r
6882 Executes an MWAIT instruction.\r
6883\r
6884 Executes an MWAIT instruction with the register state specified by Eax and\r
6885 Ecx. Returns Eax. This function is only available on IA-32 and X64.\r
6886\r
6887 @param Eax The value to load into EAX or RAX before executing the MONITOR\r
6888 instruction.\r
6889 @param Ecx The value to load into ECX or RCX before executing the MONITOR\r
6890 instruction.\r
6891\r
6892 @return Eax\r
6893\r
6894**/\r
6895UINTN\r
6896EFIAPI\r
6897AsmMwait (\r
6898 IN UINTN Eax,\r
6899 IN UINTN Ecx\r
6900 );\r
6901\r
6902\r
6903/**\r
6904 Executes a WBINVD instruction.\r
6905\r
6906 Executes a WBINVD instruction. This function is only available on IA-32 and\r
6907 X64.\r
6908\r
6909**/\r
6910VOID\r
6911EFIAPI\r
6912AsmWbinvd (\r
6913 VOID\r
6914 );\r
6915\r
6916\r
6917/**\r
6918 Executes a INVD instruction.\r
6919\r
6920 Executes a INVD instruction. This function is only available on IA-32 and\r
6921 X64.\r
6922\r
6923**/\r
6924VOID\r
6925EFIAPI\r
6926AsmInvd (\r
6927 VOID\r
6928 );\r
6929\r
6930\r
6931/**\r
6932 Flushes a cache line from all the instruction and data caches within the\r
6933 coherency domain of the CPU.\r
6934\r
6935 Flushed the cache line specified by LinearAddress, and returns LinearAddress.\r
6936 This function is only available on IA-32 and X64.\r
6937\r
6938 @param LinearAddress The address of the cache line to flush. If the CPU is\r
6939 in a physical addressing mode, then LinearAddress is a\r
6940 physical address. If the CPU is in a virtual\r
6941 addressing mode, then LinearAddress is a virtual\r
6942 address.\r
6943\r
6944 @return LinearAddress\r
6945**/\r
6946VOID *\r
6947EFIAPI\r
6948AsmFlushCacheLine (\r
6949 IN VOID *LinearAddress\r
6950 );\r
6951\r
6952\r
6953/**\r
6954 Enables the 32-bit paging mode on the CPU.\r
6955\r
6956 Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables\r
6957 must be properly initialized prior to calling this service. This function\r
6958 assumes the current execution mode is 32-bit protected mode. This function is\r
6959 only available on IA-32. After the 32-bit paging mode is enabled, control is\r
6960 transferred to the function specified by EntryPoint using the new stack\r
6961 specified by NewStack and passing in the parameters specified by Context1 and\r
6962 Context2. Context1 and Context2 are optional and may be NULL. The function\r
6963 EntryPoint must never return.\r
6964\r
6965 If the current execution mode is not 32-bit protected mode, then ASSERT().\r
6966 If EntryPoint is NULL, then ASSERT().\r
6967 If NewStack is NULL, then ASSERT().\r
6968\r
6969 There are a number of constraints that must be followed before calling this\r
6970 function:\r
6971 1) Interrupts must be disabled.\r
6972 2) The caller must be in 32-bit protected mode with flat descriptors. This\r
6973 means all descriptors must have a base of 0 and a limit of 4GB.\r
6974 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat\r
6975 descriptors.\r
6976 4) CR3 must point to valid page tables that will be used once the transition\r
6977 is complete, and those page tables must guarantee that the pages for this\r
6978 function and the stack are identity mapped.\r
6979\r
6980 @param EntryPoint A pointer to function to call with the new stack after\r
6981 paging is enabled.\r
6982 @param Context1 A pointer to the context to pass into the EntryPoint\r
6983 function as the first parameter after paging is enabled.\r
6984 @param Context2 A pointer to the context to pass into the EntryPoint\r
6985 function as the second parameter after paging is enabled.\r
6986 @param NewStack A pointer to the new stack to use for the EntryPoint\r
6987 function after paging is enabled.\r
6988\r
6989**/\r
6990VOID\r
6991EFIAPI\r
6992AsmEnablePaging32 (\r
6993 IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r
6994 IN VOID *Context1, OPTIONAL\r
6995 IN VOID *Context2, OPTIONAL\r
6996 IN VOID *NewStack\r
6997 );\r
6998\r
6999\r
7000/**\r
7001 Disables the 32-bit paging mode on the CPU.\r
7002\r
7003 Disables the 32-bit paging mode on the CPU and returns to 32-bit protected\r
7004 mode. This function assumes the current execution mode is 32-paged protected\r
7005 mode. This function is only available on IA-32. After the 32-bit paging mode\r
7006 is disabled, control is transferred to the function specified by EntryPoint\r
7007 using the new stack specified by NewStack and passing in the parameters\r
7008 specified by Context1 and Context2. Context1 and Context2 are optional and\r
7009 may be NULL. The function EntryPoint must never return.\r
7010\r
7011 If the current execution mode is not 32-bit paged mode, then ASSERT().\r
7012 If EntryPoint is NULL, then ASSERT().\r
7013 If NewStack is NULL, then ASSERT().\r
7014\r
7015 There are a number of constraints that must be followed before calling this\r
7016 function:\r
7017 1) Interrupts must be disabled.\r
7018 2) The caller must be in 32-bit paged mode.\r
7019 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.\r
7020 4) CR3 must point to valid page tables that guarantee that the pages for\r
7021 this function and the stack are identity mapped.\r
7022\r
7023 @param EntryPoint A pointer to function to call with the new stack after\r
7024 paging is disabled.\r
7025 @param Context1 A pointer to the context to pass into the EntryPoint\r
7026 function as the first parameter after paging is disabled.\r
7027 @param Context2 A pointer to the context to pass into the EntryPoint\r
7028 function as the second parameter after paging is\r
7029 disabled.\r
7030 @param NewStack A pointer to the new stack to use for the EntryPoint\r
7031 function after paging is disabled.\r
7032\r
7033**/\r
7034VOID\r
7035EFIAPI\r
7036AsmDisablePaging32 (\r
7037 IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r
7038 IN VOID *Context1, OPTIONAL\r
7039 IN VOID *Context2, OPTIONAL\r
7040 IN VOID *NewStack\r
7041 );\r
7042\r
7043\r
7044/**\r
7045 Enables the 64-bit paging mode on the CPU.\r
7046\r
7047 Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables\r
7048 must be properly initialized prior to calling this service. This function\r
7049 assumes the current execution mode is 32-bit protected mode with flat\r
7050 descriptors. This function is only available on IA-32. After the 64-bit\r
7051 paging mode is enabled, control is transferred to the function specified by\r
7052 EntryPoint using the new stack specified by NewStack and passing in the\r
7053 parameters specified by Context1 and Context2. Context1 and Context2 are\r
7054 optional and may be 0. The function EntryPoint must never return.\r
7055\r
7056 If the current execution mode is not 32-bit protected mode with flat\r
7057 descriptors, then ASSERT().\r
7058 If EntryPoint is 0, then ASSERT().\r
7059 If NewStack is 0, then ASSERT().\r
7060\r
42eedea9 7061 @param CodeSelector The 16-bit selector to load in the CS before EntryPoint\r
ac644614 7062 is called. The descriptor in the GDT that this selector\r
7063 references must be setup for long mode.\r
7064 @param EntryPoint The 64-bit virtual address of the function to call with\r
7065 the new stack after paging is enabled.\r
7066 @param Context1 The 64-bit virtual address of the context to pass into\r
7067 the EntryPoint function as the first parameter after\r
7068 paging is enabled.\r
7069 @param Context2 The 64-bit virtual address of the context to pass into\r
7070 the EntryPoint function as the second parameter after\r
7071 paging is enabled.\r
7072 @param NewStack The 64-bit virtual address of the new stack to use for\r
7073 the EntryPoint function after paging is enabled.\r
7074\r
7075**/\r
7076VOID\r
7077EFIAPI\r
7078AsmEnablePaging64 (\r
7079 IN UINT16 CodeSelector,\r
7080 IN UINT64 EntryPoint,\r
7081 IN UINT64 Context1, OPTIONAL\r
7082 IN UINT64 Context2, OPTIONAL\r
7083 IN UINT64 NewStack\r
7084 );\r
7085\r
7086\r
7087/**\r
7088 Disables the 64-bit paging mode on the CPU.\r
7089\r
7090 Disables the 64-bit paging mode on the CPU and returns to 32-bit protected\r
7091 mode. This function assumes the current execution mode is 64-paging mode.\r
7092 This function is only available on X64. After the 64-bit paging mode is\r
7093 disabled, control is transferred to the function specified by EntryPoint\r
7094 using the new stack specified by NewStack and passing in the parameters\r
7095 specified by Context1 and Context2. Context1 and Context2 are optional and\r
7096 may be 0. The function EntryPoint must never return.\r
7097\r
7098 If the current execution mode is not 64-bit paged mode, then ASSERT().\r
7099 If EntryPoint is 0, then ASSERT().\r
7100 If NewStack is 0, then ASSERT().\r
7101\r
42eedea9 7102 @param CodeSelector The 16-bit selector to load in the CS before EntryPoint\r
ac644614 7103 is called. The descriptor in the GDT that this selector\r
7104 references must be setup for 32-bit protected mode.\r
7105 @param EntryPoint The 64-bit virtual address of the function to call with\r
7106 the new stack after paging is disabled.\r
7107 @param Context1 The 64-bit virtual address of the context to pass into\r
7108 the EntryPoint function as the first parameter after\r
7109 paging is disabled.\r
7110 @param Context2 The 64-bit virtual address of the context to pass into\r
7111 the EntryPoint function as the second parameter after\r
7112 paging is disabled.\r
7113 @param NewStack The 64-bit virtual address of the new stack to use for\r
7114 the EntryPoint function after paging is disabled.\r
7115\r
7116**/\r
7117VOID\r
7118EFIAPI\r
7119AsmDisablePaging64 (\r
7120 IN UINT16 CodeSelector,\r
7121 IN UINT32 EntryPoint,\r
7122 IN UINT32 Context1, OPTIONAL\r
7123 IN UINT32 Context2, OPTIONAL\r
7124 IN UINT32 NewStack\r
7125 );\r
7126\r
7127\r
7128//\r
7129// 16-bit thunking services\r
7130//\r
7131\r
7132/**\r
7133 Retrieves the properties for 16-bit thunk functions.\r
7134\r
7135 Computes the size of the buffer and stack below 1MB required to use the\r
7136 AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This\r
7137 buffer size is returned in RealModeBufferSize, and the stack size is returned\r
7138 in ExtraStackSize. If parameters are passed to the 16-bit real mode code,\r
7139 then the actual minimum stack size is ExtraStackSize plus the maximum number\r
7140 of bytes that need to be passed to the 16-bit real mode code.\r
7141\r
7142 If RealModeBufferSize is NULL, then ASSERT().\r
7143 If ExtraStackSize is NULL, then ASSERT().\r
7144\r
7145 @param RealModeBufferSize A pointer to the size of the buffer below 1MB\r
7146 required to use the 16-bit thunk functions.\r
7147 @param ExtraStackSize A pointer to the extra size of stack below 1MB\r
7148 that the 16-bit thunk functions require for\r
7149 temporary storage in the transition to and from\r
7150 16-bit real mode.\r
7151\r
7152**/\r
7153VOID\r
7154EFIAPI\r
7155AsmGetThunk16Properties (\r
7156 OUT UINT32 *RealModeBufferSize,\r
7157 OUT UINT32 *ExtraStackSize\r
7158 );\r
7159\r
7160\r
7161/**\r
7162 Prepares all structures a code required to use AsmThunk16().\r
7163\r
7164 Prepares all structures and code required to use AsmThunk16().\r
7165\r
7166 If ThunkContext is NULL, then ASSERT().\r
7167\r
7168 @param ThunkContext A pointer to the context structure that describes the\r
7169 16-bit real mode code to call.\r
7170\r
7171**/\r
7172VOID\r
7173EFIAPI\r
7174AsmPrepareThunk16 (\r
7175 OUT THUNK_CONTEXT *ThunkContext\r
7176 );\r
7177\r
7178\r
7179/**\r
7180 Transfers control to a 16-bit real mode entry point and returns the results.\r
7181\r
7182 Transfers control to a 16-bit real mode entry point and returns the results.\r
7183 AsmPrepareThunk16() must be called with ThunkContext before this function is\r
7184 used.\r
7185\r
7186 If ThunkContext is NULL, then ASSERT().\r
7187 If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().\r
7188\r
7189 @param ThunkContext A pointer to the context structure that describes the\r
7190 16-bit real mode code to call.\r
7191\r
7192**/\r
7193VOID\r
7194EFIAPI\r
7195AsmThunk16 (\r
7196 IN OUT THUNK_CONTEXT *ThunkContext\r
7197 );\r
7198\r
7199\r
7200/**\r
7201 Prepares all structures and code for a 16-bit real mode thunk, transfers\r
7202 control to a 16-bit real mode entry point, and returns the results.\r
7203\r
7204 Prepares all structures and code for a 16-bit real mode thunk, transfers\r
7205 control to a 16-bit real mode entry point, and returns the results. If the\r
7206 caller only need to perform a single 16-bit real mode thunk, then this\r
7207 service should be used. If the caller intends to make more than one 16-bit\r
7208 real mode thunk, then it is more efficient if AsmPrepareThunk16() is called\r
7209 once and AsmThunk16() can be called for each 16-bit real mode thunk.\r
7210\r
7211 If ThunkContext is NULL, then ASSERT().\r
7212\r
7213 @param ThunkContext A pointer to the context structure that describes the\r
7214 16-bit real mode code to call.\r
7215\r
7216**/\r
7217VOID\r
7218EFIAPI\r
7219AsmPrepareAndThunk16 (\r
7220 IN OUT THUNK_CONTEXT *ThunkContext\r
7221 );\r
7222\r
ac644614 7223#endif\r
e3a7917f 7224#endif\r
ac644614 7225\r
7226\r