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

Function ExecuteCMPI

MdeModulePkg/Universal/EbcDxe/EbcExecute.c:3327–3491  ·  view source on GitHub ↗

Execute the EBC CMPI instruction Instruction syntax: CMPI[32|64]{w|d}[eq|lte|gte|ulte|ugte] {@}Rx {Index16}, Immed16|Immed32 @param VmPtr A pointer to a VM context. @retval EFI_UNSUPPORTED The opcodes/operands is not supported. @retval EFI_SUCCESS The instruction is executed successfully. **/

Source from the content-addressed store, hash-verified

3325
3326**/
3327EFI_STATUS
3328ExecuteCMPI (
3329 IN VM_CONTEXT *VmPtr
3330 )
3331{
3332 UINT8 Opcode;
3333 UINT8 Operands;
3334 UINT8 Size;
3335 INT64 Op1;
3336 INT64 Op2;
3337 INT16 Index16;
3338 UINT32 Flag;
3339
3340 //
3341 // Get opcode and operands
3342 //
3343 Opcode = GETOPCODE (VmPtr);
3344 Operands = GETOPERANDS (VmPtr);
3345
3346 //
3347 // Get operand1 index if present
3348 //
3349 Size = 2;
3350 if ((Operands & OPERAND_M_CMPI_INDEX) != 0) {
3351 Index16 = VmReadIndex16 (VmPtr, 2);
3352 Size += 2;
3353 } else {
3354 Index16 = 0;
3355 }
3356 //
3357 // Get operand1 data we're going to compare to
3358 //
3359 Op1 = (INT64) VmPtr->Gpr[OPERAND1_REGNUM (Operands)];
3360 if (OPERAND1_INDIRECT (Operands)) {
3361 //
3362 // Indirect operand1. Fetch 32 or 64-bit value based on compare size.
3363 //
3364 if ((Opcode & OPCODE_M_CMPI64) != 0) {
3365 Op1 = (INT64) VmReadMem64 (VmPtr, (UINTN) Op1 + Index16);
3366 } else {
3367 Op1 = (INT64) VmReadMem32 (VmPtr, (UINTN) Op1 + Index16);
3368 }
3369 } else {
3370 //
3371 // Better not have been an index with direct. That is, CMPI R1 Index,...
3372 // is illegal.
3373 //
3374 if ((Operands & OPERAND_M_CMPI_INDEX) != 0) {
3375 EbcDebugSignalException (
3376 EXCEPT_EBC_INSTRUCTION_ENCODING,
3377 EXCEPTION_FLAG_ERROR,
3378 VmPtr
3379 );
3380 VmPtr->Ip += Size;
3381 return EFI_UNSUPPORTED;
3382 }
3383 }
3384 //

Callers

nothing calls this directly

Calls 6

VmReadIndex16Function · 0.85
VmReadMem64Function · 0.85
VmReadMem32Function · 0.85
EbcDebugSignalExceptionFunction · 0.85
VmReadImmed32Function · 0.85
VmReadImmed16Function · 0.85

Tested by

no test coverage detected