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