]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseLib/BaseLibInternals.h
Split out Synchronization Library from Base Library
[mirror_edk2.git] / MdePkg / Library / BaseLib / BaseLibInternals.h
1 /** @file
2 Declaration of internal functions in BaseLib.
3
4 Copyright (c) 2006 - 2008, Intel Corporation<BR>
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #ifndef __BASE_LIB_INTERNALS__
16 #define __BASE_LIB_INTERNALS__
17
18 #include <Base.h>
19 #include <Library/BaseLib.h>
20 #include <Library/BaseMemoryLib.h>
21 #include <Library/DebugLib.h>
22 #include <Library/PcdLib.h>
23
24 //
25 // Math functions
26 //
27
28 /**
29 Shifts a 64-bit integer left between 0 and 63 bits. The low bits
30 are filled with zeros. The shifted value is returned.
31
32 This function shifts the 64-bit value Operand to the left by Count bits. The
33 low Count bits are set to zero. The shifted value is returned.
34
35 @param Operand The 64-bit operand to shift left.
36 @param Count The number of bits to shift left.
37
38 @return Operand << Count
39
40 **/
41 UINT64
42 EFIAPI
43 InternalMathLShiftU64 (
44 IN UINT64 Operand,
45 IN UINTN Count
46 );
47
48 /**
49 Shifts a 64-bit integer right between 0 and 63 bits. This high bits
50 are filled with zeros. The shifted value is returned.
51
52 This function shifts the 64-bit value Operand to the right by Count bits. The
53 high Count bits are set to zero. The shifted value is returned.
54
55 @param Operand The 64-bit operand to shift right.
56 @param Count The number of bits to shift right.
57
58 @return Operand >> Count
59
60 **/
61 UINT64
62 EFIAPI
63 InternalMathRShiftU64 (
64 IN UINT64 Operand,
65 IN UINTN Count
66 );
67
68 /**
69 Shifts a 64-bit integer right between 0 and 63 bits. The high bits
70 are filled with original integer's bit 63. The shifted value is returned.
71
72 This function shifts the 64-bit value Operand to the right by Count bits. The
73 high Count bits are set to bit 63 of Operand. The shifted value is returned.
74
75 @param Operand The 64-bit operand to shift right.
76 @param Count The number of bits to shift right.
77
78 @return Operand arithmetically shifted right by Count
79
80 **/
81 UINT64
82 EFIAPI
83 InternalMathARShiftU64 (
84 IN UINT64 Operand,
85 IN UINTN Count
86 );
87
88 /**
89 Rotates a 64-bit integer left between 0 and 63 bits, filling
90 the low bits with the high bits that were rotated.
91
92 This function rotates the 64-bit value Operand to the left by Count bits. The
93 low Count bits are fill with the high Count bits of Operand. The rotated
94 value is returned.
95
96 @param Operand The 64-bit operand to rotate left.
97 @param Count The number of bits to rotate left.
98
99 @return Operand <<< Count
100
101 **/
102 UINT64
103 EFIAPI
104 InternalMathLRotU64 (
105 IN UINT64 Operand,
106 IN UINTN Count
107 );
108
109 /**
110 Rotates a 64-bit integer right between 0 and 63 bits, filling
111 the high bits with the high low bits that were rotated.
112
113 This function rotates the 64-bit value Operand to the right by Count bits.
114 The high Count bits are fill with the low Count bits of Operand. The rotated
115 value is returned.
116
117 @param Operand The 64-bit operand to rotate right.
118 @param Count The number of bits to rotate right.
119
120 @return Operand >>> Count
121
122 **/
123 UINT64
124 EFIAPI
125 InternalMathRRotU64 (
126 IN UINT64 Operand,
127 IN UINTN Count
128 );
129
130 /**
131 Switches the endianess of a 64-bit integer.
132
133 This function swaps the bytes in a 64-bit unsigned value to switch the value
134 from little endian to big endian or vice versa. The byte swapped value is
135 returned.
136
137 @param Operand A 64-bit unsigned value.
138
139 @return The byte swapped Operand.
140
141 **/
142 UINT64
143 EFIAPI
144 InternalMathSwapBytes64 (
145 IN UINT64 Operand
146 );
147
148 /**
149 Multiples a 64-bit unsigned integer by a 32-bit unsigned integer
150 and generates a 64-bit unsigned result.
151
152 This function multiples the 64-bit unsigned value Multiplicand by the 32-bit
153 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
154 bit unsigned result is returned.
155
156 @param Multiplicand A 64-bit unsigned value.
157 @param Multiplier A 32-bit unsigned value.
158
159 @return Multiplicand * Multiplier
160
161 **/
162 UINT64
163 EFIAPI
164 InternalMathMultU64x32 (
165 IN UINT64 Multiplicand,
166 IN UINT32 Multiplier
167 );
168
169 /**
170 Multiples a 64-bit unsigned integer by a 64-bit unsigned integer
171 and generates a 64-bit unsigned result.
172
173 This function multiples the 64-bit unsigned value Multiplicand by the 64-bit
174 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
175 bit unsigned result is returned.
176
177 @param Multiplicand A 64-bit unsigned value.
178 @param Multiplier A 64-bit unsigned value.
179
180 @return Multiplicand * Multiplier
181
182 **/
183 UINT64
184 EFIAPI
185 InternalMathMultU64x64 (
186 IN UINT64 Multiplicand,
187 IN UINT64 Multiplier
188 );
189
190 /**
191 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and
192 generates a 64-bit unsigned result.
193
194 This function divides the 64-bit unsigned value Dividend by the 32-bit
195 unsigned value Divisor and generates a 64-bit unsigned quotient. This
196 function returns the 64-bit unsigned quotient.
197
198 @param Dividend A 64-bit unsigned value.
199 @param Divisor A 32-bit unsigned value.
200
201 @return Dividend / Divisor
202
203 **/
204 UINT64
205 EFIAPI
206 InternalMathDivU64x32 (
207 IN UINT64 Dividend,
208 IN UINT32 Divisor
209 );
210
211 /**
212 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and
213 generates a 32-bit unsigned remainder.
214
215 This function divides the 64-bit unsigned value Dividend by the 32-bit
216 unsigned value Divisor and generates a 32-bit remainder. This function
217 returns the 32-bit unsigned remainder.
218
219 @param Dividend A 64-bit unsigned value.
220 @param Divisor A 32-bit unsigned value.
221
222 @return Dividend % Divisor
223
224 **/
225 UINT32
226 EFIAPI
227 InternalMathModU64x32 (
228 IN UINT64 Dividend,
229 IN UINT32 Divisor
230 );
231
232 /**
233 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and
234 generates a 64-bit unsigned result and an optional 32-bit unsigned remainder.
235
236 This function divides the 64-bit unsigned value Dividend by the 32-bit
237 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
238 is not NULL, then the 32-bit unsigned remainder is returned in Remainder.
239 This function returns the 64-bit unsigned quotient.
240
241 @param Dividend A 64-bit unsigned value.
242 @param Divisor A 32-bit unsigned value.
243 @param Remainder A pointer to a 32-bit unsigned value. This parameter is
244 optional and may be NULL.
245
246 @return Dividend / Divisor
247
248 **/
249 UINT64
250 EFIAPI
251 InternalMathDivRemU64x32 (
252 IN UINT64 Dividend,
253 IN UINT32 Divisor,
254 OUT UINT32 *Remainder OPTIONAL
255 );
256
257 /**
258 Divides a 64-bit unsigned integer by a 64-bit unsigned integer and
259 generates a 64-bit unsigned result and an optional 64-bit unsigned remainder.
260
261 This function divides the 64-bit unsigned value Dividend by the 64-bit
262 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
263 is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
264 This function returns the 64-bit unsigned quotient.
265
266 @param Dividend A 64-bit unsigned value.
267 @param Divisor A 64-bit unsigned value.
268 @param Remainder A pointer to a 64-bit unsigned value. This parameter is
269 optional and may be NULL.
270
271 @return Dividend / Divisor
272
273 **/
274 UINT64
275 EFIAPI
276 InternalMathDivRemU64x64 (
277 IN UINT64 Dividend,
278 IN UINT64 Divisor,
279 OUT UINT64 *Remainder OPTIONAL
280 );
281
282 /**
283 Divides a 64-bit signed integer by a 64-bit signed integer and
284 generates a 64-bit signed result and an optional 64-bit signed remainder.
285
286 This function divides the 64-bit signed value Dividend by the 64-bit
287 signed value Divisor and generates a 64-bit signed quotient. If Remainder
288 is not NULL, then the 64-bit signed remainder is returned in Remainder.
289 This function returns the 64-bit signed quotient.
290
291 @param Dividend A 64-bit signed value.
292 @param Divisor A 64-bit signed value.
293 @param Remainder A pointer to a 64-bit signed value. This parameter is
294 optional and may be NULL.
295
296 @return Dividend / Divisor
297
298 **/
299 INT64
300 EFIAPI
301 InternalMathDivRemS64x64 (
302 IN INT64 Dividend,
303 IN INT64 Divisor,
304 OUT INT64 *Remainder OPTIONAL
305 );
306
307 /**
308 Transfers control to a function starting with a new stack.
309
310 Transfers control to the function specified by EntryPoint using the
311 new stack specified by NewStack and passing in the parameters specified
312 by Context1 and Context2. Context1 and Context2 are optional and may
313 be NULL. The function EntryPoint must never return.
314 Marker will be ignored on IA-32, x64, and EBC.
315 IPF CPUs expect one additional parameter of type VOID * that specifies
316 the new backing store pointer.
317
318 If EntryPoint is NULL, then ASSERT().
319 If NewStack is NULL, then ASSERT().
320
321 @param EntryPoint A pointer to function to call with the new stack.
322 @param Context1 A pointer to the context to pass into the EntryPoint
323 function.
324 @param Context2 A pointer to the context to pass into the EntryPoint
325 function.
326 @param NewStack A pointer to the new stack to use for the EntryPoint
327 function.
328 @param Marker VA_LIST marker for the variable argument list.
329
330 **/
331 VOID
332 EFIAPI
333 InternalSwitchStack (
334 IN SWITCH_STACK_ENTRY_POINT EntryPoint,
335 IN VOID *Context1, OPTIONAL
336 IN VOID *Context2, OPTIONAL
337 IN VOID *NewStack,
338 IN VA_LIST Marker
339 );
340
341
342 /**
343 Worker function that locates the Node in the List.
344
345 By searching the List, finds the location of the Node in List. At the same time,
346 verifies the validity of this list.
347
348 If List is NULL, then ASSERT().
349 If List->ForwardLink is NULL, then ASSERT().
350 If List->backLink is NULL, then ASSERT().
351 If Node is NULL, then ASSERT();
352 If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number
353 of nodes in ListHead, including the ListHead node, is greater than or
354 equal to PcdMaximumLinkedListLength, then ASSERT().
355
356 @param List A pointer to a node in a linked list.
357 @param Node A pointer to one nod.
358
359 @retval TRUE Node is in List
360 @retval FALSE Node isn't in List, or List is invalid
361
362 **/
363 BOOLEAN
364 EFIAPI
365 IsNodeInList (
366 IN CONST LIST_ENTRY *List,
367 IN CONST LIST_ENTRY *Node
368 );
369
370 /**
371 Worker function that returns a bit field from Operand.
372
373 Returns the bitfield specified by the StartBit and the EndBit from Operand.
374
375 @param Operand Operand on which to perform the bitfield operation.
376 @param StartBit The ordinal of the least significant bit in the bit field.
377 @param EndBit The ordinal of the most significant bit in the bit field.
378
379 @return The bit field read.
380
381 **/
382 UINTN
383 EFIAPI
384 BitFieldReadUint (
385 IN UINTN Operand,
386 IN UINTN StartBit,
387 IN UINTN EndBit
388 );
389
390
391 /**
392 Worker function that reads a bit field from Operand, performs a bitwise OR,
393 and returns the result.
394
395 Performs a bitwise OR between the bit field specified by StartBit and EndBit
396 in Operand and the value specified by AndData. All other bits in Operand are
397 preserved. The new value is returned.
398
399 @param Operand Operand on which to perform the bitfield operation.
400 @param StartBit The ordinal of the least significant bit in the bit field.
401 @param EndBit The ordinal of the most significant bit in the bit field.
402 @param OrData The value to OR with the read value from the value
403
404 @return The new value.
405
406 **/
407 UINTN
408 EFIAPI
409 BitFieldOrUint (
410 IN UINTN Operand,
411 IN UINTN StartBit,
412 IN UINTN EndBit,
413 IN UINTN OrData
414 );
415
416
417 /**
418 Worker function that reads a bit field from Operand, performs a bitwise AND,
419 and returns the result.
420
421 Performs a bitwise AND between the bit field specified by StartBit and EndBit
422 in Operand and the value specified by AndData. All other bits in Operand are
423 preserved. The new value is returned.
424
425 @param Operand Operand on which to perform the bitfield operation.
426 @param StartBit The ordinal of the least significant bit in the bit field.
427 @param EndBit The ordinal of the most significant bit in the bit field.
428 @param AndData The value to And with the read value from the value
429
430 @return The new value.
431
432 **/
433 UINTN
434 EFIAPI
435 BitFieldAndUint (
436 IN UINTN Operand,
437 IN UINTN StartBit,
438 IN UINTN EndBit,
439 IN UINTN AndData
440 );
441
442
443 /**
444 Worker function that checks ASSERT condition for JumpBuffer
445
446 Checks ASSERT condition for JumpBuffer.
447
448 If JumpBuffer is NULL, then ASSERT().
449 For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
450
451 @param JumpBuffer A pointer to CPU context buffer.
452
453 **/
454 VOID
455 EFIAPI
456 InternalAssertJumpBuffer (
457 IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer
458 );
459
460
461 /**
462 Restores the CPU context that was saved with SetJump().
463
464 Restores the CPU context from the buffer specified by JumpBuffer.
465 This function never returns to the caller.
466 Instead is resumes execution based on the state of JumpBuffer.
467
468 @param JumpBuffer A pointer to CPU context buffer.
469 @param Value The value to return when the SetJump() context is restored.
470
471 **/
472 VOID
473 EFIAPI
474 InternalLongJump (
475 IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer,
476 IN UINTN Value
477 );
478
479
480 //
481 // Ia32 and x64 specific functions
482 //
483 #if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
484
485 /**
486 Reads the current Global Descriptor Table Register(GDTR) descriptor.
487
488 Reads and returns the current GDTR descriptor and returns it in Gdtr. This
489 function is only available on IA-32 and x64.
490
491 @param Gdtr Pointer to a GDTR descriptor.
492
493 **/
494 VOID
495 EFIAPI
496 InternalX86ReadGdtr (
497 OUT IA32_DESCRIPTOR *Gdtr
498 );
499
500 /**
501 Writes the current Global Descriptor Table Register (GDTR) descriptor.
502
503 Writes and the current GDTR descriptor specified by Gdtr. This function is
504 only available on IA-32 and x64.
505
506 @param Gdtr Pointer to a GDTR descriptor.
507
508 **/
509 VOID
510 EFIAPI
511 InternalX86WriteGdtr (
512 IN CONST IA32_DESCRIPTOR *Gdtr
513 );
514
515 /**
516 Reads the current Interrupt Descriptor Table Register(GDTR) descriptor.
517
518 Reads and returns the current IDTR descriptor and returns it in Idtr. This
519 function is only available on IA-32 and x64.
520
521 @param Idtr Pointer to a IDTR descriptor.
522
523 **/
524 VOID
525 EFIAPI
526 InternalX86ReadIdtr (
527 OUT IA32_DESCRIPTOR *Idtr
528 );
529
530 /**
531 Writes the current Interrupt Descriptor Table Register(GDTR) descriptor.
532
533 Writes the current IDTR descriptor and returns it in Idtr. This function is
534 only available on IA-32 and x64.
535
536 @param Idtr Pointer to a IDTR descriptor.
537
538 **/
539 VOID
540 EFIAPI
541 InternalX86WriteIdtr (
542 IN CONST IA32_DESCRIPTOR *Idtr
543 );
544
545 /**
546 Save the current floating point/SSE/SSE2 context to a buffer.
547
548 Saves the current floating point/SSE/SSE2 state to the buffer specified by
549 Buffer. Buffer must be aligned on a 16-byte boundary. This function is only
550 available on IA-32 and x64.
551
552 @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.
553
554 **/
555 VOID
556 EFIAPI
557 InternalX86FxSave (
558 OUT IA32_FX_BUFFER *Buffer
559 );
560
561 /**
562 Restores the current floating point/SSE/SSE2 context from a buffer.
563
564 Restores the current floating point/SSE/SSE2 state from the buffer specified
565 by Buffer. Buffer must be aligned on a 16-byte boundary. This function is
566 only available on IA-32 and x64.
567
568 @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.
569
570 **/
571 VOID
572 EFIAPI
573 InternalX86FxRestore (
574 IN CONST IA32_FX_BUFFER *Buffer
575 );
576
577 /**
578 Enables the 32-bit paging mode on the CPU.
579
580 Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
581 must be properly initialized prior to calling this service. This function
582 assumes the current execution mode is 32-bit protected mode. This function is
583 only available on IA-32. After the 32-bit paging mode is enabled, control is
584 transferred to the function specified by EntryPoint using the new stack
585 specified by NewStack and passing in the parameters specified by Context1 and
586 Context2. Context1 and Context2 are optional and may be NULL. The function
587 EntryPoint must never return.
588
589 There are a number of constraints that must be followed before calling this
590 function:
591 1) Interrupts must be disabled.
592 2) The caller must be in 32-bit protected mode with flat descriptors. This
593 means all descriptors must have a base of 0 and a limit of 4GB.
594 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat
595 descriptors.
596 4) CR3 must point to valid page tables that will be used once the transition
597 is complete, and those page tables must guarantee that the pages for this
598 function and the stack are identity mapped.
599
600 @param EntryPoint A pointer to function to call with the new stack after
601 paging is enabled.
602 @param Context1 A pointer to the context to pass into the EntryPoint
603 function as the first parameter after paging is enabled.
604 @param Context2 A pointer to the context to pass into the EntryPoint
605 function as the second parameter after paging is enabled.
606 @param NewStack A pointer to the new stack to use for the EntryPoint
607 function after paging is enabled.
608
609 **/
610 VOID
611 EFIAPI
612 InternalX86EnablePaging32 (
613 IN SWITCH_STACK_ENTRY_POINT EntryPoint,
614 IN VOID *Context1, OPTIONAL
615 IN VOID *Context2, OPTIONAL
616 IN VOID *NewStack
617 );
618
619 /**
620 Disables the 32-bit paging mode on the CPU.
621
622 Disables the 32-bit paging mode on the CPU and returns to 32-bit protected
623 mode. This function assumes the current execution mode is 32-paged protected
624 mode. This function is only available on IA-32. After the 32-bit paging mode
625 is disabled, control is transferred to the function specified by EntryPoint
626 using the new stack specified by NewStack and passing in the parameters
627 specified by Context1 and Context2. Context1 and Context2 are optional and
628 may be NULL. The function EntryPoint must never return.
629
630 There are a number of constraints that must be followed before calling this
631 function:
632 1) Interrupts must be disabled.
633 2) The caller must be in 32-bit paged mode.
634 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.
635 4) CR3 must point to valid page tables that guarantee that the pages for
636 this function and the stack are identity mapped.
637
638 @param EntryPoint A pointer to function to call with the new stack after
639 paging is disabled.
640 @param Context1 A pointer to the context to pass into the EntryPoint
641 function as the first parameter after paging is disabled.
642 @param Context2 A pointer to the context to pass into the EntryPoint
643 function as the second parameter after paging is
644 disabled.
645 @param NewStack A pointer to the new stack to use for the EntryPoint
646 function after paging is disabled.
647
648 **/
649 VOID
650 EFIAPI
651 InternalX86DisablePaging32 (
652 IN SWITCH_STACK_ENTRY_POINT EntryPoint,
653 IN VOID *Context1, OPTIONAL
654 IN VOID *Context2, OPTIONAL
655 IN VOID *NewStack
656 );
657
658 /**
659 Enables the 64-bit paging mode on the CPU.
660
661 Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
662 must be properly initialized prior to calling this service. This function
663 assumes the current execution mode is 32-bit protected mode with flat
664 descriptors. This function is only available on IA-32. After the 64-bit
665 paging mode is enabled, control is transferred to the function specified by
666 EntryPoint using the new stack specified by NewStack and passing in the
667 parameters specified by Context1 and Context2. Context1 and Context2 are
668 optional and may be 0. The function EntryPoint must never return.
669
670 @param Cs The 16-bit selector to load in the CS before EntryPoint
671 is called. The descriptor in the GDT that this selector
672 references must be setup for long mode.
673 @param EntryPoint The 64-bit virtual address of the function to call with
674 the new stack after paging is enabled.
675 @param Context1 The 64-bit virtual address of the context to pass into
676 the EntryPoint function as the first parameter after
677 paging is enabled.
678 @param Context2 The 64-bit virtual address of the context to pass into
679 the EntryPoint function as the second parameter after
680 paging is enabled.
681 @param NewStack The 64-bit virtual address of the new stack to use for
682 the EntryPoint function after paging is enabled.
683
684 **/
685 VOID
686 EFIAPI
687 InternalX86EnablePaging64 (
688 IN UINT16 Cs,
689 IN UINT64 EntryPoint,
690 IN UINT64 Context1, OPTIONAL
691 IN UINT64 Context2, OPTIONAL
692 IN UINT64 NewStack
693 );
694
695 /**
696 Disables the 64-bit paging mode on the CPU.
697
698 Disables the 64-bit paging mode on the CPU and returns to 32-bit protected
699 mode. This function assumes the current execution mode is 64-paging mode.
700 This function is only available on x64. After the 64-bit paging mode is
701 disabled, control is transferred to the function specified by EntryPoint
702 using the new stack specified by NewStack and passing in the parameters
703 specified by Context1 and Context2. Context1 and Context2 are optional and
704 may be 0. The function EntryPoint must never return.
705
706 @param Cs The 16-bit selector to load in the CS before EntryPoint
707 is called. The descriptor in the GDT that this selector
708 references must be setup for 32-bit protected mode.
709 @param EntryPoint The 64-bit virtual address of the function to call with
710 the new stack after paging is disabled.
711 @param Context1 The 64-bit virtual address of the context to pass into
712 the EntryPoint function as the first parameter after
713 paging is disabled.
714 @param Context2 The 64-bit virtual address of the context to pass into
715 the EntryPoint function as the second parameter after
716 paging is disabled.
717 @param NewStack The 64-bit virtual address of the new stack to use for
718 the EntryPoint function after paging is disabled.
719
720 **/
721 VOID
722 EFIAPI
723 InternalX86DisablePaging64 (
724 IN UINT16 Cs,
725 IN UINT32 EntryPoint,
726 IN UINT32 Context1, OPTIONAL
727 IN UINT32 Context2, OPTIONAL
728 IN UINT32 NewStack
729 );
730
731
732 #elif defined (MDE_CPU_IPF)
733 //
734 //
735 // IPF specific functions
736 //
737
738 //
739 // Structure definition for look up table.
740 //
741 typedef struct {
742 UINT64 Index;
743 UINT64 (*Function) (VOID);
744 } REGISTER_ENTRY;
745
746
747 /**
748 Reads control register DCR.
749
750 This is a worker function for AsmReadControlRegister()
751 when its parameter Index is IPF_CONTROL_REGISTER_DCR
752
753 @return The 64-bit control register DCR.
754
755 **/
756 UINT64
757 EFIAPI
758 AsmReadControlRegisterDcr (
759 VOID
760 );
761
762
763 /**
764 Reads control register ITM.
765
766 This is a worker function for AsmReadControlRegister()
767 when its parameter Index is IPF_CONTROL_REGISTER_ITM
768
769 @return The 64-bit control register ITM.
770
771 **/
772 UINT64
773 EFIAPI
774 AsmReadControlRegisterItm (
775 VOID
776 );
777
778
779 /**
780 Reads control register IVA.
781
782 This is a worker function for AsmReadControlRegister()
783 when its parameter Index is IPF_CONTROL_REGISTER_IVA
784
785 @return The 64-bit control register IVA.
786
787 **/
788 UINT64
789 EFIAPI
790 AsmReadControlRegisterIva (
791 VOID
792 );
793
794
795 /**
796 Reads control register PTA.
797
798 This is a worker function for AsmReadControlRegister()
799 when its parameter Index is IPF_CONTROL_REGISTER_PTA
800
801 @return The 64-bit control register PTA.
802
803 **/
804 UINT64
805 EFIAPI
806 AsmReadControlRegisterPta (
807 VOID
808 );
809
810
811 /**
812 Reads control register IPSR.
813
814 This is a worker function for AsmReadControlRegister()
815 when its parameter Index is IPF_CONTROL_REGISTER_IPSR
816
817 @return The 64-bit control register IPSR.
818
819 **/
820 UINT64
821 EFIAPI
822 AsmReadControlRegisterIpsr (
823 VOID
824 );
825
826
827 /**
828 Reads control register ISR.
829
830 This is a worker function for AsmReadControlRegister()
831 when its parameter Index is IPF_CONTROL_REGISTER_ISR
832
833 @return The 64-bit control register ISR.
834
835 **/
836 UINT64
837 EFIAPI
838 AsmReadControlRegisterIsr (
839 VOID
840 );
841
842
843 /**
844 Reads control register IIP.
845
846 This is a worker function for AsmReadControlRegister()
847 when its parameter Index is IPF_CONTROL_REGISTER_IIP
848
849 @return The 64-bit control register IIP.
850
851 **/
852 UINT64
853 EFIAPI
854 AsmReadControlRegisterIip (
855 VOID
856 );
857
858
859 /**
860 Reads control register IFA.
861
862 This is a worker function for AsmReadControlRegister()
863 when its parameter Index is IPF_CONTROL_REGISTER_IFA
864
865 @return The 64-bit control register IFA.
866
867 **/
868 UINT64
869 EFIAPI
870 AsmReadControlRegisterIfa (
871 VOID
872 );
873
874
875 /**
876 Reads control register ITIR.
877
878 This is a worker function for AsmReadControlRegister()
879 when its parameter Index is IPF_CONTROL_REGISTER_ITIR
880
881 @return The 64-bit control register ITIR.
882
883 **/
884 UINT64
885 EFIAPI
886 AsmReadControlRegisterItir (
887 VOID
888 );
889
890
891 /**
892 Reads control register IIPA.
893
894 This is a worker function for AsmReadControlRegister()
895 when its parameter Index is IPF_CONTROL_REGISTER_IIPA
896
897 @return The 64-bit control register IIPA.
898
899 **/
900 UINT64
901 EFIAPI
902 AsmReadControlRegisterIipa (
903 VOID
904 );
905
906
907 /**
908 Reads control register IFS.
909
910 This is a worker function for AsmReadControlRegister()
911 when its parameter Index is IPF_CONTROL_REGISTER_IFS
912
913 @return The 64-bit control register IFS.
914
915 **/
916 UINT64
917 EFIAPI
918 AsmReadControlRegisterIfs (
919 VOID
920 );
921
922
923 /**
924 Reads control register IIM.
925
926 This is a worker function for AsmReadControlRegister()
927 when its parameter Index is IPF_CONTROL_REGISTER_IIM
928
929 @return The 64-bit control register IIM.
930
931 **/
932 UINT64
933 EFIAPI
934 AsmReadControlRegisterIim (
935 VOID
936 );
937
938
939 /**
940 Reads control register IHA.
941
942 This is a worker function for AsmReadControlRegister()
943 when its parameter Index is IPF_CONTROL_REGISTER_IHA
944
945 @return The 64-bit control register IHA.
946
947 **/
948 UINT64
949 EFIAPI
950 AsmReadControlRegisterIha (
951 VOID
952 );
953
954
955 /**
956 Reads control register LID.
957
958 This is a worker function for AsmReadControlRegister()
959 when its parameter Index is IPF_CONTROL_REGISTER_LID
960
961 @return The 64-bit control register LID.
962
963 **/
964 UINT64
965 EFIAPI
966 AsmReadControlRegisterLid (
967 VOID
968 );
969
970
971 /**
972 Reads control register IVR.
973
974 This is a worker function for AsmReadControlRegister()
975 when its parameter Index is IPF_CONTROL_REGISTER_IVR
976
977 @return The 64-bit control register IVR.
978
979 **/
980 UINT64
981 EFIAPI
982 AsmReadControlRegisterIvr (
983 VOID
984 );
985
986
987 /**
988 Reads control register TPR.
989
990 This is a worker function for AsmReadControlRegister()
991 when its parameter Index is IPF_CONTROL_REGISTER_TPR
992
993 @return The 64-bit control register TPR.
994
995 **/
996 UINT64
997 EFIAPI
998 AsmReadControlRegisterTpr (
999 VOID
1000 );
1001
1002
1003 /**
1004 Reads control register EOI.
1005
1006 This is a worker function for AsmReadControlRegister()
1007 when its parameter Index is IPF_CONTROL_REGISTER_EOI
1008
1009 @return The 64-bit control register EOI.
1010
1011 **/
1012 UINT64
1013 EFIAPI
1014 AsmReadControlRegisterEoi (
1015 VOID
1016 );
1017
1018
1019 /**
1020 Reads control register IRR0.
1021
1022 This is a worker function for AsmReadControlRegister()
1023 when its parameter Index is IPF_CONTROL_REGISTER_IRR0
1024
1025 @return The 64-bit control register IRR0.
1026
1027 **/
1028 UINT64
1029 EFIAPI
1030 AsmReadControlRegisterIrr0 (
1031 VOID
1032 );
1033
1034
1035 /**
1036 Reads control register IRR1.
1037
1038 This is a worker function for AsmReadControlRegister()
1039 when its parameter Index is IPF_CONTROL_REGISTER_IRR1
1040
1041 @return The 64-bit control register IRR1.
1042
1043 **/
1044 UINT64
1045 EFIAPI
1046 AsmReadControlRegisterIrr1 (
1047 VOID
1048 );
1049
1050
1051 /**
1052 Reads control register IRR2.
1053
1054 This is a worker function for AsmReadControlRegister()
1055 when its parameter Index is IPF_CONTROL_REGISTER_IRR2
1056
1057 @return The 64-bit control register IRR2.
1058
1059 **/
1060 UINT64
1061 EFIAPI
1062 AsmReadControlRegisterIrr2 (
1063 VOID
1064 );
1065
1066
1067 /**
1068 Reads control register IRR3.
1069
1070 This is a worker function for AsmReadControlRegister()
1071 when its parameter Index is IPF_CONTROL_REGISTER_IRR3
1072
1073 @return The 64-bit control register IRR3.
1074
1075 **/
1076 UINT64
1077 EFIAPI
1078 AsmReadControlRegisterIrr3 (
1079 VOID
1080 );
1081
1082
1083 /**
1084 Reads control register ITV.
1085
1086 This is a worker function for AsmReadControlRegister()
1087 when its parameter Index is IPF_CONTROL_REGISTER_ITV
1088
1089 @return The 64-bit control register ITV.
1090
1091 **/
1092 UINT64
1093 EFIAPI
1094 AsmReadControlRegisterItv (
1095 VOID
1096 );
1097
1098
1099 /**
1100 Reads control register PMV.
1101
1102 This is a worker function for AsmReadControlRegister()
1103 when its parameter Index is IPF_CONTROL_REGISTER_PMV
1104
1105 @return The 64-bit control register PMV.
1106
1107 **/
1108 UINT64
1109 EFIAPI
1110 AsmReadControlRegisterPmv (
1111 VOID
1112 );
1113
1114
1115 /**
1116 Reads control register CMCV.
1117
1118 This is a worker function for AsmReadControlRegister()
1119 when its parameter Index is IPF_CONTROL_REGISTER_CMCV
1120
1121 @return The 64-bit control register CMCV.
1122
1123 **/
1124 UINT64
1125 EFIAPI
1126 AsmReadControlRegisterCmcv (
1127 VOID
1128 );
1129
1130
1131 /**
1132 Reads control register LRR0.
1133
1134 This is a worker function for AsmReadControlRegister()
1135 when its parameter Index is IPF_CONTROL_REGISTER_LRR0
1136
1137 @return The 64-bit control register LRR0.
1138
1139 **/
1140 UINT64
1141 EFIAPI
1142 AsmReadControlRegisterLrr0 (
1143 VOID
1144 );
1145
1146
1147 /**
1148 Reads control register LRR1.
1149
1150 This is a worker function for AsmReadControlRegister()
1151 when its parameter Index is IPF_CONTROL_REGISTER_LRR1
1152
1153 @return The 64-bit control register LRR1.
1154
1155 **/
1156 UINT64
1157 EFIAPI
1158 AsmReadControlRegisterLrr1 (
1159 VOID
1160 );
1161
1162
1163 /**
1164 Reads application register K0.
1165
1166 This is a worker function for AsmReadApplicationRegister()
1167 when its parameter Index is IPF_APPLICATION_REGISTER_K0
1168
1169 @return The 64-bit application register K0.
1170
1171 **/
1172 UINT64
1173 EFIAPI
1174 AsmReadApplicationRegisterK0 (
1175 VOID
1176 );
1177
1178
1179
1180 /**
1181 Reads application register K1.
1182
1183 This is a worker function for AsmReadApplicationRegister()
1184 when its parameter Index is IPF_APPLICATION_REGISTER_K1
1185
1186 @return The 64-bit application register K1.
1187
1188 **/
1189 UINT64
1190 EFIAPI
1191 AsmReadApplicationRegisterK1 (
1192 VOID
1193 );
1194
1195
1196 /**
1197 Reads application register K2.
1198
1199 This is a worker function for AsmReadApplicationRegister()
1200 when its parameter Index is IPF_APPLICATION_REGISTER_K2
1201
1202 @return The 64-bit application register K2.
1203
1204 **/
1205 UINT64
1206 EFIAPI
1207 AsmReadApplicationRegisterK2 (
1208 VOID
1209 );
1210
1211
1212 /**
1213 Reads application register K3.
1214
1215 This is a worker function for AsmReadApplicationRegister()
1216 when its parameter Index is IPF_APPLICATION_REGISTER_K3
1217
1218 @return The 64-bit application register K3.
1219
1220 **/
1221 UINT64
1222 EFIAPI
1223 AsmReadApplicationRegisterK3 (
1224 VOID
1225 );
1226
1227
1228 /**
1229 Reads application register K4.
1230
1231 This is a worker function for AsmReadApplicationRegister()
1232 when its parameter Index is IPF_APPLICATION_REGISTER_K4
1233
1234 @return The 64-bit application register K4.
1235
1236 **/
1237 UINT64
1238 EFIAPI
1239 AsmReadApplicationRegisterK4 (
1240 VOID
1241 );
1242
1243
1244 /**
1245 Reads application register K5.
1246
1247 This is a worker function for AsmReadApplicationRegister()
1248 when its parameter Index is IPF_APPLICATION_REGISTER_K5
1249
1250 @return The 64-bit application register K5.
1251
1252 **/
1253 UINT64
1254 EFIAPI
1255 AsmReadApplicationRegisterK5 (
1256 VOID
1257 );
1258
1259
1260 /**
1261 Reads application register K6.
1262
1263 This is a worker function for AsmReadApplicationRegister()
1264 when its parameter Index is IPF_APPLICATION_REGISTER_K6
1265
1266 @return The 64-bit application register K6.
1267
1268 **/
1269 UINT64
1270 EFIAPI
1271 AsmReadApplicationRegisterK6 (
1272 VOID
1273 );
1274
1275
1276 /**
1277 Reads application register K7.
1278
1279 This is a worker function for AsmReadApplicationRegister()
1280 when its parameter Index is IPF_APPLICATION_REGISTER_K7
1281
1282 @return The 64-bit application register K7.
1283
1284 **/
1285 UINT64
1286 EFIAPI
1287 AsmReadApplicationRegisterK7 (
1288 VOID
1289 );
1290
1291
1292 /**
1293 Reads application register RSC.
1294
1295 This is a worker function for AsmReadApplicationRegister()
1296 when its parameter Index is IPF_APPLICATION_REGISTER_RSC
1297
1298 @return The 64-bit application register RSC.
1299
1300 **/
1301 UINT64
1302 EFIAPI
1303 AsmReadApplicationRegisterRsc (
1304 VOID
1305 );
1306
1307
1308 /**
1309 Reads application register BSP.
1310
1311 This is a worker function for AsmReadApplicationRegister()
1312 when its parameter Index is IPF_APPLICATION_REGISTER_BSP
1313
1314 @return The 64-bit application register BSP.
1315
1316 **/
1317 UINT64
1318 EFIAPI
1319 AsmReadApplicationRegisterBsp (
1320 VOID
1321 );
1322
1323
1324 /**
1325 Reads application register BSPSTORE.
1326
1327 This is a worker function for AsmReadApplicationRegister()
1328 when its parameter Index is IPF_APPLICATION_REGISTER_BSPSTORE
1329
1330 @return The 64-bit application register BSPSTORE.
1331
1332 **/
1333 UINT64
1334 EFIAPI
1335 AsmReadApplicationRegisterBspstore (
1336 VOID
1337 );
1338
1339
1340 /**
1341 Reads application register RNAT.
1342
1343 This is a worker function for AsmReadApplicationRegister()
1344 when its parameter Index is IPF_APPLICATION_REGISTER_RNAT
1345
1346 @return The 64-bit application register RNAT.
1347
1348 **/
1349 UINT64
1350 EFIAPI
1351 AsmReadApplicationRegisterRnat (
1352 VOID
1353 );
1354
1355
1356 /**
1357 Reads application register FCR.
1358
1359 This is a worker function for AsmReadApplicationRegister()
1360 when its parameter Index is IPF_APPLICATION_REGISTER_FCR
1361
1362 @return The 64-bit application register FCR.
1363
1364 **/
1365 UINT64
1366 EFIAPI
1367 AsmReadApplicationRegisterFcr (
1368 VOID
1369 );
1370
1371
1372 /**
1373 Reads application register EFLAG.
1374
1375 This is a worker function for AsmReadApplicationRegister()
1376 when its parameter Index is IPF_APPLICATION_REGISTER_EFLAG
1377
1378 @return The 64-bit application register EFLAG.
1379
1380 **/
1381 UINT64
1382 EFIAPI
1383 AsmReadApplicationRegisterEflag (
1384 VOID
1385 );
1386
1387
1388 /**
1389 Reads application register CSD.
1390
1391 This is a worker function for AsmReadApplicationRegister()
1392 when its parameter Index is IPF_APPLICATION_REGISTER_CSD
1393
1394 @return The 64-bit application register CSD.
1395
1396 **/
1397 UINT64
1398 EFIAPI
1399 AsmReadApplicationRegisterCsd (
1400 VOID
1401 );
1402
1403
1404 /**
1405 Reads application register SSD.
1406
1407 This is a worker function for AsmReadApplicationRegister()
1408 when its parameter Index is IPF_APPLICATION_REGISTER_SSD
1409
1410 @return The 64-bit application register SSD.
1411
1412 **/
1413 UINT64
1414 EFIAPI
1415 AsmReadApplicationRegisterSsd (
1416 VOID
1417 );
1418
1419
1420 /**
1421 Reads application register CFLG.
1422
1423 This is a worker function for AsmReadApplicationRegister()
1424 when its parameter Index is IPF_APPLICATION_REGISTER_CFLG
1425
1426 @return The 64-bit application register CFLG.
1427
1428 **/
1429 UINT64
1430 EFIAPI
1431 AsmReadApplicationRegisterCflg (
1432 VOID
1433 );
1434
1435
1436 /**
1437 Reads application register FSR.
1438
1439 This is a worker function for AsmReadApplicationRegister()
1440 when its parameter Index is IPF_APPLICATION_REGISTER_FSR
1441
1442 @return The 64-bit application register FSR.
1443
1444 **/
1445 UINT64
1446 EFIAPI
1447 AsmReadApplicationRegisterFsr (
1448 VOID
1449 );
1450
1451
1452 /**
1453 Reads application register FIR.
1454
1455 This is a worker function for AsmReadApplicationRegister()
1456 when its parameter Index is IPF_APPLICATION_REGISTER_FIR
1457
1458 @return The 64-bit application register FIR.
1459
1460 **/
1461 UINT64
1462 EFIAPI
1463 AsmReadApplicationRegisterFir (
1464 VOID
1465 );
1466
1467
1468 /**
1469 Reads application register FDR.
1470
1471 This is a worker function for AsmReadApplicationRegister()
1472 when its parameter Index is IPF_APPLICATION_REGISTER_FDR
1473
1474 @return The 64-bit application register FDR.
1475
1476 **/
1477 UINT64
1478 EFIAPI
1479 AsmReadApplicationRegisterFdr (
1480 VOID
1481 );
1482
1483
1484 /**
1485 Reads application register CCV.
1486
1487 This is a worker function for AsmReadApplicationRegister()
1488 when its parameter Index is IPF_APPLICATION_REGISTER_CCV
1489
1490 @return The 64-bit application register CCV.
1491
1492 **/
1493 UINT64
1494 EFIAPI
1495 AsmReadApplicationRegisterCcv (
1496 VOID
1497 );
1498
1499
1500 /**
1501 Reads application register UNAT.
1502
1503 This is a worker function for AsmReadApplicationRegister()
1504 when its parameter Index is IPF_APPLICATION_REGISTER_UNAT
1505
1506 @return The 64-bit application register UNAT.
1507
1508 **/
1509 UINT64
1510 EFIAPI
1511 AsmReadApplicationRegisterUnat (
1512 VOID
1513 );
1514
1515
1516 /**
1517 Reads application register FPSR.
1518
1519 This is a worker function for AsmReadApplicationRegister()
1520 when its parameter Index is IPF_APPLICATION_REGISTER_FPSR
1521
1522 @return The 64-bit application register FPSR.
1523
1524 **/
1525 UINT64
1526 EFIAPI
1527 AsmReadApplicationRegisterFpsr (
1528 VOID
1529 );
1530
1531
1532 /**
1533 Reads application register ITC.
1534
1535 This is a worker function for AsmReadApplicationRegister()
1536 when its parameter Index is IPF_APPLICATION_REGISTER_ITC
1537
1538 @return The 64-bit application register ITC.
1539
1540 **/
1541 UINT64
1542 EFIAPI
1543 AsmReadApplicationRegisterItc (
1544 VOID
1545 );
1546
1547
1548 /**
1549 Reads application register PFS.
1550
1551 This is a worker function for AsmReadApplicationRegister()
1552 when its parameter Index is IPF_APPLICATION_REGISTER_PFS
1553
1554 @return The 64-bit application register PFS.
1555
1556 **/
1557 UINT64
1558 EFIAPI
1559 AsmReadApplicationRegisterPfs (
1560 VOID
1561 );
1562
1563
1564 /**
1565 Reads application register LC.
1566
1567 This is a worker function for AsmReadApplicationRegister()
1568 when its parameter Index is IPF_APPLICATION_REGISTER_LC
1569
1570 @return The 64-bit application register LC.
1571
1572 **/
1573 UINT64
1574 EFIAPI
1575 AsmReadApplicationRegisterLc (
1576 VOID
1577 );
1578
1579
1580 /**
1581 Reads application register EC.
1582
1583 This is a worker function for AsmReadApplicationRegister()
1584 when its parameter Index is IPF_APPLICATION_REGISTER_EC
1585
1586 @return The 64-bit application register EC.
1587
1588 **/
1589 UINT64
1590 EFIAPI
1591 AsmReadApplicationRegisterEc (
1592 VOID
1593 );
1594
1595
1596
1597 /**
1598 Transfers control to a function starting with a new stack.
1599
1600 Transfers control to the function specified by EntryPoint using the new stack
1601 specified by NewStack and passing in the parameters specified by Context1 and
1602 Context2. Context1 and Context2 are optional and may be NULL. The function
1603 EntryPoint must never return.
1604
1605 If EntryPoint is NULL, then ASSERT().
1606 If NewStack is NULL, then ASSERT().
1607
1608 @param EntryPoint A pointer to function to call with the new stack.
1609 @param Context1 A pointer to the context to pass into the EntryPoint
1610 function.
1611 @param Context2 A pointer to the context to pass into the EntryPoint
1612 function.
1613 @param NewStack A pointer to the new stack to use for the EntryPoint
1614 function.
1615 @param NewBsp A pointer to the new memory location for RSE backing
1616 store.
1617
1618 **/
1619 VOID
1620 EFIAPI
1621 AsmSwitchStackAndBackingStore (
1622 IN SWITCH_STACK_ENTRY_POINT EntryPoint,
1623 IN VOID *Context1, OPTIONAL
1624 IN VOID *Context2, OPTIONAL
1625 IN VOID *NewStack,
1626 IN VOID *NewBsp
1627 );
1628 #else
1629
1630 #endif
1631
1632 #endif