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

Function ExecuteRET

MdeModulePkg/Universal/EbcDxe/EbcExecute.c:3112–3151  ·  view source on GitHub ↗

Execute the EBC RET instruction. Instruction syntax: RET @param VmPtr A pointer to a VM context. @retval EFI_SUCCESS The instruction is executed successfully. **/

Source from the content-addressed store, hash-verified

3110
3111**/
3112EFI_STATUS
3113ExecuteRET (
3114 IN VM_CONTEXT *VmPtr
3115 )
3116{
3117
3118 EbcDebuggerHookRETStart (VmPtr);
3119
3120 //
3121 // If we're at the top of the stack, then simply set the done
3122 // flag and return
3123 //
3124 if (VmPtr->StackRetAddr == (UINT64) VmPtr->Gpr[0]) {
3125 VmPtr->StopFlags |= STOPFLAG_APP_DONE;
3126 } else {
3127 //
3128 // Pull the return address off the VM app's stack and set the IP
3129 // to it
3130 //
3131 if (!IS_ALIGNED ((UINTN) VmPtr->Gpr[0], sizeof (UINT16))) {
3132 EbcDebugSignalException (
3133 EXCEPT_EBC_ALIGNMENT_CHECK,
3134 EXCEPTION_FLAG_FATAL,
3135 VmPtr
3136 );
3137 }
3138 //
3139 // Restore the IP and frame pointer from the stack
3140 //
3141 VmPtr->Ip = (VMIP) (UINTN) VmReadMem64 (VmPtr, (UINTN) VmPtr->Gpr[0]);
3142 VmPtr->Gpr[0] += 8;
3143 VmPtr->FramePtr = (VOID *) VmReadMemN (VmPtr, (UINTN) VmPtr->Gpr[0]);
3144 VmPtr->Gpr[0] += 8;
3145 }
3146
3147
3148 EbcDebuggerHookRETEnd (VmPtr);
3149
3150 return EFI_SUCCESS;
3151}
3152
3153
3154/**

Callers

nothing calls this directly

Calls 5

EbcDebugSignalExceptionFunction · 0.85
VmReadMem64Function · 0.85
VmReadMemNFunction · 0.85
EbcDebuggerHookRETStartFunction · 0.70
EbcDebuggerHookRETEndFunction · 0.70

Tested by

no test coverage detected