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