1 | /** @file
|
---|
2 | Provides string functions, linked list functions, math functions, synchronization
|
---|
3 | functions, file path functions, and CPU architecture-specific functions.
|
---|
4 |
|
---|
5 | Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.<BR>
|
---|
6 | Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
|
---|
7 | Copyright (c) Microsoft Corporation.<BR>
|
---|
8 | Portions Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights reserved.<BR>
|
---|
9 | Portions Copyright (c) 2022, Loongson Technology Corporation Limited. All rights reserved.<BR>
|
---|
10 |
|
---|
11 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
12 |
|
---|
13 | **/
|
---|
14 |
|
---|
15 | #ifndef __BASE_LIB__
|
---|
16 | #define __BASE_LIB__
|
---|
17 |
|
---|
18 | //
|
---|
19 | // Definitions for architecture-specific types
|
---|
20 | //
|
---|
21 | #if defined (MDE_CPU_IA32)
|
---|
22 | ///
|
---|
23 | /// The IA-32 architecture context buffer used by SetJump() and LongJump().
|
---|
24 | ///
|
---|
25 | typedef struct {
|
---|
26 | UINT32 Ebx;
|
---|
27 | UINT32 Esi;
|
---|
28 | UINT32 Edi;
|
---|
29 | UINT32 Ebp;
|
---|
30 | UINT32 Esp;
|
---|
31 | UINT32 Eip;
|
---|
32 | UINT32 Ssp;
|
---|
33 | } BASE_LIBRARY_JUMP_BUFFER;
|
---|
34 |
|
---|
35 | #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 4
|
---|
36 |
|
---|
37 | #endif // defined (MDE_CPU_IA32)
|
---|
38 |
|
---|
39 | #if defined (MDE_CPU_X64)
|
---|
40 | ///
|
---|
41 | /// The x64 architecture context buffer used by SetJump() and LongJump().
|
---|
42 | ///
|
---|
43 | typedef struct {
|
---|
44 | UINT64 Rbx;
|
---|
45 | UINT64 Rsp;
|
---|
46 | UINT64 Rbp;
|
---|
47 | UINT64 Rdi;
|
---|
48 | UINT64 Rsi;
|
---|
49 | UINT64 R12;
|
---|
50 | UINT64 R13;
|
---|
51 | UINT64 R14;
|
---|
52 | UINT64 R15;
|
---|
53 | UINT64 Rip;
|
---|
54 | UINT64 MxCsr;
|
---|
55 | UINT8 XmmBuffer[160]; ///< XMM6-XMM15.
|
---|
56 | UINT64 Ssp;
|
---|
57 | } BASE_LIBRARY_JUMP_BUFFER;
|
---|
58 |
|
---|
59 | #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
|
---|
60 |
|
---|
61 | #endif // defined (MDE_CPU_X64)
|
---|
62 |
|
---|
63 | #if defined (MDE_CPU_EBC)
|
---|
64 | ///
|
---|
65 | /// The EBC context buffer used by SetJump() and LongJump().
|
---|
66 | ///
|
---|
67 | typedef struct {
|
---|
68 | UINT64 R0;
|
---|
69 | UINT64 R1;
|
---|
70 | UINT64 R2;
|
---|
71 | UINT64 R3;
|
---|
72 | UINT64 IP;
|
---|
73 | } BASE_LIBRARY_JUMP_BUFFER;
|
---|
74 |
|
---|
75 | #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
|
---|
76 |
|
---|
77 | #endif // defined (MDE_CPU_EBC)
|
---|
78 |
|
---|
79 | #if defined (MDE_CPU_ARM)
|
---|
80 |
|
---|
81 | typedef struct {
|
---|
82 | UINT32 R3; ///< A copy of R13.
|
---|
83 | UINT32 R4;
|
---|
84 | UINT32 R5;
|
---|
85 | UINT32 R6;
|
---|
86 | UINT32 R7;
|
---|
87 | UINT32 R8;
|
---|
88 | UINT32 R9;
|
---|
89 | UINT32 R10;
|
---|
90 | UINT32 R11;
|
---|
91 | UINT32 R12;
|
---|
92 | UINT32 R14;
|
---|
93 | } BASE_LIBRARY_JUMP_BUFFER;
|
---|
94 |
|
---|
95 | #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 4
|
---|
96 |
|
---|
97 | #endif // defined (MDE_CPU_ARM)
|
---|
98 |
|
---|
99 | #if defined (MDE_CPU_AARCH64)
|
---|
100 | typedef struct {
|
---|
101 | // GP regs
|
---|
102 | UINT64 X19;
|
---|
103 | UINT64 X20;
|
---|
104 | UINT64 X21;
|
---|
105 | UINT64 X22;
|
---|
106 | UINT64 X23;
|
---|
107 | UINT64 X24;
|
---|
108 | UINT64 X25;
|
---|
109 | UINT64 X26;
|
---|
110 | UINT64 X27;
|
---|
111 | UINT64 X28;
|
---|
112 | UINT64 FP;
|
---|
113 | UINT64 LR;
|
---|
114 | UINT64 IP0;
|
---|
115 |
|
---|
116 | // FP regs
|
---|
117 | UINT64 D8;
|
---|
118 | UINT64 D9;
|
---|
119 | UINT64 D10;
|
---|
120 | UINT64 D11;
|
---|
121 | UINT64 D12;
|
---|
122 | UINT64 D13;
|
---|
123 | UINT64 D14;
|
---|
124 | UINT64 D15;
|
---|
125 | } BASE_LIBRARY_JUMP_BUFFER;
|
---|
126 |
|
---|
127 | #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
|
---|
128 |
|
---|
129 | #endif // defined (MDE_CPU_AARCH64)
|
---|
130 |
|
---|
131 | #if defined (MDE_CPU_RISCV64)
|
---|
132 | ///
|
---|
133 | /// The RISC-V architecture context buffer used by SetJump() and LongJump().
|
---|
134 | ///
|
---|
135 | typedef struct {
|
---|
136 | UINT64 RA;
|
---|
137 | UINT64 S0;
|
---|
138 | UINT64 S1;
|
---|
139 | UINT64 S2;
|
---|
140 | UINT64 S3;
|
---|
141 | UINT64 S4;
|
---|
142 | UINT64 S5;
|
---|
143 | UINT64 S6;
|
---|
144 | UINT64 S7;
|
---|
145 | UINT64 S8;
|
---|
146 | UINT64 S9;
|
---|
147 | UINT64 S10;
|
---|
148 | UINT64 S11;
|
---|
149 | UINT64 SP;
|
---|
150 | } BASE_LIBRARY_JUMP_BUFFER;
|
---|
151 |
|
---|
152 | #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
|
---|
153 |
|
---|
154 | VOID
|
---|
155 | RiscVSetSupervisorScratch (
|
---|
156 | IN UINT64
|
---|
157 | );
|
---|
158 |
|
---|
159 | UINT64
|
---|
160 | RiscVGetSupervisorScratch (
|
---|
161 | VOID
|
---|
162 | );
|
---|
163 |
|
---|
164 | VOID
|
---|
165 | RiscVSetSupervisorStvec (
|
---|
166 | IN UINT64
|
---|
167 | );
|
---|
168 |
|
---|
169 | UINT64
|
---|
170 | RiscVGetSupervisorStvec (
|
---|
171 | VOID
|
---|
172 | );
|
---|
173 |
|
---|
174 | UINT64
|
---|
175 | RiscVGetSupervisorTrapCause (
|
---|
176 | VOID
|
---|
177 | );
|
---|
178 |
|
---|
179 | VOID
|
---|
180 | RiscVSetSupervisorAddressTranslationRegister (
|
---|
181 | IN UINT64
|
---|
182 | );
|
---|
183 |
|
---|
184 | UINT64
|
---|
185 | RiscVGetSupervisorAddressTranslationRegister (
|
---|
186 | VOID
|
---|
187 | );
|
---|
188 |
|
---|
189 | UINT64
|
---|
190 | RiscVReadTimer (
|
---|
191 | VOID
|
---|
192 | );
|
---|
193 |
|
---|
194 | VOID
|
---|
195 | RiscVSetSupervisorTimeCompareRegister (
|
---|
196 | IN UINT64
|
---|
197 | );
|
---|
198 |
|
---|
199 | VOID
|
---|
200 | RiscVEnableTimerInterrupt (
|
---|
201 | VOID
|
---|
202 | );
|
---|
203 |
|
---|
204 | VOID
|
---|
205 | RiscVDisableTimerInterrupt (
|
---|
206 | VOID
|
---|
207 | );
|
---|
208 |
|
---|
209 | VOID
|
---|
210 | RiscVClearPendingTimerInterrupt (
|
---|
211 | VOID
|
---|
212 | );
|
---|
213 |
|
---|
214 | /**
|
---|
215 | RISC-V invalidate instruction cache.
|
---|
216 |
|
---|
217 | **/
|
---|
218 | VOID
|
---|
219 | EFIAPI
|
---|
220 | RiscVInvalidateInstCacheFenceAsm (
|
---|
221 | VOID
|
---|
222 | );
|
---|
223 |
|
---|
224 | /**
|
---|
225 | RISC-V invalidate data cache.
|
---|
226 |
|
---|
227 | **/
|
---|
228 | VOID
|
---|
229 | EFIAPI
|
---|
230 | RiscVInvalidateDataCacheFenceAsm (
|
---|
231 | VOID
|
---|
232 | );
|
---|
233 |
|
---|
234 | /**
|
---|
235 | RISC-V flush cache block. Atomically perform a clean operation
|
---|
236 | followed by an invalidate operation
|
---|
237 |
|
---|
238 | **/
|
---|
239 | VOID
|
---|
240 | EFIAPI
|
---|
241 | RiscVCpuCacheFlushCmoAsm (
|
---|
242 | IN UINTN
|
---|
243 | );
|
---|
244 |
|
---|
245 | /**
|
---|
246 | Perform a write transfer to another cache or to memory if the
|
---|
247 | data in the copy of the cache block have been modified by a store
|
---|
248 | operation
|
---|
249 |
|
---|
250 | **/
|
---|
251 | VOID
|
---|
252 | EFIAPI
|
---|
253 | RiscVCpuCacheCleanCmoAsm (
|
---|
254 | IN UINTN
|
---|
255 | );
|
---|
256 |
|
---|
257 | /**
|
---|
258 | Deallocate the copy of the cache block
|
---|
259 |
|
---|
260 | **/
|
---|
261 | VOID
|
---|
262 | EFIAPI
|
---|
263 | RiscVCpuCacheInvalCmoAsm (
|
---|
264 | IN UINTN
|
---|
265 | );
|
---|
266 |
|
---|
267 | #endif // defined (MDE_CPU_RISCV64)
|
---|
268 |
|
---|
269 | #if defined (MDE_CPU_LOONGARCH64)
|
---|
270 | ///
|
---|
271 | /// The LoongArch architecture context buffer used by SetJump() and LongJump()
|
---|
272 | ///
|
---|
273 | typedef struct {
|
---|
274 | UINT64 S0;
|
---|
275 | UINT64 S1;
|
---|
276 | UINT64 S2;
|
---|
277 | UINT64 S3;
|
---|
278 | UINT64 S4;
|
---|
279 | UINT64 S5;
|
---|
280 | UINT64 S6;
|
---|
281 | UINT64 S7;
|
---|
282 | UINT64 S8;
|
---|
283 | UINT64 SP;
|
---|
284 | UINT64 FP;
|
---|
285 | UINT64 RA;
|
---|
286 | } BASE_LIBRARY_JUMP_BUFFER;
|
---|
287 |
|
---|
288 | #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8
|
---|
289 |
|
---|
290 | /*
|
---|
291 | * Set the exception base address for LoongArch.
|
---|
292 | *
|
---|
293 | * @param ExceptionBaseAddress The exception base address, must be aligned greater than or qeual to 4K .
|
---|
294 | */
|
---|
295 | VOID
|
---|
296 | SetExceptionBaseAddress (
|
---|
297 | IN UINT64
|
---|
298 | );
|
---|
299 |
|
---|
300 | /*
|
---|
301 | * Set the TlbRebase address for LoongArch.
|
---|
302 | *
|
---|
303 | * @param TlbRebaseAddress The TlbRebase address, must be aligned greater than or qeual to 4K .
|
---|
304 | */
|
---|
305 | VOID
|
---|
306 | SetTlbRebaseAddress (
|
---|
307 | IN UINT64
|
---|
308 | );
|
---|
309 |
|
---|
310 | /**
|
---|
311 | Enables local CPU interrupts.
|
---|
312 |
|
---|
313 | @param Needs to enable local interrupt bit.
|
---|
314 | **/
|
---|
315 | VOID
|
---|
316 | EnableLocalInterrupts (
|
---|
317 | IN UINT16
|
---|
318 | );
|
---|
319 |
|
---|
320 | /**
|
---|
321 | Disables local CPU interrupts.
|
---|
322 |
|
---|
323 | @param Needs to disable local interrupt bit.
|
---|
324 | **/
|
---|
325 | VOID
|
---|
326 | DisableLocalInterrupts (
|
---|
327 | IN UINT16
|
---|
328 | );
|
---|
329 |
|
---|
330 | /**
|
---|
331 | Read CPUCFG register.
|
---|
332 |
|
---|
333 | @param Index Specifies the register number of the CPUCFG to read the data.
|
---|
334 | @param Data A pointer to the variable used to store the CPUCFG register value.
|
---|
335 | **/
|
---|
336 | VOID
|
---|
337 | AsmCpucfg (
|
---|
338 | IN UINT32 Index,
|
---|
339 | OUT UINT32 *Data
|
---|
340 | );
|
---|
341 |
|
---|
342 | /**
|
---|
343 | Gets the timer count value.
|
---|
344 |
|
---|
345 | @param[] VOID
|
---|
346 | @retval timer count value.
|
---|
347 |
|
---|
348 | **/
|
---|
349 | UINTN
|
---|
350 | AsmReadStableCounter (
|
---|
351 | VOID
|
---|
352 | );
|
---|
353 |
|
---|
354 | /**
|
---|
355 | CSR read operation.
|
---|
356 |
|
---|
357 | @param[in] Select CSR read instruction select values.
|
---|
358 |
|
---|
359 | @return The return value of csrrd instruction, return -1 means no CSR instruction
|
---|
360 | is found.
|
---|
361 | **/
|
---|
362 | UINTN
|
---|
363 | CsrRead (
|
---|
364 | IN UINT16 Select
|
---|
365 | );
|
---|
366 |
|
---|
367 | /**
|
---|
368 | CSR write operation.
|
---|
369 |
|
---|
370 | @param[in] Select CSR write instruction select values.
|
---|
371 | @param[in] Value The csrwr will write the value.
|
---|
372 |
|
---|
373 | @return The return value of csrwr instruction, that is, store the old value of
|
---|
374 | the register, return -1 means no CSR instruction is found.
|
---|
375 | **/
|
---|
376 | UINTN
|
---|
377 | CsrWrite (
|
---|
378 | IN UINT16 Select,
|
---|
379 | IN UINTN Value
|
---|
380 | );
|
---|
381 |
|
---|
382 | /**
|
---|
383 | CSR exchange operation.
|
---|
384 |
|
---|
385 | @param[in] Select CSR exchange instruction select values.
|
---|
386 | @param[in] Value The csrxchg will write the value.
|
---|
387 | @param[in] Mask The csrxchg mask value.
|
---|
388 |
|
---|
389 | @return The return value of csrxchg instruction, that is, store the old value of
|
---|
390 | the register, return -1 means no CSR instruction is found.
|
---|
391 | **/
|
---|
392 | UINTN
|
---|
393 | CsrXChg (
|
---|
394 | IN UINT16 Select,
|
---|
395 | IN UINTN Value,
|
---|
396 | IN UINTN Mask
|
---|
397 | );
|
---|
398 |
|
---|
399 | /**
|
---|
400 | IO CSR read byte operation.
|
---|
401 |
|
---|
402 | @param[in] Select IO CSR read instruction select values.
|
---|
403 |
|
---|
404 | @return The return value of iocsrrd.b instruction.
|
---|
405 |
|
---|
406 | **/
|
---|
407 | UINT8
|
---|
408 | IoCsrRead8 (
|
---|
409 | IN UINTN Select
|
---|
410 | );
|
---|
411 |
|
---|
412 | /**
|
---|
413 | IO CSR read half word operation.
|
---|
414 |
|
---|
415 | @param[in] Select IO CSR read instruction select values.
|
---|
416 |
|
---|
417 | @return The return value of iocsrrd.h instruction.
|
---|
418 |
|
---|
419 | **/
|
---|
420 | UINT16
|
---|
421 | IoCsrRead16 (
|
---|
422 | IN UINTN Select
|
---|
423 | );
|
---|
424 |
|
---|
425 | /**
|
---|
426 | IO CSR read word operation.
|
---|
427 |
|
---|
428 | @param[in] Select IO CSR read instruction select values.
|
---|
429 |
|
---|
430 | @return The return value of iocsrrd.w instruction.
|
---|
431 |
|
---|
432 | **/
|
---|
433 | UINT32
|
---|
434 | IoCsrRead32 (
|
---|
435 | IN UINTN Select
|
---|
436 | );
|
---|
437 |
|
---|
438 | /**
|
---|
439 | IO CSR read double word operation. Only for LoongArch64.
|
---|
440 |
|
---|
441 | @param[in] Select IO CSR read instruction select values.
|
---|
442 |
|
---|
443 | @return The return value of iocsrrd.d instruction.
|
---|
444 |
|
---|
445 | **/
|
---|
446 | UINT64
|
---|
447 | IoCsrRead64 (
|
---|
448 | IN UINTN Select
|
---|
449 | );
|
---|
450 |
|
---|
451 | /**
|
---|
452 | IO CSR write byte operation.
|
---|
453 |
|
---|
454 | @param[in] Select IO CSR write instruction select values.
|
---|
455 | @param[in] Value The iocsrwr.b will write the value.
|
---|
456 |
|
---|
457 | @return VOID.
|
---|
458 |
|
---|
459 | **/
|
---|
460 | VOID
|
---|
461 | IoCsrWrite8 (
|
---|
462 | IN UINTN Select,
|
---|
463 | IN UINT8 Value
|
---|
464 | );
|
---|
465 |
|
---|
466 | /**
|
---|
467 | IO CSR write half word operation.
|
---|
468 |
|
---|
469 | @param[in] Select IO CSR write instruction select values.
|
---|
470 | @param[in] Value The iocsrwr.h will write the value.
|
---|
471 |
|
---|
472 | @return VOID.
|
---|
473 |
|
---|
474 | **/
|
---|
475 | VOID
|
---|
476 | IoCsrWrite16 (
|
---|
477 | IN UINTN Select,
|
---|
478 | IN UINT16 Value
|
---|
479 | );
|
---|
480 |
|
---|
481 | /**
|
---|
482 | IO CSR write word operation.
|
---|
483 |
|
---|
484 | @param[in] Select IO CSR write instruction select values.
|
---|
485 | @param[in] Value The iocsrwr.w will write the value.
|
---|
486 |
|
---|
487 | @return VOID.
|
---|
488 |
|
---|
489 | **/
|
---|
490 | VOID
|
---|
491 | IoCsrWrite32 (
|
---|
492 | IN UINTN Select,
|
---|
493 | IN UINT32 Value
|
---|
494 | );
|
---|
495 |
|
---|
496 | /**
|
---|
497 | IO CSR write double word operation. Only for LoongArch64.
|
---|
498 |
|
---|
499 | @param[in] Select IO CSR write instruction select values.
|
---|
500 | @param[in] Value The iocsrwr.d will write the value.
|
---|
501 |
|
---|
502 | @return VOID.
|
---|
503 |
|
---|
504 | **/
|
---|
505 | VOID
|
---|
506 | IoCsrWrite64 (
|
---|
507 | IN UINTN Select,
|
---|
508 | IN UINT64 Value
|
---|
509 | );
|
---|
510 |
|
---|
511 | #endif // defined (MDE_CPU_LOONGARCH64)
|
---|
512 |
|
---|
513 | //
|
---|
514 | // String Services
|
---|
515 | //
|
---|
516 |
|
---|
517 | /**
|
---|
518 | Returns the length of a Null-terminated Unicode string.
|
---|
519 |
|
---|
520 | This function is similar as strlen_s defined in C11.
|
---|
521 |
|
---|
522 | If String is not aligned on a 16-bit boundary, then ASSERT().
|
---|
523 |
|
---|
524 | @param String A pointer to a Null-terminated Unicode string.
|
---|
525 | @param MaxSize The maximum number of Destination Unicode
|
---|
526 | char, including terminating null char.
|
---|
527 |
|
---|
528 | @retval 0 If String is NULL.
|
---|
529 | @retval MaxSize If there is no null character in the first MaxSize characters of String.
|
---|
530 | @return The number of characters that percede the terminating null character.
|
---|
531 |
|
---|
532 | **/
|
---|
533 | UINTN
|
---|
534 | EFIAPI
|
---|
535 | StrnLenS (
|
---|
536 | IN CONST CHAR16 *String,
|
---|
537 | IN UINTN MaxSize
|
---|
538 | );
|
---|
539 |
|
---|
540 | /**
|
---|
541 | Returns the size of a Null-terminated Unicode string in bytes, including the
|
---|
542 | Null terminator.
|
---|
543 |
|
---|
544 | This function returns the size of the Null-terminated Unicode string
|
---|
545 | specified by String in bytes, including the Null terminator.
|
---|
546 |
|
---|
547 | If String is not aligned on a 16-bit boundary, then ASSERT().
|
---|
548 |
|
---|
549 | @param String A pointer to a Null-terminated Unicode string.
|
---|
550 | @param MaxSize The maximum number of Destination Unicode
|
---|
551 | char, including the Null terminator.
|
---|
552 |
|
---|
553 | @retval 0 If String is NULL.
|
---|
554 | @retval (sizeof (CHAR16) * (MaxSize + 1))
|
---|
555 | If there is no Null terminator in the first MaxSize characters of
|
---|
556 | String.
|
---|
557 | @return The size of the Null-terminated Unicode string in bytes, including
|
---|
558 | the Null terminator.
|
---|
559 |
|
---|
560 | **/
|
---|
561 | UINTN
|
---|
562 | EFIAPI
|
---|
563 | StrnSizeS (
|
---|
564 | IN CONST CHAR16 *String,
|
---|
565 | IN UINTN MaxSize
|
---|
566 | );
|
---|
567 |
|
---|
568 | /**
|
---|
569 | Copies the string pointed to by Source (including the terminating null char)
|
---|
570 | to the array pointed to by Destination.
|
---|
571 |
|
---|
572 | This function is similar as strcpy_s defined in C11.
|
---|
573 |
|
---|
574 | If Destination is not aligned on a 16-bit boundary, then ASSERT().
|
---|
575 | If Source is not aligned on a 16-bit boundary, then ASSERT().
|
---|
576 |
|
---|
577 | If an error is returned, then the Destination is unmodified.
|
---|
578 |
|
---|
579 | @param Destination A pointer to a Null-terminated Unicode string.
|
---|
580 | @param DestMax The maximum number of Destination Unicode
|
---|
581 | char, including terminating null char.
|
---|
582 | @param Source A pointer to a Null-terminated Unicode string.
|
---|
583 |
|
---|
584 | @retval RETURN_SUCCESS String is copied.
|
---|
585 | @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).
|
---|
586 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.
|
---|
587 | If Source is NULL.
|
---|
588 | If PcdMaximumUnicodeStringLength is not zero,
|
---|
589 | and DestMax is greater than
|
---|
590 | PcdMaximumUnicodeStringLength.
|
---|
591 | If DestMax is 0.
|
---|
592 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
|
---|
593 | **/
|
---|
594 | RETURN_STATUS
|
---|
595 | EFIAPI
|
---|
596 | StrCpyS (
|
---|
597 | OUT CHAR16 *Destination,
|
---|
598 | IN UINTN DestMax,
|
---|
599 | IN CONST CHAR16 *Source
|
---|
600 | );
|
---|
601 |
|
---|
602 | /**
|
---|
603 | Copies not more than Length successive char from the string pointed to by
|
---|
604 | Source to the array pointed to by Destination. If no null char is copied from
|
---|
605 | Source, then Destination[Length] is always set to null.
|
---|
606 |
|
---|
607 | This function is similar as strncpy_s defined in C11.
|
---|
608 |
|
---|
609 | If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().
|
---|
610 | If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().
|
---|
611 |
|
---|
612 | If an error is returned, then the Destination is unmodified.
|
---|
613 |
|
---|
614 | @param Destination A pointer to a Null-terminated Unicode string.
|
---|
615 | @param DestMax The maximum number of Destination Unicode
|
---|
616 | char, including terminating null char.
|
---|
617 | @param Source A pointer to a Null-terminated Unicode string.
|
---|
618 | @param Length The maximum number of Unicode characters to copy.
|
---|
619 |
|
---|
620 | @retval RETURN_SUCCESS String is copied.
|
---|
621 | @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than
|
---|
622 | MIN(StrLen(Source), Length).
|
---|
623 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.
|
---|
624 | If Source is NULL.
|
---|
625 | If PcdMaximumUnicodeStringLength is not zero,
|
---|
626 | and DestMax is greater than
|
---|
627 | PcdMaximumUnicodeStringLength.
|
---|
628 | If DestMax is 0.
|
---|
629 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
|
---|
630 | **/
|
---|
631 | RETURN_STATUS
|
---|
632 | EFIAPI
|
---|
633 | StrnCpyS (
|
---|
634 | OUT CHAR16 *Destination,
|
---|
635 | IN UINTN DestMax,
|
---|
636 | IN CONST CHAR16 *Source,
|
---|
637 | IN UINTN Length
|
---|
638 | );
|
---|
639 |
|
---|
640 | /**
|
---|
641 | Appends a copy of the string pointed to by Source (including the terminating
|
---|
642 | null char) to the end of the string pointed to by Destination.
|
---|
643 |
|
---|
644 | This function is similar as strcat_s defined in C11.
|
---|
645 |
|
---|
646 | If Destination is not aligned on a 16-bit boundary, then ASSERT().
|
---|
647 | If Source is not aligned on a 16-bit boundary, then ASSERT().
|
---|
648 |
|
---|
649 | If an error is returned, then the Destination is unmodified.
|
---|
650 |
|
---|
651 | @param Destination A pointer to a Null-terminated Unicode string.
|
---|
652 | @param DestMax The maximum number of Destination Unicode
|
---|
653 | char, including terminating null char.
|
---|
654 | @param Source A pointer to a Null-terminated Unicode string.
|
---|
655 |
|
---|
656 | @retval RETURN_SUCCESS String is appended.
|
---|
657 | @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than
|
---|
658 | StrLen(Destination).
|
---|
659 | @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT
|
---|
660 | greater than StrLen(Source).
|
---|
661 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.
|
---|
662 | If Source is NULL.
|
---|
663 | If PcdMaximumUnicodeStringLength is not zero,
|
---|
664 | and DestMax is greater than
|
---|
665 | PcdMaximumUnicodeStringLength.
|
---|
666 | If DestMax is 0.
|
---|
667 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
|
---|
668 | **/
|
---|
669 | RETURN_STATUS
|
---|
670 | EFIAPI
|
---|
671 | StrCatS (
|
---|
672 | IN OUT CHAR16 *Destination,
|
---|
673 | IN UINTN DestMax,
|
---|
674 | IN CONST CHAR16 *Source
|
---|
675 | );
|
---|
676 |
|
---|
677 | /**
|
---|
678 | Appends not more than Length successive char from the string pointed to by
|
---|
679 | Source to the end of the string pointed to by Destination. If no null char is
|
---|
680 | copied from Source, then Destination[StrLen(Destination) + Length] is always
|
---|
681 | set to null.
|
---|
682 |
|
---|
683 | This function is similar as strncat_s defined in C11.
|
---|
684 |
|
---|
685 | If Destination is not aligned on a 16-bit boundary, then ASSERT().
|
---|
686 | If Source is not aligned on a 16-bit boundary, then ASSERT().
|
---|
687 |
|
---|
688 | If an error is returned, then the Destination is unmodified.
|
---|
689 |
|
---|
690 | @param Destination A pointer to a Null-terminated Unicode string.
|
---|
691 | @param DestMax The maximum number of Destination Unicode
|
---|
692 | char, including terminating null char.
|
---|
693 | @param Source A pointer to a Null-terminated Unicode string.
|
---|
694 | @param Length The maximum number of Unicode characters to copy.
|
---|
695 |
|
---|
696 | @retval RETURN_SUCCESS String is appended.
|
---|
697 | @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than
|
---|
698 | StrLen(Destination).
|
---|
699 | @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT
|
---|
700 | greater than MIN(StrLen(Source), Length).
|
---|
701 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.
|
---|
702 | If Source is NULL.
|
---|
703 | If PcdMaximumUnicodeStringLength is not zero,
|
---|
704 | and DestMax is greater than
|
---|
705 | PcdMaximumUnicodeStringLength.
|
---|
706 | If DestMax is 0.
|
---|
707 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
|
---|
708 | **/
|
---|
709 | RETURN_STATUS
|
---|
710 | EFIAPI
|
---|
711 | StrnCatS (
|
---|
712 | IN OUT CHAR16 *Destination,
|
---|
713 | IN UINTN DestMax,
|
---|
714 | IN CONST CHAR16 *Source,
|
---|
715 | IN UINTN Length
|
---|
716 | );
|
---|
717 |
|
---|
718 | /**
|
---|
719 | Convert a Null-terminated Unicode decimal string to a value of type UINTN.
|
---|
720 |
|
---|
721 | This function outputs a value of type UINTN by interpreting the contents of
|
---|
722 | the Unicode string specified by String as a decimal number. The format of the
|
---|
723 | input Unicode string String is:
|
---|
724 |
|
---|
725 | [spaces] [decimal digits].
|
---|
726 |
|
---|
727 | The valid decimal digit character is in the range [0-9]. The function will
|
---|
728 | ignore the pad space, which includes spaces or tab characters, before
|
---|
729 | [decimal digits]. The running zero in the beginning of [decimal digits] will
|
---|
730 | be ignored. Then, the function stops at the first character that is a not a
|
---|
731 | valid decimal character or a Null-terminator, whichever one comes first.
|
---|
732 |
|
---|
733 | If String is not aligned in a 16-bit boundary, then ASSERT().
|
---|
734 |
|
---|
735 | If String has no valid decimal digits in the above format, then 0 is stored
|
---|
736 | at the location pointed to by Data.
|
---|
737 | If the number represented by String exceeds the range defined by UINTN, then
|
---|
738 | MAX_UINTN is stored at the location pointed to by Data.
|
---|
739 |
|
---|
740 | If EndPointer is not NULL, a pointer to the character that stopped the scan
|
---|
741 | is stored at the location pointed to by EndPointer. If String has no valid
|
---|
742 | decimal digits right after the optional pad spaces, the value of String is
|
---|
743 | stored at the location pointed to by EndPointer.
|
---|
744 |
|
---|
745 | @param String Pointer to a Null-terminated Unicode string.
|
---|
746 | @param EndPointer Pointer to character that stops scan.
|
---|
747 | @param Data Pointer to the converted value.
|
---|
748 |
|
---|
749 | @retval RETURN_SUCCESS Value is translated from String.
|
---|
750 | @retval RETURN_INVALID_PARAMETER If String is NULL.
|
---|
751 | If Data is NULL.
|
---|
752 | If PcdMaximumUnicodeStringLength is not
|
---|
753 | zero, and String contains more than
|
---|
754 | PcdMaximumUnicodeStringLength Unicode
|
---|
755 | characters, not including the
|
---|
756 | Null-terminator.
|
---|
757 | @retval RETURN_UNSUPPORTED If the number represented by String exceeds
|
---|
758 | the range defined by UINTN.
|
---|
759 |
|
---|
760 | **/
|
---|
761 | RETURN_STATUS
|
---|
762 | EFIAPI
|
---|
763 | StrDecimalToUintnS (
|
---|
764 | IN CONST CHAR16 *String,
|
---|
765 | OUT CHAR16 **EndPointer OPTIONAL,
|
---|
766 | OUT UINTN *Data
|
---|
767 | );
|
---|
768 |
|
---|
769 | /**
|
---|
770 | Convert a Null-terminated Unicode decimal string to a value of type UINT64.
|
---|
771 |
|
---|
772 | This function outputs a value of type UINT64 by interpreting the contents of
|
---|
773 | the Unicode string specified by String as a decimal number. The format of the
|
---|
774 | input Unicode string String is:
|
---|
775 |
|
---|
776 | [spaces] [decimal digits].
|
---|
777 |
|
---|
778 | The valid decimal digit character is in the range [0-9]. The function will
|
---|
779 | ignore the pad space, which includes spaces or tab characters, before
|
---|
780 | [decimal digits]. The running zero in the beginning of [decimal digits] will
|
---|
781 | be ignored. Then, the function stops at the first character that is a not a
|
---|
782 | valid decimal character or a Null-terminator, whichever one comes first.
|
---|
783 |
|
---|
784 | If String is not aligned in a 16-bit boundary, then ASSERT().
|
---|
785 |
|
---|
786 | If String has no valid decimal digits in the above format, then 0 is stored
|
---|
787 | at the location pointed to by Data.
|
---|
788 | If the number represented by String exceeds the range defined by UINT64, then
|
---|
789 | MAX_UINT64 is stored at the location pointed to by Data.
|
---|
790 |
|
---|
791 | If EndPointer is not NULL, a pointer to the character that stopped the scan
|
---|
792 | is stored at the location pointed to by EndPointer. If String has no valid
|
---|
793 | decimal digits right after the optional pad spaces, the value of String is
|
---|
794 | stored at the location pointed to by EndPointer.
|
---|
795 |
|
---|
796 | @param String Pointer to a Null-terminated Unicode string.
|
---|
797 | @param EndPointer Pointer to character that stops scan.
|
---|
798 | @param Data Pointer to the converted value.
|
---|
799 |
|
---|
800 | @retval RETURN_SUCCESS Value is translated from String.
|
---|
801 | @retval RETURN_INVALID_PARAMETER If String is NULL.
|
---|
802 | If Data is NULL.
|
---|
803 | If PcdMaximumUnicodeStringLength is not
|
---|
804 | zero, and String contains more than
|
---|
805 | PcdMaximumUnicodeStringLength Unicode
|
---|
806 | characters, not including the
|
---|
807 | Null-terminator.
|
---|
808 | @retval RETURN_UNSUPPORTED If the number represented by String exceeds
|
---|
809 | the range defined by UINT64.
|
---|
810 |
|
---|
811 | **/
|
---|
812 | RETURN_STATUS
|
---|
813 | EFIAPI
|
---|
814 | StrDecimalToUint64S (
|
---|
815 | IN CONST CHAR16 *String,
|
---|
816 | OUT CHAR16 **EndPointer OPTIONAL,
|
---|
817 | OUT UINT64 *Data
|
---|
818 | );
|
---|
819 |
|
---|
820 | /**
|
---|
821 | Convert a Null-terminated Unicode hexadecimal string to a value of type
|
---|
822 | UINTN.
|
---|
823 |
|
---|
824 | This function outputs a value of type UINTN by interpreting the contents of
|
---|
825 | the Unicode string specified by String as a hexadecimal number. The format of
|
---|
826 | the input Unicode string String is:
|
---|
827 |
|
---|
828 | [spaces][zeros][x][hexadecimal digits].
|
---|
829 |
|
---|
830 | The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
|
---|
831 | The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
|
---|
832 | If "x" appears in the input string, it must be prefixed with at least one 0.
|
---|
833 | The function will ignore the pad space, which includes spaces or tab
|
---|
834 | characters, before [zeros], [x] or [hexadecimal digit]. The running zero
|
---|
835 | before [x] or [hexadecimal digit] will be ignored. Then, the decoding starts
|
---|
836 | after [x] or the first valid hexadecimal digit. Then, the function stops at
|
---|
837 | the first character that is a not a valid hexadecimal character or NULL,
|
---|
838 | whichever one comes first.
|
---|
839 |
|
---|
840 | If String is not aligned in a 16-bit boundary, then ASSERT().
|
---|
841 |
|
---|
842 | If String has no valid hexadecimal digits in the above format, then 0 is
|
---|
843 | stored at the location pointed to by Data.
|
---|
844 | If the number represented by String exceeds the range defined by UINTN, then
|
---|
845 | MAX_UINTN is stored at the location pointed to by Data.
|
---|
846 |
|
---|
847 | If EndPointer is not NULL, a pointer to the character that stopped the scan
|
---|
848 | is stored at the location pointed to by EndPointer. If String has no valid
|
---|
849 | hexadecimal digits right after the optional pad spaces, the value of String
|
---|
850 | is stored at the location pointed to by EndPointer.
|
---|
851 |
|
---|
852 | @param String Pointer to a Null-terminated Unicode string.
|
---|
853 | @param EndPointer Pointer to character that stops scan.
|
---|
854 | @param Data Pointer to the converted value.
|
---|
855 |
|
---|
856 | @retval RETURN_SUCCESS Value is translated from String.
|
---|
857 | @retval RETURN_INVALID_PARAMETER If String is NULL.
|
---|
858 | If Data is NULL.
|
---|
859 | If PcdMaximumUnicodeStringLength is not
|
---|
860 | zero, and String contains more than
|
---|
861 | PcdMaximumUnicodeStringLength Unicode
|
---|
862 | characters, not including the
|
---|
863 | Null-terminator.
|
---|
864 | @retval RETURN_UNSUPPORTED If the number represented by String exceeds
|
---|
865 | the range defined by UINTN.
|
---|
866 |
|
---|
867 | **/
|
---|
868 | RETURN_STATUS
|
---|
869 | EFIAPI
|
---|
870 | StrHexToUintnS (
|
---|
871 | IN CONST CHAR16 *String,
|
---|
872 | OUT CHAR16 **EndPointer OPTIONAL,
|
---|
873 | OUT UINTN *Data
|
---|
874 | );
|
---|
875 |
|
---|
876 | /**
|
---|
877 | Convert a Null-terminated Unicode hexadecimal string to a value of type
|
---|
878 | UINT64.
|
---|
879 |
|
---|
880 | This function outputs a value of type UINT64 by interpreting the contents of
|
---|
881 | the Unicode string specified by String as a hexadecimal number. The format of
|
---|
882 | the input Unicode string String is:
|
---|
883 |
|
---|
884 | [spaces][zeros][x][hexadecimal digits].
|
---|
885 |
|
---|
886 | The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
|
---|
887 | The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
|
---|
888 | If "x" appears in the input string, it must be prefixed with at least one 0.
|
---|
889 | The function will ignore the pad space, which includes spaces or tab
|
---|
890 | characters, before [zeros], [x] or [hexadecimal digit]. The running zero
|
---|
891 | before [x] or [hexadecimal digit] will be ignored. Then, the decoding starts
|
---|
892 | after [x] or the first valid hexadecimal digit. Then, the function stops at
|
---|
893 | the first character that is a not a valid hexadecimal character or NULL,
|
---|
894 | whichever one comes first.
|
---|
895 |
|
---|
896 | If String is not aligned in a 16-bit boundary, then ASSERT().
|
---|
897 |
|
---|
898 | If String has no valid hexadecimal digits in the above format, then 0 is
|
---|
899 | stored at the location pointed to by Data.
|
---|
900 | If the number represented by String exceeds the range defined by UINT64, then
|
---|
901 | MAX_UINT64 is stored at the location pointed to by Data.
|
---|
902 |
|
---|
903 | If EndPointer is not NULL, a pointer to the character that stopped the scan
|
---|
904 | is stored at the location pointed to by EndPointer. If String has no valid
|
---|
905 | hexadecimal digits right after the optional pad spaces, the value of String
|
---|
906 | is stored at the location pointed to by EndPointer.
|
---|
907 |
|
---|
908 | @param String Pointer to a Null-terminated Unicode string.
|
---|
909 | @param EndPointer Pointer to character that stops scan.
|
---|
910 | @param Data Pointer to the converted value.
|
---|
911 |
|
---|
912 | @retval RETURN_SUCCESS Value is translated from String.
|
---|
913 | @retval RETURN_INVALID_PARAMETER If String is NULL.
|
---|
914 | If Data is NULL.
|
---|
915 | If PcdMaximumUnicodeStringLength is not
|
---|
916 | zero, and String contains more than
|
---|
917 | PcdMaximumUnicodeStringLength Unicode
|
---|
918 | characters, not including the
|
---|
919 | Null-terminator.
|
---|
920 | @retval RETURN_UNSUPPORTED If the number represented by String exceeds
|
---|
921 | the range defined by UINT64.
|
---|
922 |
|
---|
923 | **/
|
---|
924 | RETURN_STATUS
|
---|
925 | EFIAPI
|
---|
926 | StrHexToUint64S (
|
---|
927 | IN CONST CHAR16 *String,
|
---|
928 | OUT CHAR16 **EndPointer OPTIONAL,
|
---|
929 | OUT UINT64 *Data
|
---|
930 | );
|
---|
931 |
|
---|
932 | /**
|
---|
933 | Returns the length of a Null-terminated Ascii string.
|
---|
934 |
|
---|
935 | This function is similar as strlen_s defined in C11.
|
---|
936 |
|
---|
937 | @param String A pointer to a Null-terminated Ascii string.
|
---|
938 | @param MaxSize The maximum number of Destination Ascii
|
---|
939 | char, including terminating null char.
|
---|
940 |
|
---|
941 | @retval 0 If String is NULL.
|
---|
942 | @retval MaxSize If there is no null character in the first MaxSize characters of String.
|
---|
943 | @return The number of characters that percede the terminating null character.
|
---|
944 |
|
---|
945 | **/
|
---|
946 | UINTN
|
---|
947 | EFIAPI
|
---|
948 | AsciiStrnLenS (
|
---|
949 | IN CONST CHAR8 *String,
|
---|
950 | IN UINTN MaxSize
|
---|
951 | );
|
---|
952 |
|
---|
953 | /**
|
---|
954 | Returns the size of a Null-terminated Ascii string in bytes, including the
|
---|
955 | Null terminator.
|
---|
956 |
|
---|
957 | This function returns the size of the Null-terminated Ascii string specified
|
---|
958 | by String in bytes, including the Null terminator.
|
---|
959 |
|
---|
960 | @param String A pointer to a Null-terminated Ascii string.
|
---|
961 | @param MaxSize The maximum number of Destination Ascii
|
---|
962 | char, including the Null terminator.
|
---|
963 |
|
---|
964 | @retval 0 If String is NULL.
|
---|
965 | @retval (sizeof (CHAR8) * (MaxSize + 1))
|
---|
966 | If there is no Null terminator in the first MaxSize characters of
|
---|
967 | String.
|
---|
968 | @return The size of the Null-terminated Ascii string in bytes, including the
|
---|
969 | Null terminator.
|
---|
970 |
|
---|
971 | **/
|
---|
972 | UINTN
|
---|
973 | EFIAPI
|
---|
974 | AsciiStrnSizeS (
|
---|
975 | IN CONST CHAR8 *String,
|
---|
976 | IN UINTN MaxSize
|
---|
977 | );
|
---|
978 |
|
---|
979 | /**
|
---|
980 | Copies the string pointed to by Source (including the terminating null char)
|
---|
981 | to the array pointed to by Destination.
|
---|
982 |
|
---|
983 | This function is similar as strcpy_s defined in C11.
|
---|
984 |
|
---|
985 | If an error is returned, then the Destination is unmodified.
|
---|
986 |
|
---|
987 | @param Destination A pointer to a Null-terminated Ascii string.
|
---|
988 | @param DestMax The maximum number of Destination Ascii
|
---|
989 | char, including terminating null char.
|
---|
990 | @param Source A pointer to a Null-terminated Ascii string.
|
---|
991 |
|
---|
992 | @retval RETURN_SUCCESS String is copied.
|
---|
993 | @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).
|
---|
994 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.
|
---|
995 | If Source is NULL.
|
---|
996 | If PcdMaximumAsciiStringLength is not zero,
|
---|
997 | and DestMax is greater than
|
---|
998 | PcdMaximumAsciiStringLength.
|
---|
999 | If DestMax is 0.
|
---|
1000 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
|
---|
1001 | **/
|
---|
1002 | RETURN_STATUS
|
---|
1003 | EFIAPI
|
---|
1004 | AsciiStrCpyS (
|
---|
1005 | OUT CHAR8 *Destination,
|
---|
1006 | IN UINTN DestMax,
|
---|
1007 | IN CONST CHAR8 *Source
|
---|
1008 | );
|
---|
1009 |
|
---|
1010 | /**
|
---|
1011 | Copies not more than Length successive char from the string pointed to by
|
---|
1012 | Source to the array pointed to by Destination. If no null char is copied from
|
---|
1013 | Source, then Destination[Length] is always set to null.
|
---|
1014 |
|
---|
1015 | This function is similar as strncpy_s defined in C11.
|
---|
1016 |
|
---|
1017 | If an error is returned, then the Destination is unmodified.
|
---|
1018 |
|
---|
1019 | @param Destination A pointer to a Null-terminated Ascii string.
|
---|
1020 | @param DestMax The maximum number of Destination Ascii
|
---|
1021 | char, including terminating null char.
|
---|
1022 | @param Source A pointer to a Null-terminated Ascii string.
|
---|
1023 | @param Length The maximum number of Ascii characters to copy.
|
---|
1024 |
|
---|
1025 | @retval RETURN_SUCCESS String is copied.
|
---|
1026 | @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than
|
---|
1027 | MIN(StrLen(Source), Length).
|
---|
1028 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.
|
---|
1029 | If Source is NULL.
|
---|
1030 | If PcdMaximumAsciiStringLength is not zero,
|
---|
1031 | and DestMax is greater than
|
---|
1032 | PcdMaximumAsciiStringLength.
|
---|
1033 | If DestMax is 0.
|
---|
1034 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
|
---|
1035 | **/
|
---|
1036 | RETURN_STATUS
|
---|
1037 | EFIAPI
|
---|
1038 | AsciiStrnCpyS (
|
---|
1039 | OUT CHAR8 *Destination,
|
---|
1040 | IN UINTN DestMax,
|
---|
1041 | IN CONST CHAR8 *Source,
|
---|
1042 | IN UINTN Length
|
---|
1043 | );
|
---|
1044 |
|
---|
1045 | /**
|
---|
1046 | Appends a copy of the string pointed to by Source (including the terminating
|
---|
1047 | null char) to the end of the string pointed to by Destination.
|
---|
1048 |
|
---|
1049 | This function is similar as strcat_s defined in C11.
|
---|
1050 |
|
---|
1051 | If an error is returned, then the Destination is unmodified.
|
---|
1052 |
|
---|
1053 | @param Destination A pointer to a Null-terminated Ascii string.
|
---|
1054 | @param DestMax The maximum number of Destination Ascii
|
---|
1055 | char, including terminating null char.
|
---|
1056 | @param Source A pointer to a Null-terminated Ascii string.
|
---|
1057 |
|
---|
1058 | @retval RETURN_SUCCESS String is appended.
|
---|
1059 | @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than
|
---|
1060 | StrLen(Destination).
|
---|
1061 | @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT
|
---|
1062 | greater than StrLen(Source).
|
---|
1063 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.
|
---|
1064 | If Source is NULL.
|
---|
1065 | If PcdMaximumAsciiStringLength is not zero,
|
---|
1066 | and DestMax is greater than
|
---|
1067 | PcdMaximumAsciiStringLength.
|
---|
1068 | If DestMax is 0.
|
---|
1069 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
|
---|
1070 | **/
|
---|
1071 | RETURN_STATUS
|
---|
1072 | EFIAPI
|
---|
1073 | AsciiStrCatS (
|
---|
1074 | IN OUT CHAR8 *Destination,
|
---|
1075 | IN UINTN DestMax,
|
---|
1076 | IN CONST CHAR8 *Source
|
---|
1077 | );
|
---|
1078 |
|
---|
1079 | /**
|
---|
1080 | Appends not more than Length successive char from the string pointed to by
|
---|
1081 | Source to the end of the string pointed to by Destination. If no null char is
|
---|
1082 | copied from Source, then Destination[StrLen(Destination) + Length] is always
|
---|
1083 | set to null.
|
---|
1084 |
|
---|
1085 | This function is similar as strncat_s defined in C11.
|
---|
1086 |
|
---|
1087 | If an error is returned, then the Destination is unmodified.
|
---|
1088 |
|
---|
1089 | @param Destination A pointer to a Null-terminated Ascii string.
|
---|
1090 | @param DestMax The maximum number of Destination Ascii
|
---|
1091 | char, including terminating null char.
|
---|
1092 | @param Source A pointer to a Null-terminated Ascii string.
|
---|
1093 | @param Length The maximum number of Ascii characters to copy.
|
---|
1094 |
|
---|
1095 | @retval RETURN_SUCCESS String is appended.
|
---|
1096 | @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than
|
---|
1097 | StrLen(Destination).
|
---|
1098 | @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT
|
---|
1099 | greater than MIN(StrLen(Source), Length).
|
---|
1100 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.
|
---|
1101 | If Source is NULL.
|
---|
1102 | If PcdMaximumAsciiStringLength is not zero,
|
---|
1103 | and DestMax is greater than
|
---|
1104 | PcdMaximumAsciiStringLength.
|
---|
1105 | If DestMax is 0.
|
---|
1106 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
|
---|
1107 | **/
|
---|
1108 | RETURN_STATUS
|
---|
1109 | EFIAPI
|
---|
1110 | AsciiStrnCatS (
|
---|
1111 | IN OUT CHAR8 *Destination,
|
---|
1112 | IN UINTN DestMax,
|
---|
1113 | IN CONST CHAR8 *Source,
|
---|
1114 | IN UINTN Length
|
---|
1115 | );
|
---|
1116 |
|
---|
1117 | /**
|
---|
1118 | Convert a Null-terminated Ascii decimal string to a value of type UINTN.
|
---|
1119 |
|
---|
1120 | This function outputs a value of type UINTN by interpreting the contents of
|
---|
1121 | the Ascii string specified by String as a decimal number. The format of the
|
---|
1122 | input Ascii string String is:
|
---|
1123 |
|
---|
1124 | [spaces] [decimal digits].
|
---|
1125 |
|
---|
1126 | The valid decimal digit character is in the range [0-9]. The function will
|
---|
1127 | ignore the pad space, which includes spaces or tab characters, before
|
---|
1128 | [decimal digits]. The running zero in the beginning of [decimal digits] will
|
---|
1129 | be ignored. Then, the function stops at the first character that is a not a
|
---|
1130 | valid decimal character or a Null-terminator, whichever one comes first.
|
---|
1131 |
|
---|
1132 | If String has no valid decimal digits in the above format, then 0 is stored
|
---|
1133 | at the location pointed to by Data.
|
---|
1134 | If the number represented by String exceeds the range defined by UINTN, then
|
---|
1135 | MAX_UINTN is stored at the location pointed to by Data.
|
---|
1136 |
|
---|
1137 | If EndPointer is not NULL, a pointer to the character that stopped the scan
|
---|
1138 | is stored at the location pointed to by EndPointer. If String has no valid
|
---|
1139 | decimal digits right after the optional pad spaces, the value of String is
|
---|
1140 | stored at the location pointed to by EndPointer.
|
---|
1141 |
|
---|
1142 | @param String Pointer to a Null-terminated Ascii string.
|
---|
1143 | @param EndPointer Pointer to character that stops scan.
|
---|
1144 | @param Data Pointer to the converted value.
|
---|
1145 |
|
---|
1146 | @retval RETURN_SUCCESS Value is translated from String.
|
---|
1147 | @retval RETURN_INVALID_PARAMETER If String is NULL.
|
---|
1148 | If Data is NULL.
|
---|
1149 | If PcdMaximumAsciiStringLength is not zero,
|
---|
1150 | and String contains more than
|
---|
1151 | PcdMaximumAsciiStringLength Ascii
|
---|
1152 | characters, not including the
|
---|
1153 | Null-terminator.
|
---|
1154 | @retval RETURN_UNSUPPORTED If the number represented by String exceeds
|
---|
1155 | the range defined by UINTN.
|
---|
1156 |
|
---|
1157 | **/
|
---|
1158 | RETURN_STATUS
|
---|
1159 | EFIAPI
|
---|
1160 | AsciiStrDecimalToUintnS (
|
---|
1161 | IN CONST CHAR8 *String,
|
---|
1162 | OUT CHAR8 **EndPointer OPTIONAL,
|
---|
1163 | OUT UINTN *Data
|
---|
1164 | );
|
---|
1165 |
|
---|
1166 | /**
|
---|
1167 | Convert a Null-terminated Ascii decimal string to a value of type UINT64.
|
---|
1168 |
|
---|
1169 | This function outputs a value of type UINT64 by interpreting the contents of
|
---|
1170 | the Ascii string specified by String as a decimal number. The format of the
|
---|
1171 | input Ascii string String is:
|
---|
1172 |
|
---|
1173 | [spaces] [decimal digits].
|
---|
1174 |
|
---|
1175 | The valid decimal digit character is in the range [0-9]. The function will
|
---|
1176 | ignore the pad space, which includes spaces or tab characters, before
|
---|
1177 | [decimal digits]. The running zero in the beginning of [decimal digits] will
|
---|
1178 | be ignored. Then, the function stops at the first character that is a not a
|
---|
1179 | valid decimal character or a Null-terminator, whichever one comes first.
|
---|
1180 |
|
---|
1181 | If String has no valid decimal digits in the above format, then 0 is stored
|
---|
1182 | at the location pointed to by Data.
|
---|
1183 | If the number represented by String exceeds the range defined by UINT64, then
|
---|
1184 | MAX_UINT64 is stored at the location pointed to by Data.
|
---|
1185 |
|
---|
1186 | If EndPointer is not NULL, a pointer to the character that stopped the scan
|
---|
1187 | is stored at the location pointed to by EndPointer. If String has no valid
|
---|
1188 | decimal digits right after the optional pad spaces, the value of String is
|
---|
1189 | stored at the location pointed to by EndPointer.
|
---|
1190 |
|
---|
1191 | @param String Pointer to a Null-terminated Ascii string.
|
---|
1192 | @param EndPointer Pointer to character that stops scan.
|
---|
1193 | @param Data Pointer to the converted value.
|
---|
1194 |
|
---|
1195 | @retval RETURN_SUCCESS Value is translated from String.
|
---|
1196 | @retval RETURN_INVALID_PARAMETER If String is NULL.
|
---|
1197 | If Data is NULL.
|
---|
1198 | If PcdMaximumAsciiStringLength is not zero,
|
---|
1199 | and String contains more than
|
---|
1200 | PcdMaximumAsciiStringLength Ascii
|
---|
1201 | characters, not including the
|
---|
1202 | Null-terminator.
|
---|
1203 | @retval RETURN_UNSUPPORTED If the number represented by String exceeds
|
---|
1204 | the range defined by UINT64.
|
---|
1205 |
|
---|
1206 | **/
|
---|
1207 | RETURN_STATUS
|
---|
1208 | EFIAPI
|
---|
1209 | AsciiStrDecimalToUint64S (
|
---|
1210 | IN CONST CHAR8 *String,
|
---|
1211 | OUT CHAR8 **EndPointer OPTIONAL,
|
---|
1212 | OUT UINT64 *Data
|
---|
1213 | );
|
---|
1214 |
|
---|
1215 | /**
|
---|
1216 | Convert a Null-terminated Ascii hexadecimal string to a value of type UINTN.
|
---|
1217 |
|
---|
1218 | This function outputs a value of type UINTN by interpreting the contents of
|
---|
1219 | the Ascii string specified by String as a hexadecimal number. The format of
|
---|
1220 | the input Ascii string String is:
|
---|
1221 |
|
---|
1222 | [spaces][zeros][x][hexadecimal digits].
|
---|
1223 |
|
---|
1224 | The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
|
---|
1225 | The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If
|
---|
1226 | "x" appears in the input string, it must be prefixed with at least one 0. The
|
---|
1227 | function will ignore the pad space, which includes spaces or tab characters,
|
---|
1228 | before [zeros], [x] or [hexadecimal digits]. The running zero before [x] or
|
---|
1229 | [hexadecimal digits] will be ignored. Then, the decoding starts after [x] or
|
---|
1230 | the first valid hexadecimal digit. Then, the function stops at the first
|
---|
1231 | character that is a not a valid hexadecimal character or Null-terminator,
|
---|
1232 | whichever on comes first.
|
---|
1233 |
|
---|
1234 | If String has no valid hexadecimal digits in the above format, then 0 is
|
---|
1235 | stored at the location pointed to by Data.
|
---|
1236 | If the number represented by String exceeds the range defined by UINTN, then
|
---|
1237 | MAX_UINTN is stored at the location pointed to by Data.
|
---|
1238 |
|
---|
1239 | If EndPointer is not NULL, a pointer to the character that stopped the scan
|
---|
1240 | is stored at the location pointed to by EndPointer. If String has no valid
|
---|
1241 | hexadecimal digits right after the optional pad spaces, the value of String
|
---|
1242 | is stored at the location pointed to by EndPointer.
|
---|
1243 |
|
---|
1244 | @param String Pointer to a Null-terminated Ascii string.
|
---|
1245 | @param EndPointer Pointer to character that stops scan.
|
---|
1246 | @param Data Pointer to the converted value.
|
---|
1247 |
|
---|
1248 | @retval RETURN_SUCCESS Value is translated from String.
|
---|
1249 | @retval RETURN_INVALID_PARAMETER If String is NULL.
|
---|
1250 | If Data is NULL.
|
---|
1251 | If PcdMaximumAsciiStringLength is not zero,
|
---|
1252 | and String contains more than
|
---|
1253 | PcdMaximumAsciiStringLength Ascii
|
---|
1254 | characters, not including the
|
---|
1255 | Null-terminator.
|
---|
1256 | @retval RETURN_UNSUPPORTED If the number represented by String exceeds
|
---|
1257 | the range defined by UINTN.
|
---|
1258 |
|
---|
1259 | **/
|
---|
1260 | RETURN_STATUS
|
---|
1261 | EFIAPI
|
---|
1262 | AsciiStrHexToUintnS (
|
---|
1263 | IN CONST CHAR8 *String,
|
---|
1264 | OUT CHAR8 **EndPointer OPTIONAL,
|
---|
1265 | OUT UINTN *Data
|
---|
1266 | );
|
---|
1267 |
|
---|
1268 | /**
|
---|
1269 | Convert a Null-terminated Ascii hexadecimal string to a value of type UINT64.
|
---|
1270 |
|
---|
1271 | This function outputs a value of type UINT64 by interpreting the contents of
|
---|
1272 | the Ascii string specified by String as a hexadecimal number. The format of
|
---|
1273 | the input Ascii string String is:
|
---|
1274 |
|
---|
1275 | [spaces][zeros][x][hexadecimal digits].
|
---|
1276 |
|
---|
1277 | The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
|
---|
1278 | The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If
|
---|
1279 | "x" appears in the input string, it must be prefixed with at least one 0. The
|
---|
1280 | function will ignore the pad space, which includes spaces or tab characters,
|
---|
1281 | before [zeros], [x] or [hexadecimal digits]. The running zero before [x] or
|
---|
1282 | [hexadecimal digits] will be ignored. Then, the decoding starts after [x] or
|
---|
1283 | the first valid hexadecimal digit. Then, the function stops at the first
|
---|
1284 | character that is a not a valid hexadecimal character or Null-terminator,
|
---|
1285 | whichever on comes first.
|
---|
1286 |
|
---|
1287 | If String has no valid hexadecimal digits in the above format, then 0 is
|
---|
1288 | stored at the location pointed to by Data.
|
---|
1289 | If the number represented by String exceeds the range defined by UINT64, then
|
---|
1290 | MAX_UINT64 is stored at the location pointed to by Data.
|
---|
1291 |
|
---|
1292 | If EndPointer is not NULL, a pointer to the character that stopped the scan
|
---|
1293 | is stored at the location pointed to by EndPointer. If String has no valid
|
---|
1294 | hexadecimal digits right after the optional pad spaces, the value of String
|
---|
1295 | is stored at the location pointed to by EndPointer.
|
---|
1296 |
|
---|
1297 | @param String Pointer to a Null-terminated Ascii string.
|
---|
1298 | @param EndPointer Pointer to character that stops scan.
|
---|
1299 | @param Data Pointer to the converted value.
|
---|
1300 |
|
---|
1301 | @retval RETURN_SUCCESS Value is translated from String.
|
---|
1302 | @retval RETURN_INVALID_PARAMETER If String is NULL.
|
---|
1303 | If Data is NULL.
|
---|
1304 | If PcdMaximumAsciiStringLength is not zero,
|
---|
1305 | and String contains more than
|
---|
1306 | PcdMaximumAsciiStringLength Ascii
|
---|
1307 | characters, not including the
|
---|
1308 | Null-terminator.
|
---|
1309 | @retval RETURN_UNSUPPORTED If the number represented by String exceeds
|
---|
1310 | the range defined by UINT64.
|
---|
1311 |
|
---|
1312 | **/
|
---|
1313 | RETURN_STATUS
|
---|
1314 | EFIAPI
|
---|
1315 | AsciiStrHexToUint64S (
|
---|
1316 | IN CONST CHAR8 *String,
|
---|
1317 | OUT CHAR8 **EndPointer OPTIONAL,
|
---|
1318 | OUT UINT64 *Data
|
---|
1319 | );
|
---|
1320 |
|
---|
1321 | /**
|
---|
1322 | Returns the length of a Null-terminated Unicode string.
|
---|
1323 |
|
---|
1324 | This function returns the number of Unicode characters in the Null-terminated
|
---|
1325 | Unicode string specified by String.
|
---|
1326 |
|
---|
1327 | If String is NULL, then ASSERT().
|
---|
1328 | If String is not aligned on a 16-bit boundary, then ASSERT().
|
---|
1329 | If PcdMaximumUnicodeStringLength is not zero, and String contains more than
|
---|
1330 | PcdMaximumUnicodeStringLength Unicode characters not including the
|
---|
1331 | Null-terminator, then ASSERT().
|
---|
1332 |
|
---|
1333 | @param String Pointer to a Null-terminated Unicode string.
|
---|
1334 |
|
---|
1335 | @return The length of String.
|
---|
1336 |
|
---|
1337 | **/
|
---|
1338 | UINTN
|
---|
1339 | EFIAPI
|
---|
1340 | StrLen (
|
---|
1341 | IN CONST CHAR16 *String
|
---|
1342 | );
|
---|
1343 |
|
---|
1344 | /**
|
---|
1345 | Returns the size of a Null-terminated Unicode string in bytes, including the
|
---|
1346 | Null terminator.
|
---|
1347 |
|
---|
1348 | This function returns the size, in bytes, of the Null-terminated Unicode string
|
---|
1349 | specified by String.
|
---|
1350 |
|
---|
1351 | If String is NULL, then ASSERT().
|
---|
1352 | If String is not aligned on a 16-bit boundary, then ASSERT().
|
---|
1353 | If PcdMaximumUnicodeStringLength is not zero, and String contains more than
|
---|
1354 | PcdMaximumUnicodeStringLength Unicode characters not including the
|
---|
1355 | Null-terminator, then ASSERT().
|
---|
1356 |
|
---|
1357 | @param String The pointer to a Null-terminated Unicode string.
|
---|
1358 |
|
---|
1359 | @return The size of String.
|
---|
1360 |
|
---|
1361 | **/
|
---|
1362 | UINTN
|
---|
1363 | EFIAPI
|
---|
1364 | StrSize (
|
---|
1365 | IN CONST CHAR16 *String
|
---|
1366 | );
|
---|
1367 |
|
---|
1368 | /**
|
---|
1369 | Compares two Null-terminated Unicode strings, and returns the difference
|
---|
1370 | between the first mismatched Unicode characters.
|
---|
1371 |
|
---|
1372 | This function compares the Null-terminated Unicode string FirstString to the
|
---|
1373 | Null-terminated Unicode string SecondString. If FirstString is identical to
|
---|
1374 | SecondString, then 0 is returned. Otherwise, the value returned is the first
|
---|
1375 | mismatched Unicode character in SecondString subtracted from the first
|
---|
1376 | mismatched Unicode character in FirstString.
|
---|
1377 |
|
---|
1378 | If FirstString is NULL, then ASSERT().
|
---|
1379 | If FirstString is not aligned on a 16-bit boundary, then ASSERT().
|
---|
1380 | If SecondString is NULL, then ASSERT().
|
---|
1381 | If SecondString is not aligned on a 16-bit boundary, then ASSERT().
|
---|
1382 | If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more
|
---|
1383 | than PcdMaximumUnicodeStringLength Unicode characters not including the
|
---|
1384 | Null-terminator, then ASSERT().
|
---|
1385 | If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more
|
---|
1386 | than PcdMaximumUnicodeStringLength Unicode characters, not including the
|
---|
1387 | Null-terminator, then ASSERT().
|
---|
1388 |
|
---|
1389 | @param FirstString The pointer to a Null-terminated Unicode string.
|
---|
1390 | @param SecondString The pointer to a Null-terminated Unicode string.
|
---|
1391 |
|
---|
1392 | @retval 0 FirstString is identical to SecondString.
|
---|
1393 | @return others FirstString is not identical to SecondString.
|
---|
1394 |
|
---|
1395 | **/
|
---|
1396 | INTN
|
---|
1397 | EFIAPI
|
---|
1398 | StrCmp (
|
---|
1399 | IN CONST CHAR16 *FirstString,
|
---|
1400 | IN CONST CHAR16 *SecondString
|
---|
1401 | );
|
---|
1402 |
|
---|
1403 | /**
|
---|
1404 | Compares up to a specified length the contents of two Null-terminated Unicode strings,
|
---|
1405 | and returns the difference between the first mismatched Unicode characters.
|
---|
1406 |
|
---|
1407 | This function compares the Null-terminated Unicode string FirstString to the
|
---|
1408 | Null-terminated Unicode string SecondString. At most, Length Unicode
|
---|
1409 | characters will be compared. If Length is 0, then 0 is returned. If
|
---|
1410 | FirstString is identical to SecondString, then 0 is returned. Otherwise, the
|
---|
1411 | value returned is the first mismatched Unicode character in SecondString
|
---|
1412 | subtracted from the first mismatched Unicode character in FirstString.
|
---|
1413 |
|
---|
1414 | If Length > 0 and FirstString is NULL, then ASSERT().
|
---|
1415 | If Length > 0 and FirstString is not aligned on a 16-bit boundary, then ASSERT().
|
---|
1416 | If Length > 0 and SecondString is NULL, then ASSERT().
|
---|
1417 | If Length > 0 and SecondString is not aligned on a 16-bit boundary, then ASSERT().
|
---|
1418 | If PcdMaximumUnicodeStringLength is not zero, and Length is greater than
|
---|
1419 | PcdMaximumUnicodeStringLength, then ASSERT().
|
---|
1420 | If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more than
|
---|
1421 | PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,
|
---|
1422 | then ASSERT().
|
---|
1423 | If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more than
|
---|
1424 | PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,
|
---|
1425 | then ASSERT().
|
---|
1426 |
|
---|
1427 | @param FirstString The pointer to a Null-terminated Unicode string.
|
---|
1428 | @param SecondString The pointer to a Null-terminated Unicode string.
|
---|
1429 | @param Length The maximum number of Unicode characters to compare.
|
---|
1430 |
|
---|
1431 | @retval 0 FirstString is identical to SecondString.
|
---|
1432 | @return others FirstString is not identical to SecondString.
|
---|
1433 |
|
---|
1434 | **/
|
---|
1435 | INTN
|
---|
1436 | EFIAPI
|
---|
1437 | StrnCmp (
|
---|
1438 | IN CONST CHAR16 *FirstString,
|
---|
1439 | IN CONST CHAR16 *SecondString,
|
---|
1440 | IN UINTN Length
|
---|
1441 | );
|
---|
1442 |
|
---|
1443 | /**
|
---|
1444 | Returns the first occurrence of a Null-terminated Unicode sub-string
|
---|
1445 | in a Null-terminated Unicode string.
|
---|
1446 |
|
---|
1447 | This function scans the contents of the Null-terminated Unicode string
|
---|
1448 | specified by String and returns the first occurrence of SearchString.
|
---|
1449 | If SearchString is not found in String, then NULL is returned. If
|
---|
1450 | the length of SearchString is zero, then String is returned.
|
---|
1451 |
|
---|
1452 | If String is NULL, then ASSERT().
|
---|
1453 | If String is not aligned on a 16-bit boundary, then ASSERT().
|
---|
1454 | If SearchString is NULL, then ASSERT().
|
---|
1455 | If SearchString is not aligned on a 16-bit boundary, then ASSERT().
|
---|
1456 |
|
---|
1457 | If PcdMaximumUnicodeStringLength is not zero, and SearchString
|
---|
1458 | or String contains more than PcdMaximumUnicodeStringLength Unicode
|
---|
1459 | characters, not including the Null-terminator, then ASSERT().
|
---|
1460 |
|
---|
1461 | @param String The pointer to a Null-terminated Unicode string.
|
---|
1462 | @param SearchString The pointer to a Null-terminated Unicode string to search for.
|
---|
1463 |
|
---|
1464 | @retval NULL If the SearchString does not appear in String.
|
---|
1465 | @return others If there is a match.
|
---|
1466 |
|
---|
1467 | **/
|
---|
1468 | CHAR16 *
|
---|
1469 | EFIAPI
|
---|
1470 | StrStr (
|
---|
1471 | IN CONST CHAR16 *String,
|
---|
1472 | IN CONST CHAR16 *SearchString
|
---|
1473 | );
|
---|
1474 |
|
---|
1475 | /**
|
---|
1476 | Convert a Null-terminated Unicode decimal string to a value of
|
---|
1477 | type UINTN.
|
---|
1478 |
|
---|
1479 | This function returns a value of type UINTN by interpreting the contents
|
---|
1480 | of the Unicode string specified by String as a decimal number. The format
|
---|
1481 | of the input Unicode string String is:
|
---|
1482 |
|
---|
1483 | [spaces] [decimal digits].
|
---|
1484 |
|
---|
1485 | The valid decimal digit character is in the range [0-9]. The
|
---|
1486 | function will ignore the pad space, which includes spaces or
|
---|
1487 | tab characters, before [decimal digits]. The running zero in the
|
---|
1488 | beginning of [decimal digits] will be ignored. Then, the function
|
---|
1489 | stops at the first character that is a not a valid decimal character
|
---|
1490 | or a Null-terminator, whichever one comes first.
|
---|
1491 |
|
---|
1492 | If String is NULL, then ASSERT().
|
---|
1493 | If String is not aligned in a 16-bit boundary, then ASSERT().
|
---|
1494 | If String has only pad spaces, then 0 is returned.
|
---|
1495 | If String has no pad spaces or valid decimal digits,
|
---|
1496 | then 0 is returned.
|
---|
1497 | If the number represented by String overflows according
|
---|
1498 | to the range defined by UINTN, then MAX_UINTN is returned.
|
---|
1499 |
|
---|
1500 | If PcdMaximumUnicodeStringLength is not zero, and String contains
|
---|
1501 | more than PcdMaximumUnicodeStringLength Unicode characters not including
|
---|
1502 | the Null-terminator, then ASSERT().
|
---|
1503 |
|
---|
1504 | @param String The pointer to a Null-terminated Unicode string.
|
---|
1505 |
|
---|
1506 | @retval Value translated from String.
|
---|
1507 |
|
---|
1508 | **/
|
---|
1509 | UINTN
|
---|
1510 | EFIAPI
|
---|
1511 | StrDecimalToUintn (
|
---|
1512 | IN CONST CHAR16 *String
|
---|
1513 | );
|
---|
1514 |
|
---|
1515 | /**
|
---|
1516 | Convert a Null-terminated Unicode decimal string to a value of
|
---|
1517 | type UINT64.
|
---|
1518 |
|
---|
1519 | This function returns a value of type UINT64 by interpreting the contents
|
---|
1520 | of the Unicode string specified by String as a decimal number. The format
|
---|
1521 | of the input Unicode string String is:
|
---|
1522 |
|
---|
1523 | [spaces] [decimal digits].
|
---|
1524 |
|
---|
1525 | The valid decimal digit character is in the range [0-9]. The
|
---|
1526 | function will ignore the pad space, which includes spaces or
|
---|
1527 | tab characters, before [decimal digits]. The running zero in the
|
---|
1528 | beginning of [decimal digits] will be ignored. Then, the function
|
---|
1529 | stops at the first character that is a not a valid decimal character
|
---|
1530 | or a Null-terminator, whichever one comes first.
|
---|
1531 |
|
---|
1532 | If String is NULL, then ASSERT().
|
---|
1533 | If String is not aligned in a 16-bit boundary, then ASSERT().
|
---|
1534 | If String has only pad spaces, then 0 is returned.
|
---|
1535 | If String has no pad spaces or valid decimal digits,
|
---|
1536 | then 0 is returned.
|
---|
1537 | If the number represented by String overflows according
|
---|
1538 | to the range defined by UINT64, then MAX_UINT64 is returned.
|
---|
1539 |
|
---|
1540 | If PcdMaximumUnicodeStringLength is not zero, and String contains
|
---|
1541 | more than PcdMaximumUnicodeStringLength Unicode characters not including
|
---|
1542 | the Null-terminator, then ASSERT().
|
---|
1543 |
|
---|
1544 | @param String The pointer to a Null-terminated Unicode string.
|
---|
1545 |
|
---|
1546 | @retval Value translated from String.
|
---|
1547 |
|
---|
1548 | **/
|
---|
1549 | UINT64
|
---|
1550 | EFIAPI
|
---|
1551 | StrDecimalToUint64 (
|
---|
1552 | IN CONST CHAR16 *String
|
---|
1553 | );
|
---|
1554 |
|
---|
1555 | /**
|
---|
1556 | Convert a Null-terminated Unicode hexadecimal string to a value of type UINTN.
|
---|
1557 |
|
---|
1558 | This function returns a value of type UINTN by interpreting the contents
|
---|
1559 | of the Unicode string specified by String as a hexadecimal number.
|
---|
1560 | The format of the input Unicode string String is:
|
---|
1561 |
|
---|
1562 | [spaces][zeros][x][hexadecimal digits].
|
---|
1563 |
|
---|
1564 | The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
|
---|
1565 | The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
|
---|
1566 | If "x" appears in the input string, it must be prefixed with at least one 0.
|
---|
1567 | The function will ignore the pad space, which includes spaces or tab characters,
|
---|
1568 | before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
|
---|
1569 | [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
|
---|
1570 | first valid hexadecimal digit. Then, the function stops at the first character
|
---|
1571 | that is a not a valid hexadecimal character or NULL, whichever one comes first.
|
---|
1572 |
|
---|
1573 | If String is NULL, then ASSERT().
|
---|
1574 | If String is not aligned in a 16-bit boundary, then ASSERT().
|
---|
1575 | If String has only pad spaces, then zero is returned.
|
---|
1576 | If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
|
---|
1577 | then zero is returned.
|
---|
1578 | If the number represented by String overflows according to the range defined by
|
---|
1579 | UINTN, then MAX_UINTN is returned.
|
---|
1580 |
|
---|
1581 | If PcdMaximumUnicodeStringLength is not zero, and String contains more than
|
---|
1582 | PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
|
---|
1583 | then ASSERT().
|
---|
1584 |
|
---|
1585 | @param String The pointer to a Null-terminated Unicode string.
|
---|
1586 |
|
---|
1587 | @retval Value translated from String.
|
---|
1588 |
|
---|
1589 | **/
|
---|
1590 | UINTN
|
---|
1591 | EFIAPI
|
---|
1592 | StrHexToUintn (
|
---|
1593 | IN CONST CHAR16 *String
|
---|
1594 | );
|
---|
1595 |
|
---|
1596 | /**
|
---|
1597 | Convert a Null-terminated Unicode hexadecimal string to a value of type UINT64.
|
---|
1598 |
|
---|
1599 | This function returns a value of type UINT64 by interpreting the contents
|
---|
1600 | of the Unicode string specified by String as a hexadecimal number.
|
---|
1601 | The format of the input Unicode string String is
|
---|
1602 |
|
---|
1603 | [spaces][zeros][x][hexadecimal digits].
|
---|
1604 |
|
---|
1605 | The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
|
---|
1606 | The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.
|
---|
1607 | If "x" appears in the input string, it must be prefixed with at least one 0.
|
---|
1608 | The function will ignore the pad space, which includes spaces or tab characters,
|
---|
1609 | before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or
|
---|
1610 | [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the
|
---|
1611 | first valid hexadecimal digit. Then, the function stops at the first character that is
|
---|
1612 | a not a valid hexadecimal character or NULL, whichever one comes first.
|
---|
1613 |
|
---|
1614 | If String is NULL, then ASSERT().
|
---|
1615 | If String is not aligned in a 16-bit boundary, then ASSERT().
|
---|
1616 | If String has only pad spaces, then zero is returned.
|
---|
1617 | If String has no leading pad spaces, leading zeros or valid hexadecimal digits,
|
---|
1618 | then zero is returned.
|
---|
1619 | If the number represented by String overflows according to the range defined by
|
---|
1620 | UINT64, then MAX_UINT64 is returned.
|
---|
1621 |
|
---|
1622 | If PcdMaximumUnicodeStringLength is not zero, and String contains more than
|
---|
1623 | PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,
|
---|
1624 | then ASSERT().
|
---|
1625 |
|
---|
1626 | @param String The pointer to a Null-terminated Unicode string.
|
---|
1627 |
|
---|
1628 | @retval Value translated from String.
|
---|
1629 |
|
---|
1630 | **/
|
---|
1631 | UINT64
|
---|
1632 | EFIAPI
|
---|
1633 | StrHexToUint64 (
|
---|
1634 | IN CONST CHAR16 *String
|
---|
1635 | );
|
---|
1636 |
|
---|
1637 | /**
|
---|
1638 | Convert a Null-terminated Unicode string to IPv6 address and prefix length.
|
---|
1639 |
|
---|
1640 | This function outputs a value of type IPv6_ADDRESS and may output a value
|
---|
1641 | of type UINT8 by interpreting the contents of the Unicode string specified
|
---|
1642 | by String. The format of the input Unicode string String is as follows:
|
---|
1643 |
|
---|
1644 | X:X:X:X:X:X:X:X[/P]
|
---|
1645 |
|
---|
1646 | X contains one to four hexadecimal digit characters in the range [0-9], [a-f] and
|
---|
1647 | [A-F]. X is converted to a value of type UINT16, whose low byte is stored in low
|
---|
1648 | memory address and high byte is stored in high memory address. P contains decimal
|
---|
1649 | digit characters in the range [0-9]. The running zero in the beginning of P will
|
---|
1650 | be ignored. /P is optional.
|
---|
1651 |
|
---|
1652 | When /P is not in the String, the function stops at the first character that is
|
---|
1653 | not a valid hexadecimal digit character after eight X's are converted.
|
---|
1654 |
|
---|
1655 | When /P is in the String, the function stops at the first character that is not
|
---|
1656 | a valid decimal digit character after P is converted.
|
---|
1657 |
|
---|
1658 | "::" can be used to compress one or more groups of X when X contains only 0.
|
---|
1659 | The "::" can only appear once in the String.
|
---|
1660 |
|
---|
1661 | If String is not aligned in a 16-bit boundary, then ASSERT().
|
---|
1662 |
|
---|
1663 | If EndPointer is not NULL and Address is translated from String, a pointer
|
---|
1664 | to the character that stopped the scan is stored at the location pointed to
|
---|
1665 | by EndPointer.
|
---|
1666 |
|
---|
1667 | @param String Pointer to a Null-terminated Unicode string.
|
---|
1668 | @param EndPointer Pointer to character that stops scan.
|
---|
1669 | @param Address Pointer to the converted IPv6 address.
|
---|
1670 | @param PrefixLength Pointer to the converted IPv6 address prefix
|
---|
1671 | length. MAX_UINT8 is returned when /P is
|
---|
1672 | not in the String.
|
---|
1673 |
|
---|
1674 | @retval RETURN_SUCCESS Address is translated from String.
|
---|
1675 | @retval RETURN_INVALID_PARAMETER If String is NULL.
|
---|
1676 | If Data is NULL.
|
---|
1677 | @retval RETURN_UNSUPPORTED If X contains more than four hexadecimal
|
---|
1678 | digit characters.
|
---|
1679 | If String contains "::" and number of X
|
---|
1680 | is not less than 8.
|
---|
1681 | If P starts with character that is not a
|
---|
1682 | valid decimal digit character.
|
---|
1683 | If the decimal number converted from P
|
---|
1684 | exceeds 128.
|
---|
1685 |
|
---|
1686 | **/
|
---|
1687 | RETURN_STATUS
|
---|
1688 | EFIAPI
|
---|
1689 | StrToIpv6Address (
|
---|
1690 | IN CONST CHAR16 *String,
|
---|
1691 | OUT CHAR16 **EndPointer OPTIONAL,
|
---|
1692 | OUT IPv6_ADDRESS *Address,
|
---|
1693 | OUT UINT8 *PrefixLength OPTIONAL
|
---|
1694 | );
|
---|
1695 |
|
---|
1696 | /**
|
---|
1697 | Convert a Null-terminated Unicode string to IPv4 address and prefix length.
|
---|
1698 |
|
---|
1699 | This function outputs a value of type IPv4_ADDRESS and may output a value
|
---|
1700 | of type UINT8 by interpreting the contents of the Unicode string specified
|
---|
1701 | by String. The format of the input Unicode string String is as follows:
|
---|
1702 |
|
---|
1703 | D.D.D.D[/P]
|
---|
1704 |
|
---|
1705 | D and P are decimal digit characters in the range [0-9]. The running zero in
|
---|
1706 | the beginning of D and P will be ignored. /P is optional.
|
---|
1707 |
|
---|
1708 | When /P is not in the String, the function stops at the first character that is
|
---|
1709 | not a valid decimal digit character after four D's are converted.
|
---|
1710 |
|
---|
1711 | When /P is in the String, the function stops at the first character that is not
|
---|
1712 | a valid decimal digit character after P is converted.
|
---|
1713 |
|
---|
1714 | If String is not aligned in a 16-bit boundary, then ASSERT().
|
---|
1715 |
|
---|
1716 | If EndPointer is not NULL and Address is translated from String, a pointer
|
---|
1717 | to the character that stopped the scan is stored at the location pointed to
|
---|
1718 | by EndPointer.
|
---|
1719 |
|
---|
1720 | @param String Pointer to a Null-terminated Unicode string.
|
---|
1721 | @param EndPointer Pointer to character that stops scan.
|
---|
1722 | @param Address Pointer to the converted IPv4 address.
|
---|
1723 | @param PrefixLength Pointer to the converted IPv4 address prefix
|
---|
1724 | length. MAX_UINT8 is returned when /P is
|
---|
1725 | not in the String.
|
---|
1726 |
|
---|
1727 | @retval RETURN_SUCCESS Address is translated from String.
|
---|
1728 | @retval RETURN_INVALID_PARAMETER If String is NULL.
|
---|
1729 | If Data is NULL.
|
---|
1730 | @retval RETURN_UNSUPPORTED If String is not in the correct format.
|
---|
1731 | If any decimal number converted from D
|
---|
1732 | exceeds 255.
|
---|
1733 | If the decimal number converted from P
|
---|
1734 | exceeds 32.
|
---|
1735 |
|
---|
1736 | **/
|
---|
1737 | RETURN_STATUS
|
---|
1738 | EFIAPI
|
---|
1739 | StrToIpv4Address (
|
---|
1740 | IN CONST CHAR16 *String,
|
---|
1741 | OUT CHAR16 **EndPointer OPTIONAL,
|
---|
1742 | OUT IPv4_ADDRESS *Address,
|
---|
1743 | OUT UINT8 *PrefixLength OPTIONAL
|
---|
1744 | );
|
---|
1745 |
|
---|
1746 | #define GUID_STRING_LENGTH 36
|
---|
1747 |
|
---|
1748 | /**
|
---|
1749 | Convert a Null-terminated Unicode GUID string to a value of type
|
---|
1750 | EFI_GUID.
|
---|
1751 |
|
---|
1752 | This function outputs a GUID value by interpreting the contents of
|
---|
1753 | the Unicode string specified by String. The format of the input
|
---|
1754 | Unicode string String consists of 36 characters, as follows:
|
---|
1755 |
|
---|
1756 | aabbccdd-eeff-gghh-iijj-kkllmmnnoopp
|
---|
1757 |
|
---|
1758 | The pairs aa - pp are two characters in the range [0-9], [a-f] and
|
---|
1759 | [A-F], with each pair representing a single byte hexadecimal value.
|
---|
1760 |
|
---|
1761 | The mapping between String and the EFI_GUID structure is as follows:
|
---|
1762 | aa Data1[24:31]
|
---|
1763 | bb Data1[16:23]
|
---|
1764 | cc Data1[8:15]
|
---|
1765 | dd Data1[0:7]
|
---|
1766 | ee Data2[8:15]
|
---|
1767 | ff Data2[0:7]
|
---|
1768 | gg Data3[8:15]
|
---|
1769 | hh Data3[0:7]
|
---|
1770 | ii Data4[0:7]
|
---|
1771 | jj Data4[8:15]
|
---|
1772 | kk Data4[16:23]
|
---|
1773 | ll Data4[24:31]
|
---|
1774 | mm Data4[32:39]
|
---|
1775 | nn Data4[40:47]
|
---|
1776 | oo Data4[48:55]
|
---|
1777 | pp Data4[56:63]
|
---|
1778 |
|
---|
1779 | If String is not aligned in a 16-bit boundary, then ASSERT().
|
---|
1780 |
|
---|
1781 | @param String Pointer to a Null-terminated Unicode string.
|
---|
1782 | @param Guid Pointer to the converted GUID.
|
---|
1783 |
|
---|
1784 | @retval RETURN_SUCCESS Guid is translated from String.
|
---|
1785 | @retval RETURN_INVALID_PARAMETER If String is NULL.
|
---|
1786 | If Data is NULL.
|
---|
1787 | @retval RETURN_UNSUPPORTED If String is not as the above format.
|
---|
1788 |
|
---|
1789 | **/
|
---|
1790 | RETURN_STATUS
|
---|
1791 | EFIAPI
|
---|
1792 | StrToGuid (
|
---|
1793 | IN CONST CHAR16 *String,
|
---|
1794 | OUT GUID *Guid
|
---|
1795 | );
|
---|
1796 |
|
---|
1797 | /**
|
---|
1798 | Convert a Null-terminated Unicode hexadecimal string to a byte array.
|
---|
1799 |
|
---|
1800 | This function outputs a byte array by interpreting the contents of
|
---|
1801 | the Unicode string specified by String in hexadecimal format. The format of
|
---|
1802 | the input Unicode string String is:
|
---|
1803 |
|
---|
1804 | [XX]*
|
---|
1805 |
|
---|
1806 | X is a hexadecimal digit character in the range [0-9], [a-f] and [A-F].
|
---|
1807 | The function decodes every two hexadecimal digit characters as one byte. The
|
---|
1808 | decoding stops after Length of characters and outputs Buffer containing
|
---|
1809 | (Length / 2) bytes.
|
---|
1810 |
|
---|
1811 | If String is not aligned in a 16-bit boundary, then ASSERT().
|
---|
1812 |
|
---|
1813 | @param String Pointer to a Null-terminated Unicode string.
|
---|
1814 | @param Length The number of Unicode characters to decode.
|
---|
1815 | @param Buffer Pointer to the converted bytes array.
|
---|
1816 | @param MaxBufferSize The maximum size of Buffer.
|
---|
1817 |
|
---|
1818 | @retval RETURN_SUCCESS Buffer is translated from String.
|
---|
1819 | @retval RETURN_INVALID_PARAMETER If String is NULL.
|
---|
1820 | If Data is NULL.
|
---|
1821 | If Length is not multiple of 2.
|
---|
1822 | If PcdMaximumUnicodeStringLength is not zero,
|
---|
1823 | and Length is greater than
|
---|
1824 | PcdMaximumUnicodeStringLength.
|
---|
1825 | @retval RETURN_UNSUPPORTED If Length of characters from String contain
|
---|
1826 | a character that is not valid hexadecimal
|
---|
1827 | digit characters, or a Null-terminator.
|
---|
1828 | @retval RETURN_BUFFER_TOO_SMALL If MaxBufferSize is less than (Length / 2).
|
---|
1829 | **/
|
---|
1830 | RETURN_STATUS
|
---|
1831 | EFIAPI
|
---|
1832 | StrHexToBytes (
|
---|
1833 | IN CONST CHAR16 *String,
|
---|
1834 | IN UINTN Length,
|
---|
1835 | OUT UINT8 *Buffer,
|
---|
1836 | IN UINTN MaxBufferSize
|
---|
1837 | );
|
---|
1838 |
|
---|
1839 | /**
|
---|
1840 | Convert a Null-terminated Unicode string to a Null-terminated
|
---|
1841 | ASCII string.
|
---|
1842 |
|
---|
1843 | This function is similar to AsciiStrCpyS.
|
---|
1844 |
|
---|
1845 | This function converts the content of the Unicode string Source
|
---|
1846 | to the ASCII string Destination by copying the lower 8 bits of
|
---|
1847 | each Unicode character. The function terminates the ASCII string
|
---|
1848 | Destination by appending a Null-terminator character at the end.
|
---|
1849 |
|
---|
1850 | The caller is responsible to make sure Destination points to a buffer with size
|
---|
1851 | equal or greater than ((StrLen (Source) + 1) * sizeof (CHAR8)) in bytes.
|
---|
1852 |
|
---|
1853 | If any Unicode characters in Source contain non-zero value in
|
---|
1854 | the upper 8 bits, then ASSERT().
|
---|
1855 |
|
---|
1856 | If Source is not aligned on a 16-bit boundary, then ASSERT().
|
---|
1857 |
|
---|
1858 | If an error is returned, then the Destination is unmodified.
|
---|
1859 |
|
---|
1860 | @param Source The pointer to a Null-terminated Unicode string.
|
---|
1861 | @param Destination The pointer to a Null-terminated ASCII string.
|
---|
1862 | @param DestMax The maximum number of Destination Ascii
|
---|
1863 | char, including terminating null char.
|
---|
1864 |
|
---|
1865 | @retval RETURN_SUCCESS String is converted.
|
---|
1866 | @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).
|
---|
1867 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.
|
---|
1868 | If Source is NULL.
|
---|
1869 | If PcdMaximumAsciiStringLength is not zero,
|
---|
1870 | and DestMax is greater than
|
---|
1871 | PcdMaximumAsciiStringLength.
|
---|
1872 | If PcdMaximumUnicodeStringLength is not zero,
|
---|
1873 | and DestMax is greater than
|
---|
1874 | PcdMaximumUnicodeStringLength.
|
---|
1875 | If DestMax is 0.
|
---|
1876 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
|
---|
1877 |
|
---|
1878 | **/
|
---|
1879 | RETURN_STATUS
|
---|
1880 | EFIAPI
|
---|
1881 | UnicodeStrToAsciiStrS (
|
---|
1882 | IN CONST CHAR16 *Source,
|
---|
1883 | OUT CHAR8 *Destination,
|
---|
1884 | IN UINTN DestMax
|
---|
1885 | );
|
---|
1886 |
|
---|
1887 | /**
|
---|
1888 | Convert not more than Length successive characters from a Null-terminated
|
---|
1889 | Unicode string to a Null-terminated Ascii string. If no null char is copied
|
---|
1890 | from Source, then Destination[Length] is always set to null.
|
---|
1891 |
|
---|
1892 | This function converts not more than Length successive characters from the
|
---|
1893 | Unicode string Source to the Ascii string Destination by copying the lower 8
|
---|
1894 | bits of each Unicode character. The function terminates the Ascii string
|
---|
1895 | Destination by appending a Null-terminator character at the end.
|
---|
1896 |
|
---|
1897 | The caller is responsible to make sure Destination points to a buffer with size
|
---|
1898 | equal or greater than ((StrLen (Source) + 1) * sizeof (CHAR8)) in bytes.
|
---|
1899 |
|
---|
1900 | If any Unicode characters in Source contain non-zero value in the upper 8
|
---|
1901 | bits, then ASSERT().
|
---|
1902 | If Source is not aligned on a 16-bit boundary, then ASSERT().
|
---|
1903 |
|
---|
1904 | If an error is returned, then the Destination is unmodified.
|
---|
1905 |
|
---|
1906 | @param Source The pointer to a Null-terminated Unicode string.
|
---|
1907 | @param Length The maximum number of Unicode characters to
|
---|
1908 | convert.
|
---|
1909 | @param Destination The pointer to a Null-terminated Ascii string.
|
---|
1910 | @param DestMax The maximum number of Destination Ascii
|
---|
1911 | char, including terminating null char.
|
---|
1912 | @param DestinationLength The number of Unicode characters converted.
|
---|
1913 |
|
---|
1914 | @retval RETURN_SUCCESS String is converted.
|
---|
1915 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.
|
---|
1916 | If Source is NULL.
|
---|
1917 | If DestinationLength is NULL.
|
---|
1918 | If PcdMaximumAsciiStringLength is not zero,
|
---|
1919 | and Length or DestMax is greater than
|
---|
1920 | PcdMaximumAsciiStringLength.
|
---|
1921 | If PcdMaximumUnicodeStringLength is not
|
---|
1922 | zero, and Length or DestMax is greater than
|
---|
1923 | PcdMaximumUnicodeStringLength.
|
---|
1924 | If DestMax is 0.
|
---|
1925 | @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than
|
---|
1926 | MIN(StrLen(Source), Length).
|
---|
1927 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
|
---|
1928 |
|
---|
1929 | **/
|
---|
1930 | RETURN_STATUS
|
---|
1931 | EFIAPI
|
---|
1932 | UnicodeStrnToAsciiStrS (
|
---|
1933 | IN CONST CHAR16 *Source,
|
---|
1934 | IN UINTN Length,
|
---|
1935 | OUT CHAR8 *Destination,
|
---|
1936 | IN UINTN DestMax,
|
---|
1937 | OUT UINTN *DestinationLength
|
---|
1938 | );
|
---|
1939 |
|
---|
1940 | /**
|
---|
1941 | Returns the length of a Null-terminated ASCII string.
|
---|
1942 |
|
---|
1943 | This function returns the number of ASCII characters in the Null-terminated
|
---|
1944 | ASCII string specified by String.
|
---|
1945 |
|
---|
1946 | If Length > 0 and Destination is NULL, then ASSERT().
|
---|
1947 | If Length > 0 and Source is NULL, then ASSERT().
|
---|
1948 | If PcdMaximumAsciiStringLength is not zero and String contains more than
|
---|
1949 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
|
---|
1950 | then ASSERT().
|
---|
1951 |
|
---|
1952 | @param String The pointer to a Null-terminated ASCII string.
|
---|
1953 |
|
---|
1954 | @return The length of String.
|
---|
1955 |
|
---|
1956 | **/
|
---|
1957 | UINTN
|
---|
1958 | EFIAPI
|
---|
1959 | AsciiStrLen (
|
---|
1960 | IN CONST CHAR8 *String
|
---|
1961 | );
|
---|
1962 |
|
---|
1963 | /**
|
---|
1964 | Returns the size of a Null-terminated ASCII string in bytes, including the
|
---|
1965 | Null terminator.
|
---|
1966 |
|
---|
1967 | This function returns the size, in bytes, of the Null-terminated ASCII string
|
---|
1968 | specified by String.
|
---|
1969 |
|
---|
1970 | If String is NULL, then ASSERT().
|
---|
1971 | If PcdMaximumAsciiStringLength is not zero and String contains more than
|
---|
1972 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
|
---|
1973 | then ASSERT().
|
---|
1974 |
|
---|
1975 | @param String The pointer to a Null-terminated ASCII string.
|
---|
1976 |
|
---|
1977 | @return The size of String.
|
---|
1978 |
|
---|
1979 | **/
|
---|
1980 | UINTN
|
---|
1981 | EFIAPI
|
---|
1982 | AsciiStrSize (
|
---|
1983 | IN CONST CHAR8 *String
|
---|
1984 | );
|
---|
1985 |
|
---|
1986 | /**
|
---|
1987 | Compares two Null-terminated ASCII strings, and returns the difference
|
---|
1988 | between the first mismatched ASCII characters.
|
---|
1989 |
|
---|
1990 | This function compares the Null-terminated ASCII string FirstString to the
|
---|
1991 | Null-terminated ASCII string SecondString. If FirstString is identical to
|
---|
1992 | SecondString, then 0 is returned. Otherwise, the value returned is the first
|
---|
1993 | mismatched ASCII character in SecondString subtracted from the first
|
---|
1994 | mismatched ASCII character in FirstString.
|
---|
1995 |
|
---|
1996 | If FirstString is NULL, then ASSERT().
|
---|
1997 | If SecondString is NULL, then ASSERT().
|
---|
1998 | If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
|
---|
1999 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
|
---|
2000 | then ASSERT().
|
---|
2001 | If PcdMaximumAsciiStringLength is not zero and SecondString contains more
|
---|
2002 | than PcdMaximumAsciiStringLength ASCII characters not including the
|
---|
2003 | Null-terminator, then ASSERT().
|
---|
2004 |
|
---|
2005 | @param FirstString The pointer to a Null-terminated ASCII string.
|
---|
2006 | @param SecondString The pointer to a Null-terminated ASCII string.
|
---|
2007 |
|
---|
2008 | @retval ==0 FirstString is identical to SecondString.
|
---|
2009 | @retval !=0 FirstString is not identical to SecondString.
|
---|
2010 |
|
---|
2011 | **/
|
---|
2012 | INTN
|
---|
2013 | EFIAPI
|
---|
2014 | AsciiStrCmp (
|
---|
2015 | IN CONST CHAR8 *FirstString,
|
---|
2016 | IN CONST CHAR8 *SecondString
|
---|
2017 | );
|
---|
2018 |
|
---|
2019 | /**
|
---|
2020 | Performs a case insensitive comparison of two Null-terminated ASCII strings,
|
---|
2021 | and returns the difference between the first mismatched ASCII characters.
|
---|
2022 |
|
---|
2023 | This function performs a case insensitive comparison of the Null-terminated
|
---|
2024 | ASCII string FirstString to the Null-terminated ASCII string SecondString. If
|
---|
2025 | FirstString is identical to SecondString, then 0 is returned. Otherwise, the
|
---|
2026 | value returned is the first mismatched lower case ASCII character in
|
---|
2027 | SecondString subtracted from the first mismatched lower case ASCII character
|
---|
2028 | in FirstString.
|
---|
2029 |
|
---|
2030 | If FirstString is NULL, then ASSERT().
|
---|
2031 | If SecondString is NULL, then ASSERT().
|
---|
2032 | If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
|
---|
2033 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
|
---|
2034 | then ASSERT().
|
---|
2035 | If PcdMaximumAsciiStringLength is not zero and SecondString contains more
|
---|
2036 | than PcdMaximumAsciiStringLength ASCII characters not including the
|
---|
2037 | Null-terminator, then ASSERT().
|
---|
2038 |
|
---|
2039 | @param FirstString The pointer to a Null-terminated ASCII string.
|
---|
2040 | @param SecondString The pointer to a Null-terminated ASCII string.
|
---|
2041 |
|
---|
2042 | @retval ==0 FirstString is identical to SecondString using case insensitive
|
---|
2043 | comparisons.
|
---|
2044 | @retval !=0 FirstString is not identical to SecondString using case
|
---|
2045 | insensitive comparisons.
|
---|
2046 |
|
---|
2047 | **/
|
---|
2048 | INTN
|
---|
2049 | EFIAPI
|
---|
2050 | AsciiStriCmp (
|
---|
2051 | IN CONST CHAR8 *FirstString,
|
---|
2052 | IN CONST CHAR8 *SecondString
|
---|
2053 | );
|
---|
2054 |
|
---|
2055 | /**
|
---|
2056 | Compares two Null-terminated ASCII strings with maximum lengths, and returns
|
---|
2057 | the difference between the first mismatched ASCII characters.
|
---|
2058 |
|
---|
2059 | This function compares the Null-terminated ASCII string FirstString to the
|
---|
2060 | Null-terminated ASCII string SecondString. At most, Length ASCII characters
|
---|
2061 | will be compared. If Length is 0, then 0 is returned. If FirstString is
|
---|
2062 | identical to SecondString, then 0 is returned. Otherwise, the value returned
|
---|
2063 | is the first mismatched ASCII character in SecondString subtracted from the
|
---|
2064 | first mismatched ASCII character in FirstString.
|
---|
2065 |
|
---|
2066 | If Length > 0 and FirstString is NULL, then ASSERT().
|
---|
2067 | If Length > 0 and SecondString is NULL, then ASSERT().
|
---|
2068 | If PcdMaximumAsciiStringLength is not zero, and Length is greater than
|
---|
2069 | PcdMaximumAsciiStringLength, then ASSERT().
|
---|
2070 | If PcdMaximumAsciiStringLength is not zero, and FirstString contains more than
|
---|
2071 | PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
|
---|
2072 | then ASSERT().
|
---|
2073 | If PcdMaximumAsciiStringLength is not zero, and SecondString contains more than
|
---|
2074 | PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,
|
---|
2075 | then ASSERT().
|
---|
2076 |
|
---|
2077 | @param FirstString The pointer to a Null-terminated ASCII string.
|
---|
2078 | @param SecondString The pointer to a Null-terminated ASCII string.
|
---|
2079 | @param Length The maximum number of ASCII characters for compare.
|
---|
2080 |
|
---|
2081 | @retval ==0 FirstString is identical to SecondString.
|
---|
2082 | @retval !=0 FirstString is not identical to SecondString.
|
---|
2083 |
|
---|
2084 | **/
|
---|
2085 | INTN
|
---|
2086 | EFIAPI
|
---|
2087 | AsciiStrnCmp (
|
---|
2088 | IN CONST CHAR8 *FirstString,
|
---|
2089 | IN CONST CHAR8 *SecondString,
|
---|
2090 | IN UINTN Length
|
---|
2091 | );
|
---|
2092 |
|
---|
2093 | /**
|
---|
2094 | Returns the first occurrence of a Null-terminated ASCII sub-string
|
---|
2095 | in a Null-terminated ASCII string.
|
---|
2096 |
|
---|
2097 | This function scans the contents of the ASCII string specified by String
|
---|
2098 | and returns the first occurrence of SearchString. If SearchString is not
|
---|
2099 | found in String, then NULL is returned. If the length of SearchString is zero,
|
---|
2100 | then String is returned.
|
---|
2101 |
|
---|
2102 | If String is NULL, then ASSERT().
|
---|
2103 | If SearchString is NULL, then ASSERT().
|
---|
2104 |
|
---|
2105 | If PcdMaximumAsciiStringLength is not zero, and SearchString or
|
---|
2106 | String contains more than PcdMaximumAsciiStringLength Unicode characters
|
---|
2107 | not including the Null-terminator, then ASSERT().
|
---|
2108 |
|
---|
2109 | @param String The pointer to a Null-terminated ASCII string.
|
---|
2110 | @param SearchString The pointer to a Null-terminated ASCII string to search for.
|
---|
2111 |
|
---|
2112 | @retval NULL If the SearchString does not appear in String.
|
---|
2113 | @retval others If there is a match return the first occurrence of SearchingString.
|
---|
2114 | If the length of SearchString is zero,return String.
|
---|
2115 |
|
---|
2116 | **/
|
---|
2117 | CHAR8 *
|
---|
2118 | EFIAPI
|
---|
2119 | AsciiStrStr (
|
---|
2120 | IN CONST CHAR8 *String,
|
---|
2121 | IN CONST CHAR8 *SearchString
|
---|
2122 | );
|
---|
2123 |
|
---|
2124 | /**
|
---|
2125 | Convert a Null-terminated ASCII decimal string to a value of type
|
---|
2126 | UINTN.
|
---|
2127 |
|
---|
2128 | This function returns a value of type UINTN by interpreting the contents
|
---|
2129 | of the ASCII string String as a decimal number. The format of the input
|
---|
2130 | ASCII string String is:
|
---|
2131 |
|
---|
2132 | [spaces] [decimal digits].
|
---|
2133 |
|
---|
2134 | The valid decimal digit character is in the range [0-9]. The function will
|
---|
2135 | ignore the pad space, which includes spaces or tab characters, before the digits.
|
---|
2136 | The running zero in the beginning of [decimal digits] will be ignored. Then, the
|
---|
2137 | function stops at the first character that is a not a valid decimal character or
|
---|
2138 | Null-terminator, whichever on comes first.
|
---|
2139 |
|
---|
2140 | If String has only pad spaces, then 0 is returned.
|
---|
2141 | If String has no pad spaces or valid decimal digits, then 0 is returned.
|
---|
2142 | If the number represented by String overflows according to the range defined by
|
---|
2143 | UINTN, then MAX_UINTN is returned.
|
---|
2144 | If String is NULL, then ASSERT().
|
---|
2145 | If PcdMaximumAsciiStringLength is not zero, and String contains more than
|
---|
2146 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
|
---|
2147 | then ASSERT().
|
---|
2148 |
|
---|
2149 | @param String The pointer to a Null-terminated ASCII string.
|
---|
2150 |
|
---|
2151 | @retval The value translated from String.
|
---|
2152 |
|
---|
2153 | **/
|
---|
2154 | UINTN
|
---|
2155 | EFIAPI
|
---|
2156 | AsciiStrDecimalToUintn (
|
---|
2157 | IN CONST CHAR8 *String
|
---|
2158 | );
|
---|
2159 |
|
---|
2160 | /**
|
---|
2161 | Convert a Null-terminated ASCII decimal string to a value of type
|
---|
2162 | UINT64.
|
---|
2163 |
|
---|
2164 | This function returns a value of type UINT64 by interpreting the contents
|
---|
2165 | of the ASCII string String as a decimal number. The format of the input
|
---|
2166 | ASCII string String is:
|
---|
2167 |
|
---|
2168 | [spaces] [decimal digits].
|
---|
2169 |
|
---|
2170 | The valid decimal digit character is in the range [0-9]. The function will
|
---|
2171 | ignore the pad space, which includes spaces or tab characters, before the digits.
|
---|
2172 | The running zero in the beginning of [decimal digits] will be ignored. Then, the
|
---|
2173 | function stops at the first character that is a not a valid decimal character or
|
---|
2174 | Null-terminator, whichever on comes first.
|
---|
2175 |
|
---|
2176 | If String has only pad spaces, then 0 is returned.
|
---|
2177 | If String has no pad spaces or valid decimal digits, then 0 is returned.
|
---|
2178 | If the number represented by String overflows according to the range defined by
|
---|
2179 | UINT64, then MAX_UINT64 is returned.
|
---|
2180 | If String is NULL, then ASSERT().
|
---|
2181 | If PcdMaximumAsciiStringLength is not zero, and String contains more than
|
---|
2182 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
|
---|
2183 | then ASSERT().
|
---|
2184 |
|
---|
2185 | @param String The pointer to a Null-terminated ASCII string.
|
---|
2186 |
|
---|
2187 | @retval Value translated from String.
|
---|
2188 |
|
---|
2189 | **/
|
---|
2190 | UINT64
|
---|
2191 | EFIAPI
|
---|
2192 | AsciiStrDecimalToUint64 (
|
---|
2193 | IN CONST CHAR8 *String
|
---|
2194 | );
|
---|
2195 |
|
---|
2196 | /**
|
---|
2197 | Convert a Null-terminated ASCII hexadecimal string to a value of type UINTN.
|
---|
2198 |
|
---|
2199 | This function returns a value of type UINTN by interpreting the contents of
|
---|
2200 | the ASCII string String as a hexadecimal number. The format of the input ASCII
|
---|
2201 | string String is:
|
---|
2202 |
|
---|
2203 | [spaces][zeros][x][hexadecimal digits].
|
---|
2204 |
|
---|
2205 | The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
|
---|
2206 | The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
|
---|
2207 | appears in the input string, it must be prefixed with at least one 0. The function
|
---|
2208 | will ignore the pad space, which includes spaces or tab characters, before [zeros],
|
---|
2209 | [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
|
---|
2210 | will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
|
---|
2211 | digit. Then, the function stops at the first character that is a not a valid
|
---|
2212 | hexadecimal character or Null-terminator, whichever on comes first.
|
---|
2213 |
|
---|
2214 | If String has only pad spaces, then 0 is returned.
|
---|
2215 | If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
|
---|
2216 | 0 is returned.
|
---|
2217 |
|
---|
2218 | If the number represented by String overflows according to the range defined by UINTN,
|
---|
2219 | then MAX_UINTN is returned.
|
---|
2220 | If String is NULL, then ASSERT().
|
---|
2221 | If PcdMaximumAsciiStringLength is not zero,
|
---|
2222 | and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
|
---|
2223 | the Null-terminator, then ASSERT().
|
---|
2224 |
|
---|
2225 | @param String The pointer to a Null-terminated ASCII string.
|
---|
2226 |
|
---|
2227 | @retval Value translated from String.
|
---|
2228 |
|
---|
2229 | **/
|
---|
2230 | UINTN
|
---|
2231 | EFIAPI
|
---|
2232 | AsciiStrHexToUintn (
|
---|
2233 | IN CONST CHAR8 *String
|
---|
2234 | );
|
---|
2235 |
|
---|
2236 | /**
|
---|
2237 | Convert a Null-terminated ASCII hexadecimal string to a value of type UINT64.
|
---|
2238 |
|
---|
2239 | This function returns a value of type UINT64 by interpreting the contents of
|
---|
2240 | the ASCII string String as a hexadecimal number. The format of the input ASCII
|
---|
2241 | string String is:
|
---|
2242 |
|
---|
2243 | [spaces][zeros][x][hexadecimal digits].
|
---|
2244 |
|
---|
2245 | The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].
|
---|
2246 | The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"
|
---|
2247 | appears in the input string, it must be prefixed with at least one 0. The function
|
---|
2248 | will ignore the pad space, which includes spaces or tab characters, before [zeros],
|
---|
2249 | [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]
|
---|
2250 | will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal
|
---|
2251 | digit. Then, the function stops at the first character that is a not a valid
|
---|
2252 | hexadecimal character or Null-terminator, whichever on comes first.
|
---|
2253 |
|
---|
2254 | If String has only pad spaces, then 0 is returned.
|
---|
2255 | If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then
|
---|
2256 | 0 is returned.
|
---|
2257 |
|
---|
2258 | If the number represented by String overflows according to the range defined by UINT64,
|
---|
2259 | then MAX_UINT64 is returned.
|
---|
2260 | If String is NULL, then ASSERT().
|
---|
2261 | If PcdMaximumAsciiStringLength is not zero,
|
---|
2262 | and String contains more than PcdMaximumAsciiStringLength ASCII characters not including
|
---|
2263 | the Null-terminator, then ASSERT().
|
---|
2264 |
|
---|
2265 | @param String The pointer to a Null-terminated ASCII string.
|
---|
2266 |
|
---|
2267 | @retval Value translated from String.
|
---|
2268 |
|
---|
2269 | **/
|
---|
2270 | UINT64
|
---|
2271 | EFIAPI
|
---|
2272 | AsciiStrHexToUint64 (
|
---|
2273 | IN CONST CHAR8 *String
|
---|
2274 | );
|
---|
2275 |
|
---|
2276 | /**
|
---|
2277 | Convert a Null-terminated ASCII string to IPv6 address and prefix length.
|
---|
2278 |
|
---|
2279 | This function outputs a value of type IPv6_ADDRESS and may output a value
|
---|
2280 | of type UINT8 by interpreting the contents of the ASCII string specified
|
---|
2281 | by String. The format of the input ASCII string String is as follows:
|
---|
2282 |
|
---|
2283 | X:X:X:X:X:X:X:X[/P]
|
---|
2284 |
|
---|
2285 | X contains one to four hexadecimal digit characters in the range [0-9], [a-f] and
|
---|
2286 | [A-F]. X is converted to a value of type UINT16, whose low byte is stored in low
|
---|
2287 | memory address and high byte is stored in high memory address. P contains decimal
|
---|
2288 | digit characters in the range [0-9]. The running zero in the beginning of P will
|
---|
2289 | be ignored. /P is optional.
|
---|
2290 |
|
---|
2291 | When /P is not in the String, the function stops at the first character that is
|
---|
2292 | not a valid hexadecimal digit character after eight X's are converted.
|
---|
2293 |
|
---|
2294 | When /P is in the String, the function stops at the first character that is not
|
---|
2295 | a valid decimal digit character after P is converted.
|
---|
2296 |
|
---|
2297 | "::" can be used to compress one or more groups of X when X contains only 0.
|
---|
2298 | The "::" can only appear once in the String.
|
---|
2299 |
|
---|
2300 | If EndPointer is not NULL and Address is translated from String, a pointer
|
---|
2301 | to the character that stopped the scan is stored at the location pointed to
|
---|
2302 | by EndPointer.
|
---|
2303 |
|
---|
2304 | @param String Pointer to a Null-terminated ASCII string.
|
---|
2305 | @param EndPointer Pointer to character that stops scan.
|
---|
2306 | @param Address Pointer to the converted IPv6 address.
|
---|
2307 | @param PrefixLength Pointer to the converted IPv6 address prefix
|
---|
2308 | length. MAX_UINT8 is returned when /P is
|
---|
2309 | not in the String.
|
---|
2310 |
|
---|
2311 | @retval RETURN_SUCCESS Address is translated from String.
|
---|
2312 | @retval RETURN_INVALID_PARAMETER If String is NULL.
|
---|
2313 | If Data is NULL.
|
---|
2314 | @retval RETURN_UNSUPPORTED If X contains more than four hexadecimal
|
---|
2315 | digit characters.
|
---|
2316 | If String contains "::" and number of X
|
---|
2317 | is not less than 8.
|
---|
2318 | If P starts with character that is not a
|
---|
2319 | valid decimal digit character.
|
---|
2320 | If the decimal number converted from P
|
---|
2321 | exceeds 128.
|
---|
2322 |
|
---|
2323 | **/
|
---|
2324 | RETURN_STATUS
|
---|
2325 | EFIAPI
|
---|
2326 | AsciiStrToIpv6Address (
|
---|
2327 | IN CONST CHAR8 *String,
|
---|
2328 | OUT CHAR8 **EndPointer OPTIONAL,
|
---|
2329 | OUT IPv6_ADDRESS *Address,
|
---|
2330 | OUT UINT8 *PrefixLength OPTIONAL
|
---|
2331 | );
|
---|
2332 |
|
---|
2333 | /**
|
---|
2334 | Convert a Null-terminated ASCII string to IPv4 address and prefix length.
|
---|
2335 |
|
---|
2336 | This function outputs a value of type IPv4_ADDRESS and may output a value
|
---|
2337 | of type UINT8 by interpreting the contents of the ASCII string specified
|
---|
2338 | by String. The format of the input ASCII string String is as follows:
|
---|
2339 |
|
---|
2340 | D.D.D.D[/P]
|
---|
2341 |
|
---|
2342 | D and P are decimal digit characters in the range [0-9]. The running zero in
|
---|
2343 | the beginning of D and P will be ignored. /P is optional.
|
---|
2344 |
|
---|
2345 | When /P is not in the String, the function stops at the first character that is
|
---|
2346 | not a valid decimal digit character after four D's are converted.
|
---|
2347 |
|
---|
2348 | When /P is in the String, the function stops at the first character that is not
|
---|
2349 | a valid decimal digit character after P is converted.
|
---|
2350 |
|
---|
2351 | If EndPointer is not NULL and Address is translated from String, a pointer
|
---|
2352 | to the character that stopped the scan is stored at the location pointed to
|
---|
2353 | by EndPointer.
|
---|
2354 |
|
---|
2355 | @param String Pointer to a Null-terminated ASCII string.
|
---|
2356 | @param EndPointer Pointer to character that stops scan.
|
---|
2357 | @param Address Pointer to the converted IPv4 address.
|
---|
2358 | @param PrefixLength Pointer to the converted IPv4 address prefix
|
---|
2359 | length. MAX_UINT8 is returned when /P is
|
---|
2360 | not in the String.
|
---|
2361 |
|
---|
2362 | @retval RETURN_SUCCESS Address is translated from String.
|
---|
2363 | @retval RETURN_INVALID_PARAMETER If String is NULL.
|
---|
2364 | If Data is NULL.
|
---|
2365 | @retval RETURN_UNSUPPORTED If String is not in the correct format.
|
---|
2366 | If any decimal number converted from D
|
---|
2367 | exceeds 255.
|
---|
2368 | If the decimal number converted from P
|
---|
2369 | exceeds 32.
|
---|
2370 |
|
---|
2371 | **/
|
---|
2372 | RETURN_STATUS
|
---|
2373 | EFIAPI
|
---|
2374 | AsciiStrToIpv4Address (
|
---|
2375 | IN CONST CHAR8 *String,
|
---|
2376 | OUT CHAR8 **EndPointer OPTIONAL,
|
---|
2377 | OUT IPv4_ADDRESS *Address,
|
---|
2378 | OUT UINT8 *PrefixLength OPTIONAL
|
---|
2379 | );
|
---|
2380 |
|
---|
2381 | /**
|
---|
2382 | Convert a Null-terminated ASCII GUID string to a value of type
|
---|
2383 | EFI_GUID.
|
---|
2384 |
|
---|
2385 | This function outputs a GUID value by interpreting the contents of
|
---|
2386 | the ASCII string specified by String. The format of the input
|
---|
2387 | ASCII string String consists of 36 characters, as follows:
|
---|
2388 |
|
---|
2389 | aabbccdd-eeff-gghh-iijj-kkllmmnnoopp
|
---|
2390 |
|
---|
2391 | The pairs aa - pp are two characters in the range [0-9], [a-f] and
|
---|
2392 | [A-F], with each pair representing a single byte hexadecimal value.
|
---|
2393 |
|
---|
2394 | The mapping between String and the EFI_GUID structure is as follows:
|
---|
2395 | aa Data1[24:31]
|
---|
2396 | bb Data1[16:23]
|
---|
2397 | cc Data1[8:15]
|
---|
2398 | dd Data1[0:7]
|
---|
2399 | ee Data2[8:15]
|
---|
2400 | ff Data2[0:7]
|
---|
2401 | gg Data3[8:15]
|
---|
2402 | hh Data3[0:7]
|
---|
2403 | ii Data4[0:7]
|
---|
2404 | jj Data4[8:15]
|
---|
2405 | kk Data4[16:23]
|
---|
2406 | ll Data4[24:31]
|
---|
2407 | mm Data4[32:39]
|
---|
2408 | nn Data4[40:47]
|
---|
2409 | oo Data4[48:55]
|
---|
2410 | pp Data4[56:63]
|
---|
2411 |
|
---|
2412 | @param String Pointer to a Null-terminated ASCII string.
|
---|
2413 | @param Guid Pointer to the converted GUID.
|
---|
2414 |
|
---|
2415 | @retval RETURN_SUCCESS Guid is translated from String.
|
---|
2416 | @retval RETURN_INVALID_PARAMETER If String is NULL.
|
---|
2417 | If Data is NULL.
|
---|
2418 | @retval RETURN_UNSUPPORTED If String is not as the above format.
|
---|
2419 |
|
---|
2420 | **/
|
---|
2421 | RETURN_STATUS
|
---|
2422 | EFIAPI
|
---|
2423 | AsciiStrToGuid (
|
---|
2424 | IN CONST CHAR8 *String,
|
---|
2425 | OUT GUID *Guid
|
---|
2426 | );
|
---|
2427 |
|
---|
2428 | /**
|
---|
2429 | Convert a Null-terminated ASCII hexadecimal string to a byte array.
|
---|
2430 |
|
---|
2431 | This function outputs a byte array by interpreting the contents of
|
---|
2432 | the ASCII string specified by String in hexadecimal format. The format of
|
---|
2433 | the input ASCII string String is:
|
---|
2434 |
|
---|
2435 | [XX]*
|
---|
2436 |
|
---|
2437 | X is a hexadecimal digit character in the range [0-9], [a-f] and [A-F].
|
---|
2438 | The function decodes every two hexadecimal digit characters as one byte. The
|
---|
2439 | decoding stops after Length of characters and outputs Buffer containing
|
---|
2440 | (Length / 2) bytes.
|
---|
2441 |
|
---|
2442 | @param String Pointer to a Null-terminated ASCII string.
|
---|
2443 | @param Length The number of ASCII characters to decode.
|
---|
2444 | @param Buffer Pointer to the converted bytes array.
|
---|
2445 | @param MaxBufferSize The maximum size of Buffer.
|
---|
2446 |
|
---|
2447 | @retval RETURN_SUCCESS Buffer is translated from String.
|
---|
2448 | @retval RETURN_INVALID_PARAMETER If String is NULL.
|
---|
2449 | If Data is NULL.
|
---|
2450 | If Length is not multiple of 2.
|
---|
2451 | If PcdMaximumAsciiStringLength is not zero,
|
---|
2452 | and Length is greater than
|
---|
2453 | PcdMaximumAsciiStringLength.
|
---|
2454 | @retval RETURN_UNSUPPORTED If Length of characters from String contain
|
---|
2455 | a character that is not valid hexadecimal
|
---|
2456 | digit characters, or a Null-terminator.
|
---|
2457 | @retval RETURN_BUFFER_TOO_SMALL If MaxBufferSize is less than (Length / 2).
|
---|
2458 | **/
|
---|
2459 | RETURN_STATUS
|
---|
2460 | EFIAPI
|
---|
2461 | AsciiStrHexToBytes (
|
---|
2462 | IN CONST CHAR8 *String,
|
---|
2463 | IN UINTN Length,
|
---|
2464 | OUT UINT8 *Buffer,
|
---|
2465 | IN UINTN MaxBufferSize
|
---|
2466 | );
|
---|
2467 |
|
---|
2468 | /**
|
---|
2469 | Convert one Null-terminated ASCII string to a Null-terminated
|
---|
2470 | Unicode string.
|
---|
2471 |
|
---|
2472 | This function is similar to StrCpyS.
|
---|
2473 |
|
---|
2474 | This function converts the contents of the ASCII string Source to the Unicode
|
---|
2475 | string Destination. The function terminates the Unicode string Destination by
|
---|
2476 | appending a Null-terminator character at the end.
|
---|
2477 |
|
---|
2478 | The caller is responsible to make sure Destination points to a buffer with size
|
---|
2479 | equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.
|
---|
2480 |
|
---|
2481 | If Destination is not aligned on a 16-bit boundary, then ASSERT().
|
---|
2482 |
|
---|
2483 | If an error is returned, then the Destination is unmodified.
|
---|
2484 |
|
---|
2485 | @param Source The pointer to a Null-terminated ASCII string.
|
---|
2486 | @param Destination The pointer to a Null-terminated Unicode string.
|
---|
2487 | @param DestMax The maximum number of Destination Unicode
|
---|
2488 | char, including terminating null char.
|
---|
2489 |
|
---|
2490 | @retval RETURN_SUCCESS String is converted.
|
---|
2491 | @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).
|
---|
2492 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.
|
---|
2493 | If Source is NULL.
|
---|
2494 | If PcdMaximumUnicodeStringLength is not zero,
|
---|
2495 | and DestMax is greater than
|
---|
2496 | PcdMaximumUnicodeStringLength.
|
---|
2497 | If PcdMaximumAsciiStringLength is not zero,
|
---|
2498 | and DestMax is greater than
|
---|
2499 | PcdMaximumAsciiStringLength.
|
---|
2500 | If DestMax is 0.
|
---|
2501 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
|
---|
2502 |
|
---|
2503 | **/
|
---|
2504 | RETURN_STATUS
|
---|
2505 | EFIAPI
|
---|
2506 | AsciiStrToUnicodeStrS (
|
---|
2507 | IN CONST CHAR8 *Source,
|
---|
2508 | OUT CHAR16 *Destination,
|
---|
2509 | IN UINTN DestMax
|
---|
2510 | );
|
---|
2511 |
|
---|
2512 | /**
|
---|
2513 | Convert not more than Length successive characters from a Null-terminated
|
---|
2514 | Ascii string to a Null-terminated Unicode string. If no null char is copied
|
---|
2515 | from Source, then Destination[Length] is always set to null.
|
---|
2516 |
|
---|
2517 | This function converts not more than Length successive characters from the
|
---|
2518 | Ascii string Source to the Unicode string Destination. The function
|
---|
2519 | terminates the Unicode string Destination by appending a Null-terminator
|
---|
2520 | character at the end.
|
---|
2521 |
|
---|
2522 | The caller is responsible to make sure Destination points to a buffer with
|
---|
2523 | size not smaller than
|
---|
2524 | ((MIN(AsciiStrLen(Source), Length) + 1) * sizeof (CHAR8)) in bytes.
|
---|
2525 |
|
---|
2526 | If Destination is not aligned on a 16-bit boundary, then ASSERT().
|
---|
2527 |
|
---|
2528 | If an error is returned, then Destination and DestinationLength are
|
---|
2529 | unmodified.
|
---|
2530 |
|
---|
2531 | @param Source The pointer to a Null-terminated Ascii string.
|
---|
2532 | @param Length The maximum number of Ascii characters to convert.
|
---|
2533 | @param Destination The pointer to a Null-terminated Unicode string.
|
---|
2534 | @param DestMax The maximum number of Destination Unicode char,
|
---|
2535 | including terminating null char.
|
---|
2536 | @param DestinationLength The number of Ascii characters converted.
|
---|
2537 |
|
---|
2538 | @retval RETURN_SUCCESS String is converted.
|
---|
2539 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.
|
---|
2540 | If Source is NULL.
|
---|
2541 | If DestinationLength is NULL.
|
---|
2542 | If PcdMaximumUnicodeStringLength is not
|
---|
2543 | zero, and Length or DestMax is greater than
|
---|
2544 | PcdMaximumUnicodeStringLength.
|
---|
2545 | If PcdMaximumAsciiStringLength is not zero,
|
---|
2546 | and Length or DestMax is greater than
|
---|
2547 | PcdMaximumAsciiStringLength.
|
---|
2548 | If DestMax is 0.
|
---|
2549 | @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than
|
---|
2550 | MIN(AsciiStrLen(Source), Length).
|
---|
2551 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.
|
---|
2552 |
|
---|
2553 | **/
|
---|
2554 | RETURN_STATUS
|
---|
2555 | EFIAPI
|
---|
2556 | AsciiStrnToUnicodeStrS (
|
---|
2557 | IN CONST CHAR8 *Source,
|
---|
2558 | IN UINTN Length,
|
---|
2559 | OUT CHAR16 *Destination,
|
---|
2560 | IN UINTN DestMax,
|
---|
2561 | OUT UINTN *DestinationLength
|
---|
2562 | );
|
---|
2563 |
|
---|
2564 | /**
|
---|
2565 | Convert a Unicode character to upper case only if
|
---|
2566 | it maps to a valid small-case ASCII character.
|
---|
2567 |
|
---|
2568 | This internal function only deal with Unicode character
|
---|
2569 | which maps to a valid small-case ASCII character, i.e.
|
---|
2570 | L'a' to L'z'. For other Unicode character, the input character
|
---|
2571 | is returned directly.
|
---|
2572 |
|
---|
2573 | @param Char The character to convert.
|
---|
2574 |
|
---|
2575 | @retval LowerCharacter If the Char is with range L'a' to L'z'.
|
---|
2576 | @retval Unchanged Otherwise.
|
---|
2577 |
|
---|
2578 | **/
|
---|
2579 | CHAR16
|
---|
2580 | EFIAPI
|
---|
2581 | CharToUpper (
|
---|
2582 | IN CHAR16 Char
|
---|
2583 | );
|
---|
2584 |
|
---|
2585 | /**
|
---|
2586 | Converts a lowercase Ascii character to upper one.
|
---|
2587 |
|
---|
2588 | If Chr is lowercase Ascii character, then converts it to upper one.
|
---|
2589 |
|
---|
2590 | If Value >= 0xA0, then ASSERT().
|
---|
2591 | If (Value & 0x0F) >= 0x0A, then ASSERT().
|
---|
2592 |
|
---|
2593 | @param Chr one Ascii character
|
---|
2594 |
|
---|
2595 | @return The uppercase value of Ascii character
|
---|
2596 |
|
---|
2597 | **/
|
---|
2598 | CHAR8
|
---|
2599 | EFIAPI
|
---|
2600 | AsciiCharToUpper (
|
---|
2601 | IN CHAR8 Chr
|
---|
2602 | );
|
---|
2603 |
|
---|
2604 | /**
|
---|
2605 | Convert binary data to a Base64 encoded ascii string based on RFC4648.
|
---|
2606 |
|
---|
2607 | Produce a Null-terminated Ascii string in the output buffer specified by Destination and DestinationSize.
|
---|
2608 | The Ascii string is produced by converting the data string specified by Source and SourceLength.
|
---|
2609 |
|
---|
2610 | @param Source Input UINT8 data
|
---|
2611 | @param SourceLength Number of UINT8 bytes of data
|
---|
2612 | @param Destination Pointer to output string buffer
|
---|
2613 | @param DestinationSize Size of ascii buffer. Set to 0 to get the size needed.
|
---|
2614 | Caller is responsible for passing in buffer of DestinationSize
|
---|
2615 |
|
---|
2616 | @retval RETURN_SUCCESS When ascii buffer is filled in.
|
---|
2617 | @retval RETURN_INVALID_PARAMETER If Source is NULL or DestinationSize is NULL.
|
---|
2618 | @retval RETURN_INVALID_PARAMETER If SourceLength or DestinationSize is bigger than (MAX_ADDRESS - (UINTN)Destination).
|
---|
2619 | @retval RETURN_BUFFER_TOO_SMALL If SourceLength is 0 and DestinationSize is <1.
|
---|
2620 | @retval RETURN_BUFFER_TOO_SMALL If Destination is NULL or DestinationSize is smaller than required buffersize.
|
---|
2621 |
|
---|
2622 | **/
|
---|
2623 | RETURN_STATUS
|
---|
2624 | EFIAPI
|
---|
2625 | Base64Encode (
|
---|
2626 | IN CONST UINT8 *Source,
|
---|
2627 | IN UINTN SourceLength,
|
---|
2628 | OUT CHAR8 *Destination OPTIONAL,
|
---|
2629 | IN OUT UINTN *DestinationSize
|
---|
2630 | );
|
---|
2631 |
|
---|
2632 | /**
|
---|
2633 | Decode Base64 ASCII encoded data to 8-bit binary representation, based on
|
---|
2634 | RFC4648.
|
---|
2635 |
|
---|
2636 | Decoding occurs according to "Table 1: The Base 64 Alphabet" in RFC4648.
|
---|
2637 |
|
---|
2638 | Whitespace is ignored at all positions:
|
---|
2639 | - 0x09 ('\t') horizontal tab
|
---|
2640 | - 0x0A ('\n') new line
|
---|
2641 | - 0x0B ('\v') vertical tab
|
---|
2642 | - 0x0C ('\f') form feed
|
---|
2643 | - 0x0D ('\r') carriage return
|
---|
2644 | - 0x20 (' ') space
|
---|
2645 |
|
---|
2646 | The minimum amount of required padding (with ASCII 0x3D, '=') is tolerated
|
---|
2647 | and enforced at the end of the Base64 ASCII encoded data, and only there.
|
---|
2648 |
|
---|
2649 | Other characters outside of the encoding alphabet cause the function to
|
---|
2650 | reject the Base64 ASCII encoded data.
|
---|
2651 |
|
---|
2652 | @param[in] Source Array of CHAR8 elements containing the Base64
|
---|
2653 | ASCII encoding. May be NULL if SourceSize is
|
---|
2654 | zero.
|
---|
2655 |
|
---|
2656 | @param[in] SourceSize Number of CHAR8 elements in Source.
|
---|
2657 |
|
---|
2658 | @param[out] Destination Array of UINT8 elements receiving the decoded
|
---|
2659 | 8-bit binary representation. Allocated by the
|
---|
2660 | caller. May be NULL if DestinationSize is
|
---|
2661 | zero on input. If NULL, decoding is
|
---|
2662 | performed, but the 8-bit binary
|
---|
2663 | representation is not stored. If non-NULL and
|
---|
2664 | the function returns an error, the contents
|
---|
2665 | of Destination are indeterminate.
|
---|
2666 |
|
---|
2667 | @param[in,out] DestinationSize On input, the number of UINT8 elements that
|
---|
2668 | the caller allocated for Destination. On
|
---|
2669 | output, if the function returns
|
---|
2670 | RETURN_SUCCESS or RETURN_BUFFER_TOO_SMALL,
|
---|
2671 | the number of UINT8 elements that are
|
---|
2672 | required for decoding the Base64 ASCII
|
---|
2673 | representation. If the function returns a
|
---|
2674 | value different from both RETURN_SUCCESS and
|
---|
2675 | RETURN_BUFFER_TOO_SMALL, then DestinationSize
|
---|
2676 | is indeterminate on output.
|
---|
2677 |
|
---|
2678 | @retval RETURN_SUCCESS SourceSize CHAR8 elements at Source have
|
---|
2679 | been decoded to on-output DestinationSize
|
---|
2680 | UINT8 elements at Destination. Note that
|
---|
2681 | RETURN_SUCCESS covers the case when
|
---|
2682 | DestinationSize is zero on input, and
|
---|
2683 | Source decodes to zero bytes (due to
|
---|
2684 | containing at most ignored whitespace).
|
---|
2685 |
|
---|
2686 | @retval RETURN_BUFFER_TOO_SMALL The input value of DestinationSize is not
|
---|
2687 | large enough for decoding SourceSize CHAR8
|
---|
2688 | elements at Source. The required number of
|
---|
2689 | UINT8 elements has been stored to
|
---|
2690 | DestinationSize.
|
---|
2691 |
|
---|
2692 | @retval RETURN_INVALID_PARAMETER DestinationSize is NULL.
|
---|
2693 |
|
---|
2694 | @retval RETURN_INVALID_PARAMETER Source is NULL, but SourceSize is not zero.
|
---|
2695 |
|
---|
2696 | @retval RETURN_INVALID_PARAMETER Destination is NULL, but DestinationSize is
|
---|
2697 | not zero on input.
|
---|
2698 |
|
---|
2699 | @retval RETURN_INVALID_PARAMETER Source is non-NULL, and (Source +
|
---|
2700 | SourceSize) would wrap around MAX_ADDRESS.
|
---|
2701 |
|
---|
2702 | @retval RETURN_INVALID_PARAMETER Destination is non-NULL, and (Destination +
|
---|
2703 | DestinationSize) would wrap around
|
---|
2704 | MAX_ADDRESS, as specified on input.
|
---|
2705 |
|
---|
2706 | @retval RETURN_INVALID_PARAMETER None of Source and Destination are NULL,
|
---|
2707 | and CHAR8[SourceSize] at Source overlaps
|
---|
2708 | UINT8[DestinationSize] at Destination, as
|
---|
2709 | specified on input.
|
---|
2710 |
|
---|
2711 | @retval RETURN_INVALID_PARAMETER Invalid CHAR8 element encountered in
|
---|
2712 | Source.
|
---|
2713 | **/
|
---|
2714 | RETURN_STATUS
|
---|
2715 | EFIAPI
|
---|
2716 | Base64Decode (
|
---|
2717 | IN CONST CHAR8 *Source OPTIONAL,
|
---|
2718 | IN UINTN SourceSize,
|
---|
2719 | OUT UINT8 *Destination OPTIONAL,
|
---|
2720 | IN OUT UINTN *DestinationSize
|
---|
2721 | );
|
---|
2722 |
|
---|
2723 | /**
|
---|
2724 | Converts an 8-bit value to an 8-bit BCD value.
|
---|
2725 |
|
---|
2726 | Converts the 8-bit value specified by Value to BCD. The BCD value is
|
---|
2727 | returned.
|
---|
2728 |
|
---|
2729 | If Value >= 100, then ASSERT().
|
---|
2730 |
|
---|
2731 | @param Value The 8-bit value to convert to BCD. Range 0..99.
|
---|
2732 |
|
---|
2733 | @return The BCD value.
|
---|
2734 |
|
---|
2735 | **/
|
---|
2736 | UINT8
|
---|
2737 | EFIAPI
|
---|
2738 | DecimalToBcd8 (
|
---|
2739 | IN UINT8 Value
|
---|
2740 | );
|
---|
2741 |
|
---|
2742 | /**
|
---|
2743 | Converts an 8-bit BCD value to an 8-bit value.
|
---|
2744 |
|
---|
2745 | Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit
|
---|
2746 | value is returned.
|
---|
2747 |
|
---|
2748 | If Value >= 0xA0, then ASSERT().
|
---|
2749 | If (Value & 0x0F) >= 0x0A, then ASSERT().
|
---|
2750 |
|
---|
2751 | @param Value The 8-bit BCD value to convert to an 8-bit value.
|
---|
2752 |
|
---|
2753 | @return The 8-bit value is returned.
|
---|
2754 |
|
---|
2755 | **/
|
---|
2756 | UINT8
|
---|
2757 | EFIAPI
|
---|
2758 | BcdToDecimal8 (
|
---|
2759 | IN UINT8 Value
|
---|
2760 | );
|
---|
2761 |
|
---|
2762 | //
|
---|
2763 | // File Path Manipulation Functions
|
---|
2764 | //
|
---|
2765 |
|
---|
2766 | /**
|
---|
2767 | Removes the last directory or file entry in a path.
|
---|
2768 |
|
---|
2769 | @param[in, out] Path The pointer to the path to modify.
|
---|
2770 |
|
---|
2771 | @retval FALSE Nothing was found to remove.
|
---|
2772 | @retval TRUE A directory or file was removed.
|
---|
2773 | **/
|
---|
2774 | BOOLEAN
|
---|
2775 | EFIAPI
|
---|
2776 | PathRemoveLastItem (
|
---|
2777 | IN OUT CHAR16 *Path
|
---|
2778 | );
|
---|
2779 |
|
---|
2780 | /**
|
---|
2781 | Function to clean up paths.
|
---|
2782 | - Single periods in the path are removed.
|
---|
2783 | - Double periods in the path are removed along with a single parent directory.
|
---|
2784 | - Forward slashes L'/' are converted to backward slashes L'\'.
|
---|
2785 |
|
---|
2786 | This will be done inline and the existing buffer may be larger than required
|
---|
2787 | upon completion.
|
---|
2788 |
|
---|
2789 | @param[in] Path The pointer to the string containing the path.
|
---|
2790 |
|
---|
2791 | @return Returns Path, otherwise returns NULL to indicate that an error has occurred.
|
---|
2792 | **/
|
---|
2793 | CHAR16 *
|
---|
2794 | EFIAPI
|
---|
2795 | PathCleanUpDirectories (
|
---|
2796 | IN CHAR16 *Path
|
---|
2797 | );
|
---|
2798 |
|
---|
2799 | //
|
---|
2800 | // Linked List Functions and Macros
|
---|
2801 | //
|
---|
2802 |
|
---|
2803 | /**
|
---|
2804 | Initializes the head node of a doubly linked list that is declared as a
|
---|
2805 | global variable in a module.
|
---|
2806 |
|
---|
2807 | Initializes the forward and backward links of a new linked list. After
|
---|
2808 | initializing a linked list with this macro, the other linked list functions
|
---|
2809 | may be used to add and remove nodes from the linked list. This macro results
|
---|
2810 | in smaller executables by initializing the linked list in the data section,
|
---|
2811 | instead if calling the InitializeListHead() function to perform the
|
---|
2812 | equivalent operation.
|
---|
2813 |
|
---|
2814 | @param ListHead The head note of a list to initialize.
|
---|
2815 |
|
---|
2816 | **/
|
---|
2817 | #define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&(ListHead), &(ListHead)}
|
---|
2818 |
|
---|
2819 | /**
|
---|
2820 | Iterates over each node in a doubly linked list using each node's forward link.
|
---|
2821 |
|
---|
2822 | @param Entry A pointer to a list node used as a loop cursor during iteration
|
---|
2823 | @param ListHead The head node of the doubly linked list
|
---|
2824 |
|
---|
2825 | **/
|
---|
2826 | #define BASE_LIST_FOR_EACH(Entry, ListHead) \
|
---|
2827 | for(Entry = (ListHead)->ForwardLink; Entry != (ListHead); Entry = Entry->ForwardLink)
|
---|
2828 |
|
---|
2829 | /**
|
---|
2830 | Iterates over each node in a doubly linked list using each node's forward link
|
---|
2831 | with safety against node removal.
|
---|
2832 |
|
---|
2833 | This macro uses NextEntry to temporarily store the next list node so the node
|
---|
2834 | pointed to by Entry may be deleted in the current loop iteration step and
|
---|
2835 | iteration can continue from the node pointed to by NextEntry.
|
---|
2836 |
|
---|
2837 | @param Entry A pointer to a list node used as a loop cursor during iteration
|
---|
2838 | @param NextEntry A pointer to a list node used to temporarily store the next node
|
---|
2839 | @param ListHead The head node of the doubly linked list
|
---|
2840 |
|
---|
2841 | **/
|
---|
2842 | #define BASE_LIST_FOR_EACH_SAFE(Entry, NextEntry, ListHead) \
|
---|
2843 | for(Entry = (ListHead)->ForwardLink, NextEntry = Entry->ForwardLink;\
|
---|
2844 | Entry != (ListHead); Entry = NextEntry, NextEntry = Entry->ForwardLink)
|
---|
2845 |
|
---|
2846 | /**
|
---|
2847 | Checks whether FirstEntry and SecondEntry are part of the same doubly-linked
|
---|
2848 | list.
|
---|
2849 |
|
---|
2850 | If FirstEntry is NULL, then ASSERT().
|
---|
2851 | If FirstEntry->ForwardLink is NULL, then ASSERT().
|
---|
2852 | If FirstEntry->BackLink is NULL, then ASSERT().
|
---|
2853 | If SecondEntry is NULL, then ASSERT();
|
---|
2854 | If PcdMaximumLinkedListLength is not zero, and List contains more than
|
---|
2855 | PcdMaximumLinkedListLength nodes, then ASSERT().
|
---|
2856 |
|
---|
2857 | @param FirstEntry A pointer to a node in a linked list.
|
---|
2858 | @param SecondEntry A pointer to the node to locate.
|
---|
2859 |
|
---|
2860 | @retval TRUE SecondEntry is in the same doubly-linked list as FirstEntry.
|
---|
2861 | @retval FALSE SecondEntry isn't in the same doubly-linked list as FirstEntry,
|
---|
2862 | or FirstEntry is invalid.
|
---|
2863 |
|
---|
2864 | **/
|
---|
2865 | BOOLEAN
|
---|
2866 | EFIAPI
|
---|
2867 | IsNodeInList (
|
---|
2868 | IN CONST LIST_ENTRY *FirstEntry,
|
---|
2869 | IN CONST LIST_ENTRY *SecondEntry
|
---|
2870 | );
|
---|
2871 |
|
---|
2872 | /**
|
---|
2873 | Initializes the head node of a doubly linked list, and returns the pointer to
|
---|
2874 | the head node of the doubly linked list.
|
---|
2875 |
|
---|
2876 | Initializes the forward and backward links of a new linked list. After
|
---|
2877 | initializing a linked list with this function, the other linked list
|
---|
2878 | functions may be used to add and remove nodes from the linked list. It is up
|
---|
2879 | to the caller of this function to allocate the memory for ListHead.
|
---|
2880 |
|
---|
2881 | If ListHead is NULL, then ASSERT().
|
---|
2882 |
|
---|
2883 | @param ListHead A pointer to the head node of a new doubly linked list.
|
---|
2884 |
|
---|
2885 | @return ListHead
|
---|
2886 |
|
---|
2887 | **/
|
---|
2888 | LIST_ENTRY *
|
---|
2889 | EFIAPI
|
---|
2890 | InitializeListHead (
|
---|
2891 | IN OUT LIST_ENTRY *ListHead
|
---|
2892 | );
|
---|
2893 |
|
---|
2894 | /**
|
---|
2895 | Adds a node to the beginning of a doubly linked list, and returns the pointer
|
---|
2896 | to the head node of the doubly linked list.
|
---|
2897 |
|
---|
2898 | Adds the node Entry at the beginning of the doubly linked list denoted by
|
---|
2899 | ListHead, and returns ListHead.
|
---|
2900 |
|
---|
2901 | If ListHead is NULL, then ASSERT().
|
---|
2902 | If Entry is NULL, then ASSERT().
|
---|
2903 | If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
|
---|
2904 | InitializeListHead(), then ASSERT().
|
---|
2905 | If PcdMaximumLinkedListLength is not zero, and prior to insertion the number
|
---|
2906 | of nodes in ListHead, including the ListHead node, is greater than or
|
---|
2907 | equal to PcdMaximumLinkedListLength, then ASSERT().
|
---|
2908 |
|
---|
2909 | @param ListHead A pointer to the head node of a doubly linked list.
|
---|
2910 | @param Entry A pointer to a node that is to be inserted at the beginning
|
---|
2911 | of a doubly linked list.
|
---|
2912 |
|
---|
2913 | @return ListHead
|
---|
2914 |
|
---|
2915 | **/
|
---|
2916 | LIST_ENTRY *
|
---|
2917 | EFIAPI
|
---|
2918 | InsertHeadList (
|
---|
2919 | IN OUT LIST_ENTRY *ListHead,
|
---|
2920 | IN OUT LIST_ENTRY *Entry
|
---|
2921 | );
|
---|
2922 |
|
---|
2923 | /**
|
---|
2924 | Adds a node to the end of a doubly linked list, and returns the pointer to
|
---|
2925 | the head node of the doubly linked list.
|
---|
2926 |
|
---|
2927 | Adds the node Entry to the end of the doubly linked list denoted by ListHead,
|
---|
2928 | and returns ListHead.
|
---|
2929 |
|
---|
2930 | If ListHead is NULL, then ASSERT().
|
---|
2931 | If Entry is NULL, then ASSERT().
|
---|
2932 | If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
|
---|
2933 | InitializeListHead(), then ASSERT().
|
---|
2934 | If PcdMaximumLinkedListLength is not zero, and prior to insertion the number
|
---|
2935 | of nodes in ListHead, including the ListHead node, is greater than or
|
---|
2936 | equal to PcdMaximumLinkedListLength, then ASSERT().
|
---|
2937 |
|
---|
2938 | @param ListHead A pointer to the head node of a doubly linked list.
|
---|
2939 | @param Entry A pointer to a node that is to be added at the end of the
|
---|
2940 | doubly linked list.
|
---|
2941 |
|
---|
2942 | @return ListHead
|
---|
2943 |
|
---|
2944 | **/
|
---|
2945 | LIST_ENTRY *
|
---|
2946 | EFIAPI
|
---|
2947 | InsertTailList (
|
---|
2948 | IN OUT LIST_ENTRY *ListHead,
|
---|
2949 | IN OUT LIST_ENTRY *Entry
|
---|
2950 | );
|
---|
2951 |
|
---|
2952 | /**
|
---|
2953 | Retrieves the first node of a doubly linked list.
|
---|
2954 |
|
---|
2955 | Returns the first node of a doubly linked list. List must have been
|
---|
2956 | initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
|
---|
2957 | If List is empty, then List is returned.
|
---|
2958 |
|
---|
2959 | If List is NULL, then ASSERT().
|
---|
2960 | If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
|
---|
2961 | InitializeListHead(), then ASSERT().
|
---|
2962 | If PcdMaximumLinkedListLength is not zero, and the number of nodes
|
---|
2963 | in List, including the List node, is greater than or equal to
|
---|
2964 | PcdMaximumLinkedListLength, then ASSERT().
|
---|
2965 |
|
---|
2966 | @param List A pointer to the head node of a doubly linked list.
|
---|
2967 |
|
---|
2968 | @return The first node of a doubly linked list.
|
---|
2969 | @retval List The list is empty.
|
---|
2970 |
|
---|
2971 | **/
|
---|
2972 | LIST_ENTRY *
|
---|
2973 | EFIAPI
|
---|
2974 | GetFirstNode (
|
---|
2975 | IN CONST LIST_ENTRY *List
|
---|
2976 | );
|
---|
2977 |
|
---|
2978 | /**
|
---|
2979 | Retrieves the next node of a doubly linked list.
|
---|
2980 |
|
---|
2981 | Returns the node of a doubly linked list that follows Node.
|
---|
2982 | List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()
|
---|
2983 | or InitializeListHead(). If List is empty, then List is returned.
|
---|
2984 |
|
---|
2985 | If List is NULL, then ASSERT().
|
---|
2986 | If Node is NULL, then ASSERT().
|
---|
2987 | If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
|
---|
2988 | InitializeListHead(), then ASSERT().
|
---|
2989 | If PcdMaximumLinkedListLength is not zero, and List contains more than
|
---|
2990 | PcdMaximumLinkedListLength nodes, then ASSERT().
|
---|
2991 | If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
|
---|
2992 |
|
---|
2993 | @param List A pointer to the head node of a doubly linked list.
|
---|
2994 | @param Node A pointer to a node in the doubly linked list.
|
---|
2995 |
|
---|
2996 | @return The pointer to the next node if one exists. Otherwise List is returned.
|
---|
2997 |
|
---|
2998 | **/
|
---|
2999 | LIST_ENTRY *
|
---|
3000 | EFIAPI
|
---|
3001 | GetNextNode (
|
---|
3002 | IN CONST LIST_ENTRY *List,
|
---|
3003 | IN CONST LIST_ENTRY *Node
|
---|
3004 | );
|
---|
3005 |
|
---|
3006 | /**
|
---|
3007 | Retrieves the previous node of a doubly linked list.
|
---|
3008 |
|
---|
3009 | Returns the node of a doubly linked list that precedes Node.
|
---|
3010 | List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()
|
---|
3011 | or InitializeListHead(). If List is empty, then List is returned.
|
---|
3012 |
|
---|
3013 | If List is NULL, then ASSERT().
|
---|
3014 | If Node is NULL, then ASSERT().
|
---|
3015 | If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
|
---|
3016 | InitializeListHead(), then ASSERT().
|
---|
3017 | If PcdMaximumLinkedListLength is not zero, and List contains more than
|
---|
3018 | PcdMaximumLinkedListLength nodes, then ASSERT().
|
---|
3019 | If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
|
---|
3020 |
|
---|
3021 | @param List A pointer to the head node of a doubly linked list.
|
---|
3022 | @param Node A pointer to a node in the doubly linked list.
|
---|
3023 |
|
---|
3024 | @return The pointer to the previous node if one exists. Otherwise List is returned.
|
---|
3025 |
|
---|
3026 | **/
|
---|
3027 | LIST_ENTRY *
|
---|
3028 | EFIAPI
|
---|
3029 | GetPreviousNode (
|
---|
3030 | IN CONST LIST_ENTRY *List,
|
---|
3031 | IN CONST LIST_ENTRY *Node
|
---|
3032 | );
|
---|
3033 |
|
---|
3034 | /**
|
---|
3035 | Checks to see if a doubly linked list is empty or not.
|
---|
3036 |
|
---|
3037 | Checks to see if the doubly linked list is empty. If the linked list contains
|
---|
3038 | zero nodes, this function returns TRUE. Otherwise, it returns FALSE.
|
---|
3039 |
|
---|
3040 | If ListHead is NULL, then ASSERT().
|
---|
3041 | If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
|
---|
3042 | InitializeListHead(), then ASSERT().
|
---|
3043 | If PcdMaximumLinkedListLength is not zero, and the number of nodes
|
---|
3044 | in List, including the List node, is greater than or equal to
|
---|
3045 | PcdMaximumLinkedListLength, then ASSERT().
|
---|
3046 |
|
---|
3047 | @param ListHead A pointer to the head node of a doubly linked list.
|
---|
3048 |
|
---|
3049 | @retval TRUE The linked list is empty.
|
---|
3050 | @retval FALSE The linked list is not empty.
|
---|
3051 |
|
---|
3052 | **/
|
---|
3053 | BOOLEAN
|
---|
3054 | EFIAPI
|
---|
3055 | IsListEmpty (
|
---|
3056 | IN CONST LIST_ENTRY *ListHead
|
---|
3057 | );
|
---|
3058 |
|
---|
3059 | /**
|
---|
3060 | Determines if a node in a doubly linked list is the head node of a the same
|
---|
3061 | doubly linked list. This function is typically used to terminate a loop that
|
---|
3062 | traverses all the nodes in a doubly linked list starting with the head node.
|
---|
3063 |
|
---|
3064 | Returns TRUE if Node is equal to List. Returns FALSE if Node is one of the
|
---|
3065 | nodes in the doubly linked list specified by List. List must have been
|
---|
3066 | initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
|
---|
3067 |
|
---|
3068 | If List is NULL, then ASSERT().
|
---|
3069 | If Node is NULL, then ASSERT().
|
---|
3070 | If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead(),
|
---|
3071 | then ASSERT().
|
---|
3072 | If PcdMaximumLinkedListLength is not zero, and the number of nodes
|
---|
3073 | in List, including the List node, is greater than or equal to
|
---|
3074 | PcdMaximumLinkedListLength, then ASSERT().
|
---|
3075 | If PcdVerifyNodeInList is TRUE and Node is not a node in List the and Node is not equal
|
---|
3076 | to List, then ASSERT().
|
---|
3077 |
|
---|
3078 | @param List A pointer to the head node of a doubly linked list.
|
---|
3079 | @param Node A pointer to a node in the doubly linked list.
|
---|
3080 |
|
---|
3081 | @retval TRUE Node is the head of the doubly-linked list pointed by List.
|
---|
3082 | @retval FALSE Node is not the head of the doubly-linked list pointed by List.
|
---|
3083 |
|
---|
3084 | **/
|
---|
3085 | BOOLEAN
|
---|
3086 | EFIAPI
|
---|
3087 | IsNull (
|
---|
3088 | IN CONST LIST_ENTRY *List,
|
---|
3089 | IN CONST LIST_ENTRY *Node
|
---|
3090 | );
|
---|
3091 |
|
---|
3092 | /**
|
---|
3093 | Determines if a node the last node in a doubly linked list.
|
---|
3094 |
|
---|
3095 | Returns TRUE if Node is the last node in the doubly linked list specified by
|
---|
3096 | List. Otherwise, FALSE is returned. List must have been initialized with
|
---|
3097 | INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
|
---|
3098 |
|
---|
3099 | If List is NULL, then ASSERT().
|
---|
3100 | If Node is NULL, then ASSERT().
|
---|
3101 | If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or
|
---|
3102 | InitializeListHead(), then ASSERT().
|
---|
3103 | If PcdMaximumLinkedListLength is not zero, and the number of nodes
|
---|
3104 | in List, including the List node, is greater than or equal to
|
---|
3105 | PcdMaximumLinkedListLength, then ASSERT().
|
---|
3106 | If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().
|
---|
3107 |
|
---|
3108 | @param List A pointer to the head node of a doubly linked list.
|
---|
3109 | @param Node A pointer to a node in the doubly linked list.
|
---|
3110 |
|
---|
3111 | @retval TRUE Node is the last node in the linked list.
|
---|
3112 | @retval FALSE Node is not the last node in the linked list.
|
---|
3113 |
|
---|
3114 | **/
|
---|
3115 | BOOLEAN
|
---|
3116 | EFIAPI
|
---|
3117 | IsNodeAtEnd (
|
---|
3118 | IN CONST LIST_ENTRY *List,
|
---|
3119 | IN CONST LIST_ENTRY *Node
|
---|
3120 | );
|
---|
3121 |
|
---|
3122 | /**
|
---|
3123 | Swaps the location of two nodes in a doubly linked list, and returns the
|
---|
3124 | first node after the swap.
|
---|
3125 |
|
---|
3126 | If FirstEntry is identical to SecondEntry, then SecondEntry is returned.
|
---|
3127 | Otherwise, the location of the FirstEntry node is swapped with the location
|
---|
3128 | of the SecondEntry node in a doubly linked list. SecondEntry must be in the
|
---|
3129 | same double linked list as FirstEntry and that double linked list must have
|
---|
3130 | been initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().
|
---|
3131 | SecondEntry is returned after the nodes are swapped.
|
---|
3132 |
|
---|
3133 | If FirstEntry is NULL, then ASSERT().
|
---|
3134 | If SecondEntry is NULL, then ASSERT().
|
---|
3135 | If PcdVerifyNodeInList is TRUE and SecondEntry and FirstEntry are not in the
|
---|
3136 | same linked list, then ASSERT().
|
---|
3137 | If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
|
---|
3138 | linked list containing the FirstEntry and SecondEntry nodes, including
|
---|
3139 | the FirstEntry and SecondEntry nodes, is greater than or equal to
|
---|
3140 | PcdMaximumLinkedListLength, then ASSERT().
|
---|
3141 |
|
---|
3142 | @param FirstEntry A pointer to a node in a linked list.
|
---|
3143 | @param SecondEntry A pointer to another node in the same linked list.
|
---|
3144 |
|
---|
3145 | @return SecondEntry.
|
---|
3146 |
|
---|
3147 | **/
|
---|
3148 | LIST_ENTRY *
|
---|
3149 | EFIAPI
|
---|
3150 | SwapListEntries (
|
---|
3151 | IN OUT LIST_ENTRY *FirstEntry,
|
---|
3152 | IN OUT LIST_ENTRY *SecondEntry
|
---|
3153 | );
|
---|
3154 |
|
---|
3155 | /**
|
---|
3156 | Removes a node from a doubly linked list, and returns the node that follows
|
---|
3157 | the removed node.
|
---|
3158 |
|
---|
3159 | Removes the node Entry from a doubly linked list. It is up to the caller of
|
---|
3160 | this function to release the memory used by this node if that is required. On
|
---|
3161 | exit, the node following Entry in the doubly linked list is returned. If
|
---|
3162 | Entry is the only node in the linked list, then the head node of the linked
|
---|
3163 | list is returned.
|
---|
3164 |
|
---|
3165 | If Entry is NULL, then ASSERT().
|
---|
3166 | If Entry is the head node of an empty list, then ASSERT().
|
---|
3167 | If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
|
---|
3168 | linked list containing Entry, including the Entry node, is greater than
|
---|
3169 | or equal to PcdMaximumLinkedListLength, then ASSERT().
|
---|
3170 |
|
---|
3171 | @param Entry A pointer to a node in a linked list.
|
---|
3172 |
|
---|
3173 | @return Entry.
|
---|
3174 |
|
---|
3175 | **/
|
---|
3176 | LIST_ENTRY *
|
---|
3177 | EFIAPI
|
---|
3178 | RemoveEntryList (
|
---|
3179 | IN CONST LIST_ENTRY *Entry
|
---|
3180 | );
|
---|
3181 |
|
---|
3182 | //
|
---|
3183 | // Math Services
|
---|
3184 | //
|
---|
3185 |
|
---|
3186 | /**
|
---|
3187 | Prototype for comparison function for any two element types.
|
---|
3188 |
|
---|
3189 | @param[in] Buffer1 The pointer to first buffer.
|
---|
3190 | @param[in] Buffer2 The pointer to second buffer.
|
---|
3191 |
|
---|
3192 | @retval 0 Buffer1 equal to Buffer2.
|
---|
3193 | @return <0 Buffer1 is less than Buffer2.
|
---|
3194 | @return >0 Buffer1 is greater than Buffer2.
|
---|
3195 | **/
|
---|
3196 | typedef
|
---|
3197 | INTN
|
---|
3198 | (EFIAPI *BASE_SORT_COMPARE)(
|
---|
3199 | IN CONST VOID *Buffer1,
|
---|
3200 | IN CONST VOID *Buffer2
|
---|
3201 | );
|
---|
3202 |
|
---|
3203 | /**
|
---|
3204 | This function is identical to perform QuickSort,
|
---|
3205 | except that is uses the pre-allocated buffer so the in place sorting does not need to
|
---|
3206 | allocate and free buffers constantly.
|
---|
3207 |
|
---|
3208 | Each element must be equal sized.
|
---|
3209 |
|
---|
3210 | if BufferToSort is NULL, then ASSERT.
|
---|
3211 | if CompareFunction is NULL, then ASSERT.
|
---|
3212 | if BufferOneElement is NULL, then ASSERT.
|
---|
3213 | if ElementSize is < 1, then ASSERT.
|
---|
3214 |
|
---|
3215 | if Count is < 2 then perform no action.
|
---|
3216 |
|
---|
3217 | @param[in, out] BufferToSort on call a Buffer of (possibly sorted) elements
|
---|
3218 | on return a buffer of sorted elements
|
---|
3219 | @param[in] Count the number of elements in the buffer to sort
|
---|
3220 | @param[in] ElementSize Size of an element in bytes
|
---|
3221 | @param[in] CompareFunction The function to call to perform the comparison
|
---|
3222 | of any 2 elements
|
---|
3223 | @param[out] BufferOneElement Caller provided buffer whose size equals to ElementSize.
|
---|
3224 | It's used by QuickSort() for swapping in sorting.
|
---|
3225 | **/
|
---|
3226 | VOID
|
---|
3227 | EFIAPI
|
---|
3228 | QuickSort (
|
---|
3229 | IN OUT VOID *BufferToSort,
|
---|
3230 | IN CONST UINTN Count,
|
---|
3231 | IN CONST UINTN ElementSize,
|
---|
3232 | IN BASE_SORT_COMPARE CompareFunction,
|
---|
3233 | OUT VOID *BufferOneElement
|
---|
3234 | );
|
---|
3235 |
|
---|
3236 | /**
|
---|
3237 | Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled
|
---|
3238 | with zeros. The shifted value is returned.
|
---|
3239 |
|
---|
3240 | This function shifts the 64-bit value Operand to the left by Count bits. The
|
---|
3241 | low Count bits are set to zero. The shifted value is returned.
|
---|
3242 |
|
---|
3243 | If Count is greater than 63, then ASSERT().
|
---|
3244 |
|
---|
3245 | @param Operand The 64-bit operand to shift left.
|
---|
3246 | @param Count The number of bits to shift left.
|
---|
3247 |
|
---|
3248 | @return Operand << Count.
|
---|
3249 |
|
---|
3250 | **/
|
---|
3251 | UINT64
|
---|
3252 | EFIAPI
|
---|
3253 | LShiftU64 (
|
---|
3254 | IN UINT64 Operand,
|
---|
3255 | IN UINTN Count
|
---|
3256 | );
|
---|
3257 |
|
---|
3258 | /**
|
---|
3259 | Shifts a 64-bit integer right between 0 and 63 bits. This high bits are
|
---|
3260 | filled with zeros. The shifted value is returned.
|
---|
3261 |
|
---|
3262 | This function shifts the 64-bit value Operand to the right by Count bits. The
|
---|
3263 | high Count bits are set to zero. The shifted value is returned.
|
---|
3264 |
|
---|
3265 | If Count is greater than 63, then ASSERT().
|
---|
3266 |
|
---|
3267 | @param Operand The 64-bit operand to shift right.
|
---|
3268 | @param Count The number of bits to shift right.
|
---|
3269 |
|
---|
3270 | @return Operand >> Count
|
---|
3271 |
|
---|
3272 | **/
|
---|
3273 | UINT64
|
---|
3274 | EFIAPI
|
---|
3275 | RShiftU64 (
|
---|
3276 | IN UINT64 Operand,
|
---|
3277 | IN UINTN Count
|
---|
3278 | );
|
---|
3279 |
|
---|
3280 | /**
|
---|
3281 | Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled
|
---|
3282 | with original integer's bit 63. The shifted value is returned.
|
---|
3283 |
|
---|
3284 | This function shifts the 64-bit value Operand to the right by Count bits. The
|
---|
3285 | high Count bits are set to bit 63 of Operand. The shifted value is returned.
|
---|
3286 |
|
---|
3287 | If Count is greater than 63, then ASSERT().
|
---|
3288 |
|
---|
3289 | @param Operand The 64-bit operand to shift right.
|
---|
3290 | @param Count The number of bits to shift right.
|
---|
3291 |
|
---|
3292 | @return Operand >> Count
|
---|
3293 |
|
---|
3294 | **/
|
---|
3295 | UINT64
|
---|
3296 | EFIAPI
|
---|
3297 | ARShiftU64 (
|
---|
3298 | IN UINT64 Operand,
|
---|
3299 | IN UINTN Count
|
---|
3300 | );
|
---|
3301 |
|
---|
3302 | /**
|
---|
3303 | Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits
|
---|
3304 | with the high bits that were rotated.
|
---|
3305 |
|
---|
3306 | This function rotates the 32-bit value Operand to the left by Count bits. The
|
---|
3307 | low Count bits are fill with the high Count bits of Operand. The rotated
|
---|
3308 | value is returned.
|
---|
3309 |
|
---|
3310 | If Count is greater than 31, then ASSERT().
|
---|
3311 |
|
---|
3312 | @param Operand The 32-bit operand to rotate left.
|
---|
3313 | @param Count The number of bits to rotate left.
|
---|
3314 |
|
---|
3315 | @return Operand << Count
|
---|
3316 |
|
---|
3317 | **/
|
---|
3318 | UINT32
|
---|
3319 | EFIAPI
|
---|
3320 | LRotU32 (
|
---|
3321 | IN UINT32 Operand,
|
---|
3322 | IN UINTN Count
|
---|
3323 | );
|
---|
3324 |
|
---|
3325 | /**
|
---|
3326 | Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits
|
---|
3327 | with the low bits that were rotated.
|
---|
3328 |
|
---|
3329 | This function rotates the 32-bit value Operand to the right by Count bits.
|
---|
3330 | The high Count bits are fill with the low Count bits of Operand. The rotated
|
---|
3331 | value is returned.
|
---|
3332 |
|
---|
3333 | If Count is greater than 31, then ASSERT().
|
---|
3334 |
|
---|
3335 | @param Operand The 32-bit operand to rotate right.
|
---|
3336 | @param Count The number of bits to rotate right.
|
---|
3337 |
|
---|
3338 | @return Operand >> Count
|
---|
3339 |
|
---|
3340 | **/
|
---|
3341 | UINT32
|
---|
3342 | EFIAPI
|
---|
3343 | RRotU32 (
|
---|
3344 | IN UINT32 Operand,
|
---|
3345 | IN UINTN Count
|
---|
3346 | );
|
---|
3347 |
|
---|
3348 | /**
|
---|
3349 | Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits
|
---|
3350 | with the high bits that were rotated.
|
---|
3351 |
|
---|
3352 | This function rotates the 64-bit value Operand to the left by Count bits. The
|
---|
3353 | low Count bits are fill with the high Count bits of Operand. The rotated
|
---|
3354 | value is returned.
|
---|
3355 |
|
---|
3356 | If Count is greater than 63, then ASSERT().
|
---|
3357 |
|
---|
3358 | @param Operand The 64-bit operand to rotate left.
|
---|
3359 | @param Count The number of bits to rotate left.
|
---|
3360 |
|
---|
3361 | @return Operand << Count
|
---|
3362 |
|
---|
3363 | **/
|
---|
3364 | UINT64
|
---|
3365 | EFIAPI
|
---|
3366 | LRotU64 (
|
---|
3367 | IN UINT64 Operand,
|
---|
3368 | IN UINTN Count
|
---|
3369 | );
|
---|
3370 |
|
---|
3371 | /**
|
---|
3372 | Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits
|
---|
3373 | with the high low bits that were rotated.
|
---|
3374 |
|
---|
3375 | This function rotates the 64-bit value Operand to the right by Count bits.
|
---|
3376 | The high Count bits are fill with the low Count bits of Operand. The rotated
|
---|
3377 | value is returned.
|
---|
3378 |
|
---|
3379 | If Count is greater than 63, then ASSERT().
|
---|
3380 |
|
---|
3381 | @param Operand The 64-bit operand to rotate right.
|
---|
3382 | @param Count The number of bits to rotate right.
|
---|
3383 |
|
---|
3384 | @return Operand >> Count
|
---|
3385 |
|
---|
3386 | **/
|
---|
3387 | UINT64
|
---|
3388 | EFIAPI
|
---|
3389 | RRotU64 (
|
---|
3390 | IN UINT64 Operand,
|
---|
3391 | IN UINTN Count
|
---|
3392 | );
|
---|
3393 |
|
---|
3394 | /**
|
---|
3395 | Returns the bit position of the lowest bit set in a 32-bit value.
|
---|
3396 |
|
---|
3397 | This function computes the bit position of the lowest bit set in the 32-bit
|
---|
3398 | value specified by Operand. If Operand is zero, then -1 is returned.
|
---|
3399 | Otherwise, a value between 0 and 31 is returned.
|
---|
3400 |
|
---|
3401 | @param Operand The 32-bit operand to evaluate.
|
---|
3402 |
|
---|
3403 | @retval 0..31 The lowest bit set in Operand was found.
|
---|
3404 | @retval -1 Operand is zero.
|
---|
3405 |
|
---|
3406 | **/
|
---|
3407 | INTN
|
---|
3408 | EFIAPI
|
---|
3409 | LowBitSet32 (
|
---|
3410 | IN UINT32 Operand
|
---|
3411 | );
|
---|
3412 |
|
---|
3413 | /**
|
---|
3414 | Returns the bit position of the lowest bit set in a 64-bit value.
|
---|
3415 |
|
---|
3416 | This function computes the bit position of the lowest bit set in the 64-bit
|
---|
3417 | value specified by Operand. If Operand is zero, then -1 is returned.
|
---|
3418 | Otherwise, a value between 0 and 63 is returned.
|
---|
3419 |
|
---|
3420 | @param Operand The 64-bit operand to evaluate.
|
---|
3421 |
|
---|
3422 | @retval 0..63 The lowest bit set in Operand was found.
|
---|
3423 | @retval -1 Operand is zero.
|
---|
3424 |
|
---|
3425 |
|
---|
3426 | **/
|
---|
3427 | INTN
|
---|
3428 | EFIAPI
|
---|
3429 | LowBitSet64 (
|
---|
3430 | IN UINT64 Operand
|
---|
3431 | );
|
---|
3432 |
|
---|
3433 | /**
|
---|
3434 | Returns the bit position of the highest bit set in a 32-bit value. Equivalent
|
---|
3435 | to log2(x).
|
---|
3436 |
|
---|
3437 | This function computes the bit position of the highest bit set in the 32-bit
|
---|
3438 | value specified by Operand. If Operand is zero, then -1 is returned.
|
---|
3439 | Otherwise, a value between 0 and 31 is returned.
|
---|
3440 |
|
---|
3441 | @param Operand The 32-bit operand to evaluate.
|
---|
3442 |
|
---|
3443 | @retval 0..31 Position of the highest bit set in Operand if found.
|
---|
3444 | @retval -1 Operand is zero.
|
---|
3445 |
|
---|
3446 | **/
|
---|
3447 | INTN
|
---|
3448 | EFIAPI
|
---|
3449 | HighBitSet32 (
|
---|
3450 | IN UINT32 Operand
|
---|
3451 | );
|
---|
3452 |
|
---|
3453 | /**
|
---|
3454 | Returns the bit position of the highest bit set in a 64-bit value. Equivalent
|
---|
3455 | to log2(x).
|
---|
3456 |
|
---|
3457 | This function computes the bit position of the highest bit set in the 64-bit
|
---|
3458 | value specified by Operand. If Operand is zero, then -1 is returned.
|
---|
3459 | Otherwise, a value between 0 and 63 is returned.
|
---|
3460 |
|
---|
3461 | @param Operand The 64-bit operand to evaluate.
|
---|
3462 |
|
---|
3463 | @retval 0..63 Position of the highest bit set in Operand if found.
|
---|
3464 | @retval -1 Operand is zero.
|
---|
3465 |
|
---|
3466 | **/
|
---|
3467 | INTN
|
---|
3468 | EFIAPI
|
---|
3469 | HighBitSet64 (
|
---|
3470 | IN UINT64 Operand
|
---|
3471 | );
|
---|
3472 |
|
---|
3473 | /**
|
---|
3474 | Returns the value of the highest bit set in a 32-bit value. Equivalent to
|
---|
3475 | 1 << log2(x).
|
---|
3476 |
|
---|
3477 | This function computes the value of the highest bit set in the 32-bit value
|
---|
3478 | specified by Operand. If Operand is zero, then zero is returned.
|
---|
3479 |
|
---|
3480 | @param Operand The 32-bit operand to evaluate.
|
---|
3481 |
|
---|
3482 | @return 1 << HighBitSet32(Operand)
|
---|
3483 | @retval 0 Operand is zero.
|
---|
3484 |
|
---|
3485 | **/
|
---|
3486 | UINT32
|
---|
3487 | EFIAPI
|
---|
3488 | GetPowerOfTwo32 (
|
---|
3489 | IN UINT32 Operand
|
---|
3490 | );
|
---|
3491 |
|
---|
3492 | /**
|
---|
3493 | Returns the value of the highest bit set in a 64-bit value. Equivalent to
|
---|
3494 | 1 << log2(x).
|
---|
3495 |
|
---|
3496 | This function computes the value of the highest bit set in the 64-bit value
|
---|
3497 | specified by Operand. If Operand is zero, then zero is returned.
|
---|
3498 |
|
---|
3499 | @param Operand The 64-bit operand to evaluate.
|
---|
3500 |
|
---|
3501 | @return 1 << HighBitSet64(Operand)
|
---|
3502 | @retval 0 Operand is zero.
|
---|
3503 |
|
---|
3504 | **/
|
---|
3505 | UINT64
|
---|
3506 | EFIAPI
|
---|
3507 | GetPowerOfTwo64 (
|
---|
3508 | IN UINT64 Operand
|
---|
3509 | );
|
---|
3510 |
|
---|
3511 | /**
|
---|
3512 | Switches the endianness of a 16-bit integer.
|
---|
3513 |
|
---|
3514 | This function swaps the bytes in a 16-bit unsigned value to switch the value
|
---|
3515 | from little endian to big endian or vice versa. The byte swapped value is
|
---|
3516 | returned.
|
---|
3517 |
|
---|
3518 | @param Value A 16-bit unsigned value.
|
---|
3519 |
|
---|
3520 | @return The byte swapped Value.
|
---|
3521 |
|
---|
3522 | **/
|
---|
3523 | UINT16
|
---|
3524 | EFIAPI
|
---|
3525 | SwapBytes16 (
|
---|
3526 | IN UINT16 Value
|
---|
3527 | );
|
---|
3528 |
|
---|
3529 | /**
|
---|
3530 | Switches the endianness of a 32-bit integer.
|
---|
3531 |
|
---|
3532 | This function swaps the bytes in a 32-bit unsigned value to switch the value
|
---|
3533 | from little endian to big endian or vice versa. The byte swapped value is
|
---|
3534 | returned.
|
---|
3535 |
|
---|
3536 | @param Value A 32-bit unsigned value.
|
---|
3537 |
|
---|
3538 | @return The byte swapped Value.
|
---|
3539 |
|
---|
3540 | **/
|
---|
3541 | UINT32
|
---|
3542 | EFIAPI
|
---|
3543 | SwapBytes32 (
|
---|
3544 | IN UINT32 Value
|
---|
3545 | );
|
---|
3546 |
|
---|
3547 | /**
|
---|
3548 | Switches the endianness of a 64-bit integer.
|
---|
3549 |
|
---|
3550 | This function swaps the bytes in a 64-bit unsigned value to switch the value
|
---|
3551 | from little endian to big endian or vice versa. The byte swapped value is
|
---|
3552 | returned.
|
---|
3553 |
|
---|
3554 | @param Value A 64-bit unsigned value.
|
---|
3555 |
|
---|
3556 | @return The byte swapped Value.
|
---|
3557 |
|
---|
3558 | **/
|
---|
3559 | UINT64
|
---|
3560 | EFIAPI
|
---|
3561 | SwapBytes64 (
|
---|
3562 | IN UINT64 Value
|
---|
3563 | );
|
---|
3564 |
|
---|
3565 | /**
|
---|
3566 | Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and
|
---|
3567 | generates a 64-bit unsigned result.
|
---|
3568 |
|
---|
3569 | This function multiples the 64-bit unsigned value Multiplicand by the 32-bit
|
---|
3570 | unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
|
---|
3571 | bit unsigned result is returned.
|
---|
3572 |
|
---|
3573 | @param Multiplicand A 64-bit unsigned value.
|
---|
3574 | @param Multiplier A 32-bit unsigned value.
|
---|
3575 |
|
---|
3576 | @return Multiplicand * Multiplier
|
---|
3577 |
|
---|
3578 | **/
|
---|
3579 | UINT64
|
---|
3580 | EFIAPI
|
---|
3581 | MultU64x32 (
|
---|
3582 | IN UINT64 Multiplicand,
|
---|
3583 | IN UINT32 Multiplier
|
---|
3584 | );
|
---|
3585 |
|
---|
3586 | /**
|
---|
3587 | Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and
|
---|
3588 | generates a 64-bit unsigned result.
|
---|
3589 |
|
---|
3590 | This function multiples the 64-bit unsigned value Multiplicand by the 64-bit
|
---|
3591 | unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
|
---|
3592 | bit unsigned result is returned.
|
---|
3593 |
|
---|
3594 | @param Multiplicand A 64-bit unsigned value.
|
---|
3595 | @param Multiplier A 64-bit unsigned value.
|
---|
3596 |
|
---|
3597 | @return Multiplicand * Multiplier.
|
---|
3598 |
|
---|
3599 | **/
|
---|
3600 | UINT64
|
---|
3601 | EFIAPI
|
---|
3602 | MultU64x64 (
|
---|
3603 | IN UINT64 Multiplicand,
|
---|
3604 | IN UINT64 Multiplier
|
---|
3605 | );
|
---|
3606 |
|
---|
3607 | /**
|
---|
3608 | Multiples a 64-bit signed integer by a 64-bit signed integer and generates a
|
---|
3609 | 64-bit signed result.
|
---|
3610 |
|
---|
3611 | This function multiples the 64-bit signed value Multiplicand by the 64-bit
|
---|
3612 | signed value Multiplier and generates a 64-bit signed result. This 64-bit
|
---|
3613 | signed result is returned.
|
---|
3614 |
|
---|
3615 | @param Multiplicand A 64-bit signed value.
|
---|
3616 | @param Multiplier A 64-bit signed value.
|
---|
3617 |
|
---|
3618 | @return Multiplicand * Multiplier
|
---|
3619 |
|
---|
3620 | **/
|
---|
3621 | INT64
|
---|
3622 | EFIAPI
|
---|
3623 | MultS64x64 (
|
---|
3624 | IN INT64 Multiplicand,
|
---|
3625 | IN INT64 Multiplier
|
---|
3626 | );
|
---|
3627 |
|
---|
3628 | /**
|
---|
3629 | Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
|
---|
3630 | a 64-bit unsigned result.
|
---|
3631 |
|
---|
3632 | This function divides the 64-bit unsigned value Dividend by the 32-bit
|
---|
3633 | unsigned value Divisor and generates a 64-bit unsigned quotient. This
|
---|
3634 | function returns the 64-bit unsigned quotient.
|
---|
3635 |
|
---|
3636 | If Divisor is 0, then ASSERT().
|
---|
3637 |
|
---|
3638 | @param Dividend A 64-bit unsigned value.
|
---|
3639 | @param Divisor A 32-bit unsigned value.
|
---|
3640 |
|
---|
3641 | @return Dividend / Divisor.
|
---|
3642 |
|
---|
3643 | **/
|
---|
3644 | UINT64
|
---|
3645 | EFIAPI
|
---|
3646 | DivU64x32 (
|
---|
3647 | IN UINT64 Dividend,
|
---|
3648 | IN UINT32 Divisor
|
---|
3649 | );
|
---|
3650 |
|
---|
3651 | /**
|
---|
3652 | Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
|
---|
3653 | a 32-bit unsigned remainder.
|
---|
3654 |
|
---|
3655 | This function divides the 64-bit unsigned value Dividend by the 32-bit
|
---|
3656 | unsigned value Divisor and generates a 32-bit remainder. This function
|
---|
3657 | returns the 32-bit unsigned remainder.
|
---|
3658 |
|
---|
3659 | If Divisor is 0, then ASSERT().
|
---|
3660 |
|
---|
3661 | @param Dividend A 64-bit unsigned value.
|
---|
3662 | @param Divisor A 32-bit unsigned value.
|
---|
3663 |
|
---|
3664 | @return Dividend % Divisor.
|
---|
3665 |
|
---|
3666 | **/
|
---|
3667 | UINT32
|
---|
3668 | EFIAPI
|
---|
3669 | ModU64x32 (
|
---|
3670 | IN UINT64 Dividend,
|
---|
3671 | IN UINT32 Divisor
|
---|
3672 | );
|
---|
3673 |
|
---|
3674 | /**
|
---|
3675 | Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
|
---|
3676 | a 64-bit unsigned result and an optional 32-bit unsigned remainder.
|
---|
3677 |
|
---|
3678 | This function divides the 64-bit unsigned value Dividend by the 32-bit
|
---|
3679 | unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
|
---|
3680 | is not NULL, then the 32-bit unsigned remainder is returned in Remainder.
|
---|
3681 | This function returns the 64-bit unsigned quotient.
|
---|
3682 |
|
---|
3683 | If Divisor is 0, then ASSERT().
|
---|
3684 |
|
---|
3685 | @param Dividend A 64-bit unsigned value.
|
---|
3686 | @param Divisor A 32-bit unsigned value.
|
---|
3687 | @param Remainder A pointer to a 32-bit unsigned value. This parameter is
|
---|
3688 | optional and may be NULL.
|
---|
3689 |
|
---|
3690 | @return Dividend / Divisor.
|
---|
3691 |
|
---|
3692 | **/
|
---|
3693 | UINT64
|
---|
3694 | EFIAPI
|
---|
3695 | DivU64x32Remainder (
|
---|
3696 | IN UINT64 Dividend,
|
---|
3697 | IN UINT32 Divisor,
|
---|
3698 | OUT UINT32 *Remainder OPTIONAL
|
---|
3699 | );
|
---|
3700 |
|
---|
3701 | /**
|
---|
3702 | Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates
|
---|
3703 | a 64-bit unsigned result and an optional 64-bit unsigned remainder.
|
---|
3704 |
|
---|
3705 | This function divides the 64-bit unsigned value Dividend by the 64-bit
|
---|
3706 | unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
|
---|
3707 | is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
|
---|
3708 | This function returns the 64-bit unsigned quotient.
|
---|
3709 |
|
---|
3710 | If Divisor is 0, then ASSERT().
|
---|
3711 |
|
---|
3712 | @param Dividend A 64-bit unsigned value.
|
---|
3713 | @param Divisor A 64-bit unsigned value.
|
---|
3714 | @param Remainder A pointer to a 64-bit unsigned value. This parameter is
|
---|
3715 | optional and may be NULL.
|
---|
3716 |
|
---|
3717 | @return Dividend / Divisor.
|
---|
3718 |
|
---|
3719 | **/
|
---|
3720 | UINT64
|
---|
3721 | EFIAPI
|
---|
3722 | DivU64x64Remainder (
|
---|
3723 | IN UINT64 Dividend,
|
---|
3724 | IN UINT64 Divisor,
|
---|
3725 | OUT UINT64 *Remainder OPTIONAL
|
---|
3726 | );
|
---|
3727 |
|
---|
3728 | /**
|
---|
3729 | Divides a 64-bit signed integer by a 64-bit signed integer and generates a
|
---|
3730 | 64-bit signed result and a optional 64-bit signed remainder.
|
---|
3731 |
|
---|
3732 | This function divides the 64-bit signed value Dividend by the 64-bit signed
|
---|
3733 | value Divisor and generates a 64-bit signed quotient. If Remainder is not
|
---|
3734 | NULL, then the 64-bit signed remainder is returned in Remainder. This
|
---|
3735 | function returns the 64-bit signed quotient.
|
---|
3736 |
|
---|
3737 | It is the caller's responsibility to not call this function with a Divisor of 0.
|
---|
3738 | If Divisor is 0, then the quotient and remainder should be assumed to be
|
---|
3739 | the largest negative integer.
|
---|
3740 |
|
---|
3741 | If Divisor is 0, then ASSERT().
|
---|
3742 |
|
---|
3743 | @param Dividend A 64-bit signed value.
|
---|
3744 | @param Divisor A 64-bit signed value.
|
---|
3745 | @param Remainder A pointer to a 64-bit signed value. This parameter is
|
---|
3746 | optional and may be NULL.
|
---|
3747 |
|
---|
3748 | @return Dividend / Divisor.
|
---|
3749 |
|
---|
3750 | **/
|
---|
3751 | INT64
|
---|
3752 | EFIAPI
|
---|
3753 | DivS64x64Remainder (
|
---|
3754 | IN INT64 Dividend,
|
---|
3755 | IN INT64 Divisor,
|
---|
3756 | OUT INT64 *Remainder OPTIONAL
|
---|
3757 | );
|
---|
3758 |
|
---|
3759 | /**
|
---|
3760 | Reads a 16-bit value from memory that may be unaligned.
|
---|
3761 |
|
---|
3762 | This function returns the 16-bit value pointed to by Buffer. The function
|
---|
3763 | guarantees that the read operation does not produce an alignment fault.
|
---|
3764 |
|
---|
3765 | If the Buffer is NULL, then ASSERT().
|
---|
3766 |
|
---|
3767 | @param Buffer The pointer to a 16-bit value that may be unaligned.
|
---|
3768 |
|
---|
3769 | @return The 16-bit value read from Buffer.
|
---|
3770 |
|
---|
3771 | **/
|
---|
3772 | UINT16
|
---|
3773 | EFIAPI
|
---|
3774 | ReadUnaligned16 (
|
---|
3775 | IN CONST UINT16 *Buffer
|
---|
3776 | );
|
---|
3777 |
|
---|
3778 | /**
|
---|
3779 | Writes a 16-bit value to memory that may be unaligned.
|
---|
3780 |
|
---|
3781 | This function writes the 16-bit value specified by Value to Buffer. Value is
|
---|
3782 | returned. The function guarantees that the write operation does not produce
|
---|
3783 | an alignment fault.
|
---|
3784 |
|
---|
3785 | If the Buffer is NULL, then ASSERT().
|
---|
3786 |
|
---|
3787 | @param Buffer The pointer to a 16-bit value that may be unaligned.
|
---|
3788 | @param Value 16-bit value to write to Buffer.
|
---|
3789 |
|
---|
3790 | @return The 16-bit value to write to Buffer.
|
---|
3791 |
|
---|
3792 | **/
|
---|
3793 | UINT16
|
---|
3794 | EFIAPI
|
---|
3795 | WriteUnaligned16 (
|
---|
3796 | OUT UINT16 *Buffer,
|
---|
3797 | IN UINT16 Value
|
---|
3798 | );
|
---|
3799 |
|
---|
3800 | /**
|
---|
3801 | Reads a 24-bit value from memory that may be unaligned.
|
---|
3802 |
|
---|
3803 | This function returns the 24-bit value pointed to by Buffer. The function
|
---|
3804 | guarantees that the read operation does not produce an alignment fault.
|
---|
3805 |
|
---|
3806 | If the Buffer is NULL, then ASSERT().
|
---|
3807 |
|
---|
3808 | @param Buffer The pointer to a 24-bit value that may be unaligned.
|
---|
3809 |
|
---|
3810 | @return The 24-bit value read from Buffer.
|
---|
3811 |
|
---|
3812 | **/
|
---|
3813 | UINT32
|
---|
3814 | EFIAPI
|
---|
3815 | ReadUnaligned24 (
|
---|
3816 | IN CONST UINT32 *Buffer
|
---|
3817 | );
|
---|
3818 |
|
---|
3819 | /**
|
---|
3820 | Writes a 24-bit value to memory that may be unaligned.
|
---|
3821 |
|
---|
3822 | This function writes the 24-bit value specified by Value to Buffer. Value is
|
---|
3823 | returned. The function guarantees that the write operation does not produce
|
---|
3824 | an alignment fault.
|
---|
3825 |
|
---|
3826 | If the Buffer is NULL, then ASSERT().
|
---|
3827 |
|
---|
3828 | @param Buffer The pointer to a 24-bit value that may be unaligned.
|
---|
3829 | @param Value 24-bit value to write to Buffer.
|
---|
3830 |
|
---|
3831 | @return The 24-bit value to write to Buffer.
|
---|
3832 |
|
---|
3833 | **/
|
---|
3834 | UINT32
|
---|
3835 | EFIAPI
|
---|
3836 | WriteUnaligned24 (
|
---|
3837 | OUT UINT32 *Buffer,
|
---|
3838 | IN UINT32 Value
|
---|
3839 | );
|
---|
3840 |
|
---|
3841 | /**
|
---|
3842 | Reads a 32-bit value from memory that may be unaligned.
|
---|
3843 |
|
---|
3844 | This function returns the 32-bit value pointed to by Buffer. The function
|
---|
3845 | guarantees that the read operation does not produce an alignment fault.
|
---|
3846 |
|
---|
3847 | If the Buffer is NULL, then ASSERT().
|
---|
3848 |
|
---|
3849 | @param Buffer The pointer to a 32-bit value that may be unaligned.
|
---|
3850 |
|
---|
3851 | @return The 32-bit value read from Buffer.
|
---|
3852 |
|
---|
3853 | **/
|
---|
3854 | UINT32
|
---|
3855 | EFIAPI
|
---|
3856 | ReadUnaligned32 (
|
---|
3857 | IN CONST UINT32 *Buffer
|
---|
3858 | );
|
---|
3859 |
|
---|
3860 | /**
|
---|
3861 | Writes a 32-bit value to memory that may be unaligned.
|
---|
3862 |
|
---|
3863 | This function writes the 32-bit value specified by Value to Buffer. Value is
|
---|
3864 | returned. The function guarantees that the write operation does not produce
|
---|
3865 | an alignment fault.
|
---|
3866 |
|
---|
3867 | If the Buffer is NULL, then ASSERT().
|
---|
3868 |
|
---|
3869 | @param Buffer The pointer to a 32-bit value that may be unaligned.
|
---|
3870 | @param Value 32-bit value to write to Buffer.
|
---|
3871 |
|
---|
3872 | @return The 32-bit value to write to Buffer.
|
---|
3873 |
|
---|
3874 | **/
|
---|
3875 | UINT32
|
---|
3876 | EFIAPI
|
---|
3877 | WriteUnaligned32 (
|
---|
3878 | OUT UINT32 *Buffer,
|
---|
3879 | IN UINT32 Value
|
---|
3880 | );
|
---|
3881 |
|
---|
3882 | /**
|
---|
3883 | Reads a 64-bit value from memory that may be unaligned.
|
---|
3884 |
|
---|
3885 | This function returns the 64-bit value pointed to by Buffer. The function
|
---|
3886 | guarantees that the read operation does not produce an alignment fault.
|
---|
3887 |
|
---|
3888 | If the Buffer is NULL, then ASSERT().
|
---|
3889 |
|
---|
3890 | @param Buffer The pointer to a 64-bit value that may be unaligned.
|
---|
3891 |
|
---|
3892 | @return The 64-bit value read from Buffer.
|
---|
3893 |
|
---|
3894 | **/
|
---|
3895 | UINT64
|
---|
3896 | EFIAPI
|
---|
3897 | ReadUnaligned64 (
|
---|
3898 | IN CONST UINT64 *Buffer
|
---|
3899 | );
|
---|
3900 |
|
---|
3901 | /**
|
---|
3902 | Writes a 64-bit value to memory that may be unaligned.
|
---|
3903 |
|
---|
3904 | This function writes the 64-bit value specified by Value to Buffer. Value is
|
---|
3905 | returned. The function guarantees that the write operation does not produce
|
---|
3906 | an alignment fault.
|
---|
3907 |
|
---|
3908 | If the Buffer is NULL, then ASSERT().
|
---|
3909 |
|
---|
3910 | @param Buffer The pointer to a 64-bit value that may be unaligned.
|
---|
3911 | @param Value 64-bit value to write to Buffer.
|
---|
3912 |
|
---|
3913 | @return The 64-bit value to write to Buffer.
|
---|
3914 |
|
---|
3915 | **/
|
---|
3916 | UINT64
|
---|
3917 | EFIAPI
|
---|
3918 | WriteUnaligned64 (
|
---|
3919 | OUT UINT64 *Buffer,
|
---|
3920 | IN UINT64 Value
|
---|
3921 | );
|
---|
3922 |
|
---|
3923 | //
|
---|
3924 | // Bit Field Functions
|
---|
3925 | //
|
---|
3926 |
|
---|
3927 | /**
|
---|
3928 | Returns a bit field from an 8-bit value.
|
---|
3929 |
|
---|
3930 | Returns the bitfield specified by the StartBit and the EndBit from Operand.
|
---|
3931 |
|
---|
3932 | If 8-bit operations are not supported, then ASSERT().
|
---|
3933 | If StartBit is greater than 7, then ASSERT().
|
---|
3934 | If EndBit is greater than 7, then ASSERT().
|
---|
3935 | If EndBit is less than StartBit, then ASSERT().
|
---|
3936 |
|
---|
3937 | @param Operand Operand on which to perform the bitfield operation.
|
---|
3938 | @param StartBit The ordinal of the least significant bit in the bit field.
|
---|
3939 | Range 0..7.
|
---|
3940 | @param EndBit The ordinal of the most significant bit in the bit field.
|
---|
3941 | Range 0..7.
|
---|
3942 |
|
---|
3943 | @return The bit field read.
|
---|
3944 |
|
---|
3945 | **/
|
---|
3946 | UINT8
|
---|
3947 | EFIAPI
|
---|
3948 | BitFieldRead8 (
|
---|
3949 | IN UINT8 Operand,
|
---|
3950 | IN UINTN StartBit,
|
---|
3951 | IN UINTN EndBit
|
---|
3952 | );
|
---|
3953 |
|
---|
3954 | /**
|
---|
3955 | Writes a bit field to an 8-bit value, and returns the result.
|
---|
3956 |
|
---|
3957 | Writes Value to the bit field specified by the StartBit and the EndBit in
|
---|
3958 | Operand. All other bits in Operand are preserved. The new 8-bit value is
|
---|
3959 | returned.
|
---|
3960 |
|
---|
3961 | If 8-bit operations are not supported, then ASSERT().
|
---|
3962 | If StartBit is greater than 7, then ASSERT().
|
---|
3963 | If EndBit is greater than 7, then ASSERT().
|
---|
3964 | If EndBit is less than StartBit, then ASSERT().
|
---|
3965 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
|
---|
3966 |
|
---|
3967 | @param Operand Operand on which to perform the bitfield operation.
|
---|
3968 | @param StartBit The ordinal of the least significant bit in the bit field.
|
---|
3969 | Range 0..7.
|
---|
3970 | @param EndBit The ordinal of the most significant bit in the bit field.
|
---|
3971 | Range 0..7.
|
---|
3972 | @param Value New value of the bit field.
|
---|
3973 |
|
---|
3974 | @return The new 8-bit value.
|
---|
3975 |
|
---|
3976 | **/
|
---|
3977 | UINT8
|
---|
3978 | EFIAPI
|
---|
3979 | BitFieldWrite8 (
|
---|
3980 | IN UINT8 Operand,
|
---|
3981 | IN UINTN StartBit,
|
---|
3982 | IN UINTN EndBit,
|
---|
3983 | IN UINT8 Value
|
---|
3984 | );
|
---|
3985 |
|
---|
3986 | /**
|
---|
3987 | Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the
|
---|
3988 | result.
|
---|
3989 |
|
---|
3990 | Performs a bitwise OR between the bit field specified by StartBit
|
---|
3991 | and EndBit in Operand and the value specified by OrData. All other bits in
|
---|
3992 | Operand are preserved. The new 8-bit value is returned.
|
---|
3993 |
|
---|
3994 | If 8-bit operations are not supported, then ASSERT().
|
---|
3995 | If StartBit is greater than 7, then ASSERT().
|
---|
3996 | If EndBit is greater than 7, then ASSERT().
|
---|
3997 | If EndBit is less than StartBit, then ASSERT().
|
---|
3998 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
|
---|
3999 |
|
---|
4000 | @param Operand Operand on which to perform the bitfield operation.
|
---|
4001 | @param StartBit The ordinal of the least significant bit in the bit field.
|
---|
4002 | Range 0..7.
|
---|
4003 | @param EndBit The ordinal of the most significant bit in the bit field.
|
---|
4004 | Range 0..7.
|
---|
4005 | @param OrData The value to OR with the read value from the value
|
---|
4006 |
|
---|
4007 | @return The new 8-bit value.
|
---|
4008 |
|
---|
4009 | **/
|
---|
4010 | UINT8
|
---|
4011 | EFIAPI
|
---|
4012 | BitFieldOr8 (
|
---|
4013 | IN UINT8 Operand,
|
---|
4014 | IN UINTN StartBit,
|
---|
4015 | IN UINTN EndBit,
|
---|
4016 | IN UINT8 OrData
|
---|
4017 | );
|
---|
4018 |
|
---|
4019 | /**
|
---|
4020 | Reads a bit field from an 8-bit value, performs a bitwise AND, and returns
|
---|
4021 | the result.
|
---|
4022 |
|
---|
4023 | Performs a bitwise AND between the bit field specified by StartBit and EndBit
|
---|
4024 | in Operand and the value specified by AndData. All other bits in Operand are
|
---|
4025 | preserved. The new 8-bit value is returned.
|
---|
4026 |
|
---|
4027 | If 8-bit operations are not supported, then ASSERT().
|
---|
4028 | If StartBit is greater than 7, then ASSERT().
|
---|
4029 | If EndBit is greater than 7, then ASSERT().
|
---|
4030 | If EndBit is less than StartBit, then ASSERT().
|
---|
4031 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
|
---|
4032 |
|
---|
4033 | @param Operand Operand on which to perform the bitfield operation.
|
---|
4034 | @param StartBit The ordinal of the least significant bit in the bit field.
|
---|
4035 | Range 0..7.
|
---|
4036 | @param EndBit The ordinal of the most significant bit in the bit field.
|
---|
4037 | Range 0..7.
|
---|
4038 | @param AndData The value to AND with the read value from the value.
|
---|
4039 |
|
---|
4040 | @return The new 8-bit value.
|
---|
4041 |
|
---|
4042 | **/
|
---|
4043 | UINT8
|
---|
4044 | EFIAPI
|
---|
4045 | BitFieldAnd8 (
|
---|
4046 | IN UINT8 Operand,
|
---|
4047 | IN UINTN StartBit,
|
---|
4048 | IN UINTN EndBit,
|
---|
4049 | IN UINT8 AndData
|
---|
4050 | );
|
---|
4051 |
|
---|
4052 | /**
|
---|
4053 | Reads a bit field from an 8-bit value, performs a bitwise AND followed by a
|
---|
4054 | bitwise OR, and returns the result.
|
---|
4055 |
|
---|
4056 | Performs a bitwise AND between the bit field specified by StartBit and EndBit
|
---|
4057 | in Operand and the value specified by AndData, followed by a bitwise
|
---|
4058 | OR with value specified by OrData. All other bits in Operand are
|
---|
4059 | preserved. The new 8-bit value is returned.
|
---|
4060 |
|
---|
4061 | If 8-bit operations are not supported, then ASSERT().
|
---|
4062 | If StartBit is greater than 7, then ASSERT().
|
---|
4063 | If EndBit is greater than 7, then ASSERT().
|
---|
4064 | If EndBit is less than StartBit, then ASSERT().
|
---|
4065 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
|
---|
4066 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
|
---|
4067 |
|
---|
4068 | @param Operand Operand on which to perform the bitfield operation.
|
---|
4069 | @param StartBit The ordinal of the least significant bit in the bit field.
|
---|
4070 | Range 0..7.
|
---|
4071 | @param EndBit The ordinal of the most significant bit in the bit field.
|
---|
4072 | Range 0..7.
|
---|
4073 | @param AndData The value to AND with the read value from the value.
|
---|
4074 | @param OrData The value to OR with the result of the AND operation.
|
---|
4075 |
|
---|
4076 | @return The new 8-bit value.
|
---|
4077 |
|
---|
4078 | **/
|
---|
4079 | UINT8
|
---|
4080 | EFIAPI
|
---|
4081 | BitFieldAndThenOr8 (
|
---|
4082 | IN UINT8 Operand,
|
---|
4083 | IN UINTN StartBit,
|
---|
4084 | IN UINTN EndBit,
|
---|
4085 | IN UINT8 AndData,
|
---|
4086 | IN UINT8 OrData
|
---|
4087 | );
|
---|
4088 |
|
---|
4089 | /**
|
---|
4090 | Returns a bit field from a 16-bit value.
|
---|
4091 |
|
---|
4092 | Returns the bitfield specified by the StartBit and the EndBit from Operand.
|
---|
4093 |
|
---|
4094 | If 16-bit operations are not supported, then ASSERT().
|
---|
4095 | If StartBit is greater than 15, then ASSERT().
|
---|
4096 | If EndBit is greater than 15, then ASSERT().
|
---|
4097 | If EndBit is less than StartBit, then ASSERT().
|
---|
4098 |
|
---|
4099 | @param Operand Operand on which to perform the bitfield operation.
|
---|
4100 | @param StartBit The ordinal of the least significant bit in the bit field.
|
---|
4101 | Range 0..15.
|
---|
4102 | @param EndBit The ordinal of the most significant bit in the bit field.
|
---|
4103 | Range 0..15.
|
---|
4104 |
|
---|
4105 | @return The bit field read.
|
---|
4106 |
|
---|
4107 | **/
|
---|
4108 | UINT16
|
---|
4109 | EFIAPI
|
---|
4110 | BitFieldRead16 (
|
---|
4111 | IN UINT16 Operand,
|
---|
4112 | IN UINTN StartBit,
|
---|
4113 | IN UINTN EndBit
|
---|
4114 | );
|
---|
4115 |
|
---|
4116 | /**
|
---|
4117 | Writes a bit field to a 16-bit value, and returns the result.
|
---|
4118 |
|
---|
4119 | Writes Value to the bit field specified by the StartBit and the EndBit in
|
---|
4120 | Operand. All other bits in Operand are preserved. The new 16-bit value is
|
---|
4121 | returned.
|
---|
4122 |
|
---|
4123 | If 16-bit operations are not supported, then ASSERT().
|
---|
4124 | If StartBit is greater than 15, then ASSERT().
|
---|
4125 | If EndBit is greater than 15, then ASSERT().
|
---|
4126 | If EndBit is less than StartBit, then ASSERT().
|
---|
4127 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
|
---|
4128 |
|
---|
4129 | @param Operand Operand on which to perform the bitfield operation.
|
---|
4130 | @param StartBit The ordinal of the least significant bit in the bit field.
|
---|
4131 | Range 0..15.
|
---|
4132 | @param EndBit The ordinal of the most significant bit in the bit field.
|
---|
4133 | Range 0..15.
|
---|
4134 | @param Value New value of the bit field.
|
---|
4135 |
|
---|
4136 | @return The new 16-bit value.
|
---|
4137 |
|
---|
4138 | **/
|
---|
4139 | UINT16
|
---|
4140 | EFIAPI
|
---|
4141 | BitFieldWrite16 (
|
---|
4142 | IN UINT16 Operand,
|
---|
4143 | IN UINTN StartBit,
|
---|
4144 | IN UINTN EndBit,
|
---|
4145 | IN UINT16 Value
|
---|
4146 | );
|
---|
4147 |
|
---|
4148 | /**
|
---|
4149 | Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the
|
---|
4150 | result.
|
---|
4151 |
|
---|
4152 | Performs a bitwise OR between the bit field specified by StartBit
|
---|
4153 | and EndBit in Operand and the value specified by OrData. All other bits in
|
---|
4154 | Operand are preserved. The new 16-bit value is returned.
|
---|
4155 |
|
---|
4156 | If 16-bit operations are not supported, then ASSERT().
|
---|
4157 | If StartBit is greater than 15, then ASSERT().
|
---|
4158 | If EndBit is greater than 15, then ASSERT().
|
---|
4159 | If EndBit is less than StartBit, then ASSERT().
|
---|
4160 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
|
---|
4161 |
|
---|
4162 | @param Operand Operand on which to perform the bitfield operation.
|
---|
4163 | @param StartBit The ordinal of the least significant bit in the bit field.
|
---|
4164 | Range 0..15.
|
---|
4165 | @param EndBit The ordinal of the most significant bit in the bit field.
|
---|
4166 | Range 0..15.
|
---|
4167 | @param OrData The value to OR with the read value from the value
|
---|
4168 |
|
---|
4169 | @return The new 16-bit value.
|
---|
4170 |
|
---|
4171 | **/
|
---|
4172 | UINT16
|
---|
4173 | EFIAPI
|
---|
4174 | BitFieldOr16 (
|
---|
4175 | IN UINT16 Operand,
|
---|
4176 | IN UINTN StartBit,
|
---|
4177 | IN UINTN EndBit,
|
---|
4178 | IN UINT16 OrData
|
---|
4179 | );
|
---|
4180 |
|
---|
4181 | /**
|
---|
4182 | Reads a bit field from a 16-bit value, performs a bitwise AND, and returns
|
---|
4183 | the result.
|
---|
4184 |
|
---|
4185 | Performs a bitwise AND between the bit field specified by StartBit and EndBit
|
---|
4186 | in Operand and the value specified by AndData. All other bits in Operand are
|
---|
4187 | preserved. The new 16-bit value is returned.
|
---|
4188 |
|
---|
4189 | If 16-bit operations are not supported, then ASSERT().
|
---|
4190 | If StartBit is greater than 15, then ASSERT().
|
---|
4191 | If EndBit is greater than 15, then ASSERT().
|
---|
4192 | If EndBit is less than StartBit, then ASSERT().
|
---|
4193 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
|
---|
4194 |
|
---|
4195 | @param Operand Operand on which to perform the bitfield operation.
|
---|
4196 | @param StartBit The ordinal of the least significant bit in the bit field.
|
---|
4197 | Range 0..15.
|
---|
4198 | @param EndBit The ordinal of the most significant bit in the bit field.
|
---|
4199 | Range 0..15.
|
---|
4200 | @param AndData The value to AND with the read value from the value
|
---|
4201 |
|
---|
4202 | @return The new 16-bit value.
|
---|
4203 |
|
---|
4204 | **/
|
---|
4205 | UINT16
|
---|
4206 | EFIAPI
|
---|
4207 | BitFieldAnd16 (
|
---|
4208 | IN UINT16 Operand,
|
---|
4209 | IN UINTN StartBit,
|
---|
4210 | IN UINTN EndBit,
|
---|
4211 | IN UINT16 AndData
|
---|
4212 | );
|
---|
4213 |
|
---|
4214 | /**
|
---|
4215 | Reads a bit field from a 16-bit value, performs a bitwise AND followed by a
|
---|
4216 | bitwise OR, and returns the result.
|
---|
4217 |
|
---|
4218 | Performs a bitwise AND between the bit field specified by StartBit and EndBit
|
---|
4219 | in Operand and the value specified by AndData, followed by a bitwise
|
---|
4220 | OR with value specified by OrData. All other bits in Operand are
|
---|
4221 | preserved. The new 16-bit value is returned.
|
---|
4222 |
|
---|
4223 | If 16-bit operations are not supported, then ASSERT().
|
---|
4224 | If StartBit is greater than 15, then ASSERT().
|
---|
4225 | If EndBit is greater than 15, then ASSERT().
|
---|
4226 | If EndBit is less than StartBit, then ASSERT().
|
---|
4227 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
|
---|
4228 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
|
---|
4229 |
|
---|
4230 | @param Operand Operand on which to perform the bitfield operation.
|
---|
4231 | @param StartBit The ordinal of the least significant bit in the bit field.
|
---|
4232 | Range 0..15.
|
---|
4233 | @param EndBit The ordinal of the most significant bit in the bit field.
|
---|
4234 | Range 0..15.
|
---|
4235 | @param AndData The value to AND with the read value from the value.
|
---|
4236 | @param OrData The value to OR with the result of the AND operation.
|
---|
4237 |
|
---|
4238 | @return The new 16-bit value.
|
---|
4239 |
|
---|
4240 | **/
|
---|
4241 | UINT16
|
---|
4242 | EFIAPI
|
---|
4243 | BitFieldAndThenOr16 (
|
---|
4244 | IN UINT16 Operand,
|
---|
4245 | IN UINTN StartBit,
|
---|
4246 | IN UINTN EndBit,
|
---|
4247 | IN UINT16 AndData,
|
---|
4248 | IN UINT16 OrData
|
---|
4249 | );
|
---|
4250 |
|
---|
4251 | /**
|
---|
4252 | Returns a bit field from a 32-bit value.
|
---|
4253 |
|
---|
4254 | Returns the bitfield specified by the StartBit and the EndBit from Operand.
|
---|
4255 |
|
---|
4256 | If 32-bit operations are not supported, then ASSERT().
|
---|
4257 | If StartBit is greater than 31, then ASSERT().
|
---|
4258 | If EndBit is greater than 31, then ASSERT().
|
---|
4259 | If EndBit is less than StartBit, then ASSERT().
|
---|
4260 |
|
---|
4261 | @param Operand Operand on which to perform the bitfield operation.
|
---|
4262 | @param StartBit The ordinal of the least significant bit in the bit field.
|
---|
4263 | Range 0..31.
|
---|
4264 | @param EndBit The ordinal of the most significant bit in the bit field.
|
---|
4265 | Range 0..31.
|
---|
4266 |
|
---|
4267 | @return The bit field read.
|
---|
4268 |
|
---|
4269 | **/
|
---|
4270 | UINT32
|
---|
4271 | EFIAPI
|
---|
4272 | BitFieldRead32 (
|
---|
4273 | IN UINT32 Operand,
|
---|
4274 | IN UINTN StartBit,
|
---|
4275 | IN UINTN EndBit
|
---|
4276 | );
|
---|
4277 |
|
---|
4278 | /**
|
---|
4279 | Writes a bit field to a 32-bit value, and returns the result.
|
---|
4280 |
|
---|
4281 | Writes Value to the bit field specified by the StartBit and the EndBit in
|
---|
4282 | Operand. All other bits in Operand are preserved. The new 32-bit value is
|
---|
4283 | returned.
|
---|
4284 |
|
---|
4285 | If 32-bit operations are not supported, then ASSERT().
|
---|
4286 | If StartBit is greater than 31, then ASSERT().
|
---|
4287 | If EndBit is greater than 31, then ASSERT().
|
---|
4288 | If EndBit is less than StartBit, then ASSERT().
|
---|
4289 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
|
---|
4290 |
|
---|
4291 | @param Operand Operand on which to perform the bitfield operation.
|
---|
4292 | @param StartBit The ordinal of the least significant bit in the bit field.
|
---|
4293 | Range 0..31.
|
---|
4294 | @param EndBit The ordinal of the most significant bit in the bit field.
|
---|
4295 | Range 0..31.
|
---|
4296 | @param Value New value of the bit field.
|
---|
4297 |
|
---|
4298 | @return The new 32-bit value.
|
---|
4299 |
|
---|
4300 | **/
|
---|
4301 | UINT32
|
---|
4302 | EFIAPI
|
---|
4303 | BitFieldWrite32 (
|
---|
4304 | IN UINT32 Operand,
|
---|
4305 | IN UINTN StartBit,
|
---|
4306 | IN UINTN EndBit,
|
---|
4307 | IN UINT32 Value
|
---|
4308 | );
|
---|
4309 |
|
---|
4310 | /**
|
---|
4311 | Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the
|
---|
4312 | result.
|
---|
4313 |
|
---|
4314 | Performs a bitwise OR between the bit field specified by StartBit
|
---|
4315 | and EndBit in Operand and the value specified by OrData. All other bits in
|
---|
4316 | Operand are preserved. The new 32-bit value is returned.
|
---|
4317 |
|
---|
4318 | If 32-bit operations are not supported, then ASSERT().
|
---|
4319 | If StartBit is greater than 31, then ASSERT().
|
---|
4320 | If EndBit is greater than 31, then ASSERT().
|
---|
4321 | If EndBit is less than StartBit, then ASSERT().
|
---|
4322 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
|
---|
4323 |
|
---|
4324 | @param Operand Operand on which to perform the bitfield operation.
|
---|
4325 | @param StartBit The ordinal of the least significant bit in the bit field.
|
---|
4326 | Range 0..31.
|
---|
4327 | @param EndBit The ordinal of the most significant bit in the bit field.
|
---|
4328 | Range 0..31.
|
---|
4329 | @param OrData The value to OR with the read value from the value.
|
---|
4330 |
|
---|
4331 | @return The new 32-bit value.
|
---|
4332 |
|
---|
4333 | **/
|
---|
4334 | UINT32
|
---|
4335 | EFIAPI
|
---|
4336 | BitFieldOr32 (
|
---|
4337 | IN UINT32 Operand,
|
---|
4338 | IN UINTN StartBit,
|
---|
4339 | IN UINTN EndBit,
|
---|
4340 | IN UINT32 OrData
|
---|
4341 | );
|
---|
4342 |
|
---|
4343 | /**
|
---|
4344 | Reads a bit field from a 32-bit value, performs a bitwise AND, and returns
|
---|
4345 | the result.
|
---|
4346 |
|
---|
4347 | Performs a bitwise AND between the bit field specified by StartBit and EndBit
|
---|
4348 | in Operand and the value specified by AndData. All other bits in Operand are
|
---|
4349 | preserved. The new 32-bit value is returned.
|
---|
4350 |
|
---|
4351 | If 32-bit operations are not supported, then ASSERT().
|
---|
4352 | If StartBit is greater than 31, then ASSERT().
|
---|
4353 | If EndBit is greater than 31, then ASSERT().
|
---|
4354 | If EndBit is less than StartBit, then ASSERT().
|
---|
4355 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
|
---|
4356 |
|
---|
4357 | @param Operand Operand on which to perform the bitfield operation.
|
---|
4358 | @param StartBit The ordinal of the least significant bit in the bit field.
|
---|
4359 | Range 0..31.
|
---|
4360 | @param EndBit The ordinal of the most significant bit in the bit field.
|
---|
4361 | Range 0..31.
|
---|
4362 | @param AndData The value to AND with the read value from the value
|
---|
4363 |
|
---|
4364 | @return The new 32-bit value.
|
---|
4365 |
|
---|
4366 | **/
|
---|
4367 | UINT32
|
---|
4368 | EFIAPI
|
---|
4369 | BitFieldAnd32 (
|
---|
4370 | IN UINT32 Operand,
|
---|
4371 | IN UINTN StartBit,
|
---|
4372 | IN UINTN EndBit,
|
---|
4373 | IN UINT32 AndData
|
---|
4374 | );
|
---|
4375 |
|
---|
4376 | /**
|
---|
4377 | Reads a bit field from a 32-bit value, performs a bitwise AND followed by a
|
---|
4378 | bitwise OR, and returns the result.
|
---|
4379 |
|
---|
4380 | Performs a bitwise AND between the bit field specified by StartBit and EndBit
|
---|
4381 | in Operand and the value specified by AndData, followed by a bitwise
|
---|
4382 | OR with value specified by OrData. All other bits in Operand are
|
---|
4383 | preserved. The new 32-bit value is returned.
|
---|
4384 |
|
---|
4385 | If 32-bit operations are not supported, then ASSERT().
|
---|
4386 | If StartBit is greater than 31, then ASSERT().
|
---|
4387 | If EndBit is greater than 31, then ASSERT().
|
---|
4388 | If EndBit is less than StartBit, then ASSERT().
|
---|
4389 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
|
---|
4390 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
|
---|
4391 |
|
---|
4392 | @param Operand Operand on which to perform the bitfield operation.
|
---|
4393 | @param StartBit The ordinal of the least significant bit in the bit field.
|
---|
4394 | Range 0..31.
|
---|
4395 | @param EndBit The ordinal of the most significant bit in the bit field.
|
---|
4396 | Range 0..31.
|
---|
4397 | @param AndData The value to AND with the read value from the value.
|
---|
4398 | @param OrData The value to OR with the result of the AND operation.
|
---|
4399 |
|
---|
4400 | @return The new 32-bit value.
|
---|
4401 |
|
---|
4402 | **/
|
---|
4403 | UINT32
|
---|
4404 | EFIAPI
|
---|
4405 | BitFieldAndThenOr32 (
|
---|
4406 | IN UINT32 Operand,
|
---|
4407 | IN UINTN StartBit,
|
---|
4408 | IN UINTN EndBit,
|
---|
4409 | IN UINT32 AndData,
|
---|
4410 | IN UINT32 OrData
|
---|
4411 | );
|
---|
4412 |
|
---|
4413 | /**
|
---|
4414 | Returns a bit field from a 64-bit value.
|
---|
4415 |
|
---|
4416 | Returns the bitfield specified by the StartBit and the EndBit from Operand.
|
---|
4417 |
|
---|
4418 | If 64-bit operations are not supported, then ASSERT().
|
---|
4419 | If StartBit is greater than 63, then ASSERT().
|
---|
4420 | If EndBit is greater than 63, then ASSERT().
|
---|
4421 | If EndBit is less than StartBit, then ASSERT().
|
---|
4422 |
|
---|
4423 | @param Operand Operand on which to perform the bitfield operation.
|
---|
4424 | @param StartBit The ordinal of the least significant bit in the bit field.
|
---|
4425 | Range 0..63.
|
---|
4426 | @param EndBit The ordinal of the most significant bit in the bit field.
|
---|
4427 | Range 0..63.
|
---|
4428 |
|
---|
4429 | @return The bit field read.
|
---|
4430 |
|
---|
4431 | **/
|
---|
4432 | UINT64
|
---|
4433 | EFIAPI
|
---|
4434 | BitFieldRead64 (
|
---|
4435 | IN UINT64 Operand,
|
---|
4436 | IN UINTN StartBit,
|
---|
4437 | IN UINTN EndBit
|
---|
4438 | );
|
---|
4439 |
|
---|
4440 | /**
|
---|
4441 | Writes a bit field to a 64-bit value, and returns the result.
|
---|
4442 |
|
---|
4443 | Writes Value to the bit field specified by the StartBit and the EndBit in
|
---|
4444 | Operand. All other bits in Operand are preserved. The new 64-bit value is
|
---|
4445 | returned.
|
---|
4446 |
|
---|
4447 | If 64-bit operations are not supported, then ASSERT().
|
---|
4448 | If StartBit is greater than 63, then ASSERT().
|
---|
4449 | If EndBit is greater than 63, then ASSERT().
|
---|
4450 | If EndBit is less than StartBit, then ASSERT().
|
---|
4451 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
|
---|
4452 |
|
---|
4453 | @param Operand Operand on which to perform the bitfield operation.
|
---|
4454 | @param StartBit The ordinal of the least significant bit in the bit field.
|
---|
4455 | Range 0..63.
|
---|
4456 | @param EndBit The ordinal of the most significant bit in the bit field.
|
---|
4457 | Range 0..63.
|
---|
4458 | @param Value New value of the bit field.
|
---|
4459 |
|
---|
4460 | @return The new 64-bit value.
|
---|
4461 |
|
---|
4462 | **/
|
---|
4463 | UINT64
|
---|
4464 | EFIAPI
|
---|
4465 | BitFieldWrite64 (
|
---|
4466 | IN UINT64 Operand,
|
---|
4467 | IN UINTN StartBit,
|
---|
4468 | IN UINTN EndBit,
|
---|
4469 | IN UINT64 Value
|
---|
4470 | );
|
---|
4471 |
|
---|
4472 | /**
|
---|
4473 | Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the
|
---|
4474 | result.
|
---|
4475 |
|
---|
4476 | Performs a bitwise OR between the bit field specified by StartBit
|
---|
4477 | and EndBit in Operand and the value specified by OrData. All other bits in
|
---|
4478 | Operand are preserved. The new 64-bit value is returned.
|
---|
4479 |
|
---|
4480 | If 64-bit operations are not supported, then ASSERT().
|
---|
4481 | If StartBit is greater than 63, then ASSERT().
|
---|
4482 | If EndBit is greater than 63, then ASSERT().
|
---|
4483 | If EndBit is less than StartBit, then ASSERT().
|
---|
4484 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
|
---|
4485 |
|
---|
4486 | @param Operand Operand on which to perform the bitfield operation.
|
---|
4487 | @param StartBit The ordinal of the least significant bit in the bit field.
|
---|
4488 | Range 0..63.
|
---|
4489 | @param EndBit The ordinal of the most significant bit in the bit field.
|
---|
4490 | Range 0..63.
|
---|
4491 | @param OrData The value to OR with the read value from the value
|
---|
4492 |
|
---|
4493 | @return The new 64-bit value.
|
---|
4494 |
|
---|
4495 | **/
|
---|
4496 | UINT64
|
---|
4497 | EFIAPI
|
---|
4498 | BitFieldOr64 (
|
---|
4499 | IN UINT64 Operand,
|
---|
4500 | IN UINTN StartBit,
|
---|
4501 | IN UINTN EndBit,
|
---|
4502 | IN UINT64 OrData
|
---|
4503 | );
|
---|
4504 |
|
---|
4505 | /**
|
---|
4506 | Reads a bit field from a 64-bit value, performs a bitwise AND, and returns
|
---|
4507 | the result.
|
---|
4508 |
|
---|
4509 | Performs a bitwise AND between the bit field specified by StartBit and EndBit
|
---|
4510 | in Operand and the value specified by AndData. All other bits in Operand are
|
---|
4511 | preserved. The new 64-bit value is returned.
|
---|
4512 |
|
---|
4513 | If 64-bit operations are not supported, then ASSERT().
|
---|
4514 | If StartBit is greater than 63, then ASSERT().
|
---|
4515 | If EndBit is greater than 63, then ASSERT().
|
---|
4516 | If EndBit is less than StartBit, then ASSERT().
|
---|
4517 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
|
---|
4518 |
|
---|
4519 | @param Operand Operand on which to perform the bitfield operation.
|
---|
4520 | @param StartBit The ordinal of the least significant bit in the bit field.
|
---|
4521 | Range 0..63.
|
---|
4522 | @param EndBit The ordinal of the most significant bit in the bit field.
|
---|
4523 | Range 0..63.
|
---|
4524 | @param AndData The value to AND with the read value from the value
|
---|
4525 |
|
---|
4526 | @return The new 64-bit value.
|
---|
4527 |
|
---|
4528 | **/
|
---|
4529 | UINT64
|
---|
4530 | EFIAPI
|
---|
4531 | BitFieldAnd64 (
|
---|
4532 | IN UINT64 Operand,
|
---|
4533 | IN UINTN StartBit,
|
---|
4534 | IN UINTN EndBit,
|
---|
4535 | IN UINT64 AndData
|
---|
4536 | );
|
---|
4537 |
|
---|
4538 | /**
|
---|
4539 | Reads a bit field from a 64-bit value, performs a bitwise AND followed by a
|
---|
4540 | bitwise OR, and returns the result.
|
---|
4541 |
|
---|
4542 | Performs a bitwise AND between the bit field specified by StartBit and EndBit
|
---|
4543 | in Operand and the value specified by AndData, followed by a bitwise
|
---|
4544 | OR with value specified by OrData. All other bits in Operand are
|
---|
4545 | preserved. The new 64-bit value is returned.
|
---|
4546 |
|
---|
4547 | If 64-bit operations are not supported, then ASSERT().
|
---|
4548 | If StartBit is greater than 63, then ASSERT().
|
---|
4549 | If EndBit is greater than 63, then ASSERT().
|
---|
4550 | If EndBit is less than StartBit, then ASSERT().
|
---|
4551 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
|
---|
4552 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
|
---|
4553 |
|
---|
4554 | @param Operand Operand on which to perform the bitfield operation.
|
---|
4555 | @param StartBit The ordinal of the least significant bit in the bit field.
|
---|
4556 | Range 0..63.
|
---|
4557 | @param EndBit The ordinal of the most significant bit in the bit field.
|
---|
4558 | Range 0..63.
|
---|
4559 | @param AndData The value to AND with the read value from the value.
|
---|
4560 | @param OrData The value to OR with the result of the AND operation.
|
---|
4561 |
|
---|
4562 | @return The new 64-bit value.
|
---|
4563 |
|
---|
4564 | **/
|
---|
4565 | UINT64
|
---|
4566 | EFIAPI
|
---|
4567 | BitFieldAndThenOr64 (
|
---|
4568 | IN UINT64 Operand,
|
---|
4569 | IN UINTN StartBit,
|
---|
4570 | IN UINTN EndBit,
|
---|
4571 | IN UINT64 AndData,
|
---|
4572 | IN UINT64 OrData
|
---|
4573 | );
|
---|
4574 |
|
---|
4575 | /**
|
---|
4576 | Reads a bit field from a 32-bit value, counts and returns
|
---|
4577 | the number of set bits.
|
---|
4578 |
|
---|
4579 | Counts the number of set bits in the bit field specified by
|
---|
4580 | StartBit and EndBit in Operand. The count is returned.
|
---|
4581 |
|
---|
4582 | If StartBit is greater than 31, then ASSERT().
|
---|
4583 | If EndBit is greater than 31, then ASSERT().
|
---|
4584 | If EndBit is less than StartBit, then ASSERT().
|
---|
4585 |
|
---|
4586 | @param Operand Operand on which to perform the bitfield operation.
|
---|
4587 | @param StartBit The ordinal of the least significant bit in the bit field.
|
---|
4588 | Range 0..31.
|
---|
4589 | @param EndBit The ordinal of the most significant bit in the bit field.
|
---|
4590 | Range 0..31.
|
---|
4591 |
|
---|
4592 | @return The number of bits set between StartBit and EndBit.
|
---|
4593 |
|
---|
4594 | **/
|
---|
4595 | UINT8
|
---|
4596 | EFIAPI
|
---|
4597 | BitFieldCountOnes32 (
|
---|
4598 | IN UINT32 Operand,
|
---|
4599 | IN UINTN StartBit,
|
---|
4600 | IN UINTN EndBit
|
---|
4601 | );
|
---|
4602 |
|
---|
4603 | /**
|
---|
4604 | Reads a bit field from a 64-bit value, counts and returns
|
---|
4605 | the number of set bits.
|
---|
4606 |
|
---|
4607 | Counts the number of set bits in the bit field specified by
|
---|
4608 | StartBit and EndBit in Operand. The count is returned.
|
---|
4609 |
|
---|
4610 | If StartBit is greater than 63, then ASSERT().
|
---|
4611 | If EndBit is greater than 63, then ASSERT().
|
---|
4612 | If EndBit is less than StartBit, then ASSERT().
|
---|
4613 |
|
---|
4614 | @param Operand Operand on which to perform the bitfield operation.
|
---|
4615 | @param StartBit The ordinal of the least significant bit in the bit field.
|
---|
4616 | Range 0..63.
|
---|
4617 | @param EndBit The ordinal of the most significant bit in the bit field.
|
---|
4618 | Range 0..63.
|
---|
4619 |
|
---|
4620 | @return The number of bits set between StartBit and EndBit.
|
---|
4621 |
|
---|
4622 | **/
|
---|
4623 | UINT8
|
---|
4624 | EFIAPI
|
---|
4625 | BitFieldCountOnes64 (
|
---|
4626 | IN UINT64 Operand,
|
---|
4627 | IN UINTN StartBit,
|
---|
4628 | IN UINTN EndBit
|
---|
4629 | );
|
---|
4630 |
|
---|
4631 | //
|
---|
4632 | // Base Library Checksum Functions
|
---|
4633 | //
|
---|
4634 |
|
---|
4635 | /**
|
---|
4636 | Returns the sum of all elements in a buffer in unit of UINT8.
|
---|
4637 | During calculation, the carry bits are dropped.
|
---|
4638 |
|
---|
4639 | This function calculates the sum of all elements in a buffer
|
---|
4640 | in unit of UINT8. The carry bits in result of addition are dropped.
|
---|
4641 | The result is returned as UINT8. If Length is Zero, then Zero is
|
---|
4642 | returned.
|
---|
4643 |
|
---|
4644 | If Buffer is NULL, then ASSERT().
|
---|
4645 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
|
---|
4646 |
|
---|
4647 | @param Buffer The pointer to the buffer to carry out the sum operation.
|
---|
4648 | @param Length The size, in bytes, of Buffer.
|
---|
4649 |
|
---|
4650 | @return Sum The sum of Buffer with carry bits dropped during additions.
|
---|
4651 |
|
---|
4652 | **/
|
---|
4653 | UINT8
|
---|
4654 | EFIAPI
|
---|
4655 | CalculateSum8 (
|
---|
4656 | IN CONST UINT8 *Buffer,
|
---|
4657 | IN UINTN Length
|
---|
4658 | );
|
---|
4659 |
|
---|
4660 | /**
|
---|
4661 | Returns the two's complement checksum of all elements in a buffer
|
---|
4662 | of 8-bit values.
|
---|
4663 |
|
---|
4664 | This function first calculates the sum of the 8-bit values in the
|
---|
4665 | buffer specified by Buffer and Length. The carry bits in the result
|
---|
4666 | of addition are dropped. Then, the two's complement of the sum is
|
---|
4667 | returned. If Length is 0, then 0 is returned.
|
---|
4668 |
|
---|
4669 | If Buffer is NULL, then ASSERT().
|
---|
4670 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
|
---|
4671 |
|
---|
4672 | @param Buffer The pointer to the buffer to carry out the checksum operation.
|
---|
4673 | @param Length The size, in bytes, of Buffer.
|
---|
4674 |
|
---|
4675 | @return Checksum The two's complement checksum of Buffer.
|
---|
4676 |
|
---|
4677 | **/
|
---|
4678 | UINT8
|
---|
4679 | EFIAPI
|
---|
4680 | CalculateCheckSum8 (
|
---|
4681 | IN CONST UINT8 *Buffer,
|
---|
4682 | IN UINTN Length
|
---|
4683 | );
|
---|
4684 |
|
---|
4685 | /**
|
---|
4686 | Returns the sum of all elements in a buffer of 16-bit values. During
|
---|
4687 | calculation, the carry bits are dropped.
|
---|
4688 |
|
---|
4689 | This function calculates the sum of the 16-bit values in the buffer
|
---|
4690 | specified by Buffer and Length. The carry bits in result of addition are dropped.
|
---|
4691 | The 16-bit result is returned. If Length is 0, then 0 is returned.
|
---|
4692 |
|
---|
4693 | If Buffer is NULL, then ASSERT().
|
---|
4694 | If Buffer is not aligned on a 16-bit boundary, then ASSERT().
|
---|
4695 | If Length is not aligned on a 16-bit boundary, then ASSERT().
|
---|
4696 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
|
---|
4697 |
|
---|
4698 | @param Buffer The pointer to the buffer to carry out the sum operation.
|
---|
4699 | @param Length The size, in bytes, of Buffer.
|
---|
4700 |
|
---|
4701 | @return Sum The sum of Buffer with carry bits dropped during additions.
|
---|
4702 |
|
---|
4703 | **/
|
---|
4704 | UINT16
|
---|
4705 | EFIAPI
|
---|
4706 | CalculateSum16 (
|
---|
4707 | IN CONST UINT16 *Buffer,
|
---|
4708 | IN UINTN Length
|
---|
4709 | );
|
---|
4710 |
|
---|
4711 | /**
|
---|
4712 | Returns the two's complement checksum of all elements in a buffer of
|
---|
4713 | 16-bit values.
|
---|
4714 |
|
---|
4715 | This function first calculates the sum of the 16-bit values in the buffer
|
---|
4716 | specified by Buffer and Length. The carry bits in the result of addition
|
---|
4717 | are dropped. Then, the two's complement of the sum is returned. If Length
|
---|
4718 | is 0, then 0 is returned.
|
---|
4719 |
|
---|
4720 | If Buffer is NULL, then ASSERT().
|
---|
4721 | If Buffer is not aligned on a 16-bit boundary, then ASSERT().
|
---|
4722 | If Length is not aligned on a 16-bit boundary, then ASSERT().
|
---|
4723 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
|
---|
4724 |
|
---|
4725 | @param Buffer The pointer to the buffer to carry out the checksum operation.
|
---|
4726 | @param Length The size, in bytes, of Buffer.
|
---|
4727 |
|
---|
4728 | @return Checksum The two's complement checksum of Buffer.
|
---|
4729 |
|
---|
4730 | **/
|
---|
4731 | UINT16
|
---|
4732 | EFIAPI
|
---|
4733 | CalculateCheckSum16 (
|
---|
4734 | IN CONST UINT16 *Buffer,
|
---|
4735 | IN UINTN Length
|
---|
4736 | );
|
---|
4737 |
|
---|
4738 | /**
|
---|
4739 | Returns the sum of all elements in a buffer of 32-bit values. During
|
---|
4740 | calculation, the carry bits are dropped.
|
---|
4741 |
|
---|
4742 | This function calculates the sum of the 32-bit values in the buffer
|
---|
4743 | specified by Buffer and Length. The carry bits in result of addition are dropped.
|
---|
4744 | The 32-bit result is returned. If Length is 0, then 0 is returned.
|
---|
4745 |
|
---|
4746 | If Buffer is NULL, then ASSERT().
|
---|
4747 | If Buffer is not aligned on a 32-bit boundary, then ASSERT().
|
---|
4748 | If Length is not aligned on a 32-bit boundary, then ASSERT().
|
---|
4749 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
|
---|
4750 |
|
---|
4751 | @param Buffer The pointer to the buffer to carry out the sum operation.
|
---|
4752 | @param Length The size, in bytes, of Buffer.
|
---|
4753 |
|
---|
4754 | @return Sum The sum of Buffer with carry bits dropped during additions.
|
---|
4755 |
|
---|
4756 | **/
|
---|
4757 | UINT32
|
---|
4758 | EFIAPI
|
---|
4759 | CalculateSum32 (
|
---|
4760 | IN CONST UINT32 *Buffer,
|
---|
4761 | IN UINTN Length
|
---|
4762 | );
|
---|
4763 |
|
---|
4764 | /**
|
---|
4765 | Returns the two's complement checksum of all elements in a buffer of
|
---|
4766 | 32-bit values.
|
---|
4767 |
|
---|
4768 | This function first calculates the sum of the 32-bit values in the buffer
|
---|
4769 | specified by Buffer and Length. The carry bits in the result of addition
|
---|
4770 | are dropped. Then, the two's complement of the sum is returned. If Length
|
---|
4771 | is 0, then 0 is returned.
|
---|
4772 |
|
---|
4773 | If Buffer is NULL, then ASSERT().
|
---|
4774 | If Buffer is not aligned on a 32-bit boundary, then ASSERT().
|
---|
4775 | If Length is not aligned on a 32-bit boundary, then ASSERT().
|
---|
4776 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
|
---|
4777 |
|
---|
4778 | @param Buffer The pointer to the buffer to carry out the checksum operation.
|
---|
4779 | @param Length The size, in bytes, of Buffer.
|
---|
4780 |
|
---|
4781 | @return Checksum The two's complement checksum of Buffer.
|
---|
4782 |
|
---|
4783 | **/
|
---|
4784 | UINT32
|
---|
4785 | EFIAPI
|
---|
4786 | CalculateCheckSum32 (
|
---|
4787 | IN CONST UINT32 *Buffer,
|
---|
4788 | IN UINTN Length
|
---|
4789 | );
|
---|
4790 |
|
---|
4791 | /**
|
---|
4792 | Returns the sum of all elements in a buffer of 64-bit values. During
|
---|
4793 | calculation, the carry bits are dropped.
|
---|
4794 |
|
---|
4795 | This function calculates the sum of the 64-bit values in the buffer
|
---|
4796 | specified by Buffer and Length. The carry bits in result of addition are dropped.
|
---|
4797 | The 64-bit result is returned. If Length is 0, then 0 is returned.
|
---|
4798 |
|
---|
4799 | If Buffer is NULL, then ASSERT().
|
---|
4800 | If Buffer is not aligned on a 64-bit boundary, then ASSERT().
|
---|
4801 | If Length is not aligned on a 64-bit boundary, then ASSERT().
|
---|
4802 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
|
---|
4803 |
|
---|
4804 | @param Buffer The pointer to the buffer to carry out the sum operation.
|
---|
4805 | @param Length The size, in bytes, of Buffer.
|
---|
4806 |
|
---|
4807 | @return Sum The sum of Buffer with carry bits dropped during additions.
|
---|
4808 |
|
---|
4809 | **/
|
---|
4810 | UINT64
|
---|
4811 | EFIAPI
|
---|
4812 | CalculateSum64 (
|
---|
4813 | IN CONST UINT64 *Buffer,
|
---|
4814 | IN UINTN Length
|
---|
4815 | );
|
---|
4816 |
|
---|
4817 | /**
|
---|
4818 | Returns the two's complement checksum of all elements in a buffer of
|
---|
4819 | 64-bit values.
|
---|
4820 |
|
---|
4821 | This function first calculates the sum of the 64-bit values in the buffer
|
---|
4822 | specified by Buffer and Length. The carry bits in the result of addition
|
---|
4823 | are dropped. Then, the two's complement of the sum is returned. If Length
|
---|
4824 | is 0, then 0 is returned.
|
---|
4825 |
|
---|
4826 | If Buffer is NULL, then ASSERT().
|
---|
4827 | If Buffer is not aligned on a 64-bit boundary, then ASSERT().
|
---|
4828 | If Length is not aligned on a 64-bit boundary, then ASSERT().
|
---|
4829 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
|
---|
4830 |
|
---|
4831 | @param Buffer The pointer to the buffer to carry out the checksum operation.
|
---|
4832 | @param Length The size, in bytes, of Buffer.
|
---|
4833 |
|
---|
4834 | @return Checksum The two's complement checksum of Buffer.
|
---|
4835 |
|
---|
4836 | **/
|
---|
4837 | UINT64
|
---|
4838 | EFIAPI
|
---|
4839 | CalculateCheckSum64 (
|
---|
4840 | IN CONST UINT64 *Buffer,
|
---|
4841 | IN UINTN Length
|
---|
4842 | );
|
---|
4843 |
|
---|
4844 | /**
|
---|
4845 | Computes and returns a 32-bit CRC for a data buffer.
|
---|
4846 | CRC32 value bases on ITU-T V.42.
|
---|
4847 |
|
---|
4848 | If Buffer is NULL, then ASSERT().
|
---|
4849 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
|
---|
4850 |
|
---|
4851 | @param[in] Buffer A pointer to the buffer on which the 32-bit CRC is to be computed.
|
---|
4852 | @param[in] Length The number of bytes in the buffer Data.
|
---|
4853 |
|
---|
4854 | @retval Crc32 The 32-bit CRC was computed for the data buffer.
|
---|
4855 |
|
---|
4856 | **/
|
---|
4857 | UINT32
|
---|
4858 | EFIAPI
|
---|
4859 | CalculateCrc32 (
|
---|
4860 | IN VOID *Buffer,
|
---|
4861 | IN UINTN Length
|
---|
4862 | );
|
---|
4863 |
|
---|
4864 | /**
|
---|
4865 | Calculates the CRC16-ANSI checksum of the given buffer.
|
---|
4866 |
|
---|
4867 | @param[in] Buffer Pointer to the buffer.
|
---|
4868 | @param[in] Length Length of the buffer, in bytes.
|
---|
4869 | @param[in] InitialValue Initial value of the CRC.
|
---|
4870 |
|
---|
4871 | @return The CRC16-ANSI checksum.
|
---|
4872 | **/
|
---|
4873 | UINT16
|
---|
4874 | EFIAPI
|
---|
4875 | CalculateCrc16Ansi (
|
---|
4876 | IN CONST VOID *Buffer,
|
---|
4877 | IN UINTN Length,
|
---|
4878 | IN UINT16 InitialValue
|
---|
4879 | );
|
---|
4880 |
|
---|
4881 | //
|
---|
4882 | // Initial value for the CRC16-ANSI algorithm, when no prior checksum has been calculated.
|
---|
4883 | //
|
---|
4884 | #define CRC16ANSI_INIT 0xffff
|
---|
4885 |
|
---|
4886 | /**
|
---|
4887 | Calculates the CRC32c checksum of the given buffer.
|
---|
4888 |
|
---|
4889 | @param[in] Buffer Pointer to the buffer.
|
---|
4890 | @param[in] Length Length of the buffer, in bytes.
|
---|
4891 | @param[in] InitialValue Initial value of the CRC.
|
---|
4892 |
|
---|
4893 | @return The CRC32c checksum.
|
---|
4894 | **/
|
---|
4895 | UINT32
|
---|
4896 | EFIAPI
|
---|
4897 | CalculateCrc32c (
|
---|
4898 | IN CONST VOID *Buffer,
|
---|
4899 | IN UINTN Length,
|
---|
4900 | IN UINT32 InitialValue
|
---|
4901 | );
|
---|
4902 |
|
---|
4903 | //
|
---|
4904 | // Base Library CPU Functions
|
---|
4905 | //
|
---|
4906 |
|
---|
4907 | /**
|
---|
4908 | Function entry point used when a stack switch is requested with SwitchStack()
|
---|
4909 |
|
---|
4910 | @param Context1 Context1 parameter passed into SwitchStack().
|
---|
4911 | @param Context2 Context2 parameter passed into SwitchStack().
|
---|
4912 | **/
|
---|
4913 | typedef
|
---|
4914 | VOID
|
---|
4915 | (EFIAPI *SWITCH_STACK_ENTRY_POINT)(
|
---|
4916 | IN VOID *Context1 OPTIONAL,
|
---|
4917 | IN VOID *Context2 OPTIONAL
|
---|
4918 | );
|
---|
4919 |
|
---|
4920 | /**
|
---|
4921 | Used to serialize load and store operations.
|
---|
4922 |
|
---|
4923 | All loads and stores that proceed calls to this function are guaranteed to be
|
---|
4924 | globally visible when this function returns.
|
---|
4925 |
|
---|
4926 | **/
|
---|
4927 | VOID
|
---|
4928 | EFIAPI
|
---|
4929 | MemoryFence (
|
---|
4930 | VOID
|
---|
4931 | );
|
---|
4932 |
|
---|
4933 | /**
|
---|
4934 | Saves the current CPU context that can be restored with a call to LongJump()
|
---|
4935 | and returns 0.
|
---|
4936 |
|
---|
4937 | Saves the current CPU context in the buffer specified by JumpBuffer and
|
---|
4938 | returns 0. The initial call to SetJump() must always return 0. Subsequent
|
---|
4939 | calls to LongJump() cause a non-zero value to be returned by SetJump().
|
---|
4940 |
|
---|
4941 | If JumpBuffer is NULL, then ASSERT().
|
---|
4942 | For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
|
---|
4943 |
|
---|
4944 | NOTE: The structure BASE_LIBRARY_JUMP_BUFFER is CPU architecture specific.
|
---|
4945 | The same structure must never be used for more than one CPU architecture context.
|
---|
4946 | For example, a BASE_LIBRARY_JUMP_BUFFER allocated by an IA-32 module must never be used from an x64 module.
|
---|
4947 | SetJump()/LongJump() is not currently supported for the EBC processor type.
|
---|
4948 |
|
---|
4949 | @param JumpBuffer A pointer to CPU context buffer.
|
---|
4950 |
|
---|
4951 | @retval 0 Indicates a return from SetJump().
|
---|
4952 |
|
---|
4953 | **/
|
---|
4954 | RETURNS_TWICE
|
---|
4955 | UINTN
|
---|
4956 | EFIAPI
|
---|
4957 | SetJump (
|
---|
4958 | OUT BASE_LIBRARY_JUMP_BUFFER *JumpBuffer
|
---|
4959 | );
|
---|
4960 |
|
---|
4961 | /**
|
---|
4962 | Restores the CPU context that was saved with SetJump().
|
---|
4963 |
|
---|
4964 | Restores the CPU context from the buffer specified by JumpBuffer. This
|
---|
4965 | function never returns to the caller. Instead is resumes execution based on
|
---|
4966 | the state of JumpBuffer.
|
---|
4967 |
|
---|
4968 | If JumpBuffer is NULL, then ASSERT().
|
---|
4969 | For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
|
---|
4970 | If Value is 0, then ASSERT().
|
---|
4971 |
|
---|
4972 | @param JumpBuffer A pointer to CPU context buffer.
|
---|
4973 | @param Value The value to return when the SetJump() context is
|
---|
4974 | restored and must be non-zero.
|
---|
4975 |
|
---|
4976 | **/
|
---|
4977 | VOID
|
---|
4978 | EFIAPI
|
---|
4979 | LongJump (
|
---|
4980 | IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer,
|
---|
4981 | IN UINTN Value
|
---|
4982 | );
|
---|
4983 |
|
---|
4984 | /**
|
---|
4985 | Enables CPU interrupts.
|
---|
4986 |
|
---|
4987 | **/
|
---|
4988 | VOID
|
---|
4989 | EFIAPI
|
---|
4990 | EnableInterrupts (
|
---|
4991 | VOID
|
---|
4992 | );
|
---|
4993 |
|
---|
4994 | /**
|
---|
4995 | Disables CPU interrupts.
|
---|
4996 |
|
---|
4997 | **/
|
---|
4998 | VOID
|
---|
4999 | EFIAPI
|
---|
5000 | DisableInterrupts (
|
---|
5001 | VOID
|
---|
5002 | );
|
---|
5003 |
|
---|
5004 | /**
|
---|
5005 | Disables CPU interrupts and returns the interrupt state prior to the disable
|
---|
5006 | operation.
|
---|
5007 |
|
---|
5008 | @retval TRUE CPU interrupts were enabled on entry to this call.
|
---|
5009 | @retval FALSE CPU interrupts were disabled on entry to this call.
|
---|
5010 |
|
---|
5011 | **/
|
---|
5012 | BOOLEAN
|
---|
5013 | EFIAPI
|
---|
5014 | SaveAndDisableInterrupts (
|
---|
5015 | VOID
|
---|
5016 | );
|
---|
5017 |
|
---|
5018 | /**
|
---|
5019 | Enables CPU interrupts for the smallest window required to capture any
|
---|
5020 | pending interrupts.
|
---|
5021 |
|
---|
5022 | **/
|
---|
5023 | VOID
|
---|
5024 | EFIAPI
|
---|
5025 | EnableDisableInterrupts (
|
---|
5026 | VOID
|
---|
5027 | );
|
---|
5028 |
|
---|
5029 | /**
|
---|
5030 | Retrieves the current CPU interrupt state.
|
---|
5031 |
|
---|
5032 | Returns TRUE if interrupts are currently enabled. Otherwise
|
---|
5033 | returns FALSE.
|
---|
5034 |
|
---|
5035 | @retval TRUE CPU interrupts are enabled.
|
---|
5036 | @retval FALSE CPU interrupts are disabled.
|
---|
5037 |
|
---|
5038 | **/
|
---|
5039 | BOOLEAN
|
---|
5040 | EFIAPI
|
---|
5041 | GetInterruptState (
|
---|
5042 | VOID
|
---|
5043 | );
|
---|
5044 |
|
---|
5045 | /**
|
---|
5046 | Set the current CPU interrupt state.
|
---|
5047 |
|
---|
5048 | Sets the current CPU interrupt state to the state specified by
|
---|
5049 | InterruptState. If InterruptState is TRUE, then interrupts are enabled. If
|
---|
5050 | InterruptState is FALSE, then interrupts are disabled. InterruptState is
|
---|
5051 | returned.
|
---|
5052 |
|
---|
5053 | @param InterruptState TRUE if interrupts should enabled. FALSE if
|
---|
5054 | interrupts should be disabled.
|
---|
5055 |
|
---|
5056 | @return InterruptState
|
---|
5057 |
|
---|
5058 | **/
|
---|
5059 | BOOLEAN
|
---|
5060 | EFIAPI
|
---|
5061 | SetInterruptState (
|
---|
5062 | IN BOOLEAN InterruptState
|
---|
5063 | );
|
---|
5064 |
|
---|
5065 | /**
|
---|
5066 | Requests CPU to pause for a short period of time.
|
---|
5067 |
|
---|
5068 | Requests CPU to pause for a short period of time. Typically used in MP
|
---|
5069 | systems to prevent memory starvation while waiting for a spin lock.
|
---|
5070 |
|
---|
5071 | **/
|
---|
5072 | VOID
|
---|
5073 | EFIAPI
|
---|
5074 | CpuPause (
|
---|
5075 | VOID
|
---|
5076 | );
|
---|
5077 |
|
---|
5078 | /**
|
---|
5079 | Transfers control to a function starting with a new stack.
|
---|
5080 |
|
---|
5081 | Transfers control to the function specified by EntryPoint using the
|
---|
5082 | new stack specified by NewStack and passing in the parameters specified
|
---|
5083 | by Context1 and Context2. Context1 and Context2 are optional and may
|
---|
5084 | be NULL. The function EntryPoint must never return. This function
|
---|
5085 | supports a variable number of arguments following the NewStack parameter.
|
---|
5086 | These additional arguments are ignored on IA-32, x64, and EBC architectures.
|
---|
5087 | Itanium processors expect one additional parameter of type VOID * that specifies
|
---|
5088 | the new backing store pointer.
|
---|
5089 |
|
---|
5090 | If EntryPoint is NULL, then ASSERT().
|
---|
5091 | If NewStack is NULL, then ASSERT().
|
---|
5092 |
|
---|
5093 | @param EntryPoint A pointer to function to call with the new stack.
|
---|
5094 | @param Context1 A pointer to the context to pass into the EntryPoint
|
---|
5095 | function.
|
---|
5096 | @param Context2 A pointer to the context to pass into the EntryPoint
|
---|
5097 | function.
|
---|
5098 | @param NewStack A pointer to the new stack to use for the EntryPoint
|
---|
5099 | function.
|
---|
5100 | @param ... This variable argument list is ignored for IA-32, x64, and
|
---|
5101 | EBC architectures. For Itanium processors, this variable
|
---|
5102 | argument list is expected to contain a single parameter of
|
---|
5103 | type VOID * that specifies the new backing store pointer.
|
---|
5104 |
|
---|
5105 |
|
---|
5106 | **/
|
---|
5107 | VOID
|
---|
5108 | EFIAPI
|
---|
5109 | SwitchStack (
|
---|
5110 | IN SWITCH_STACK_ENTRY_POINT EntryPoint,
|
---|
5111 | IN VOID *Context1 OPTIONAL,
|
---|
5112 | IN VOID *Context2 OPTIONAL,
|
---|
5113 | IN VOID *NewStack,
|
---|
5114 | ...
|
---|
5115 | );
|
---|
5116 |
|
---|
5117 | /**
|
---|
5118 | Generates a breakpoint on the CPU.
|
---|
5119 |
|
---|
5120 | Generates a breakpoint on the CPU. The breakpoint must be implemented such
|
---|
5121 | that code can resume normal execution after the breakpoint.
|
---|
5122 |
|
---|
5123 | **/
|
---|
5124 | VOID
|
---|
5125 | EFIAPI
|
---|
5126 | CpuBreakpoint (
|
---|
5127 | VOID
|
---|
5128 | );
|
---|
5129 |
|
---|
5130 | /**
|
---|
5131 | Executes an infinite loop.
|
---|
5132 |
|
---|
5133 | Forces the CPU to execute an infinite loop. A debugger may be used to skip
|
---|
5134 | past the loop and the code that follows the loop must execute properly. This
|
---|
5135 | implies that the infinite loop must not cause the code that follow it to be
|
---|
5136 | optimized away.
|
---|
5137 |
|
---|
5138 | **/
|
---|
5139 | VOID
|
---|
5140 | EFIAPI
|
---|
5141 | CpuDeadLoop (
|
---|
5142 | VOID
|
---|
5143 | );
|
---|
5144 |
|
---|
5145 | /**
|
---|
5146 | Uses as a barrier to stop speculative execution.
|
---|
5147 |
|
---|
5148 | Ensures that no later instruction will execute speculatively, until all prior
|
---|
5149 | instructions have completed.
|
---|
5150 |
|
---|
5151 | **/
|
---|
5152 | VOID
|
---|
5153 | EFIAPI
|
---|
5154 | SpeculationBarrier (
|
---|
5155 | VOID
|
---|
5156 | );
|
---|
5157 |
|
---|
5158 | #if defined (MDE_CPU_X64) || defined (MDE_CPU_IA32)
|
---|
5159 |
|
---|
5160 | /**
|
---|
5161 | The TDCALL instruction causes a VM exit to the Intel TDX module. It is
|
---|
5162 | used to call guest-side Intel TDX functions, either local or a TD exit
|
---|
5163 | to the host VMM, as selected by Leaf.
|
---|
5164 |
|
---|
5165 | @param[in] Leaf Leaf number of TDCALL instruction
|
---|
5166 | @param[in] Arg1 Arg1
|
---|
5167 | @param[in] Arg2 Arg2
|
---|
5168 | @param[in] Arg3 Arg3
|
---|
5169 | @param[in,out] Results Returned result of the Leaf function
|
---|
5170 |
|
---|
5171 | @return 0 A successful call
|
---|
5172 | @return Other See individual leaf functions
|
---|
5173 | **/
|
---|
5174 | UINTN
|
---|
5175 | EFIAPI
|
---|
5176 | TdCall (
|
---|
5177 | IN UINT64 Leaf,
|
---|
5178 | IN UINT64 Arg1,
|
---|
5179 | IN UINT64 Arg2,
|
---|
5180 | IN UINT64 Arg3,
|
---|
5181 | IN OUT VOID *Results
|
---|
5182 | );
|
---|
5183 |
|
---|
5184 | /**
|
---|
5185 | TDVMALL is a leaf function 0 for TDCALL. It helps invoke services from the
|
---|
5186 | host VMM to pass/receive information.
|
---|
5187 |
|
---|
5188 | @param[in] Leaf Number of sub-functions
|
---|
5189 | @param[in] Arg1 Arg1
|
---|
5190 | @param[in] Arg2 Arg2
|
---|
5191 | @param[in] Arg3 Arg3
|
---|
5192 | @param[in] Arg4 Arg4
|
---|
5193 | @param[in,out] Results Returned result of the sub-function
|
---|
5194 |
|
---|
5195 | @return 0 A successful call
|
---|
5196 | @return Other See individual sub-functions
|
---|
5197 |
|
---|
5198 | **/
|
---|
5199 | UINTN
|
---|
5200 | EFIAPI
|
---|
5201 | TdVmCall (
|
---|
5202 | IN UINT64 Leaf,
|
---|
5203 | IN UINT64 Arg1,
|
---|
5204 | IN UINT64 Arg2,
|
---|
5205 | IN UINT64 Arg3,
|
---|
5206 | IN UINT64 Arg4,
|
---|
5207 | IN OUT VOID *Results
|
---|
5208 | );
|
---|
5209 |
|
---|
5210 | /**
|
---|
5211 | Probe if TD is enabled.
|
---|
5212 |
|
---|
5213 | @return TRUE TD is enabled.
|
---|
5214 | @return FALSE TD is not enabled.
|
---|
5215 | **/
|
---|
5216 | BOOLEAN
|
---|
5217 | EFIAPI
|
---|
5218 | TdIsEnabled (
|
---|
5219 | VOID
|
---|
5220 | );
|
---|
5221 |
|
---|
5222 | #endif
|
---|
5223 |
|
---|
5224 | #if defined (MDE_CPU_X64)
|
---|
5225 | //
|
---|
5226 | // The page size for the PVALIDATE instruction
|
---|
5227 | //
|
---|
5228 | typedef enum {
|
---|
5229 | PvalidatePageSize4K = 0,
|
---|
5230 | PvalidatePageSize2MB,
|
---|
5231 | } PVALIDATE_PAGE_SIZE;
|
---|
5232 |
|
---|
5233 | //
|
---|
5234 | // PVALIDATE Return Code.
|
---|
5235 | //
|
---|
5236 | #define PVALIDATE_RET_SUCCESS 0
|
---|
5237 | #define PVALIDATE_RET_FAIL_INPUT 1
|
---|
5238 | #define PVALIDATE_RET_SIZE_MISMATCH 6
|
---|
5239 |
|
---|
5240 | //
|
---|
5241 | // The PVALIDATE instruction did not make any changes to the RMP entry.
|
---|
5242 | //
|
---|
5243 | #define PVALIDATE_RET_NO_RMPUPDATE 255
|
---|
5244 |
|
---|
5245 | /**
|
---|
5246 | Execute a PVALIDATE instruction to validate or to rescinds validation of a guest
|
---|
5247 | page's RMP entry.
|
---|
5248 |
|
---|
5249 | The instruction is available only when CPUID Fn8000_001F_EAX[SNP]=1.
|
---|
5250 |
|
---|
5251 | The function is available on X64.
|
---|
5252 |
|
---|
5253 | @param[in] PageSize The page size to use.
|
---|
5254 | @param[in] Validate If TRUE, validate the guest virtual address
|
---|
5255 | otherwise invalidate the guest virtual address.
|
---|
5256 | @param[in] Address The guest virtual address.
|
---|
5257 |
|
---|
5258 | @retval PVALIDATE_RET_SUCCESS The PVALIDATE instruction succeeded, and
|
---|
5259 | updated the RMP entry.
|
---|
5260 | @retval PVALIDATE_RET_NO_RMPUPDATE The PVALIDATE instruction succeeded, but
|
---|
5261 | did not update the RMP entry.
|
---|
5262 | @return Failure code from the PVALIDATE
|
---|
5263 | instruction.
|
---|
5264 | **/
|
---|
5265 | UINT32
|
---|
5266 | EFIAPI
|
---|
5267 | AsmPvalidate (
|
---|
5268 | IN PVALIDATE_PAGE_SIZE PageSize,
|
---|
5269 | IN BOOLEAN Validate,
|
---|
5270 | IN PHYSICAL_ADDRESS Address
|
---|
5271 | );
|
---|
5272 |
|
---|
5273 | //
|
---|
5274 | // RDX settings for RMPADJUST
|
---|
5275 | //
|
---|
5276 | #define RMPADJUST_VMPL_MAX 3
|
---|
5277 | #define RMPADJUST_VMPL_MASK 0xFF
|
---|
5278 | #define RMPADJUST_VMPL_SHIFT 0
|
---|
5279 | #define RMPADJUST_PERMISSION_MASK_MASK 0xFF
|
---|
5280 | #define RMPADJUST_PERMISSION_MASK_SHIFT 8
|
---|
5281 | #define RMPADJUST_VMSA_PAGE_BIT BIT16
|
---|
5282 |
|
---|
5283 | /**
|
---|
5284 | Adjusts the permissions of an SEV-SNP guest page.
|
---|
5285 |
|
---|
5286 | Executes a RMPADJUST instruction with the register state specified by Rax,
|
---|
5287 | Rcx, and Rdx. Returns Eax. This function is only available on X64.
|
---|
5288 |
|
---|
5289 | The instruction is available only when CPUID Fn8000_001F_EAX[SNP]=1.
|
---|
5290 |
|
---|
5291 | @param[in] Rax The value to load into RAX before executing the RMPADJUST
|
---|
5292 | instruction.
|
---|
5293 | @param[in] Rcx The value to load into RCX before executing the RMPADJUST
|
---|
5294 | instruction.
|
---|
5295 | @param[in] Rdx The value to load into RDX before executing the RMPADJUST
|
---|
5296 | instruction.
|
---|
5297 |
|
---|
5298 | @return Eax
|
---|
5299 | **/
|
---|
5300 | UINT32
|
---|
5301 | EFIAPI
|
---|
5302 | AsmRmpAdjust (
|
---|
5303 | IN UINT64 Rax,
|
---|
5304 | IN UINT64 Rcx,
|
---|
5305 | IN UINT64 Rdx
|
---|
5306 | );
|
---|
5307 |
|
---|
5308 | #endif
|
---|
5309 |
|
---|
5310 | #if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
|
---|
5311 | ///
|
---|
5312 | /// IA32 and x64 Specific Functions.
|
---|
5313 | /// Byte packed structure for 16-bit Real Mode EFLAGS.
|
---|
5314 | ///
|
---|
5315 | typedef union {
|
---|
5316 | struct {
|
---|
5317 | UINT32 CF : 1; ///< Carry Flag.
|
---|
5318 | UINT32 Reserved_0 : 1; ///< Reserved.
|
---|
5319 | UINT32 PF : 1; ///< Parity Flag.
|
---|
5320 | UINT32 Reserved_1 : 1; ///< Reserved.
|
---|
5321 | UINT32 AF : 1; ///< Auxiliary Carry Flag.
|
---|
5322 | UINT32 Reserved_2 : 1; ///< Reserved.
|
---|
5323 | UINT32 ZF : 1; ///< Zero Flag.
|
---|
5324 | UINT32 SF : 1; ///< Sign Flag.
|
---|
5325 | UINT32 TF : 1; ///< Trap Flag.
|
---|
5326 | UINT32 IF : 1; ///< Interrupt Enable Flag.
|
---|
5327 | UINT32 DF : 1; ///< Direction Flag.
|
---|
5328 | UINT32 OF : 1; ///< Overflow Flag.
|
---|
5329 | UINT32 IOPL : 2; ///< I/O Privilege Level.
|
---|
5330 | UINT32 NT : 1; ///< Nested Task.
|
---|
5331 | UINT32 Reserved_3 : 1; ///< Reserved.
|
---|
5332 | } Bits;
|
---|
5333 | UINT16 Uint16;
|
---|
5334 | } IA32_FLAGS16;
|
---|
5335 |
|
---|
5336 | ///
|
---|
5337 | /// Byte packed structure for EFLAGS/RFLAGS.
|
---|
5338 | /// 32-bits on IA-32.
|
---|
5339 | /// 64-bits on x64. The upper 32-bits on x64 are reserved.
|
---|
5340 | ///
|
---|
5341 | typedef union {
|
---|
5342 | struct {
|
---|
5343 | UINT32 CF : 1; ///< Carry Flag.
|
---|
5344 | UINT32 Reserved_0 : 1; ///< Reserved.
|
---|
5345 | UINT32 PF : 1; ///< Parity Flag.
|
---|
5346 | UINT32 Reserved_1 : 1; ///< Reserved.
|
---|
5347 | UINT32 AF : 1; ///< Auxiliary Carry Flag.
|
---|
5348 | UINT32 Reserved_2 : 1; ///< Reserved.
|
---|
5349 | UINT32 ZF : 1; ///< Zero Flag.
|
---|
5350 | UINT32 SF : 1; ///< Sign Flag.
|
---|
5351 | UINT32 TF : 1; ///< Trap Flag.
|
---|
5352 | UINT32 IF : 1; ///< Interrupt Enable Flag.
|
---|
5353 | UINT32 DF : 1; ///< Direction Flag.
|
---|
5354 | UINT32 OF : 1; ///< Overflow Flag.
|
---|
5355 | UINT32 IOPL : 2; ///< I/O Privilege Level.
|
---|
5356 | UINT32 NT : 1; ///< Nested Task.
|
---|
5357 | UINT32 Reserved_3 : 1; ///< Reserved.
|
---|
5358 | UINT32 RF : 1; ///< Resume Flag.
|
---|
5359 | UINT32 VM : 1; ///< Virtual 8086 Mode.
|
---|
5360 | UINT32 AC : 1; ///< Alignment Check.
|
---|
5361 | UINT32 VIF : 1; ///< Virtual Interrupt Flag.
|
---|
5362 | UINT32 VIP : 1; ///< Virtual Interrupt Pending.
|
---|
5363 | UINT32 ID : 1; ///< ID Flag.
|
---|
5364 | UINT32 Reserved_4 : 10; ///< Reserved.
|
---|
5365 | } Bits;
|
---|
5366 | UINTN UintN;
|
---|
5367 | } IA32_EFLAGS32;
|
---|
5368 |
|
---|
5369 | ///
|
---|
5370 | /// Byte packed structure for Control Register 0 (CR0).
|
---|
5371 | /// 32-bits on IA-32.
|
---|
5372 | /// 64-bits on x64. The upper 32-bits on x64 are reserved.
|
---|
5373 | ///
|
---|
5374 | typedef union {
|
---|
5375 | struct {
|
---|
5376 | UINT32 PE : 1; ///< Protection Enable.
|
---|
5377 | UINT32 MP : 1; ///< Monitor Coprocessor.
|
---|
5378 | UINT32 EM : 1; ///< Emulation.
|
---|
5379 | UINT32 TS : 1; ///< Task Switched.
|
---|
5380 | UINT32 ET : 1; ///< Extension Type.
|
---|
5381 | UINT32 NE : 1; ///< Numeric Error.
|
---|
5382 | UINT32 Reserved_0 : 10; ///< Reserved.
|
---|
5383 | UINT32 WP : 1; ///< Write Protect.
|
---|
5384 | UINT32 Reserved_1 : 1; ///< Reserved.
|
---|
5385 | UINT32 AM : 1; ///< Alignment Mask.
|
---|
5386 | UINT32 Reserved_2 : 10; ///< Reserved.
|
---|
5387 | UINT32 NW : 1; ///< Mot Write-through.
|
---|
5388 | UINT32 CD : 1; ///< Cache Disable.
|
---|
5389 | UINT32 PG : 1; ///< Paging.
|
---|
5390 | } Bits;
|
---|
5391 | UINTN UintN;
|
---|
5392 | } IA32_CR0;
|
---|
5393 |
|
---|
5394 | ///
|
---|
5395 | /// Byte packed structure for Control Register 4 (CR4).
|
---|
5396 | /// 32-bits on IA-32.
|
---|
5397 | /// 64-bits on x64. The upper 32-bits on x64 are reserved.
|
---|
5398 | ///
|
---|
5399 | typedef union {
|
---|
5400 | struct {
|
---|
5401 | UINT32 VME : 1; ///< Virtual-8086 Mode Extensions.
|
---|
5402 | UINT32 PVI : 1; ///< Protected-Mode Virtual Interrupts.
|
---|
5403 | UINT32 TSD : 1; ///< Time Stamp Disable.
|
---|
5404 | UINT32 DE : 1; ///< Debugging Extensions.
|
---|
5405 | UINT32 PSE : 1; ///< Page Size Extensions.
|
---|
5406 | UINT32 PAE : 1; ///< Physical Address Extension.
|
---|
5407 | UINT32 MCE : 1; ///< Machine Check Enable.
|
---|
5408 | UINT32 PGE : 1; ///< Page Global Enable.
|
---|
5409 | UINT32 PCE : 1; ///< Performance Monitoring Counter
|
---|
5410 | ///< Enable.
|
---|
5411 | UINT32 OSFXSR : 1; ///< Operating System Support for
|
---|
5412 | ///< FXSAVE and FXRSTOR instructions
|
---|
5413 | UINT32 OSXMMEXCPT : 1; ///< Operating System Support for
|
---|
5414 | ///< Unmasked SIMD Floating Point
|
---|
5415 | ///< Exceptions.
|
---|
5416 | UINT32 UMIP : 1; ///< User-Mode Instruction Prevention.
|
---|
5417 | UINT32 LA57 : 1; ///< Linear Address 57bit.
|
---|
5418 | UINT32 VMXE : 1; ///< VMX Enable.
|
---|
5419 | UINT32 SMXE : 1; ///< SMX Enable.
|
---|
5420 | UINT32 Reserved_3 : 1; ///< Reserved.
|
---|
5421 | UINT32 FSGSBASE : 1; ///< FSGSBASE Enable.
|
---|
5422 | UINT32 PCIDE : 1; ///< PCID Enable.
|
---|
5423 | UINT32 OSXSAVE : 1; ///< XSAVE and Processor Extended States Enable.
|
---|
5424 | UINT32 Reserved_4 : 1; ///< Reserved.
|
---|
5425 | UINT32 SMEP : 1; ///< SMEP Enable.
|
---|
5426 | UINT32 SMAP : 1; ///< SMAP Enable.
|
---|
5427 | UINT32 PKE : 1; ///< Protection-Key Enable.
|
---|
5428 | UINT32 Reserved_5 : 9; ///< Reserved.
|
---|
5429 | } Bits;
|
---|
5430 | UINTN UintN;
|
---|
5431 | } IA32_CR4;
|
---|
5432 |
|
---|
5433 | ///
|
---|
5434 | /// Byte packed structure for a segment descriptor in a GDT/LDT.
|
---|
5435 | ///
|
---|
5436 | typedef union {
|
---|
5437 | struct {
|
---|
5438 | UINT32 LimitLow : 16;
|
---|
5439 | UINT32 BaseLow : 16;
|
---|
5440 | UINT32 BaseMid : 8;
|
---|
5441 | UINT32 Type : 4;
|
---|
5442 | UINT32 S : 1;
|
---|
5443 | UINT32 DPL : 2;
|
---|
5444 | UINT32 P : 1;
|
---|
5445 | UINT32 LimitHigh : 4;
|
---|
5446 | UINT32 AVL : 1;
|
---|
5447 | UINT32 L : 1;
|
---|
5448 | UINT32 DB : 1;
|
---|
5449 | UINT32 G : 1;
|
---|
5450 | UINT32 BaseHigh : 8;
|
---|
5451 | } Bits;
|
---|
5452 | UINT64 Uint64;
|
---|
5453 | } IA32_SEGMENT_DESCRIPTOR;
|
---|
5454 |
|
---|
5455 | ///
|
---|
5456 | /// Byte packed structure for an IDTR, GDTR, LDTR descriptor.
|
---|
5457 | ///
|
---|
5458 | #pragma pack (1)
|
---|
5459 | typedef struct {
|
---|
5460 | UINT16 Limit;
|
---|
5461 | UINTN Base;
|
---|
5462 | } IA32_DESCRIPTOR;
|
---|
5463 | #pragma pack ()
|
---|
5464 |
|
---|
5465 | #define IA32_IDT_GATE_TYPE_TASK 0x85
|
---|
5466 | #define IA32_IDT_GATE_TYPE_INTERRUPT_16 0x86
|
---|
5467 | #define IA32_IDT_GATE_TYPE_TRAP_16 0x87
|
---|
5468 | #define IA32_IDT_GATE_TYPE_INTERRUPT_32 0x8E
|
---|
5469 | #define IA32_IDT_GATE_TYPE_TRAP_32 0x8F
|
---|
5470 |
|
---|
5471 | #define IA32_GDT_TYPE_TSS 0x9
|
---|
5472 | #define IA32_GDT_ALIGNMENT 8
|
---|
5473 |
|
---|
5474 | #if defined (MDE_CPU_IA32)
|
---|
5475 | ///
|
---|
5476 | /// Byte packed structure for an IA-32 Interrupt Gate Descriptor.
|
---|
5477 | ///
|
---|
5478 | typedef union {
|
---|
5479 | struct {
|
---|
5480 | UINT32 OffsetLow : 16; ///< Offset bits 15..0.
|
---|
5481 | UINT32 Selector : 16; ///< Selector.
|
---|
5482 | UINT32 Reserved_0 : 8; ///< Reserved.
|
---|
5483 | UINT32 GateType : 8; ///< Gate Type. See #defines above.
|
---|
5484 | UINT32 OffsetHigh : 16; ///< Offset bits 31..16.
|
---|
5485 | } Bits;
|
---|
5486 | UINT64 Uint64;
|
---|
5487 | } IA32_IDT_GATE_DESCRIPTOR;
|
---|
5488 |
|
---|
5489 | #pragma pack (1)
|
---|
5490 | //
|
---|
5491 | // IA32 Task-State Segment Definition
|
---|
5492 | //
|
---|
5493 | typedef struct {
|
---|
5494 | UINT16 PreviousTaskLink;
|
---|
5495 | UINT16 Reserved_2;
|
---|
5496 | UINT32 ESP0;
|
---|
5497 | UINT16 SS0;
|
---|
5498 | UINT16 Reserved_10;
|
---|
5499 | UINT32 ESP1;
|
---|
5500 | UINT16 SS1;
|
---|
5501 | UINT16 Reserved_18;
|
---|
5502 | UINT32 ESP2;
|
---|
5503 | UINT16 SS2;
|
---|
5504 | UINT16 Reserved_26;
|
---|
5505 | UINT32 CR3;
|
---|
5506 | UINT32 EIP;
|
---|
5507 | UINT32 EFLAGS;
|
---|
5508 | UINT32 EAX;
|
---|
5509 | UINT32 ECX;
|
---|
5510 | UINT32 EDX;
|
---|
5511 | UINT32 EBX;
|
---|
5512 | UINT32 ESP;
|
---|
5513 | UINT32 EBP;
|
---|
5514 | UINT32 ESI;
|
---|
5515 | UINT32 EDI;
|
---|
5516 | UINT16 ES;
|
---|
5517 | UINT16 Reserved_74;
|
---|
5518 | UINT16 CS;
|
---|
5519 | UINT16 Reserved_78;
|
---|
5520 | UINT16 SS;
|
---|
5521 | UINT16 Reserved_82;
|
---|
5522 | UINT16 DS;
|
---|
5523 | UINT16 Reserved_86;
|
---|
5524 | UINT16 FS;
|
---|
5525 | UINT16 Reserved_90;
|
---|
5526 | UINT16 GS;
|
---|
5527 | UINT16 Reserved_94;
|
---|
5528 | UINT16 LDTSegmentSelector;
|
---|
5529 | UINT16 Reserved_98;
|
---|
5530 | UINT16 T;
|
---|
5531 | UINT16 IOMapBaseAddress;
|
---|
5532 | } IA32_TASK_STATE_SEGMENT;
|
---|
5533 |
|
---|
5534 | typedef union {
|
---|
5535 | struct {
|
---|
5536 | UINT32 LimitLow : 16; ///< Segment Limit 15..00
|
---|
5537 | UINT32 BaseLow : 16; ///< Base Address 15..00
|
---|
5538 | UINT32 BaseMid : 8; ///< Base Address 23..16
|
---|
5539 | UINT32 Type : 4; ///< Type (1 0 B 1)
|
---|
5540 | UINT32 Reserved_43 : 1; ///< 0
|
---|
5541 | UINT32 DPL : 2; ///< Descriptor Privilege Level
|
---|
5542 | UINT32 P : 1; ///< Segment Present
|
---|
5543 | UINT32 LimitHigh : 4; ///< Segment Limit 19..16
|
---|
5544 | UINT32 AVL : 1; ///< Available for use by system software
|
---|
5545 | UINT32 Reserved_52 : 2; ///< 0 0
|
---|
5546 | UINT32 G : 1; ///< Granularity
|
---|
5547 | UINT32 BaseHigh : 8; ///< Base Address 31..24
|
---|
5548 | } Bits;
|
---|
5549 | UINT64 Uint64;
|
---|
5550 | } IA32_TSS_DESCRIPTOR;
|
---|
5551 | #pragma pack ()
|
---|
5552 |
|
---|
5553 | #endif // defined (MDE_CPU_IA32)
|
---|
5554 |
|
---|
5555 | #if defined (MDE_CPU_X64)
|
---|
5556 | ///
|
---|
5557 | /// Byte packed structure for an x64 Interrupt Gate Descriptor.
|
---|
5558 | ///
|
---|
5559 | typedef union {
|
---|
5560 | struct {
|
---|
5561 | UINT32 OffsetLow : 16; ///< Offset bits 15..0.
|
---|
5562 | UINT32 Selector : 16; ///< Selector.
|
---|
5563 | UINT32 Reserved_0 : 8; ///< Reserved.
|
---|
5564 | UINT32 GateType : 8; ///< Gate Type. See #defines above.
|
---|
5565 | UINT32 OffsetHigh : 16; ///< Offset bits 31..16.
|
---|
5566 | UINT32 OffsetUpper : 32; ///< Offset bits 63..32.
|
---|
5567 | UINT32 Reserved_1 : 32; ///< Reserved.
|
---|
5568 | } Bits;
|
---|
5569 | struct {
|
---|
5570 | UINT64 Uint64;
|
---|
5571 | UINT64 Uint64_1;
|
---|
5572 | } Uint128;
|
---|
5573 | } IA32_IDT_GATE_DESCRIPTOR;
|
---|
5574 |
|
---|
5575 | #pragma pack (1)
|
---|
5576 | //
|
---|
5577 | // IA32 Task-State Segment Definition
|
---|
5578 | //
|
---|
5579 | typedef struct {
|
---|
5580 | UINT32 Reserved_0;
|
---|
5581 | UINT64 RSP0;
|
---|
5582 | UINT64 RSP1;
|
---|
5583 | UINT64 RSP2;
|
---|
5584 | UINT64 Reserved_28;
|
---|
5585 | UINT64 IST[7];
|
---|
5586 | UINT64 Reserved_92;
|
---|
5587 | UINT16 Reserved_100;
|
---|
5588 | UINT16 IOMapBaseAddress;
|
---|
5589 | } IA32_TASK_STATE_SEGMENT;
|
---|
5590 |
|
---|
5591 | typedef union {
|
---|
5592 | struct {
|
---|
5593 | UINT32 LimitLow : 16; ///< Segment Limit 15..00
|
---|
5594 | UINT32 BaseLow : 16; ///< Base Address 15..00
|
---|
5595 | UINT32 BaseMidl : 8; ///< Base Address 23..16
|
---|
5596 | UINT32 Type : 4; ///< Type (1 0 B 1)
|
---|
5597 | UINT32 Reserved_43 : 1; ///< 0
|
---|
5598 | UINT32 DPL : 2; ///< Descriptor Privilege Level
|
---|
5599 | UINT32 P : 1; ///< Segment Present
|
---|
5600 | UINT32 LimitHigh : 4; ///< Segment Limit 19..16
|
---|
5601 | UINT32 AVL : 1; ///< Available for use by system software
|
---|
5602 | UINT32 Reserved_52 : 2; ///< 0 0
|
---|
5603 | UINT32 G : 1; ///< Granularity
|
---|
5604 | UINT32 BaseMidh : 8; ///< Base Address 31..24
|
---|
5605 | UINT32 BaseHigh : 32; ///< Base Address 63..32
|
---|
5606 | UINT32 Reserved_96 : 32; ///< Reserved
|
---|
5607 | } Bits;
|
---|
5608 | struct {
|
---|
5609 | UINT64 Uint64;
|
---|
5610 | UINT64 Uint64_1;
|
---|
5611 | } Uint128;
|
---|
5612 | } IA32_TSS_DESCRIPTOR;
|
---|
5613 | #pragma pack ()
|
---|
5614 |
|
---|
5615 | #endif // defined (MDE_CPU_X64)
|
---|
5616 |
|
---|
5617 | ///
|
---|
5618 | /// Byte packed structure for an FP/SSE/SSE2 context.
|
---|
5619 | ///
|
---|
5620 | typedef struct {
|
---|
5621 | UINT8 Buffer[512];
|
---|
5622 | } IA32_FX_BUFFER;
|
---|
5623 |
|
---|
5624 | ///
|
---|
5625 | /// Structures for the 16-bit real mode thunks.
|
---|
5626 | ///
|
---|
5627 | typedef struct {
|
---|
5628 | UINT32 Reserved1;
|
---|
5629 | UINT32 Reserved2;
|
---|
5630 | UINT32 Reserved3;
|
---|
5631 | UINT32 Reserved4;
|
---|
5632 | UINT8 BL;
|
---|
5633 | UINT8 BH;
|
---|
5634 | UINT16 Reserved5;
|
---|
5635 | UINT8 DL;
|
---|
5636 | UINT8 DH;
|
---|
5637 | UINT16 Reserved6;
|
---|
5638 | UINT8 CL;
|
---|
5639 | UINT8 CH;
|
---|
5640 | UINT16 Reserved7;
|
---|
5641 | UINT8 AL;
|
---|
5642 | UINT8 AH;
|
---|
5643 | UINT16 Reserved8;
|
---|
5644 | } IA32_BYTE_REGS;
|
---|
5645 |
|
---|
5646 | typedef struct {
|
---|
5647 | UINT16 DI;
|
---|
5648 | UINT16 Reserved1;
|
---|
5649 | UINT16 SI;
|
---|
5650 | UINT16 Reserved2;
|
---|
5651 | UINT16 BP;
|
---|
5652 | UINT16 Reserved3;
|
---|
5653 | UINT16 SP;
|
---|
5654 | UINT16 Reserved4;
|
---|
5655 | UINT16 BX;
|
---|
5656 | UINT16 Reserved5;
|
---|
5657 | UINT16 DX;
|
---|
5658 | UINT16 Reserved6;
|
---|
5659 | UINT16 CX;
|
---|
5660 | UINT16 Reserved7;
|
---|
5661 | UINT16 AX;
|
---|
5662 | UINT16 Reserved8;
|
---|
5663 | } IA32_WORD_REGS;
|
---|
5664 |
|
---|
5665 | typedef struct {
|
---|
5666 | UINT32 EDI;
|
---|
5667 | UINT32 ESI;
|
---|
5668 | UINT32 EBP;
|
---|
5669 | UINT32 ESP;
|
---|
5670 | UINT32 EBX;
|
---|
5671 | UINT32 EDX;
|
---|
5672 | UINT32 ECX;
|
---|
5673 | UINT32 EAX;
|
---|
5674 | UINT16 DS;
|
---|
5675 | UINT16 ES;
|
---|
5676 | UINT16 FS;
|
---|
5677 | UINT16 GS;
|
---|
5678 | IA32_EFLAGS32 EFLAGS;
|
---|
5679 | UINT32 Eip;
|
---|
5680 | UINT16 CS;
|
---|
5681 | UINT16 SS;
|
---|
5682 | } IA32_DWORD_REGS;
|
---|
5683 |
|
---|
5684 | typedef union {
|
---|
5685 | IA32_DWORD_REGS E;
|
---|
5686 | IA32_WORD_REGS X;
|
---|
5687 | IA32_BYTE_REGS H;
|
---|
5688 | } IA32_REGISTER_SET;
|
---|
5689 |
|
---|
5690 | ///
|
---|
5691 | /// Byte packed structure for an 16-bit real mode thunks.
|
---|
5692 | ///
|
---|
5693 | typedef struct {
|
---|
5694 | IA32_REGISTER_SET *RealModeState;
|
---|
5695 | VOID *RealModeBuffer;
|
---|
5696 | UINT32 RealModeBufferSize;
|
---|
5697 | UINT32 ThunkAttributes;
|
---|
5698 | } THUNK_CONTEXT;
|
---|
5699 |
|
---|
5700 | #define THUNK_ATTRIBUTE_BIG_REAL_MODE 0x00000001
|
---|
5701 | #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 0x00000002
|
---|
5702 | #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004
|
---|
5703 |
|
---|
5704 | ///
|
---|
5705 | /// Type definition for representing labels in NASM source code that allow for
|
---|
5706 | /// the patching of immediate operands of IA32 and X64 instructions.
|
---|
5707 | ///
|
---|
5708 | /// While the type is technically defined as a function type (note: not a
|
---|
5709 | /// pointer-to-function type), such labels in NASM source code never stand for
|
---|
5710 | /// actual functions, and identifiers declared with this function type should
|
---|
5711 | /// never be called. This is also why the EFIAPI calling convention specifier
|
---|
5712 | /// is missing from the typedef, and why the typedef does not follow the usual
|
---|
5713 | /// edk2 coding style for function (or pointer-to-function) typedefs. The VOID
|
---|
5714 | /// return type and the VOID argument list are merely artifacts.
|
---|
5715 | ///
|
---|
5716 | typedef VOID (X86_ASSEMBLY_PATCH_LABEL) (
|
---|
5717 | VOID
|
---|
5718 | );
|
---|
5719 |
|
---|
5720 | /**
|
---|
5721 | Retrieves CPUID information.
|
---|
5722 |
|
---|
5723 | Executes the CPUID instruction with EAX set to the value specified by Index.
|
---|
5724 | This function always returns Index.
|
---|
5725 | If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
|
---|
5726 | If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
|
---|
5727 | If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
|
---|
5728 | If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
|
---|
5729 | This function is only available on IA-32 and x64.
|
---|
5730 |
|
---|
5731 | @param Index The 32-bit value to load into EAX prior to invoking the CPUID
|
---|
5732 | instruction.
|
---|
5733 | @param Eax The pointer to the 32-bit EAX value returned by the CPUID
|
---|
5734 | instruction. This is an optional parameter that may be NULL.
|
---|
5735 | @param Ebx The pointer to the 32-bit EBX value returned by the CPUID
|
---|
5736 | instruction. This is an optional parameter that may be NULL.
|
---|
5737 | @param Ecx The pointer to the 32-bit ECX value returned by the CPUID
|
---|
5738 | instruction. This is an optional parameter that may be NULL.
|
---|
5739 | @param Edx The pointer to the 32-bit EDX value returned by the CPUID
|
---|
5740 | instruction. This is an optional parameter that may be NULL.
|
---|
5741 |
|
---|
5742 | @return Index.
|
---|
5743 |
|
---|
5744 | **/
|
---|
5745 | UINT32
|
---|
5746 | EFIAPI
|
---|
5747 | AsmCpuid (
|
---|
5748 | IN UINT32 Index,
|
---|
5749 | OUT UINT32 *Eax OPTIONAL,
|
---|
5750 | OUT UINT32 *Ebx OPTIONAL,
|
---|
5751 | OUT UINT32 *Ecx OPTIONAL,
|
---|
5752 | OUT UINT32 *Edx OPTIONAL
|
---|
5753 | );
|
---|
5754 |
|
---|
5755 | /**
|
---|
5756 | Retrieves CPUID information using an extended leaf identifier.
|
---|
5757 |
|
---|
5758 | Executes the CPUID instruction with EAX set to the value specified by Index
|
---|
5759 | and ECX set to the value specified by SubIndex. This function always returns
|
---|
5760 | Index. This function is only available on IA-32 and x64.
|
---|
5761 |
|
---|
5762 | If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
|
---|
5763 | If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
|
---|
5764 | If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
|
---|
5765 | If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
|
---|
5766 |
|
---|
5767 | @param Index The 32-bit value to load into EAX prior to invoking the
|
---|
5768 | CPUID instruction.
|
---|
5769 | @param SubIndex The 32-bit value to load into ECX prior to invoking the
|
---|
5770 | CPUID instruction.
|
---|
5771 | @param Eax The pointer to the 32-bit EAX value returned by the CPUID
|
---|
5772 | instruction. This is an optional parameter that may be
|
---|
5773 | NULL.
|
---|
5774 | @param Ebx The pointer to the 32-bit EBX value returned by the CPUID
|
---|
5775 | instruction. This is an optional parameter that may be
|
---|
5776 | NULL.
|
---|
5777 | @param Ecx The pointer to the 32-bit ECX value returned by the CPUID
|
---|
5778 | instruction. This is an optional parameter that may be
|
---|
5779 | NULL.
|
---|
5780 | @param Edx The pointer to the 32-bit EDX value returned by the CPUID
|
---|
5781 | instruction. This is an optional parameter that may be
|
---|
5782 | NULL.
|
---|
5783 |
|
---|
5784 | @return Index.
|
---|
5785 |
|
---|
5786 | **/
|
---|
5787 | UINT32
|
---|
5788 | EFIAPI
|
---|
5789 | AsmCpuidEx (
|
---|
5790 | IN UINT32 Index,
|
---|
5791 | IN UINT32 SubIndex,
|
---|
5792 | OUT UINT32 *Eax OPTIONAL,
|
---|
5793 | OUT UINT32 *Ebx OPTIONAL,
|
---|
5794 | OUT UINT32 *Ecx OPTIONAL,
|
---|
5795 | OUT UINT32 *Edx OPTIONAL
|
---|
5796 | );
|
---|
5797 |
|
---|
5798 | /**
|
---|
5799 | Set CD bit and clear NW bit of CR0 followed by a WBINVD.
|
---|
5800 |
|
---|
5801 | Disables the caches by setting the CD bit of CR0 to 1, clearing the NW bit of CR0 to 0,
|
---|
5802 | and executing a WBINVD instruction. This function is only available on IA-32 and x64.
|
---|
5803 |
|
---|
5804 | **/
|
---|
5805 | VOID
|
---|
5806 | EFIAPI
|
---|
5807 | AsmDisableCache (
|
---|
5808 | VOID
|
---|
5809 | );
|
---|
5810 |
|
---|
5811 | /**
|
---|
5812 | Perform a WBINVD and clear both the CD and NW bits of CR0.
|
---|
5813 |
|
---|
5814 | Enables the caches by executing a WBINVD instruction and then clear both the CD and NW
|
---|
5815 | bits of CR0 to 0. This function is only available on IA-32 and x64.
|
---|
5816 |
|
---|
5817 | **/
|
---|
5818 | VOID
|
---|
5819 | EFIAPI
|
---|
5820 | AsmEnableCache (
|
---|
5821 | VOID
|
---|
5822 | );
|
---|
5823 |
|
---|
5824 | /**
|
---|
5825 | Returns the lower 32-bits of a Machine Specific Register(MSR).
|
---|
5826 |
|
---|
5827 | Reads and returns the lower 32-bits of the MSR specified by Index.
|
---|
5828 | No parameter checking is performed on Index, and some Index values may cause
|
---|
5829 | CPU exceptions. The caller must either guarantee that Index is valid, or the
|
---|
5830 | caller must set up exception handlers to catch the exceptions. This function
|
---|
5831 | is only available on IA-32 and x64.
|
---|
5832 |
|
---|
5833 | @param Index The 32-bit MSR index to read.
|
---|
5834 |
|
---|
5835 | @return The lower 32 bits of the MSR identified by Index.
|
---|
5836 |
|
---|
5837 | **/
|
---|
5838 | UINT32
|
---|
5839 | EFIAPI
|
---|
5840 | AsmReadMsr32 (
|
---|
5841 | IN UINT32 Index
|
---|
5842 | );
|
---|
5843 |
|
---|
5844 | /**
|
---|
5845 | Writes a 32-bit value to a Machine Specific Register(MSR), and returns the value.
|
---|
5846 | The upper 32-bits of the MSR are set to zero.
|
---|
5847 |
|
---|
5848 | Writes the 32-bit value specified by Value to the MSR specified by Index. The
|
---|
5849 | upper 32-bits of the MSR write are set to zero. The 32-bit value written to
|
---|
5850 | the MSR is returned. No parameter checking is performed on Index or Value,
|
---|
5851 | and some of these may cause CPU exceptions. The caller must either guarantee
|
---|
5852 | that Index and Value are valid, or the caller must establish proper exception
|
---|
5853 | handlers. This function is only available on IA-32 and x64.
|
---|
5854 |
|
---|
5855 | @param Index The 32-bit MSR index to write.
|
---|
5856 | @param Value The 32-bit value to write to the MSR.
|
---|
5857 |
|
---|
5858 | @return Value
|
---|
5859 |
|
---|
5860 | **/
|
---|
5861 | UINT32
|
---|
5862 | EFIAPI
|
---|
5863 | AsmWriteMsr32 (
|
---|
5864 | IN UINT32 Index,
|
---|
5865 | IN UINT32 Value
|
---|
5866 | );
|
---|
5867 |
|
---|
5868 | /**
|
---|
5869 | Reads a 64-bit MSR, performs a bitwise OR on the lower 32-bits, and
|
---|
5870 | writes the result back to the 64-bit MSR.
|
---|
5871 |
|
---|
5872 | Reads the 64-bit MSR specified by Index, performs a bitwise OR
|
---|
5873 | between the lower 32-bits of the read result and the value specified by
|
---|
5874 | OrData, and writes the result to the 64-bit MSR specified by Index. The lower
|
---|
5875 | 32-bits of the value written to the MSR is returned. No parameter checking is
|
---|
5876 | performed on Index or OrData, and some of these may cause CPU exceptions. The
|
---|
5877 | caller must either guarantee that Index and OrData are valid, or the caller
|
---|
5878 | must establish proper exception handlers. This function is only available on
|
---|
5879 | IA-32 and x64.
|
---|
5880 |
|
---|
5881 | @param Index The 32-bit MSR index to write.
|
---|
5882 | @param OrData The value to OR with the read value from the MSR.
|
---|
5883 |
|
---|
5884 | @return The lower 32-bit value written to the MSR.
|
---|
5885 |
|
---|
5886 | **/
|
---|
5887 | UINT32
|
---|
5888 | EFIAPI
|
---|
5889 | AsmMsrOr32 (
|
---|
5890 | IN UINT32 Index,
|
---|
5891 | IN UINT32 OrData
|
---|
5892 | );
|
---|
5893 |
|
---|
5894 | /**
|
---|
5895 | Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes
|
---|
5896 | the result back to the 64-bit MSR.
|
---|
5897 |
|
---|
5898 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
|
---|
5899 | lower 32-bits of the read result and the value specified by AndData, and
|
---|
5900 | writes the result to the 64-bit MSR specified by Index. The lower 32-bits of
|
---|
5901 | the value written to the MSR is returned. No parameter checking is performed
|
---|
5902 | on Index or AndData, and some of these may cause CPU exceptions. The caller
|
---|
5903 | must either guarantee that Index and AndData are valid, or the caller must
|
---|
5904 | establish proper exception handlers. This function is only available on IA-32
|
---|
5905 | and x64.
|
---|
5906 |
|
---|
5907 | @param Index The 32-bit MSR index to write.
|
---|
5908 | @param AndData The value to AND with the read value from the MSR.
|
---|
5909 |
|
---|
5910 | @return The lower 32-bit value written to the MSR.
|
---|
5911 |
|
---|
5912 | **/
|
---|
5913 | UINT32
|
---|
5914 | EFIAPI
|
---|
5915 | AsmMsrAnd32 (
|
---|
5916 | IN UINT32 Index,
|
---|
5917 | IN UINT32 AndData
|
---|
5918 | );
|
---|
5919 |
|
---|
5920 | /**
|
---|
5921 | Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise OR
|
---|
5922 | on the lower 32-bits, and writes the result back to the 64-bit MSR.
|
---|
5923 |
|
---|
5924 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
|
---|
5925 | lower 32-bits of the read result and the value specified by AndData
|
---|
5926 | preserving the upper 32-bits, performs a bitwise OR between the
|
---|
5927 | result of the AND operation and the value specified by OrData, and writes the
|
---|
5928 | result to the 64-bit MSR specified by Address. The lower 32-bits of the value
|
---|
5929 | written to the MSR is returned. No parameter checking is performed on Index,
|
---|
5930 | AndData, or OrData, and some of these may cause CPU exceptions. The caller
|
---|
5931 | must either guarantee that Index, AndData, and OrData are valid, or the
|
---|
5932 | caller must establish proper exception handlers. This function is only
|
---|
5933 | available on IA-32 and x64.
|
---|
5934 |
|
---|
5935 | @param Index The 32-bit MSR index to write.
|
---|
5936 | @param AndData The value to AND with the read value from the MSR.
|
---|
5937 | @param OrData The value to OR with the result of the AND operation.
|
---|
5938 |
|
---|
5939 | @return The lower 32-bit value written to the MSR.
|
---|
5940 |
|
---|
5941 | **/
|
---|
5942 | UINT32
|
---|
5943 | EFIAPI
|
---|
5944 | AsmMsrAndThenOr32 (
|
---|
5945 | IN UINT32 Index,
|
---|
5946 | IN UINT32 AndData,
|
---|
5947 | IN UINT32 OrData
|
---|
5948 | );
|
---|
5949 |
|
---|
5950 | /**
|
---|
5951 | Reads a bit field of an MSR.
|
---|
5952 |
|
---|
5953 | Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is
|
---|
5954 | specified by the StartBit and the EndBit. The value of the bit field is
|
---|
5955 | returned. The caller must either guarantee that Index is valid, or the caller
|
---|
5956 | must set up exception handlers to catch the exceptions. This function is only
|
---|
5957 | available on IA-32 and x64.
|
---|
5958 |
|
---|
5959 | If StartBit is greater than 31, then ASSERT().
|
---|
5960 | If EndBit is greater than 31, then ASSERT().
|
---|
5961 | If EndBit is less than StartBit, then ASSERT().
|
---|
5962 |
|
---|
5963 | @param Index The 32-bit MSR index to read.
|
---|
5964 | @param StartBit The ordinal of the least significant bit in the bit field.
|
---|
5965 | Range 0..31.
|
---|
5966 | @param EndBit The ordinal of the most significant bit in the bit field.
|
---|
5967 | Range 0..31.
|
---|
5968 |
|
---|
5969 | @return The bit field read from the MSR.
|
---|
5970 |
|
---|
5971 | **/
|
---|
5972 | UINT32
|
---|
5973 | EFIAPI
|
---|
5974 | AsmMsrBitFieldRead32 (
|
---|
5975 | IN UINT32 Index,
|
---|
5976 | IN UINTN StartBit,
|
---|
5977 | IN UINTN EndBit
|
---|
5978 | );
|
---|
5979 |
|
---|
5980 | /**
|
---|
5981 | Writes a bit field to an MSR.
|
---|
5982 |
|
---|
5983 | Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit
|
---|
5984 | field is specified by the StartBit and the EndBit. All other bits in the
|
---|
5985 | destination MSR are preserved. The lower 32-bits of the MSR written is
|
---|
5986 | returned. The caller must either guarantee that Index and the data written
|
---|
5987 | is valid, or the caller must set up exception handlers to catch the exceptions.
|
---|
5988 | This function is only available on IA-32 and x64.
|
---|
5989 |
|
---|
5990 | If StartBit is greater than 31, then ASSERT().
|
---|
5991 | If EndBit is greater than 31, then ASSERT().
|
---|
5992 | If EndBit is less than StartBit, then ASSERT().
|
---|
5993 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
|
---|
5994 |
|
---|
5995 | @param Index The 32-bit MSR index to write.
|
---|
5996 | @param StartBit The ordinal of the least significant bit in the bit field.
|
---|
5997 | Range 0..31.
|
---|
5998 | @param EndBit The ordinal of the most significant bit in the bit field.
|
---|
5999 | Range 0..31.
|
---|
6000 | @param Value New value of the bit field.
|
---|
6001 |
|
---|
6002 | @return The lower 32-bit of the value written to the MSR.
|
---|
6003 |
|
---|
6004 | **/
|
---|
6005 | UINT32
|
---|
6006 | EFIAPI
|
---|
6007 | AsmMsrBitFieldWrite32 (
|
---|
6008 | IN UINT32 Index,
|
---|
6009 | IN UINTN StartBit,
|
---|
6010 | IN UINTN EndBit,
|
---|
6011 | IN UINT32 Value
|
---|
6012 | );
|
---|
6013 |
|
---|
6014 | /**
|
---|
6015 | Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the
|
---|
6016 | result back to the bit field in the 64-bit MSR.
|
---|
6017 |
|
---|
6018 | Reads the 64-bit MSR specified by Index, performs a bitwise OR
|
---|
6019 | between the read result and the value specified by OrData, and writes the
|
---|
6020 | result to the 64-bit MSR specified by Index. The lower 32-bits of the value
|
---|
6021 | written to the MSR are returned. Extra left bits in OrData are stripped. The
|
---|
6022 | caller must either guarantee that Index and the data written is valid, or
|
---|
6023 | the caller must set up exception handlers to catch the exceptions. This
|
---|
6024 | function is only available on IA-32 and x64.
|
---|
6025 |
|
---|
6026 | If StartBit is greater than 31, then ASSERT().
|
---|
6027 | If EndBit is greater than 31, then ASSERT().
|
---|
6028 | If EndBit is less than StartBit, then ASSERT().
|
---|
6029 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
|
---|
6030 |
|
---|
6031 | @param Index The 32-bit MSR index to write.
|
---|
6032 | @param StartBit The ordinal of the least significant bit in the bit field.
|
---|
6033 | Range 0..31.
|
---|
6034 | @param EndBit The ordinal of the most significant bit in the bit field.
|
---|
6035 | Range 0..31.
|
---|
6036 | @param OrData The value to OR with the read value from the MSR.
|
---|
6037 |
|
---|
6038 | @return The lower 32-bit of the value written to the MSR.
|
---|
6039 |
|
---|
6040 | **/
|
---|
6041 | UINT32
|
---|
6042 | EFIAPI
|
---|
6043 | AsmMsrBitFieldOr32 (
|
---|
6044 | IN UINT32 Index,
|
---|
6045 | IN UINTN StartBit,
|
---|
6046 | IN UINTN EndBit,
|
---|
6047 | IN UINT32 OrData
|
---|
6048 | );
|
---|
6049 |
|
---|
6050 | /**
|
---|
6051 | Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
|
---|
6052 | result back to the bit field in the 64-bit MSR.
|
---|
6053 |
|
---|
6054 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
|
---|
6055 | read result and the value specified by AndData, and writes the result to the
|
---|
6056 | 64-bit MSR specified by Index. The lower 32-bits of the value written to the
|
---|
6057 | MSR are returned. Extra left bits in AndData are stripped. The caller must
|
---|
6058 | either guarantee that Index and the data written is valid, or the caller must
|
---|
6059 | set up exception handlers to catch the exceptions. This function is only
|
---|
6060 | available on IA-32 and x64.
|
---|
6061 |
|
---|
6062 | If StartBit is greater than 31, then ASSERT().
|
---|
6063 | If EndBit is greater than 31, then ASSERT().
|
---|
6064 | If EndBit is less than StartBit, then ASSERT().
|
---|
6065 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
|
---|
6066 |
|
---|
6067 | @param Index The 32-bit MSR index to write.
|
---|
6068 | @param StartBit The ordinal of the least significant bit in the bit field.
|
---|
6069 | Range 0..31.
|
---|
6070 | @param EndBit The ordinal of the most significant bit in the bit field.
|
---|
6071 | Range 0..31.
|
---|
6072 | @param AndData The value to AND with the read value from the MSR.
|
---|
6073 |
|
---|
6074 | @return The lower 32-bit of the value written to the MSR.
|
---|
6075 |
|
---|
6076 | **/
|
---|
6077 | UINT32
|
---|
6078 | EFIAPI
|
---|
6079 | AsmMsrBitFieldAnd32 (
|
---|
6080 | IN UINT32 Index,
|
---|
6081 | IN UINTN StartBit,
|
---|
6082 | IN UINTN EndBit,
|
---|
6083 | IN UINT32 AndData
|
---|
6084 | );
|
---|
6085 |
|
---|
6086 | /**
|
---|
6087 | Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
|
---|
6088 | bitwise OR, and writes the result back to the bit field in the
|
---|
6089 | 64-bit MSR.
|
---|
6090 |
|
---|
6091 | Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a
|
---|
6092 | bitwise OR between the read result and the value specified by
|
---|
6093 | AndData, and writes the result to the 64-bit MSR specified by Index. The
|
---|
6094 | lower 32-bits of the value written to the MSR are returned. Extra left bits
|
---|
6095 | in both AndData and OrData are stripped. The caller must either guarantee
|
---|
6096 | that Index and the data written is valid, or the caller must set up exception
|
---|
6097 | handlers to catch the exceptions. This function is only available on IA-32
|
---|
6098 | and x64.
|
---|
6099 |
|
---|
6100 | If StartBit is greater than 31, then ASSERT().
|
---|
6101 | If EndBit is greater than 31, then ASSERT().
|
---|
6102 | If EndBit is less than StartBit, then ASSERT().
|
---|
6103 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
|
---|
6104 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
|
---|
6105 |
|
---|
6106 | @param Index The 32-bit MSR index to write.
|
---|
6107 | @param StartBit The ordinal of the least significant bit in the bit field.
|
---|
6108 | Range 0..31.
|
---|
6109 | @param EndBit The ordinal of the most significant bit in the bit field.
|
---|
6110 | Range 0..31.
|
---|
6111 | @param AndData The value to AND with the read value from the MSR.
|
---|
6112 | @param OrData The value to OR with the result of the AND operation.
|
---|
6113 |
|
---|
6114 | @return The lower 32-bit of the value written to the MSR.
|
---|
6115 |
|
---|
6116 | **/
|
---|
6117 | UINT32
|
---|
6118 | EFIAPI
|
---|
6119 | AsmMsrBitFieldAndThenOr32 (
|
---|
6120 | IN UINT32 Index,
|
---|
6121 | IN UINTN StartBit,
|
---|
6122 | IN UINTN EndBit,
|
---|
6123 | IN UINT32 AndData,
|
---|
6124 | IN UINT32 OrData
|
---|
6125 | );
|
---|
6126 |
|
---|
6127 | /**
|
---|
6128 | Returns a 64-bit Machine Specific Register(MSR).
|
---|
6129 |
|
---|
6130 | Reads and returns the 64-bit MSR specified by Index. No parameter checking is
|
---|
6131 | performed on Index, and some Index values may cause CPU exceptions. The
|
---|
6132 | caller must either guarantee that Index is valid, or the caller must set up
|
---|
6133 | exception handlers to catch the exceptions. This function is only available
|
---|
6134 | on IA-32 and x64.
|
---|
6135 |
|
---|
6136 | @param Index The 32-bit MSR index to read.
|
---|
6137 |
|
---|
6138 | @return The value of the MSR identified by Index.
|
---|
6139 |
|
---|
6140 | **/
|
---|
6141 | UINT64
|
---|
6142 | EFIAPI
|
---|
6143 | AsmReadMsr64 (
|
---|
6144 | IN UINT32 Index
|
---|
6145 | );
|
---|
6146 |
|
---|
6147 | /**
|
---|
6148 | Writes a 64-bit value to a Machine Specific Register(MSR), and returns the
|
---|
6149 | value.
|
---|
6150 |
|
---|
6151 | Writes the 64-bit value specified by Value to the MSR specified by Index. The
|
---|
6152 | 64-bit value written to the MSR is returned. No parameter checking is
|
---|
6153 | performed on Index or Value, and some of these may cause CPU exceptions. The
|
---|
6154 | caller must either guarantee that Index and Value are valid, or the caller
|
---|
6155 | must establish proper exception handlers. This function is only available on
|
---|
6156 | IA-32 and x64.
|
---|
6157 |
|
---|
6158 | @param Index The 32-bit MSR index to write.
|
---|
6159 | @param Value The 64-bit value to write to the MSR.
|
---|
6160 |
|
---|
6161 | @return Value
|
---|
6162 |
|
---|
6163 | **/
|
---|
6164 | UINT64
|
---|
6165 | EFIAPI
|
---|
6166 | AsmWriteMsr64 (
|
---|
6167 | IN UINT32 Index,
|
---|
6168 | IN UINT64 Value
|
---|
6169 | );
|
---|
6170 |
|
---|
6171 | /**
|
---|
6172 | Reads a 64-bit MSR, performs a bitwise OR, and writes the result
|
---|
6173 | back to the 64-bit MSR.
|
---|
6174 |
|
---|
6175 | Reads the 64-bit MSR specified by Index, performs a bitwise OR
|
---|
6176 | between the read result and the value specified by OrData, and writes the
|
---|
6177 | result to the 64-bit MSR specified by Index. The value written to the MSR is
|
---|
6178 | returned. No parameter checking is performed on Index or OrData, and some of
|
---|
6179 | these may cause CPU exceptions. The caller must either guarantee that Index
|
---|
6180 | and OrData are valid, or the caller must establish proper exception handlers.
|
---|
6181 | This function is only available on IA-32 and x64.
|
---|
6182 |
|
---|
6183 | @param Index The 32-bit MSR index to write.
|
---|
6184 | @param OrData The value to OR with the read value from the MSR.
|
---|
6185 |
|
---|
6186 | @return The value written back to the MSR.
|
---|
6187 |
|
---|
6188 | **/
|
---|
6189 | UINT64
|
---|
6190 | EFIAPI
|
---|
6191 | AsmMsrOr64 (
|
---|
6192 | IN UINT32 Index,
|
---|
6193 | IN UINT64 OrData
|
---|
6194 | );
|
---|
6195 |
|
---|
6196 | /**
|
---|
6197 | Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the
|
---|
6198 | 64-bit MSR.
|
---|
6199 |
|
---|
6200 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
|
---|
6201 | read result and the value specified by OrData, and writes the result to the
|
---|
6202 | 64-bit MSR specified by Index. The value written to the MSR is returned. No
|
---|
6203 | parameter checking is performed on Index or OrData, and some of these may
|
---|
6204 | cause CPU exceptions. The caller must either guarantee that Index and OrData
|
---|
6205 | are valid, or the caller must establish proper exception handlers. This
|
---|
6206 | function is only available on IA-32 and x64.
|
---|
6207 |
|
---|
6208 | @param Index The 32-bit MSR index to write.
|
---|
6209 | @param AndData The value to AND with the read value from the MSR.
|
---|
6210 |
|
---|
6211 | @return The value written back to the MSR.
|
---|
6212 |
|
---|
6213 | **/
|
---|
6214 | UINT64
|
---|
6215 | EFIAPI
|
---|
6216 | AsmMsrAnd64 (
|
---|
6217 | IN UINT32 Index,
|
---|
6218 | IN UINT64 AndData
|
---|
6219 | );
|
---|
6220 |
|
---|
6221 | /**
|
---|
6222 | Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise
|
---|
6223 | OR, and writes the result back to the 64-bit MSR.
|
---|
6224 |
|
---|
6225 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between read
|
---|
6226 | result and the value specified by AndData, performs a bitwise OR
|
---|
6227 | between the result of the AND operation and the value specified by OrData,
|
---|
6228 | and writes the result to the 64-bit MSR specified by Index. The value written
|
---|
6229 | to the MSR is returned. No parameter checking is performed on Index, AndData,
|
---|
6230 | or OrData, and some of these may cause CPU exceptions. The caller must either
|
---|
6231 | guarantee that Index, AndData, and OrData are valid, or the caller must
|
---|
6232 | establish proper exception handlers. This function is only available on IA-32
|
---|
6233 | and x64.
|
---|
6234 |
|
---|
6235 | @param Index The 32-bit MSR index to write.
|
---|
6236 | @param AndData The value to AND with the read value from the MSR.
|
---|
6237 | @param OrData The value to OR with the result of the AND operation.
|
---|
6238 |
|
---|
6239 | @return The value written back to the MSR.
|
---|
6240 |
|
---|
6241 | **/
|
---|
6242 | UINT64
|
---|
6243 | EFIAPI
|
---|
6244 | AsmMsrAndThenOr64 (
|
---|
6245 | IN UINT32 Index,
|
---|
6246 | IN UINT64 AndData,
|
---|
6247 | IN UINT64 OrData
|
---|
6248 | );
|
---|
6249 |
|
---|
6250 | /**
|
---|
6251 | Reads a bit field of an MSR.
|
---|
6252 |
|
---|
6253 | Reads the bit field in the 64-bit MSR. The bit field is specified by the
|
---|
6254 | StartBit and the EndBit. The value of the bit field is returned. The caller
|
---|
6255 | must either guarantee that Index is valid, or the caller must set up
|
---|
6256 | exception handlers to catch the exceptions. This function is only available
|
---|
6257 | on IA-32 and x64.
|
---|
6258 |
|
---|
6259 | If StartBit is greater than 63, then ASSERT().
|
---|
6260 | If EndBit is greater than 63, then ASSERT().
|
---|
6261 | If EndBit is less than StartBit, then ASSERT().
|
---|
6262 |
|
---|
6263 | @param Index The 32-bit MSR index to read.
|
---|
6264 | @param StartBit The ordinal of the least significant bit in the bit field.
|
---|
6265 | Range 0..63.
|
---|
6266 | @param EndBit The ordinal of the most significant bit in the bit field.
|
---|
6267 | Range 0..63.
|
---|
6268 |
|
---|
6269 | @return The value read from the MSR.
|
---|
6270 |
|
---|
6271 | **/
|
---|
6272 | UINT64
|
---|
6273 | EFIAPI
|
---|
6274 | AsmMsrBitFieldRead64 (
|
---|
6275 | IN UINT32 Index,
|
---|
6276 | IN UINTN StartBit,
|
---|
6277 | IN UINTN EndBit
|
---|
6278 | );
|
---|
6279 |
|
---|
6280 | /**
|
---|
6281 | Writes a bit field to an MSR.
|
---|
6282 |
|
---|
6283 | Writes Value to a bit field in a 64-bit MSR. The bit field is specified by
|
---|
6284 | the StartBit and the EndBit. All other bits in the destination MSR are
|
---|
6285 | preserved. The MSR written is returned. The caller must either guarantee
|
---|
6286 | that Index and the data written is valid, or the caller must set up exception
|
---|
6287 | handlers to catch the exceptions. This function is only available on IA-32 and x64.
|
---|
6288 |
|
---|
6289 | If StartBit is greater than 63, then ASSERT().
|
---|
6290 | If EndBit is greater than 63, then ASSERT().
|
---|
6291 | If EndBit is less than StartBit, then ASSERT().
|
---|
6292 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
|
---|
6293 |
|
---|
6294 | @param Index The 32-bit MSR index to write.
|
---|
6295 | @param StartBit The ordinal of the least significant bit in the bit field.
|
---|
6296 | Range 0..63.
|
---|
6297 | @param EndBit The ordinal of the most significant bit in the bit field.
|
---|
6298 | Range 0..63.
|
---|
6299 | @param Value New value of the bit field.
|
---|
6300 |
|
---|
6301 | @return The value written back to the MSR.
|
---|
6302 |
|
---|
6303 | **/
|
---|
6304 | UINT64
|
---|
6305 | EFIAPI
|
---|
6306 | AsmMsrBitFieldWrite64 (
|
---|
6307 | IN UINT32 Index,
|
---|
6308 | IN UINTN StartBit,
|
---|
6309 | IN UINTN EndBit,
|
---|
6310 | IN UINT64 Value
|
---|
6311 | );
|
---|
6312 |
|
---|
6313 | /**
|
---|
6314 | Reads a bit field in a 64-bit MSR, performs a bitwise OR, and
|
---|
6315 | writes the result back to the bit field in the 64-bit MSR.
|
---|
6316 |
|
---|
6317 | Reads the 64-bit MSR specified by Index, performs a bitwise OR
|
---|
6318 | between the read result and the value specified by OrData, and writes the
|
---|
6319 | result to the 64-bit MSR specified by Index. The value written to the MSR is
|
---|
6320 | returned. Extra left bits in OrData are stripped. The caller must either
|
---|
6321 | guarantee that Index and the data written is valid, or the caller must set up
|
---|
6322 | exception handlers to catch the exceptions. This function is only available
|
---|
6323 | on IA-32 and x64.
|
---|
6324 |
|
---|
6325 | If StartBit is greater than 63, then ASSERT().
|
---|
6326 | If EndBit is greater than 63, then ASSERT().
|
---|
6327 | If EndBit is less than StartBit, then ASSERT().
|
---|
6328 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
|
---|
6329 |
|
---|
6330 | @param Index The 32-bit MSR index to write.
|
---|
6331 | @param StartBit The ordinal of the least significant bit in the bit field.
|
---|
6332 | Range 0..63.
|
---|
6333 | @param EndBit The ordinal of the most significant bit in the bit field.
|
---|
6334 | Range 0..63.
|
---|
6335 | @param OrData The value to OR with the read value from the bit field.
|
---|
6336 |
|
---|
6337 | @return The value written back to the MSR.
|
---|
6338 |
|
---|
6339 | **/
|
---|
6340 | UINT64
|
---|
6341 | EFIAPI
|
---|
6342 | AsmMsrBitFieldOr64 (
|
---|
6343 | IN UINT32 Index,
|
---|
6344 | IN UINTN StartBit,
|
---|
6345 | IN UINTN EndBit,
|
---|
6346 | IN UINT64 OrData
|
---|
6347 | );
|
---|
6348 |
|
---|
6349 | /**
|
---|
6350 | Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
|
---|
6351 | result back to the bit field in the 64-bit MSR.
|
---|
6352 |
|
---|
6353 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
|
---|
6354 | read result and the value specified by AndData, and writes the result to the
|
---|
6355 | 64-bit MSR specified by Index. The value written to the MSR is returned.
|
---|
6356 | Extra left bits in AndData are stripped. The caller must either guarantee
|
---|
6357 | that Index and the data written is valid, or the caller must set up exception
|
---|
6358 | handlers to catch the exceptions. This function is only available on IA-32
|
---|
6359 | and x64.
|
---|
6360 |
|
---|
6361 | If StartBit is greater than 63, then ASSERT().
|
---|
6362 | If EndBit is greater than 63, then ASSERT().
|
---|
6363 | If EndBit is less than StartBit, then ASSERT().
|
---|
6364 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
|
---|
6365 |
|
---|
6366 | @param Index The 32-bit MSR index to write.
|
---|
6367 | @param StartBit The ordinal of the least significant bit in the bit field.
|
---|
6368 | Range 0..63.
|
---|
6369 | @param EndBit The ordinal of the most significant bit in the bit field.
|
---|
6370 | Range 0..63.
|
---|
6371 | @param AndData The value to AND with the read value from the bit field.
|
---|
6372 |
|
---|
6373 | @return The value written back to the MSR.
|
---|
6374 |
|
---|
6375 | **/
|
---|
6376 | UINT64
|
---|
6377 | EFIAPI
|
---|
6378 | AsmMsrBitFieldAnd64 (
|
---|
6379 | IN UINT32 Index,
|
---|
6380 | IN UINTN StartBit,
|
---|
6381 | IN UINTN EndBit,
|
---|
6382 | IN UINT64 AndData
|
---|
6383 | );
|
---|
6384 |
|
---|
6385 | /**
|
---|
6386 | Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
|
---|
6387 | bitwise OR, and writes the result back to the bit field in the
|
---|
6388 | 64-bit MSR.
|
---|
6389 |
|
---|
6390 | Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by
|
---|
6391 | a bitwise OR between the read result and the value specified by
|
---|
6392 | AndData, and writes the result to the 64-bit MSR specified by Index. The
|
---|
6393 | value written to the MSR is returned. Extra left bits in both AndData and
|
---|
6394 | OrData are stripped. The caller must either guarantee that Index and the data
|
---|
6395 | written is valid, or the caller must set up exception handlers to catch the
|
---|
6396 | exceptions. This function is only available on IA-32 and x64.
|
---|
6397 |
|
---|
6398 | If StartBit is greater than 63, then ASSERT().
|
---|
6399 | If EndBit is greater than 63, then ASSERT().
|
---|
6400 | If EndBit is less than StartBit, then ASSERT().
|
---|
6401 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
|
---|
6402 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().
|
---|
6403 |
|
---|
6404 | @param Index The 32-bit MSR index to write.
|
---|
6405 | @param StartBit The ordinal of the least significant bit in the bit field.
|
---|
6406 | Range 0..63.
|
---|
6407 | @param EndBit The ordinal of the most significant bit in the bit field.
|
---|
6408 | Range 0..63.
|
---|
6409 | @param AndData The value to AND with the read value from the bit field.
|
---|
6410 | @param OrData The value to OR with the result of the AND operation.
|
---|
6411 |
|
---|
6412 | @return The value written back to the MSR.
|
---|
6413 |
|
---|
6414 | **/
|
---|
6415 | UINT64
|
---|
6416 | EFIAPI
|
---|
6417 | AsmMsrBitFieldAndThenOr64 (
|
---|
6418 | IN UINT32 Index,
|
---|
6419 | IN UINTN StartBit,
|
---|
6420 | IN UINTN EndBit,
|
---|
6421 | IN UINT64 AndData,
|
---|
6422 | IN UINT64 OrData
|
---|
6423 | );
|
---|
6424 |
|
---|
6425 | /**
|
---|
6426 | Reads the current value of the EFLAGS register.
|
---|
6427 |
|
---|
6428 | Reads and returns the current value of the EFLAGS register. This function is
|
---|
6429 | only available on IA-32 and x64. This returns a 32-bit value on IA-32 and a
|
---|
6430 | 64-bit value on x64.
|
---|
6431 |
|
---|
6432 | @return EFLAGS on IA-32 or RFLAGS on x64.
|
---|
6433 |
|
---|
6434 | **/
|
---|
6435 | UINTN
|
---|
6436 | EFIAPI
|
---|
6437 | AsmReadEflags (
|
---|
6438 | VOID
|
---|
6439 | );
|
---|
6440 |
|
---|
6441 | /**
|
---|
6442 | Reads the current value of the Control Register 0 (CR0).
|
---|
6443 |
|
---|
6444 | Reads and returns the current value of CR0. This function is only available
|
---|
6445 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
|
---|
6446 | x64.
|
---|
6447 |
|
---|
6448 | @return The value of the Control Register 0 (CR0).
|
---|
6449 |
|
---|
6450 | **/
|
---|
6451 | UINTN
|
---|
6452 | EFIAPI
|
---|
6453 | AsmReadCr0 (
|
---|
6454 | VOID
|
---|
6455 | );
|
---|
6456 |
|
---|
6457 | /**
|
---|
6458 | Reads the current value of the Control Register 2 (CR2).
|
---|
6459 |
|
---|
6460 | Reads and returns the current value of CR2. This function is only available
|
---|
6461 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
|
---|
6462 | x64.
|
---|
6463 |
|
---|
6464 | @return The value of the Control Register 2 (CR2).
|
---|
6465 |
|
---|
6466 | **/
|
---|
6467 | UINTN
|
---|
6468 | EFIAPI
|
---|
6469 | AsmReadCr2 (
|
---|
6470 | VOID
|
---|
6471 | );
|
---|
6472 |
|
---|
6473 | /**
|
---|
6474 | Reads the current value of the Control Register 3 (CR3).
|
---|
6475 |
|
---|
6476 | Reads and returns the current value of CR3. This function is only available
|
---|
6477 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
|
---|
6478 | x64.
|
---|
6479 |
|
---|
6480 | @return The value of the Control Register 3 (CR3).
|
---|
6481 |
|
---|
6482 | **/
|
---|
6483 | UINTN
|
---|
6484 | EFIAPI
|
---|
6485 | AsmReadCr3 (
|
---|
6486 | VOID
|
---|
6487 | );
|
---|
6488 |
|
---|
6489 | /**
|
---|
6490 | Reads the current value of the Control Register 4 (CR4).
|
---|
6491 |
|
---|
6492 | Reads and returns the current value of CR4. This function is only available
|
---|
6493 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
|
---|
6494 | x64.
|
---|
6495 |
|
---|
6496 | @return The value of the Control Register 4 (CR4).
|
---|
6497 |
|
---|
6498 | **/
|
---|
6499 | UINTN
|
---|
6500 | EFIAPI
|
---|
6501 | AsmReadCr4 (
|
---|
6502 | VOID
|
---|
6503 | );
|
---|
6504 |
|
---|
6505 | /**
|
---|
6506 | Writes a value to Control Register 0 (CR0).
|
---|
6507 |
|
---|
6508 | Writes and returns a new value to CR0. This function is only available on
|
---|
6509 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
|
---|
6510 |
|
---|
6511 | @param Cr0 The value to write to CR0.
|
---|
6512 |
|
---|
6513 | @return The value written to CR0.
|
---|
6514 |
|
---|
6515 | **/
|
---|
6516 | UINTN
|
---|
6517 | EFIAPI
|
---|
6518 | AsmWriteCr0 (
|
---|
6519 | UINTN Cr0
|
---|
6520 | );
|
---|
6521 |
|
---|
6522 | /**
|
---|
6523 | Writes a value to Control Register 2 (CR2).
|
---|
6524 |
|
---|
6525 | Writes and returns a new value to CR2. This function is only available on
|
---|
6526 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
|
---|
6527 |
|
---|
6528 | @param Cr2 The value to write to CR2.
|
---|
6529 |
|
---|
6530 | @return The value written to CR2.
|
---|
6531 |
|
---|
6532 | **/
|
---|
6533 | UINTN
|
---|
6534 | EFIAPI
|
---|
6535 | AsmWriteCr2 (
|
---|
6536 | UINTN Cr2
|
---|
6537 | );
|
---|
6538 |
|
---|
6539 | /**
|
---|
6540 | Writes a value to Control Register 3 (CR3).
|
---|
6541 |
|
---|
6542 | Writes and returns a new value to CR3. This function is only available on
|
---|
6543 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
|
---|
6544 |
|
---|
6545 | @param Cr3 The value to write to CR3.
|
---|
6546 |
|
---|
6547 | @return The value written to CR3.
|
---|
6548 |
|
---|
6549 | **/
|
---|
6550 | UINTN
|
---|
6551 | EFIAPI
|
---|
6552 | AsmWriteCr3 (
|
---|
6553 | UINTN Cr3
|
---|
6554 | );
|
---|
6555 |
|
---|
6556 | /**
|
---|
6557 | Writes a value to Control Register 4 (CR4).
|
---|
6558 |
|
---|
6559 | Writes and returns a new value to CR4. This function is only available on
|
---|
6560 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
|
---|
6561 |
|
---|
6562 | @param Cr4 The value to write to CR4.
|
---|
6563 |
|
---|
6564 | @return The value written to CR4.
|
---|
6565 |
|
---|
6566 | **/
|
---|
6567 | UINTN
|
---|
6568 | EFIAPI
|
---|
6569 | AsmWriteCr4 (
|
---|
6570 | UINTN Cr4
|
---|
6571 | );
|
---|
6572 |
|
---|
6573 | /**
|
---|
6574 | Reads the current value of Debug Register 0 (DR0).
|
---|
6575 |
|
---|
6576 | Reads and returns the current value of DR0. This function is only available
|
---|
6577 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
|
---|
6578 | x64.
|
---|
6579 |
|
---|
6580 | @return The value of Debug Register 0 (DR0).
|
---|
6581 |
|
---|
6582 | **/
|
---|
6583 | UINTN
|
---|
6584 | EFIAPI
|
---|
6585 | AsmReadDr0 (
|
---|
6586 | VOID
|
---|
6587 | );
|
---|
6588 |
|
---|
6589 | /**
|
---|
6590 | Reads the current value of Debug Register 1 (DR1).
|
---|
6591 |
|
---|
6592 | Reads and returns the current value of DR1. This function is only available
|
---|
6593 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
|
---|
6594 | x64.
|
---|
6595 |
|
---|
6596 | @return The value of Debug Register 1 (DR1).
|
---|
6597 |
|
---|
6598 | **/
|
---|
6599 | UINTN
|
---|
6600 | EFIAPI
|
---|
6601 | AsmReadDr1 (
|
---|
6602 | VOID
|
---|
6603 | );
|
---|
6604 |
|
---|
6605 | /**
|
---|
6606 | Reads the current value of Debug Register 2 (DR2).
|
---|
6607 |
|
---|
6608 | Reads and returns the current value of DR2. This function is only available
|
---|
6609 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
|
---|
6610 | x64.
|
---|
6611 |
|
---|
6612 | @return The value of Debug Register 2 (DR2).
|
---|
6613 |
|
---|
6614 | **/
|
---|
6615 | UINTN
|
---|
6616 | EFIAPI
|
---|
6617 | AsmReadDr2 (
|
---|
6618 | VOID
|
---|
6619 | );
|
---|
6620 |
|
---|
6621 | /**
|
---|
6622 | Reads the current value of Debug Register 3 (DR3).
|
---|
6623 |
|
---|
6624 | Reads and returns the current value of DR3. This function is only available
|
---|
6625 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
|
---|
6626 | x64.
|
---|
6627 |
|
---|
6628 | @return The value of Debug Register 3 (DR3).
|
---|
6629 |
|
---|
6630 | **/
|
---|
6631 | UINTN
|
---|
6632 | EFIAPI
|
---|
6633 | AsmReadDr3 (
|
---|
6634 | VOID
|
---|
6635 | );
|
---|
6636 |
|
---|
6637 | /**
|
---|
6638 | Reads the current value of Debug Register 4 (DR4).
|
---|
6639 |
|
---|
6640 | Reads and returns the current value of DR4. This function is only available
|
---|
6641 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
|
---|
6642 | x64.
|
---|
6643 |
|
---|
6644 | @return The value of Debug Register 4 (DR4).
|
---|
6645 |
|
---|
6646 | **/
|
---|
6647 | UINTN
|
---|
6648 | EFIAPI
|
---|
6649 | AsmReadDr4 (
|
---|
6650 | VOID
|
---|
6651 | );
|
---|
6652 |
|
---|
6653 | /**
|
---|
6654 | Reads the current value of Debug Register 5 (DR5).
|
---|
6655 |
|
---|
6656 | Reads and returns the current value of DR5. This function is only available
|
---|
6657 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
|
---|
6658 | x64.
|
---|
6659 |
|
---|
6660 | @return The value of Debug Register 5 (DR5).
|
---|
6661 |
|
---|
6662 | **/
|
---|
6663 | UINTN
|
---|
6664 | EFIAPI
|
---|
6665 | AsmReadDr5 (
|
---|
6666 | VOID
|
---|
6667 | );
|
---|
6668 |
|
---|
6669 | /**
|
---|
6670 | Reads the current value of Debug Register 6 (DR6).
|
---|
6671 |
|
---|
6672 | Reads and returns the current value of DR6. This function is only available
|
---|
6673 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
|
---|
6674 | x64.
|
---|
6675 |
|
---|
6676 | @return The value of Debug Register 6 (DR6).
|
---|
6677 |
|
---|
6678 | **/
|
---|
6679 | UINTN
|
---|
6680 | EFIAPI
|
---|
6681 | AsmReadDr6 (
|
---|
6682 | VOID
|
---|
6683 | );
|
---|
6684 |
|
---|
6685 | /**
|
---|
6686 | Reads the current value of Debug Register 7 (DR7).
|
---|
6687 |
|
---|
6688 | Reads and returns the current value of DR7. This function is only available
|
---|
6689 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on
|
---|
6690 | x64.
|
---|
6691 |
|
---|
6692 | @return The value of Debug Register 7 (DR7).
|
---|
6693 |
|
---|
6694 | **/
|
---|
6695 | UINTN
|
---|
6696 | EFIAPI
|
---|
6697 | AsmReadDr7 (
|
---|
6698 | VOID
|
---|
6699 | );
|
---|
6700 |
|
---|
6701 | /**
|
---|
6702 | Writes a value to Debug Register 0 (DR0).
|
---|
6703 |
|
---|
6704 | Writes and returns a new value to DR0. This function is only available on
|
---|
6705 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
|
---|
6706 |
|
---|
6707 | @param Dr0 The value to write to Dr0.
|
---|
6708 |
|
---|
6709 | @return The value written to Debug Register 0 (DR0).
|
---|
6710 |
|
---|
6711 | **/
|
---|
6712 | UINTN
|
---|
6713 | EFIAPI
|
---|
6714 | AsmWriteDr0 (
|
---|
6715 | UINTN Dr0
|
---|
6716 | );
|
---|
6717 |
|
---|
6718 | /**
|
---|
6719 | Writes a value to Debug Register 1 (DR1).
|
---|
6720 |
|
---|
6721 | Writes and returns a new value to DR1. This function is only available on
|
---|
6722 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
|
---|
6723 |
|
---|
6724 | @param Dr1 The value to write to Dr1.
|
---|
6725 |
|
---|
6726 | @return The value written to Debug Register 1 (DR1).
|
---|
6727 |
|
---|
6728 | **/
|
---|
6729 | UINTN
|
---|
6730 | EFIAPI
|
---|
6731 | AsmWriteDr1 (
|
---|
6732 | UINTN Dr1
|
---|
6733 | );
|
---|
6734 |
|
---|
6735 | /**
|
---|
6736 | Writes a value to Debug Register 2 (DR2).
|
---|
6737 |
|
---|
6738 | Writes and returns a new value to DR2. This function is only available on
|
---|
6739 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
|
---|
6740 |
|
---|
6741 | @param Dr2 The value to write to Dr2.
|
---|
6742 |
|
---|
6743 | @return The value written to Debug Register 2 (DR2).
|
---|
6744 |
|
---|
6745 | **/
|
---|
6746 | UINTN
|
---|
6747 | EFIAPI
|
---|
6748 | AsmWriteDr2 (
|
---|
6749 | UINTN Dr2
|
---|
6750 | );
|
---|
6751 |
|
---|
6752 | /**
|
---|
6753 | Writes a value to Debug Register 3 (DR3).
|
---|
6754 |
|
---|
6755 | Writes and returns a new value to DR3. This function is only available on
|
---|
6756 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
|
---|
6757 |
|
---|
6758 | @param Dr3 The value to write to Dr3.
|
---|
6759 |
|
---|
6760 | @return The value written to Debug Register 3 (DR3).
|
---|
6761 |
|
---|
6762 | **/
|
---|
6763 | UINTN
|
---|
6764 | EFIAPI
|
---|
6765 | AsmWriteDr3 (
|
---|
6766 | UINTN Dr3
|
---|
6767 | );
|
---|
6768 |
|
---|
6769 | /**
|
---|
6770 | Writes a value to Debug Register 4 (DR4).
|
---|
6771 |
|
---|
6772 | Writes and returns a new value to DR4. This function is only available on
|
---|
6773 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
|
---|
6774 |
|
---|
6775 | @param Dr4 The value to write to Dr4.
|
---|
6776 |
|
---|
6777 | @return The value written to Debug Register 4 (DR4).
|
---|
6778 |
|
---|
6779 | **/
|
---|
6780 | UINTN
|
---|
6781 | EFIAPI
|
---|
6782 | AsmWriteDr4 (
|
---|
6783 | UINTN Dr4
|
---|
6784 | );
|
---|
6785 |
|
---|
6786 | /**
|
---|
6787 | Writes a value to Debug Register 5 (DR5).
|
---|
6788 |
|
---|
6789 | Writes and returns a new value to DR5. This function is only available on
|
---|
6790 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
|
---|
6791 |
|
---|
6792 | @param Dr5 The value to write to Dr5.
|
---|
6793 |
|
---|
6794 | @return The value written to Debug Register 5 (DR5).
|
---|
6795 |
|
---|
6796 | **/
|
---|
6797 | UINTN
|
---|
6798 | EFIAPI
|
---|
6799 | AsmWriteDr5 (
|
---|
6800 | UINTN Dr5
|
---|
6801 | );
|
---|
6802 |
|
---|
6803 | /**
|
---|
6804 | Writes a value to Debug Register 6 (DR6).
|
---|
6805 |
|
---|
6806 | Writes and returns a new value to DR6. This function is only available on
|
---|
6807 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
|
---|
6808 |
|
---|
6809 | @param Dr6 The value to write to Dr6.
|
---|
6810 |
|
---|
6811 | @return The value written to Debug Register 6 (DR6).
|
---|
6812 |
|
---|
6813 | **/
|
---|
6814 | UINTN
|
---|
6815 | EFIAPI
|
---|
6816 | AsmWriteDr6 (
|
---|
6817 | UINTN Dr6
|
---|
6818 | );
|
---|
6819 |
|
---|
6820 | /**
|
---|
6821 | Writes a value to Debug Register 7 (DR7).
|
---|
6822 |
|
---|
6823 | Writes and returns a new value to DR7. This function is only available on
|
---|
6824 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.
|
---|
6825 |
|
---|
6826 | @param Dr7 The value to write to Dr7.
|
---|
6827 |
|
---|
6828 | @return The value written to Debug Register 7 (DR7).
|
---|
6829 |
|
---|
6830 | **/
|
---|
6831 | UINTN
|
---|
6832 | EFIAPI
|
---|
6833 | AsmWriteDr7 (
|
---|
6834 | UINTN Dr7
|
---|
6835 | );
|
---|
6836 |
|
---|
6837 | /**
|
---|
6838 | Reads the current value of Code Segment Register (CS).
|
---|
6839 |
|
---|
6840 | Reads and returns the current value of CS. This function is only available on
|
---|
6841 | IA-32 and x64.
|
---|
6842 |
|
---|
6843 | @return The current value of CS.
|
---|
6844 |
|
---|
6845 | **/
|
---|
6846 | UINT16
|
---|
6847 | EFIAPI
|
---|
6848 | AsmReadCs (
|
---|
6849 | VOID
|
---|
6850 | );
|
---|
6851 |
|
---|
6852 | /**
|
---|
6853 | Reads the current value of Data Segment Register (DS).
|
---|
6854 |
|
---|
6855 | Reads and returns the current value of DS. This function is only available on
|
---|
6856 | IA-32 and x64.
|
---|
6857 |
|
---|
6858 | @return The current value of DS.
|
---|
6859 |
|
---|
6860 | **/
|
---|
6861 | UINT16
|
---|
6862 | EFIAPI
|
---|
6863 | AsmReadDs (
|
---|
6864 | VOID
|
---|
6865 | );
|
---|
6866 |
|
---|
6867 | /**
|
---|
6868 | Reads the current value of Extra Segment Register (ES).
|
---|
6869 |
|
---|
6870 | Reads and returns the current value of ES. This function is only available on
|
---|
6871 | IA-32 and x64.
|
---|
6872 |
|
---|
6873 | @return The current value of ES.
|
---|
6874 |
|
---|
6875 | **/
|
---|
6876 | UINT16
|
---|
6877 | EFIAPI
|
---|
6878 | AsmReadEs (
|
---|
6879 | VOID
|
---|
6880 | );
|
---|
6881 |
|
---|
6882 | /**
|
---|
6883 | Reads the current value of FS Data Segment Register (FS).
|
---|
6884 |
|
---|
6885 | Reads and returns the current value of FS. This function is only available on
|
---|
6886 | IA-32 and x64.
|
---|
6887 |
|
---|
6888 | @return The current value of FS.
|
---|
6889 |
|
---|
6890 | **/
|
---|
6891 | UINT16
|
---|
6892 | EFIAPI
|
---|
6893 | AsmReadFs (
|
---|
6894 | VOID
|
---|
6895 | );
|
---|
6896 |
|
---|
6897 | /**
|
---|
6898 | Reads the current value of GS Data Segment Register (GS).
|
---|
6899 |
|
---|
6900 | Reads and returns the current value of GS. This function is only available on
|
---|
6901 | IA-32 and x64.
|
---|
6902 |
|
---|
6903 | @return The current value of GS.
|
---|
6904 |
|
---|
6905 | **/
|
---|
6906 | UINT16
|
---|
6907 | EFIAPI
|
---|
6908 | AsmReadGs (
|
---|
6909 | VOID
|
---|
6910 | );
|
---|
6911 |
|
---|
6912 | /**
|
---|
6913 | Reads the current value of Stack Segment Register (SS).
|
---|
6914 |
|
---|
6915 | Reads and returns the current value of SS. This function is only available on
|
---|
6916 | IA-32 and x64.
|
---|
6917 |
|
---|
6918 | @return The current value of SS.
|
---|
6919 |
|
---|
6920 | **/
|
---|
6921 | UINT16
|
---|
6922 | EFIAPI
|
---|
6923 | AsmReadSs (
|
---|
6924 | VOID
|
---|
6925 | );
|
---|
6926 |
|
---|
6927 | /**
|
---|
6928 | Reads the current value of Task Register (TR).
|
---|
6929 |
|
---|
6930 | Reads and returns the current value of TR. This function is only available on
|
---|
6931 | IA-32 and x64.
|
---|
6932 |
|
---|
6933 | @return The current value of TR.
|
---|
6934 |
|
---|
6935 | **/
|
---|
6936 | UINT16
|
---|
6937 | EFIAPI
|
---|
6938 | AsmReadTr (
|
---|
6939 | VOID
|
---|
6940 | );
|
---|
6941 |
|
---|
6942 | /**
|
---|
6943 | Reads the current Global Descriptor Table Register(GDTR) descriptor.
|
---|
6944 |
|
---|
6945 | Reads and returns the current GDTR descriptor and returns it in Gdtr. This
|
---|
6946 | function is only available on IA-32 and x64.
|
---|
6947 |
|
---|
6948 | If Gdtr is NULL, then ASSERT().
|
---|
6949 |
|
---|
6950 | @param Gdtr The pointer to a GDTR descriptor.
|
---|
6951 |
|
---|
6952 | **/
|
---|
6953 | VOID
|
---|
6954 | EFIAPI
|
---|
6955 | AsmReadGdtr (
|
---|
6956 | OUT IA32_DESCRIPTOR *Gdtr
|
---|
6957 | );
|
---|
6958 |
|
---|
6959 | /**
|
---|
6960 | Writes the current Global Descriptor Table Register (GDTR) descriptor.
|
---|
6961 |
|
---|
6962 | Writes and the current GDTR descriptor specified by Gdtr. This function is
|
---|
6963 | only available on IA-32 and x64.
|
---|
6964 |
|
---|
6965 | If Gdtr is NULL, then ASSERT().
|
---|
6966 |
|
---|
6967 | @param Gdtr The pointer to a GDTR descriptor.
|
---|
6968 |
|
---|
6969 | **/
|
---|
6970 | VOID
|
---|
6971 | EFIAPI
|
---|
6972 | AsmWriteGdtr (
|
---|
6973 | IN CONST IA32_DESCRIPTOR *Gdtr
|
---|
6974 | );
|
---|
6975 |
|
---|
6976 | /**
|
---|
6977 | Reads the current Interrupt Descriptor Table Register(IDTR) descriptor.
|
---|
6978 |
|
---|
6979 | Reads and returns the current IDTR descriptor and returns it in Idtr. This
|
---|
6980 | function is only available on IA-32 and x64.
|
---|
6981 |
|
---|
6982 | If Idtr is NULL, then ASSERT().
|
---|
6983 |
|
---|
6984 | @param Idtr The pointer to a IDTR descriptor.
|
---|
6985 |
|
---|
6986 | **/
|
---|
6987 | VOID
|
---|
6988 | EFIAPI
|
---|
6989 | AsmReadIdtr (
|
---|
6990 | OUT IA32_DESCRIPTOR *Idtr
|
---|
6991 | );
|
---|
6992 |
|
---|
6993 | /**
|
---|
6994 | Writes the current Interrupt Descriptor Table Register(IDTR) descriptor.
|
---|
6995 |
|
---|
6996 | Writes the current IDTR descriptor and returns it in Idtr. This function is
|
---|
6997 | only available on IA-32 and x64.
|
---|
6998 |
|
---|
6999 | If Idtr is NULL, then ASSERT().
|
---|
7000 |
|
---|
7001 | @param Idtr The pointer to a IDTR descriptor.
|
---|
7002 |
|
---|
7003 | **/
|
---|
7004 | VOID
|
---|
7005 | EFIAPI
|
---|
7006 | AsmWriteIdtr (
|
---|
7007 | IN CONST IA32_DESCRIPTOR *Idtr
|
---|
7008 | );
|
---|
7009 |
|
---|
7010 | /**
|
---|
7011 | Reads the current Local Descriptor Table Register(LDTR) selector.
|
---|
7012 |
|
---|
7013 | Reads and returns the current 16-bit LDTR descriptor value. This function is
|
---|
7014 | only available on IA-32 and x64.
|
---|
7015 |
|
---|
7016 | @return The current selector of LDT.
|
---|
7017 |
|
---|
7018 | **/
|
---|
7019 | UINT16
|
---|
7020 | EFIAPI
|
---|
7021 | AsmReadLdtr (
|
---|
7022 | VOID
|
---|
7023 | );
|
---|
7024 |
|
---|
7025 | /**
|
---|
7026 | Writes the current Local Descriptor Table Register (LDTR) selector.
|
---|
7027 |
|
---|
7028 | Writes and the current LDTR descriptor specified by Ldtr. This function is
|
---|
7029 | only available on IA-32 and x64.
|
---|
7030 |
|
---|
7031 | @param Ldtr 16-bit LDTR selector value.
|
---|
7032 |
|
---|
7033 | **/
|
---|
7034 | VOID
|
---|
7035 | EFIAPI
|
---|
7036 | AsmWriteLdtr (
|
---|
7037 | IN UINT16 Ldtr
|
---|
7038 | );
|
---|
7039 |
|
---|
7040 | /**
|
---|
7041 | Save the current floating point/SSE/SSE2 context to a buffer.
|
---|
7042 |
|
---|
7043 | Saves the current floating point/SSE/SSE2 state to the buffer specified by
|
---|
7044 | Buffer. Buffer must be aligned on a 16-byte boundary. This function is only
|
---|
7045 | available on IA-32 and x64.
|
---|
7046 |
|
---|
7047 | If Buffer is NULL, then ASSERT().
|
---|
7048 | If Buffer is not aligned on a 16-byte boundary, then ASSERT().
|
---|
7049 |
|
---|
7050 | @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.
|
---|
7051 |
|
---|
7052 | **/
|
---|
7053 | VOID
|
---|
7054 | EFIAPI
|
---|
7055 | AsmFxSave (
|
---|
7056 | OUT IA32_FX_BUFFER *Buffer
|
---|
7057 | );
|
---|
7058 |
|
---|
7059 | /**
|
---|
7060 | Restores the current floating point/SSE/SSE2 context from a buffer.
|
---|
7061 |
|
---|
7062 | Restores the current floating point/SSE/SSE2 state from the buffer specified
|
---|
7063 | by Buffer. Buffer must be aligned on a 16-byte boundary. This function is
|
---|
7064 | only available on IA-32 and x64.
|
---|
7065 |
|
---|
7066 | If Buffer is NULL, then ASSERT().
|
---|
7067 | If Buffer is not aligned on a 16-byte boundary, then ASSERT().
|
---|
7068 | If Buffer was not saved with AsmFxSave(), then ASSERT().
|
---|
7069 |
|
---|
7070 | @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.
|
---|
7071 |
|
---|
7072 | **/
|
---|
7073 | VOID
|
---|
7074 | EFIAPI
|
---|
7075 | AsmFxRestore (
|
---|
7076 | IN CONST IA32_FX_BUFFER *Buffer
|
---|
7077 | );
|
---|
7078 |
|
---|
7079 | /**
|
---|
7080 | Reads the current value of 64-bit MMX Register #0 (MM0).
|
---|
7081 |
|
---|
7082 | Reads and returns the current value of MM0. This function is only available
|
---|
7083 | on IA-32 and x64.
|
---|
7084 |
|
---|
7085 | @return The current value of MM0.
|
---|
7086 |
|
---|
7087 | **/
|
---|
7088 | UINT64
|
---|
7089 | EFIAPI
|
---|
7090 | AsmReadMm0 (
|
---|
7091 | VOID
|
---|
7092 | );
|
---|
7093 |
|
---|
7094 | /**
|
---|
7095 | Reads the current value of 64-bit MMX Register #1 (MM1).
|
---|
7096 |
|
---|
7097 | Reads and returns the current value of MM1. This function is only available
|
---|
7098 | on IA-32 and x64.
|
---|
7099 |
|
---|
7100 | @return The current value of MM1.
|
---|
7101 |
|
---|
7102 | **/
|
---|
7103 | UINT64
|
---|
7104 | EFIAPI
|
---|
7105 | AsmReadMm1 (
|
---|
7106 | VOID
|
---|
7107 | );
|
---|
7108 |
|
---|
7109 | /**
|
---|
7110 | Reads the current value of 64-bit MMX Register #2 (MM2).
|
---|
7111 |
|
---|
7112 | Reads and returns the current value of MM2. This function is only available
|
---|
7113 | on IA-32 and x64.
|
---|
7114 |
|
---|
7115 | @return The current value of MM2.
|
---|
7116 |
|
---|
7117 | **/
|
---|
7118 | UINT64
|
---|
7119 | EFIAPI
|
---|
7120 | AsmReadMm2 (
|
---|
7121 | VOID
|
---|
7122 | );
|
---|
7123 |
|
---|
7124 | /**
|
---|
7125 | Reads the current value of 64-bit MMX Register #3 (MM3).
|
---|
7126 |
|
---|
7127 | Reads and returns the current value of MM3. This function is only available
|
---|
7128 | on IA-32 and x64.
|
---|
7129 |
|
---|
7130 | @return The current value of MM3.
|
---|
7131 |
|
---|
7132 | **/
|
---|
7133 | UINT64
|
---|
7134 | EFIAPI
|
---|
7135 | AsmReadMm3 (
|
---|
7136 | VOID
|
---|
7137 | );
|
---|
7138 |
|
---|
7139 | /**
|
---|
7140 | Reads the current value of 64-bit MMX Register #4 (MM4).
|
---|
7141 |
|
---|
7142 | Reads and returns the current value of MM4. This function is only available
|
---|
7143 | on IA-32 and x64.
|
---|
7144 |
|
---|
7145 | @return The current value of MM4.
|
---|
7146 |
|
---|
7147 | **/
|
---|
7148 | UINT64
|
---|
7149 | EFIAPI
|
---|
7150 | AsmReadMm4 (
|
---|
7151 | VOID
|
---|
7152 | );
|
---|
7153 |
|
---|
7154 | /**
|
---|
7155 | Reads the current value of 64-bit MMX Register #5 (MM5).
|
---|
7156 |
|
---|
7157 | Reads and returns the current value of MM5. This function is only available
|
---|
7158 | on IA-32 and x64.
|
---|
7159 |
|
---|
7160 | @return The current value of MM5.
|
---|
7161 |
|
---|
7162 | **/
|
---|
7163 | UINT64
|
---|
7164 | EFIAPI
|
---|
7165 | AsmReadMm5 (
|
---|
7166 | VOID
|
---|
7167 | );
|
---|
7168 |
|
---|
7169 | /**
|
---|
7170 | Reads the current value of 64-bit MMX Register #6 (MM6).
|
---|
7171 |
|
---|
7172 | Reads and returns the current value of MM6. This function is only available
|
---|
7173 | on IA-32 and x64.
|
---|
7174 |
|
---|
7175 | @return The current value of MM6.
|
---|
7176 |
|
---|
7177 | **/
|
---|
7178 | UINT64
|
---|
7179 | EFIAPI
|
---|
7180 | AsmReadMm6 (
|
---|
7181 | VOID
|
---|
7182 | );
|
---|
7183 |
|
---|
7184 | /**
|
---|
7185 | Reads the current value of 64-bit MMX Register #7 (MM7).
|
---|
7186 |
|
---|
7187 | Reads and returns the current value of MM7. This function is only available
|
---|
7188 | on IA-32 and x64.
|
---|
7189 |
|
---|
7190 | @return The current value of MM7.
|
---|
7191 |
|
---|
7192 | **/
|
---|
7193 | UINT64
|
---|
7194 | EFIAPI
|
---|
7195 | AsmReadMm7 (
|
---|
7196 | VOID
|
---|
7197 | );
|
---|
7198 |
|
---|
7199 | /**
|
---|
7200 | Writes the current value of 64-bit MMX Register #0 (MM0).
|
---|
7201 |
|
---|
7202 | Writes the current value of MM0. This function is only available on IA32 and
|
---|
7203 | x64.
|
---|
7204 |
|
---|
7205 | @param Value The 64-bit value to write to MM0.
|
---|
7206 |
|
---|
7207 | **/
|
---|
7208 | VOID
|
---|
7209 | EFIAPI
|
---|
7210 | AsmWriteMm0 (
|
---|
7211 | IN UINT64 Value
|
---|
7212 | );
|
---|
7213 |
|
---|
7214 | /**
|
---|
7215 | Writes the current value of 64-bit MMX Register #1 (MM1).
|
---|
7216 |
|
---|
7217 | Writes the current value of MM1. This function is only available on IA32 and
|
---|
7218 | x64.
|
---|
7219 |
|
---|
7220 | @param Value The 64-bit value to write to MM1.
|
---|
7221 |
|
---|
7222 | **/
|
---|
7223 | VOID
|
---|
7224 | EFIAPI
|
---|
7225 | AsmWriteMm1 (
|
---|
7226 | IN UINT64 Value
|
---|
7227 | );
|
---|
7228 |
|
---|
7229 | /**
|
---|
7230 | Writes the current value of 64-bit MMX Register #2 (MM2).
|
---|
7231 |
|
---|
7232 | Writes the current value of MM2. This function is only available on IA32 and
|
---|
7233 | x64.
|
---|
7234 |
|
---|
7235 | @param Value The 64-bit value to write to MM2.
|
---|
7236 |
|
---|
7237 | **/
|
---|
7238 | VOID
|
---|
7239 | EFIAPI
|
---|
7240 | AsmWriteMm2 (
|
---|
7241 | IN UINT64 Value
|
---|
7242 | );
|
---|
7243 |
|
---|
7244 | /**
|
---|
7245 | Writes the current value of 64-bit MMX Register #3 (MM3).
|
---|
7246 |
|
---|
7247 | Writes the current value of MM3. This function is only available on IA32 and
|
---|
7248 | x64.
|
---|
7249 |
|
---|
7250 | @param Value The 64-bit value to write to MM3.
|
---|
7251 |
|
---|
7252 | **/
|
---|
7253 | VOID
|
---|
7254 | EFIAPI
|
---|
7255 | AsmWriteMm3 (
|
---|
7256 | IN UINT64 Value
|
---|
7257 | );
|
---|
7258 |
|
---|
7259 | /**
|
---|
7260 | Writes the current value of 64-bit MMX Register #4 (MM4).
|
---|
7261 |
|
---|
7262 | Writes the current value of MM4. This function is only available on IA32 and
|
---|
7263 | x64.
|
---|
7264 |
|
---|
7265 | @param Value The 64-bit value to write to MM4.
|
---|
7266 |
|
---|
7267 | **/
|
---|
7268 | VOID
|
---|
7269 | EFIAPI
|
---|
7270 | AsmWriteMm4 (
|
---|
7271 | IN UINT64 Value
|
---|
7272 | );
|
---|
7273 |
|
---|
7274 | /**
|
---|
7275 | Writes the current value of 64-bit MMX Register #5 (MM5).
|
---|
7276 |
|
---|
7277 | Writes the current value of MM5. This function is only available on IA32 and
|
---|
7278 | x64.
|
---|
7279 |
|
---|
7280 | @param Value The 64-bit value to write to MM5.
|
---|
7281 |
|
---|
7282 | **/
|
---|
7283 | VOID
|
---|
7284 | EFIAPI
|
---|
7285 | AsmWriteMm5 (
|
---|
7286 | IN UINT64 Value
|
---|
7287 | );
|
---|
7288 |
|
---|
7289 | /**
|
---|
7290 | Writes the current value of 64-bit MMX Register #6 (MM6).
|
---|
7291 |
|
---|
7292 | Writes the current value of MM6. This function is only available on IA32 and
|
---|
7293 | x64.
|
---|
7294 |
|
---|
7295 | @param Value The 64-bit value to write to MM6.
|
---|
7296 |
|
---|
7297 | **/
|
---|
7298 | VOID
|
---|
7299 | EFIAPI
|
---|
7300 | AsmWriteMm6 (
|
---|
7301 | IN UINT64 Value
|
---|
7302 | );
|
---|
7303 |
|
---|
7304 | /**
|
---|
7305 | Writes the current value of 64-bit MMX Register #7 (MM7).
|
---|
7306 |
|
---|
7307 | Writes the current value of MM7. This function is only available on IA32 and
|
---|
7308 | x64.
|
---|
7309 |
|
---|
7310 | @param Value The 64-bit value to write to MM7.
|
---|
7311 |
|
---|
7312 | **/
|
---|
7313 | VOID
|
---|
7314 | EFIAPI
|
---|
7315 | AsmWriteMm7 (
|
---|
7316 | IN UINT64 Value
|
---|
7317 | );
|
---|
7318 |
|
---|
7319 | /**
|
---|
7320 | Reads the current value of Time Stamp Counter (TSC).
|
---|
7321 |
|
---|
7322 | Reads and returns the current value of TSC. This function is only available
|
---|
7323 | on IA-32 and x64.
|
---|
7324 |
|
---|
7325 | @return The current value of TSC
|
---|
7326 |
|
---|
7327 | **/
|
---|
7328 | UINT64
|
---|
7329 | EFIAPI
|
---|
7330 | AsmReadTsc (
|
---|
7331 | VOID
|
---|
7332 | );
|
---|
7333 |
|
---|
7334 | /**
|
---|
7335 | Reads the current value of a Performance Counter (PMC).
|
---|
7336 |
|
---|
7337 | Reads and returns the current value of performance counter specified by
|
---|
7338 | Index. This function is only available on IA-32 and x64.
|
---|
7339 |
|
---|
7340 | @param Index The 32-bit Performance Counter index to read.
|
---|
7341 |
|
---|
7342 | @return The value of the PMC specified by Index.
|
---|
7343 |
|
---|
7344 | **/
|
---|
7345 | UINT64
|
---|
7346 | EFIAPI
|
---|
7347 | AsmReadPmc (
|
---|
7348 | IN UINT32 Index
|
---|
7349 | );
|
---|
7350 |
|
---|
7351 | /**
|
---|
7352 | Sets up a monitor buffer that is used by AsmMwait().
|
---|
7353 |
|
---|
7354 | Executes a MONITOR instruction with the register state specified by Eax, Ecx
|
---|
7355 | and Edx. Returns Eax. This function is only available on IA-32 and x64.
|
---|
7356 |
|
---|
7357 | @param Eax The value to load into EAX or RAX before executing the MONITOR
|
---|
7358 | instruction.
|
---|
7359 | @param Ecx The value to load into ECX or RCX before executing the MONITOR
|
---|
7360 | instruction.
|
---|
7361 | @param Edx The value to load into EDX or RDX before executing the MONITOR
|
---|
7362 | instruction.
|
---|
7363 |
|
---|
7364 | @return Eax
|
---|
7365 |
|
---|
7366 | **/
|
---|
7367 | UINTN
|
---|
7368 | EFIAPI
|
---|
7369 | AsmMonitor (
|
---|
7370 | IN UINTN Eax,
|
---|
7371 | IN UINTN Ecx,
|
---|
7372 | IN UINTN Edx
|
---|
7373 | );
|
---|
7374 |
|
---|
7375 | /**
|
---|
7376 | Executes an MWAIT instruction.
|
---|
7377 |
|
---|
7378 | Executes an MWAIT instruction with the register state specified by Eax and
|
---|
7379 | Ecx. Returns Eax. This function is only available on IA-32 and x64.
|
---|
7380 |
|
---|
7381 | @param Eax The value to load into EAX or RAX before executing the MONITOR
|
---|
7382 | instruction.
|
---|
7383 | @param Ecx The value to load into ECX or RCX before executing the MONITOR
|
---|
7384 | instruction.
|
---|
7385 |
|
---|
7386 | @return Eax
|
---|
7387 |
|
---|
7388 | **/
|
---|
7389 | UINTN
|
---|
7390 | EFIAPI
|
---|
7391 | AsmMwait (
|
---|
7392 | IN UINTN Eax,
|
---|
7393 | IN UINTN Ecx
|
---|
7394 | );
|
---|
7395 |
|
---|
7396 | /**
|
---|
7397 | Executes a WBINVD instruction.
|
---|
7398 |
|
---|
7399 | Executes a WBINVD instruction. This function is only available on IA-32 and
|
---|
7400 | x64.
|
---|
7401 |
|
---|
7402 | **/
|
---|
7403 | VOID
|
---|
7404 | EFIAPI
|
---|
7405 | AsmWbinvd (
|
---|
7406 | VOID
|
---|
7407 | );
|
---|
7408 |
|
---|
7409 | /**
|
---|
7410 | Executes a INVD instruction.
|
---|
7411 |
|
---|
7412 | Executes a INVD instruction. This function is only available on IA-32 and
|
---|
7413 | x64.
|
---|
7414 |
|
---|
7415 | **/
|
---|
7416 | VOID
|
---|
7417 | EFIAPI
|
---|
7418 | AsmInvd (
|
---|
7419 | VOID
|
---|
7420 | );
|
---|
7421 |
|
---|
7422 | /**
|
---|
7423 | Flushes a cache line from all the instruction and data caches within the
|
---|
7424 | coherency domain of the CPU.
|
---|
7425 |
|
---|
7426 | Flushed the cache line specified by LinearAddress, and returns LinearAddress.
|
---|
7427 | This function is only available on IA-32 and x64.
|
---|
7428 |
|
---|
7429 | @param LinearAddress The address of the cache line to flush. If the CPU is
|
---|
7430 | in a physical addressing mode, then LinearAddress is a
|
---|
7431 | physical address. If the CPU is in a virtual
|
---|
7432 | addressing mode, then LinearAddress is a virtual
|
---|
7433 | address.
|
---|
7434 |
|
---|
7435 | @return LinearAddress.
|
---|
7436 | **/
|
---|
7437 | VOID *
|
---|
7438 | EFIAPI
|
---|
7439 | AsmFlushCacheLine (
|
---|
7440 | IN VOID *LinearAddress
|
---|
7441 | );
|
---|
7442 |
|
---|
7443 | /**
|
---|
7444 | Enables the 32-bit paging mode on the CPU.
|
---|
7445 |
|
---|
7446 | Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
|
---|
7447 | must be properly initialized prior to calling this service. This function
|
---|
7448 | assumes the current execution mode is 32-bit protected mode. This function is
|
---|
7449 | only available on IA-32. After the 32-bit paging mode is enabled, control is
|
---|
7450 | transferred to the function specified by EntryPoint using the new stack
|
---|
7451 | specified by NewStack and passing in the parameters specified by Context1 and
|
---|
7452 | Context2. Context1 and Context2 are optional and may be NULL. The function
|
---|
7453 | EntryPoint must never return.
|
---|
7454 |
|
---|
7455 | If the current execution mode is not 32-bit protected mode, then ASSERT().
|
---|
7456 | If EntryPoint is NULL, then ASSERT().
|
---|
7457 | If NewStack is NULL, then ASSERT().
|
---|
7458 |
|
---|
7459 | There are a number of constraints that must be followed before calling this
|
---|
7460 | function:
|
---|
7461 | 1) Interrupts must be disabled.
|
---|
7462 | 2) The caller must be in 32-bit protected mode with flat descriptors. This
|
---|
7463 | means all descriptors must have a base of 0 and a limit of 4GB.
|
---|
7464 | 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat
|
---|
7465 | descriptors.
|
---|
7466 | 4) CR3 must point to valid page tables that will be used once the transition
|
---|
7467 | is complete, and those page tables must guarantee that the pages for this
|
---|
7468 | function and the stack are identity mapped.
|
---|
7469 |
|
---|
7470 | @param EntryPoint A pointer to function to call with the new stack after
|
---|
7471 | paging is enabled.
|
---|
7472 | @param Context1 A pointer to the context to pass into the EntryPoint
|
---|
7473 | function as the first parameter after paging is enabled.
|
---|
7474 | @param Context2 A pointer to the context to pass into the EntryPoint
|
---|
7475 | function as the second parameter after paging is enabled.
|
---|
7476 | @param NewStack A pointer to the new stack to use for the EntryPoint
|
---|
7477 | function after paging is enabled.
|
---|
7478 |
|
---|
7479 | **/
|
---|
7480 | VOID
|
---|
7481 | EFIAPI
|
---|
7482 | AsmEnablePaging32 (
|
---|
7483 | IN SWITCH_STACK_ENTRY_POINT EntryPoint,
|
---|
7484 | IN VOID *Context1 OPTIONAL,
|
---|
7485 | IN VOID *Context2 OPTIONAL,
|
---|
7486 | IN VOID *NewStack
|
---|
7487 | );
|
---|
7488 |
|
---|
7489 | /**
|
---|
7490 | Disables the 32-bit paging mode on the CPU.
|
---|
7491 |
|
---|
7492 | Disables the 32-bit paging mode on the CPU and returns to 32-bit protected
|
---|
7493 | mode. This function assumes the current execution mode is 32-paged protected
|
---|
7494 | mode. This function is only available on IA-32. After the 32-bit paging mode
|
---|
7495 | is disabled, control is transferred to the function specified by EntryPoint
|
---|
7496 | using the new stack specified by NewStack and passing in the parameters
|
---|
7497 | specified by Context1 and Context2. Context1 and Context2 are optional and
|
---|
7498 | may be NULL. The function EntryPoint must never return.
|
---|
7499 |
|
---|
7500 | If the current execution mode is not 32-bit paged mode, then ASSERT().
|
---|
7501 | If EntryPoint is NULL, then ASSERT().
|
---|
7502 | If NewStack is NULL, then ASSERT().
|
---|
7503 |
|
---|
7504 | There are a number of constraints that must be followed before calling this
|
---|
7505 | function:
|
---|
7506 | 1) Interrupts must be disabled.
|
---|
7507 | 2) The caller must be in 32-bit paged mode.
|
---|
7508 | 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.
|
---|
7509 | 4) CR3 must point to valid page tables that guarantee that the pages for
|
---|
7510 | this function and the stack are identity mapped.
|
---|
7511 |
|
---|
7512 | @param EntryPoint A pointer to function to call with the new stack after
|
---|
7513 | paging is disabled.
|
---|
7514 | @param Context1 A pointer to the context to pass into the EntryPoint
|
---|
7515 | function as the first parameter after paging is disabled.
|
---|
7516 | @param Context2 A pointer to the context to pass into the EntryPoint
|
---|
7517 | function as the second parameter after paging is
|
---|
7518 | disabled.
|
---|
7519 | @param NewStack A pointer to the new stack to use for the EntryPoint
|
---|
7520 | function after paging is disabled.
|
---|
7521 |
|
---|
7522 | **/
|
---|
7523 | VOID
|
---|
7524 | EFIAPI
|
---|
7525 | AsmDisablePaging32 (
|
---|
7526 | IN SWITCH_STACK_ENTRY_POINT EntryPoint,
|
---|
7527 | IN VOID *Context1 OPTIONAL,
|
---|
7528 | IN VOID *Context2 OPTIONAL,
|
---|
7529 | IN VOID *NewStack
|
---|
7530 | );
|
---|
7531 |
|
---|
7532 | /**
|
---|
7533 | Enables the 64-bit paging mode on the CPU.
|
---|
7534 |
|
---|
7535 | Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
|
---|
7536 | must be properly initialized prior to calling this service. This function
|
---|
7537 | assumes the current execution mode is 32-bit protected mode with flat
|
---|
7538 | descriptors. This function is only available on IA-32. After the 64-bit
|
---|
7539 | paging mode is enabled, control is transferred to the function specified by
|
---|
7540 | EntryPoint using the new stack specified by NewStack and passing in the
|
---|
7541 | parameters specified by Context1 and Context2. Context1 and Context2 are
|
---|
7542 | optional and may be 0. The function EntryPoint must never return.
|
---|
7543 |
|
---|
7544 | If the current execution mode is not 32-bit protected mode with flat
|
---|
7545 | descriptors, then ASSERT().
|
---|
7546 | If EntryPoint is 0, then ASSERT().
|
---|
7547 | If NewStack is 0, then ASSERT().
|
---|
7548 |
|
---|
7549 | @param Cs The 16-bit selector to load in the CS before EntryPoint
|
---|
7550 | is called. The descriptor in the GDT that this selector
|
---|
7551 | references must be setup for long mode.
|
---|
7552 | @param EntryPoint The 64-bit virtual address of the function to call with
|
---|
7553 | the new stack after paging is enabled.
|
---|
7554 | @param Context1 The 64-bit virtual address of the context to pass into
|
---|
7555 | the EntryPoint function as the first parameter after
|
---|
7556 | paging is enabled.
|
---|
7557 | @param Context2 The 64-bit virtual address of the context to pass into
|
---|
7558 | the EntryPoint function as the second parameter after
|
---|
7559 | paging is enabled.
|
---|
7560 | @param NewStack The 64-bit virtual address of the new stack to use for
|
---|
7561 | the EntryPoint function after paging is enabled.
|
---|
7562 |
|
---|
7563 | **/
|
---|
7564 | VOID
|
---|
7565 | EFIAPI
|
---|
7566 | AsmEnablePaging64 (
|
---|
7567 | IN UINT16 Cs,
|
---|
7568 | IN UINT64 EntryPoint,
|
---|
7569 | IN UINT64 Context1 OPTIONAL,
|
---|
7570 | IN UINT64 Context2 OPTIONAL,
|
---|
7571 | IN UINT64 NewStack
|
---|
7572 | );
|
---|
7573 |
|
---|
7574 | /**
|
---|
7575 | Disables the 64-bit paging mode on the CPU.
|
---|
7576 |
|
---|
7577 | Disables the 64-bit paging mode on the CPU and returns to 32-bit protected
|
---|
7578 | mode. This function assumes the current execution mode is 64-paging mode.
|
---|
7579 | This function is only available on x64. After the 64-bit paging mode is
|
---|
7580 | disabled, control is transferred to the function specified by EntryPoint
|
---|
7581 | using the new stack specified by NewStack and passing in the parameters
|
---|
7582 | specified by Context1 and Context2. Context1 and Context2 are optional and
|
---|
7583 | may be 0. The function EntryPoint must never return.
|
---|
7584 |
|
---|
7585 | If the current execution mode is not 64-bit paged mode, then ASSERT().
|
---|
7586 | If EntryPoint is 0, then ASSERT().
|
---|
7587 | If NewStack is 0, then ASSERT().
|
---|
7588 |
|
---|
7589 | @param Cs The 16-bit selector to load in the CS before EntryPoint
|
---|
7590 | is called. The descriptor in the GDT that this selector
|
---|
7591 | references must be setup for 32-bit protected mode.
|
---|
7592 | @param EntryPoint The 64-bit virtual address of the function to call with
|
---|
7593 | the new stack after paging is disabled.
|
---|
7594 | @param Context1 The 64-bit virtual address of the context to pass into
|
---|
7595 | the EntryPoint function as the first parameter after
|
---|
7596 | paging is disabled.
|
---|
7597 | @param Context2 The 64-bit virtual address of the context to pass into
|
---|
7598 | the EntryPoint function as the second parameter after
|
---|
7599 | paging is disabled.
|
---|
7600 | @param NewStack The 64-bit virtual address of the new stack to use for
|
---|
7601 | the EntryPoint function after paging is disabled.
|
---|
7602 |
|
---|
7603 | **/
|
---|
7604 | VOID
|
---|
7605 | EFIAPI
|
---|
7606 | AsmDisablePaging64 (
|
---|
7607 | IN UINT16 Cs,
|
---|
7608 | IN UINT32 EntryPoint,
|
---|
7609 | IN UINT32 Context1 OPTIONAL,
|
---|
7610 | IN UINT32 Context2 OPTIONAL,
|
---|
7611 | IN UINT32 NewStack
|
---|
7612 | );
|
---|
7613 |
|
---|
7614 | //
|
---|
7615 | // 16-bit thunking services
|
---|
7616 | //
|
---|
7617 |
|
---|
7618 | /**
|
---|
7619 | Retrieves the properties for 16-bit thunk functions.
|
---|
7620 |
|
---|
7621 | Computes the size of the buffer and stack below 1MB required to use the
|
---|
7622 | AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This
|
---|
7623 | buffer size is returned in RealModeBufferSize, and the stack size is returned
|
---|
7624 | in ExtraStackSize. If parameters are passed to the 16-bit real mode code,
|
---|
7625 | then the actual minimum stack size is ExtraStackSize plus the maximum number
|
---|
7626 | of bytes that need to be passed to the 16-bit real mode code.
|
---|
7627 |
|
---|
7628 | If RealModeBufferSize is NULL, then ASSERT().
|
---|
7629 | If ExtraStackSize is NULL, then ASSERT().
|
---|
7630 |
|
---|
7631 | @param RealModeBufferSize A pointer to the size of the buffer below 1MB
|
---|
7632 | required to use the 16-bit thunk functions.
|
---|
7633 | @param ExtraStackSize A pointer to the extra size of stack below 1MB
|
---|
7634 | that the 16-bit thunk functions require for
|
---|
7635 | temporary storage in the transition to and from
|
---|
7636 | 16-bit real mode.
|
---|
7637 |
|
---|
7638 | **/
|
---|
7639 | VOID
|
---|
7640 | EFIAPI
|
---|
7641 | AsmGetThunk16Properties (
|
---|
7642 | OUT UINT32 *RealModeBufferSize,
|
---|
7643 | OUT UINT32 *ExtraStackSize
|
---|
7644 | );
|
---|
7645 |
|
---|
7646 | /**
|
---|
7647 | Prepares all structures a code required to use AsmThunk16().
|
---|
7648 |
|
---|
7649 | Prepares all structures and code required to use AsmThunk16().
|
---|
7650 |
|
---|
7651 | This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
|
---|
7652 | virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.
|
---|
7653 |
|
---|
7654 | If ThunkContext is NULL, then ASSERT().
|
---|
7655 |
|
---|
7656 | @param ThunkContext A pointer to the context structure that describes the
|
---|
7657 | 16-bit real mode code to call.
|
---|
7658 |
|
---|
7659 | **/
|
---|
7660 | VOID
|
---|
7661 | EFIAPI
|
---|
7662 | AsmPrepareThunk16 (
|
---|
7663 | IN OUT THUNK_CONTEXT *ThunkContext
|
---|
7664 | );
|
---|
7665 |
|
---|
7666 | /**
|
---|
7667 | Transfers control to a 16-bit real mode entry point and returns the results.
|
---|
7668 |
|
---|
7669 | Transfers control to a 16-bit real mode entry point and returns the results.
|
---|
7670 | AsmPrepareThunk16() must be called with ThunkContext before this function is used.
|
---|
7671 | This function must be called with interrupts disabled.
|
---|
7672 |
|
---|
7673 | The register state from the RealModeState field of ThunkContext is restored just prior
|
---|
7674 | to calling the 16-bit real mode entry point. This includes the EFLAGS field of RealModeState,
|
---|
7675 | which is used to set the interrupt state when a 16-bit real mode entry point is called.
|
---|
7676 | Control is transferred to the 16-bit real mode entry point specified by the CS and Eip fields of RealModeState.
|
---|
7677 | The stack is initialized to the SS and ESP fields of RealModeState. Any parameters passed to
|
---|
7678 | the 16-bit real mode code must be populated by the caller at SS:ESP prior to calling this function.
|
---|
7679 | The 16-bit real mode entry point is invoked with a 16-bit CALL FAR instruction,
|
---|
7680 | so when accessing stack contents, the 16-bit real mode code must account for the 16-bit segment
|
---|
7681 | and 16-bit offset of the return address that were pushed onto the stack. The 16-bit real mode entry
|
---|
7682 | point must exit with a RETF instruction. The register state is captured into RealModeState immediately
|
---|
7683 | after the RETF instruction is executed.
|
---|
7684 |
|
---|
7685 | If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,
|
---|
7686 | or any of the 16-bit real mode code makes a SW interrupt, then the caller is responsible for making sure
|
---|
7687 | the IDT at address 0 is initialized to handle any HW or SW interrupts that may occur while in 16-bit real mode.
|
---|
7688 |
|
---|
7689 | If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,
|
---|
7690 | then the caller is responsible for making sure the 8259 PIC is in a state compatible with 16-bit real mode.
|
---|
7691 | This includes the base vectors, the interrupt masks, and the edge/level trigger mode.
|
---|
7692 |
|
---|
7693 | If THUNK_ATTRIBUTE_BIG_REAL_MODE is set in the ThunkAttributes field of ThunkContext, then the user code
|
---|
7694 | is invoked in big real mode. Otherwise, the user code is invoked in 16-bit real mode with 64KB segment limits.
|
---|
7695 |
|
---|
7696 | If neither THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 nor THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in
|
---|
7697 | ThunkAttributes, then it is assumed that the user code did not enable the A20 mask, and no attempt is made to
|
---|
7698 | disable the A20 mask.
|
---|
7699 |
|
---|
7700 | If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is set and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is clear in
|
---|
7701 | ThunkAttributes, then attempt to use the INT 15 service to disable the A20 mask. If this INT 15 call fails,
|
---|
7702 | then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
|
---|
7703 |
|
---|
7704 | If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is clear and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is set in
|
---|
7705 | ThunkAttributes, then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.
|
---|
7706 |
|
---|
7707 | If ThunkContext is NULL, then ASSERT().
|
---|
7708 | If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().
|
---|
7709 | If both THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in
|
---|
7710 | ThunkAttributes, then ASSERT().
|
---|
7711 |
|
---|
7712 | This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
|
---|
7713 | virtual to physical mappings for ThunkContext.RealModeBuffer are mapped 1:1.
|
---|
7714 |
|
---|
7715 | @param ThunkContext A pointer to the context structure that describes the
|
---|
7716 | 16-bit real mode code to call.
|
---|
7717 |
|
---|
7718 | **/
|
---|
7719 | VOID
|
---|
7720 | EFIAPI
|
---|
7721 | AsmThunk16 (
|
---|
7722 | IN OUT THUNK_CONTEXT *ThunkContext
|
---|
7723 | );
|
---|
7724 |
|
---|
7725 | /**
|
---|
7726 | Prepares all structures and code for a 16-bit real mode thunk, transfers
|
---|
7727 | control to a 16-bit real mode entry point, and returns the results.
|
---|
7728 |
|
---|
7729 | Prepares all structures and code for a 16-bit real mode thunk, transfers
|
---|
7730 | control to a 16-bit real mode entry point, and returns the results. If the
|
---|
7731 | caller only need to perform a single 16-bit real mode thunk, then this
|
---|
7732 | service should be used. If the caller intends to make more than one 16-bit
|
---|
7733 | real mode thunk, then it is more efficient if AsmPrepareThunk16() is called
|
---|
7734 | once and AsmThunk16() can be called for each 16-bit real mode thunk.
|
---|
7735 |
|
---|
7736 | This interface is limited to be used in either physical mode or virtual modes with paging enabled where the
|
---|
7737 | virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.
|
---|
7738 |
|
---|
7739 | See AsmPrepareThunk16() and AsmThunk16() for the detailed description and ASSERT() conditions.
|
---|
7740 |
|
---|
7741 | @param ThunkContext A pointer to the context structure that describes the
|
---|
7742 | 16-bit real mode code to call.
|
---|
7743 |
|
---|
7744 | **/
|
---|
7745 | VOID
|
---|
7746 | EFIAPI
|
---|
7747 | AsmPrepareAndThunk16 (
|
---|
7748 | IN OUT THUNK_CONTEXT *ThunkContext
|
---|
7749 | );
|
---|
7750 |
|
---|
7751 | /**
|
---|
7752 | Generates a 16-bit random number through RDRAND instruction.
|
---|
7753 |
|
---|
7754 | if Rand is NULL, then ASSERT().
|
---|
7755 |
|
---|
7756 | @param[out] Rand Buffer pointer to store the random result.
|
---|
7757 |
|
---|
7758 | @retval TRUE RDRAND call was successful.
|
---|
7759 | @retval FALSE Failed attempts to call RDRAND.
|
---|
7760 |
|
---|
7761 | **/
|
---|
7762 | BOOLEAN
|
---|
7763 | EFIAPI
|
---|
7764 | AsmRdRand16 (
|
---|
7765 | OUT UINT16 *Rand
|
---|
7766 | );
|
---|
7767 |
|
---|
7768 | /**
|
---|
7769 | Generates a 32-bit random number through RDRAND instruction.
|
---|
7770 |
|
---|
7771 | if Rand is NULL, then ASSERT().
|
---|
7772 |
|
---|
7773 | @param[out] Rand Buffer pointer to store the random result.
|
---|
7774 |
|
---|
7775 | @retval TRUE RDRAND call was successful.
|
---|
7776 | @retval FALSE Failed attempts to call RDRAND.
|
---|
7777 |
|
---|
7778 | **/
|
---|
7779 | BOOLEAN
|
---|
7780 | EFIAPI
|
---|
7781 | AsmRdRand32 (
|
---|
7782 | OUT UINT32 *Rand
|
---|
7783 | );
|
---|
7784 |
|
---|
7785 | /**
|
---|
7786 | Generates a 64-bit random number through RDRAND instruction.
|
---|
7787 |
|
---|
7788 | if Rand is NULL, then ASSERT().
|
---|
7789 |
|
---|
7790 | @param[out] Rand Buffer pointer to store the random result.
|
---|
7791 |
|
---|
7792 | @retval TRUE RDRAND call was successful.
|
---|
7793 | @retval FALSE Failed attempts to call RDRAND.
|
---|
7794 |
|
---|
7795 | **/
|
---|
7796 | BOOLEAN
|
---|
7797 | EFIAPI
|
---|
7798 | AsmRdRand64 (
|
---|
7799 | OUT UINT64 *Rand
|
---|
7800 | );
|
---|
7801 |
|
---|
7802 | /**
|
---|
7803 | Load given selector into TR register.
|
---|
7804 |
|
---|
7805 | @param[in] Selector Task segment selector
|
---|
7806 | **/
|
---|
7807 | VOID
|
---|
7808 | EFIAPI
|
---|
7809 | AsmWriteTr (
|
---|
7810 | IN UINT16 Selector
|
---|
7811 | );
|
---|
7812 |
|
---|
7813 | /**
|
---|
7814 | Performs a serializing operation on all load-from-memory instructions that
|
---|
7815 | were issued prior the AsmLfence function.
|
---|
7816 |
|
---|
7817 | Executes a LFENCE instruction. This function is only available on IA-32 and x64.
|
---|
7818 |
|
---|
7819 | **/
|
---|
7820 | VOID
|
---|
7821 | EFIAPI
|
---|
7822 | AsmLfence (
|
---|
7823 | VOID
|
---|
7824 | );
|
---|
7825 |
|
---|
7826 | /**
|
---|
7827 | Executes a XGETBV instruction
|
---|
7828 |
|
---|
7829 | Executes a XGETBV instruction. This function is only available on IA-32 and
|
---|
7830 | x64.
|
---|
7831 |
|
---|
7832 | @param[in] Index Extended control register index
|
---|
7833 |
|
---|
7834 | @return The current value of the extended control register
|
---|
7835 | **/
|
---|
7836 | UINT64
|
---|
7837 | EFIAPI
|
---|
7838 | AsmXGetBv (
|
---|
7839 | IN UINT32 Index
|
---|
7840 | );
|
---|
7841 |
|
---|
7842 | /**
|
---|
7843 | Executes a XSETBV instruction to write a 64-bit value to a Extended Control
|
---|
7844 | Register(XCR), and returns the value.
|
---|
7845 |
|
---|
7846 | Writes the 64-bit value specified by Value to the XCR specified by Index. The
|
---|
7847 | 64-bit value written to the XCR is returned. No parameter checking is
|
---|
7848 | performed on Index or Value, and some of these may cause CPU exceptions. The
|
---|
7849 | caller must either guarantee that Index and Value are valid, or the caller
|
---|
7850 | must establish proper exception handlers. This function is only available on
|
---|
7851 | IA-32 and x64.
|
---|
7852 |
|
---|
7853 | @param Index The 32-bit XCR index to write.
|
---|
7854 | @param Value The 64-bit value to write to the XCR.
|
---|
7855 |
|
---|
7856 | @return Value
|
---|
7857 |
|
---|
7858 | **/
|
---|
7859 | UINT64
|
---|
7860 | EFIAPI
|
---|
7861 | AsmXSetBv (
|
---|
7862 | IN UINT32 Index,
|
---|
7863 | IN UINT64 Value
|
---|
7864 | );
|
---|
7865 |
|
---|
7866 | /**
|
---|
7867 | Executes a VMGEXIT instruction (VMMCALL with a REP prefix)
|
---|
7868 |
|
---|
7869 | Executes a VMGEXIT instruction. This function is only available on IA-32 and
|
---|
7870 | x64.
|
---|
7871 |
|
---|
7872 | **/
|
---|
7873 | VOID
|
---|
7874 | EFIAPI
|
---|
7875 | AsmVmgExit (
|
---|
7876 | VOID
|
---|
7877 | );
|
---|
7878 |
|
---|
7879 | ///
|
---|
7880 | /// The structure used to supply and return data to and from the SVSM.
|
---|
7881 | ///
|
---|
7882 | typedef struct {
|
---|
7883 | VOID *Caa;
|
---|
7884 | UINT64 RaxIn;
|
---|
7885 | UINT64 RcxIn;
|
---|
7886 | UINT64 RdxIn;
|
---|
7887 | UINT64 R8In;
|
---|
7888 | UINT64 R9In;
|
---|
7889 | UINT64 RaxOut;
|
---|
7890 | UINT64 RcxOut;
|
---|
7891 | UINT64 RdxOut;
|
---|
7892 | UINT64 R8Out;
|
---|
7893 | UINT64 R9Out;
|
---|
7894 | UINT8 *CallPending;
|
---|
7895 | } SVSM_CALL_DATA;
|
---|
7896 |
|
---|
7897 | /**
|
---|
7898 | Executes a VMGEXIT instruction (VMMCALL with a REP prefix) with arguments
|
---|
7899 | and return code
|
---|
7900 |
|
---|
7901 | Executes a VMGEXIT instruction placing the specified arguments in the
|
---|
7902 | corresponding registers before invocation. Upon return an XCHG is done to
|
---|
7903 | atomically clear and retrieve the SVSM call pending value. The returned RAX
|
---|
7904 | register value becomes the function return code. This function is intended
|
---|
7905 | for use with an SVSM. This function is only available on IA-32 and x64.
|
---|
7906 |
|
---|
7907 | @param[in,out] SvsmCallPending Pointer to the location of the SVSM call data
|
---|
7908 |
|
---|
7909 | @return Value of the RAX register on return
|
---|
7910 |
|
---|
7911 | **/
|
---|
7912 | UINT32
|
---|
7913 | EFIAPI
|
---|
7914 | AsmVmgExitSvsm (
|
---|
7915 | IN OUT SVSM_CALL_DATA *SvsmCallData
|
---|
7916 | );
|
---|
7917 |
|
---|
7918 | /**
|
---|
7919 | Patch the immediate operand of an IA32 or X64 instruction such that the byte,
|
---|
7920 | word, dword or qword operand is encoded at the end of the instruction's
|
---|
7921 | binary representation.
|
---|
7922 |
|
---|
7923 | This function should be used to update object code that was compiled with
|
---|
7924 | NASM from assembly source code. Example:
|
---|
7925 |
|
---|
7926 | NASM source code:
|
---|
7927 |
|
---|
7928 | mov eax, strict dword 0 ; the imm32 zero operand will be patched
|
---|
7929 | ASM_PFX(gPatchCr3):
|
---|
7930 | mov cr3, eax
|
---|
7931 |
|
---|
7932 | C source code:
|
---|
7933 |
|
---|
7934 | X86_ASSEMBLY_PATCH_LABEL gPatchCr3;
|
---|
7935 | PatchInstructionX86 (gPatchCr3, AsmReadCr3 (), 4);
|
---|
7936 |
|
---|
7937 | @param[out] InstructionEnd Pointer right past the instruction to patch. The
|
---|
7938 | immediate operand to patch is expected to
|
---|
7939 | comprise the trailing bytes of the instruction.
|
---|
7940 | If InstructionEnd is closer to address 0 than
|
---|
7941 | ValueSize permits, then ASSERT().
|
---|
7942 |
|
---|
7943 | @param[in] PatchValue The constant to write to the immediate operand.
|
---|
7944 | The caller is responsible for ensuring that
|
---|
7945 | PatchValue can be represented in the byte, word,
|
---|
7946 | dword or qword operand (as indicated through
|
---|
7947 | ValueSize); otherwise ASSERT().
|
---|
7948 |
|
---|
7949 | @param[in] ValueSize The size of the operand in bytes; must be 1, 2,
|
---|
7950 | 4, or 8. ASSERT() otherwise.
|
---|
7951 | **/
|
---|
7952 | VOID
|
---|
7953 | EFIAPI
|
---|
7954 | PatchInstructionX86 (
|
---|
7955 | OUT X86_ASSEMBLY_PATCH_LABEL *InstructionEnd,
|
---|
7956 | IN UINT64 PatchValue,
|
---|
7957 | IN UINTN ValueSize
|
---|
7958 | );
|
---|
7959 |
|
---|
7960 | #endif // defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
|
---|
7961 | #endif // !defined (__BASE_LIB__)
|
---|