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