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