MCPcopy Create free account
hub / github.com/CloverHackyColor/CloverBootloader / ExecutePUSH

Function ExecutePUSH

MdeModulePkg/Universal/EbcDxe/EbcExecute.c:2747–2809  ·  view source on GitHub ↗

Execute the EBC PUSH instruction. Instruction syntax: PUSH[32|64] {@}R1 {Index16|Immed16} @param VmPtr A pointer to a VM context. @retval EFI_SUCCESS The instruction is executed successfully. **/

Source from the content-addressed store, hash-verified

2745
2746**/
2747EFI_STATUS
2748ExecutePUSH (
2749 IN VM_CONTEXT *VmPtr
2750 )
2751{
2752 UINT8 Opcode;
2753 UINT8 Operands;
2754 UINT32 Data32;
2755 UINT64 Data64;
2756 INT16 Index16;
2757
2758 //
2759 // Get opcode and operands
2760 //
2761 Opcode = GETOPCODE (VmPtr);
2762 Operands = GETOPERANDS (VmPtr);
2763 //
2764 // Get immediate index if present, then advance the IP.
2765 //
2766 if ((Opcode & PUSHPOP_M_IMMDATA) != 0) {
2767 if (OPERAND1_INDIRECT (Operands)) {
2768 Index16 = VmReadIndex16 (VmPtr, 2);
2769 } else {
2770 Index16 = VmReadImmed16 (VmPtr, 2);
2771 }
2772
2773 VmPtr->Ip += 4;
2774 } else {
2775 Index16 = 0;
2776 VmPtr->Ip += 2;
2777 }
2778 //
2779 // Get the data to push
2780 //
2781 if ((Opcode & PUSHPOP_M_64) != 0) {
2782 if (OPERAND1_INDIRECT (Operands)) {
2783 Data64 = VmReadMem64 (VmPtr, (UINTN) (VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16));
2784 } else {
2785 Data64 = (UINT64) VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16;
2786 }
2787 //
2788 // Adjust the stack down, then write back the data
2789 //
2790 VmPtr->Gpr[0] -= sizeof (UINT64);
2791 VmWriteMem64 (VmPtr, (UINTN) VmPtr->Gpr[0], Data64);
2792 } else {
2793 //
2794 // 32-bit data
2795 //
2796 if (OPERAND1_INDIRECT (Operands)) {
2797 Data32 = VmReadMem32 (VmPtr, (UINTN) (VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16));
2798 } else {
2799 Data32 = (UINT32) VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16;
2800 }
2801 //
2802 // Adjust the stack down and write the data
2803 //
2804 VmPtr->Gpr[0] -= sizeof (UINT32);

Callers

nothing calls this directly

Calls 6

VmReadIndex16Function · 0.85
VmReadImmed16Function · 0.85
VmReadMem64Function · 0.85
VmWriteMem64Function · 0.85
VmReadMem32Function · 0.85
VmWriteMem32Function · 0.85

Tested by

no test coverage detected