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

Function ExecuteJMP

MdeModulePkg/Universal/EbcDxe/EbcExecute.c:1948–2106  ·  view source on GitHub ↗

Execute the JMP instruction. Instruction syntax: JMP64{cs|cc} Immed64 JMP32{cs|cc} {@}R1 {Immed32|Index32} Encoding: b0.7 - immediate data present b0.6 - 1 = 64 bit immediate data 0 = 32 bit immediate data b1.7 - 1 = conditional b1.6 1 = CS (condition set) 0 = CC (condition clear) b1.4 1 = relative address

Source from the content-addressed store, hash-verified

1946
1947**/
1948EFI_STATUS
1949ExecuteJMP (
1950 IN VM_CONTEXT *VmPtr
1951 )
1952{
1953 UINT8 Opcode;
1954 UINT8 CompareSet;
1955 UINT8 ConditionFlag;
1956 UINT8 Size;
1957 UINT8 Operand;
1958 UINT64 Data64;
1959 INT32 Index32;
1960 UINTN Addr;
1961
1962 Operand = GETOPERANDS (VmPtr);
1963 Opcode = GETOPCODE (VmPtr);
1964
1965 //
1966 // Get instruction length from the opcode. The upper two bits are used here
1967 // to index into the length array.
1968 //
1969 Size = mJMPLen[(Opcode >> 6) & 0x03];
1970
1971 //
1972 // Decode instruction conditions
1973 // If we haven't met the condition, then simply advance the IP and return.
1974 //
1975 CompareSet = (UINT8) (((Operand & JMP_M_CS) != 0) ? 1 : 0);
1976 ConditionFlag = (UINT8) VMFLAG_ISSET (VmPtr, VMFLAGS_CC);
1977 if ((Operand & CONDITION_M_CONDITIONAL) != 0) {
1978 if (CompareSet != ConditionFlag) {
1979 EbcDebuggerHookJMPStart (VmPtr);
1980 VmPtr->Ip += Size;
1981 EbcDebuggerHookJMPEnd (VmPtr);
1982 return EFI_SUCCESS;
1983 }
1984 }
1985 //
1986 // Check for 64-bit form and do it right away since it's the most
1987 // straight-forward form.
1988 //
1989 if ((Opcode & OPCODE_M_IMMDATA64) != 0) {
1990 //
1991 // Double check for immediate-data, which is required. If not there,
1992 // then signal an exception
1993 //
1994 if ((Opcode & OPCODE_M_IMMDATA) == 0) {
1995 EbcDebugSignalException (
1996 EXCEPT_EBC_INSTRUCTION_ENCODING,
1997 EXCEPTION_FLAG_ERROR,
1998 VmPtr
1999 );
2000 return EFI_UNSUPPORTED;
2001 }
2002 //
2003 // 64-bit immediate data is full address. Read the immediate data,
2004 // check for alignment, and jump absolute.
2005 //

Callers

nothing calls this directly

Calls 7

EbcDebugSignalExceptionFunction · 0.85
VmReadImmed64Function · 0.85
VmReadIndex32Function · 0.85
VmReadImmed32Function · 0.85
VmReadMemNFunction · 0.85
EbcDebuggerHookJMPStartFunction · 0.70
EbcDebuggerHookJMPEndFunction · 0.70

Tested by

no test coverage detected