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

Function ExecutePOPn

MdeModulePkg/Universal/EbcDxe/EbcExecute.c:2823–2868  ·  view source on GitHub ↗

Execute the EBC POPn instruction. Instruction syntax: POPn {@}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

2821
2822**/
2823EFI_STATUS
2824ExecutePOPn (
2825 IN VM_CONTEXT *VmPtr
2826 )
2827{
2828 UINT8 Opcode;
2829 UINT8 Operands;
2830 INT16 Index16;
2831 UINTN DataN;
2832
2833 //
2834 // Get opcode and operands
2835 //
2836 Opcode = GETOPCODE (VmPtr);
2837 Operands = GETOPERANDS (VmPtr);
2838 //
2839 // Get immediate data if present, and advance the IP
2840 //
2841 if ((Opcode & PUSHPOP_M_IMMDATA) != 0) {
2842 if (OPERAND1_INDIRECT (Operands)) {
2843 Index16 = VmReadIndex16 (VmPtr, 2);
2844 } else {
2845 Index16 = VmReadImmed16 (VmPtr, 2);
2846 }
2847
2848 VmPtr->Ip += 4;
2849 } else {
2850 Index16 = 0;
2851 VmPtr->Ip += 2;
2852 }
2853 //
2854 // Read the data off the stack, then adjust the stack pointer
2855 //
2856 DataN = VmReadMemN (VmPtr, (UINTN) VmPtr->Gpr[0]);
2857 VmPtr->Gpr[0] += sizeof (UINTN);
2858 //
2859 // Do the write-back
2860 //
2861 if (OPERAND1_INDIRECT (Operands)) {
2862 VmWriteMemN (VmPtr, (UINTN) (VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16), DataN);
2863 } else {
2864 VmPtr->Gpr[OPERAND1_REGNUM (Operands)] = (INT64) (UINT64) (UINTN) (DataN + Index16);
2865 }
2866
2867 return EFI_SUCCESS;
2868}
2869
2870
2871/**

Callers

nothing calls this directly

Calls 4

VmReadIndex16Function · 0.85
VmReadImmed16Function · 0.85
VmReadMemNFunction · 0.85
VmWriteMemNFunction · 0.85

Tested by

no test coverage detected