]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Library/BaseLib.h
Minor comments update to remove long line (column num > 120)
[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
282b7ec6 3059 OUT SPIN_LOCK *SpinLock\r
ac644614 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
dc317713 5082#if defined (MDE_CPU_IA32)\r
5083\r
5084typedef union {\r
5085 struct {\r
5086 UINT32 OffsetLow:16; // Offset bits 15..0\r
5087 UINT32 Selector:16; // Selector\r
5088 UINT32 Reserved_0:8; // Reserved\r
5089 UINT32 GateType:8; // Gate Type. See #defines above\r
5090 UINT32 OffsetHigh:16; // Offset bits 31..16\r
5091 } Bits;\r
5092 UINT64 Uint64;\r
5093} IA32_IDT_GATE_DESCRIPTOR;\r
5094\r
5095#endif\r
5096\r
5097#if defined (MDE_CPU_X64)\r
5098\r
ac644614 5099typedef union {\r
5100 struct {\r
dc317713 5101 UINT32 OffsetLow:16; // Offset bits 15..0\r
5102 UINT32 Selector:16; // Selector\r
5103 UINT32 Reserved_0:8; // Reserved\r
5104 UINT32 GateType:8; // Gate Type. See #defines above\r
5105 UINT32 OffsetHigh:16; // Offset bits 31..16\r
5106 UINT32 OffsetUpper:32; // Offset bits 63..32\r
5107 UINT32 Reserved_1:32; // Reserved\r
ac644614 5108 } Bits;\r
5109 UINT64 Uint64;\r
dc317713 5110 UINT64 Uint64_1;\r
ac644614 5111} IA32_IDT_GATE_DESCRIPTOR;\r
5112\r
dc317713 5113#endif\r
5114\r
1106ffe1 5115///\r
5116/// Byte packed structure for an FP/SSE/SSE2 context\r
5117///\r
ac644614 5118typedef struct {\r
5119 UINT8 Buffer[512];\r
5120} IA32_FX_BUFFER;\r
5121\r
1106ffe1 5122///\r
5123/// Structures for the 16-bit real mode thunks\r
5124///\r
ac644614 5125typedef struct {\r
5126 UINT32 Reserved1;\r
5127 UINT32 Reserved2;\r
5128 UINT32 Reserved3;\r
5129 UINT32 Reserved4;\r
5130 UINT8 BL;\r
5131 UINT8 BH;\r
5132 UINT16 Reserved5;\r
5133 UINT8 DL;\r
5134 UINT8 DH;\r
5135 UINT16 Reserved6;\r
5136 UINT8 CL;\r
5137 UINT8 CH;\r
5138 UINT16 Reserved7;\r
5139 UINT8 AL;\r
5140 UINT8 AH;\r
5141 UINT16 Reserved8;\r
5142} IA32_BYTE_REGS;\r
5143\r
5144typedef struct {\r
5145 UINT16 DI;\r
5146 UINT16 Reserved1;\r
5147 UINT16 SI;\r
5148 UINT16 Reserved2;\r
5149 UINT16 BP;\r
5150 UINT16 Reserved3;\r
5151 UINT16 SP;\r
5152 UINT16 Reserved4;\r
5153 UINT16 BX;\r
5154 UINT16 Reserved5;\r
5155 UINT16 DX;\r
5156 UINT16 Reserved6;\r
5157 UINT16 CX;\r
5158 UINT16 Reserved7;\r
5159 UINT16 AX;\r
5160 UINT16 Reserved8;\r
5161} IA32_WORD_REGS;\r
5162\r
5163typedef struct {\r
5164 UINT32 EDI;\r
5165 UINT32 ESI;\r
5166 UINT32 EBP;\r
5167 UINT32 ESP;\r
5168 UINT32 EBX;\r
5169 UINT32 EDX;\r
5170 UINT32 ECX;\r
5171 UINT32 EAX;\r
5172 UINT16 DS;\r
5173 UINT16 ES;\r
5174 UINT16 FS;\r
5175 UINT16 GS;\r
5176 IA32_EFLAGS32 EFLAGS;\r
5177 UINT32 Eip;\r
5178 UINT16 CS;\r
5179 UINT16 SS;\r
5180} IA32_DWORD_REGS;\r
5181\r
5182typedef union {\r
5183 IA32_DWORD_REGS E;\r
5184 IA32_WORD_REGS X;\r
5185 IA32_BYTE_REGS H;\r
5186} IA32_REGISTER_SET;\r
5187\r
1106ffe1 5188///\r
5189/// Byte packed structure for an 16-bit real mode thunks\r
5190///\r
ac644614 5191typedef struct {\r
5192 IA32_REGISTER_SET *RealModeState;\r
5193 VOID *RealModeBuffer;\r
5194 UINT32 RealModeBufferSize;\r
5195 UINT32 ThunkAttributes;\r
5196} THUNK_CONTEXT;\r
5197\r
5198#define THUNK_ATTRIBUTE_BIG_REAL_MODE 0x00000001\r
5199#define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 0x00000002\r
5200#define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004\r
5201\r
5202/**\r
5203 Retrieves CPUID information.\r
5204\r
5205 Executes the CPUID instruction with EAX set to the value specified by Index.\r
5206 This function always returns Index.\r
5207 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.\r
5208 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.\r
5209 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.\r
5210 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.\r
5211 This function is only available on IA-32 and X64.\r
5212\r
5213 @param Index The 32-bit value to load into EAX prior to invoking the CPUID\r
5214 instruction.\r
5215 @param Eax Pointer to the 32-bit EAX value returned by the CPUID\r
5216 instruction. This is an optional parameter that may be NULL.\r
5217 @param Ebx Pointer to the 32-bit EBX value returned by the CPUID\r
5218 instruction. This is an optional parameter that may be NULL.\r
5219 @param Ecx Pointer to the 32-bit ECX value returned by the CPUID\r
5220 instruction. This is an optional parameter that may be NULL.\r
5221 @param Edx Pointer to the 32-bit EDX value returned by the CPUID\r
5222 instruction. This is an optional parameter that may be NULL.\r
5223\r
5224 @return Index\r
5225\r
5226**/\r
5227UINT32\r
5228EFIAPI\r
5229AsmCpuid (\r
5230 IN UINT32 Index,\r
5231 OUT UINT32 *Eax, OPTIONAL\r
5232 OUT UINT32 *Ebx, OPTIONAL\r
5233 OUT UINT32 *Ecx, OPTIONAL\r
5234 OUT UINT32 *Edx OPTIONAL\r
5235 );\r
5236\r
5237\r
5238/**\r
5239 Retrieves CPUID information using an extended leaf identifier.\r
5240\r
5241 Executes the CPUID instruction with EAX set to the value specified by Index\r
5242 and ECX set to the value specified by SubIndex. This function always returns\r
5243 Index. This function is only available on IA-32 and x64.\r
5244\r
5245 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.\r
5246 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.\r
5247 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.\r
5248 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.\r
5249\r
5250 @param Index The 32-bit value to load into EAX prior to invoking the\r
5251 CPUID instruction.\r
5252 @param SubIndex The 32-bit value to load into ECX prior to invoking the\r
5253 CPUID instruction.\r
5254 @param Eax Pointer to the 32-bit EAX value returned by the CPUID\r
5255 instruction. This is an optional parameter that may be\r
5256 NULL.\r
5257 @param Ebx Pointer to the 32-bit EBX value returned by the CPUID\r
5258 instruction. This is an optional parameter that may be\r
5259 NULL.\r
5260 @param Ecx Pointer to the 32-bit ECX value returned by the CPUID\r
5261 instruction. This is an optional parameter that may be\r
5262 NULL.\r
5263 @param Edx Pointer to the 32-bit EDX value returned by the CPUID\r
5264 instruction. This is an optional parameter that may be\r
5265 NULL.\r
5266\r
5267 @return Index\r
5268\r
5269**/\r
5270UINT32\r
5271EFIAPI\r
5272AsmCpuidEx (\r
5273 IN UINT32 Index,\r
5274 IN UINT32 SubIndex,\r
5275 OUT UINT32 *Eax, OPTIONAL\r
5276 OUT UINT32 *Ebx, OPTIONAL\r
5277 OUT UINT32 *Ecx, OPTIONAL\r
5278 OUT UINT32 *Edx OPTIONAL\r
5279 );\r
5280\r
5281\r
5282/**\r
5283 Returns the lower 32-bits of a Machine Specific Register(MSR).\r
5284\r
5285 Reads and returns the lower 32-bits of the MSR specified by Index.\r
5286 No parameter checking is performed on Index, and some Index values may cause\r
5287 CPU exceptions. The caller must either guarantee that Index is valid, or the\r
5288 caller must set up exception handlers to catch the exceptions. This function\r
5289 is only available on IA-32 and X64.\r
5290\r
5291 @param Index The 32-bit MSR index to read.\r
5292\r
5293 @return The lower 32 bits of the MSR identified by Index.\r
5294\r
5295**/\r
5296UINT32\r
5297EFIAPI\r
5298AsmReadMsr32 (\r
5299 IN UINT32 Index\r
5300 );\r
5301\r
5302\r
5303/**\r
5304 Zero-extend a 32-bit value and writes it to a Machine Specific Register(MSR).\r
5305\r
5306 Writes the 32-bit value specified by Value to the MSR specified by Index. The\r
5307 upper 32-bits of the MSR write are set to zero. The 32-bit value written to\r
5308 the MSR is returned. No parameter checking is performed on Index or Value,\r
5309 and some of these may cause CPU exceptions. The caller must either guarantee\r
5310 that Index and Value are valid, or the caller must establish proper exception\r
5311 handlers. This function is only available on IA-32 and X64.\r
5312\r
5313 @param Index The 32-bit MSR index to write.\r
5314 @param Value The 32-bit value to write to the MSR.\r
5315\r
5316 @return Value\r
5317\r
5318**/\r
5319UINT32\r
5320EFIAPI\r
5321AsmWriteMsr32 (\r
5322 IN UINT32 Index,\r
5323 IN UINT32 Value\r
5324 );\r
5325\r
5326\r
5327/**\r
5328 Reads a 64-bit MSR, performs a bitwise inclusive OR on the lower 32-bits, and\r
5329 writes the result back to the 64-bit MSR.\r
5330\r
5331 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR\r
5332 between the lower 32-bits of the read result and the value specified by\r
5333 OrData, and writes the result to the 64-bit MSR specified by Index. The lower\r
5334 32-bits of the value written to the MSR is returned. No parameter checking is\r
5335 performed on Index or OrData, and some of these may cause CPU exceptions. The\r
5336 caller must either guarantee that Index and OrData are valid, or the caller\r
5337 must establish proper exception handlers. This function is only available on\r
5338 IA-32 and X64.\r
5339\r
5340 @param Index The 32-bit MSR index to write.\r
5341 @param OrData The value to OR with the read value from the MSR.\r
5342\r
5343 @return The lower 32-bit value written to the MSR.\r
5344\r
5345**/\r
5346UINT32\r
5347EFIAPI\r
5348AsmMsrOr32 (\r
5349 IN UINT32 Index,\r
5350 IN UINT32 OrData\r
5351 );\r
5352\r
5353\r
5354/**\r
5355 Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes\r
5356 the result back to the 64-bit MSR.\r
5357\r
5358 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r
5359 lower 32-bits of the read result and the value specified by AndData, and\r
5360 writes the result to the 64-bit MSR specified by Index. The lower 32-bits of\r
5361 the value written to the MSR is returned. No parameter checking is performed\r
5362 on Index or AndData, and some of these may cause CPU exceptions. The caller\r
5363 must either guarantee that Index and AndData are valid, or the caller must\r
5364 establish proper exception handlers. This function is only available on IA-32\r
5365 and X64.\r
5366\r
5367 @param Index The 32-bit MSR index to write.\r
5368 @param AndData The value to AND with the read value from the MSR.\r
5369\r
5370 @return The lower 32-bit value written to the MSR.\r
5371\r
5372**/\r
5373UINT32\r
5374EFIAPI\r
5375AsmMsrAnd32 (\r
5376 IN UINT32 Index,\r
5377 IN UINT32 AndData\r
5378 );\r
5379\r
5380\r
5381/**\r
5382 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive OR\r
5383 on the lower 32-bits, and writes the result back to the 64-bit MSR.\r
5384\r
5385 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r
5386 lower 32-bits of the read result and the value specified by AndData\r
5387 preserving the upper 32-bits, performs a bitwise inclusive OR between the\r
5388 result of the AND operation and the value specified by OrData, and writes the\r
5389 result to the 64-bit MSR specified by Address. The lower 32-bits of the value\r
5390 written to the MSR is returned. No parameter checking is performed on Index,\r
5391 AndData, or OrData, and some of these may cause CPU exceptions. The caller\r
5392 must either guarantee that Index, AndData, and OrData are valid, or the\r
5393 caller must establish proper exception handlers. This function is only\r
5394 available on IA-32 and X64.\r
5395\r
5396 @param Index The 32-bit MSR index to write.\r
5397 @param AndData The value to AND with the read value from the MSR.\r
5398 @param OrData The value to OR with the result of the AND operation.\r
5399\r
5400 @return The lower 32-bit value written to the MSR.\r
5401\r
5402**/\r
5403UINT32\r
5404EFIAPI\r
5405AsmMsrAndThenOr32 (\r
5406 IN UINT32 Index,\r
5407 IN UINT32 AndData,\r
5408 IN UINT32 OrData\r
5409 );\r
5410\r
5411\r
5412/**\r
5413 Reads a bit field of an MSR.\r
5414\r
5415 Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is\r
5416 specified by the StartBit and the EndBit. The value of the bit field is\r
5417 returned. The caller must either guarantee that Index is valid, or the caller\r
5418 must set up exception handlers to catch the exceptions. This function is only\r
5419 available on IA-32 and X64.\r
5420\r
5421 If StartBit is greater than 31, then ASSERT().\r
5422 If EndBit is greater than 31, then ASSERT().\r
5423 If EndBit is less than StartBit, then ASSERT().\r
5424\r
5425 @param Index The 32-bit MSR index to read.\r
5426 @param StartBit The ordinal of the least significant bit in the bit field.\r
5427 Range 0..31.\r
5428 @param EndBit The ordinal of the most significant bit in the bit field.\r
5429 Range 0..31.\r
5430\r
5431 @return The bit field read from the MSR.\r
5432\r
5433**/\r
5434UINT32\r
5435EFIAPI\r
5436AsmMsrBitFieldRead32 (\r
5437 IN UINT32 Index,\r
5438 IN UINTN StartBit,\r
5439 IN UINTN EndBit\r
5440 );\r
5441\r
5442\r
5443/**\r
5444 Writes a bit field to an MSR.\r
5445\r
5446 Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit\r
5447 field is specified by the StartBit and the EndBit. All other bits in the\r
5448 destination MSR are preserved. The lower 32-bits of the MSR written is\r
5449 returned. Extra left bits in Value are stripped. The caller must either\r
5450 guarantee that Index and the data written is valid, or the caller must set up\r
5451 exception handlers to catch the exceptions. This function is only available\r
5452 on IA-32 and X64.\r
5453\r
5454 If StartBit is greater than 31, then ASSERT().\r
5455 If EndBit is greater than 31, then ASSERT().\r
5456 If EndBit is less than StartBit, then ASSERT().\r
5457\r
5458 @param Index The 32-bit MSR index to write.\r
5459 @param StartBit The ordinal of the least significant bit in the bit field.\r
5460 Range 0..31.\r
5461 @param EndBit The ordinal of the most significant bit in the bit field.\r
5462 Range 0..31.\r
5463 @param Value New value of the bit field.\r
5464\r
5465 @return The lower 32-bit of the value written to the MSR.\r
5466\r
5467**/\r
5468UINT32\r
5469EFIAPI\r
5470AsmMsrBitFieldWrite32 (\r
5471 IN UINT32 Index,\r
5472 IN UINTN StartBit,\r
5473 IN UINTN EndBit,\r
5474 IN UINT32 Value\r
5475 );\r
5476\r
5477\r
5478/**\r
5479 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the\r
5480 result back to the bit field in the 64-bit MSR.\r
5481\r
5482 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR\r
5483 between the read result and the value specified by OrData, and writes the\r
5484 result to the 64-bit MSR specified by Index. The lower 32-bits of the value\r
5485 written to the MSR are returned. Extra left bits in OrData are stripped. The\r
5486 caller must either guarantee that Index and the data written is valid, or\r
5487 the caller must set up exception handlers to catch the exceptions. This\r
5488 function is only available on IA-32 and X64.\r
5489\r
5490 If StartBit is greater than 31, then ASSERT().\r
5491 If EndBit is greater than 31, then ASSERT().\r
5492 If EndBit is less than StartBit, then ASSERT().\r
5493\r
5494 @param Index The 32-bit MSR index to write.\r
5495 @param StartBit The ordinal of the least significant bit in the bit field.\r
5496 Range 0..31.\r
5497 @param EndBit The ordinal of the most significant bit in the bit field.\r
5498 Range 0..31.\r
5499 @param OrData The value to OR with the read value from the MSR.\r
5500\r
5501 @return The lower 32-bit of the value written to the MSR.\r
5502\r
5503**/\r
5504UINT32\r
5505EFIAPI\r
5506AsmMsrBitFieldOr32 (\r
5507 IN UINT32 Index,\r
5508 IN UINTN StartBit,\r
5509 IN UINTN EndBit,\r
5510 IN UINT32 OrData\r
5511 );\r
5512\r
5513\r
5514/**\r
5515 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the\r
5516 result back to the bit field in the 64-bit MSR.\r
5517\r
5518 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r
5519 read result and the value specified by AndData, and writes the result to the\r
5520 64-bit MSR specified by Index. The lower 32-bits of the value written to the\r
5521 MSR are returned. Extra left bits in AndData are stripped. The caller must\r
5522 either guarantee that Index and the data written is valid, or the caller must\r
5523 set up exception handlers to catch the exceptions. This function is only\r
5524 available on IA-32 and X64.\r
5525\r
5526 If StartBit is greater than 31, then ASSERT().\r
5527 If EndBit is greater than 31, then ASSERT().\r
5528 If EndBit is less than StartBit, then ASSERT().\r
5529\r
5530 @param Index The 32-bit MSR index to write.\r
5531 @param StartBit The ordinal of the least significant bit in the bit field.\r
5532 Range 0..31.\r
5533 @param EndBit The ordinal of the most significant bit in the bit field.\r
5534 Range 0..31.\r
5535 @param AndData The value to AND with the read value from the MSR.\r
5536\r
5537 @return The lower 32-bit of the value written to the MSR.\r
5538\r
5539**/\r
5540UINT32\r
5541EFIAPI\r
5542AsmMsrBitFieldAnd32 (\r
5543 IN UINT32 Index,\r
5544 IN UINTN StartBit,\r
5545 IN UINTN EndBit,\r
5546 IN UINT32 AndData\r
5547 );\r
5548\r
5549\r
5550/**\r
5551 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a\r
5552 bitwise inclusive OR, and writes the result back to the bit field in the\r
5553 64-bit MSR.\r
5554\r
5555 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a\r
5556 bitwise inclusive OR between the read result and the value specified by\r
5557 AndData, and writes the result to the 64-bit MSR specified by Index. The\r
5558 lower 32-bits of the value written to the MSR are returned. Extra left bits\r
5559 in both AndData and OrData are stripped. The caller must either guarantee\r
5560 that Index and the data written is valid, or the caller must set up exception\r
5561 handlers to catch the exceptions. This function is only available on IA-32\r
5562 and X64.\r
5563\r
5564 If StartBit is greater than 31, then ASSERT().\r
5565 If EndBit is greater than 31, then ASSERT().\r
5566 If EndBit is less than StartBit, then ASSERT().\r
5567\r
5568 @param Index The 32-bit MSR index to write.\r
5569 @param StartBit The ordinal of the least significant bit in the bit field.\r
5570 Range 0..31.\r
5571 @param EndBit The ordinal of the most significant bit in the bit field.\r
5572 Range 0..31.\r
5573 @param AndData The value to AND with the read value from the MSR.\r
5574 @param OrData The value to OR with the result of the AND operation.\r
5575\r
5576 @return The lower 32-bit of the value written to the MSR.\r
5577\r
5578**/\r
5579UINT32\r
5580EFIAPI\r
5581AsmMsrBitFieldAndThenOr32 (\r
5582 IN UINT32 Index,\r
5583 IN UINTN StartBit,\r
5584 IN UINTN EndBit,\r
5585 IN UINT32 AndData,\r
5586 IN UINT32 OrData\r
5587 );\r
5588\r
5589\r
5590/**\r
5591 Returns a 64-bit Machine Specific Register(MSR).\r
5592\r
5593 Reads and returns the 64-bit MSR specified by Index. No parameter checking is\r
5594 performed on Index, and some Index values may cause CPU exceptions. The\r
5595 caller must either guarantee that Index is valid, or the caller must set up\r
5596 exception handlers to catch the exceptions. This function is only available\r
5597 on IA-32 and X64.\r
5598\r
5599 @param Index The 32-bit MSR index to read.\r
5600\r
5601 @return The value of the MSR identified by Index.\r
5602\r
5603**/\r
5604UINT64\r
5605EFIAPI\r
5606AsmReadMsr64 (\r
5607 IN UINT32 Index\r
5608 );\r
5609\r
5610\r
5611/**\r
5612 Writes a 64-bit value to a Machine Specific Register(MSR), and returns the\r
5613 value.\r
5614\r
5615 Writes the 64-bit value specified by Value to the MSR specified by Index. The\r
5616 64-bit value written to the MSR is returned. No parameter checking is\r
5617 performed on Index or Value, and some of these may cause CPU exceptions. The\r
5618 caller must either guarantee that Index and Value are valid, or the caller\r
5619 must establish proper exception handlers. This function is only available on\r
5620 IA-32 and X64.\r
5621\r
5622 @param Index The 32-bit MSR index to write.\r
5623 @param Value The 64-bit value to write to the MSR.\r
5624\r
5625 @return Value\r
5626\r
5627**/\r
5628UINT64\r
5629EFIAPI\r
5630AsmWriteMsr64 (\r
5631 IN UINT32 Index,\r
5632 IN UINT64 Value\r
5633 );\r
5634\r
5635\r
5636/**\r
5637 Reads a 64-bit MSR, performs a bitwise inclusive OR, and writes the result\r
5638 back to the 64-bit MSR.\r
5639\r
5640 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR\r
5641 between the read result and the value specified by OrData, and writes the\r
5642 result to the 64-bit MSR specified by Index. The value written to the MSR is\r
5643 returned. No parameter checking is performed on Index or OrData, and some of\r
5644 these may cause CPU exceptions. The caller must either guarantee that Index\r
5645 and OrData are valid, or the caller must establish proper exception handlers.\r
5646 This function is only available on IA-32 and X64.\r
5647\r
5648 @param Index The 32-bit MSR index to write.\r
5649 @param OrData The value to OR with the read value from the MSR.\r
5650\r
5651 @return The value written back to the MSR.\r
5652\r
5653**/\r
5654UINT64\r
5655EFIAPI\r
5656AsmMsrOr64 (\r
5657 IN UINT32 Index,\r
5658 IN UINT64 OrData\r
5659 );\r
5660\r
5661\r
5662/**\r
5663 Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the\r
5664 64-bit MSR.\r
5665\r
5666 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r
5667 read result and the value specified by OrData, and writes the result to the\r
5668 64-bit MSR specified by Index. The value written to the MSR is returned. No\r
5669 parameter checking is performed on Index or OrData, and some of these may\r
5670 cause CPU exceptions. The caller must either guarantee that Index and OrData\r
5671 are valid, or the caller must establish proper exception handlers. This\r
5672 function is only available on IA-32 and X64.\r
5673\r
5674 @param Index The 32-bit MSR index to write.\r
5675 @param AndData The value to AND with the read value from the MSR.\r
5676\r
5677 @return The value written back to the MSR.\r
5678\r
5679**/\r
5680UINT64\r
5681EFIAPI\r
5682AsmMsrAnd64 (\r
5683 IN UINT32 Index,\r
5684 IN UINT64 AndData\r
5685 );\r
5686\r
5687\r
5688/**\r
5689 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive\r
5690 OR, and writes the result back to the 64-bit MSR.\r
5691\r
5692 Reads the 64-bit MSR specified by Index, performs a bitwise AND between read\r
5693 result and the value specified by AndData, performs a bitwise inclusive OR\r
5694 between the result of the AND operation and the value specified by OrData,\r
5695 and writes the result to the 64-bit MSR specified by Index. The value written\r
5696 to the MSR is returned. No parameter checking is performed on Index, AndData,\r
5697 or OrData, and some of these may cause CPU exceptions. The caller must either\r
5698 guarantee that Index, AndData, and OrData are valid, or the caller must\r
5699 establish proper exception handlers. This function is only available on IA-32\r
5700 and X64.\r
5701\r
5702 @param Index The 32-bit MSR index to write.\r
5703 @param AndData The value to AND with the read value from the MSR.\r
5704 @param OrData The value to OR with the result of the AND operation.\r
5705\r
5706 @return The value written back to the MSR.\r
5707\r
5708**/\r
5709UINT64\r
5710EFIAPI\r
5711AsmMsrAndThenOr64 (\r
5712 IN UINT32 Index,\r
5713 IN UINT64 AndData,\r
5714 IN UINT64 OrData\r
5715 );\r
5716\r
5717\r
5718/**\r
5719 Reads a bit field of an MSR.\r
5720\r
5721 Reads the bit field in the 64-bit MSR. The bit field is specified by the\r
5722 StartBit and the EndBit. The value of the bit field is returned. The caller\r
5723 must either guarantee that Index is valid, or the caller must set up\r
5724 exception handlers to catch the exceptions. This function is only available\r
5725 on IA-32 and X64.\r
5726\r
5727 If StartBit is greater than 63, then ASSERT().\r
5728 If EndBit is greater than 63, then ASSERT().\r
5729 If EndBit is less than StartBit, then ASSERT().\r
5730\r
5731 @param Index The 32-bit MSR index to read.\r
5732 @param StartBit The ordinal of the least significant bit in the bit field.\r
5733 Range 0..63.\r
5734 @param EndBit The ordinal of the most significant bit in the bit field.\r
5735 Range 0..63.\r
5736\r
5737 @return The value read from the MSR.\r
5738\r
5739**/\r
5740UINT64\r
5741EFIAPI\r
5742AsmMsrBitFieldRead64 (\r
5743 IN UINT32 Index,\r
5744 IN UINTN StartBit,\r
5745 IN UINTN EndBit\r
5746 );\r
5747\r
5748\r
5749/**\r
5750 Writes a bit field to an MSR.\r
5751\r
5752 Writes Value to a bit field in a 64-bit MSR. The bit field is specified by\r
5753 the StartBit and the EndBit. All other bits in the destination MSR are\r
5754 preserved. The MSR written is returned. Extra left bits in Value are\r
5755 stripped. The caller must either guarantee that Index and the data written is\r
5756 valid, or the caller must set up exception handlers to catch the exceptions.\r
5757 This function is only available on IA-32 and X64.\r
5758\r
5759 If StartBit is greater than 63, then ASSERT().\r
5760 If EndBit is greater than 63, then ASSERT().\r
5761 If EndBit is less than StartBit, then ASSERT().\r
5762\r
5763 @param Index The 32-bit MSR index to write.\r
5764 @param StartBit The ordinal of the least significant bit in the bit field.\r
5765 Range 0..63.\r
5766 @param EndBit The ordinal of the most significant bit in the bit field.\r
5767 Range 0..63.\r
5768 @param Value New value of the bit field.\r
5769\r
5770 @return The value written back to the MSR.\r
5771\r
5772**/\r
5773UINT64\r
5774EFIAPI\r
5775AsmMsrBitFieldWrite64 (\r
5776 IN UINT32 Index,\r
5777 IN UINTN StartBit,\r
5778 IN UINTN EndBit,\r
5779 IN UINT64 Value\r
5780 );\r
5781\r
5782\r
5783/**\r
5784 Reads a bit field in a 64-bit MSR, performs a bitwise inclusive OR, and\r
5785 writes the result back to the bit field in the 64-bit MSR.\r
5786\r
5787 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR\r
5788 between the read result and the value specified by OrData, and writes the\r
5789 result to the 64-bit MSR specified by Index. The value written to the MSR is\r
5790 returned. Extra left bits in OrData are stripped. The caller must either\r
5791 guarantee that Index and the data written is valid, or the caller must set up\r
5792 exception handlers to catch the exceptions. This function is only available\r
5793 on IA-32 and X64.\r
5794\r
5795 If StartBit is greater than 63, then ASSERT().\r
5796 If EndBit is greater than 63, then ASSERT().\r
5797 If EndBit is less than StartBit, then ASSERT().\r
5798\r
5799 @param Index The 32-bit MSR index to write.\r
5800 @param StartBit The ordinal of the least significant bit in the bit field.\r
5801 Range 0..63.\r
5802 @param EndBit The ordinal of the most significant bit in the bit field.\r
5803 Range 0..63.\r
5804 @param OrData The value to OR with the read value from the bit field.\r
5805\r
5806 @return The value written back to the MSR.\r
5807\r
5808**/\r
5809UINT64\r
5810EFIAPI\r
5811AsmMsrBitFieldOr64 (\r
5812 IN UINT32 Index,\r
5813 IN UINTN StartBit,\r
5814 IN UINTN EndBit,\r
5815 IN UINT64 OrData\r
5816 );\r
5817\r
5818\r
5819/**\r
5820 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the\r
5821 result back to the bit field in the 64-bit MSR.\r
5822\r
5823 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r
5824 read result and the value specified by AndData, and writes the result to the\r
5825 64-bit MSR specified by Index. The value written to the MSR is returned.\r
5826 Extra left bits in AndData are stripped. The caller must either guarantee\r
5827 that Index and the data written is valid, or the caller must set up exception\r
5828 handlers to catch the exceptions. This function is only available on IA-32\r
5829 and X64.\r
5830\r
5831 If StartBit is greater than 63, then ASSERT().\r
5832 If EndBit is greater than 63, then ASSERT().\r
5833 If EndBit is less than StartBit, then ASSERT().\r
5834\r
5835 @param Index The 32-bit MSR index to write.\r
5836 @param StartBit The ordinal of the least significant bit in the bit field.\r
5837 Range 0..63.\r
5838 @param EndBit The ordinal of the most significant bit in the bit field.\r
5839 Range 0..63.\r
5840 @param AndData The value to AND with the read value from the bit field.\r
5841\r
5842 @return The value written back to the MSR.\r
5843\r
5844**/\r
5845UINT64\r
5846EFIAPI\r
5847AsmMsrBitFieldAnd64 (\r
5848 IN UINT32 Index,\r
5849 IN UINTN StartBit,\r
5850 IN UINTN EndBit,\r
5851 IN UINT64 AndData\r
5852 );\r
5853\r
5854\r
5855/**\r
5856 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a\r
5857 bitwise inclusive OR, and writes the result back to the bit field in the\r
5858 64-bit MSR.\r
5859\r
5860 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by\r
5861 a bitwise inclusive OR between the read result and the value specified by\r
5862 AndData, and writes the result to the 64-bit MSR specified by Index. The\r
5863 value written to the MSR is returned. Extra left bits in both AndData and\r
5864 OrData are stripped. The caller must either guarantee that Index and the data\r
5865 written is valid, or the caller must set up exception handlers to catch the\r
5866 exceptions. This function is only available on IA-32 and X64.\r
5867\r
5868 If StartBit is greater than 63, then ASSERT().\r
5869 If EndBit is greater than 63, then ASSERT().\r
5870 If EndBit is less than StartBit, then ASSERT().\r
5871\r
5872 @param Index The 32-bit MSR index to write.\r
5873 @param StartBit The ordinal of the least significant bit in the bit field.\r
5874 Range 0..63.\r
5875 @param EndBit The ordinal of the most significant bit in the bit field.\r
5876 Range 0..63.\r
5877 @param AndData The value to AND with the read value from the bit field.\r
5878 @param OrData The value to OR with the result of the AND operation.\r
5879\r
5880 @return The value written back to the MSR.\r
5881\r
5882**/\r
5883UINT64\r
5884EFIAPI\r
5885AsmMsrBitFieldAndThenOr64 (\r
5886 IN UINT32 Index,\r
5887 IN UINTN StartBit,\r
5888 IN UINTN EndBit,\r
5889 IN UINT64 AndData,\r
5890 IN UINT64 OrData\r
5891 );\r
5892\r
5893\r
5894/**\r
5895 Reads the current value of the EFLAGS register.\r
5896\r
5897 Reads and returns the current value of the EFLAGS register. This function is\r
5898 only available on IA-32 and X64. This returns a 32-bit value on IA-32 and a\r
5899 64-bit value on X64.\r
5900\r
5901 @return EFLAGS on IA-32 or RFLAGS on X64.\r
5902\r
5903**/\r
5904UINTN\r
5905EFIAPI\r
5906AsmReadEflags (\r
5907 VOID\r
5908 );\r
5909\r
5910\r
5911/**\r
5912 Reads the current value of the Control Register 0 (CR0).\r
5913\r
5914 Reads and returns the current value of CR0. This function is only available\r
5915 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
5916 X64.\r
5917\r
5918 @return The value of the Control Register 0 (CR0).\r
5919\r
5920**/\r
5921UINTN\r
5922EFIAPI\r
5923AsmReadCr0 (\r
5924 VOID\r
5925 );\r
5926\r
5927\r
5928/**\r
5929 Reads the current value of the Control Register 2 (CR2).\r
5930\r
5931 Reads and returns the current value of CR2. This function is only available\r
5932 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
5933 X64.\r
5934\r
5935 @return The value of the Control Register 2 (CR2).\r
5936\r
5937**/\r
5938UINTN\r
5939EFIAPI\r
5940AsmReadCr2 (\r
5941 VOID\r
5942 );\r
5943\r
5944\r
5945/**\r
5946 Reads the current value of the Control Register 3 (CR3).\r
5947\r
5948 Reads and returns the current value of CR3. This function is only available\r
5949 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
5950 X64.\r
5951\r
5952 @return The value of the Control Register 3 (CR3).\r
5953\r
5954**/\r
5955UINTN\r
5956EFIAPI\r
5957AsmReadCr3 (\r
5958 VOID\r
5959 );\r
5960\r
5961\r
5962/**\r
5963 Reads the current value of the Control Register 4 (CR4).\r
5964\r
5965 Reads and returns the current value of CR4. This function is only available\r
5966 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
5967 X64.\r
5968\r
5969 @return The value of the Control Register 4 (CR4).\r
5970\r
5971**/\r
5972UINTN\r
5973EFIAPI\r
5974AsmReadCr4 (\r
5975 VOID\r
5976 );\r
5977\r
5978\r
5979/**\r
5980 Writes a value to Control Register 0 (CR0).\r
5981\r
5982 Writes and returns a new value to CR0. This function is only available on\r
5983 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r
5984\r
5985 @param Cr0 The value to write to CR0.\r
5986\r
5987 @return The value written to CR0.\r
5988\r
5989**/\r
5990UINTN\r
5991EFIAPI\r
5992AsmWriteCr0 (\r
5993 UINTN Cr0\r
5994 );\r
5995\r
5996\r
5997/**\r
5998 Writes a value to Control Register 2 (CR2).\r
5999\r
6000 Writes and returns a new value to CR2. This function is only available on\r
6001 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r
6002\r
6003 @param Cr2 The value to write to CR2.\r
6004\r
6005 @return The value written to CR2.\r
6006\r
6007**/\r
6008UINTN\r
6009EFIAPI\r
6010AsmWriteCr2 (\r
6011 UINTN Cr2\r
6012 );\r
6013\r
6014\r
6015/**\r
6016 Writes a value to Control Register 3 (CR3).\r
6017\r
6018 Writes and returns a new value to CR3. This function is only available on\r
6019 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r
6020\r
6021 @param Cr3 The value to write to CR3.\r
6022\r
6023 @return The value written to CR3.\r
6024\r
6025**/\r
6026UINTN\r
6027EFIAPI\r
6028AsmWriteCr3 (\r
6029 UINTN Cr3\r
6030 );\r
6031\r
6032\r
6033/**\r
6034 Writes a value to Control Register 4 (CR4).\r
6035\r
6036 Writes and returns a new value to CR4. This function is only available on\r
6037 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r
6038\r
6039 @param Cr4 The value to write to CR4.\r
6040\r
6041 @return The value written to CR4.\r
6042\r
6043**/\r
6044UINTN\r
6045EFIAPI\r
6046AsmWriteCr4 (\r
6047 UINTN Cr4\r
6048 );\r
6049\r
6050\r
6051/**\r
6052 Reads the current value of Debug Register 0 (DR0).\r
6053\r
6054 Reads and returns the current value of DR0. This function is only available\r
6055 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
6056 X64.\r
6057\r
6058 @return The value of Debug Register 0 (DR0).\r
6059\r
6060**/\r
6061UINTN\r
6062EFIAPI\r
6063AsmReadDr0 (\r
6064 VOID\r
6065 );\r
6066\r
6067\r
6068/**\r
6069 Reads the current value of Debug Register 1 (DR1).\r
6070\r
6071 Reads and returns the current value of DR1. This function is only available\r
6072 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
6073 X64.\r
6074\r
6075 @return The value of Debug Register 1 (DR1).\r
6076\r
6077**/\r
6078UINTN\r
6079EFIAPI\r
6080AsmReadDr1 (\r
6081 VOID\r
6082 );\r
6083\r
6084\r
6085/**\r
6086 Reads the current value of Debug Register 2 (DR2).\r
6087\r
6088 Reads and returns the current value of DR2. This function is only available\r
6089 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
6090 X64.\r
6091\r
6092 @return The value of Debug Register 2 (DR2).\r
6093\r
6094**/\r
6095UINTN\r
6096EFIAPI\r
6097AsmReadDr2 (\r
6098 VOID\r
6099 );\r
6100\r
6101\r
6102/**\r
6103 Reads the current value of Debug Register 3 (DR3).\r
6104\r
6105 Reads and returns the current value of DR3. This function is only available\r
6106 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
6107 X64.\r
6108\r
6109 @return The value of Debug Register 3 (DR3).\r
6110\r
6111**/\r
6112UINTN\r
6113EFIAPI\r
6114AsmReadDr3 (\r
6115 VOID\r
6116 );\r
6117\r
6118\r
6119/**\r
6120 Reads the current value of Debug Register 4 (DR4).\r
6121\r
6122 Reads and returns the current value of DR4. This function is only available\r
6123 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
6124 X64.\r
6125\r
6126 @return The value of Debug Register 4 (DR4).\r
6127\r
6128**/\r
6129UINTN\r
6130EFIAPI\r
6131AsmReadDr4 (\r
6132 VOID\r
6133 );\r
6134\r
6135\r
6136/**\r
6137 Reads the current value of Debug Register 5 (DR5).\r
6138\r
6139 Reads and returns the current value of DR5. This function is only available\r
6140 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
6141 X64.\r
6142\r
6143 @return The value of Debug Register 5 (DR5).\r
6144\r
6145**/\r
6146UINTN\r
6147EFIAPI\r
6148AsmReadDr5 (\r
6149 VOID\r
6150 );\r
6151\r
6152\r
6153/**\r
6154 Reads the current value of Debug Register 6 (DR6).\r
6155\r
6156 Reads and returns the current value of DR6. This function is only available\r
6157 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
6158 X64.\r
6159\r
6160 @return The value of Debug Register 6 (DR6).\r
6161\r
6162**/\r
6163UINTN\r
6164EFIAPI\r
6165AsmReadDr6 (\r
6166 VOID\r
6167 );\r
6168\r
6169\r
6170/**\r
6171 Reads the current value of Debug Register 7 (DR7).\r
6172\r
6173 Reads and returns the current value of DR7. This function is only available\r
6174 on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
6175 X64.\r
6176\r
6177 @return The value of Debug Register 7 (DR7).\r
6178\r
6179**/\r
6180UINTN\r
6181EFIAPI\r
6182AsmReadDr7 (\r
6183 VOID\r
6184 );\r
6185\r
6186\r
6187/**\r
6188 Writes a value to Debug Register 0 (DR0).\r
6189\r
6190 Writes and returns a new value to DR0. This function is only available on\r
6191 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r
6192\r
6193 @param Dr0 The value to write to Dr0.\r
6194\r
6195 @return The value written to Debug Register 0 (DR0).\r
6196\r
6197**/\r
6198UINTN\r
6199EFIAPI\r
6200AsmWriteDr0 (\r
6201 UINTN Dr0\r
6202 );\r
6203\r
6204\r
6205/**\r
6206 Writes a value to Debug Register 1 (DR1).\r
6207\r
6208 Writes and returns a new value to DR1. This function is only available on\r
6209 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r
6210\r
6211 @param Dr1 The value to write to Dr1.\r
6212\r
6213 @return The value written to Debug Register 1 (DR1).\r
6214\r
6215**/\r
6216UINTN\r
6217EFIAPI\r
6218AsmWriteDr1 (\r
6219 UINTN Dr1\r
6220 );\r
6221\r
6222\r
6223/**\r
6224 Writes a value to Debug Register 2 (DR2).\r
6225\r
6226 Writes and returns a new value to DR2. This function is only available on\r
6227 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r
6228\r
6229 @param Dr2 The value to write to Dr2.\r
6230\r
6231 @return The value written to Debug Register 2 (DR2).\r
6232\r
6233**/\r
6234UINTN\r
6235EFIAPI\r
6236AsmWriteDr2 (\r
6237 UINTN Dr2\r
6238 );\r
6239\r
6240\r
6241/**\r
6242 Writes a value to Debug Register 3 (DR3).\r
6243\r
6244 Writes and returns a new value to DR3. This function is only available on\r
6245 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r
6246\r
6247 @param Dr3 The value to write to Dr3.\r
6248\r
6249 @return The value written to Debug Register 3 (DR3).\r
6250\r
6251**/\r
6252UINTN\r
6253EFIAPI\r
6254AsmWriteDr3 (\r
6255 UINTN Dr3\r
6256 );\r
6257\r
6258\r
6259/**\r
6260 Writes a value to Debug Register 4 (DR4).\r
6261\r
6262 Writes and returns a new value to DR4. This function is only available on\r
6263 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r
6264\r
6265 @param Dr4 The value to write to Dr4.\r
6266\r
6267 @return The value written to Debug Register 4 (DR4).\r
6268\r
6269**/\r
6270UINTN\r
6271EFIAPI\r
6272AsmWriteDr4 (\r
6273 UINTN Dr4\r
6274 );\r
6275\r
6276\r
6277/**\r
6278 Writes a value to Debug Register 5 (DR5).\r
6279\r
6280 Writes and returns a new value to DR5. This function is only available on\r
6281 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r
6282\r
6283 @param Dr5 The value to write to Dr5.\r
6284\r
6285 @return The value written to Debug Register 5 (DR5).\r
6286\r
6287**/\r
6288UINTN\r
6289EFIAPI\r
6290AsmWriteDr5 (\r
6291 UINTN Dr5\r
6292 );\r
6293\r
6294\r
6295/**\r
6296 Writes a value to Debug Register 6 (DR6).\r
6297\r
6298 Writes and returns a new value to DR6. This function is only available on\r
6299 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r
6300\r
6301 @param Dr6 The value to write to Dr6.\r
6302\r
6303 @return The value written to Debug Register 6 (DR6).\r
6304\r
6305**/\r
6306UINTN\r
6307EFIAPI\r
6308AsmWriteDr6 (\r
6309 UINTN Dr6\r
6310 );\r
6311\r
6312\r
6313/**\r
6314 Writes a value to Debug Register 7 (DR7).\r
6315\r
6316 Writes and returns a new value to DR7. This function is only available on\r
6317 IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r
6318\r
6319 @param Dr7 The value to write to Dr7.\r
6320\r
6321 @return The value written to Debug Register 7 (DR7).\r
6322\r
6323**/\r
6324UINTN\r
6325EFIAPI\r
6326AsmWriteDr7 (\r
6327 UINTN Dr7\r
6328 );\r
6329\r
6330\r
6331/**\r
6332 Reads the current value of Code Segment Register (CS).\r
6333\r
6334 Reads and returns the current value of CS. This function is only available on\r
6335 IA-32 and X64.\r
6336\r
6337 @return The current value of CS.\r
6338\r
6339**/\r
6340UINT16\r
6341EFIAPI\r
6342AsmReadCs (\r
6343 VOID\r
6344 );\r
6345\r
6346\r
6347/**\r
6348 Reads the current value of Data Segment Register (DS).\r
6349\r
6350 Reads and returns the current value of DS. This function is only available on\r
6351 IA-32 and X64.\r
6352\r
6353 @return The current value of DS.\r
6354\r
6355**/\r
6356UINT16\r
6357EFIAPI\r
6358AsmReadDs (\r
6359 VOID\r
6360 );\r
6361\r
6362\r
6363/**\r
6364 Reads the current value of Extra Segment Register (ES).\r
6365\r
6366 Reads and returns the current value of ES. This function is only available on\r
6367 IA-32 and X64.\r
6368\r
6369 @return The current value of ES.\r
6370\r
6371**/\r
6372UINT16\r
6373EFIAPI\r
6374AsmReadEs (\r
6375 VOID\r
6376 );\r
6377\r
6378\r
6379/**\r
6380 Reads the current value of FS Data Segment Register (FS).\r
6381\r
6382 Reads and returns the current value of FS. This function is only available on\r
6383 IA-32 and X64.\r
6384\r
6385 @return The current value of FS.\r
6386\r
6387**/\r
6388UINT16\r
6389EFIAPI\r
6390AsmReadFs (\r
6391 VOID\r
6392 );\r
6393\r
6394\r
6395/**\r
6396 Reads the current value of GS Data Segment Register (GS).\r
6397\r
6398 Reads and returns the current value of GS. This function is only available on\r
6399 IA-32 and X64.\r
6400\r
6401 @return The current value of GS.\r
6402\r
6403**/\r
6404UINT16\r
6405EFIAPI\r
6406AsmReadGs (\r
6407 VOID\r
6408 );\r
6409\r
6410\r
6411/**\r
6412 Reads the current value of Stack Segment Register (SS).\r
6413\r
6414 Reads and returns the current value of SS. This function is only available on\r
6415 IA-32 and X64.\r
6416\r
6417 @return The current value of SS.\r
6418\r
6419**/\r
6420UINT16\r
6421EFIAPI\r
6422AsmReadSs (\r
6423 VOID\r
6424 );\r
6425\r
6426\r
6427/**\r
6428 Reads the current value of Task Register (TR).\r
6429\r
6430 Reads and returns the current value of TR. This function is only available on\r
6431 IA-32 and X64.\r
6432\r
6433 @return The current value of TR.\r
6434\r
6435**/\r
6436UINT16\r
6437EFIAPI\r
6438AsmReadTr (\r
6439 VOID\r
6440 );\r
6441\r
6442\r
6443/**\r
6444 Reads the current Global Descriptor Table Register(GDTR) descriptor.\r
6445\r
6446 Reads and returns the current GDTR descriptor and returns it in Gdtr. This\r
6447 function is only available on IA-32 and X64.\r
6448\r
6449 If Gdtr is NULL, then ASSERT().\r
6450\r
6451 @param Gdtr Pointer to a GDTR descriptor.\r
6452\r
6453**/\r
6454VOID\r
6455EFIAPI\r
6456AsmReadGdtr (\r
6457 OUT IA32_DESCRIPTOR *Gdtr\r
6458 );\r
6459\r
6460\r
6461/**\r
6462 Writes the current Global Descriptor Table Register (GDTR) descriptor.\r
6463\r
6464 Writes and the current GDTR descriptor specified by Gdtr. This function is\r
6465 only available on IA-32 and X64.\r
6466\r
6467 If Gdtr is NULL, then ASSERT().\r
6468\r
6469 @param Gdtr Pointer to a GDTR descriptor.\r
6470\r
6471**/\r
6472VOID\r
6473EFIAPI\r
6474AsmWriteGdtr (\r
6475 IN CONST IA32_DESCRIPTOR *Gdtr\r
6476 );\r
6477\r
6478\r
6479/**\r
6480 Reads the current Interrupt Descriptor Table Register(GDTR) descriptor.\r
6481\r
6482 Reads and returns the current IDTR descriptor and returns it in Idtr. This\r
6483 function is only available on IA-32 and X64.\r
6484\r
6485 If Idtr is NULL, then ASSERT().\r
6486\r
6487 @param Idtr Pointer to a IDTR descriptor.\r
6488\r
6489**/\r
6490VOID\r
6491EFIAPI\r
6492AsmReadIdtr (\r
6493 OUT IA32_DESCRIPTOR *Idtr\r
6494 );\r
6495\r
6496\r
6497/**\r
6498 Writes the current Interrupt Descriptor Table Register(GDTR) descriptor.\r
6499\r
6500 Writes the current IDTR descriptor and returns it in Idtr. This function is\r
6501 only available on IA-32 and X64.\r
6502\r
6503 If Idtr is NULL, then ASSERT().\r
6504\r
6505 @param Idtr Pointer to a IDTR descriptor.\r
6506\r
6507**/\r
6508VOID\r
6509EFIAPI\r
6510AsmWriteIdtr (\r
6511 IN CONST IA32_DESCRIPTOR *Idtr\r
6512 );\r
6513\r
6514\r
6515/**\r
6516 Reads the current Local Descriptor Table Register(LDTR) selector.\r
6517\r
6518 Reads and returns the current 16-bit LDTR descriptor value. This function is\r
6519 only available on IA-32 and X64.\r
6520\r
6521 @return The current selector of LDT.\r
6522\r
6523**/\r
6524UINT16\r
6525EFIAPI\r
6526AsmReadLdtr (\r
6527 VOID\r
6528 );\r
6529\r
6530\r
6531/**\r
6532 Writes the current Local Descriptor Table Register (GDTR) selector.\r
6533\r
6534 Writes and the current LDTR descriptor specified by Ldtr. This function is\r
6535 only available on IA-32 and X64.\r
6536\r
6537 @param Ldtr 16-bit LDTR selector value.\r
6538\r
6539**/\r
6540VOID\r
6541EFIAPI\r
6542AsmWriteLdtr (\r
6543 IN UINT16 Ldtr\r
6544 );\r
6545\r
6546\r
6547/**\r
6548 Save the current floating point/SSE/SSE2 context to a buffer.\r
6549\r
6550 Saves the current floating point/SSE/SSE2 state to the buffer specified by\r
6551 Buffer. Buffer must be aligned on a 16-byte boundary. This function is only\r
6552 available on IA-32 and X64.\r
6553\r
6554 If Buffer is NULL, then ASSERT().\r
6555 If Buffer is not aligned on a 16-byte boundary, then ASSERT().\r
6556\r
6557 @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.\r
6558\r
6559**/\r
6560VOID\r
6561EFIAPI\r
6562AsmFxSave (\r
6563 OUT IA32_FX_BUFFER *Buffer\r
6564 );\r
6565\r
6566\r
6567/**\r
6568 Restores the current floating point/SSE/SSE2 context from a buffer.\r
6569\r
6570 Restores the current floating point/SSE/SSE2 state from the buffer specified\r
6571 by Buffer. Buffer must be aligned on a 16-byte boundary. This function is\r
6572 only available on IA-32 and X64.\r
6573\r
6574 If Buffer is NULL, then ASSERT().\r
6575 If Buffer is not aligned on a 16-byte boundary, then ASSERT().\r
6576 If Buffer was not saved with AsmFxSave(), then ASSERT().\r
6577\r
6578 @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.\r
6579\r
6580**/\r
6581VOID\r
6582EFIAPI\r
6583AsmFxRestore (\r
6584 IN CONST IA32_FX_BUFFER *Buffer\r
6585 );\r
6586\r
6587\r
6588/**\r
6589 Reads the current value of 64-bit MMX Register #0 (MM0).\r
6590\r
6591 Reads and returns the current value of MM0. This function is only available\r
6592 on IA-32 and X64.\r
6593\r
6594 @return The current value of MM0.\r
6595\r
6596**/\r
6597UINT64\r
6598EFIAPI\r
6599AsmReadMm0 (\r
6600 VOID\r
6601 );\r
6602\r
6603\r
6604/**\r
6605 Reads the current value of 64-bit MMX Register #1 (MM1).\r
6606\r
6607 Reads and returns the current value of MM1. This function is only available\r
6608 on IA-32 and X64.\r
6609\r
6610 @return The current value of MM1.\r
6611\r
6612**/\r
6613UINT64\r
6614EFIAPI\r
6615AsmReadMm1 (\r
6616 VOID\r
6617 );\r
6618\r
6619\r
6620/**\r
6621 Reads the current value of 64-bit MMX Register #2 (MM2).\r
6622\r
6623 Reads and returns the current value of MM2. This function is only available\r
6624 on IA-32 and X64.\r
6625\r
6626 @return The current value of MM2.\r
6627\r
6628**/\r
6629UINT64\r
6630EFIAPI\r
6631AsmReadMm2 (\r
6632 VOID\r
6633 );\r
6634\r
6635\r
6636/**\r
6637 Reads the current value of 64-bit MMX Register #3 (MM3).\r
6638\r
6639 Reads and returns the current value of MM3. This function is only available\r
6640 on IA-32 and X64.\r
6641\r
6642 @return The current value of MM3.\r
6643\r
6644**/\r
6645UINT64\r
6646EFIAPI\r
6647AsmReadMm3 (\r
6648 VOID\r
6649 );\r
6650\r
6651\r
6652/**\r
6653 Reads the current value of 64-bit MMX Register #4 (MM4).\r
6654\r
6655 Reads and returns the current value of MM4. This function is only available\r
6656 on IA-32 and X64.\r
6657\r
6658 @return The current value of MM4.\r
6659\r
6660**/\r
6661UINT64\r
6662EFIAPI\r
6663AsmReadMm4 (\r
6664 VOID\r
6665 );\r
6666\r
6667\r
6668/**\r
6669 Reads the current value of 64-bit MMX Register #5 (MM5).\r
6670\r
6671 Reads and returns the current value of MM5. This function is only available\r
6672 on IA-32 and X64.\r
6673\r
6674 @return The current value of MM5.\r
6675\r
6676**/\r
6677UINT64\r
6678EFIAPI\r
6679AsmReadMm5 (\r
6680 VOID\r
6681 );\r
6682\r
6683\r
6684/**\r
6685 Reads the current value of 64-bit MMX Register #6 (MM6).\r
6686\r
6687 Reads and returns the current value of MM6. This function is only available\r
6688 on IA-32 and X64.\r
6689\r
6690 @return The current value of MM6.\r
6691\r
6692**/\r
6693UINT64\r
6694EFIAPI\r
6695AsmReadMm6 (\r
6696 VOID\r
6697 );\r
6698\r
6699\r
6700/**\r
6701 Reads the current value of 64-bit MMX Register #7 (MM7).\r
6702\r
6703 Reads and returns the current value of MM7. This function is only available\r
6704 on IA-32 and X64.\r
6705\r
6706 @return The current value of MM7.\r
6707\r
6708**/\r
6709UINT64\r
6710EFIAPI\r
6711AsmReadMm7 (\r
6712 VOID\r
6713 );\r
6714\r
6715\r
6716/**\r
6717 Writes the current value of 64-bit MMX Register #0 (MM0).\r
6718\r
6719 Writes the current value of MM0. This function is only available on IA32 and\r
6720 X64.\r
6721\r
6722 @param Value The 64-bit value to write to MM0.\r
6723\r
6724**/\r
6725VOID\r
6726EFIAPI\r
6727AsmWriteMm0 (\r
6728 IN UINT64 Value\r
6729 );\r
6730\r
6731\r
6732/**\r
6733 Writes the current value of 64-bit MMX Register #1 (MM1).\r
6734\r
6735 Writes the current value of MM1. This function is only available on IA32 and\r
6736 X64.\r
6737\r
6738 @param Value The 64-bit value to write to MM1.\r
6739\r
6740**/\r
6741VOID\r
6742EFIAPI\r
6743AsmWriteMm1 (\r
6744 IN UINT64 Value\r
6745 );\r
6746\r
6747\r
6748/**\r
6749 Writes the current value of 64-bit MMX Register #2 (MM2).\r
6750\r
6751 Writes the current value of MM2. This function is only available on IA32 and\r
6752 X64.\r
6753\r
6754 @param Value The 64-bit value to write to MM2.\r
6755\r
6756**/\r
6757VOID\r
6758EFIAPI\r
6759AsmWriteMm2 (\r
6760 IN UINT64 Value\r
6761 );\r
6762\r
6763\r
6764/**\r
6765 Writes the current value of 64-bit MMX Register #3 (MM3).\r
6766\r
6767 Writes the current value of MM3. This function is only available on IA32 and\r
6768 X64.\r
6769\r
6770 @param Value The 64-bit value to write to MM3.\r
6771\r
6772**/\r
6773VOID\r
6774EFIAPI\r
6775AsmWriteMm3 (\r
6776 IN UINT64 Value\r
6777 );\r
6778\r
6779\r
6780/**\r
6781 Writes the current value of 64-bit MMX Register #4 (MM4).\r
6782\r
6783 Writes the current value of MM4. This function is only available on IA32 and\r
6784 X64.\r
6785\r
6786 @param Value The 64-bit value to write to MM4.\r
6787\r
6788**/\r
6789VOID\r
6790EFIAPI\r
6791AsmWriteMm4 (\r
6792 IN UINT64 Value\r
6793 );\r
6794\r
6795\r
6796/**\r
6797 Writes the current value of 64-bit MMX Register #5 (MM5).\r
6798\r
6799 Writes the current value of MM5. This function is only available on IA32 and\r
6800 X64.\r
6801\r
6802 @param Value The 64-bit value to write to MM5.\r
6803\r
6804**/\r
6805VOID\r
6806EFIAPI\r
6807AsmWriteMm5 (\r
6808 IN UINT64 Value\r
6809 );\r
6810\r
6811\r
6812/**\r
6813 Writes the current value of 64-bit MMX Register #6 (MM6).\r
6814\r
6815 Writes the current value of MM6. This function is only available on IA32 and\r
6816 X64.\r
6817\r
6818 @param Value The 64-bit value to write to MM6.\r
6819\r
6820**/\r
6821VOID\r
6822EFIAPI\r
6823AsmWriteMm6 (\r
6824 IN UINT64 Value\r
6825 );\r
6826\r
6827\r
6828/**\r
6829 Writes the current value of 64-bit MMX Register #7 (MM7).\r
6830\r
6831 Writes the current value of MM7. This function is only available on IA32 and\r
6832 X64.\r
6833\r
6834 @param Value The 64-bit value to write to MM7.\r
6835\r
6836**/\r
6837VOID\r
6838EFIAPI\r
6839AsmWriteMm7 (\r
6840 IN UINT64 Value\r
6841 );\r
6842\r
6843\r
6844/**\r
6845 Reads the current value of Time Stamp Counter (TSC).\r
6846\r
6847 Reads and returns the current value of TSC. This function is only available\r
6848 on IA-32 and X64.\r
6849\r
6850 @return The current value of TSC\r
6851\r
6852**/\r
6853UINT64\r
6854EFIAPI\r
6855AsmReadTsc (\r
6856 VOID\r
6857 );\r
6858\r
6859\r
6860/**\r
6861 Reads the current value of a Performance Counter (PMC).\r
6862\r
6863 Reads and returns the current value of performance counter specified by\r
6864 Index. This function is only available on IA-32 and X64.\r
6865\r
6866 @param Index The 32-bit Performance Counter index to read.\r
6867\r
6868 @return The value of the PMC specified by Index.\r
6869\r
6870**/\r
6871UINT64\r
6872EFIAPI\r
6873AsmReadPmc (\r
6874 IN UINT32 Index\r
6875 );\r
6876\r
6877\r
6878/**\r
6879 Sets up a monitor buffer that is used by AsmMwait().\r
6880\r
6881 Executes a MONITOR instruction with the register state specified by Eax, Ecx\r
6882 and Edx. Returns Eax. This function is only available on IA-32 and X64.\r
6883\r
6884 @param Eax The value to load into EAX or RAX before executing the MONITOR\r
6885 instruction.\r
6886 @param Ecx The value to load into ECX or RCX before executing the MONITOR\r
6887 instruction.\r
6888 @param Edx The value to load into EDX or RDX before executing the MONITOR\r
6889 instruction.\r
6890\r
6891 @return Eax\r
6892\r
6893**/\r
6894UINTN\r
6895EFIAPI\r
6896AsmMonitor (\r
6897 IN UINTN Eax,\r
6898 IN UINTN Ecx,\r
6899 IN UINTN Edx\r
6900 );\r
6901\r
6902\r
6903/**\r
6904 Executes an MWAIT instruction.\r
6905\r
6906 Executes an MWAIT instruction with the register state specified by Eax and\r
6907 Ecx. Returns Eax. This function is only available on IA-32 and X64.\r
6908\r
6909 @param Eax The value to load into EAX or RAX before executing the MONITOR\r
6910 instruction.\r
6911 @param Ecx The value to load into ECX or RCX before executing the MONITOR\r
6912 instruction.\r
6913\r
6914 @return Eax\r
6915\r
6916**/\r
6917UINTN\r
6918EFIAPI\r
6919AsmMwait (\r
6920 IN UINTN Eax,\r
6921 IN UINTN Ecx\r
6922 );\r
6923\r
6924\r
6925/**\r
6926 Executes a WBINVD instruction.\r
6927\r
6928 Executes a WBINVD instruction. This function is only available on IA-32 and\r
6929 X64.\r
6930\r
6931**/\r
6932VOID\r
6933EFIAPI\r
6934AsmWbinvd (\r
6935 VOID\r
6936 );\r
6937\r
6938\r
6939/**\r
6940 Executes a INVD instruction.\r
6941\r
6942 Executes a INVD instruction. This function is only available on IA-32 and\r
6943 X64.\r
6944\r
6945**/\r
6946VOID\r
6947EFIAPI\r
6948AsmInvd (\r
6949 VOID\r
6950 );\r
6951\r
6952\r
6953/**\r
6954 Flushes a cache line from all the instruction and data caches within the\r
6955 coherency domain of the CPU.\r
6956\r
6957 Flushed the cache line specified by LinearAddress, and returns LinearAddress.\r
6958 This function is only available on IA-32 and X64.\r
6959\r
6960 @param LinearAddress The address of the cache line to flush. If the CPU is\r
6961 in a physical addressing mode, then LinearAddress is a\r
6962 physical address. If the CPU is in a virtual\r
6963 addressing mode, then LinearAddress is a virtual\r
6964 address.\r
6965\r
6966 @return LinearAddress\r
6967**/\r
6968VOID *\r
6969EFIAPI\r
6970AsmFlushCacheLine (\r
6971 IN VOID *LinearAddress\r
6972 );\r
6973\r
6974\r
6975/**\r
6976 Enables the 32-bit paging mode on the CPU.\r
6977\r
6978 Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables\r
6979 must be properly initialized prior to calling this service. This function\r
6980 assumes the current execution mode is 32-bit protected mode. This function is\r
6981 only available on IA-32. After the 32-bit paging mode is enabled, control is\r
6982 transferred to the function specified by EntryPoint using the new stack\r
6983 specified by NewStack and passing in the parameters specified by Context1 and\r
6984 Context2. Context1 and Context2 are optional and may be NULL. The function\r
6985 EntryPoint must never return.\r
6986\r
6987 If the current execution mode is not 32-bit protected mode, then ASSERT().\r
6988 If EntryPoint is NULL, then ASSERT().\r
6989 If NewStack is NULL, then ASSERT().\r
6990\r
6991 There are a number of constraints that must be followed before calling this\r
6992 function:\r
6993 1) Interrupts must be disabled.\r
6994 2) The caller must be in 32-bit protected mode with flat descriptors. This\r
6995 means all descriptors must have a base of 0 and a limit of 4GB.\r
6996 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat\r
6997 descriptors.\r
6998 4) CR3 must point to valid page tables that will be used once the transition\r
6999 is complete, and those page tables must guarantee that the pages for this\r
7000 function and the stack are identity mapped.\r
7001\r
7002 @param EntryPoint A pointer to function to call with the new stack after\r
7003 paging is enabled.\r
7004 @param Context1 A pointer to the context to pass into the EntryPoint\r
7005 function as the first parameter after paging is enabled.\r
7006 @param Context2 A pointer to the context to pass into the EntryPoint\r
7007 function as the second parameter after paging is enabled.\r
7008 @param NewStack A pointer to the new stack to use for the EntryPoint\r
7009 function after paging is enabled.\r
7010\r
7011**/\r
7012VOID\r
7013EFIAPI\r
7014AsmEnablePaging32 (\r
7015 IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r
7016 IN VOID *Context1, OPTIONAL\r
7017 IN VOID *Context2, OPTIONAL\r
7018 IN VOID *NewStack\r
7019 );\r
7020\r
7021\r
7022/**\r
7023 Disables the 32-bit paging mode on the CPU.\r
7024\r
7025 Disables the 32-bit paging mode on the CPU and returns to 32-bit protected\r
7026 mode. This function assumes the current execution mode is 32-paged protected\r
7027 mode. This function is only available on IA-32. After the 32-bit paging mode\r
7028 is disabled, control is transferred to the function specified by EntryPoint\r
7029 using the new stack specified by NewStack and passing in the parameters\r
7030 specified by Context1 and Context2. Context1 and Context2 are optional and\r
7031 may be NULL. The function EntryPoint must never return.\r
7032\r
7033 If the current execution mode is not 32-bit paged mode, then ASSERT().\r
7034 If EntryPoint is NULL, then ASSERT().\r
7035 If NewStack is NULL, then ASSERT().\r
7036\r
7037 There are a number of constraints that must be followed before calling this\r
7038 function:\r
7039 1) Interrupts must be disabled.\r
7040 2) The caller must be in 32-bit paged mode.\r
7041 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.\r
7042 4) CR3 must point to valid page tables that guarantee that the pages for\r
7043 this function and the stack are identity mapped.\r
7044\r
7045 @param EntryPoint A pointer to function to call with the new stack after\r
7046 paging is disabled.\r
7047 @param Context1 A pointer to the context to pass into the EntryPoint\r
7048 function as the first parameter after paging is disabled.\r
7049 @param Context2 A pointer to the context to pass into the EntryPoint\r
7050 function as the second parameter after paging is\r
7051 disabled.\r
7052 @param NewStack A pointer to the new stack to use for the EntryPoint\r
7053 function after paging is disabled.\r
7054\r
7055**/\r
7056VOID\r
7057EFIAPI\r
7058AsmDisablePaging32 (\r
7059 IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r
7060 IN VOID *Context1, OPTIONAL\r
7061 IN VOID *Context2, OPTIONAL\r
7062 IN VOID *NewStack\r
7063 );\r
7064\r
7065\r
7066/**\r
7067 Enables the 64-bit paging mode on the CPU.\r
7068\r
7069 Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables\r
7070 must be properly initialized prior to calling this service. This function\r
7071 assumes the current execution mode is 32-bit protected mode with flat\r
7072 descriptors. This function is only available on IA-32. After the 64-bit\r
7073 paging mode is enabled, control is transferred to the function specified by\r
7074 EntryPoint using the new stack specified by NewStack and passing in the\r
7075 parameters specified by Context1 and Context2. Context1 and Context2 are\r
7076 optional and may be 0. The function EntryPoint must never return.\r
7077\r
7078 If the current execution mode is not 32-bit protected mode with flat\r
7079 descriptors, then ASSERT().\r
7080 If EntryPoint is 0, then ASSERT().\r
7081 If NewStack is 0, then ASSERT().\r
7082\r
42eedea9 7083 @param CodeSelector The 16-bit selector to load in the CS before EntryPoint\r
ac644614 7084 is called. The descriptor in the GDT that this selector\r
7085 references must be setup for long mode.\r
7086 @param EntryPoint The 64-bit virtual address of the function to call with\r
7087 the new stack after paging is enabled.\r
7088 @param Context1 The 64-bit virtual address of the context to pass into\r
7089 the EntryPoint function as the first parameter after\r
7090 paging is enabled.\r
7091 @param Context2 The 64-bit virtual address of the context to pass into\r
7092 the EntryPoint function as the second parameter after\r
7093 paging is enabled.\r
7094 @param NewStack The 64-bit virtual address of the new stack to use for\r
7095 the EntryPoint function after paging is enabled.\r
7096\r
7097**/\r
7098VOID\r
7099EFIAPI\r
7100AsmEnablePaging64 (\r
7101 IN UINT16 CodeSelector,\r
7102 IN UINT64 EntryPoint,\r
7103 IN UINT64 Context1, OPTIONAL\r
7104 IN UINT64 Context2, OPTIONAL\r
7105 IN UINT64 NewStack\r
7106 );\r
7107\r
7108\r
7109/**\r
7110 Disables the 64-bit paging mode on the CPU.\r
7111\r
7112 Disables the 64-bit paging mode on the CPU and returns to 32-bit protected\r
7113 mode. This function assumes the current execution mode is 64-paging mode.\r
7114 This function is only available on X64. After the 64-bit paging mode is\r
7115 disabled, control is transferred to the function specified by EntryPoint\r
7116 using the new stack specified by NewStack and passing in the parameters\r
7117 specified by Context1 and Context2. Context1 and Context2 are optional and\r
7118 may be 0. The function EntryPoint must never return.\r
7119\r
7120 If the current execution mode is not 64-bit paged mode, then ASSERT().\r
7121 If EntryPoint is 0, then ASSERT().\r
7122 If NewStack is 0, then ASSERT().\r
7123\r
42eedea9 7124 @param CodeSelector The 16-bit selector to load in the CS before EntryPoint\r
ac644614 7125 is called. The descriptor in the GDT that this selector\r
7126 references must be setup for 32-bit protected mode.\r
7127 @param EntryPoint The 64-bit virtual address of the function to call with\r
7128 the new stack after paging is disabled.\r
7129 @param Context1 The 64-bit virtual address of the context to pass into\r
7130 the EntryPoint function as the first parameter after\r
7131 paging is disabled.\r
7132 @param Context2 The 64-bit virtual address of the context to pass into\r
7133 the EntryPoint function as the second parameter after\r
7134 paging is disabled.\r
7135 @param NewStack The 64-bit virtual address of the new stack to use for\r
7136 the EntryPoint function after paging is disabled.\r
7137\r
7138**/\r
7139VOID\r
7140EFIAPI\r
7141AsmDisablePaging64 (\r
7142 IN UINT16 CodeSelector,\r
7143 IN UINT32 EntryPoint,\r
7144 IN UINT32 Context1, OPTIONAL\r
7145 IN UINT32 Context2, OPTIONAL\r
7146 IN UINT32 NewStack\r
7147 );\r
7148\r
7149\r
7150//\r
7151// 16-bit thunking services\r
7152//\r
7153\r
7154/**\r
7155 Retrieves the properties for 16-bit thunk functions.\r
7156\r
7157 Computes the size of the buffer and stack below 1MB required to use the\r
7158 AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This\r
7159 buffer size is returned in RealModeBufferSize, and the stack size is returned\r
7160 in ExtraStackSize. If parameters are passed to the 16-bit real mode code,\r
7161 then the actual minimum stack size is ExtraStackSize plus the maximum number\r
7162 of bytes that need to be passed to the 16-bit real mode code.\r
7163\r
7164 If RealModeBufferSize is NULL, then ASSERT().\r
7165 If ExtraStackSize is NULL, then ASSERT().\r
7166\r
7167 @param RealModeBufferSize A pointer to the size of the buffer below 1MB\r
7168 required to use the 16-bit thunk functions.\r
7169 @param ExtraStackSize A pointer to the extra size of stack below 1MB\r
7170 that the 16-bit thunk functions require for\r
7171 temporary storage in the transition to and from\r
7172 16-bit real mode.\r
7173\r
7174**/\r
7175VOID\r
7176EFIAPI\r
7177AsmGetThunk16Properties (\r
7178 OUT UINT32 *RealModeBufferSize,\r
7179 OUT UINT32 *ExtraStackSize\r
7180 );\r
7181\r
7182\r
7183/**\r
7184 Prepares all structures a code required to use AsmThunk16().\r
7185\r
7186 Prepares all structures and code required to use AsmThunk16().\r
7187\r
7188 If ThunkContext is NULL, then ASSERT().\r
7189\r
7190 @param ThunkContext A pointer to the context structure that describes the\r
7191 16-bit real mode code to call.\r
7192\r
7193**/\r
7194VOID\r
7195EFIAPI\r
7196AsmPrepareThunk16 (\r
7197 OUT THUNK_CONTEXT *ThunkContext\r
7198 );\r
7199\r
7200\r
7201/**\r
7202 Transfers control to a 16-bit real mode entry point and returns the results.\r
7203\r
7204 Transfers control to a 16-bit real mode entry point and returns the results.\r
7205 AsmPrepareThunk16() must be called with ThunkContext before this function is\r
7206 used.\r
7207\r
7208 If ThunkContext is NULL, then ASSERT().\r
7209 If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().\r
7210\r
7211 @param ThunkContext A pointer to the context structure that describes the\r
7212 16-bit real mode code to call.\r
7213\r
7214**/\r
7215VOID\r
7216EFIAPI\r
7217AsmThunk16 (\r
7218 IN OUT THUNK_CONTEXT *ThunkContext\r
7219 );\r
7220\r
7221\r
7222/**\r
7223 Prepares all structures and code for a 16-bit real mode thunk, transfers\r
7224 control to a 16-bit real mode entry point, and returns the results.\r
7225\r
7226 Prepares all structures and code for a 16-bit real mode thunk, transfers\r
7227 control to a 16-bit real mode entry point, and returns the results. If the\r
7228 caller only need to perform a single 16-bit real mode thunk, then this\r
7229 service should be used. If the caller intends to make more than one 16-bit\r
7230 real mode thunk, then it is more efficient if AsmPrepareThunk16() is called\r
7231 once and AsmThunk16() can be called for each 16-bit real mode thunk.\r
7232\r
7233 If ThunkContext is NULL, then ASSERT().\r
7234\r
7235 @param ThunkContext A pointer to the context structure that describes the\r
7236 16-bit real mode code to call.\r
7237\r
7238**/\r
7239VOID\r
7240EFIAPI\r
7241AsmPrepareAndThunk16 (\r
7242 IN OUT THUNK_CONTEXT *ThunkContext\r
7243 );\r
7244\r
ac644614 7245#endif\r
e3a7917f 7246#endif\r
ac644614 7247\r
7248\r