]>
Commit | Line | Data |
---|---|---|
878ddf1f | 1 | /** @file\r |
2 | Memory-only library functions with no library constructor/destructor\r | |
3 | \r | |
4 | Copyright (c) 2006, Intel Corporation\r | |
5 | All rights reserved. This program and the accompanying materials\r | |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
13 | Module Name: BaseLib.h\r | |
14 | \r | |
15 | **/\r | |
16 | \r | |
17 | #ifndef __BASE_LIB__\r | |
18 | #define __BASE_LIB__\r | |
19 | \r | |
20 | //\r | |
21 | // Definitions for architecture specific types\r | |
22 | // These include SPIN_LOCK and BASE_LIBRARY_JUMP_BUFFER\r | |
23 | //\r | |
24 | \r | |
25 | //\r | |
26 | // SPIN_LOCK\r | |
27 | //\r | |
28 | typedef UINTN SPIN_LOCK;\r | |
29 | \r | |
30 | #if defined (MDE_CPU_IA32)\r | |
31 | //\r | |
32 | // IA32 context buffer used by SetJump() and LongJump()\r | |
33 | //\r | |
34 | typedef struct {\r | |
35 | UINT32 Ebx;\r | |
36 | UINT32 Esi;\r | |
37 | UINT32 Edi;\r | |
38 | UINT32 Ebp;\r | |
39 | UINT32 Esp;\r | |
40 | UINT32 Eip;\r | |
41 | } BASE_LIBRARY_JUMP_BUFFER;\r | |
42 | \r | |
43 | #elif defined (MDE_CPU_IPF)\r | |
44 | //\r | |
45 | // IPF context buffer used by SetJump() and LongJump()\r | |
46 | //\r | |
47 | typedef struct {\r | |
4cbd2175 | 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 | |
878ddf1f | 68 | UINT64 R4;\r |
69 | UINT64 R5;\r | |
70 | UINT64 R6;\r | |
71 | UINT64 R7;\r | |
72 | UINT64 SP;\r | |
878ddf1f | 73 | UINT64 BR0;\r |
74 | UINT64 BR1;\r | |
75 | UINT64 BR2;\r | |
76 | UINT64 BR3;\r | |
77 | UINT64 BR4;\r | |
78 | UINT64 BR5;\r | |
4cbd2175 | 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 | |
878ddf1f | 86 | } BASE_LIBRARY_JUMP_BUFFER;\r |
87 | \r | |
88 | #elif defined (MDE_CPU_X64)\r | |
89 | //\r | |
90 | // X64 context buffer used by SetJump() and LongJump()\r | |
91 | //\r | |
92 | typedef struct {\r | |
93 | UINT64 Rbx;\r | |
94 | UINT64 Rsp;\r | |
95 | UINT64 Rbp;\r | |
96 | UINT64 Rdi;\r | |
97 | UINT64 Rsi;\r | |
98 | UINT64 R12;\r | |
99 | UINT64 R13;\r | |
100 | UINT64 R14;\r | |
101 | UINT64 R15;\r | |
102 | UINT64 Rip;\r | |
103 | } BASE_LIBRARY_JUMP_BUFFER;\r | |
104 | \r | |
105 | #elif defined (MDE_CPU_EBC)\r | |
106 | //\r | |
107 | // EBC context buffer used by SetJump() and LongJump()\r | |
108 | //\r | |
109 | typedef struct {\r | |
110 | UINT64 R0;\r | |
111 | UINT64 R1;\r | |
112 | UINT64 R2;\r | |
113 | UINT64 R3;\r | |
114 | UINT64 IP;\r | |
115 | } BASE_LIBRARY_JUMP_BUFFER;\r | |
116 | \r | |
117 | #else\r | |
118 | #error Unknown Processor Type\r | |
119 | #endif\r | |
120 | \r | |
121 | //\r | |
122 | // String Services\r | |
123 | //\r | |
124 | \r | |
125 | /**\r | |
126 | Copies one Null-terminated Unicode string to another Null-terminated Unicode\r | |
127 | string and returns the new Unicode string.\r | |
128 | \r | |
129 | This function copies the contents of the Unicode string Source to the Unicode\r | |
130 | string Destination, and returns Destination. If Source and Destination\r | |
131 | overlap, then the results are undefined.\r | |
132 | \r | |
133 | If Destination is NULL, then ASSERT().\r | |
134 | If Source is NULL, then ASSERT().\r | |
135 | If Source and Destination overlap, then ASSERT().\r | |
136 | If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r | |
137 | PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r | |
138 | \r | |
139 | @param Destination Pointer to a Null-terminated Unicode string.\r | |
140 | @param Source Pointer to a Null-terminated Unicode string.\r | |
141 | \r | |
142 | @return Destiantion\r | |
143 | \r | |
144 | **/\r | |
145 | CHAR16 *\r | |
146 | EFIAPI\r | |
147 | StrCpy (\r | |
148 | OUT CHAR16 *Destination,\r | |
149 | IN CONST CHAR16 *Source\r | |
150 | );\r | |
151 | \r | |
152 | /**\r | |
153 | Copies one Null-terminated Unicode string with a maximum length to another\r | |
154 | Null-terminated Unicode string with a maximum length and returns the new\r | |
155 | Unicode string.\r | |
156 | \r | |
157 | This function copies the contents of the Unicode string Source to the Unicode\r | |
158 | string Destination, and returns Destination. At most, Length Unicode\r | |
159 | characters are copied from Source to Destination. If Length is 0, then\r | |
160 | Destination is returned unmodified. If Length is greater that the number of\r | |
161 | Unicode characters in Source, then Destination is padded with Null Unicode\r | |
162 | characters. If Source and Destination overlap, then the results are\r | |
163 | undefined.\r | |
164 | \r | |
165 | If Destination is NULL, then ASSERT().\r | |
166 | If Source is NULL, then ASSERT().\r | |
167 | If Source and Destination overlap, then ASSERT().\r | |
168 | If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r | |
169 | PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r | |
170 | \r | |
171 | @param Destination Pointer to a Null-terminated Unicode string.\r | |
172 | @param Source Pointer to a Null-terminated Unicode string.\r | |
173 | @param Length Maximum number of Unicode characters to copy.\r | |
174 | \r | |
175 | @return Destination\r | |
176 | \r | |
177 | **/\r | |
178 | CHAR16 *\r | |
179 | EFIAPI\r | |
180 | StrnCpy (\r | |
181 | OUT CHAR16 *Destination,\r | |
182 | IN CONST CHAR16 *Source,\r | |
183 | IN UINTN Length\r | |
184 | );\r | |
185 | \r | |
186 | /**\r | |
187 | Returns the length of a Null-terminated Unicode string.\r | |
188 | \r | |
189 | This function returns the number of Unicode characters in the Null-terminated\r | |
190 | Unicode string specified by String.\r | |
191 | \r | |
192 | If String is NULL, then ASSERT().\r | |
193 | If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r | |
194 | PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r | |
195 | \r | |
196 | @param String Pointer to a Null-terminated Unicode string.\r | |
197 | \r | |
198 | @return The length of String.\r | |
199 | \r | |
200 | **/\r | |
201 | UINTN\r | |
202 | EFIAPI\r | |
203 | StrLen (\r | |
204 | IN CONST CHAR16 *String\r | |
205 | );\r | |
206 | \r | |
207 | /**\r | |
208 | Returns the size of a Null-terminated Unicode string in bytes, including the\r | |
209 | Null terminator.\r | |
210 | \r | |
211 | This function returns the size, in bytes, of the Null-terminated Unicode\r | |
212 | string specified by String.\r | |
213 | \r | |
214 | If String is NULL, then ASSERT().\r | |
215 | If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r | |
216 | PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r | |
217 | \r | |
218 | @param String Pointer to a Null-terminated Unicode string.\r | |
219 | \r | |
220 | @return The size of String.\r | |
221 | \r | |
222 | **/\r | |
223 | UINTN\r | |
224 | EFIAPI\r | |
225 | StrSize (\r | |
226 | IN CONST CHAR16 *String\r | |
227 | );\r | |
228 | \r | |
229 | /**\r | |
230 | Compares two Null-terminated Unicode strings, and returns the difference\r | |
231 | between the first mismatched Unicode characters.\r | |
232 | \r | |
233 | This function compares the Null-terminated Unicode string FirstString to the\r | |
234 | Null-terminated Unicode string SecondString. If FirstString is identical to\r | |
235 | SecondString, then 0 is returned. Otherwise, the value returned is the first\r | |
236 | mismatched Unicode character in SecondString subtracted from the first\r | |
237 | mismatched Unicode character in FirstString.\r | |
238 | \r | |
239 | If FirstString is NULL, then ASSERT().\r | |
240 | If SecondString is NULL, then ASSERT().\r | |
241 | If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more\r | |
242 | than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r | |
243 | If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more\r | |
244 | than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r | |
245 | \r | |
246 | @param FirstString Pointer to a Null-terminated Unicode string.\r | |
247 | @param SecondString Pointer to a Null-terminated Unicode string.\r | |
248 | \r | |
249 | @retval 0 FirstString is identical to SecondString.\r | |
250 | @retval !=0 FirstString is not identical to SecondString.\r | |
251 | \r | |
252 | **/\r | |
253 | INTN\r | |
254 | EFIAPI\r | |
255 | StrCmp (\r | |
256 | IN CONST CHAR16 *FirstString,\r | |
257 | IN CONST CHAR16 *SecondString\r | |
258 | );\r | |
259 | \r | |
260 | /**\r | |
261 | Compares two Null-terminated Unicode strings with maximum lengths, and\r | |
262 | returns the difference between the first mismatched Unicode characters.\r | |
263 | \r | |
264 | This function compares the Null-terminated Unicode string FirstString to the\r | |
265 | Null-terminated Unicode string SecondString. At most, Length Unicode\r | |
266 | characters will be compared. If Length is 0, then 0 is returned. If\r | |
267 | FirstString is identical to SecondString, then 0 is returned. Otherwise, the\r | |
268 | value returned is the first mismatched Unicode character in SecondString\r | |
269 | subtracted from the first mismatched Unicode character in FirstString.\r | |
270 | \r | |
271 | If FirstString is NULL, then ASSERT().\r | |
272 | If SecondString is NULL, then ASSERT().\r | |
273 | If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more\r | |
274 | than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r | |
275 | If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more\r | |
276 | than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r | |
277 | \r | |
278 | @param FirstString Pointer to a Null-terminated Unicode string.\r | |
279 | @param SecondString Pointer to a Null-terminated Unicode string.\r | |
280 | @param Length Maximum number of Unicode characters to compare.\r | |
281 | \r | |
282 | @retval 0 FirstString is identical to SecondString.\r | |
283 | @retval !=0 FirstString is not identical to SecondString.\r | |
284 | \r | |
285 | **/\r | |
286 | INTN\r | |
287 | EFIAPI\r | |
288 | StrnCmp (\r | |
289 | IN CONST CHAR16 *FirstString,\r | |
290 | IN CONST CHAR16 *SecondString,\r | |
291 | IN UINTN Length\r | |
292 | );\r | |
293 | \r | |
294 | /**\r | |
295 | Concatenates one Null-terminated Unicode string to another Null-terminated\r | |
296 | Unicode string, and returns the concatenated Unicode string.\r | |
297 | \r | |
298 | This function concatenates two Null-terminated Unicode strings. The contents\r | |
299 | of Null-terminated Unicode string Source are concatenated to the end of\r | |
300 | Null-terminated Unicode string Destination. The Null-terminated concatenated\r | |
301 | Unicode String is returned. If Source and Destination overlap, then the\r | |
302 | results are undefined.\r | |
303 | \r | |
304 | If Destination is NULL, then ASSERT().\r | |
305 | If Source is NULL, then ASSERT().\r | |
306 | If Source and Destination overlap, then ASSERT().\r | |
307 | If PcdMaximumUnicodeStringLength is not zero, and Destination contains more\r | |
308 | than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r | |
309 | If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r | |
310 | PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r | |
311 | If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination\r | |
312 | and Source results in a Unicode string with more than\r | |
313 | PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r | |
314 | \r | |
315 | @param Destination Pointer to a Null-terminated Unicode string.\r | |
316 | @param Source Pointer to a Null-terminated Unicode string.\r | |
317 | \r | |
318 | @return Destination\r | |
319 | \r | |
320 | **/\r | |
321 | CHAR16 *\r | |
322 | EFIAPI\r | |
323 | StrCat (\r | |
324 | IN OUT CHAR16 *Destination,\r | |
325 | IN CONST CHAR16 *Source\r | |
326 | );\r | |
327 | \r | |
328 | /**\r | |
329 | Concatenates one Null-terminated Unicode string with a maximum length to the\r | |
330 | end of another Null-terminated Unicode string, and returns the concatenated\r | |
331 | Unicode string.\r | |
332 | \r | |
333 | This function concatenates two Null-terminated Unicode strings. The contents\r | |
334 | of Null-terminated Unicode string Source are concatenated to the end of\r | |
335 | Null-terminated Unicode string Destination, and Destination is returned. At\r | |
336 | most, Length Unicode characters are concatenated from Source to the end of\r | |
337 | Destination, and Destination is always Null-terminated. If Length is 0, then\r | |
338 | Destination is returned unmodified. If Source and Destination overlap, then\r | |
339 | the results are undefined.\r | |
340 | \r | |
341 | If Destination is NULL, then ASSERT().\r | |
342 | If Source is NULL, then ASSERT().\r | |
343 | If Source and Destination overlap, then ASSERT().\r | |
344 | If PcdMaximumUnicodeStringLength is not zero, and Destination contains more\r | |
345 | than PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r | |
346 | If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r | |
347 | PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r | |
348 | If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination\r | |
349 | and Source results in a Unicode string with more than\r | |
350 | PcdMaximumUnicodeStringLength Unicode characters, then ASSERT().\r | |
351 | \r | |
352 | @param Destination Pointer to a Null-terminated Unicode string.\r | |
353 | @param Source Pointer to a Null-terminated Unicode string.\r | |
354 | @param Length Maximum number of Unicode characters to concatenate from\r | |
355 | Source.\r | |
356 | \r | |
357 | @return Destination\r | |
358 | \r | |
359 | **/\r | |
360 | CHAR16 *\r | |
361 | EFIAPI\r | |
362 | StrnCat (\r | |
363 | IN OUT CHAR16 *Destination,\r | |
364 | IN CONST CHAR16 *Source,\r | |
365 | IN UINTN Length\r | |
366 | );\r | |
367 | \r | |
368 | /**\r | |
369 | Copies one Null-terminated ASCII string to another Null-terminated ASCII\r | |
370 | string and returns the new ASCII string.\r | |
371 | \r | |
372 | This function copies the contents of the ASCII string Source to the ASCII\r | |
373 | string Destination, and returns Destination. If Source and Destination\r | |
374 | overlap, then the results are undefined.\r | |
375 | \r | |
376 | If Destination is NULL, then ASSERT().\r | |
377 | If Source is NULL, then ASSERT().\r | |
378 | If Source and Destination overlap, then ASSERT().\r | |
379 | If PcdMaximumAsciiStringLength is not zero and Source contains more than\r | |
380 | PcdMaximumAsciiStringLength ASCII characters, then ASSERT().\r | |
381 | \r | |
382 | @param Destination Pointer to a Null-terminated ASCII string.\r | |
383 | @param Source Pointer to a Null-terminated ASCII string.\r | |
384 | \r | |
385 | @return Destination\r | |
386 | \r | |
387 | **/\r | |
388 | CHAR8 *\r | |
389 | EFIAPI\r | |
390 | AsciiStrCpy (\r | |
391 | OUT CHAR8 *Destination,\r | |
392 | IN CONST CHAR8 *Source\r | |
393 | );\r | |
394 | \r | |
395 | /**\r | |
396 | Copies one Null-terminated ASCII string with a maximum length to another\r | |
397 | Null-terminated ASCII string with a maximum length and returns the new ASCII\r | |
398 | string.\r | |
399 | \r | |
400 | This function copies the contents of the ASCII string Source to the ASCII\r | |
401 | string Destination, and returns Destination. At most, Length ASCII characters\r | |
402 | are copied from Source to Destination. If Length is 0, then Destination is\r | |
403 | returned unmodified. If Length is greater that the number of ASCII characters\r | |
404 | in Source, then Destination is padded with Null ASCII characters. If Source\r | |
405 | and Destination overlap, then the results are undefined.\r | |
406 | \r | |
407 | If Destination is NULL, then ASSERT().\r | |
408 | If Source is NULL, then ASSERT().\r | |
409 | If Source and Destination overlap, then ASSERT().\r | |
410 | If PcdMaximumAsciiStringLength is not zero, and Source contains more than\r | |
411 | PcdMaximumAsciiStringLength ASCII characters, then ASSERT().\r | |
412 | \r | |
413 | @param Destination Pointer to a Null-terminated ASCII string.\r | |
414 | @param Source Pointer to a Null-terminated ASCII string.\r | |
415 | @param Length Maximum number of ASCII characters to copy.\r | |
416 | \r | |
417 | @return Destination\r | |
418 | \r | |
419 | **/\r | |
420 | CHAR8 *\r | |
421 | EFIAPI\r | |
422 | AsciiStrnCpy (\r | |
423 | OUT CHAR8 *Destination,\r | |
424 | IN CONST CHAR8 *Source,\r | |
425 | IN UINTN Length\r | |
426 | );\r | |
427 | \r | |
428 | /**\r | |
429 | Returns the length of a Null-terminated ASCII string.\r | |
430 | \r | |
431 | This function returns the number of ASCII characters in the Null-terminated\r | |
432 | ASCII string specified by String.\r | |
433 | \r | |
434 | If String is NULL, then ASSERT().\r | |
435 | If PcdMaximumAsciiStringLength is not zero and String contains more than\r | |
436 | PcdMaximumAsciiStringLength ASCII characters, then ASSERT().\r | |
437 | \r | |
438 | @param String Pointer to a Null-terminated ASCII string.\r | |
439 | \r | |
440 | @return The length of String.\r | |
441 | \r | |
442 | **/\r | |
443 | UINTN\r | |
444 | EFIAPI\r | |
445 | AsciiStrLen (\r | |
446 | IN CONST CHAR8 *String\r | |
447 | );\r | |
448 | \r | |
449 | /**\r | |
450 | Returns the size of a Null-terminated ASCII string in bytes, including the\r | |
451 | Null terminator.\r | |
452 | \r | |
453 | This function returns the size, in bytes, of the Null-terminated ASCII string\r | |
454 | specified by String.\r | |
455 | \r | |
456 | If String is NULL, then ASSERT().\r | |
457 | If PcdMaximumAsciiStringLength is not zero and String contains more than\r | |
458 | PcdMaximumAsciiStringLength ASCII characters, then ASSERT().\r | |
459 | \r | |
460 | @param String Pointer to a Null-terminated ASCII string.\r | |
461 | \r | |
462 | @return The size of String.\r | |
463 | \r | |
464 | **/\r | |
465 | UINTN\r | |
466 | EFIAPI\r | |
467 | AsciiStrSize (\r | |
468 | IN CONST CHAR8 *String\r | |
469 | );\r | |
470 | \r | |
471 | /**\r | |
472 | Compares two Null-terminated ASCII strings, and returns the difference\r | |
473 | between the first mismatched ASCII characters.\r | |
474 | \r | |
475 | This function compares the Null-terminated ASCII string FirstString to the\r | |
476 | Null-terminated ASCII string SecondString. If FirstString is identical to\r | |
477 | SecondString, then 0 is returned. Otherwise, the value returned is the first\r | |
478 | mismatched ASCII character in SecondString subtracted from the first\r | |
479 | mismatched ASCII character in FirstString.\r | |
480 | \r | |
481 | If FirstString is NULL, then ASSERT().\r | |
482 | If SecondString is NULL, then ASSERT().\r | |
483 | If PcdMaximumAsciiStringLength is not zero and FirstString contains more than\r | |
484 | PcdMaximumAsciiStringLength ASCII characters, then ASSERT().\r | |
485 | If PcdMaximumAsciiStringLength is not zero and SecondString contains more\r | |
486 | than PcdMaximumAsciiStringLength ASCII characters, then ASSERT().\r | |
487 | \r | |
488 | @param FirstString Pointer to a Null-terminated ASCII string.\r | |
489 | @param SecondString Pointer to a Null-terminated ASCII string.\r | |
490 | \r | |
491 | @retval 0 FirstString is identical to SecondString.\r | |
492 | @retval !=0 FirstString is not identical to SecondString.\r | |
493 | \r | |
494 | **/\r | |
495 | INTN\r | |
496 | EFIAPI\r | |
497 | AsciiStrCmp (\r | |
498 | IN CONST CHAR8 *FirstString,\r | |
499 | IN CONST CHAR8 *SecondString\r | |
500 | );\r | |
501 | \r | |
502 | /**\r | |
503 | Performs a case insensitive comparison of two Null-terminated ASCII strings,\r | |
504 | and returns the difference between the first mismatched ASCII characters.\r | |
505 | \r | |
506 | This function performs a case insensitive comparison of the Null-terminated\r | |
507 | ASCII string FirstString to the Null-terminated ASCII string SecondString. If\r | |
508 | FirstString is identical to SecondString, then 0 is returned. Otherwise, the\r | |
509 | value returned is the first mismatched lower case ASCII character in\r | |
510 | SecondString subtracted from the first mismatched lower case ASCII character\r | |
511 | in FirstString.\r | |
512 | \r | |
513 | If FirstString is NULL, then ASSERT().\r | |
514 | If SecondString is NULL, then ASSERT().\r | |
515 | If PcdMaximumAsciiStringLength is not zero and FirstString contains more than\r | |
516 | PcdMaximumAsciiStringLength ASCII characters, then ASSERT().\r | |
517 | If PcdMaximumAsciiStringLength is not zero and SecondString contains more\r | |
518 | than PcdMaximumAsciiStringLength ASCII characters, then ASSERT().\r | |
519 | \r | |
520 | @param FirstString Pointer to a Null-terminated ASCII string.\r | |
521 | @param SecondString Pointer to a Null-terminated ASCII string.\r | |
522 | \r | |
523 | @retval 0 FirstString is identical to SecondString using case insensitive\r | |
524 | comparisons.\r | |
525 | @retval !=0 FirstString is not identical to SecondString using case\r | |
526 | insensitive comparisons.\r | |
527 | \r | |
528 | **/\r | |
529 | INTN\r | |
530 | EFIAPI\r | |
531 | AsciiStriCmp (\r | |
532 | IN CONST CHAR8 *FirstString,\r | |
533 | IN CONST CHAR8 *SecondString\r | |
534 | );\r | |
535 | \r | |
536 | /**\r | |
537 | Compares two Null-terminated ASCII strings with maximum lengths, and returns\r | |
538 | the difference between the first mismatched ASCII characters.\r | |
539 | \r | |
540 | This function compares the Null-terminated ASCII string FirstString to the\r | |
541 | Null-terminated ASCII string SecondString. At most, Length ASCII characters\r | |
542 | will be compared. If Length is 0, then 0 is returned. If FirstString is\r | |
543 | identical to SecondString, then 0 is returned. Otherwise, the value returned\r | |
544 | is the first mismatched ASCII character in SecondString subtracted from the\r | |
545 | first mismatched ASCII character in FirstString.\r | |
546 | \r | |
547 | If FirstString is NULL, then ASSERT().\r | |
548 | If SecondString is NULL, then ASSERT().\r | |
549 | If PcdMaximumAsciiStringLength is not zero and FirstString contains more than\r | |
550 | PcdMaximumAsciiStringLength ASCII characters, then ASSERT().\r | |
551 | If PcdMaximumAsciiStringLength is not zero and SecondString contains more\r | |
552 | than PcdMaximumAsciiStringLength ASCII characters, then ASSERT().\r | |
553 | \r | |
554 | @param FirstString Pointer to a Null-terminated ASCII string.\r | |
555 | @param SecondString Pointer to a Null-terminated ASCII string.\r | |
556 | \r | |
557 | @retval 0 FirstString is identical to SecondString.\r | |
558 | @retval !=0 FirstString is not identical to SecondString.\r | |
559 | \r | |
560 | **/\r | |
561 | INTN\r | |
562 | EFIAPI\r | |
563 | AsciiStrnCmp (\r | |
564 | IN CONST CHAR8 *FirstString,\r | |
565 | IN CONST CHAR8 *SecondString,\r | |
566 | IN UINTN Length\r | |
567 | );\r | |
568 | \r | |
569 | /**\r | |
570 | Concatenates one Null-terminated ASCII string to another Null-terminated\r | |
571 | ASCII string, and returns the concatenated ASCII string.\r | |
572 | \r | |
573 | This function concatenates two Null-terminated ASCII strings. The contents of\r | |
574 | Null-terminated ASCII string Source are concatenated to the end of Null-\r | |
575 | terminated ASCII string Destination. The Null-terminated concatenated ASCII\r | |
576 | String is returned.\r | |
577 | \r | |
578 | If Destination is NULL, then ASSERT().\r | |
579 | If Source is NULL, then ASSERT().\r | |
580 | If PcdMaximumAsciiStringLength is not zero and Destination contains more than\r | |
581 | PcdMaximumAsciiStringLength ASCII characters, then ASSERT().\r | |
582 | If PcdMaximumAsciiStringLength is not zero and Source contains more than\r | |
583 | PcdMaximumAsciiStringLength ASCII characters, then ASSERT().\r | |
584 | If PcdMaximumAsciiStringLength is not zero and concatenating Destination and\r | |
585 | Source results in a ASCII string with more than PcdMaximumAsciiStringLength\r | |
586 | ASCII characters, then ASSERT().\r | |
587 | \r | |
588 | @param Destination Pointer to a Null-terminated ASCII string.\r | |
589 | @param Source Pointer to a Null-terminated ASCII string.\r | |
590 | \r | |
591 | @return Destination\r | |
592 | \r | |
593 | **/\r | |
594 | CHAR8 *\r | |
595 | EFIAPI\r | |
596 | AsciiStrCat (\r | |
597 | IN OUT CHAR8 *Destination,\r | |
598 | IN CONST CHAR8 *Source\r | |
599 | );\r | |
600 | \r | |
601 | /**\r | |
602 | Concatenates one Null-terminated ASCII string with a maximum length to the\r | |
603 | end of another Null-terminated ASCII string, and returns the concatenated\r | |
604 | ASCII string.\r | |
605 | \r | |
606 | This function concatenates two Null-terminated ASCII strings. The contents\r | |
607 | of Null-terminated ASCII string Source are concatenated to the end of Null-\r | |
608 | terminated ASCII string Destination, and Destination is returned. At most,\r | |
609 | Length ASCII characters are concatenated from Source to the end of\r | |
610 | Destination, and Destination is always Null-terminated. If Length is 0, then\r | |
611 | Destination is returned unmodified. If Source and Destination overlap, then\r | |
612 | the results are undefined.\r | |
613 | \r | |
614 | If Destination is NULL, then ASSERT().\r | |
615 | If Source is NULL, then ASSERT().\r | |
616 | If Source and Destination overlap, then ASSERT().\r | |
617 | If PcdMaximumAsciiStringLength is not zero, and Destination contains more\r | |
618 | than PcdMaximumAsciiStringLength ASCII characters, then ASSERT().\r | |
619 | If PcdMaximumAsciiStringLength is not zero, and Source contains more than\r | |
620 | PcdMaximumAsciiStringLength ASCII characters, then ASSERT().\r | |
621 | If PcdMaximumAsciiStringLength is not zero, and concatenating Destination and\r | |
622 | Source results in a ASCII string with more than PcdMaximumAsciiStringLength\r | |
623 | ASCII characters, then ASSERT().\r | |
624 | \r | |
625 | @param Destination Pointer to a Null-terminated ASCII string.\r | |
626 | @param Source Pointer to a Null-terminated ASCII string.\r | |
627 | @param Length Maximum number of ASCII characters to concatenate from\r | |
628 | Source.\r | |
629 | \r | |
630 | @return Destination\r | |
631 | \r | |
632 | **/\r | |
633 | CHAR8 *\r | |
634 | EFIAPI\r | |
635 | AsciiStrnCat (\r | |
636 | IN OUT CHAR8 *Destination,\r | |
637 | IN CONST CHAR8 *Source,\r | |
638 | IN UINTN Length\r | |
639 | );\r | |
640 | \r | |
dee4740a | 641 | /**\r |
642 | Converts an 8-bit value to an 8-bit BCD value.\r | |
643 | \r | |
644 | Converts the 8-bit value specified by Value to BCD. The BCD value is\r | |
645 | returned.\r | |
646 | \r | |
647 | If Value >= 100, then ASSERT().\r | |
648 | \r | |
649 | @param Value The 8-bit value to convert to BCD. Range 0..99.\r | |
650 | \r | |
651 | @return The BCD value\r | |
652 | \r | |
653 | **/\r | |
654 | UINT8\r | |
655 | EFIAPI\r | |
656 | DecimalToBcd8 (\r | |
657 | IN UINT8 Value\r | |
658 | );\r | |
659 | \r | |
660 | /**\r | |
661 | Converts an 8-bit BCD value to an 8-bit value.\r | |
662 | \r | |
663 | Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit\r | |
664 | value is returned.\r | |
665 | \r | |
666 | If Value >= 0xA0, then ASSERT().\r | |
667 | If (Value & 0x0F) >= 0x0A, then ASSERT().\r | |
668 | \r | |
669 | @param Value The 8-bit BCD value to convert to an 8-bit value.\r | |
670 | \r | |
671 | @return The 8-bit value is returned.\r | |
672 | \r | |
673 | **/\r | |
674 | UINT8\r | |
675 | EFIAPI\r | |
676 | BcdToDecimal8 (\r | |
677 | IN UINT8 Value\r | |
678 | );\r | |
679 | \r | |
878ddf1f | 680 | //\r |
681 | // LIST_ENTRY definition\r | |
682 | //\r | |
683 | typedef struct _LIST_ENTRY LIST_ENTRY;\r | |
684 | \r | |
685 | struct _LIST_ENTRY {\r | |
686 | LIST_ENTRY *ForwardLink;\r | |
687 | LIST_ENTRY *BackLink;\r | |
688 | };\r | |
689 | \r | |
690 | //\r | |
691 | // Linked List Functions and Macros\r | |
692 | //\r | |
693 | \r | |
694 | /**\r | |
695 | Initializes the head node of a doubly linked list that is declared as a\r | |
696 | global variable in a module.\r | |
697 | \r | |
698 | Initializes the forward and backward links of a new linked list. After\r | |
699 | initializing a linked list with this macro, the other linked list functions\r | |
700 | may be used to add and remove nodes from the linked list. This macro results\r | |
701 | in smaller executables by initializing the linked list in the data section,\r | |
702 | instead if calling the InitializeListHead() function to perform the\r | |
703 | equivalent operation.\r | |
704 | \r | |
705 | @param ListHead The head note of a list to initiailize.\r | |
706 | \r | |
707 | **/\r | |
708 | #define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&ListHead, &ListHead}\r | |
709 | \r | |
710 | /**\r | |
711 | Initializes the head node of a doubly linked list, and returns the pointer to\r | |
712 | the head node of the doubly linked list.\r | |
713 | \r | |
714 | Initializes the forward and backward links of a new linked list. After\r | |
715 | initializing a linked list with this function, the other linked list\r | |
716 | functions may be used to add and remove nodes from the linked list. It is up\r | |
717 | to the caller of this function to allocate the memory for ListHead.\r | |
718 | \r | |
719 | If ListHead is NULL, then ASSERT().\r | |
720 | \r | |
721 | @param ListHead A pointer to the head node of a new doubly linked list.\r | |
722 | \r | |
723 | @return ListHead\r | |
724 | \r | |
725 | **/\r | |
726 | LIST_ENTRY *\r | |
727 | EFIAPI\r | |
728 | InitializeListHead (\r | |
729 | IN LIST_ENTRY *ListHead\r | |
730 | );\r | |
731 | \r | |
732 | /**\r | |
733 | Adds a node to the beginning of a doubly linked list, and returns the pointer\r | |
734 | to the head node of the doubly linked list.\r | |
735 | \r | |
736 | Adds the node Entry at the beginning of the doubly linked list denoted by\r | |
737 | ListHead, and returns ListHead.\r | |
738 | \r | |
739 | If ListHead is NULL, then ASSERT().\r | |
740 | If Entry is NULL, then ASSERT().\r | |
741 | If ListHead was not initialized with InitializeListHead(), then ASSERT().\r | |
742 | If PcdMaximumLinkedListLenth is not zero, and ListHead contains more than\r | |
743 | PcdMaximumLinkedListLenth nodes, then ASSERT().\r | |
744 | \r | |
745 | @param ListHead A pointer to the head node of a doubly linked list.\r | |
746 | @param Entry A pointer to a node that is to be inserted at the beginning\r | |
747 | of a doubly linked list.\r | |
748 | \r | |
749 | @return ListHead\r | |
750 | \r | |
751 | **/\r | |
752 | LIST_ENTRY *\r | |
753 | EFIAPI\r | |
754 | InsertHeadList (\r | |
755 | IN LIST_ENTRY *ListHead,\r | |
756 | IN LIST_ENTRY *Entry\r | |
757 | );\r | |
758 | \r | |
759 | /**\r | |
760 | Adds a node to the end of a doubly linked list, and returns the pointer to\r | |
761 | the head node of the doubly linked list.\r | |
762 | \r | |
763 | Adds the node Entry to the end of the doubly linked list denoted by ListHead,\r | |
764 | and returns ListHead.\r | |
765 | \r | |
766 | If ListHead is NULL, then ASSERT().\r | |
767 | If Entry is NULL, then ASSERT().\r | |
768 | If ListHead was not initialized with InitializeListHead(), then ASSERT().\r | |
769 | If PcdMaximumLinkedListLenth is not zero, and ListHead contains more than\r | |
770 | PcdMaximumLinkedListLenth nodes, then ASSERT().\r | |
771 | \r | |
772 | @param ListHead A pointer to the head node of a doubly linked list.\r | |
773 | @param Entry A pointer to a node that is to be added at the end of the\r | |
774 | doubly linked list.\r | |
775 | \r | |
776 | @return ListHead\r | |
777 | \r | |
778 | **/\r | |
779 | LIST_ENTRY *\r | |
780 | EFIAPI\r | |
781 | InsertTailList (\r | |
782 | IN LIST_ENTRY *ListHead,\r | |
783 | IN LIST_ENTRY *Entry\r | |
784 | );\r | |
785 | \r | |
786 | /**\r | |
787 | Retrieves the first node of a doubly linked list.\r | |
788 | \r | |
789 | Returns the first node of a doubly linked list. List must have been\r | |
790 | initialized with InitializeListHead(). If List is empty, then NULL is\r | |
791 | returned.\r | |
792 | \r | |
793 | If List is NULL, then ASSERT().\r | |
794 | If List was not initialized with InitializeListHead(), then ASSERT().\r | |
795 | If PcdMaximumLinkedListLenth is not zero, and List contains more than\r | |
796 | PcdMaximumLinkedListLenth nodes, then ASSERT().\r | |
797 | \r | |
798 | @param List A pointer to the head node of a doubly linked list.\r | |
799 | \r | |
800 | @return The first node of a doubly linked list.\r | |
801 | @retval NULL The list is empty.\r | |
802 | \r | |
803 | **/\r | |
804 | LIST_ENTRY *\r | |
805 | EFIAPI\r | |
806 | GetFirstNode (\r | |
807 | IN CONST LIST_ENTRY *List\r | |
808 | );\r | |
809 | \r | |
810 | /**\r | |
811 | Retrieves the next node of a doubly linked list.\r | |
812 | \r | |
813 | Returns the node of a doubly linked list that follows Node. List must have\r | |
814 | been initialized with InitializeListHead(). If List is empty, then List is\r | |
815 | returned.\r | |
816 | \r | |
817 | If List is NULL, then ASSERT().\r | |
818 | If Node is NULL, then ASSERT().\r | |
819 | If List was not initialized with InitializeListHead(), then ASSERT().\r | |
820 | If PcdMaximumLinkedListLenth is not zero, and List contains more than\r | |
821 | PcdMaximumLinkedListLenth nodes, then ASSERT().\r | |
822 | If Node is not a node in List, then ASSERT().\r | |
823 | \r | |
824 | @param List A pointer to the head node of a doubly linked list.\r | |
825 | @param Node A pointer to a node in the doubly linked list.\r | |
826 | \r | |
827 | @return Pointer to the next node if one exists. Otherwise a null value which\r | |
828 | is actually List is returned.\r | |
829 | \r | |
830 | **/\r | |
831 | LIST_ENTRY *\r | |
832 | EFIAPI\r | |
833 | GetNextNode (\r | |
834 | IN CONST LIST_ENTRY *List,\r | |
835 | IN CONST LIST_ENTRY *Node\r | |
836 | );\r | |
837 | \r | |
838 | /**\r | |
839 | Checks to see if a doubly linked list is empty or not.\r | |
840 | \r | |
841 | Checks to see if the doubly linked list is empty. If the linked list contains\r | |
842 | zero nodes, this function returns TRUE. Otherwise, it returns FALSE.\r | |
843 | \r | |
844 | If ListHead is NULL, then ASSERT().\r | |
845 | If ListHead was not initialized with InitializeListHead(), then ASSERT().\r | |
846 | If PcdMaximumLinkedListLenth is not zero, and List contains more than\r | |
847 | PcdMaximumLinkedListLenth nodes, then ASSERT().\r | |
848 | \r | |
849 | @param ListHead A pointer to the head node of a doubly linked list.\r | |
850 | \r | |
851 | @retval TRUE The linked list is empty.\r | |
852 | @retval FALSE The linked list is not empty.\r | |
853 | \r | |
854 | **/\r | |
855 | BOOLEAN\r | |
856 | EFIAPI\r | |
857 | IsListEmpty (\r | |
858 | IN CONST LIST_ENTRY *ListHead\r | |
859 | );\r | |
860 | \r | |
861 | /**\r | |
862 | Determines if a node in a doubly linked list is null.\r | |
863 | \r | |
864 | Returns FALSE if Node is one of the nodes in the doubly linked list specified\r | |
865 | by List. Otherwise, TRUE is returned. List must have been initialized with\r | |
866 | InitializeListHead().\r | |
867 | \r | |
868 | If List is NULL, then ASSERT().\r | |
869 | If Node is NULL, then ASSERT().\r | |
870 | If List was not initialized with InitializeListHead(), then ASSERT().\r | |
871 | If PcdMaximumLinkedListLenth is not zero, and List contains more than\r | |
872 | PcdMaximumLinkedListLenth nodes, then ASSERT().\r | |
873 | If Node is not a node in List and Node is not equal to List, then ASSERT().\r | |
874 | \r | |
875 | @param List A pointer to the head node of a doubly linked list.\r | |
876 | @param Node A pointer to a node in the doubly linked list.\r | |
877 | \r | |
878 | @retval TRUE Node is one of the nodes in the doubly linked list.\r | |
879 | @retval FALSE Node is not one of the nodes in the doubly linked list.\r | |
880 | \r | |
881 | **/\r | |
882 | BOOLEAN\r | |
883 | EFIAPI\r | |
884 | IsNull (\r | |
885 | IN CONST LIST_ENTRY *List,\r | |
886 | IN CONST LIST_ENTRY *Node\r | |
887 | );\r | |
888 | \r | |
889 | /**\r | |
890 | Determines if a node the last node in a doubly linked list.\r | |
891 | \r | |
892 | Returns TRUE if Node is the last node in the doubly linked list specified by\r | |
893 | List. Otherwise, FALSE is returned. List must have been initialized with\r | |
894 | InitializeListHead().\r | |
895 | \r | |
896 | If List is NULL, then ASSERT().\r | |
897 | If Node is NULL, then ASSERT().\r | |
898 | If List was not initialized with InitializeListHead(), then ASSERT().\r | |
899 | If PcdMaximumLinkedListLenth is not zero, and List contains more than\r | |
900 | PcdMaximumLinkedListLenth nodes, then ASSERT().\r | |
901 | If Node is not a node in List, then ASSERT().\r | |
902 | \r | |
903 | @param List A pointer to the head node of a doubly linked list.\r | |
904 | @param Node A pointer to a node in the doubly linked list.\r | |
905 | \r | |
906 | @retval TRUE Node is the last node in the linked list.\r | |
907 | @retval FALSE Node is not the last node in the linked list.\r | |
908 | \r | |
909 | **/\r | |
910 | BOOLEAN\r | |
911 | EFIAPI\r | |
912 | IsNodeAtEnd (\r | |
913 | IN CONST LIST_ENTRY *List,\r | |
914 | IN CONST LIST_ENTRY *Node\r | |
915 | );\r | |
916 | \r | |
917 | /**\r | |
918 | Swaps the location of two nodes in a doubly linked list, and returns the\r | |
919 | first node after the swap.\r | |
920 | \r | |
921 | If FirstEntry is identical to SecondEntry, then SecondEntry is returned.\r | |
922 | Otherwise, the location of the FirstEntry node is swapped with the location\r | |
923 | of the SecondEntry node in a doubly linked list. SecondEntry must be in the\r | |
924 | same double linked list as FirstEntry and that double linked list must have\r | |
925 | been initialized with InitializeListHead(). SecondEntry is returned after the\r | |
926 | nodes are swapped.\r | |
927 | \r | |
928 | If FirstEntry is NULL, then ASSERT().\r | |
929 | If SecondEntry is NULL, then ASSERT().\r | |
930 | If SecondEntry and FirstEntry are not in the same linked list, then ASSERT().\r | |
931 | If PcdMaximumLinkedListLenth is not zero, and the linked list containing\r | |
932 | FirstEntry and SecondEntry contains more than PcdMaximumLinkedListLenth\r | |
933 | nodes, then ASSERT().\r | |
934 | \r | |
935 | @param FirstEntry A pointer to a node in a linked list.\r | |
936 | @param SecondEntry A pointer to another node in the same linked list.\r | |
937 | \r | |
938 | **/\r | |
939 | LIST_ENTRY *\r | |
940 | EFIAPI\r | |
941 | SwapListEntries (\r | |
942 | IN LIST_ENTRY *FirstEntry,\r | |
943 | IN LIST_ENTRY *SecondEntry\r | |
944 | );\r | |
945 | \r | |
946 | /**\r | |
947 | Removes a node from a doubly linked list, and returns the node that follows\r | |
948 | the removed node.\r | |
949 | \r | |
950 | Removes the node Entry from a doubly linked list. It is up to the caller of\r | |
951 | this function to release the memory used by this node if that is required. On\r | |
952 | exit, the node following Entry in the doubly linked list is returned. If\r | |
953 | Entry is the only node in the linked list, then the head node of the linked\r | |
954 | list is returned.\r | |
955 | \r | |
956 | If Entry is NULL, then ASSERT().\r | |
957 | If Entry is the head node of an empty list, then ASSERT().\r | |
958 | If PcdMaximumLinkedListLenth is not zero, and the linked list containing\r | |
959 | Entry contains more than PcdMaximumLinkedListLenth nodes, then ASSERT().\r | |
960 | \r | |
961 | @param Entry A pointer to a node in a linked list\r | |
962 | \r | |
963 | @return Entry\r | |
964 | \r | |
965 | **/\r | |
966 | LIST_ENTRY *\r | |
967 | EFIAPI\r | |
968 | RemoveEntryList (\r | |
969 | IN CONST LIST_ENTRY *Entry\r | |
970 | );\r | |
971 | \r | |
972 | //\r | |
973 | // Math Services\r | |
974 | //\r | |
975 | \r | |
976 | /**\r | |
977 | Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled\r | |
978 | with zeros. The shifted value is returned.\r | |
979 | \r | |
980 | This function shifts the 64-bit value Operand to the left by Count bits. The\r | |
981 | low Count bits are set to zero. The shifted value is returned.\r | |
982 | \r | |
983 | If Count is greater than 63, then ASSERT().\r | |
984 | \r | |
985 | @param Operand The 64-bit operand to shift left.\r | |
986 | @param Count The number of bits to shift left.\r | |
987 | \r | |
988 | @return Operand << Count\r | |
989 | \r | |
990 | **/\r | |
991 | UINT64\r | |
992 | EFIAPI\r | |
993 | LShiftU64 (\r | |
994 | IN UINT64 Operand,\r | |
995 | IN UINTN Count\r | |
996 | );\r | |
997 | \r | |
998 | /**\r | |
999 | Shifts a 64-bit integer right between 0 and 63 bits. This high bits are\r | |
1000 | filled with zeros. The shifted value is returned.\r | |
1001 | \r | |
1002 | This function shifts the 64-bit value Operand to the right by Count bits. The\r | |
1003 | high Count bits are set to zero. The shifted value is returned.\r | |
1004 | \r | |
1005 | If Count is greater than 63, then ASSERT().\r | |
1006 | \r | |
1007 | @param Operand The 64-bit operand to shift right.\r | |
1008 | @param Count The number of bits to shift right.\r | |
1009 | \r | |
1010 | @return Operand >> Count\r | |
1011 | \r | |
1012 | **/\r | |
1013 | UINT64\r | |
1014 | EFIAPI\r | |
1015 | RShiftU64 (\r | |
1016 | IN UINT64 Operand,\r | |
1017 | IN UINTN Count\r | |
1018 | );\r | |
1019 | \r | |
1020 | /**\r | |
1021 | Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled\r | |
1022 | with original integer's bit 63. The shifted value is returned.\r | |
1023 | \r | |
1024 | This function shifts the 64-bit value Operand to the right by Count bits. The\r | |
1025 | high Count bits are set to bit 63 of Operand. The shifted value is returned.\r | |
1026 | \r | |
1027 | If Count is greater than 63, then ASSERT().\r | |
1028 | \r | |
1029 | @param Operand The 64-bit operand to shift right.\r | |
1030 | @param Count The number of bits to shift right.\r | |
1031 | \r | |
1032 | @return Operand >> Count\r | |
1033 | \r | |
1034 | **/\r | |
1035 | UINT64\r | |
1036 | EFIAPI\r | |
1037 | ARShiftU64 (\r | |
1038 | IN UINT64 Operand,\r | |
1039 | IN UINTN Count\r | |
1040 | );\r | |
1041 | \r | |
1042 | /**\r | |
1043 | Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits\r | |
1044 | with the high bits that were rotated.\r | |
1045 | \r | |
1046 | This function rotates the 32-bit value Operand to the left by Count bits. The\r | |
1047 | low Count bits are fill with the high Count bits of Operand. The rotated\r | |
1048 | value is returned.\r | |
1049 | \r | |
1050 | If Count is greater than 31, then ASSERT().\r | |
1051 | \r | |
1052 | @param Operand The 32-bit operand to rotate left.\r | |
1053 | @param Count The number of bits to rotate left.\r | |
1054 | \r | |
1055 | @return Operand <<< Count\r | |
1056 | \r | |
1057 | **/\r | |
1058 | UINT32\r | |
1059 | EFIAPI\r | |
1060 | LRotU32 (\r | |
1061 | IN UINT32 Operand,\r | |
1062 | IN UINTN Count\r | |
1063 | );\r | |
1064 | \r | |
1065 | /**\r | |
1066 | Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits\r | |
1067 | with the low bits that were rotated.\r | |
1068 | \r | |
1069 | This function rotates the 32-bit value Operand to the right by Count bits.\r | |
1070 | The high Count bits are fill with the low Count bits of Operand. The rotated\r | |
1071 | value is returned.\r | |
1072 | \r | |
1073 | If Count is greater than 31, then ASSERT().\r | |
1074 | \r | |
1075 | @param Operand The 32-bit operand to rotate right.\r | |
1076 | @param Count The number of bits to rotate right.\r | |
1077 | \r | |
1078 | @return Operand >>> Count\r | |
1079 | \r | |
1080 | **/\r | |
1081 | UINT32\r | |
1082 | EFIAPI\r | |
1083 | RRotU32 (\r | |
1084 | IN UINT32 Operand,\r | |
1085 | IN UINTN Count\r | |
1086 | );\r | |
1087 | \r | |
1088 | /**\r | |
1089 | Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits\r | |
1090 | with the high bits that were rotated.\r | |
1091 | \r | |
1092 | This function rotates the 64-bit value Operand to the left by Count bits. The\r | |
1093 | low Count bits are fill with the high Count bits of Operand. The rotated\r | |
1094 | value is returned.\r | |
1095 | \r | |
1096 | If Count is greater than 63, then ASSERT().\r | |
1097 | \r | |
1098 | @param Operand The 64-bit operand to rotate left.\r | |
1099 | @param Count The number of bits to rotate left.\r | |
1100 | \r | |
1101 | @return Operand <<< Count\r | |
1102 | \r | |
1103 | **/\r | |
1104 | UINT64\r | |
1105 | EFIAPI\r | |
1106 | LRotU64 (\r | |
1107 | IN UINT64 Operand,\r | |
1108 | IN UINTN Count\r | |
1109 | );\r | |
1110 | \r | |
1111 | /**\r | |
1112 | Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits\r | |
1113 | with the high low bits that were rotated.\r | |
1114 | \r | |
1115 | This function rotates the 64-bit value Operand to the right by Count bits.\r | |
1116 | The high Count bits are fill with the low Count bits of Operand. The rotated\r | |
1117 | value is returned.\r | |
1118 | \r | |
1119 | If Count is greater than 63, then ASSERT().\r | |
1120 | \r | |
1121 | @param Operand The 64-bit operand to rotate right.\r | |
1122 | @param Count The number of bits to rotate right.\r | |
1123 | \r | |
1124 | @return Operand >>> Count\r | |
1125 | \r | |
1126 | **/\r | |
1127 | UINT64\r | |
1128 | EFIAPI\r | |
1129 | RRotU64 (\r | |
1130 | IN UINT64 Operand,\r | |
1131 | IN UINTN Count\r | |
1132 | );\r | |
1133 | \r | |
1134 | /**\r | |
1135 | Returns the bit position of the lowest bit set in a 32-bit value.\r | |
1136 | \r | |
1137 | This function computes the bit position of the lowest bit set in the 32-bit\r | |
1138 | value specified by Operand. If Operand is zero, then -1 is returned.\r | |
1139 | Otherwise, a value between 0 and 31 is returned.\r | |
1140 | \r | |
1141 | @param Operand The 32-bit operand to evaluate.\r | |
1142 | \r | |
1143 | @return Position of the lowest bit set in Operand if found.\r | |
1144 | @retval -1 Operand is zero.\r | |
1145 | \r | |
1146 | **/\r | |
1147 | INTN\r | |
1148 | EFIAPI\r | |
1149 | LowBitSet32 (\r | |
1150 | IN UINT32 Operand\r | |
1151 | );\r | |
1152 | \r | |
1153 | /**\r | |
1154 | Returns the bit position of the lowest bit set in a 64-bit value.\r | |
1155 | \r | |
1156 | This function computes the bit position of the lowest bit set in the 64-bit\r | |
1157 | value specified by Operand. If Operand is zero, then -1 is returned.\r | |
1158 | Otherwise, a value between 0 and 63 is returned.\r | |
1159 | \r | |
1160 | @param Operand The 64-bit operand to evaluate.\r | |
1161 | \r | |
1162 | @return Position of the lowest bit set in Operand if found.\r | |
1163 | @retval -1 Operand is zero.\r | |
1164 | \r | |
1165 | **/\r | |
1166 | INTN\r | |
1167 | EFIAPI\r | |
1168 | LowBitSet64 (\r | |
1169 | IN UINT64 Operand\r | |
1170 | );\r | |
1171 | \r | |
1172 | /**\r | |
1173 | Returns the bit position of the highest bit set in a 32-bit value. Equivalent\r | |
1174 | to log2(x).\r | |
1175 | \r | |
1176 | This function computes the bit position of the highest bit set in the 32-bit\r | |
1177 | value specified by Operand. If Operand is zero, then -1 is returned.\r | |
1178 | Otherwise, a value between 0 and 31 is returned.\r | |
1179 | \r | |
1180 | @param Operand The 32-bit operand to evaluate.\r | |
1181 | \r | |
1182 | @return Position of the highest bit set in Operand if found.\r | |
1183 | @retval -1 Operand is zero.\r | |
1184 | \r | |
1185 | **/\r | |
1186 | INTN\r | |
1187 | EFIAPI\r | |
1188 | HighBitSet32 (\r | |
1189 | IN UINT32 Operand\r | |
1190 | );\r | |
1191 | \r | |
1192 | /**\r | |
1193 | Returns the bit position of the highest bit set in a 64-bit value. Equivalent\r | |
1194 | to log2(x).\r | |
1195 | \r | |
1196 | This function computes the bit position of the highest bit set in the 64-bit\r | |
1197 | value specified by Operand. If Operand is zero, then -1 is returned.\r | |
1198 | Otherwise, a value between 0 and 63 is returned.\r | |
1199 | \r | |
1200 | @param Operand The 64-bit operand to evaluate.\r | |
1201 | \r | |
1202 | @return Position of the highest bit set in Operand if found.\r | |
1203 | @retval -1 Operand is zero.\r | |
1204 | \r | |
1205 | **/\r | |
1206 | INTN\r | |
1207 | EFIAPI\r | |
1208 | HighBitSet64 (\r | |
1209 | IN UINT64 Operand\r | |
1210 | );\r | |
1211 | \r | |
1212 | /**\r | |
1213 | Returns the value of the highest bit set in a 32-bit value. Equivalent to\r | |
1214 | 1 << HighBitSet32(x).\r | |
1215 | \r | |
1216 | This function computes the value of the highest bit set in the 32-bit value\r | |
1217 | specified by Operand. If Operand is zero, then zero is returned.\r | |
1218 | \r | |
1219 | @param Operand The 32-bit operand to evaluate.\r | |
1220 | \r | |
1221 | @return 1 << HighBitSet32(Operand)\r | |
1222 | @retval 0 Operand is zero.\r | |
1223 | \r | |
1224 | **/\r | |
1225 | UINT32\r | |
1226 | EFIAPI\r | |
1227 | GetPowerOfTwo32 (\r | |
1228 | IN UINT32 Operand\r | |
1229 | );\r | |
1230 | \r | |
1231 | /**\r | |
1232 | Returns the value of the highest bit set in a 64-bit value. Equivalent to\r | |
1233 | 1 << HighBitSet64(x).\r | |
1234 | \r | |
1235 | This function computes the value of the highest bit set in the 64-bit value\r | |
1236 | specified by Operand. If Operand is zero, then zero is returned.\r | |
1237 | \r | |
1238 | @param Operand The 64-bit operand to evaluate.\r | |
1239 | \r | |
1240 | @return 1 << HighBitSet64(Operand)\r | |
1241 | @retval 0 Operand is zero.\r | |
1242 | \r | |
1243 | **/\r | |
1244 | UINT64\r | |
1245 | EFIAPI\r | |
1246 | GetPowerOfTwo64 (\r | |
1247 | IN UINT64 Operand\r | |
1248 | );\r | |
1249 | \r | |
1250 | /**\r | |
1251 | Switches the endianess of a 16-bit integer.\r | |
1252 | \r | |
1253 | This function swaps the bytes in a 16-bit unsigned value to switch the value\r | |
1254 | from little endian to big endian or vice versa. The byte swapped value is\r | |
1255 | returned.\r | |
1256 | \r | |
1257 | @param Operand A 16-bit unsigned value.\r | |
1258 | \r | |
1259 | @return The byte swaped Operand.\r | |
1260 | \r | |
1261 | **/\r | |
1262 | UINT16\r | |
1263 | EFIAPI\r | |
1264 | SwapBytes16 (\r | |
1265 | IN UINT16 Value\r | |
1266 | );\r | |
1267 | \r | |
1268 | /**\r | |
1269 | Switches the endianess of a 32-bit integer.\r | |
1270 | \r | |
1271 | This function swaps the bytes in a 32-bit unsigned value to switch the value\r | |
1272 | from little endian to big endian or vice versa. The byte swapped value is\r | |
1273 | returned.\r | |
1274 | \r | |
1275 | @param Operand A 32-bit unsigned value.\r | |
1276 | \r | |
1277 | @return The byte swaped Operand.\r | |
1278 | \r | |
1279 | **/\r | |
1280 | UINT32\r | |
1281 | EFIAPI\r | |
1282 | SwapBytes32 (\r | |
1283 | IN UINT32 Value\r | |
1284 | );\r | |
1285 | \r | |
1286 | /**\r | |
1287 | Switches the endianess of a 64-bit integer.\r | |
1288 | \r | |
1289 | This function swaps the bytes in a 64-bit unsigned value to switch the value\r | |
1290 | from little endian to big endian or vice versa. The byte swapped value is\r | |
1291 | returned.\r | |
1292 | \r | |
1293 | @param Operand A 64-bit unsigned value.\r | |
1294 | \r | |
1295 | @return The byte swaped Operand.\r | |
1296 | \r | |
1297 | **/\r | |
1298 | UINT64\r | |
1299 | EFIAPI\r | |
1300 | SwapBytes64 (\r | |
1301 | IN UINT64 Value\r | |
1302 | );\r | |
1303 | \r | |
1304 | /**\r | |
1305 | Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and\r | |
1306 | generates a 64-bit unsigned result.\r | |
1307 | \r | |
1308 | This function multiples the 64-bit unsigned value Multiplicand by the 32-bit\r | |
1309 | unsigned value Multiplier and generates a 64-bit unsigned result. This 64-\r | |
1310 | bit unsigned result is returned.\r | |
1311 | \r | |
1312 | If the result overflows, then ASSERT().\r | |
1313 | \r | |
1314 | @param Multiplicand A 64-bit unsigned value.\r | |
1315 | @param Multiplier A 32-bit unsigned value.\r | |
1316 | \r | |
1317 | @return Multiplicand * Multiplier\r | |
1318 | \r | |
1319 | **/\r | |
1320 | UINT64\r | |
1321 | EFIAPI\r | |
1322 | MultU64x32 (\r | |
1323 | IN UINT64 Multiplicand,\r | |
1324 | IN UINT32 Multiplier\r | |
1325 | );\r | |
1326 | \r | |
1327 | /**\r | |
1328 | Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and\r | |
1329 | generates a 64-bit unsigned result.\r | |
1330 | \r | |
1331 | This function multiples the 64-bit unsigned value Multiplicand by the 64-bit\r | |
1332 | unsigned value Multiplier and generates a 64-bit unsigned result. This 64-\r | |
1333 | bit unsigned result is returned.\r | |
1334 | \r | |
1335 | If the result overflows, then ASSERT().\r | |
1336 | \r | |
1337 | @param Multiplicand A 64-bit unsigned value.\r | |
1338 | @param Multiplier A 64-bit unsigned value.\r | |
1339 | \r | |
1340 | @return Multiplicand * Multiplier\r | |
1341 | \r | |
1342 | **/\r | |
1343 | UINT64\r | |
1344 | EFIAPI\r | |
1345 | MultU64x64 (\r | |
1346 | IN UINT64 Multiplicand,\r | |
1347 | IN UINT64 Multiplier\r | |
1348 | );\r | |
1349 | \r | |
1350 | /**\r | |
1351 | Multiples a 64-bit signed integer by a 64-bit signed integer and generates a\r | |
1352 | 64-bit signed result.\r | |
1353 | \r | |
1354 | This function multiples the 64-bit signed value Multiplicand by the 64-bit\r | |
1355 | signed value Multiplier and generates a 64-bit signed result. This 64-bit\r | |
1356 | signed result is returned.\r | |
1357 | \r | |
1358 | If the result overflows, then ASSERT().\r | |
1359 | \r | |
1360 | @param Multiplicand A 64-bit signed value.\r | |
1361 | @param Multiplier A 64-bit signed value.\r | |
1362 | \r | |
1363 | @return Multiplicand * Multiplier\r | |
1364 | \r | |
1365 | **/\r | |
1366 | INT64\r | |
1367 | EFIAPI\r | |
1368 | MultS64x64 (\r | |
1369 | IN INT64 Multiplicand,\r | |
1370 | IN INT64 Multiplier\r | |
1371 | );\r | |
1372 | \r | |
1373 | /**\r | |
1374 | Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates\r | |
1375 | a 64-bit unsigned result.\r | |
1376 | \r | |
1377 | This function divides the 64-bit unsigned value Dividend by the 32-bit\r | |
1378 | unsigned value Divisor and generates a 64-bit unsigned quotient. This\r | |
1379 | function returns the 64-bit unsigned quotient.\r | |
1380 | \r | |
1381 | If Divisor is 0, then ASSERT().\r | |
1382 | \r | |
1383 | @param Dividend A 64-bit unsigned value.\r | |
1384 | @param Divisor A 32-bit unsigned value.\r | |
1385 | \r | |
1386 | @return Dividend / Divisor\r | |
1387 | \r | |
1388 | **/\r | |
1389 | UINT64\r | |
1390 | EFIAPI\r | |
1391 | DivU64x32 (\r | |
1392 | IN UINT64 Dividend,\r | |
1393 | IN UINT32 Divisor\r | |
1394 | );\r | |
1395 | \r | |
1396 | /**\r | |
1397 | Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates\r | |
1398 | a 32-bit unsigned remainder.\r | |
1399 | \r | |
1400 | This function divides the 64-bit unsigned value Dividend by the 32-bit\r | |
1401 | unsigned value Divisor and generates a 32-bit remainder. This function\r | |
1402 | returns the 32-bit unsigned remainder.\r | |
1403 | \r | |
1404 | If Divisor is 0, then ASSERT().\r | |
1405 | \r | |
1406 | @param Dividend A 64-bit unsigned value.\r | |
1407 | @param Divisor A 32-bit unsigned value.\r | |
1408 | \r | |
1409 | @return Dividend % Divisor\r | |
1410 | \r | |
1411 | **/\r | |
1412 | UINT32\r | |
1413 | EFIAPI\r | |
1414 | ModU64x32 (\r | |
1415 | IN UINT64 Dividend,\r | |
1416 | IN UINT32 Divisor\r | |
1417 | );\r | |
1418 | \r | |
1419 | /**\r | |
1420 | Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates\r | |
1421 | a 64-bit unsigned result and an optional 32-bit unsigned remainder.\r | |
1422 | \r | |
1423 | This function divides the 64-bit unsigned value Dividend by the 32-bit\r | |
1424 | unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder\r | |
1425 | is not NULL, then the 32-bit unsigned remainder is returned in Remainder.\r | |
1426 | This function returns the 64-bit unsigned quotient.\r | |
1427 | \r | |
1428 | If Divisor is 0, then ASSERT().\r | |
1429 | \r | |
1430 | @param Dividend A 64-bit unsigned value.\r | |
1431 | @param Divisor A 32-bit unsigned value.\r | |
1432 | @param Remainder A pointer to a 32-bit unsigned value. This parameter is\r | |
1433 | optional and may be NULL.\r | |
1434 | \r | |
1435 | @return Dividend / Divisor\r | |
1436 | \r | |
1437 | **/\r | |
1438 | UINT64\r | |
1439 | EFIAPI\r | |
1440 | DivU64x32Remainder (\r | |
1441 | IN UINT64 Dividend,\r | |
1442 | IN UINT32 Divisor,\r | |
1443 | OUT UINT32 *Remainder OPTIONAL\r | |
1444 | );\r | |
1445 | \r | |
1446 | /**\r | |
1447 | Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates\r | |
1448 | a 64-bit unsigned result and an optional 64-bit unsigned remainder.\r | |
1449 | \r | |
1450 | This function divides the 64-bit unsigned value Dividend by the 64-bit\r | |
1451 | unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder\r | |
1452 | is not NULL, then the 64-bit unsigned remainder is returned in Remainder.\r | |
1453 | This function returns the 64-bit unsigned quotient.\r | |
1454 | \r | |
1455 | If Divisor is 0, then ASSERT().\r | |
1456 | \r | |
1457 | @param Dividend A 64-bit unsigned value.\r | |
1458 | @param Divisor A 64-bit unsigned value.\r | |
1459 | @param Remainder A pointer to a 64-bit unsigned value. This parameter is\r | |
1460 | optional and may be NULL.\r | |
1461 | \r | |
1462 | @return Dividend / Divisor\r | |
1463 | \r | |
1464 | **/\r | |
1465 | UINT64\r | |
1466 | EFIAPI\r | |
1467 | DivU64x64Remainder (\r | |
1468 | IN UINT64 Dividend,\r | |
1469 | IN UINT64 Divisor,\r | |
1470 | OUT UINT64 *Remainder OPTIONAL\r | |
1471 | );\r | |
1472 | \r | |
1473 | /**\r | |
1474 | Divides a 64-bit signed integer by a 64-bit signed integer and generates a\r | |
1475 | 64-bit signed result and a optional 64-bit signed remainder.\r | |
1476 | \r | |
1477 | This function divides the 64-bit signed value Dividend by the 64-bit signed\r | |
1478 | value Divisor and generates a 64-bit signed quotient. If Remainder is not\r | |
1479 | NULL, then the 64-bit signed remainder is returned in Remainder. This\r | |
1480 | function returns the 64-bit signed quotient.\r | |
1481 | \r | |
1482 | If Divisor is 0, then ASSERT().\r | |
1483 | \r | |
1484 | @param Dividend A 64-bit signed value.\r | |
1485 | @param Divisor A 64-bit signed value.\r | |
1486 | @param Remainder A pointer to a 64-bit signed value. This parameter is\r | |
1487 | optional and may be NULL.\r | |
1488 | \r | |
1489 | @return Dividend / Divisor\r | |
1490 | \r | |
1491 | **/\r | |
1492 | INT64\r | |
1493 | EFIAPI\r | |
1494 | DivS64x64Remainder (\r | |
1495 | IN INT64 Dividend,\r | |
1496 | IN INT64 Divisor,\r | |
1497 | OUT INT64 *Remainder OPTIONAL\r | |
1498 | );\r | |
1499 | \r | |
1500 | /**\r | |
1501 | Reads a 16-bit value from memory that may be unaligned.\r | |
1502 | \r | |
1503 | This function returns the 16-bit value pointed to by Buffer. The function\r | |
1504 | guarantees that the read operation does not produce an alignment fault.\r | |
1505 | \r | |
1506 | If the Buffer is NULL, then ASSERT().\r | |
1507 | \r | |
1508 | @param Buffer Pointer to a 16-bit value that may be unaligned.\r | |
1509 | \r | |
1510 | @return *Uint16\r | |
1511 | \r | |
1512 | **/\r | |
1513 | UINT16\r | |
1514 | EFIAPI\r | |
1515 | ReadUnaligned16 (\r | |
1516 | IN CONST UINT16 *Uint16\r | |
1517 | );\r | |
1518 | \r | |
1519 | /**\r | |
1520 | Writes a 16-bit value to memory that may be unaligned.\r | |
1521 | \r | |
1522 | This function writes the 16-bit value specified by Value to Buffer. Value is\r | |
1523 | returned. The function guarantees that the write operation does not produce\r | |
1524 | an alignment fault.\r | |
1525 | \r | |
1526 | If the Buffer is NULL, then ASSERT().\r | |
1527 | \r | |
1528 | @param Buffer Pointer to a 16-bit value that may be unaligned.\r | |
1529 | @param Value 16-bit value to write to Buffer.\r | |
1530 | \r | |
1531 | @return Value\r | |
1532 | \r | |
1533 | **/\r | |
1534 | UINT16\r | |
1535 | EFIAPI\r | |
1536 | WriteUnaligned16 (\r | |
1537 | OUT UINT16 *Uint16,\r | |
1538 | IN UINT16 Value\r | |
1539 | );\r | |
1540 | \r | |
1541 | /**\r | |
1542 | Reads a 24-bit value from memory that may be unaligned.\r | |
1543 | \r | |
1544 | This function returns the 24-bit value pointed to by Buffer. The function\r | |
1545 | guarantees that the read operation does not produce an alignment fault.\r | |
1546 | \r | |
1547 | If the Buffer is NULL, then ASSERT().\r | |
1548 | \r | |
1549 | @param Buffer Pointer to a 24-bit value that may be unaligned.\r | |
1550 | \r | |
1551 | @return The value read.\r | |
1552 | \r | |
1553 | **/\r | |
1554 | UINT32\r | |
1555 | EFIAPI\r | |
1556 | ReadUnaligned24 (\r | |
1557 | IN CONST UINT32 *Buffer\r | |
1558 | );\r | |
1559 | \r | |
1560 | /**\r | |
1561 | Writes a 24-bit value to memory that may be unaligned.\r | |
1562 | \r | |
1563 | This function writes the 24-bit value specified by Value to Buffer. Value is\r | |
1564 | returned. The function guarantees that the write operation does not produce\r | |
1565 | an alignment fault.\r | |
1566 | \r | |
1567 | If the Buffer is NULL, then ASSERT().\r | |
1568 | \r | |
1569 | @param Buffer Pointer to a 24-bit value that may be unaligned.\r | |
1570 | @param Value 24-bit value to write to Buffer.\r | |
1571 | \r | |
1572 | @return The value written.\r | |
1573 | \r | |
1574 | **/\r | |
1575 | UINT32\r | |
1576 | EFIAPI\r | |
1577 | WriteUnaligned24 (\r | |
1578 | OUT UINT32 *Buffer,\r | |
1579 | IN UINT32 Value\r | |
1580 | );\r | |
1581 | \r | |
1582 | /**\r | |
1583 | Reads a 32-bit value from memory that may be unaligned.\r | |
1584 | \r | |
1585 | This function returns the 32-bit value pointed to by Buffer. The function\r | |
1586 | guarantees that the read operation does not produce an alignment fault.\r | |
1587 | \r | |
1588 | If the Buffer is NULL, then ASSERT().\r | |
1589 | \r | |
1590 | @param Buffer Pointer to a 32-bit value that may be unaligned.\r | |
1591 | \r | |
1592 | @return *Uint32\r | |
1593 | \r | |
1594 | **/\r | |
1595 | UINT32\r | |
1596 | EFIAPI\r | |
1597 | ReadUnaligned32 (\r | |
1598 | IN CONST UINT32 *Uint32\r | |
1599 | );\r | |
1600 | \r | |
1601 | /**\r | |
1602 | Writes a 32-bit value to memory that may be unaligned.\r | |
1603 | \r | |
1604 | This function writes the 32-bit value specified by Value to Buffer. Value is\r | |
1605 | returned. The function guarantees that the write operation does not produce\r | |
1606 | an alignment fault.\r | |
1607 | \r | |
1608 | If the Buffer is NULL, then ASSERT().\r | |
1609 | \r | |
1610 | @param Buffer Pointer to a 32-bit value that may be unaligned.\r | |
1611 | @param Value 32-bit value to write to Buffer.\r | |
1612 | \r | |
1613 | @return Value\r | |
1614 | \r | |
1615 | **/\r | |
1616 | UINT32\r | |
1617 | EFIAPI\r | |
1618 | WriteUnaligned32 (\r | |
1619 | OUT UINT32 *Uint32,\r | |
1620 | IN UINT32 Value\r | |
1621 | );\r | |
1622 | \r | |
1623 | /**\r | |
1624 | Reads a 64-bit value from memory that may be unaligned.\r | |
1625 | \r | |
1626 | This function returns the 64-bit value pointed to by Buffer. The function\r | |
1627 | guarantees that the read operation does not produce an alignment fault.\r | |
1628 | \r | |
1629 | If the Buffer is NULL, then ASSERT().\r | |
1630 | \r | |
1631 | @param Buffer Pointer to a 64-bit value that may be unaligned.\r | |
1632 | \r | |
1633 | @return *Uint64\r | |
1634 | \r | |
1635 | **/\r | |
1636 | UINT64\r | |
1637 | EFIAPI\r | |
1638 | ReadUnaligned64 (\r | |
1639 | IN CONST UINT64 *Uint64\r | |
1640 | );\r | |
1641 | \r | |
1642 | /**\r | |
1643 | Writes a 64-bit value to memory that may be unaligned.\r | |
1644 | \r | |
1645 | This function writes the 64-bit value specified by Value to Buffer. Value is\r | |
1646 | returned. The function guarantees that the write operation does not produce\r | |
1647 | an alignment fault.\r | |
1648 | \r | |
1649 | If the Buffer is NULL, then ASSERT().\r | |
1650 | \r | |
1651 | @param Buffer Pointer to a 64-bit value that may be unaligned.\r | |
1652 | @param Value 64-bit value to write to Buffer.\r | |
1653 | \r | |
1654 | @return Value\r | |
1655 | \r | |
1656 | **/\r | |
1657 | UINT64\r | |
1658 | EFIAPI\r | |
1659 | WriteUnaligned64 (\r | |
1660 | OUT UINT64 *Uint64,\r | |
1661 | IN UINT64 Value\r | |
1662 | );\r | |
1663 | \r | |
1664 | //\r | |
1665 | // Bit Field Functions\r | |
1666 | //\r | |
1667 | \r | |
1668 | /**\r | |
1669 | Returns a bit field from an 8-bit value.\r | |
1670 | \r | |
1671 | Returns the bitfield specified by the StartBit and the EndBit from Operand.\r | |
1672 | \r | |
1673 | If 8-bit operations are not supported, then ASSERT().\r | |
1674 | If StartBit is greater than 7, then ASSERT().\r | |
1675 | If EndBit is greater than 7, then ASSERT().\r | |
0ffa1286 | 1676 | If EndBit is less than StartBit, then ASSERT().\r |
878ddf1f | 1677 | \r |
1678 | @param Operand Operand on which to perform the bitfield operation.\r | |
1679 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
1680 | Range 0..7.\r | |
1681 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
1682 | Range 0..7.\r | |
1683 | \r | |
1684 | @return The bit field read.\r | |
1685 | \r | |
1686 | **/\r | |
1687 | UINT8\r | |
1688 | EFIAPI\r | |
1689 | BitFieldRead8 (\r | |
1690 | IN UINT8 Operand,\r | |
1691 | IN UINTN StartBit,\r | |
1692 | IN UINTN EndBit\r | |
1693 | );\r | |
1694 | \r | |
1695 | /**\r | |
1696 | Writes a bit field to an 8-bit value, and returns the result.\r | |
1697 | \r | |
1698 | Writes Value to the bit field specified by the StartBit and the EndBit in\r | |
1699 | Operand. All other bits in Operand are preserved. The new 8-bit value is\r | |
1700 | returned.\r | |
1701 | \r | |
1702 | If 8-bit operations are not supported, then ASSERT().\r | |
1703 | If StartBit is greater than 7, then ASSERT().\r | |
1704 | If EndBit is greater than 7, then ASSERT().\r | |
0ffa1286 | 1705 | If EndBit is less than StartBit, then ASSERT().\r |
878ddf1f | 1706 | \r |
1707 | @param Operand Operand on which to perform the bitfield operation.\r | |
1708 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
1709 | Range 0..7.\r | |
1710 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
1711 | Range 0..7.\r | |
1712 | @param Value New value of the bit field.\r | |
1713 | \r | |
1714 | @return The new 8-bit value.\r | |
1715 | \r | |
1716 | **/\r | |
1717 | UINT8\r | |
1718 | EFIAPI\r | |
1719 | BitFieldWrite8 (\r | |
1720 | IN UINT8 Operand,\r | |
1721 | IN UINTN StartBit,\r | |
1722 | IN UINTN EndBit,\r | |
1723 | IN UINT8 Value\r | |
1724 | );\r | |
1725 | \r | |
1726 | /**\r | |
1727 | Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the\r | |
1728 | result.\r | |
1729 | \r | |
1730 | Performs a bitwise inclusive OR between the bit field specified by StartBit\r | |
1731 | and EndBit in Operand and the value specified by OrData. All other bits in\r | |
1732 | Operand are preserved. The new 8-bit value is returned.\r | |
1733 | \r | |
1734 | If 8-bit operations are not supported, then ASSERT().\r | |
1735 | If StartBit is greater than 7, then ASSERT().\r | |
1736 | If EndBit is greater than 7, then ASSERT().\r | |
0ffa1286 | 1737 | If EndBit is less than StartBit, then ASSERT().\r |
878ddf1f | 1738 | \r |
1739 | @param Operand Operand on which to perform the bitfield operation.\r | |
1740 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
1741 | Range 0..7.\r | |
1742 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
1743 | Range 0..7.\r | |
1744 | @param OrData The value to OR with the read value from the value\r | |
1745 | \r | |
1746 | @return The new 8-bit value.\r | |
1747 | \r | |
1748 | **/\r | |
1749 | UINT8\r | |
1750 | EFIAPI\r | |
1751 | BitFieldOr8 (\r | |
1752 | IN UINT8 Operand,\r | |
1753 | IN UINTN StartBit,\r | |
1754 | IN UINTN EndBit,\r | |
1755 | IN UINT8 OrData\r | |
1756 | );\r | |
1757 | \r | |
1758 | /**\r | |
1759 | Reads a bit field from an 8-bit value, performs a bitwise AND, and returns\r | |
1760 | the result.\r | |
1761 | \r | |
1762 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
1763 | in Operand and the value specified by AndData. All other bits in Operand are\r | |
1764 | preserved. The new 8-bit value is returned.\r | |
1765 | \r | |
1766 | If 8-bit operations are not supported, then ASSERT().\r | |
1767 | If StartBit is greater than 7, then ASSERT().\r | |
1768 | If EndBit is greater than 7, then ASSERT().\r | |
0ffa1286 | 1769 | If EndBit is less than StartBit, then ASSERT().\r |
878ddf1f | 1770 | \r |
1771 | @param Operand Operand on which to perform the bitfield operation.\r | |
1772 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
1773 | Range 0..7.\r | |
1774 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
1775 | Range 0..7.\r | |
1776 | @param AndData The value to AND with the read value from the value.\r | |
1777 | \r | |
1778 | @return The new 8-bit value.\r | |
1779 | \r | |
1780 | **/\r | |
1781 | UINT8\r | |
1782 | EFIAPI\r | |
1783 | BitFieldAnd8 (\r | |
1784 | IN UINT8 Operand,\r | |
1785 | IN UINTN StartBit,\r | |
1786 | IN UINTN EndBit,\r | |
1787 | IN UINT8 AndData\r | |
1788 | );\r | |
1789 | \r | |
1790 | /**\r | |
1791 | Reads a bit field from an 8-bit value, performs a bitwise AND followed by a\r | |
1792 | bitwise OR, and returns the result.\r | |
1793 | \r | |
1794 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
1795 | in Operand and the value specified by AndData, followed by a bitwise\r | |
1796 | inclusive OR with value specified by OrData. All other bits in Operand are\r | |
1797 | preserved. The new 8-bit value is returned.\r | |
1798 | \r | |
1799 | If 8-bit operations are not supported, then ASSERT().\r | |
1800 | If StartBit is greater than 7, then ASSERT().\r | |
1801 | If EndBit is greater than 7, then ASSERT().\r | |
0ffa1286 | 1802 | If EndBit is less than StartBit, then ASSERT().\r |
878ddf1f | 1803 | \r |
1804 | @param Operand Operand on which to perform the bitfield operation.\r | |
1805 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
1806 | Range 0..7.\r | |
1807 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
1808 | Range 0..7.\r | |
1809 | @param AndData The value to AND with the read value from the value.\r | |
1810 | @param OrData The value to OR with the result of the AND operation.\r | |
1811 | \r | |
1812 | @return The new 8-bit value.\r | |
1813 | \r | |
1814 | **/\r | |
1815 | UINT8\r | |
1816 | EFIAPI\r | |
1817 | BitFieldAndThenOr8 (\r | |
1818 | IN UINT8 Operand,\r | |
1819 | IN UINTN StartBit,\r | |
1820 | IN UINTN EndBit,\r | |
1821 | IN UINT8 AndData,\r | |
1822 | IN UINT8 OrData\r | |
1823 | );\r | |
1824 | \r | |
1825 | /**\r | |
1826 | Returns a bit field from a 16-bit value.\r | |
1827 | \r | |
1828 | Returns the bitfield specified by the StartBit and the EndBit from Operand.\r | |
1829 | \r | |
1830 | If 16-bit operations are not supported, then ASSERT().\r | |
1831 | If StartBit is greater than 15, then ASSERT().\r | |
1832 | If EndBit is greater than 15, then ASSERT().\r | |
0ffa1286 | 1833 | If EndBit is less than StartBit, then ASSERT().\r |
878ddf1f | 1834 | \r |
1835 | @param Operand Operand on which to perform the bitfield operation.\r | |
1836 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
1837 | Range 0..15.\r | |
1838 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
1839 | Range 0..15.\r | |
1840 | \r | |
1841 | @return The bit field read.\r | |
1842 | \r | |
1843 | **/\r | |
1844 | UINT16\r | |
1845 | EFIAPI\r | |
1846 | BitFieldRead16 (\r | |
1847 | IN UINT16 Operand,\r | |
1848 | IN UINTN StartBit,\r | |
1849 | IN UINTN EndBit\r | |
1850 | );\r | |
1851 | \r | |
1852 | /**\r | |
1853 | Writes a bit field to a 16-bit value, and returns the result.\r | |
1854 | \r | |
1855 | Writes Value to the bit field specified by the StartBit and the EndBit in\r | |
1856 | Operand. All other bits in Operand are preserved. The new 16-bit value is\r | |
1857 | returned.\r | |
1858 | \r | |
1859 | If 16-bit operations are not supported, then ASSERT().\r | |
1860 | If StartBit is greater than 15, then ASSERT().\r | |
1861 | If EndBit is greater than 15, then ASSERT().\r | |
0ffa1286 | 1862 | If EndBit is less than StartBit, then ASSERT().\r |
878ddf1f | 1863 | \r |
1864 | @param Operand Operand on which to perform the bitfield operation.\r | |
1865 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
1866 | Range 0..15.\r | |
1867 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
1868 | Range 0..15.\r | |
1869 | @param Value New value of the bit field.\r | |
1870 | \r | |
1871 | @return The new 16-bit value.\r | |
1872 | \r | |
1873 | **/\r | |
1874 | UINT16\r | |
1875 | EFIAPI\r | |
1876 | BitFieldWrite16 (\r | |
1877 | IN UINT16 Operand,\r | |
1878 | IN UINTN StartBit,\r | |
1879 | IN UINTN EndBit,\r | |
1880 | IN UINT16 Value\r | |
1881 | );\r | |
1882 | \r | |
1883 | /**\r | |
1884 | Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the\r | |
1885 | result.\r | |
1886 | \r | |
1887 | Performs a bitwise inclusive OR between the bit field specified by StartBit\r | |
1888 | and EndBit in Operand and the value specified by OrData. All other bits in\r | |
1889 | Operand are preserved. The new 16-bit value is returned.\r | |
1890 | \r | |
1891 | If 16-bit operations are not supported, then ASSERT().\r | |
1892 | If StartBit is greater than 15, then ASSERT().\r | |
1893 | If EndBit is greater than 15, then ASSERT().\r | |
0ffa1286 | 1894 | If EndBit is less than StartBit, then ASSERT().\r |
878ddf1f | 1895 | \r |
1896 | @param Operand Operand on which to perform the bitfield operation.\r | |
1897 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
1898 | Range 0..15.\r | |
1899 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
1900 | Range 0..15.\r | |
1901 | @param OrData The value to OR with the read value from the value\r | |
1902 | \r | |
1903 | @return The new 16-bit value.\r | |
1904 | \r | |
1905 | **/\r | |
1906 | UINT16\r | |
1907 | EFIAPI\r | |
1908 | BitFieldOr16 (\r | |
1909 | IN UINT16 Operand,\r | |
1910 | IN UINTN StartBit,\r | |
1911 | IN UINTN EndBit,\r | |
1912 | IN UINT16 OrData\r | |
1913 | );\r | |
1914 | \r | |
1915 | /**\r | |
1916 | Reads a bit field from a 16-bit value, performs a bitwise AND, and returns\r | |
1917 | the result.\r | |
1918 | \r | |
1919 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
1920 | in Operand and the value specified by AndData. All other bits in Operand are\r | |
1921 | preserved. The new 16-bit value is returned.\r | |
1922 | \r | |
1923 | If 16-bit operations are not supported, then ASSERT().\r | |
1924 | If StartBit is greater than 15, then ASSERT().\r | |
1925 | If EndBit is greater than 15, then ASSERT().\r | |
0ffa1286 | 1926 | If EndBit is less than StartBit, then ASSERT().\r |
878ddf1f | 1927 | \r |
1928 | @param Operand Operand on which to perform the bitfield operation.\r | |
1929 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
1930 | Range 0..15.\r | |
1931 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
1932 | Range 0..15.\r | |
1933 | @param AndData The value to AND with the read value from the value\r | |
1934 | \r | |
1935 | @return The new 16-bit value.\r | |
1936 | \r | |
1937 | **/\r | |
1938 | UINT16\r | |
1939 | EFIAPI\r | |
1940 | BitFieldAnd16 (\r | |
1941 | IN UINT16 Operand,\r | |
1942 | IN UINTN StartBit,\r | |
1943 | IN UINTN EndBit,\r | |
1944 | IN UINT16 AndData\r | |
1945 | );\r | |
1946 | \r | |
1947 | /**\r | |
1948 | Reads a bit field from a 16-bit value, performs a bitwise AND followed by a\r | |
1949 | bitwise OR, and returns the result.\r | |
1950 | \r | |
1951 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
1952 | in Operand and the value specified by AndData, followed by a bitwise\r | |
1953 | inclusive OR with value specified by OrData. All other bits in Operand are\r | |
1954 | preserved. The new 16-bit value is returned.\r | |
1955 | \r | |
1956 | If 16-bit operations are not supported, then ASSERT().\r | |
1957 | If StartBit is greater than 15, then ASSERT().\r | |
1958 | If EndBit is greater than 15, then ASSERT().\r | |
0ffa1286 | 1959 | If EndBit is less than StartBit, then ASSERT().\r |
878ddf1f | 1960 | \r |
1961 | @param Operand Operand on which to perform the bitfield operation.\r | |
1962 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
1963 | Range 0..15.\r | |
1964 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
1965 | Range 0..15.\r | |
1966 | @param AndData The value to AND with the read value from the value.\r | |
1967 | @param OrData The value to OR with the result of the AND operation.\r | |
1968 | \r | |
1969 | @return The new 16-bit value.\r | |
1970 | \r | |
1971 | **/\r | |
1972 | UINT16\r | |
1973 | EFIAPI\r | |
1974 | BitFieldAndThenOr16 (\r | |
1975 | IN UINT16 Operand,\r | |
1976 | IN UINTN StartBit,\r | |
1977 | IN UINTN EndBit,\r | |
1978 | IN UINT16 AndData,\r | |
1979 | IN UINT16 OrData\r | |
1980 | );\r | |
1981 | \r | |
1982 | /**\r | |
1983 | Returns a bit field from a 32-bit value.\r | |
1984 | \r | |
1985 | Returns the bitfield specified by the StartBit and the EndBit from Operand.\r | |
1986 | \r | |
1987 | If 32-bit operations are not supported, then ASSERT().\r | |
1988 | If StartBit is greater than 31, then ASSERT().\r | |
1989 | If EndBit is greater than 31, then ASSERT().\r | |
0ffa1286 | 1990 | If EndBit is less than StartBit, then ASSERT().\r |
878ddf1f | 1991 | \r |
1992 | @param Operand Operand on which to perform the bitfield operation.\r | |
1993 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
1994 | Range 0..31.\r | |
1995 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
1996 | Range 0..31.\r | |
1997 | \r | |
1998 | @return The bit field read.\r | |
1999 | \r | |
2000 | **/\r | |
2001 | UINT32\r | |
2002 | EFIAPI\r | |
2003 | BitFieldRead32 (\r | |
2004 | IN UINT32 Operand,\r | |
2005 | IN UINTN StartBit,\r | |
2006 | IN UINTN EndBit\r | |
2007 | );\r | |
2008 | \r | |
2009 | /**\r | |
2010 | Writes a bit field to a 32-bit value, and returns the result.\r | |
2011 | \r | |
2012 | Writes Value to the bit field specified by the StartBit and the EndBit in\r | |
2013 | Operand. All other bits in Operand are preserved. The new 32-bit value is\r | |
2014 | returned.\r | |
2015 | \r | |
2016 | If 32-bit operations are not supported, then ASSERT().\r | |
2017 | If StartBit is greater than 31, then ASSERT().\r | |
2018 | If EndBit is greater than 31, then ASSERT().\r | |
0ffa1286 | 2019 | If EndBit is less than StartBit, then ASSERT().\r |
878ddf1f | 2020 | \r |
2021 | @param Operand Operand on which to perform the bitfield operation.\r | |
2022 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
2023 | Range 0..31.\r | |
2024 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2025 | Range 0..31.\r | |
2026 | @param Value New value of the bit field.\r | |
2027 | \r | |
2028 | @return The new 32-bit value.\r | |
2029 | \r | |
2030 | **/\r | |
2031 | UINT32\r | |
2032 | EFIAPI\r | |
2033 | BitFieldWrite32 (\r | |
2034 | IN UINT32 Operand,\r | |
2035 | IN UINTN StartBit,\r | |
2036 | IN UINTN EndBit,\r | |
2037 | IN UINT32 Value\r | |
2038 | );\r | |
2039 | \r | |
2040 | /**\r | |
2041 | Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the\r | |
2042 | result.\r | |
2043 | \r | |
2044 | Performs a bitwise inclusive OR between the bit field specified by StartBit\r | |
2045 | and EndBit in Operand and the value specified by OrData. All other bits in\r | |
2046 | Operand are preserved. The new 32-bit value is returned.\r | |
2047 | \r | |
2048 | If 32-bit operations are not supported, then ASSERT().\r | |
2049 | If StartBit is greater than 31, then ASSERT().\r | |
2050 | If EndBit is greater than 31, then ASSERT().\r | |
0ffa1286 | 2051 | If EndBit is less than StartBit, then ASSERT().\r |
878ddf1f | 2052 | \r |
2053 | @param Operand Operand on which to perform the bitfield operation.\r | |
2054 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
2055 | Range 0..31.\r | |
2056 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2057 | Range 0..31.\r | |
2058 | @param OrData The value to OR with the read value from the value\r | |
2059 | \r | |
2060 | @return The new 32-bit value.\r | |
2061 | \r | |
2062 | **/\r | |
2063 | UINT32\r | |
2064 | EFIAPI\r | |
2065 | BitFieldOr32 (\r | |
2066 | IN UINT32 Operand,\r | |
2067 | IN UINTN StartBit,\r | |
2068 | IN UINTN EndBit,\r | |
2069 | IN UINT32 OrData\r | |
2070 | );\r | |
2071 | \r | |
2072 | /**\r | |
2073 | Reads a bit field from a 32-bit value, performs a bitwise AND, and returns\r | |
2074 | the result.\r | |
2075 | \r | |
2076 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
2077 | in Operand and the value specified by AndData. All other bits in Operand are\r | |
2078 | preserved. The new 32-bit value is returned.\r | |
2079 | \r | |
2080 | If 32-bit operations are not supported, then ASSERT().\r | |
2081 | If StartBit is greater than 31, then ASSERT().\r | |
2082 | If EndBit is greater than 31, then ASSERT().\r | |
0ffa1286 | 2083 | If EndBit is less than StartBit, then ASSERT().\r |
878ddf1f | 2084 | \r |
2085 | @param Operand Operand on which to perform the bitfield operation.\r | |
2086 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
2087 | Range 0..31.\r | |
2088 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2089 | Range 0..31.\r | |
2090 | @param AndData The value to AND with the read value from the value\r | |
2091 | \r | |
2092 | @return The new 32-bit value.\r | |
2093 | \r | |
2094 | **/\r | |
2095 | UINT32\r | |
2096 | EFIAPI\r | |
2097 | BitFieldAnd32 (\r | |
2098 | IN UINT32 Operand,\r | |
2099 | IN UINTN StartBit,\r | |
2100 | IN UINTN EndBit,\r | |
2101 | IN UINT32 AndData\r | |
2102 | );\r | |
2103 | \r | |
2104 | /**\r | |
2105 | Reads a bit field from a 32-bit value, performs a bitwise AND followed by a\r | |
2106 | bitwise OR, and returns the result.\r | |
2107 | \r | |
2108 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
2109 | in Operand and the value specified by AndData, followed by a bitwise\r | |
2110 | inclusive OR with value specified by OrData. All other bits in Operand are\r | |
2111 | preserved. The new 32-bit value is returned.\r | |
2112 | \r | |
2113 | If 32-bit operations are not supported, then ASSERT().\r | |
2114 | If StartBit is greater than 31, then ASSERT().\r | |
2115 | If EndBit is greater than 31, then ASSERT().\r | |
0ffa1286 | 2116 | If EndBit is less than StartBit, then ASSERT().\r |
878ddf1f | 2117 | \r |
2118 | @param Operand Operand on which to perform the bitfield operation.\r | |
2119 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
2120 | Range 0..31.\r | |
2121 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2122 | Range 0..31.\r | |
2123 | @param AndData The value to AND with the read value from the value.\r | |
2124 | @param OrData The value to OR with the result of the AND operation.\r | |
2125 | \r | |
2126 | @return The new 32-bit value.\r | |
2127 | \r | |
2128 | **/\r | |
2129 | UINT32\r | |
2130 | EFIAPI\r | |
2131 | BitFieldAndThenOr32 (\r | |
2132 | IN UINT32 Operand,\r | |
2133 | IN UINTN StartBit,\r | |
2134 | IN UINTN EndBit,\r | |
2135 | IN UINT32 AndData,\r | |
2136 | IN UINT32 OrData\r | |
2137 | );\r | |
2138 | \r | |
2139 | /**\r | |
2140 | Returns a bit field from a 64-bit value.\r | |
2141 | \r | |
2142 | Returns the bitfield specified by the StartBit and the EndBit from Operand.\r | |
2143 | \r | |
2144 | If 64-bit operations are not supported, then ASSERT().\r | |
2145 | If StartBit is greater than 63, then ASSERT().\r | |
2146 | If EndBit is greater than 63, then ASSERT().\r | |
0ffa1286 | 2147 | If EndBit is less than StartBit, then ASSERT().\r |
878ddf1f | 2148 | \r |
2149 | @param Operand Operand on which to perform the bitfield operation.\r | |
2150 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
2151 | Range 0..63.\r | |
2152 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2153 | Range 0..63.\r | |
2154 | \r | |
2155 | @return The bit field read.\r | |
2156 | \r | |
2157 | **/\r | |
2158 | UINT64\r | |
2159 | EFIAPI\r | |
2160 | BitFieldRead64 (\r | |
2161 | IN UINT64 Operand,\r | |
2162 | IN UINTN StartBit,\r | |
2163 | IN UINTN EndBit\r | |
2164 | );\r | |
2165 | \r | |
2166 | /**\r | |
2167 | Writes a bit field to a 64-bit value, and returns the result.\r | |
2168 | \r | |
2169 | Writes Value to the bit field specified by the StartBit and the EndBit in\r | |
2170 | Operand. All other bits in Operand are preserved. The new 64-bit value is\r | |
2171 | returned.\r | |
2172 | \r | |
2173 | If 64-bit operations are not supported, then ASSERT().\r | |
2174 | If StartBit is greater than 63, then ASSERT().\r | |
2175 | If EndBit is greater than 63, then ASSERT().\r | |
0ffa1286 | 2176 | If EndBit is less than StartBit, then ASSERT().\r |
878ddf1f | 2177 | \r |
2178 | @param Operand Operand on which to perform the bitfield operation.\r | |
2179 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
2180 | Range 0..63.\r | |
2181 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2182 | Range 0..63.\r | |
2183 | @param Value New value of the bit field.\r | |
2184 | \r | |
2185 | @return The new 64-bit value.\r | |
2186 | \r | |
2187 | **/\r | |
2188 | UINT64\r | |
2189 | EFIAPI\r | |
2190 | BitFieldWrite64 (\r | |
2191 | IN UINT64 Operand,\r | |
2192 | IN UINTN StartBit,\r | |
2193 | IN UINTN EndBit,\r | |
2194 | IN UINT64 Value\r | |
2195 | );\r | |
2196 | \r | |
2197 | /**\r | |
2198 | Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the\r | |
2199 | result.\r | |
2200 | \r | |
2201 | Performs a bitwise inclusive OR between the bit field specified by StartBit\r | |
2202 | and EndBit in Operand and the value specified by OrData. All other bits in\r | |
2203 | Operand are preserved. The new 64-bit value is returned.\r | |
2204 | \r | |
2205 | If 64-bit operations are not supported, then ASSERT().\r | |
2206 | If StartBit is greater than 63, then ASSERT().\r | |
2207 | If EndBit is greater than 63, then ASSERT().\r | |
0ffa1286 | 2208 | If EndBit is less than StartBit, then ASSERT().\r |
878ddf1f | 2209 | \r |
2210 | @param Operand Operand on which to perform the bitfield operation.\r | |
2211 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
2212 | Range 0..63.\r | |
2213 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2214 | Range 0..63.\r | |
2215 | @param OrData The value to OR with the read value from the value\r | |
2216 | \r | |
2217 | @return The new 64-bit value.\r | |
2218 | \r | |
2219 | **/\r | |
2220 | UINT64\r | |
2221 | EFIAPI\r | |
2222 | BitFieldOr64 (\r | |
2223 | IN UINT64 Operand,\r | |
2224 | IN UINTN StartBit,\r | |
2225 | IN UINTN EndBit,\r | |
2226 | IN UINT64 OrData\r | |
2227 | );\r | |
2228 | \r | |
2229 | /**\r | |
2230 | Reads a bit field from a 64-bit value, performs a bitwise AND, and returns\r | |
2231 | the result.\r | |
2232 | \r | |
2233 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
2234 | in Operand and the value specified by AndData. All other bits in Operand are\r | |
2235 | preserved. The new 64-bit value is returned.\r | |
2236 | \r | |
2237 | If 64-bit operations are not supported, then ASSERT().\r | |
2238 | If StartBit is greater than 63, then ASSERT().\r | |
2239 | If EndBit is greater than 63, then ASSERT().\r | |
0ffa1286 | 2240 | If EndBit is less than StartBit, then ASSERT().\r |
878ddf1f | 2241 | \r |
2242 | @param Operand Operand on which to perform the bitfield operation.\r | |
2243 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
2244 | Range 0..63.\r | |
2245 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2246 | Range 0..63.\r | |
2247 | @param AndData The value to AND with the read value from the value\r | |
2248 | \r | |
2249 | @return The new 64-bit value.\r | |
2250 | \r | |
2251 | **/\r | |
2252 | UINT64\r | |
2253 | EFIAPI\r | |
2254 | BitFieldAnd64 (\r | |
2255 | IN UINT64 Operand,\r | |
2256 | IN UINTN StartBit,\r | |
2257 | IN UINTN EndBit,\r | |
2258 | IN UINT64 AndData\r | |
2259 | );\r | |
2260 | \r | |
2261 | /**\r | |
2262 | Reads a bit field from a 64-bit value, performs a bitwise AND followed by a\r | |
2263 | bitwise OR, and returns the result.\r | |
2264 | \r | |
2265 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
2266 | in Operand and the value specified by AndData, followed by a bitwise\r | |
2267 | inclusive OR with value specified by OrData. All other bits in Operand are\r | |
2268 | preserved. The new 64-bit value is returned.\r | |
2269 | \r | |
2270 | If 64-bit operations are not supported, then ASSERT().\r | |
2271 | If StartBit is greater than 63, then ASSERT().\r | |
2272 | If EndBit is greater than 63, then ASSERT().\r | |
0ffa1286 | 2273 | If EndBit is less than StartBit, then ASSERT().\r |
878ddf1f | 2274 | \r |
2275 | @param Operand Operand on which to perform the bitfield operation.\r | |
2276 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
2277 | Range 0..63.\r | |
2278 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
2279 | Range 0..63.\r | |
2280 | @param AndData The value to AND with the read value from the value.\r | |
2281 | @param OrData The value to OR with the result of the AND operation.\r | |
2282 | \r | |
2283 | @return The new 64-bit value.\r | |
2284 | \r | |
2285 | **/\r | |
2286 | UINT64\r | |
2287 | EFIAPI\r | |
2288 | BitFieldAndThenOr64 (\r | |
2289 | IN UINT64 Operand,\r | |
2290 | IN UINTN StartBit,\r | |
2291 | IN UINTN EndBit,\r | |
2292 | IN UINT64 AndData,\r | |
2293 | IN UINT64 OrData\r | |
2294 | );\r | |
2295 | \r | |
2296 | //\r | |
2297 | // Base Library Synchronization Functions\r | |
2298 | //\r | |
2299 | \r | |
2300 | /**\r | |
2301 | Retrieves the architecture specific spin lock alignment requirements for\r | |
2302 | optimal spin lock performance.\r | |
2303 | \r | |
2304 | This function retrieves the spin lock alignment requirements for optimal\r | |
2305 | performance on a given CPU architecture. The spin lock alignment must be a\r | |
2306 | power of two and is returned by this function. If there are no alignment\r | |
2307 | requirements, then 1 must be returned. The spin lock synchronization\r | |
2308 | functions must function correctly if the spin lock size and alignment values\r | |
2309 | returned by this function are not used at all. These values are hints to the\r | |
2310 | consumers of the spin lock synchronization functions to obtain optimal spin\r | |
2311 | lock performance.\r | |
2312 | \r | |
2313 | @return The architecture specific spin lock alignment.\r | |
2314 | \r | |
2315 | **/\r | |
2316 | UINTN\r | |
2317 | EFIAPI\r | |
2318 | GetSpinLockProperties (\r | |
2319 | VOID\r | |
2320 | );\r | |
2321 | \r | |
2322 | /**\r | |
2323 | Initializes a spin lock to the released state and returns the spin lock.\r | |
2324 | \r | |
2325 | This function initializes the spin lock specified by SpinLock to the released\r | |
2326 | state, and returns SpinLock. Optimal performance can be achieved by calling\r | |
2327 | GetSpinLockProperties() to determine the size and alignment requirements for\r | |
2328 | SpinLock.\r | |
2329 | \r | |
2330 | If SpinLock is NULL, then ASSERT().\r | |
2331 | \r | |
2332 | @param SpinLock A pointer to the spin lock to initialize to the released\r | |
2333 | state.\r | |
2334 | \r | |
2335 | @return SpinLock\r | |
2336 | \r | |
2337 | **/\r | |
2338 | SPIN_LOCK *\r | |
2339 | EFIAPI\r | |
2340 | InitializeSpinLock (\r | |
2341 | IN SPIN_LOCK *SpinLock\r | |
2342 | );\r | |
2343 | \r | |
2344 | /**\r | |
2345 | Waits until a spin lock can be placed in the acquired state.\r | |
2346 | \r | |
2347 | This function checks the state of the spin lock specified by SpinLock. If\r | |
2348 | SpinLock is in the released state, then this function places SpinLock in the\r | |
2349 | acquired state and returns SpinLock. Otherwise, this function waits\r | |
2350 | indefinitely for the spin lock to be released, and then places it in the\r | |
2351 | acquired state and returns SpinLock. All state transitions of SpinLock must\r | |
2352 | be performed using MP safe mechanisms.\r | |
2353 | \r | |
2354 | If SpinLock is NULL, then ASSERT().\r | |
2355 | If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().\r | |
2356 | If PcdSpinLockTimeout is not zero, and SpinLock is can not be acquired in\r | |
2357 | PcdSpinLockTimeout microseconds, then ASSERT().\r | |
2358 | \r | |
2359 | @param SpinLock A pointer to the spin lock to place in the acquired state.\r | |
2360 | \r | |
2361 | @return SpinLock\r | |
2362 | \r | |
2363 | **/\r | |
2364 | SPIN_LOCK *\r | |
2365 | EFIAPI\r | |
2366 | AcquireSpinLock (\r | |
2367 | IN SPIN_LOCK *SpinLock\r | |
2368 | );\r | |
2369 | \r | |
2370 | /**\r | |
2371 | Attempts to place a spin lock in the acquired state.\r | |
2372 | \r | |
2373 | This function checks the state of the spin lock specified by SpinLock. If\r | |
2374 | SpinLock is in the released state, then this function places SpinLock in the\r | |
2375 | acquired state and returns TRUE. Otherwise, FALSE is returned. All state\r | |
2376 | transitions of SpinLock must be performed using MP safe mechanisms.\r | |
2377 | \r | |
2378 | If SpinLock is NULL, then ASSERT().\r | |
2379 | If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().\r | |
2380 | \r | |
2381 | @param SpinLock A pointer to the spin lock to place in the acquired state.\r | |
2382 | \r | |
2383 | @retval TRUE SpinLock was placed in the acquired state.\r | |
2384 | @retval FALSE SpinLock could not be acquired.\r | |
2385 | \r | |
2386 | **/\r | |
2387 | BOOLEAN\r | |
2388 | EFIAPI\r | |
2389 | AcquireSpinLockOrFail (\r | |
2390 | IN SPIN_LOCK *SpinLock\r | |
2391 | );\r | |
2392 | \r | |
2393 | /**\r | |
2394 | Releases a spin lock.\r | |
2395 | \r | |
2396 | This function places the spin lock specified by SpinLock in the release state\r | |
2397 | and returns SpinLock.\r | |
2398 | \r | |
2399 | If SpinLock is NULL, then ASSERT().\r | |
2400 | If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().\r | |
2401 | \r | |
2402 | @param SpinLock A pointer to the spin lock to release.\r | |
2403 | \r | |
2404 | @return SpinLock\r | |
2405 | \r | |
2406 | **/\r | |
2407 | SPIN_LOCK *\r | |
2408 | EFIAPI\r | |
2409 | ReleaseSpinLock (\r | |
2410 | IN SPIN_LOCK *SpinLock\r | |
2411 | );\r | |
2412 | \r | |
2413 | /**\r | |
2414 | Performs an atomic increment of an 32-bit unsigned integer.\r | |
2415 | \r | |
2416 | Performs an atomic increment of the 32-bit unsigned integer specified by\r | |
2417 | Value and returns the incremented value. The increment operation must be\r | |
2418 | performed using MP safe mechanisms. The state of the return value is not\r | |
2419 | guaranteed to be MP safe.\r | |
2420 | \r | |
2421 | If Value is NULL, then ASSERT().\r | |
2422 | \r | |
2423 | @param Value A pointer to the 32-bit value to increment.\r | |
2424 | \r | |
2425 | @return The incremented value.\r | |
2426 | \r | |
2427 | **/\r | |
2428 | UINT32\r | |
2429 | EFIAPI\r | |
2430 | InterlockedIncrement (\r | |
2431 | IN UINT32 *Value\r | |
2432 | );\r | |
2433 | \r | |
2434 | /**\r | |
2435 | Performs an atomic decrement of an 32-bit unsigned integer.\r | |
2436 | \r | |
2437 | Performs an atomic decrement of the 32-bit unsigned integer specified by\r | |
2438 | Value and returns the decremented value. The decrement operation must be\r | |
2439 | performed using MP safe mechanisms. The state of the return value is not\r | |
2440 | guaranteed to be MP safe.\r | |
2441 | \r | |
2442 | If Value is NULL, then ASSERT().\r | |
2443 | \r | |
2444 | @param Value A pointer to the 32-bit value to decrement.\r | |
2445 | \r | |
2446 | @return The decremented value.\r | |
2447 | \r | |
2448 | **/\r | |
2449 | UINT32\r | |
2450 | EFIAPI\r | |
2451 | InterlockedDecrement (\r | |
2452 | IN UINT32 *Value\r | |
2453 | );\r | |
2454 | \r | |
2455 | /**\r | |
2456 | Performs an atomic compare exchange operation on a 32-bit unsigned integer.\r | |
2457 | \r | |
2458 | @param Value A pointer to the 32-bit value for the compare exchange\r | |
2459 | operation.\r | |
2460 | @param CompareValue 32-bit value used in compare operation.\r | |
2461 | @param ExchangeValue 32-bit value used in exchange operation.\r | |
2462 | \r | |
2463 | @return The original *Value before exchange.\r | |
2464 | \r | |
2465 | **/\r | |
2466 | UINT32\r | |
2467 | EFIAPI\r | |
2468 | InterlockedCompareExchange32 (\r | |
0ffa1286 | 2469 | IN OUT UINT32 *Value,\r |
878ddf1f | 2470 | IN UINT32 CompareValue,\r |
2471 | IN UINT32 ExchangeValue\r | |
2472 | );\r | |
2473 | \r | |
2474 | /**\r | |
2475 | Performs an atomic compare exchange operation on a 64-bit unsigned integer.\r | |
2476 | \r | |
2477 | @param Value A pointer to the 64-bit value for the compare exchange\r | |
2478 | operation.\r | |
2479 | @param CompareValue 64-bit value used in compare operation.\r | |
2480 | @param ExchangeValue 64-bit value used in exchange operation.\r | |
2481 | \r | |
2482 | @return The original *Value before exchange.\r | |
2483 | \r | |
2484 | **/\r | |
2485 | UINT64\r | |
2486 | EFIAPI\r | |
2487 | InterlockedCompareExchange64 (\r | |
0ffa1286 | 2488 | IN OUT UINT64 *Value,\r |
878ddf1f | 2489 | IN UINT64 CompareValue,\r |
2490 | IN UINT64 ExchangeValue\r | |
2491 | );\r | |
2492 | \r | |
2493 | /**\r | |
2494 | Performs an atomic compare exchange operation on a pointer value.\r | |
2495 | \r | |
2496 | Performs an atomic compare exchange operation on the pointer value specified\r | |
2497 | by Value. If Value is equal to CompareValue, then Value is set to\r | |
2498 | ExchangeValue and CompareValue is returned. If Value is not equal to\r | |
2499 | CompareValue, then Value is returned. The compare exchange operation must be\r | |
2500 | performed using MP safe mechanisms.\r | |
2501 | \r | |
2502 | If Value is NULL, then ASSERT().\r | |
2503 | \r | |
2504 | @param Value A pointer to the pointer value for the compare exchange\r | |
2505 | operation.\r | |
2506 | @param CompareValue Pointer value used in compare operation.\r | |
2507 | @param ExchangeValue Pointer value used in exchange operation.\r | |
2508 | \r | |
2509 | **/\r | |
2510 | VOID *\r | |
2511 | EFIAPI\r | |
2512 | InterlockedCompareExchangePointer (\r | |
0ffa1286 | 2513 | IN OUT VOID **Value,\r |
878ddf1f | 2514 | IN VOID *CompareValue,\r |
2515 | IN VOID *ExchangeValue\r | |
2516 | );\r | |
2517 | \r | |
2518 | //\r | |
2519 | // Base Library CPU Functions\r | |
2520 | //\r | |
2521 | typedef\r | |
2522 | VOID\r | |
2523 | (EFIAPI *SWITCH_STACK_ENTRY_POINT) (\r | |
2524 | IN VOID *Context1, OPTIONAL\r | |
2525 | IN VOID *Context2 OPTIONAL\r | |
2526 | );\r | |
2527 | \r | |
2528 | /**\r | |
2529 | Used to serialize load and store operations.\r | |
2530 | \r | |
2531 | All loads and stores that proceed calls to this function are guaranteed to be\r | |
2532 | globally visible when this function returns.\r | |
2533 | \r | |
2534 | **/\r | |
2535 | VOID\r | |
2536 | EFIAPI\r | |
2537 | MemoryFence (\r | |
2538 | VOID\r | |
2539 | );\r | |
2540 | \r | |
2541 | /**\r | |
2542 | Saves the current CPU context that can be restored with a call to LongJump()\r | |
2543 | and returns 0.\r | |
2544 | \r | |
2545 | Saves the current CPU context in the buffer specified by JumpBuffer and\r | |
2546 | returns 0. The initial call to SetJump() must always return 0. Subsequent\r | |
2547 | calls to LongJump() cause a non-zero value to be returned by SetJump().\r | |
2548 | \r | |
2549 | If JumpBuffer is NULL, then ASSERT().\r | |
2550 | \r | |
2551 | @param JumpBuffer A pointer to CPU context buffer.\r | |
2552 | \r | |
2553 | @retval 0 Indicates a return from SetJump().\r | |
2554 | \r | |
2555 | **/\r | |
2556 | UINTN\r | |
2557 | EFIAPI\r | |
2558 | SetJump (\r | |
2559 | OUT BASE_LIBRARY_JUMP_BUFFER *JumpBuffer\r | |
2560 | );\r | |
2561 | \r | |
2562 | /**\r | |
2563 | Restores the CPU context that was saved with SetJump().\r | |
2564 | \r | |
2565 | Restores the CPU context from the buffer specified by JumpBuffer. This\r | |
2566 | function never returns to the caller. Instead is resumes execution based on\r | |
2567 | the state of JumpBuffer.\r | |
2568 | \r | |
2569 | If JumpBuffer is NULL, then ASSERT().\r | |
2570 | If Value is 0, then ASSERT().\r | |
2571 | \r | |
2572 | @param JumpBuffer A pointer to CPU context buffer.\r | |
2573 | @param Value The value to return when the SetJump() context is\r | |
2574 | restored and must be non-zero.\r | |
2575 | \r | |
2576 | **/\r | |
2577 | VOID\r | |
2578 | EFIAPI\r | |
2579 | LongJump (\r | |
2580 | IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer,\r | |
2581 | IN UINTN Value\r | |
2582 | );\r | |
2583 | \r | |
2584 | /**\r | |
2585 | Enables CPU interrupts.\r | |
2586 | \r | |
2587 | Enables CPU interrupts.\r | |
2588 | \r | |
2589 | **/\r | |
2590 | VOID\r | |
2591 | EFIAPI\r | |
2592 | EnableInterrupts (\r | |
2593 | VOID\r | |
2594 | );\r | |
2595 | \r | |
2596 | /**\r | |
2597 | Disables CPU interrupts.\r | |
2598 | \r | |
2599 | Disables CPU interrupts.\r | |
2600 | \r | |
2601 | **/\r | |
2602 | VOID\r | |
2603 | EFIAPI\r | |
2604 | DisableInterrupts (\r | |
2605 | VOID\r | |
2606 | );\r | |
2607 | \r | |
2608 | /**\r | |
2609 | Disables CPU interrupts and returns the interrupt state prior to the disable\r | |
2610 | operation.\r | |
2611 | \r | |
2612 | Disables CPU interrupts and returns the interrupt state prior to the disable\r | |
2613 | operation.\r | |
2614 | \r | |
2615 | @retval TRUE CPU interrupts were enabled on entry to this call.\r | |
2616 | @retval FALSE CPU interrupts were disabled on entry to this call.\r | |
2617 | \r | |
2618 | **/\r | |
2619 | BOOLEAN\r | |
2620 | EFIAPI\r | |
2621 | SaveAndDisableInterrupts (\r | |
2622 | VOID\r | |
2623 | );\r | |
2624 | \r | |
2625 | /**\r | |
2626 | Enables CPU interrupts for the smallest window required to capture any\r | |
2627 | pending interrupts.\r | |
2628 | \r | |
2629 | Enables CPU interrupts for the smallest window required to capture any\r | |
2630 | pending interrupts.\r | |
2631 | \r | |
2632 | **/\r | |
2633 | VOID\r | |
2634 | EFIAPI\r | |
2635 | EnableDisableInterrupts (\r | |
2636 | VOID\r | |
2637 | );\r | |
2638 | \r | |
2639 | /**\r | |
2640 | Retrieves the current CPU interrupt state.\r | |
2641 | \r | |
2642 | Retrieves the current CPU interrupt state. Returns TRUE is interrupts are\r | |
2643 | currently enabled. Otherwise returns FALSE.\r | |
2644 | \r | |
2645 | @retval TRUE CPU interrupts are enabled.\r | |
2646 | @retval FALSE CPU interrupts are disabled.\r | |
2647 | \r | |
2648 | **/\r | |
2649 | BOOLEAN\r | |
2650 | EFIAPI\r | |
2651 | GetInterruptState (\r | |
2652 | VOID\r | |
2653 | );\r | |
2654 | \r | |
2655 | /**\r | |
2656 | Set the current CPU interrupt state.\r | |
2657 | \r | |
2658 | Sets the current CPU interrupt state to the state specified by\r | |
2659 | InterruptState. If InterruptState is TRUE, then interrupts are enabled. If\r | |
2660 | InterruptState is FALSE, then interrupts are disabled. InterruptState is\r | |
2661 | returned.\r | |
2662 | \r | |
2663 | @param InterruptState TRUE if interrupts should enabled. FALSE if\r | |
2664 | interrupts should be disabled.\r | |
2665 | \r | |
2666 | @return InterruptState\r | |
2667 | \r | |
2668 | **/\r | |
2669 | BOOLEAN\r | |
2670 | EFIAPI\r | |
2671 | SetInterruptState (\r | |
2672 | IN BOOLEAN InterruptState\r | |
2673 | );\r | |
2674 | \r | |
2675 | /**\r | |
2676 | Places the CPU in a sleep state until an interrupt is received.\r | |
2677 | \r | |
2678 | Places the CPU in a sleep state until an interrupt is received. If interrupts\r | |
2679 | are disabled prior to calling this function, then the CPU will be placed in a\r | |
2680 | sleep state indefinitely.\r | |
2681 | \r | |
2682 | **/\r | |
2683 | VOID\r | |
2684 | EFIAPI\r | |
2685 | CpuSleep (\r | |
2686 | VOID\r | |
2687 | );\r | |
2688 | \r | |
2689 | /**\r | |
2690 | Requests CPU to pause for a short period of time.\r | |
2691 | \r | |
2692 | Requests CPU to pause for a short period of time. Typically used in MP\r | |
2693 | systems to prevent memory starvation while waiting for a spin lock.\r | |
2694 | \r | |
2695 | **/\r | |
2696 | VOID\r | |
2697 | EFIAPI\r | |
2698 | CpuPause (\r | |
2699 | VOID\r | |
2700 | );\r | |
2701 | \r | |
2702 | /**\r | |
2703 | Flushes all the Translation Lookaside Buffers(TLB) entries in a CPU.\r | |
2704 | \r | |
2705 | Flushes all the Translation Lookaside Buffers(TLB) entries in a CPU.\r | |
2706 | \r | |
2707 | **/\r | |
2708 | VOID\r | |
2709 | EFIAPI\r | |
2710 | CpuFlushTlb (\r | |
2711 | VOID\r | |
2712 | );\r | |
2713 | \r | |
2714 | /**\r | |
2715 | Transfers control to a function starting with a new stack.\r | |
2716 | \r | |
2717 | Transfers control to the function specified by EntryPoint using the new stack\r | |
2718 | specified by NewStack and passing in the parameters specified by Context1 and\r | |
2719 | Context2. Context1 and Context2 are optional and may be NULL. The function\r | |
2720 | EntryPoint must never return.\r | |
2721 | \r | |
2722 | If EntryPoint is NULL, then ASSERT().\r | |
2723 | If NewStack is NULL, then ASSERT().\r | |
2724 | \r | |
2725 | @param EntryPoint A pointer to function to call with the new stack.\r | |
2726 | @param Context1 A pointer to the context to pass into the EntryPoint\r | |
2727 | function.\r | |
2728 | @param Context2 A pointer to the context to pass into the EntryPoint\r | |
2729 | function.\r | |
2730 | @param NewStack A pointer to the new stack to use for the EntryPoint\r | |
2731 | function.\r | |
2732 | \r | |
2733 | **/\r | |
2734 | VOID\r | |
2735 | EFIAPI\r | |
2736 | SwitchStack (\r | |
2737 | IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r | |
2738 | IN VOID *Context1, OPTIONAL\r | |
2739 | IN VOID *Context2, OPTIONAL\r | |
2740 | IN VOID *NewStack\r | |
2741 | );\r | |
2742 | \r | |
2743 | /**\r | |
2744 | Generates a breakpoint on the CPU.\r | |
2745 | \r | |
2746 | Generates a breakpoint on the CPU. The breakpoint must be implemented such\r | |
2747 | that code can resume normal execution after the breakpoint.\r | |
2748 | \r | |
2749 | **/\r | |
2750 | VOID\r | |
2751 | EFIAPI\r | |
2752 | CpuBreakpoint (\r | |
2753 | VOID\r | |
2754 | );\r | |
2755 | \r | |
2756 | /**\r | |
2757 | Executes an infinite loop.\r | |
2758 | \r | |
2759 | Forces the CPU to execute an infinite loop. A debugger may be used to skip\r | |
2760 | past the loop and the code that follows the loop must execute properly. This\r | |
2761 | implies that the infinite loop must not cause the code that follow it to be\r | |
2762 | optimized away.\r | |
2763 | \r | |
2764 | **/\r | |
2765 | VOID\r | |
2766 | EFIAPI\r | |
2767 | CpuDeadLoop (\r | |
2768 | VOID\r | |
2769 | );\r | |
2770 | \r | |
2771 | //\r | |
2772 | // IA32 and X64 Specific Functions\r | |
2773 | //\r | |
2774 | //\r | |
2775 | // Byte packed structure for 16-bit Real Mode EFLAGS\r | |
2776 | //\r | |
2777 | typedef union {\r | |
2778 | struct {\r | |
2779 | UINT32 CF:1; // Carry Flag\r | |
2780 | UINT32 Reserved_0:1; // Reserved\r | |
2781 | UINT32 PF:1; // Parity Flag\r | |
2782 | UINT32 Reserved_1:1; // Reserved\r | |
2783 | UINT32 AF:1; // Auxiliary Carry Flag\r | |
2784 | UINT32 Reserved_2:1; // Reserved\r | |
2785 | UINT32 ZF:1; // Zero Flag\r | |
2786 | UINT32 SF:1; // Sign Flag\r | |
2787 | UINT32 TF:1; // Trap Flag\r | |
2788 | UINT32 IF:1; // Interrupt Enable Flag\r | |
2789 | UINT32 DF:1; // Direction Flag\r | |
2790 | UINT32 OF:1; // Overflow Flag\r | |
2791 | UINT32 IOPL:2; // I/O Privilege Level\r | |
2792 | UINT32 NT:1; // Nested Task\r | |
2793 | UINT32 Reserved_3:1; // Reserved\r | |
2794 | } Bits;\r | |
2795 | UINT16 Uint16;\r | |
2796 | } IA32_FLAGS16;\r | |
2797 | \r | |
2798 | //\r | |
2799 | // Byte packed structure for EFLAGS/RFLAGS\r | |
2800 | // 32-bits on IA-32\r | |
2801 | // 64-bits on X64. The upper 32-bits on X64 are reserved\r | |
2802 | //\r | |
2803 | typedef union {\r | |
2804 | struct {\r | |
2805 | UINT32 CF:1; // Carry Flag\r | |
2806 | UINT32 Reserved_0:1; // Reserved\r | |
2807 | UINT32 PF:1; // Parity Flag\r | |
2808 | UINT32 Reserved_1:1; // Reserved\r | |
2809 | UINT32 AF:1; // Auxiliary Carry Flag\r | |
2810 | UINT32 Reserved_2:1; // Reserved\r | |
2811 | UINT32 ZF:1; // Zero Flag\r | |
2812 | UINT32 SF:1; // Sign Flag\r | |
2813 | UINT32 TF:1; // Trap Flag\r | |
2814 | UINT32 IF:1; // Interrupt Enable Flag\r | |
2815 | UINT32 DF:1; // Direction Flag\r | |
2816 | UINT32 OF:1; // Overflow Flag\r | |
2817 | UINT32 IOPL:2; // I/O Privilege Level\r | |
2818 | UINT32 NT:1; // Nested Task\r | |
2819 | UINT32 Reserved_3:1; // Reserved\r | |
2820 | UINT32 RF:1; // Resume Flag\r | |
2821 | UINT32 VM:1; // Virtual 8086 Mode\r | |
2822 | UINT32 AC:1; // Alignment Check\r | |
2823 | UINT32 VIF:1; // Virtual Interrupt Flag\r | |
2824 | UINT32 VIP:1; // Virtual Interrupt Pending\r | |
2825 | UINT32 ID:1; // ID Flag\r | |
2826 | UINT32 Reserved_4:10; // Reserved\r | |
2827 | } Bits;\r | |
2828 | UINTN UintN;\r | |
2829 | } IA32_EFLAGS32;\r | |
2830 | \r | |
2831 | //\r | |
2832 | // Byte packed structure for Control Register 0 (CR0)\r | |
2833 | // 32-bits on IA-32\r | |
2834 | // 64-bits on X64. The upper 32-bits on X64 are reserved\r | |
2835 | //\r | |
2836 | typedef union {\r | |
2837 | struct {\r | |
2838 | UINT32 PE:1; // Protection Enable\r | |
2839 | UINT32 MP:1; // Monitor Coprocessor\r | |
2840 | UINT32 EM:1; // Emulation\r | |
2841 | UINT32 TS:1; // Task Switched\r | |
2842 | UINT32 ET:1; // Extension Type\r | |
2843 | UINT32 NE:1; // Numeric Error\r | |
2844 | UINT32 Reserved_0:10; // Reserved\r | |
2845 | UINT32 WP:1; // Write Protect\r | |
2846 | UINT32 Reserved_1:1; // Reserved\r | |
2847 | UINT32 AM:1; // Alignment Mask\r | |
2848 | UINT32 Reserved_2:10; // Reserved\r | |
2849 | UINT32 NW:1; // Mot Write-through\r | |
2850 | UINT32 CD:1; // Cache Disable\r | |
2851 | UINT32 PG:1; // Paging\r | |
2852 | } Bits;\r | |
2853 | UINTN UintN;\r | |
2854 | } IA32_CR0;\r | |
2855 | \r | |
2856 | //\r | |
2857 | // Byte packed structure for Control Register 4 (CR4)\r | |
2858 | // 32-bits on IA-32\r | |
2859 | // 64-bits on X64. The upper 32-bits on X64 are reserved\r | |
2860 | //\r | |
2861 | typedef union {\r | |
2862 | struct {\r | |
2863 | UINT32 VME:1; // Virtual-8086 Mode Extensions\r | |
2864 | UINT32 PVI:1; // Protected-Mode Virtual Interrupts\r | |
2865 | UINT32 TSD:1; // Time Stamp Disable\r | |
2866 | UINT32 DE:1; // Debugging Extensions\r | |
2867 | UINT32 PSE:1; // Page Size Extensions\r | |
2868 | UINT32 PAE:1; // Physical Address Extension\r | |
2869 | UINT32 MCE:1; // Machine Check Enable\r | |
2870 | UINT32 PGE:1; // Page Global Enable\r | |
2871 | UINT32 PCE:1; // Performance Monitoring Counter\r | |
2872 | // Enable\r | |
2873 | UINT32 OSFXSR:1; // Operating System Support for\r | |
2874 | // FXSAVE and FXRSTOR instructions\r | |
2875 | UINT32 OSXMMEXCPT:1; // Operating System Support for\r | |
2876 | // Unmasked SIMD Floating Point\r | |
2877 | // Exceptions\r | |
2878 | UINT32 Reserved_0:2; // Reserved\r | |
2879 | UINT32 VMXE:1; // VMX Enable\r | |
2880 | UINT32 Reserved_1:18; // Reseved\r | |
2881 | } Bits;\r | |
2882 | UINTN UintN;\r | |
2883 | } IA32_CR4;\r | |
2884 | \r | |
2885 | //\r | |
2886 | // Byte packed structure for an IDTR, GDTR, LDTR descriptor\r | |
4cbd2175 | 2887 | /// @bug How to make this structure byte-packed in a compiler independent way?\r |
878ddf1f | 2888 | //\r |
2889 | typedef struct {\r | |
2890 | UINT16 Limit;\r | |
2891 | UINTN Base;\r | |
2892 | } IA32_DESCRIPTOR;\r | |
2893 | \r | |
2894 | #define IA32_IDT_GATE_TYPE_TASK 0x85\r | |
2895 | #define IA32_IDT_GATE_TYPE_INTERRUPT_16 0x86\r | |
2896 | #define IA32_IDT_GATE_TYPE_TRAP_16 0x87\r | |
2897 | #define IA32_IDT_GATE_TYPE_INTERRUPT_32 0x8E\r | |
2898 | #define IA32_IDT_GATE_TYPE_TRAP_32 0x8F\r | |
2899 | \r | |
2900 | //\r | |
2901 | // Byte packed structure for an Interrupt Gate Descriptor\r | |
2902 | //\r | |
2903 | typedef union {\r | |
2904 | struct {\r | |
2905 | UINT32 OffsetLow:16; // Offset bits 15..0\r | |
2906 | UINT32 Selector:16; // Selector\r | |
2907 | UINT32 Reserved_0:8; // Reserved\r | |
2908 | UINT32 GateType:8; // Gate Type. See #defines above\r | |
2909 | UINT32 OffsetHigh:16; // Offset bits 31..16\r | |
2910 | } Bits;\r | |
2911 | UINT64 Uint64;\r | |
2912 | } IA32_IDT_GATE_DESCRIPTOR;\r | |
2913 | \r | |
2914 | //\r | |
2915 | // Byte packed structure for an FP/SSE/SSE2 context\r | |
2916 | //\r | |
2917 | typedef struct {\r | |
2918 | UINT8 Buffer[512];\r | |
2919 | } IA32_FX_BUFFER;\r | |
2920 | \r | |
2921 | //\r | |
2922 | // Structures for the 16-bit real mode thunks\r | |
2923 | //\r | |
2924 | typedef struct {\r | |
2925 | UINT32 Reserved1;\r | |
2926 | UINT32 Reserved2;\r | |
2927 | UINT32 Reserved3;\r | |
2928 | UINT32 Reserved4;\r | |
2929 | UINT8 BL;\r | |
2930 | UINT8 BH;\r | |
2931 | UINT16 Reserved5;\r | |
2932 | UINT8 DL;\r | |
2933 | UINT8 DH;\r | |
2934 | UINT16 Reserved6;\r | |
2935 | UINT8 CL;\r | |
2936 | UINT8 CH;\r | |
2937 | UINT16 Reserved7;\r | |
2938 | UINT8 AL;\r | |
2939 | UINT8 AH;\r | |
2940 | UINT16 Reserved8;\r | |
2941 | } IA32_BYTE_REGS;\r | |
2942 | \r | |
2943 | typedef struct {\r | |
2944 | UINT16 DI;\r | |
2945 | UINT16 Reserved1;\r | |
2946 | UINT16 SI;\r | |
2947 | UINT16 Reserved2;\r | |
2948 | UINT16 BP;\r | |
2949 | UINT16 Reserved3;\r | |
2950 | UINT16 SP;\r | |
2951 | UINT16 Reserved4;\r | |
2952 | UINT16 BX;\r | |
2953 | UINT16 Reserved5;\r | |
2954 | UINT16 DX;\r | |
2955 | UINT16 Reserved6;\r | |
2956 | UINT16 CX;\r | |
2957 | UINT16 Reserved7;\r | |
2958 | UINT16 AX;\r | |
2959 | UINT16 Reserved8;\r | |
2960 | } IA32_WORD_REGS;\r | |
2961 | \r | |
2962 | typedef struct {\r | |
2963 | UINT32 EDI;\r | |
2964 | UINT32 ESI;\r | |
2965 | UINT32 EBP;\r | |
2966 | UINT32 ESP;\r | |
2967 | UINT32 EBX;\r | |
2968 | UINT32 EDX;\r | |
2969 | UINT32 ECX;\r | |
2970 | UINT32 EAX;\r | |
2971 | UINT16 DS;\r | |
2972 | UINT16 ES;\r | |
2973 | UINT16 FS;\r | |
2974 | UINT16 GS;\r | |
2975 | IA32_EFLAGS32 EFLAGS;\r | |
2976 | UINT32 Eip;\r | |
2977 | UINT16 CS;\r | |
2978 | UINT16 SS;\r | |
2979 | } IA32_DWORD_REGS;\r | |
2980 | \r | |
2981 | typedef union {\r | |
2982 | IA32_DWORD_REGS E;\r | |
2983 | IA32_WORD_REGS X;\r | |
2984 | IA32_BYTE_REGS H;\r | |
2985 | } IA32_REGISTER_SET;\r | |
2986 | \r | |
2987 | //\r | |
2988 | // Byte packed structure for an 16-bit real mode thunks\r | |
2989 | //\r | |
2990 | typedef struct {\r | |
97d92bda | 2991 | IA32_REGISTER_SET *RealModeState;\r |
878ddf1f | 2992 | VOID *RealModeBuffer;\r |
97d92bda | 2993 | UINT32 RealModeBufferSize;\r |
2994 | UINT32 ThunkAttributes;\r | |
878ddf1f | 2995 | } THUNK_CONTEXT;\r |
2996 | \r | |
97d92bda | 2997 | #define THUNK_ATTRIBUTE_BIG_REAL_MODE 0x00000001\r |
2998 | #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 0x00000002\r | |
2999 | #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004\r | |
3000 | \r | |
878ddf1f | 3001 | /**\r |
3002 | Retrieves CPUID information.\r | |
3003 | \r | |
3004 | Executes the CPUID instruction with EAX set to the value specified by Index.\r | |
3005 | This function always returns Index.\r | |
3006 | If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.\r | |
3007 | If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.\r | |
3008 | If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.\r | |
3009 | If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.\r | |
3010 | This function is only available on IA-32 and X64.\r | |
3011 | \r | |
3012 | @param Index The 32-bit value to load into EAX prior to invoking the CPUID\r | |
3013 | instruction.\r | |
3014 | @param Eax Pointer to the 32-bit EAX value returned by the CPUID\r | |
3015 | instruction. This is an optional parameter that may be NULL.\r | |
3016 | @param Ebx Pointer to the 32-bit EBX value returned by the CPUID\r | |
3017 | instruction. This is an optional parameter that may be NULL.\r | |
3018 | @param Ecx Pointer to the 32-bit ECX value returned by the CPUID\r | |
3019 | instruction. This is an optional parameter that may be NULL.\r | |
3020 | @param Edx Pointer to the 32-bit EDX value returned by the CPUID\r | |
3021 | instruction. This is an optional parameter that may be NULL.\r | |
3022 | \r | |
3023 | @return Index\r | |
3024 | \r | |
3025 | **/\r | |
3026 | UINT32\r | |
3027 | EFIAPI\r | |
3028 | AsmCpuid (\r | |
3029 | IN UINT32 Index,\r | |
3030 | OUT UINT32 *Eax, OPTIONAL\r | |
3031 | OUT UINT32 *Ebx, OPTIONAL\r | |
3032 | OUT UINT32 *Ecx, OPTIONAL\r | |
3033 | OUT UINT32 *Edx OPTIONAL\r | |
3034 | );\r | |
3035 | \r | |
dee4740a | 3036 | /**\r |
3037 | Retrieves CPUID information using an extended leaf identifier.\r | |
3038 | \r | |
3039 | Executes the CPUID instruction with EAX set to the value specified by Index\r | |
3040 | and ECX set to the value specified by SubIndex. This function always returns\r | |
3041 | Index. This function is only available on IA-32 and x64.\r | |
3042 | \r | |
3043 | If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.\r | |
3044 | If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.\r | |
3045 | If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.\r | |
3046 | If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.\r | |
3047 | \r | |
3048 | @param Index The 32-bit value to load into EAX prior to invoking the\r | |
3049 | CPUID instruction.\r | |
3050 | @param SubIndex The 32-bit value to load into ECX prior to invoking the\r | |
3051 | CPUID instruction.\r | |
3052 | @param Eax Pointer to the 32-bit EAX value returned by the CPUID\r | |
3053 | instruction. This is an optional parameter that may be\r | |
3054 | NULL.\r | |
3055 | @param Ebx Pointer to the 32-bit EBX value returned by the CPUID\r | |
3056 | instruction. This is an optional parameter that may be\r | |
3057 | NULL.\r | |
3058 | @param Ecx Pointer to the 32-bit ECX value returned by the CPUID\r | |
3059 | instruction. This is an optional parameter that may be\r | |
3060 | NULL.\r | |
3061 | @param Edx Pointer to the 32-bit EDX value returned by the CPUID\r | |
3062 | instruction. This is an optional parameter that may be\r | |
3063 | NULL.\r | |
3064 | \r | |
3065 | @return Index\r | |
3066 | \r | |
3067 | **/\r | |
3068 | UINT32\r | |
3069 | EFIAPI\r | |
3070 | AsmCpuidEx (\r | |
3071 | IN UINT32 Index,\r | |
3072 | IN UINT32 SubIndex,\r | |
3073 | OUT UINT32 *Eax, OPTIONAL\r | |
3074 | OUT UINT32 *Ebx, OPTIONAL\r | |
3075 | OUT UINT32 *Ecx, OPTIONAL\r | |
3076 | OUT UINT32 *Edx OPTIONAL\r | |
3077 | );\r | |
3078 | \r | |
878ddf1f | 3079 | /**\r |
3080 | Returns the lower 32-bits of a Machine Specific Register(MSR).\r | |
3081 | \r | |
3082 | Reads and returns the lower 32-bits of the MSR specified by Index.\r | |
3083 | No parameter checking is performed on Index, and some Index values may cause\r | |
3084 | CPU exceptions. The caller must either guarantee that Index is valid, or the\r | |
3085 | caller must set up exception handlers to catch the exceptions. This function\r | |
3086 | is only available on IA-32 and X64.\r | |
3087 | \r | |
3088 | @param Index The 32-bit MSR index to read.\r | |
3089 | \r | |
3090 | @return The lower 32 bits of the MSR identified by Index.\r | |
3091 | \r | |
3092 | **/\r | |
3093 | UINT32\r | |
3094 | EFIAPI\r | |
3095 | AsmReadMsr32 (\r | |
3096 | IN UINT32 Index\r | |
3097 | );\r | |
3098 | \r | |
3099 | /**\r | |
3100 | Zero-extend a 32-bit value and writes it to a Machine Specific Register(MSR).\r | |
3101 | \r | |
3102 | Writes the 32-bit value specified by Value to the MSR specified by Index. The\r | |
3103 | upper 32-bits of the MSR write are set to zero. The 32-bit value written to\r | |
3104 | the MSR is returned. No parameter checking is performed on Index or Value,\r | |
3105 | and some of these may cause CPU exceptions. The caller must either guarantee\r | |
3106 | that Index and Value are valid, or the caller must establish proper exception\r | |
3107 | handlers. This function is only available on IA-32 and X64.\r | |
3108 | \r | |
3109 | @param Index The 32-bit MSR index to write.\r | |
3110 | @param Value The 32-bit value to write to the MSR.\r | |
3111 | \r | |
3112 | @return Value\r | |
3113 | \r | |
3114 | **/\r | |
3115 | UINT32\r | |
3116 | EFIAPI\r | |
3117 | AsmWriteMsr32 (\r | |
3118 | IN UINT32 Index,\r | |
3119 | IN UINT32 Value\r | |
3120 | );\r | |
3121 | \r | |
3122 | /**\r | |
3123 | Reads a 64-bit MSR, performs a bitwise inclusive OR on the lower 32-bits, and\r | |
3124 | writes the result back to the 64-bit MSR.\r | |
3125 | \r | |
3126 | Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR\r | |
3127 | between the lower 32-bits of the read result and the value specified by\r | |
3128 | OrData, and writes the result to the 64-bit MSR specified by Index. The lower\r | |
3129 | 32-bits of the value written to the MSR is returned. No parameter checking is\r | |
3130 | performed on Index or OrData, and some of these may cause CPU exceptions. The\r | |
3131 | caller must either guarantee that Index and OrData are valid, or the caller\r | |
3132 | must establish proper exception handlers. This function is only available on\r | |
3133 | IA-32 and X64.\r | |
3134 | \r | |
3135 | @param Index The 32-bit MSR index to write.\r | |
3136 | @param OrData The value to OR with the read value from the MSR.\r | |
3137 | \r | |
3138 | @return The lower 32-bit value written to the MSR.\r | |
3139 | \r | |
3140 | **/\r | |
3141 | UINT32\r | |
3142 | EFIAPI\r | |
3143 | AsmMsrOr32 (\r | |
3144 | IN UINT32 Index,\r | |
3145 | IN UINT32 OrData\r | |
3146 | );\r | |
3147 | \r | |
3148 | /**\r | |
3149 | Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes\r | |
3150 | the result back to the 64-bit MSR.\r | |
3151 | \r | |
3152 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r | |
3153 | lower 32-bits of the read result and the value specified by AndData, and\r | |
3154 | writes the result to the 64-bit MSR specified by Index. The lower 32-bits of\r | |
3155 | the value written to the MSR is returned. No parameter checking is performed\r | |
3156 | on Index or AndData, and some of these may cause CPU exceptions. The caller\r | |
3157 | must either guarantee that Index and AndData are valid, or the caller must\r | |
3158 | establish proper exception handlers. This function is only available on IA-32\r | |
3159 | and X64.\r | |
3160 | \r | |
3161 | @param Index The 32-bit MSR index to write.\r | |
3162 | @param AndData The value to AND with the read value from the MSR.\r | |
3163 | \r | |
3164 | @return The lower 32-bit value written to the MSR.\r | |
3165 | \r | |
3166 | **/\r | |
3167 | UINT32\r | |
3168 | EFIAPI\r | |
3169 | AsmMsrAnd32 (\r | |
3170 | IN UINT32 Index,\r | |
3171 | IN UINT32 AndData\r | |
3172 | );\r | |
3173 | \r | |
3174 | /**\r | |
3175 | Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive OR\r | |
3176 | on the lower 32-bits, and writes the result back to the 64-bit MSR.\r | |
3177 | \r | |
3178 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r | |
3179 | lower 32-bits of the read result and the value specified by AndData\r | |
3180 | preserving the upper 32-bits, performs a bitwise inclusive OR between the\r | |
3181 | result of the AND operation and the value specified by OrData, and writes the\r | |
3182 | result to the 64-bit MSR specified by Address. The lower 32-bits of the value\r | |
3183 | written to the MSR is returned. No parameter checking is performed on Index,\r | |
3184 | AndData, or OrData, and some of these may cause CPU exceptions. The caller\r | |
3185 | must either guarantee that Index, AndData, and OrData are valid, or the\r | |
3186 | caller must establish proper exception handlers. This function is only\r | |
3187 | available on IA-32 and X64.\r | |
3188 | \r | |
3189 | @param Index The 32-bit MSR index to write.\r | |
3190 | @param AndData The value to AND with the read value from the MSR.\r | |
3191 | @param OrData The value to OR with the result of the AND operation.\r | |
3192 | \r | |
3193 | @return The lower 32-bit value written to the MSR.\r | |
3194 | \r | |
3195 | **/\r | |
3196 | UINT32\r | |
3197 | EFIAPI\r | |
3198 | AsmMsrAndThenOr32 (\r | |
3199 | IN UINT32 Index,\r | |
3200 | IN UINT32 AndData,\r | |
3201 | IN UINT32 OrData\r | |
3202 | );\r | |
3203 | \r | |
3204 | /**\r | |
3205 | Reads a bit field of an MSR.\r | |
3206 | \r | |
3207 | Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is\r | |
3208 | specified by the StartBit and the EndBit. The value of the bit field is\r | |
3209 | returned. The caller must either guarantee that Index is valid, or the caller\r | |
3210 | must set up exception handlers to catch the exceptions. This function is only\r | |
3211 | available on IA-32 and X64.\r | |
3212 | \r | |
3213 | If StartBit is greater than 31, then ASSERT().\r | |
3214 | If EndBit is greater than 31, then ASSERT().\r | |
0ffa1286 | 3215 | If EndBit is less than StartBit, then ASSERT().\r |
878ddf1f | 3216 | \r |
3217 | @param Index The 32-bit MSR index to read.\r | |
3218 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
3219 | Range 0..31.\r | |
3220 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
3221 | Range 0..31.\r | |
3222 | \r | |
3223 | @return The bit field read from the MSR.\r | |
3224 | \r | |
3225 | **/\r | |
3226 | UINT32\r | |
3227 | EFIAPI\r | |
3228 | AsmMsrBitFieldRead32 (\r | |
3229 | IN UINT32 Index,\r | |
3230 | IN UINTN StartBit,\r | |
3231 | IN UINTN EndBit\r | |
3232 | );\r | |
3233 | \r | |
3234 | /**\r | |
3235 | Writes a bit field to an MSR.\r | |
3236 | \r | |
3237 | Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit\r | |
3238 | field is specified by the StartBit and the EndBit. All other bits in the\r | |
3239 | destination MSR are preserved. The lower 32-bits of the MSR written is\r | |
3240 | returned. Extra left bits in Value are stripped. The caller must either\r | |
3241 | guarantee that Index and the data written is valid, or the caller must set up\r | |
3242 | exception handlers to catch the exceptions. This function is only available\r | |
3243 | on IA-32 and X64.\r | |
3244 | \r | |
3245 | If StartBit is greater than 31, then ASSERT().\r | |
3246 | If EndBit is greater than 31, then ASSERT().\r | |
0ffa1286 | 3247 | If EndBit is less than StartBit, then ASSERT().\r |
878ddf1f | 3248 | \r |
3249 | @param Index The 32-bit MSR index to write.\r | |
3250 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
3251 | Range 0..31.\r | |
3252 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
3253 | Range 0..31.\r | |
3254 | @param Value New value of the bit field.\r | |
3255 | \r | |
3256 | @return The lower 32-bit of the value written to the MSR.\r | |
3257 | \r | |
3258 | **/\r | |
3259 | UINT32\r | |
3260 | EFIAPI\r | |
3261 | AsmMsrBitFieldWrite32 (\r | |
3262 | IN UINT32 Index,\r | |
3263 | IN UINTN StartBit,\r | |
3264 | IN UINTN EndBit,\r | |
3265 | IN UINT32 Value\r | |
3266 | );\r | |
3267 | \r | |
3268 | /**\r | |
3269 | Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the\r | |
3270 | result back to the bit field in the 64-bit MSR.\r | |
3271 | \r | |
3272 | Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR\r | |
3273 | between the read result and the value specified by OrData, and writes the\r | |
3274 | result to the 64-bit MSR specified by Index. The lower 32-bits of the value\r | |
3275 | written to the MSR are returned. Extra left bits in OrData are stripped. The\r | |
3276 | caller must either guarantee that Index and the data written is valid, or\r | |
3277 | the caller must set up exception handlers to catch the exceptions. This\r | |
3278 | function is only available on IA-32 and X64.\r | |
3279 | \r | |
3280 | If StartBit is greater than 31, then ASSERT().\r | |
3281 | If EndBit is greater than 31, then ASSERT().\r | |
0ffa1286 | 3282 | If EndBit is less than StartBit, then ASSERT().\r |
878ddf1f | 3283 | \r |
3284 | @param Index The 32-bit MSR index to write.\r | |
3285 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
3286 | Range 0..31.\r | |
3287 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
3288 | Range 0..31.\r | |
3289 | @param OrData The value to OR with the read value from the MSR.\r | |
3290 | \r | |
3291 | @return The lower 32-bit of the value written to the MSR.\r | |
3292 | \r | |
3293 | **/\r | |
3294 | UINT32\r | |
3295 | EFIAPI\r | |
3296 | AsmMsrBitFieldOr32 (\r | |
3297 | IN UINT32 Index,\r | |
3298 | IN UINTN StartBit,\r | |
3299 | IN UINTN EndBit,\r | |
3300 | IN UINT32 OrData\r | |
3301 | );\r | |
3302 | \r | |
3303 | /**\r | |
3304 | Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the\r | |
3305 | result back to the bit field in the 64-bit MSR.\r | |
3306 | \r | |
3307 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r | |
3308 | read result and the value specified by AndData, and writes the result to the\r | |
3309 | 64-bit MSR specified by Index. The lower 32-bits of the value written to the\r | |
3310 | MSR are returned. Extra left bits in AndData are stripped. The caller must\r | |
3311 | either guarantee that Index and the data written is valid, or the caller must\r | |
3312 | set up exception handlers to catch the exceptions. This function is only\r | |
3313 | available on IA-32 and X64.\r | |
3314 | \r | |
3315 | If StartBit is greater than 31, then ASSERT().\r | |
3316 | If EndBit is greater than 31, then ASSERT().\r | |
0ffa1286 | 3317 | If EndBit is less than StartBit, then ASSERT().\r |
878ddf1f | 3318 | \r |
3319 | @param Index The 32-bit MSR index to write.\r | |
3320 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
3321 | Range 0..31.\r | |
3322 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
3323 | Range 0..31.\r | |
3324 | @param AndData The value to AND with the read value from the MSR.\r | |
3325 | \r | |
3326 | @return The lower 32-bit of the value written to the MSR.\r | |
3327 | \r | |
3328 | **/\r | |
3329 | UINT32\r | |
3330 | EFIAPI\r | |
3331 | AsmMsrBitFieldAnd32 (\r | |
3332 | IN UINT32 Index,\r | |
3333 | IN UINTN StartBit,\r | |
3334 | IN UINTN EndBit,\r | |
3335 | IN UINT32 AndData\r | |
3336 | );\r | |
3337 | \r | |
3338 | /**\r | |
3339 | Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a\r | |
3340 | bitwise inclusive OR, and writes the result back to the bit field in the\r | |
3341 | 64-bit MSR.\r | |
3342 | \r | |
3343 | Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a\r | |
3344 | bitwise inclusive OR between the read result and the value specified by\r | |
3345 | AndData, and writes the result to the 64-bit MSR specified by Index. The\r | |
3346 | lower 32-bits of the value written to the MSR are returned. Extra left bits\r | |
3347 | in both AndData and OrData are stripped. The caller must either guarantee\r | |
3348 | that Index and the data written is valid, or the caller must set up exception\r | |
3349 | handlers to catch the exceptions. This function is only available on IA-32\r | |
3350 | and X64.\r | |
3351 | \r | |
3352 | If StartBit is greater than 31, then ASSERT().\r | |
3353 | If EndBit is greater than 31, then ASSERT().\r | |
0ffa1286 | 3354 | If EndBit is less than StartBit, then ASSERT().\r |
878ddf1f | 3355 | \r |
3356 | @param Index The 32-bit MSR index to write.\r | |
3357 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
3358 | Range 0..31.\r | |
3359 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
3360 | Range 0..31.\r | |
3361 | @param AndData The value to AND with the read value from the MSR.\r | |
3362 | @param OrData The value to OR with the result of the AND operation.\r | |
3363 | \r | |
3364 | @return The lower 32-bit of the value written to the MSR.\r | |
3365 | \r | |
3366 | **/\r | |
3367 | UINT32\r | |
3368 | EFIAPI\r | |
3369 | AsmMsrBitFieldAndThenOr32 (\r | |
3370 | IN UINT32 Index,\r | |
3371 | IN UINTN StartBit,\r | |
3372 | IN UINTN EndBit,\r | |
3373 | IN UINT32 AndData,\r | |
3374 | IN UINT32 OrData\r | |
3375 | );\r | |
3376 | \r | |
3377 | /**\r | |
3378 | Returns a 64-bit Machine Specific Register(MSR).\r | |
3379 | \r | |
3380 | Reads and returns the 64-bit MSR specified by Index. No parameter checking is\r | |
3381 | performed on Index, and some Index values may cause CPU exceptions. The\r | |
3382 | caller must either guarantee that Index is valid, or the caller must set up\r | |
3383 | exception handlers to catch the exceptions. This function is only available\r | |
3384 | on IA-32 and X64.\r | |
3385 | \r | |
3386 | @param Index The 32-bit MSR index to read.\r | |
3387 | \r | |
3388 | @return The value of the MSR identified by Index.\r | |
3389 | \r | |
3390 | **/\r | |
3391 | UINT64\r | |
3392 | EFIAPI\r | |
3393 | AsmReadMsr64 (\r | |
3394 | IN UINT32 Index\r | |
3395 | );\r | |
3396 | \r | |
3397 | /**\r | |
3398 | Writes a 64-bit value to a Machine Specific Register(MSR), and returns the\r | |
3399 | value.\r | |
3400 | \r | |
3401 | Writes the 64-bit value specified by Value to the MSR specified by Index. The\r | |
3402 | 64-bit value written to the MSR is returned. No parameter checking is\r | |
3403 | performed on Index or Value, and some of these may cause CPU exceptions. The\r | |
3404 | caller must either guarantee that Index and Value are valid, or the caller\r | |
3405 | must establish proper exception handlers. This function is only available on\r | |
3406 | IA-32 and X64.\r | |
3407 | \r | |
3408 | @param Index The 32-bit MSR index to write.\r | |
3409 | @param Value The 64-bit value to write to the MSR.\r | |
3410 | \r | |
3411 | @return Value\r | |
3412 | \r | |
3413 | **/\r | |
3414 | UINT64\r | |
3415 | EFIAPI\r | |
3416 | AsmWriteMsr64 (\r | |
3417 | IN UINT32 Index,\r | |
3418 | IN UINT64 Value\r | |
3419 | );\r | |
3420 | \r | |
3421 | /**\r | |
3422 | Reads a 64-bit MSR, performs a bitwise inclusive OR, and writes the result\r | |
3423 | back to the 64-bit MSR.\r | |
3424 | \r | |
3425 | Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR\r | |
3426 | between the read result and the value specified by OrData, and writes the\r | |
3427 | result to the 64-bit MSR specified by Index. The value written to the MSR is\r | |
3428 | returned. No parameter checking is performed on Index or OrData, and some of\r | |
3429 | these may cause CPU exceptions. The caller must either guarantee that Index\r | |
3430 | and OrData are valid, or the caller must establish proper exception handlers.\r | |
3431 | This function is only available on IA-32 and X64.\r | |
3432 | \r | |
3433 | @param Index The 32-bit MSR index to write.\r | |
3434 | @param OrData The value to OR with the read value from the MSR.\r | |
3435 | \r | |
3436 | @return The value written back to the MSR.\r | |
3437 | \r | |
3438 | **/\r | |
3439 | UINT64\r | |
3440 | EFIAPI\r | |
3441 | AsmMsrOr64 (\r | |
3442 | IN UINT32 Index,\r | |
3443 | IN UINT64 OrData\r | |
3444 | );\r | |
3445 | \r | |
3446 | /**\r | |
3447 | Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the\r | |
3448 | 64-bit MSR.\r | |
3449 | \r | |
3450 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r | |
3451 | read result and the value specified by OrData, and writes the result to the\r | |
3452 | 64-bit MSR specified by Index. The value written to the MSR is returned. No\r | |
3453 | parameter checking is performed on Index or OrData, and some of these may\r | |
3454 | cause CPU exceptions. The caller must either guarantee that Index and OrData\r | |
3455 | are valid, or the caller must establish proper exception handlers. This\r | |
3456 | function is only available on IA-32 and X64.\r | |
3457 | \r | |
3458 | @param Index The 32-bit MSR index to write.\r | |
3459 | @param AndData The value to AND with the read value from the MSR.\r | |
3460 | \r | |
3461 | @return The value written back to the MSR.\r | |
3462 | \r | |
3463 | **/\r | |
3464 | UINT64\r | |
3465 | EFIAPI\r | |
3466 | AsmMsrAnd64 (\r | |
3467 | IN UINT32 Index,\r | |
3468 | IN UINT64 AndData\r | |
3469 | );\r | |
3470 | \r | |
3471 | /**\r | |
3472 | Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive\r | |
3473 | OR, and writes the result back to the 64-bit MSR.\r | |
3474 | \r | |
3475 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between read\r | |
3476 | result and the value specified by AndData, performs a bitwise inclusive OR\r | |
3477 | between the result of the AND operation and the value specified by OrData,\r | |
3478 | and writes the result to the 64-bit MSR specified by Index. The value written\r | |
3479 | to the MSR is returned. No parameter checking is performed on Index, AndData,\r | |
3480 | or OrData, and some of these may cause CPU exceptions. The caller must either\r | |
3481 | guarantee that Index, AndData, and OrData are valid, or the caller must\r | |
3482 | establish proper exception handlers. This function is only available on IA-32\r | |
3483 | and X64.\r | |
3484 | \r | |
3485 | @param Index The 32-bit MSR index to write.\r | |
3486 | @param AndData The value to AND with the read value from the MSR.\r | |
3487 | @param OrData The value to OR with the result of the AND operation.\r | |
3488 | \r | |
3489 | @return The value written back to the MSR.\r | |
3490 | \r | |
3491 | **/\r | |
3492 | UINT64\r | |
3493 | EFIAPI\r | |
3494 | AsmMsrAndThenOr64 (\r | |
3495 | IN UINT32 Index,\r | |
3496 | IN UINT64 AndData,\r | |
3497 | IN UINT64 OrData\r | |
3498 | );\r | |
3499 | \r | |
3500 | /**\r | |
3501 | Reads a bit field of an MSR.\r | |
3502 | \r | |
3503 | Reads the bit field in the 64-bit MSR. The bit field is specified by the\r | |
3504 | StartBit and the EndBit. The value of the bit field is returned. The caller\r | |
3505 | must either guarantee that Index is valid, or the caller must set up\r | |
3506 | exception handlers to catch the exceptions. This function is only available\r | |
3507 | on IA-32 and X64.\r | |
3508 | \r | |
3509 | If StartBit is greater than 63, then ASSERT().\r | |
3510 | If EndBit is greater than 63, then ASSERT().\r | |
0ffa1286 | 3511 | If EndBit is less than StartBit, then ASSERT().\r |
878ddf1f | 3512 | \r |
3513 | @param Index The 32-bit MSR index to read.\r | |
3514 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
3515 | Range 0..63.\r | |
3516 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
3517 | Range 0..63.\r | |
3518 | \r | |
3519 | @return The value read from the MSR.\r | |
3520 | \r | |
3521 | **/\r | |
3522 | UINT64\r | |
3523 | EFIAPI\r | |
3524 | AsmMsrBitFieldRead64 (\r | |
3525 | IN UINT32 Index,\r | |
3526 | IN UINTN StartBit,\r | |
3527 | IN UINTN EndBit\r | |
3528 | );\r | |
3529 | \r | |
3530 | /**\r | |
3531 | Writes a bit field to an MSR.\r | |
3532 | \r | |
3533 | Writes Value to a bit field in a 64-bit MSR. The bit field is specified by\r | |
3534 | the StartBit and the EndBit. All other bits in the destination MSR are\r | |
3535 | preserved. The MSR written is returned. Extra left bits in Value are\r | |
3536 | stripped. The caller must either guarantee that Index and the data written is\r | |
3537 | valid, or the caller must set up exception handlers to catch the exceptions.\r | |
3538 | This function is only available on IA-32 and X64.\r | |
3539 | \r | |
3540 | If StartBit is greater than 63, then ASSERT().\r | |
3541 | If EndBit is greater than 63, then ASSERT().\r | |
0ffa1286 | 3542 | If EndBit is less than StartBit, then ASSERT().\r |
878ddf1f | 3543 | \r |
3544 | @param Index The 32-bit MSR index to write.\r | |
3545 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
3546 | Range 0..63.\r | |
3547 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
3548 | Range 0..63.\r | |
3549 | @param Value New value of the bit field.\r | |
3550 | \r | |
3551 | @return The value written back to the MSR.\r | |
3552 | \r | |
3553 | **/\r | |
3554 | UINT64\r | |
3555 | EFIAPI\r | |
3556 | AsmMsrBitFieldWrite64 (\r | |
3557 | IN UINT32 Index,\r | |
3558 | IN UINTN StartBit,\r | |
3559 | IN UINTN EndBit,\r | |
3560 | IN UINT64 Value\r | |
3561 | );\r | |
3562 | \r | |
3563 | /**\r | |
3564 | Reads a bit field in a 64-bit MSR, performs a bitwise inclusive OR, and\r | |
3565 | writes the result back to the bit field in the 64-bit MSR.\r | |
3566 | \r | |
3567 | Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR\r | |
3568 | between the read result and the value specified by OrData, and writes the\r | |
3569 | result to the 64-bit MSR specified by Index. The value written to the MSR is\r | |
3570 | returned. Extra left bits in OrData are stripped. The caller must either\r | |
3571 | guarantee that Index and the data written is valid, or the caller must set up\r | |
3572 | exception handlers to catch the exceptions. This function is only available\r | |
3573 | on IA-32 and X64.\r | |
3574 | \r | |
3575 | If StartBit is greater than 63, then ASSERT().\r | |
3576 | If EndBit is greater than 63, then ASSERT().\r | |
0ffa1286 | 3577 | If EndBit is less than StartBit, then ASSERT().\r |
878ddf1f | 3578 | \r |
3579 | @param Index The 32-bit MSR index to write.\r | |
3580 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
3581 | Range 0..63.\r | |
3582 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
3583 | Range 0..63.\r | |
3584 | @param OrData The value to OR with the read value from the bit field.\r | |
3585 | \r | |
3586 | @return The value written back to the MSR.\r | |
3587 | \r | |
3588 | **/\r | |
3589 | UINT64\r | |
3590 | EFIAPI\r | |
3591 | AsmMsrBitFieldOr64 (\r | |
3592 | IN UINT32 Index,\r | |
3593 | IN UINTN StartBit,\r | |
3594 | IN UINTN EndBit,\r | |
3595 | IN UINT64 OrData\r | |
3596 | );\r | |
3597 | \r | |
3598 | /**\r | |
3599 | Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the\r | |
3600 | result back to the bit field in the 64-bit MSR.\r | |
3601 | \r | |
3602 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r | |
3603 | read result and the value specified by AndData, and writes the result to the\r | |
3604 | 64-bit MSR specified by Index. The value written to the MSR is returned.\r | |
3605 | Extra left bits in AndData are stripped. The caller must either guarantee\r | |
3606 | that Index and the data written is valid, or the caller must set up exception\r | |
3607 | handlers to catch the exceptions. This function is only available on IA-32\r | |
3608 | and X64.\r | |
3609 | \r | |
3610 | If StartBit is greater than 63, then ASSERT().\r | |
3611 | If EndBit is greater than 63, then ASSERT().\r | |
0ffa1286 | 3612 | If EndBit is less than StartBit, then ASSERT().\r |
878ddf1f | 3613 | \r |
3614 | @param Index The 32-bit MSR index to write.\r | |
3615 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
3616 | Range 0..63.\r | |
3617 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
3618 | Range 0..63.\r | |
3619 | @param AndData The value to AND with the read value from the bit field.\r | |
3620 | \r | |
3621 | @return The value written back to the MSR.\r | |
3622 | \r | |
3623 | **/\r | |
3624 | UINT64\r | |
3625 | EFIAPI\r | |
3626 | AsmMsrBitFieldAnd64 (\r | |
3627 | IN UINT32 Index,\r | |
3628 | IN UINTN StartBit,\r | |
3629 | IN UINTN EndBit,\r | |
3630 | IN UINT64 AndData\r | |
3631 | );\r | |
3632 | \r | |
3633 | /**\r | |
3634 | Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a\r | |
3635 | bitwise inclusive OR, and writes the result back to the bit field in the\r | |
3636 | 64-bit MSR.\r | |
3637 | \r | |
3638 | Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by\r | |
3639 | a bitwise inclusive OR between the read result and the value specified by\r | |
3640 | AndData, and writes the result to the 64-bit MSR specified by Index. The\r | |
3641 | value written to the MSR is returned. Extra left bits in both AndData and\r | |
3642 | OrData are stripped. The caller must either guarantee that Index and the data\r | |
3643 | written is valid, or the caller must set up exception handlers to catch the\r | |
3644 | exceptions. This function is only available on IA-32 and X64.\r | |
3645 | \r | |
3646 | If StartBit is greater than 63, then ASSERT().\r | |
3647 | If EndBit is greater than 63, then ASSERT().\r | |
0ffa1286 | 3648 | If EndBit is less than StartBit, then ASSERT().\r |
878ddf1f | 3649 | \r |
3650 | @param Index The 32-bit MSR index to write.\r | |
3651 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
3652 | Range 0..63.\r | |
3653 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
3654 | Range 0..63.\r | |
3655 | @param AndData The value to AND with the read value from the bit field.\r | |
3656 | @param OrData The value to OR with the result of the AND operation.\r | |
3657 | \r | |
3658 | @return The value written back to the MSR.\r | |
3659 | \r | |
3660 | **/\r | |
3661 | UINT64\r | |
3662 | EFIAPI\r | |
3663 | AsmMsrBitFieldAndThenOr64 (\r | |
3664 | IN UINT32 Index,\r | |
3665 | IN UINTN StartBit,\r | |
3666 | IN UINTN EndBit,\r | |
3667 | IN UINT64 AndData,\r | |
3668 | IN UINT64 OrData\r | |
3669 | );\r | |
3670 | \r | |
3671 | /**\r | |
3672 | Reads the current value of the EFLAGS register.\r | |
3673 | \r | |
3674 | Reads and returns the current value of the EFLAGS register. This function is\r | |
3675 | only available on IA-32 and X64. This returns a 32-bit value on IA-32 and a\r | |
3676 | 64-bit value on X64.\r | |
3677 | \r | |
3678 | @return EFLAGS on IA-32 or RFLAGS on X64.\r | |
3679 | \r | |
3680 | **/\r | |
3681 | UINTN\r | |
3682 | EFIAPI\r | |
3683 | AsmReadEflags (\r | |
3684 | VOID\r | |
3685 | );\r | |
3686 | \r | |
3687 | /**\r | |
3688 | Reads the current value of the Control Register 0 (CR0).\r | |
3689 | \r | |
3690 | Reads and returns the current value of CR0. This function is only available\r | |
3691 | on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r | |
3692 | X64.\r | |
3693 | \r | |
3694 | @return The value of the Control Register 0 (CR0).\r | |
3695 | \r | |
3696 | **/\r | |
3697 | UINTN\r | |
3698 | EFIAPI\r | |
3699 | AsmReadCr0 (\r | |
3700 | VOID\r | |
3701 | );\r | |
3702 | \r | |
3703 | /**\r | |
3704 | Reads the current value of the Control Register 2 (CR2).\r | |
3705 | \r | |
3706 | Reads and returns the current value of CR2. This function is only available\r | |
3707 | on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r | |
3708 | X64.\r | |
3709 | \r | |
3710 | @return The value of the Control Register 2 (CR2).\r | |
3711 | \r | |
3712 | **/\r | |
3713 | UINTN\r | |
3714 | EFIAPI\r | |
3715 | AsmReadCr2 (\r | |
3716 | VOID\r | |
3717 | );\r | |
3718 | \r | |
3719 | /**\r | |
3720 | Reads the current value of the Control Register 3 (CR3).\r | |
3721 | \r | |
3722 | Reads and returns the current value of CR3. This function is only available\r | |
3723 | on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r | |
3724 | X64.\r | |
3725 | \r | |
3726 | @return The value of the Control Register 3 (CR3).\r | |
3727 | \r | |
3728 | **/\r | |
3729 | UINTN\r | |
3730 | EFIAPI\r | |
3731 | AsmReadCr3 (\r | |
3732 | VOID\r | |
3733 | );\r | |
3734 | \r | |
3735 | /**\r | |
3736 | Reads the current value of the Control Register 4 (CR4).\r | |
3737 | \r | |
3738 | Reads and returns the current value of CR4. This function is only available\r | |
3739 | on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r | |
3740 | X64.\r | |
3741 | \r | |
3742 | @return The value of the Control Register 4 (CR4).\r | |
3743 | \r | |
3744 | **/\r | |
3745 | UINTN\r | |
3746 | EFIAPI\r | |
3747 | AsmReadCr4 (\r | |
3748 | VOID\r | |
3749 | );\r | |
3750 | \r | |
3751 | /**\r | |
3752 | Writes a value to Control Register 0 (CR0).\r | |
3753 | \r | |
3754 | Writes and returns a new value to CR0. This function is only available on\r | |
3755 | IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r | |
3756 | \r | |
3757 | @param Cr0 The value to write to CR0.\r | |
3758 | \r | |
3759 | @return The value written to CR0.\r | |
3760 | \r | |
3761 | **/\r | |
3762 | UINTN\r | |
3763 | EFIAPI\r | |
3764 | AsmWriteCr0 (\r | |
3765 | UINTN Cr0\r | |
3766 | );\r | |
3767 | \r | |
3768 | /**\r | |
3769 | Writes a value to Control Register 2 (CR2).\r | |
3770 | \r | |
3771 | Writes and returns a new value to CR2. This function is only available on\r | |
3772 | IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r | |
3773 | \r | |
3774 | @param Cr2 The value to write to CR2.\r | |
3775 | \r | |
3776 | @return The value written to CR2.\r | |
3777 | \r | |
3778 | **/\r | |
3779 | UINTN\r | |
3780 | EFIAPI\r | |
3781 | AsmWriteCr2 (\r | |
3782 | UINTN Cr2\r | |
3783 | );\r | |
3784 | \r | |
3785 | /**\r | |
3786 | Writes a value to Control Register 3 (CR3).\r | |
3787 | \r | |
3788 | Writes and returns a new value to CR3. This function is only available on\r | |
3789 | IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r | |
3790 | \r | |
3791 | @param Cr3 The value to write to CR3.\r | |
3792 | \r | |
3793 | @return The value written to CR3.\r | |
3794 | \r | |
3795 | **/\r | |
3796 | UINTN\r | |
3797 | EFIAPI\r | |
3798 | AsmWriteCr3 (\r | |
3799 | UINTN Cr3\r | |
3800 | );\r | |
3801 | \r | |
3802 | /**\r | |
3803 | Writes a value to Control Register 4 (CR4).\r | |
3804 | \r | |
3805 | Writes and returns a new value to CR4. This function is only available on\r | |
3806 | IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r | |
3807 | \r | |
3808 | @param Cr4 The value to write to CR4.\r | |
3809 | \r | |
3810 | @return The value written to CR4.\r | |
3811 | \r | |
3812 | **/\r | |
3813 | UINTN\r | |
3814 | EFIAPI\r | |
3815 | AsmWriteCr4 (\r | |
3816 | UINTN Cr4\r | |
3817 | );\r | |
3818 | \r | |
3819 | /**\r | |
3820 | Reads the current value of Debug Register 0 (DR0).\r | |
3821 | \r | |
3822 | Reads and returns the current value of DR0. This function is only available\r | |
3823 | on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r | |
3824 | X64.\r | |
3825 | \r | |
3826 | @return The value of Debug Register 0 (DR0).\r | |
3827 | \r | |
3828 | **/\r | |
3829 | UINTN\r | |
3830 | EFIAPI\r | |
3831 | AsmReadDr0 (\r | |
3832 | VOID\r | |
3833 | );\r | |
3834 | \r | |
3835 | /**\r | |
3836 | Reads the current value of Debug Register 1 (DR1).\r | |
3837 | \r | |
3838 | Reads and returns the current value of DR1. This function is only available\r | |
3839 | on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r | |
3840 | X64.\r | |
3841 | \r | |
3842 | @return The value of Debug Register 1 (DR1).\r | |
3843 | \r | |
3844 | **/\r | |
3845 | UINTN\r | |
3846 | EFIAPI\r | |
3847 | AsmReadDr1 (\r | |
3848 | VOID\r | |
3849 | );\r | |
3850 | \r | |
3851 | /**\r | |
3852 | Reads the current value of Debug Register 2 (DR2).\r | |
3853 | \r | |
3854 | Reads and returns the current value of DR2. This function is only available\r | |
3855 | on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r | |
3856 | X64.\r | |
3857 | \r | |
3858 | @return The value of Debug Register 2 (DR2).\r | |
3859 | \r | |
3860 | **/\r | |
3861 | UINTN\r | |
3862 | EFIAPI\r | |
3863 | AsmReadDr2 (\r | |
3864 | VOID\r | |
3865 | );\r | |
3866 | \r | |
3867 | /**\r | |
3868 | Reads the current value of Debug Register 3 (DR3).\r | |
3869 | \r | |
3870 | Reads and returns the current value of DR3. This function is only available\r | |
3871 | on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r | |
3872 | X64.\r | |
3873 | \r | |
3874 | @return The value of Debug Register 3 (DR3).\r | |
3875 | \r | |
3876 | **/\r | |
3877 | UINTN\r | |
3878 | EFIAPI\r | |
3879 | AsmReadDr3 (\r | |
3880 | VOID\r | |
3881 | );\r | |
3882 | \r | |
3883 | /**\r | |
3884 | Reads the current value of Debug Register 4 (DR4).\r | |
3885 | \r | |
3886 | Reads and returns the current value of DR4. This function is only available\r | |
3887 | on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r | |
3888 | X64.\r | |
3889 | \r | |
3890 | @return The value of Debug Register 4 (DR4).\r | |
3891 | \r | |
3892 | **/\r | |
3893 | UINTN\r | |
3894 | EFIAPI\r | |
3895 | AsmReadDr4 (\r | |
3896 | VOID\r | |
3897 | );\r | |
3898 | \r | |
3899 | /**\r | |
3900 | Reads the current value of Debug Register 5 (DR5).\r | |
3901 | \r | |
3902 | Reads and returns the current value of DR5. This function is only available\r | |
3903 | on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r | |
3904 | X64.\r | |
3905 | \r | |
3906 | @return The value of Debug Register 5 (DR5).\r | |
3907 | \r | |
3908 | **/\r | |
3909 | UINTN\r | |
3910 | EFIAPI\r | |
3911 | AsmReadDr5 (\r | |
3912 | VOID\r | |
3913 | );\r | |
3914 | \r | |
3915 | /**\r | |
3916 | Reads the current value of Debug Register 6 (DR6).\r | |
3917 | \r | |
3918 | Reads and returns the current value of DR6. This function is only available\r | |
3919 | on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r | |
3920 | X64.\r | |
3921 | \r | |
3922 | @return The value of Debug Register 6 (DR6).\r | |
3923 | \r | |
3924 | **/\r | |
3925 | UINTN\r | |
3926 | EFIAPI\r | |
3927 | AsmReadDr6 (\r | |
3928 | VOID\r | |
3929 | );\r | |
3930 | \r | |
3931 | /**\r | |
3932 | Reads the current value of Debug Register 7 (DR7).\r | |
3933 | \r | |
3934 | Reads and returns the current value of DR7. This function is only available\r | |
3935 | on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on\r | |
3936 | X64.\r | |
3937 | \r | |
3938 | @return The value of Debug Register 7 (DR7).\r | |
3939 | \r | |
3940 | **/\r | |
3941 | UINTN\r | |
3942 | EFIAPI\r | |
3943 | AsmReadDr7 (\r | |
3944 | VOID\r | |
3945 | );\r | |
3946 | \r | |
3947 | /**\r | |
3948 | Writes a value to Debug Register 0 (DR0).\r | |
3949 | \r | |
3950 | Writes and returns a new value to DR0. This function is only available on\r | |
3951 | IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r | |
3952 | \r | |
3953 | @param Dr0 The value to write to Dr0.\r | |
3954 | \r | |
3955 | @return The value written to Debug Register 0 (DR0).\r | |
3956 | \r | |
3957 | **/\r | |
3958 | UINTN\r | |
3959 | EFIAPI\r | |
3960 | AsmWriteDr0 (\r | |
3961 | UINTN Dr0\r | |
3962 | );\r | |
3963 | \r | |
3964 | /**\r | |
3965 | Writes a value to Debug Register 1 (DR1).\r | |
3966 | \r | |
3967 | Writes and returns a new value to DR1. This function is only available on\r | |
3968 | IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r | |
3969 | \r | |
3970 | @param Dr1 The value to write to Dr1.\r | |
3971 | \r | |
3972 | @return The value written to Debug Register 1 (DR1).\r | |
3973 | \r | |
3974 | **/\r | |
3975 | UINTN\r | |
3976 | EFIAPI\r | |
3977 | AsmWriteDr1 (\r | |
3978 | UINTN Dr1\r | |
3979 | );\r | |
3980 | \r | |
3981 | /**\r | |
3982 | Writes a value to Debug Register 2 (DR2).\r | |
3983 | \r | |
3984 | Writes and returns a new value to DR2. This function is only available on\r | |
3985 | IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r | |
3986 | \r | |
3987 | @param Dr2 The value to write to Dr2.\r | |
3988 | \r | |
3989 | @return The value written to Debug Register 2 (DR2).\r | |
3990 | \r | |
3991 | **/\r | |
3992 | UINTN\r | |
3993 | EFIAPI\r | |
3994 | AsmWriteDr2 (\r | |
3995 | UINTN Dr2\r | |
3996 | );\r | |
3997 | \r | |
3998 | /**\r | |
3999 | Writes a value to Debug Register 3 (DR3).\r | |
4000 | \r | |
4001 | Writes and returns a new value to DR3. This function is only available on\r | |
4002 | IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r | |
4003 | \r | |
4004 | @param Dr3 The value to write to Dr3.\r | |
4005 | \r | |
4006 | @return The value written to Debug Register 3 (DR3).\r | |
4007 | \r | |
4008 | **/\r | |
4009 | UINTN\r | |
4010 | EFIAPI\r | |
4011 | AsmWriteDr3 (\r | |
4012 | UINTN Dr3\r | |
4013 | );\r | |
4014 | \r | |
4015 | /**\r | |
4016 | Writes a value to Debug Register 4 (DR4).\r | |
4017 | \r | |
4018 | Writes and returns a new value to DR4. This function is only available on\r | |
4019 | IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r | |
4020 | \r | |
4021 | @param Dr4 The value to write to Dr4.\r | |
4022 | \r | |
4023 | @return The value written to Debug Register 4 (DR4).\r | |
4024 | \r | |
4025 | **/\r | |
4026 | UINTN\r | |
4027 | EFIAPI\r | |
4028 | AsmWriteDr4 (\r | |
4029 | UINTN Dr4\r | |
4030 | );\r | |
4031 | \r | |
4032 | /**\r | |
4033 | Writes a value to Debug Register 5 (DR5).\r | |
4034 | \r | |
4035 | Writes and returns a new value to DR5. This function is only available on\r | |
4036 | IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r | |
4037 | \r | |
4038 | @param Dr5 The value to write to Dr5.\r | |
4039 | \r | |
4040 | @return The value written to Debug Register 5 (DR5).\r | |
4041 | \r | |
4042 | **/\r | |
4043 | UINTN\r | |
4044 | EFIAPI\r | |
4045 | AsmWriteDr5 (\r | |
4046 | UINTN Dr5\r | |
4047 | );\r | |
4048 | \r | |
4049 | /**\r | |
4050 | Writes a value to Debug Register 6 (DR6).\r | |
4051 | \r | |
4052 | Writes and returns a new value to DR6. This function is only available on\r | |
4053 | IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r | |
4054 | \r | |
4055 | @param Dr6 The value to write to Dr6.\r | |
4056 | \r | |
4057 | @return The value written to Debug Register 6 (DR6).\r | |
4058 | \r | |
4059 | **/\r | |
4060 | UINTN\r | |
4061 | EFIAPI\r | |
4062 | AsmWriteDr6 (\r | |
4063 | UINTN Dr6\r | |
4064 | );\r | |
4065 | \r | |
4066 | /**\r | |
4067 | Writes a value to Debug Register 7 (DR7).\r | |
4068 | \r | |
4069 | Writes and returns a new value to DR7. This function is only available on\r | |
4070 | IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.\r | |
4071 | \r | |
4072 | @param Dr7 The value to write to Dr7.\r | |
4073 | \r | |
4074 | @return The value written to Debug Register 7 (DR7).\r | |
4075 | \r | |
4076 | **/\r | |
4077 | UINTN\r | |
4078 | EFIAPI\r | |
4079 | AsmWriteDr7 (\r | |
4080 | UINTN Dr7\r | |
4081 | );\r | |
4082 | \r | |
4083 | /**\r | |
4084 | Reads the current value of Code Segment Register (CS).\r | |
4085 | \r | |
4086 | Reads and returns the current value of CS. This function is only available on\r | |
4087 | IA-32 and X64.\r | |
4088 | \r | |
4089 | @return The current value of CS.\r | |
4090 | \r | |
4091 | **/\r | |
4092 | UINT16\r | |
4093 | EFIAPI\r | |
4094 | AsmReadCs (\r | |
4095 | VOID\r | |
4096 | );\r | |
4097 | \r | |
4098 | /**\r | |
4099 | Reads the current value of Data Segment Register (DS).\r | |
4100 | \r | |
4101 | Reads and returns the current value of DS. This function is only available on\r | |
4102 | IA-32 and X64.\r | |
4103 | \r | |
4104 | @return The current value of DS.\r | |
4105 | \r | |
4106 | **/\r | |
4107 | UINT16\r | |
4108 | EFIAPI\r | |
4109 | AsmReadDs (\r | |
4110 | VOID\r | |
4111 | );\r | |
4112 | \r | |
4113 | /**\r | |
4114 | Reads the current value of Extra Segment Register (ES).\r | |
4115 | \r | |
4116 | Reads and returns the current value of ES. This function is only available on\r | |
4117 | IA-32 and X64.\r | |
4118 | \r | |
4119 | @return The current value of ES.\r | |
4120 | \r | |
4121 | **/\r | |
4122 | UINT16\r | |
4123 | EFIAPI\r | |
4124 | AsmReadEs (\r | |
4125 | VOID\r | |
4126 | );\r | |
4127 | \r | |
4128 | /**\r | |
4129 | Reads the current value of FS Data Segment Register (FS).\r | |
4130 | \r | |
4131 | Reads and returns the current value of FS. This function is only available on\r | |
4132 | IA-32 and X64.\r | |
4133 | \r | |
4134 | @return The current value of FS.\r | |
4135 | \r | |
4136 | **/\r | |
4137 | UINT16\r | |
4138 | EFIAPI\r | |
4139 | AsmReadFs (\r | |
4140 | VOID\r | |
4141 | );\r | |
4142 | \r | |
4143 | /**\r | |
4144 | Reads the current value of GS Data Segment Register (GS).\r | |
4145 | \r | |
4146 | Reads and returns the current value of GS. This function is only available on\r | |
4147 | IA-32 and X64.\r | |
4148 | \r | |
4149 | @return The current value of GS.\r | |
4150 | \r | |
4151 | **/\r | |
4152 | UINT16\r | |
4153 | EFIAPI\r | |
4154 | AsmReadGs (\r | |
4155 | VOID\r | |
4156 | );\r | |
4157 | \r | |
4158 | /**\r | |
4159 | Reads the current value of Stack Segment Register (SS).\r | |
4160 | \r | |
4161 | Reads and returns the current value of SS. This function is only available on\r | |
4162 | IA-32 and X64.\r | |
4163 | \r | |
4164 | @return The current value of SS.\r | |
4165 | \r | |
4166 | **/\r | |
4167 | UINT16\r | |
4168 | EFIAPI\r | |
4169 | AsmReadSs (\r | |
4170 | VOID\r | |
4171 | );\r | |
4172 | \r | |
4173 | /**\r | |
4174 | Reads the current value of Task Register (TR).\r | |
4175 | \r | |
4176 | Reads and returns the current value of TR. This function is only available on\r | |
4177 | IA-32 and X64.\r | |
4178 | \r | |
4179 | @return The current value of TR.\r | |
4180 | \r | |
4181 | **/\r | |
4182 | UINT16\r | |
4183 | EFIAPI\r | |
4184 | AsmReadTr (\r | |
4185 | VOID\r | |
4186 | );\r | |
4187 | \r | |
4188 | /**\r | |
4189 | Reads the current Global Descriptor Table Register(GDTR) descriptor.\r | |
4190 | \r | |
4191 | Reads and returns the current GDTR descriptor and returns it in Gdtr. This\r | |
4192 | function is only available on IA-32 and X64.\r | |
4193 | \r | |
4194 | If Gdtr is NULL, then ASSERT().\r | |
4195 | \r | |
4196 | @param Gdtr Pointer to a GDTR descriptor.\r | |
4197 | \r | |
4198 | **/\r | |
4199 | VOID\r | |
4200 | EFIAPI\r | |
4201 | AsmReadGdtr (\r | |
4202 | OUT IA32_DESCRIPTOR *Gdtr\r | |
4203 | );\r | |
4204 | \r | |
4205 | /**\r | |
4206 | Writes the current Global Descriptor Table Register (GDTR) descriptor.\r | |
4207 | \r | |
4208 | Writes and the current GDTR descriptor specified by Gdtr. This function is\r | |
4209 | only available on IA-32 and X64.\r | |
4210 | \r | |
4211 | If Gdtr is NULL, then ASSERT().\r | |
4212 | \r | |
4213 | @param Gdtr Pointer to a GDTR descriptor.\r | |
4214 | \r | |
4215 | **/\r | |
4216 | VOID\r | |
4217 | EFIAPI\r | |
4218 | AsmWriteGdtr (\r | |
4219 | IN CONST IA32_DESCRIPTOR *Gdtr\r | |
4220 | );\r | |
4221 | \r | |
4222 | /**\r | |
4223 | Reads the current Interrupt Descriptor Table Register(GDTR) descriptor.\r | |
4224 | \r | |
4225 | Reads and returns the current IDTR descriptor and returns it in Idtr. This\r | |
4226 | function is only available on IA-32 and X64.\r | |
4227 | \r | |
4228 | If Idtr is NULL, then ASSERT().\r | |
4229 | \r | |
4230 | @param Idtr Pointer to a IDTR descriptor.\r | |
4231 | \r | |
4232 | **/\r | |
4233 | VOID\r | |
4234 | EFIAPI\r | |
4235 | AsmReadIdtr (\r | |
4236 | OUT IA32_DESCRIPTOR *Idtr\r | |
4237 | );\r | |
4238 | \r | |
4239 | /**\r | |
4240 | Writes the current Interrupt Descriptor Table Register(GDTR) descriptor.\r | |
4241 | \r | |
4242 | Writes the current IDTR descriptor and returns it in Idtr. This function is\r | |
4243 | only available on IA-32 and X64.\r | |
4244 | \r | |
4245 | If Idtr is NULL, then ASSERT().\r | |
4246 | \r | |
4247 | @param Idtr Pointer to a IDTR descriptor.\r | |
4248 | \r | |
4249 | **/\r | |
4250 | VOID\r | |
4251 | EFIAPI\r | |
4252 | AsmWriteIdtr (\r | |
4253 | IN CONST IA32_DESCRIPTOR *Idtr\r | |
4254 | );\r | |
4255 | \r | |
4256 | /**\r | |
4257 | Reads the current Local Descriptor Table Register(LDTR) selector.\r | |
4258 | \r | |
4259 | Reads and returns the current 16-bit LDTR descriptor value. This function is\r | |
4260 | only available on IA-32 and X64.\r | |
4261 | \r | |
4262 | @return The current selector of LDT.\r | |
4263 | \r | |
4264 | **/\r | |
4265 | UINT16\r | |
4266 | EFIAPI\r | |
4267 | AsmReadLdtr (\r | |
4268 | VOID\r | |
4269 | );\r | |
4270 | \r | |
4271 | /**\r | |
4272 | Writes the current Local Descriptor Table Register (GDTR) selector.\r | |
4273 | \r | |
4274 | Writes and the current LDTR descriptor specified by Ldtr. This function is\r | |
4275 | only available on IA-32 and X64.\r | |
4276 | \r | |
4277 | @param Ldtr 16-bit LDTR selector value.\r | |
4278 | \r | |
4279 | **/\r | |
4280 | VOID\r | |
4281 | EFIAPI\r | |
4282 | AsmWriteLdtr (\r | |
4283 | IN UINT16 Ldtr\r | |
4284 | );\r | |
4285 | \r | |
4286 | /**\r | |
4287 | Save the current floating point/SSE/SSE2 context to a buffer.\r | |
4288 | \r | |
4289 | Saves the current floating point/SSE/SSE2 state to the buffer specified by\r | |
4290 | Buffer. Buffer must be aligned on a 16-byte boundary. This function is only\r | |
4291 | available on IA-32 and X64.\r | |
4292 | \r | |
4293 | If Buffer is NULL, then ASSERT().\r | |
4294 | If Buffer is not aligned on a 16-byte boundary, then ASSERT().\r | |
4295 | \r | |
4296 | @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.\r | |
4297 | \r | |
4298 | **/\r | |
4299 | VOID\r | |
4300 | EFIAPI\r | |
4301 | AsmFxSave (\r | |
4302 | OUT IA32_FX_BUFFER *Buffer\r | |
4303 | );\r | |
4304 | \r | |
4305 | /**\r | |
4306 | Restores the current floating point/SSE/SSE2 context from a buffer.\r | |
4307 | \r | |
4308 | Restores the current floating point/SSE/SSE2 state from the buffer specified\r | |
4309 | by Buffer. Buffer must be aligned on a 16-byte boundary. This function is\r | |
4310 | only available on IA-32 and X64.\r | |
4311 | \r | |
4312 | If Buffer is NULL, then ASSERT().\r | |
4313 | If Buffer is not aligned on a 16-byte boundary, then ASSERT().\r | |
4314 | If Buffer was not saved with AsmFxSave(), then ASSERT().\r | |
4315 | \r | |
4316 | @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.\r | |
4317 | \r | |
4318 | **/\r | |
4319 | VOID\r | |
4320 | EFIAPI\r | |
4321 | AsmFxRestore (\r | |
4322 | IN CONST IA32_FX_BUFFER *Buffer\r | |
4323 | );\r | |
4324 | \r | |
4325 | /**\r | |
4326 | Reads the current value of 64-bit MMX Register #0 (MM0).\r | |
4327 | \r | |
4328 | Reads and returns the current value of MM0. This function is only available\r | |
4329 | on IA-32 and X64.\r | |
4330 | \r | |
4331 | @return The current value of MM0.\r | |
4332 | \r | |
4333 | **/\r | |
4334 | UINT64\r | |
4335 | EFIAPI\r | |
4336 | AsmReadMm0 (\r | |
4337 | VOID\r | |
4338 | );\r | |
4339 | \r | |
4340 | /**\r | |
4341 | Reads the current value of 64-bit MMX Register #1 (MM1).\r | |
4342 | \r | |
4343 | Reads and returns the current value of MM1. This function is only available\r | |
4344 | on IA-32 and X64.\r | |
4345 | \r | |
4346 | @return The current value of MM1.\r | |
4347 | \r | |
4348 | **/\r | |
4349 | UINT64\r | |
4350 | EFIAPI\r | |
4351 | AsmReadMm1 (\r | |
4352 | VOID\r | |
4353 | );\r | |
4354 | \r | |
4355 | /**\r | |
4356 | Reads the current value of 64-bit MMX Register #2 (MM2).\r | |
4357 | \r | |
4358 | Reads and returns the current value of MM2. This function is only available\r | |
4359 | on IA-32 and X64.\r | |
4360 | \r | |
4361 | @return The current value of MM2.\r | |
4362 | \r | |
4363 | **/\r | |
4364 | UINT64\r | |
4365 | EFIAPI\r | |
4366 | AsmReadMm2 (\r | |
4367 | VOID\r | |
4368 | );\r | |
4369 | \r | |
4370 | /**\r | |
4371 | Reads the current value of 64-bit MMX Register #3 (MM3).\r | |
4372 | \r | |
4373 | Reads and returns the current value of MM3. This function is only available\r | |
4374 | on IA-32 and X64.\r | |
4375 | \r | |
4376 | @return The current value of MM3.\r | |
4377 | \r | |
4378 | **/\r | |
4379 | UINT64\r | |
4380 | EFIAPI\r | |
4381 | AsmReadMm3 (\r | |
4382 | VOID\r | |
4383 | );\r | |
4384 | \r | |
4385 | /**\r | |
4386 | Reads the current value of 64-bit MMX Register #4 (MM4).\r | |
4387 | \r | |
4388 | Reads and returns the current value of MM4. This function is only available\r | |
4389 | on IA-32 and X64.\r | |
4390 | \r | |
4391 | @return The current value of MM4.\r | |
4392 | \r | |
4393 | **/\r | |
4394 | UINT64\r | |
4395 | EFIAPI\r | |
4396 | AsmReadMm4 (\r | |
4397 | VOID\r | |
4398 | );\r | |
4399 | \r | |
4400 | /**\r | |
4401 | Reads the current value of 64-bit MMX Register #5 (MM5).\r | |
4402 | \r | |
4403 | Reads and returns the current value of MM5. This function is only available\r | |
4404 | on IA-32 and X64.\r | |
4405 | \r | |
4406 | @return The current value of MM5.\r | |
4407 | \r | |
4408 | **/\r | |
4409 | UINT64\r | |
4410 | EFIAPI\r | |
4411 | AsmReadMm5 (\r | |
4412 | VOID\r | |
4413 | );\r | |
4414 | \r | |
4415 | /**\r | |
4416 | Reads the current value of 64-bit MMX Register #6 (MM6).\r | |
4417 | \r | |
4418 | Reads and returns the current value of MM6. This function is only available\r | |
4419 | on IA-32 and X64.\r | |
4420 | \r | |
4421 | @return The current value of MM6.\r | |
4422 | \r | |
4423 | **/\r | |
4424 | UINT64\r | |
4425 | EFIAPI\r | |
4426 | AsmReadMm6 (\r | |
4427 | VOID\r | |
4428 | );\r | |
4429 | \r | |
4430 | /**\r | |
4431 | Reads the current value of 64-bit MMX Register #7 (MM7).\r | |
4432 | \r | |
4433 | Reads and returns the current value of MM7. This function is only available\r | |
4434 | on IA-32 and X64.\r | |
4435 | \r | |
4436 | @return The current value of MM7.\r | |
4437 | \r | |
4438 | **/\r | |
4439 | UINT64\r | |
4440 | EFIAPI\r | |
4441 | AsmReadMm7 (\r | |
4442 | VOID\r | |
4443 | );\r | |
4444 | \r | |
4445 | /**\r | |
4446 | Writes the current value of 64-bit MMX Register #0 (MM0).\r | |
4447 | \r | |
4448 | Writes the current value of MM0. This function is only available on IA32 and\r | |
4449 | X64.\r | |
4450 | \r | |
4451 | @param Value The 64-bit value to write to MM0.\r | |
4452 | \r | |
4453 | **/\r | |
4454 | VOID\r | |
4455 | EFIAPI\r | |
4456 | AsmWriteMm0 (\r | |
4457 | IN UINT64 Value\r | |
4458 | );\r | |
4459 | \r | |
4460 | /**\r | |
4461 | Writes the current value of 64-bit MMX Register #1 (MM1).\r | |
4462 | \r | |
4463 | Writes the current value of MM1. This function is only available on IA32 and\r | |
4464 | X64.\r | |
4465 | \r | |
4466 | @param Value The 64-bit value to write to MM1.\r | |
4467 | \r | |
4468 | **/\r | |
4469 | VOID\r | |
4470 | EFIAPI\r | |
4471 | AsmWriteMm1 (\r | |
4472 | IN UINT64 Value\r | |
4473 | );\r | |
4474 | \r | |
4475 | /**\r | |
4476 | Writes the current value of 64-bit MMX Register #2 (MM2).\r | |
4477 | \r | |
4478 | Writes the current value of MM2. This function is only available on IA32 and\r | |
4479 | X64.\r | |
4480 | \r | |
4481 | @param Value The 64-bit value to write to MM2.\r | |
4482 | \r | |
4483 | **/\r | |
4484 | VOID\r | |
4485 | EFIAPI\r | |
4486 | AsmWriteMm2 (\r | |
4487 | IN UINT64 Value\r | |
4488 | );\r | |
4489 | \r | |
4490 | /**\r | |
4491 | Writes the current value of 64-bit MMX Register #3 (MM3).\r | |
4492 | \r | |
4493 | Writes the current value of MM3. This function is only available on IA32 and\r | |
4494 | X64.\r | |
4495 | \r | |
4496 | @param Value The 64-bit value to write to MM3.\r | |
4497 | \r | |
4498 | **/\r | |
4499 | VOID\r | |
4500 | EFIAPI\r | |
4501 | AsmWriteMm3 (\r | |
4502 | IN UINT64 Value\r | |
4503 | );\r | |
4504 | \r | |
4505 | /**\r | |
4506 | Writes the current value of 64-bit MMX Register #4 (MM4).\r | |
4507 | \r | |
4508 | Writes the current value of MM4. This function is only available on IA32 and\r | |
4509 | X64.\r | |
4510 | \r | |
4511 | @param Value The 64-bit value to write to MM4.\r | |
4512 | \r | |
4513 | **/\r | |
4514 | VOID\r | |
4515 | EFIAPI\r | |
4516 | AsmWriteMm4 (\r | |
4517 | IN UINT64 Value\r | |
4518 | );\r | |
4519 | \r | |
4520 | /**\r | |
4521 | Writes the current value of 64-bit MMX Register #5 (MM5).\r | |
4522 | \r | |
4523 | Writes the current value of MM5. This function is only available on IA32 and\r | |
4524 | X64.\r | |
4525 | \r | |
4526 | @param Value The 64-bit value to write to MM5.\r | |
4527 | \r | |
4528 | **/\r | |
4529 | VOID\r | |
4530 | EFIAPI\r | |
4531 | AsmWriteMm5 (\r | |
4532 | IN UINT64 Value\r | |
4533 | );\r | |
4534 | \r | |
4535 | /**\r | |
4536 | Writes the current value of 64-bit MMX Register #6 (MM6).\r | |
4537 | \r | |
4538 | Writes the current value of MM6. This function is only available on IA32 and\r | |
4539 | X64.\r | |
4540 | \r | |
4541 | @param Value The 64-bit value to write to MM6.\r | |
4542 | \r | |
4543 | **/\r | |
4544 | VOID\r | |
4545 | EFIAPI\r | |
4546 | AsmWriteMm6 (\r | |
4547 | IN UINT64 Value\r | |
4548 | );\r | |
4549 | \r | |
4550 | /**\r | |
4551 | Writes the current value of 64-bit MMX Register #7 (MM7).\r | |
4552 | \r | |
4553 | Writes the current value of MM7. This function is only available on IA32 and\r | |
4554 | X64.\r | |
4555 | \r | |
4556 | @param Value The 64-bit value to write to MM7.\r | |
4557 | \r | |
4558 | **/\r | |
4559 | VOID\r | |
4560 | EFIAPI\r | |
4561 | AsmWriteMm7 (\r | |
4562 | IN UINT64 Value\r | |
4563 | );\r | |
4564 | \r | |
4565 | /**\r | |
4566 | Reads the current value of Time Stamp Counter (TSC).\r | |
4567 | \r | |
4568 | Reads and returns the current value of TSC. This function is only available\r | |
4569 | on IA-32 and X64.\r | |
4570 | \r | |
4571 | @return The current value of TSC\r | |
4572 | \r | |
4573 | **/\r | |
4574 | UINT64\r | |
4575 | EFIAPI\r | |
4576 | AsmReadTsc (\r | |
4577 | VOID\r | |
4578 | );\r | |
4579 | \r | |
4580 | /**\r | |
4581 | Reads the current value of a Performance Counter (PMC).\r | |
4582 | \r | |
4583 | Reads and returns the current value of performance counter specified by\r | |
4584 | Index. This function is only available on IA-32 and X64.\r | |
4585 | \r | |
4586 | @param Index The 32-bit Performance Counter index to read.\r | |
4587 | \r | |
4588 | @return The value of the PMC specified by Index.\r | |
4589 | \r | |
4590 | **/\r | |
4591 | UINT64\r | |
4592 | EFIAPI\r | |
4593 | AsmReadPmc (\r | |
4594 | IN UINT32 Index\r | |
4595 | );\r | |
4596 | \r | |
4597 | /**\r | |
4598 | Sets up a monitor buffer that is used by AsmMwait().\r | |
4599 | \r | |
4600 | Executes a MONITOR instruction with the register state specified by Eax, Ecx\r | |
4601 | and Edx. Returns Eax. This function is only available on IA-32 and X64.\r | |
4602 | \r | |
4603 | @param Eax The value to load into EAX or RAX before executing the MONITOR\r | |
4604 | instruction.\r | |
4605 | @param Ecx The value to load into ECX or RCX before executing the MONITOR\r | |
4606 | instruction.\r | |
4607 | @param Edx The value to load into EDX or RDX before executing the MONITOR\r | |
4608 | instruction.\r | |
4609 | \r | |
4610 | @return Eax\r | |
4611 | \r | |
4612 | **/\r | |
4613 | UINTN\r | |
4614 | EFIAPI\r | |
4615 | AsmMonitor (\r | |
4616 | IN UINTN Eax,\r | |
4617 | IN UINTN Ecx,\r | |
4618 | IN UINTN Edx\r | |
4619 | );\r | |
4620 | \r | |
4621 | /**\r | |
4622 | Executes an MWAIT instruction.\r | |
4623 | \r | |
4624 | Executes an MWAIT instruction with the register state specified by Eax and\r | |
4625 | Ecx. Returns Eax. This function is only available on IA-32 and X64.\r | |
4626 | \r | |
4627 | @param Eax The value to load into EAX or RAX before executing the MONITOR\r | |
4628 | instruction.\r | |
4629 | @param Ecx The value to load into ECX or RCX before executing the MONITOR\r | |
4630 | instruction.\r | |
4631 | \r | |
4632 | @return Eax\r | |
4633 | \r | |
4634 | **/\r | |
4635 | UINTN\r | |
4636 | EFIAPI\r | |
4637 | AsmMwait (\r | |
4638 | IN UINTN Eax,\r | |
4639 | IN UINTN Ecx\r | |
4640 | );\r | |
4641 | \r | |
4642 | /**\r | |
4643 | Executes a WBINVD instruction.\r | |
4644 | \r | |
4645 | Executes a WBINVD instruction. This function is only available on IA-32 and\r | |
4646 | X64.\r | |
4647 | \r | |
4648 | **/\r | |
4649 | VOID\r | |
4650 | EFIAPI\r | |
4651 | AsmWbinvd (\r | |
4652 | VOID\r | |
4653 | );\r | |
4654 | \r | |
4655 | /**\r | |
4656 | Executes a INVD instruction.\r | |
4657 | \r | |
4658 | Executes a INVD instruction. This function is only available on IA-32 and\r | |
4659 | X64.\r | |
4660 | \r | |
4661 | **/\r | |
4662 | VOID\r | |
4663 | EFIAPI\r | |
4664 | AsmInvd (\r | |
4665 | VOID\r | |
4666 | );\r | |
4667 | \r | |
4668 | /**\r | |
4669 | Flushes a cache line from all the instruction and data caches within the\r | |
4670 | coherency domain of the CPU.\r | |
4671 | \r | |
4672 | Flushed the cache line specified by LinearAddress, and returns LinearAddress.\r | |
4673 | This function is only available on IA-32 and X64.\r | |
4674 | \r | |
4675 | @param LinearAddress The address of the cache line to flush. If the CPU is\r | |
4676 | in a physical addressing mode, then LinearAddress is a\r | |
4677 | physical address. If the CPU is in a virtual\r | |
4678 | addressing mode, then LinearAddress is a virtual\r | |
4679 | address.\r | |
4680 | \r | |
4681 | @return LinearAddress\r | |
4682 | **/\r | |
4683 | VOID *\r | |
4684 | EFIAPI\r | |
4685 | AsmFlushCacheLine (\r | |
4686 | IN VOID *LinearAddress\r | |
4687 | );\r | |
4688 | \r | |
4689 | /**\r | |
4690 | Enables the 32-bit paging mode on the CPU.\r | |
4691 | \r | |
4692 | Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables\r | |
4693 | must be properly initialized prior to calling this service. This function\r | |
4694 | assumes the current execution mode is 32-bit protected mode. This function is\r | |
4695 | only available on IA-32. After the 32-bit paging mode is enabled, control is\r | |
4696 | transferred to the function specified by EntryPoint using the new stack\r | |
4697 | specified by NewStack and passing in the parameters specified by Context1 and\r | |
4698 | Context2. Context1 and Context2 are optional and may be NULL. The function\r | |
4699 | EntryPoint must never return.\r | |
4700 | \r | |
4701 | If the current execution mode is not 32-bit protected mode, then ASSERT().\r | |
4702 | If EntryPoint is NULL, then ASSERT().\r | |
4703 | If NewStack is NULL, then ASSERT().\r | |
4704 | \r | |
4705 | There are a number of constraints that must be followed before calling this\r | |
4706 | function:\r | |
4707 | 1) Interrupts must be disabled.\r | |
4708 | 2) The caller must be in 32-bit protected mode with flat descriptors. This\r | |
4709 | means all descriptors must have a base of 0 and a limit of 4GB.\r | |
4710 | 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat\r | |
4711 | descriptors.\r | |
4712 | 4) CR3 must point to valid page tables that will be used once the transition\r | |
4713 | is complete, and those page tables must guarantee that the pages for this\r | |
4714 | function and the stack are identity mapped.\r | |
4715 | \r | |
4716 | @param EntryPoint A pointer to function to call with the new stack after\r | |
4717 | paging is enabled.\r | |
4718 | @param Context1 A pointer to the context to pass into the EntryPoint\r | |
4719 | function as the first parameter after paging is enabled.\r | |
4720 | @param Context2 A pointer to the context to pass into the EntryPoint\r | |
4721 | function as the second parameter after paging is enabled.\r | |
4722 | @param NewStack A pointer to the new stack to use for the EntryPoint\r | |
4723 | function after paging is enabled.\r | |
4724 | \r | |
4725 | **/\r | |
4726 | VOID\r | |
4727 | EFIAPI\r | |
4728 | AsmEnablePaging32 (\r | |
4729 | IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r | |
4730 | IN VOID *Context1, OPTIONAL\r | |
4731 | IN VOID *Context2, OPTIONAL\r | |
4732 | IN VOID *NewStack\r | |
4733 | );\r | |
4734 | \r | |
4735 | /**\r | |
4736 | Disables the 32-bit paging mode on the CPU.\r | |
4737 | \r | |
4738 | Disables the 32-bit paging mode on the CPU and returns to 32-bit protected\r | |
4739 | mode. This function assumes the current execution mode is 32-paged protected\r | |
4740 | mode. This function is only available on IA-32. After the 32-bit paging mode\r | |
4741 | is disabled, control is transferred to the function specified by EntryPoint\r | |
4742 | using the new stack specified by NewStack and passing in the parameters\r | |
4743 | specified by Context1 and Context2. Context1 and Context2 are optional and\r | |
4744 | may be NULL. The function EntryPoint must never return.\r | |
4745 | \r | |
4746 | If the current execution mode is not 32-bit paged mode, then ASSERT().\r | |
4747 | If EntryPoint is NULL, then ASSERT().\r | |
4748 | If NewStack is NULL, then ASSERT().\r | |
4749 | \r | |
4750 | There are a number of constraints that must be followed before calling this\r | |
4751 | function:\r | |
4752 | 1) Interrupts must be disabled.\r | |
4753 | 2) The caller must be in 32-bit paged mode.\r | |
4754 | 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.\r | |
4755 | 4) CR3 must point to valid page tables that guarantee that the pages for\r | |
4756 | this function and the stack are identity mapped.\r | |
4757 | \r | |
4758 | @param EntryPoint A pointer to function to call with the new stack after\r | |
4759 | paging is disabled.\r | |
4760 | @param Context1 A pointer to the context to pass into the EntryPoint\r | |
4761 | function as the first parameter after paging is disabled.\r | |
4762 | @param Context2 A pointer to the context to pass into the EntryPoint\r | |
4763 | function as the second parameter after paging is\r | |
4764 | disabled.\r | |
4765 | @param NewStack A pointer to the new stack to use for the EntryPoint\r | |
4766 | function after paging is disabled.\r | |
4767 | \r | |
4768 | **/\r | |
4769 | VOID\r | |
4770 | EFIAPI\r | |
4771 | AsmDisablePaging32 (\r | |
4772 | IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r | |
4773 | IN VOID *Context1, OPTIONAL\r | |
4774 | IN VOID *Context2, OPTIONAL\r | |
4775 | IN VOID *NewStack\r | |
4776 | );\r | |
4777 | \r | |
4778 | /**\r | |
4779 | Enables the 64-bit paging mode on the CPU.\r | |
4780 | \r | |
4781 | Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables\r | |
4782 | must be properly initialized prior to calling this service. This function\r | |
4783 | assumes the current execution mode is 32-bit protected mode with flat\r | |
4784 | descriptors. This function is only available on IA-32. After the 64-bit\r | |
4785 | paging mode is enabled, control is transferred to the function specified by\r | |
4786 | EntryPoint using the new stack specified by NewStack and passing in the\r | |
4787 | parameters specified by Context1 and Context2. Context1 and Context2 are\r | |
4788 | optional and may be 0. The function EntryPoint must never return.\r | |
4789 | \r | |
4790 | If the current execution mode is not 32-bit protected mode with flat\r | |
4791 | descriptors, then ASSERT().\r | |
4792 | If EntryPoint is 0, then ASSERT().\r | |
4793 | If NewStack is 0, then ASSERT().\r | |
4794 | \r | |
4795 | @param Cs The 16-bit selector to load in the CS before EntryPoint\r | |
4796 | is called. The descriptor in the GDT that this selector\r | |
4797 | references must be setup for long mode.\r | |
4798 | @param EntryPoint The 64-bit virtual address of the function to call with\r | |
4799 | the new stack after paging is enabled.\r | |
4800 | @param Context1 The 64-bit virtual address of the context to pass into\r | |
4801 | the EntryPoint function as the first parameter after\r | |
4802 | paging is enabled.\r | |
4803 | @param Context2 The 64-bit virtual address of the context to pass into\r | |
4804 | the EntryPoint function as the second parameter after\r | |
4805 | paging is enabled.\r | |
4806 | @param NewStack The 64-bit virtual address of the new stack to use for\r | |
4807 | the EntryPoint function after paging is enabled.\r | |
4808 | \r | |
4809 | **/\r | |
4810 | VOID\r | |
4811 | EFIAPI\r | |
4812 | AsmEnablePaging64 (\r | |
4813 | IN UINT16 CodeSelector,\r | |
4814 | IN UINT64 EntryPoint,\r | |
4815 | IN UINT64 Context1, OPTIONAL\r | |
4816 | IN UINT64 Context2, OPTIONAL\r | |
4817 | IN UINT64 NewStack\r | |
4818 | );\r | |
4819 | \r | |
4820 | /**\r | |
4821 | Disables the 64-bit paging mode on the CPU.\r | |
4822 | \r | |
4823 | Disables the 64-bit paging mode on the CPU and returns to 32-bit protected\r | |
4824 | mode. This function assumes the current execution mode is 64-paging mode.\r | |
4825 | This function is only available on X64. After the 64-bit paging mode is\r | |
4826 | disabled, control is transferred to the function specified by EntryPoint\r | |
4827 | using the new stack specified by NewStack and passing in the parameters\r | |
4828 | specified by Context1 and Context2. Context1 and Context2 are optional and\r | |
4829 | may be 0. The function EntryPoint must never return.\r | |
4830 | \r | |
4831 | If the current execution mode is not 64-bit paged mode, then ASSERT().\r | |
4832 | If EntryPoint is 0, then ASSERT().\r | |
4833 | If NewStack is 0, then ASSERT().\r | |
4834 | \r | |
4835 | @param Cs The 16-bit selector to load in the CS before EntryPoint\r | |
4836 | is called. The descriptor in the GDT that this selector\r | |
4837 | references must be setup for 32-bit protected mode.\r | |
4838 | @param EntryPoint The 64-bit virtual address of the function to call with\r | |
4839 | the new stack after paging is disabled.\r | |
4840 | @param Context1 The 64-bit virtual address of the context to pass into\r | |
4841 | the EntryPoint function as the first parameter after\r | |
4842 | paging is disabled.\r | |
4843 | @param Context2 The 64-bit virtual address of the context to pass into\r | |
4844 | the EntryPoint function as the second parameter after\r | |
4845 | paging is disabled.\r | |
4846 | @param NewStack The 64-bit virtual address of the new stack to use for\r | |
4847 | the EntryPoint function after paging is disabled.\r | |
4848 | \r | |
4849 | **/\r | |
4850 | VOID\r | |
4851 | EFIAPI\r | |
4852 | AsmDisablePaging64 (\r | |
4853 | IN UINT16 CodeSelector,\r | |
4854 | IN UINT32 EntryPoint,\r | |
4855 | IN UINT32 Context1, OPTIONAL\r | |
4856 | IN UINT32 Context2, OPTIONAL\r | |
4857 | IN UINT32 NewStack\r | |
4858 | );\r | |
4859 | \r | |
4860 | //\r | |
4861 | // 16-bit thunking services\r | |
4862 | //\r | |
4863 | \r | |
97d92bda | 4864 | /**\r |
4865 | Retrieves the properties for 16-bit thunk functions.\r | |
4866 | \r | |
4867 | Computes the size of the buffer and stack below 1MB required to use the\r | |
4868 | AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This\r | |
4869 | buffer size is returned in RealModeBufferSize, and the stack size is returned\r | |
4870 | in ExtraStackSize. If parameters are passed to the 16-bit real mode code,\r | |
4871 | then the actual minimum stack size is ExtraStackSize plus the maximum number\r | |
4872 | of bytes that need to be passed to the 16-bit real mode code.\r | |
4873 | \r | |
4874 | If RealModeBufferSize is NULL, then ASSERT().\r | |
4875 | If ExtraStackSize is NULL, then ASSERT().\r | |
4876 | \r | |
4877 | @param RealModeBufferSize A pointer to the size of the buffer below 1MB\r | |
4878 | required to use the 16-bit thunk functions.\r | |
4879 | @param ExtraStackSize A pointer to the extra size of stack below 1MB\r | |
4880 | that the 16-bit thunk functions require for\r | |
4881 | temporary storage in the transition to and from\r | |
4882 | 16-bit real mode.\r | |
4883 | \r | |
4884 | **/\r | |
4885 | VOID\r | |
4886 | EFIAPI\r | |
4887 | AsmGetThunk16Properties (\r | |
4888 | OUT UINT32 *RealModeBufferSize,\r | |
4889 | OUT UINT32 *ExtraStackSize\r | |
4890 | );\r | |
4891 | \r | |
878ddf1f | 4892 | /**\r |
4893 | Prepares all structures a code required to use AsmThunk16().\r | |
4894 | \r | |
4895 | Prepares all structures and code required to use AsmThunk16().\r | |
4896 | \r | |
4897 | If ThunkContext is NULL, then ASSERT().\r | |
4898 | \r | |
4899 | @param ThunkContext A pointer to the context structure that describes the\r | |
4900 | 16-bit real mode code to call.\r | |
4901 | \r | |
4902 | **/\r | |
4903 | VOID\r | |
4904 | EFIAPI\r | |
4905 | AsmPrepareThunk16 (\r | |
4906 | OUT THUNK_CONTEXT *ThunkContext\r | |
4907 | );\r | |
4908 | \r | |
4909 | /**\r | |
4910 | Transfers control to a 16-bit real mode entry point and returns the results.\r | |
4911 | \r | |
4912 | Transfers control to a 16-bit real mode entry point and returns the results.\r | |
4913 | AsmPrepareThunk16() must be called with ThunkContext before this function is\r | |
4914 | used.\r | |
4915 | \r | |
4916 | If ThunkContext is NULL, then ASSERT().\r | |
4917 | If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().\r | |
4918 | \r | |
4919 | @param ThunkContext A pointer to the context structure that describes the\r | |
4920 | 16-bit real mode code to call.\r | |
4921 | \r | |
4922 | **/\r | |
4923 | VOID\r | |
4924 | EFIAPI\r | |
4925 | AsmThunk16 (\r | |
4926 | IN OUT THUNK_CONTEXT *ThunkContext\r | |
4927 | );\r | |
4928 | \r | |
4929 | /**\r | |
4930 | Prepares all structures and code for a 16-bit real mode thunk, transfers\r | |
4931 | control to a 16-bit real mode entry point, and returns the results.\r | |
4932 | \r | |
4933 | Prepares all structures and code for a 16-bit real mode thunk, transfers\r | |
4934 | control to a 16-bit real mode entry point, and returns the results. If the\r | |
4935 | caller only need to perform a single 16-bit real mode thunk, then this\r | |
4936 | service should be used. If the caller intends to make more than one 16-bit\r | |
4937 | real mode thunk, then it is more efficient if AsmPrepareThunk16() is called\r | |
4938 | once and AsmThunk16() can be called for each 16-bit real mode thunk.\r | |
4939 | \r | |
4940 | If ThunkContext is NULL, then ASSERT().\r | |
4941 | \r | |
4942 | @param ThunkContext A pointer to the context structure that describes the\r | |
4943 | 16-bit real mode code to call.\r | |
4944 | \r | |
4945 | **/\r | |
4946 | VOID\r | |
4947 | EFIAPI\r | |
4948 | AsmPrepareAndThunk16 (\r | |
4949 | IN OUT THUNK_CONTEXT *ThunkContext\r | |
4950 | );\r | |
4951 | \r | |
4952 | #endif\r |