1 /** @file 2 Declaration of internal functions in BaseLib. 3 4 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR> 5 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. The 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 filled 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 filled 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 Multiplies a 64-bit unsigned integer by a 32-bit unsigned integer 150 and generates a 64-bit unsigned result. 151 152 This function multiplies 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 Multiplies 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 PcdMaximumLinkedListLength 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 The 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 The 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 The pointer to an 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 The pointer to an 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 The 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 The 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 Reads control register DCR. 740 741 This is a worker function for AsmReadControlRegister() 742 when its parameter Index is IPF_CONTROL_REGISTER_DCR. 743 744 @return The 64-bit control register DCR. 745 746 **/ 747 UINT64 748 EFIAPI 749 AsmReadControlRegisterDcr ( 750 VOID 751 ); 752 753 754 /** 755 Reads control register ITM. 756 757 This is a worker function for AsmReadControlRegister() 758 when its parameter Index is IPF_CONTROL_REGISTER_ITM. 759 760 @return The 64-bit control register ITM. 761 762 **/ 763 UINT64 764 EFIAPI 765 AsmReadControlRegisterItm ( 766 VOID 767 ); 768 769 770 /** 771 Reads control register IVA. 772 773 This is a worker function for AsmReadControlRegister() 774 when its parameter Index is IPF_CONTROL_REGISTER_IVA. 775 776 @return The 64-bit control register IVA. 777 778 **/ 779 UINT64 780 EFIAPI 781 AsmReadControlRegisterIva ( 782 VOID 783 ); 784 785 786 /** 787 Reads control register PTA. 788 789 This is a worker function for AsmReadControlRegister() 790 when its parameter Index is IPF_CONTROL_REGISTER_PTA. 791 792 @return The 64-bit control register PTA. 793 794 **/ 795 UINT64 796 EFIAPI 797 AsmReadControlRegisterPta ( 798 VOID 799 ); 800 801 802 /** 803 Reads control register IPSR. 804 805 This is a worker function for AsmReadControlRegister() 806 when its parameter Index is IPF_CONTROL_REGISTER_IPSR. 807 808 @return The 64-bit control register IPSR. 809 810 **/ 811 UINT64 812 EFIAPI 813 AsmReadControlRegisterIpsr ( 814 VOID 815 ); 816 817 818 /** 819 Reads control register ISR. 820 821 This is a worker function for AsmReadControlRegister() 822 when its parameter Index is IPF_CONTROL_REGISTER_ISR. 823 824 @return The 64-bit control register ISR. 825 826 **/ 827 UINT64 828 EFIAPI 829 AsmReadControlRegisterIsr ( 830 VOID 831 ); 832 833 834 /** 835 Reads control register IIP. 836 837 This is a worker function for AsmReadControlRegister() 838 when its parameter Index is IPF_CONTROL_REGISTER_IIP. 839 840 @return The 64-bit control register IIP. 841 842 **/ 843 UINT64 844 EFIAPI 845 AsmReadControlRegisterIip ( 846 VOID 847 ); 848 849 850 /** 851 Reads control register IFA. 852 853 This is a worker function for AsmReadControlRegister() 854 when its parameter Index is IPF_CONTROL_REGISTER_IFA. 855 856 @return The 64-bit control register IFA. 857 858 **/ 859 UINT64 860 EFIAPI 861 AsmReadControlRegisterIfa ( 862 VOID 863 ); 864 865 866 /** 867 Reads control register ITIR. 868 869 This is a worker function for AsmReadControlRegister() 870 when its parameter Index is IPF_CONTROL_REGISTER_ITIR. 871 872 @return The 64-bit control register ITIR. 873 874 **/ 875 UINT64 876 EFIAPI 877 AsmReadControlRegisterItir ( 878 VOID 879 ); 880 881 882 /** 883 Reads control register IIPA. 884 885 This is a worker function for AsmReadControlRegister() 886 when its parameter Index is IPF_CONTROL_REGISTER_IIPA. 887 888 @return The 64-bit control register IIPA. 889 890 **/ 891 UINT64 892 EFIAPI 893 AsmReadControlRegisterIipa ( 894 VOID 895 ); 896 897 898 /** 899 Reads control register IFS. 900 901 This is a worker function for AsmReadControlRegister() 902 when its parameter Index is IPF_CONTROL_REGISTER_IFS. 903 904 @return The 64-bit control register IFS. 905 906 **/ 907 UINT64 908 EFIAPI 909 AsmReadControlRegisterIfs ( 910 VOID 911 ); 912 913 914 /** 915 Reads control register IIM. 916 917 This is a worker function for AsmReadControlRegister() 918 when its parameter Index is IPF_CONTROL_REGISTER_IIM. 919 920 @return The 64-bit control register IIM. 921 922 **/ 923 UINT64 924 EFIAPI 925 AsmReadControlRegisterIim ( 926 VOID 927 ); 928 929 930 /** 931 Reads control register IHA. 932 933 This is a worker function for AsmReadControlRegister() 934 when its parameter Index is IPF_CONTROL_REGISTER_IHA. 935 936 @return The 64-bit control register IHA. 937 938 **/ 939 UINT64 940 EFIAPI 941 AsmReadControlRegisterIha ( 942 VOID 943 ); 944 945 946 /** 947 Reads control register LID. 948 949 This is a worker function for AsmReadControlRegister() 950 when its parameter Index is IPF_CONTROL_REGISTER_LID. 951 952 @return The 64-bit control register LID. 953 954 **/ 955 UINT64 956 EFIAPI 957 AsmReadControlRegisterLid ( 958 VOID 959 ); 960 961 962 /** 963 Reads control register IVR. 964 965 This is a worker function for AsmReadControlRegister() 966 when its parameter Index is IPF_CONTROL_REGISTER_IVR. 967 968 @return The 64-bit control register IVR. 969 970 **/ 971 UINT64 972 EFIAPI 973 AsmReadControlRegisterIvr ( 974 VOID 975 ); 976 977 978 /** 979 Reads control register TPR. 980 981 This is a worker function for AsmReadControlRegister() 982 when its parameter Index is IPF_CONTROL_REGISTER_TPR. 983 984 @return The 64-bit control register TPR. 985 986 **/ 987 UINT64 988 EFIAPI 989 AsmReadControlRegisterTpr ( 990 VOID 991 ); 992 993 994 /** 995 Reads control register EOI. 996 997 This is a worker function for AsmReadControlRegister() 998 when its parameter Index is IPF_CONTROL_REGISTER_EOI. 999 1000 @return The 64-bit control register EOI. 1001 1002 **/ 1003 UINT64 1004 EFIAPI 1005 AsmReadControlRegisterEoi ( 1006 VOID 1007 ); 1008 1009 1010 /** 1011 Reads control register IRR0. 1012 1013 This is a worker function for AsmReadControlRegister() 1014 when its parameter Index is IPF_CONTROL_REGISTER_IRR0. 1015 1016 @return The 64-bit control register IRR0. 1017 1018 **/ 1019 UINT64 1020 EFIAPI 1021 AsmReadControlRegisterIrr0 ( 1022 VOID 1023 ); 1024 1025 1026 /** 1027 Reads control register IRR1. 1028 1029 This is a worker function for AsmReadControlRegister() 1030 when its parameter Index is IPF_CONTROL_REGISTER_IRR1. 1031 1032 @return The 64-bit control register IRR1. 1033 1034 **/ 1035 UINT64 1036 EFIAPI 1037 AsmReadControlRegisterIrr1 ( 1038 VOID 1039 ); 1040 1041 1042 /** 1043 Reads control register IRR2. 1044 1045 This is a worker function for AsmReadControlRegister() 1046 when its parameter Index is IPF_CONTROL_REGISTER_IRR2. 1047 1048 @return The 64-bit control register IRR2. 1049 1050 **/ 1051 UINT64 1052 EFIAPI 1053 AsmReadControlRegisterIrr2 ( 1054 VOID 1055 ); 1056 1057 1058 /** 1059 Reads control register IRR3. 1060 1061 This is a worker function for AsmReadControlRegister() 1062 when its parameter Index is IPF_CONTROL_REGISTER_IRR3. 1063 1064 @return The 64-bit control register IRR3. 1065 1066 **/ 1067 UINT64 1068 EFIAPI 1069 AsmReadControlRegisterIrr3 ( 1070 VOID 1071 ); 1072 1073 1074 /** 1075 Reads control register ITV. 1076 1077 This is a worker function for AsmReadControlRegister() 1078 when its parameter Index is IPF_CONTROL_REGISTER_ITV. 1079 1080 @return The 64-bit control register ITV. 1081 1082 **/ 1083 UINT64 1084 EFIAPI 1085 AsmReadControlRegisterItv ( 1086 VOID 1087 ); 1088 1089 1090 /** 1091 Reads control register PMV. 1092 1093 This is a worker function for AsmReadControlRegister() 1094 when its parameter Index is IPF_CONTROL_REGISTER_PMV. 1095 1096 @return The 64-bit control register PMV. 1097 1098 **/ 1099 UINT64 1100 EFIAPI 1101 AsmReadControlRegisterPmv ( 1102 VOID 1103 ); 1104 1105 1106 /** 1107 Reads control register CMCV. 1108 1109 This is a worker function for AsmReadControlRegister() 1110 when its parameter Index is IPF_CONTROL_REGISTER_CMCV. 1111 1112 @return The 64-bit control register CMCV. 1113 1114 **/ 1115 UINT64 1116 EFIAPI 1117 AsmReadControlRegisterCmcv ( 1118 VOID 1119 ); 1120 1121 1122 /** 1123 Reads control register LRR0. 1124 1125 This is a worker function for AsmReadControlRegister() 1126 when its parameter Index is IPF_CONTROL_REGISTER_LRR0. 1127 1128 @return The 64-bit control register LRR0. 1129 1130 **/ 1131 UINT64 1132 EFIAPI 1133 AsmReadControlRegisterLrr0 ( 1134 VOID 1135 ); 1136 1137 1138 /** 1139 Reads control register LRR1. 1140 1141 This is a worker function for AsmReadControlRegister() 1142 when its parameter Index is IPF_CONTROL_REGISTER_LRR1. 1143 1144 @return The 64-bit control register LRR1. 1145 1146 **/ 1147 UINT64 1148 EFIAPI 1149 AsmReadControlRegisterLrr1 ( 1150 VOID 1151 ); 1152 1153 1154 /** 1155 Reads application register K0. 1156 1157 This is a worker function for AsmReadApplicationRegister() 1158 when its parameter Index is IPF_APPLICATION_REGISTER_K0. 1159 1160 @return The 64-bit application register K0. 1161 1162 **/ 1163 UINT64 1164 EFIAPI 1165 AsmReadApplicationRegisterK0 ( 1166 VOID 1167 ); 1168 1169 1170 1171 /** 1172 Reads application register K1. 1173 1174 This is a worker function for AsmReadApplicationRegister() 1175 when its parameter Index is IPF_APPLICATION_REGISTER_K1. 1176 1177 @return The 64-bit application register K1. 1178 1179 **/ 1180 UINT64 1181 EFIAPI 1182 AsmReadApplicationRegisterK1 ( 1183 VOID 1184 ); 1185 1186 1187 /** 1188 Reads application register K2. 1189 1190 This is a worker function for AsmReadApplicationRegister() 1191 when its parameter Index is IPF_APPLICATION_REGISTER_K2. 1192 1193 @return The 64-bit application register K2. 1194 1195 **/ 1196 UINT64 1197 EFIAPI 1198 AsmReadApplicationRegisterK2 ( 1199 VOID 1200 ); 1201 1202 1203 /** 1204 Reads application register K3. 1205 1206 This is a worker function for AsmReadApplicationRegister() 1207 when its parameter Index is IPF_APPLICATION_REGISTER_K3. 1208 1209 @return The 64-bit application register K3. 1210 1211 **/ 1212 UINT64 1213 EFIAPI 1214 AsmReadApplicationRegisterK3 ( 1215 VOID 1216 ); 1217 1218 1219 /** 1220 Reads application register K4. 1221 1222 This is a worker function for AsmReadApplicationRegister() 1223 when its parameter Index is IPF_APPLICATION_REGISTER_K4. 1224 1225 @return The 64-bit application register K4. 1226 1227 **/ 1228 UINT64 1229 EFIAPI 1230 AsmReadApplicationRegisterK4 ( 1231 VOID 1232 ); 1233 1234 1235 /** 1236 Reads application register K5. 1237 1238 This is a worker function for AsmReadApplicationRegister() 1239 when its parameter Index is IPF_APPLICATION_REGISTER_K5. 1240 1241 @return The 64-bit application register K5. 1242 1243 **/ 1244 UINT64 1245 EFIAPI 1246 AsmReadApplicationRegisterK5 ( 1247 VOID 1248 ); 1249 1250 1251 /** 1252 Reads application register K6. 1253 1254 This is a worker function for AsmReadApplicationRegister() 1255 when its parameter Index is IPF_APPLICATION_REGISTER_K6. 1256 1257 @return The 64-bit application register K6. 1258 1259 **/ 1260 UINT64 1261 EFIAPI 1262 AsmReadApplicationRegisterK6 ( 1263 VOID 1264 ); 1265 1266 1267 /** 1268 Reads application register K7. 1269 1270 This is a worker function for AsmReadApplicationRegister() 1271 when its parameter Index is IPF_APPLICATION_REGISTER_K7. 1272 1273 @return The 64-bit application register K7. 1274 1275 **/ 1276 UINT64 1277 EFIAPI 1278 AsmReadApplicationRegisterK7 ( 1279 VOID 1280 ); 1281 1282 1283 /** 1284 Reads application register RSC. 1285 1286 This is a worker function for AsmReadApplicationRegister() 1287 when its parameter Index is IPF_APPLICATION_REGISTER_RSC. 1288 1289 @return The 64-bit application register RSC. 1290 1291 **/ 1292 UINT64 1293 EFIAPI 1294 AsmReadApplicationRegisterRsc ( 1295 VOID 1296 ); 1297 1298 1299 /** 1300 Reads application register BSP. 1301 1302 This is a worker function for AsmReadApplicationRegister() 1303 when its parameter Index is IPF_APPLICATION_REGISTER_BSP. 1304 1305 @return The 64-bit application register BSP. 1306 1307 **/ 1308 UINT64 1309 EFIAPI 1310 AsmReadApplicationRegisterBsp ( 1311 VOID 1312 ); 1313 1314 1315 /** 1316 Reads application register BSPSTORE. 1317 1318 This is a worker function for AsmReadApplicationRegister() 1319 when its parameter Index is IPF_APPLICATION_REGISTER_BSPSTORE. 1320 1321 @return The 64-bit application register BSPSTORE. 1322 1323 **/ 1324 UINT64 1325 EFIAPI 1326 AsmReadApplicationRegisterBspstore ( 1327 VOID 1328 ); 1329 1330 1331 /** 1332 Reads application register RNAT. 1333 1334 This is a worker function for AsmReadApplicationRegister() 1335 when its parameter Index is IPF_APPLICATION_REGISTER_RNAT. 1336 1337 @return The 64-bit application register RNAT. 1338 1339 **/ 1340 UINT64 1341 EFIAPI 1342 AsmReadApplicationRegisterRnat ( 1343 VOID 1344 ); 1345 1346 1347 /** 1348 Reads application register FCR. 1349 1350 This is a worker function for AsmReadApplicationRegister() 1351 when its parameter Index is IPF_APPLICATION_REGISTER_FCR. 1352 1353 @return The 64-bit application register FCR. 1354 1355 **/ 1356 UINT64 1357 EFIAPI 1358 AsmReadApplicationRegisterFcr ( 1359 VOID 1360 ); 1361 1362 1363 /** 1364 Reads application register EFLAG. 1365 1366 This is a worker function for AsmReadApplicationRegister() 1367 when its parameter Index is IPF_APPLICATION_REGISTER_EFLAG. 1368 1369 @return The 64-bit application register EFLAG. 1370 1371 **/ 1372 UINT64 1373 EFIAPI 1374 AsmReadApplicationRegisterEflag ( 1375 VOID 1376 ); 1377 1378 1379 /** 1380 Reads application register CSD. 1381 1382 This is a worker function for AsmReadApplicationRegister() 1383 when its parameter Index is IPF_APPLICATION_REGISTER_CSD. 1384 1385 @return The 64-bit application register CSD. 1386 1387 **/ 1388 UINT64 1389 EFIAPI 1390 AsmReadApplicationRegisterCsd ( 1391 VOID 1392 ); 1393 1394 1395 /** 1396 Reads application register SSD. 1397 1398 This is a worker function for AsmReadApplicationRegister() 1399 when its parameter Index is IPF_APPLICATION_REGISTER_SSD. 1400 1401 @return The 64-bit application register SSD. 1402 1403 **/ 1404 UINT64 1405 EFIAPI 1406 AsmReadApplicationRegisterSsd ( 1407 VOID 1408 ); 1409 1410 1411 /** 1412 Reads application register CFLG. 1413 1414 This is a worker function for AsmReadApplicationRegister() 1415 when its parameter Index is IPF_APPLICATION_REGISTER_CFLG. 1416 1417 @return The 64-bit application register CFLG. 1418 1419 **/ 1420 UINT64 1421 EFIAPI 1422 AsmReadApplicationRegisterCflg ( 1423 VOID 1424 ); 1425 1426 1427 /** 1428 Reads application register FSR. 1429 1430 This is a worker function for AsmReadApplicationRegister() 1431 when its parameter Index is IPF_APPLICATION_REGISTER_FSR. 1432 1433 @return The 64-bit application register FSR. 1434 1435 **/ 1436 UINT64 1437 EFIAPI 1438 AsmReadApplicationRegisterFsr ( 1439 VOID 1440 ); 1441 1442 1443 /** 1444 Reads application register FIR. 1445 1446 This is a worker function for AsmReadApplicationRegister() 1447 when its parameter Index is IPF_APPLICATION_REGISTER_FIR. 1448 1449 @return The 64-bit application register FIR. 1450 1451 **/ 1452 UINT64 1453 EFIAPI 1454 AsmReadApplicationRegisterFir ( 1455 VOID 1456 ); 1457 1458 1459 /** 1460 Reads application register FDR. 1461 1462 This is a worker function for AsmReadApplicationRegister() 1463 when its parameter Index is IPF_APPLICATION_REGISTER_FDR. 1464 1465 @return The 64-bit application register FDR. 1466 1467 **/ 1468 UINT64 1469 EFIAPI 1470 AsmReadApplicationRegisterFdr ( 1471 VOID 1472 ); 1473 1474 1475 /** 1476 Reads application register CCV. 1477 1478 This is a worker function for AsmReadApplicationRegister() 1479 when its parameter Index is IPF_APPLICATION_REGISTER_CCV. 1480 1481 @return The 64-bit application register CCV. 1482 1483 **/ 1484 UINT64 1485 EFIAPI 1486 AsmReadApplicationRegisterCcv ( 1487 VOID 1488 ); 1489 1490 1491 /** 1492 Reads application register UNAT. 1493 1494 This is a worker function for AsmReadApplicationRegister() 1495 when its parameter Index is IPF_APPLICATION_REGISTER_UNAT. 1496 1497 @return The 64-bit application register UNAT. 1498 1499 **/ 1500 UINT64 1501 EFIAPI 1502 AsmReadApplicationRegisterUnat ( 1503 VOID 1504 ); 1505 1506 1507 /** 1508 Reads application register FPSR. 1509 1510 This is a worker function for AsmReadApplicationRegister() 1511 when its parameter Index is IPF_APPLICATION_REGISTER_FPSR. 1512 1513 @return The 64-bit application register FPSR. 1514 1515 **/ 1516 UINT64 1517 EFIAPI 1518 AsmReadApplicationRegisterFpsr ( 1519 VOID 1520 ); 1521 1522 1523 /** 1524 Reads application register ITC. 1525 1526 This is a worker function for AsmReadApplicationRegister() 1527 when its parameter Index is IPF_APPLICATION_REGISTER_ITC. 1528 1529 @return The 64-bit application register ITC. 1530 1531 **/ 1532 UINT64 1533 EFIAPI 1534 AsmReadApplicationRegisterItc ( 1535 VOID 1536 ); 1537 1538 1539 /** 1540 Reads application register PFS. 1541 1542 This is a worker function for AsmReadApplicationRegister() 1543 when its parameter Index is IPF_APPLICATION_REGISTER_PFS. 1544 1545 @return The 64-bit application register PFS. 1546 1547 **/ 1548 UINT64 1549 EFIAPI 1550 AsmReadApplicationRegisterPfs ( 1551 VOID 1552 ); 1553 1554 1555 /** 1556 Reads application register LC. 1557 1558 This is a worker function for AsmReadApplicationRegister() 1559 when its parameter Index is IPF_APPLICATION_REGISTER_LC. 1560 1561 @return The 64-bit application register LC. 1562 1563 **/ 1564 UINT64 1565 EFIAPI 1566 AsmReadApplicationRegisterLc ( 1567 VOID 1568 ); 1569 1570 1571 /** 1572 Reads application register EC. 1573 1574 This is a worker function for AsmReadApplicationRegister() 1575 when its parameter Index is IPF_APPLICATION_REGISTER_EC. 1576 1577 @return The 64-bit application register EC. 1578 1579 **/ 1580 UINT64 1581 EFIAPI 1582 AsmReadApplicationRegisterEc ( 1583 VOID 1584 ); 1585 1586 1587 1588 /** 1589 Transfers control to a function starting with a new stack. 1590 1591 Transfers control to the function specified by EntryPoint using the new stack 1592 specified by NewStack and passing in the parameters specified by Context1 and 1593 Context2. Context1 and Context2 are optional and may be NULL. The function 1594 EntryPoint must never return. 1595 1596 If EntryPoint is NULL, then ASSERT(). 1597 If NewStack is NULL, then ASSERT(). 1598 1599 @param EntryPoint A pointer to function to call with the new stack. 1600 @param Context1 A pointer to the context to pass into the EntryPoint 1601 function. 1602 @param Context2 A pointer to the context to pass into the EntryPoint 1603 function. 1604 @param NewStack A pointer to the new stack to use for the EntryPoint 1605 function. 1606 @param NewBsp A pointer to the new memory location for RSE backing 1607 store. 1608 1609 **/ 1610 VOID 1611 EFIAPI 1612 AsmSwitchStackAndBackingStore ( 1613 IN SWITCH_STACK_ENTRY_POINT EntryPoint, 1614 IN VOID *Context1, OPTIONAL 1615 IN VOID *Context2, OPTIONAL 1616 IN VOID *NewStack, 1617 IN VOID *NewBsp 1618 ); 1619 1620 /** 1621 Internal worker function to invalidate a range of instruction cache lines 1622 in the cache coherency domain of the calling CPU. 1623 1624 Internal worker function to invalidate the instruction cache lines specified 1625 by Address and Length. If Address is not aligned on a cache line boundary, 1626 then entire instruction cache line containing Address is invalidated. If 1627 Address + Length is not aligned on a cache line boundary, then the entire 1628 instruction cache line containing Address + Length -1 is invalidated. This 1629 function may choose to invalidate the entire instruction cache if that is more 1630 efficient than invalidating the specified range. If Length is 0, the no instruction 1631 cache lines are invalidated. Address is returned. 1632 This function is only available on IPF. 1633 1634 @param Address The base address of the instruction cache lines to 1635 invalidate. If the CPU is in a physical addressing mode, then 1636 Address is a physical address. If the CPU is in a virtual 1637 addressing mode, then Address is a virtual address. 1638 1639 @param Length The number of bytes to invalidate from the instruction cache. 1640 1641 @return Address 1642 1643 **/ 1644 VOID * 1645 EFIAPI 1646 InternalFlushCacheRange ( 1647 IN VOID *Address, 1648 IN UINTN Length 1649 ); 1650 1651 #else 1652 1653 #endif 1654 1655 #endif 1656