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