From 34e4e297bf61ae304e6b9a339b3a6954dd7a668f Mon Sep 17 00:00:00 2001 From: qhuang8 Date: Sat, 26 Jul 2008 07:35:34 +0000 Subject: [PATCH] Code scrub for EBC module. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5568 6f19259b-4bc3-4df7-8a09-765794883524 --- MdeModulePkg/Universal/EbcDxe/EbcDxe.inf | 5 +- MdeModulePkg/Universal/EbcDxe/EbcExecute.c | 182 +++++++++--------- MdeModulePkg/Universal/EbcDxe/EbcExecute.h | 14 +- MdeModulePkg/Universal/EbcDxe/EbcInt.c | 60 +++--- MdeModulePkg/Universal/EbcDxe/EbcInt.h | 54 +++--- .../Universal/EbcDxe/X64/EbcSupport.c | 2 +- 6 files changed, 158 insertions(+), 159 deletions(-) diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDxe.inf b/MdeModulePkg/Universal/EbcDxe/EbcDxe.inf index d912a2c93c..68fd2300c5 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcDxe.inf +++ b/MdeModulePkg/Universal/EbcDxe/EbcDxe.inf @@ -1,9 +1,7 @@ #/** @file # -# Component description file for Ebc module. -# # This module for the EBC virtual machine implementation produces -# EBC and EBC debug support protocols. +# EBC and EBC debug support protocols. # # Copyright (c) 2006 - 2008, Intel Corporation.
# All rights reserved. This program and the accompanying materials @@ -57,7 +55,6 @@ [Packages] MdePkg/MdePkg.dec - [LibraryClasses] diff --git a/MdeModulePkg/Universal/EbcDxe/EbcExecute.c b/MdeModulePkg/Universal/EbcDxe/EbcExecute.c index b819c5f024..334073c954 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcExecute.c +++ b/MdeModulePkg/Universal/EbcDxe/EbcExecute.c @@ -49,13 +49,13 @@ UINT64 b14:12 - number of bits in this index assigned to natural units (=a) ba:11 - constant units = ConstUnits b0:a - natural units = NaturalUnits - + Given this info, the offset can be computed by: offset = sign_bit * (ConstUnits + NaturalUnits * sizeof(UINTN)) Max offset is achieved with index = 0x7FFF giving an offset of 0x27B (32-bit machine) or 0x477 (64-bit machine). - Min offset is achieved with index = + Min offset is achieved with index = @param VmPtr A pointer to VM context. @param CodeOffset Offset from IP of the location of the 16-bit index @@ -179,7 +179,7 @@ VmReadMemN ( /** Writes 8-bit data to memory address. - + This routine is called by the EBC data movement instructions that write to memory. Since these writes may be to the stack, which looks like (high address on top) this, @@ -189,14 +189,14 @@ VmReadMemN ( [EBC stack] we need to detect all attempts to write to the EBC entry point argument - stack area and adjust the address (which will initially point into the + stack area and adjust the address (which will initially point into the VM stack) to point into the EBC entry point arguments. @param VmPtr A pointer to a VM context. @param Addr Adddress to write to. @param Data Value to write to Addr. - @retval EFI_SUCCESS The instruction is executed successfully. + @retval EFI_SUCCESS The instruction is executed successfully. @retval Other Some error occurs when writing data to the address. **/ @@ -209,7 +209,7 @@ VmWriteMem8 ( /** Writes 16-bit data to memory address. - + This routine is called by the EBC data movement instructions that write to memory. Since these writes may be to the stack, which looks like (high address on top) this, @@ -219,14 +219,14 @@ VmWriteMem8 ( [EBC stack] we need to detect all attempts to write to the EBC entry point argument - stack area and adjust the address (which will initially point into the + stack area and adjust the address (which will initially point into the VM stack) to point into the EBC entry point arguments. @param VmPtr A pointer to a VM context. @param Addr Adddress to write to. @param Data Value to write to Addr. - @retval EFI_SUCCESS The instruction is executed successfully. + @retval EFI_SUCCESS The instruction is executed successfully. @retval Other Some error occurs when writing data to the address. **/ @@ -239,7 +239,7 @@ VmWriteMem16 ( /** Writes 32-bit data to memory address. - + This routine is called by the EBC data movement instructions that write to memory. Since these writes may be to the stack, which looks like (high address on top) this, @@ -249,14 +249,14 @@ VmWriteMem16 ( [EBC stack] we need to detect all attempts to write to the EBC entry point argument - stack area and adjust the address (which will initially point into the + stack area and adjust the address (which will initially point into the VM stack) to point into the EBC entry point arguments. @param VmPtr A pointer to a VM context. @param Addr Adddress to write to. @param Data Value to write to Addr. - @retval EFI_SUCCESS The instruction is executed successfully. + @retval EFI_SUCCESS The instruction is executed successfully. @retval Other Some error occurs when writing data to the address. **/ @@ -440,7 +440,7 @@ ConvertStackAddr ( @param VmPtr A pointer to VM context. @param IsSignedOp Indicates whether the operand is signed or not. - @retval EFI_UNSUPPORTED The opcodes/operands is not supported. + @retval EFI_UNSUPPORTED The opcodes/operands is not supported. @retval EFI_SUCCESS The instruction is executed successfully. **/ @@ -472,7 +472,7 @@ ExecuteBREAK ( 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 @@ -557,7 +557,7 @@ ExecuteRET ( @param VmPtr A pointer to a VM context. - @retval EFI_UNSUPPORTED The opcodes/operands is not supported. + @retval EFI_UNSUPPORTED The opcodes/operands is not supported. @retval EFI_SUCCESS The instruction is executed successfully. **/ @@ -574,7 +574,7 @@ ExecuteCMP ( @param VmPtr A pointer to a VM context. - @retval EFI_UNSUPPORTED The opcodes/operands is not supported. + @retval EFI_UNSUPPORTED The opcodes/operands is not supported. @retval EFI_SUCCESS The instruction is executed successfully. **/ @@ -587,15 +587,15 @@ ExecuteCMPI ( Execute the MOVxx instructions. Instruction format: - + MOV[b|w|d|q|n]{w|d} {@}R1 {Index16|32}, {@}R2 {Index16|32} MOVqq {@}R1 {Index64}, {@}R2 {Index64} - + Copies contents of [R2] -> [R1], zero extending where required. - + First character indicates the size of the move. Second character indicates the size of the index(s). - + Invalid to have R1 direct with index. @param VmPtr A pointer to a VM context. @@ -613,20 +613,20 @@ ExecuteMOVxx ( Execute the EBC MOVI. Instruction syntax: - + MOVI[b|w|d|q][w|d|q] {@}R1 {Index16}, ImmData16|32|64 - + First variable character specifies the move size Second variable character specifies size of the immediate data - + Sign-extend the immediate data to the size of the operation, and zero-extend if storing to a register. - + Operand1 direct with index/immed is invalid. @param VmPtr A pointer to a VM context. - @retval EFI_UNSUPPORTED The opcodes/operands is not supported. + @retval EFI_UNSUPPORTED The opcodes/operands is not supported. @retval EFI_SUCCESS The instruction is executed successfully. **/ @@ -640,12 +640,12 @@ ExecuteMOVI ( index value into a register or memory location. Instruction syntax: - + MOVIn[w|d|q] {@}R1 {Index16}, Index16|32|64 @param VmPtr A pointer to a VM context. - @retval EFI_UNSUPPORTED The opcodes/operands is not supported. + @retval EFI_UNSUPPORTED The opcodes/operands is not supported. @retval EFI_SUCCESS The instruction is executed successfully. **/ @@ -659,12 +659,12 @@ ExecuteMOVIn ( Dest <- Ip + ImmData Instruction syntax: - + MOVREL[w|d|q] {@}R1 {Index16}, ImmData16|32|64 @param VmPtr A pointer to a VM context. - @retval EFI_UNSUPPORTED The opcodes/operands is not supported. + @retval EFI_UNSUPPORTED The opcodes/operands is not supported. @retval EFI_SUCCESS The instruction is executed successfully. **/ @@ -750,7 +750,7 @@ ExecutePOP ( @param VmPtr A pointer to VM context. - @retval EFI_UNSUPPORTED The opcodes/operands is not supported. + @retval EFI_UNSUPPORTED The opcodes/operands is not supported. @retval EFI_SUCCESS The instruction is executed successfully. **/ @@ -772,7 +772,7 @@ ExecuteSignedDataManip ( @param VmPtr A pointer to VM context. - @retval EFI_UNSUPPORTED The opcodes/operands is not supported. + @retval EFI_UNSUPPORTED The opcodes/operands is not supported. @retval EFI_SUCCESS The instruction is executed successfully. **/ @@ -789,7 +789,7 @@ ExecuteUnsignedDataManip ( @param VmPtr A pointer to a VM context. - @retval EFI_UNSUPPORTED The opcodes/operands is not supported. + @retval EFI_UNSUPPORTED The opcodes/operands is not supported. @retval EFI_SUCCESS The instruction is executed successfully. **/ @@ -806,7 +806,7 @@ ExecuteLOADSP ( @param VmPtr A pointer to a VM context. - @retval EFI_UNSUPPORTED The opcodes/operands is not supported. + @retval EFI_UNSUPPORTED The opcodes/operands is not supported. @retval EFI_SUCCESS The instruction is executed successfully. **/ @@ -822,15 +822,15 @@ ExecuteSTORESP ( is a register. Instruction syntax: - + MOVsnd {@}R1 {Indx32}, {@}R2 {Index32|Immed32} - + 0:7 1=>operand1 index present 0:6 1=>operand2 index present @param VmPtr A pointer to a VM context. - @retval EFI_UNSUPPORTED The opcodes/operands is not supported. + @retval EFI_UNSUPPORTED The opcodes/operands is not supported. @retval EFI_SUCCESS The instruction is executed successfully. **/ @@ -846,15 +846,15 @@ ExecuteMOVsnd ( is a register. Instruction syntax: - + MOVsnw {@}R1 {Index16}, {@}R2 {Index16|Immed16} - + 0:7 1=>operand1 index present 0:6 1=>operand2 index present @param VmPtr A pointer to a VM context. - @retval EFI_UNSUPPORTED The opcodes/operands is not supported. + @retval EFI_UNSUPPORTED The opcodes/operands is not supported. @retval EFI_SUCCESS The instruction is executed successfully. **/ @@ -1250,7 +1250,7 @@ ExecuteEXTNDD ( // Once we retrieve the operands for the data manipulation instructions, // call these functions to perform the operation. // -STATIC CONST DATA_MANIP_EXEC_FUNCTION mDataManipDispatchTable[] = { +CONST DATA_MANIP_EXEC_FUNCTION mDataManipDispatchTable[] = { ExecuteNOT, ExecuteNEG, ExecuteADD, @@ -1272,7 +1272,7 @@ STATIC CONST DATA_MANIP_EXEC_FUNCTION mDataManipDispatchTable[] = { ExecuteEXTNDD, }; -STATIC CONST VM_TABLE_ENTRY mVmOpcodeTable[] = { +CONST VM_TABLE_ENTRY mVmOpcodeTable[] = { { ExecuteBREAK }, // opcode 0x00 { ExecuteJMP }, // opcode 0x01 { ExecuteJMP8 }, // opcode 0x02 @@ -1336,7 +1336,7 @@ STATIC CONST VM_TABLE_ENTRY mVmOpcodeTable[] = { // // Length of JMP instructions, depending on upper two bits of opcode. // -STATIC CONST UINT8 mJMPLen[] = { 2, 2, 6, 10 }; +CONST UINT8 mJMPLen[] = { 2, 2, 6, 10 }; // // Simple Debugger Protocol GUID @@ -1536,15 +1536,15 @@ Done: Execute the MOVxx instructions. Instruction format: - + MOV[b|w|d|q|n]{w|d} {@}R1 {Index16|32}, {@}R2 {Index16|32} MOVqq {@}R1 {Index64}, {@}R2 {Index64} - + Copies contents of [R2] -> [R1], zero extending where required. - + First character indicates the size of the move. Second character indicates the size of the index(s). - + Invalid to have R1 direct with index. @param VmPtr A pointer to a VM context. @@ -1928,7 +1928,7 @@ ExecuteBREAK ( 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 @@ -2152,20 +2152,20 @@ ExecuteJMP8 ( Execute the EBC MOVI. Instruction syntax: - + MOVI[b|w|d|q][w|d|q] {@}R1 {Index16}, ImmData16|32|64 - + First variable character specifies the move size Second variable character specifies size of the immediate data - + Sign-extend the immediate data to the size of the operation, and zero-extend if storing to a register. - + Operand1 direct with index/immed is invalid. @param VmPtr A pointer to a VM context. - @retval EFI_UNSUPPORTED The opcodes/operands is not supported. + @retval EFI_UNSUPPORTED The opcodes/operands is not supported. @retval EFI_SUCCESS The instruction is executed successfully. **/ @@ -2278,12 +2278,12 @@ ExecuteMOVI ( index value into a register or memory location. Instruction syntax: - + MOVIn[w|d|q] {@}R1 {Index16}, Index16|32|64 @param VmPtr A pointer to a VM context. - @retval EFI_UNSUPPORTED The opcodes/operands is not supported. + @retval EFI_UNSUPPORTED The opcodes/operands is not supported. @retval EFI_SUCCESS The instruction is executed successfully. **/ @@ -2380,12 +2380,12 @@ ExecuteMOVIn ( Dest <- Ip + ImmData Instruction syntax: - + MOVREL[w|d|q] {@}R1 {Index16}, ImmData16|32|64 @param VmPtr A pointer to a VM context. - @retval EFI_UNSUPPORTED The opcodes/operands is not supported. + @retval EFI_UNSUPPORTED The opcodes/operands is not supported. @retval EFI_SUCCESS The instruction is executed successfully. **/ @@ -2483,15 +2483,15 @@ ExecuteMOVREL ( is a register. Instruction syntax: - + MOVsnw {@}R1 {Index16}, {@}R2 {Index16|Immed16} - + 0:7 1=>operand1 index present 0:6 1=>operand2 index present @param VmPtr A pointer to a VM context. - @retval EFI_UNSUPPORTED The opcodes/operands is not supported. + @retval EFI_UNSUPPORTED The opcodes/operands is not supported. @retval EFI_SUCCESS The instruction is executed successfully. **/ @@ -2576,15 +2576,15 @@ ExecuteMOVsnw ( is a register. Instruction syntax: - + MOVsnd {@}R1 {Indx32}, {@}R2 {Index32|Immed32} - + 0:7 1=>operand1 index present 0:6 1=>operand2 index present @param VmPtr A pointer to a VM context. - @retval EFI_UNSUPPORTED The opcodes/operands is not supported. + @retval EFI_UNSUPPORTED The opcodes/operands is not supported. @retval EFI_SUCCESS The instruction is executed successfully. **/ @@ -3128,7 +3128,7 @@ ExecuteRET ( @param VmPtr A pointer to a VM context. - @retval EFI_UNSUPPORTED The opcodes/operands is not supported. + @retval EFI_UNSUPPORTED The opcodes/operands is not supported. @retval EFI_SUCCESS The instruction is executed successfully. **/ @@ -3289,7 +3289,7 @@ ExecuteCMP ( @param VmPtr A pointer to a VM context. - @retval EFI_UNSUPPORTED The opcodes/operands is not supported. + @retval EFI_UNSUPPORTED The opcodes/operands is not supported. @retval EFI_SUCCESS The instruction is executed successfully. **/ @@ -4057,7 +4057,7 @@ ExecuteEXTNDD ( @param VmPtr A pointer to VM context. - @retval EFI_UNSUPPORTED The opcodes/operands is not supported. + @retval EFI_UNSUPPORTED The opcodes/operands is not supported. @retval EFI_SUCCESS The instruction is executed successfully. **/ @@ -4087,7 +4087,7 @@ ExecuteSignedDataManip ( @param VmPtr A pointer to VM context. - @retval EFI_UNSUPPORTED The opcodes/operands is not supported. + @retval EFI_UNSUPPORTED The opcodes/operands is not supported. @retval EFI_SUCCESS The instruction is executed successfully. **/ @@ -4118,7 +4118,7 @@ ExecuteUnsignedDataManip ( @param VmPtr A pointer to VM context. @param IsSignedOp Indicates whether the operand is signed or not. - @retval EFI_UNSUPPORTED The opcodes/operands is not supported. + @retval EFI_UNSUPPORTED The opcodes/operands is not supported. @retval EFI_SUCCESS The instruction is executed successfully. **/ @@ -4267,7 +4267,7 @@ ExecuteDataManip ( @param VmPtr A pointer to a VM context. - @retval EFI_UNSUPPORTED The opcodes/operands is not supported. + @retval EFI_UNSUPPORTED The opcodes/operands is not supported. @retval EFI_SUCCESS The instruction is executed successfully. **/ @@ -4321,7 +4321,7 @@ ExecuteLOADSP ( @param VmPtr A pointer to a VM context. - @retval EFI_UNSUPPORTED The opcodes/operands is not supported. + @retval EFI_UNSUPPORTED The opcodes/operands is not supported. @retval EFI_SUCCESS The instruction is executed successfully. **/ @@ -4381,13 +4381,13 @@ ExecuteSTORESP ( b14:12 - number of bits in this index assigned to natural units (=a) ba:11 - constant units = ConstUnits b0:a - natural units = NaturalUnits - + Given this info, the offset can be computed by: offset = sign_bit * (ConstUnits + NaturalUnits * sizeof(UINTN)) Max offset is achieved with index = 0x7FFF giving an offset of 0x27B (32-bit machine) or 0x477 (64-bit machine). - Min offset is achieved with index = + Min offset is achieved with index = @param VmPtr A pointer to VM context. @param CodeOffset Offset from IP of the location of the 16-bit index @@ -4585,7 +4585,7 @@ VmReadIndex64 ( /** Writes 8-bit data to memory address. - + This routine is called by the EBC data movement instructions that write to memory. Since these writes may be to the stack, which looks like (high address on top) this, @@ -4595,14 +4595,14 @@ VmReadIndex64 ( [EBC stack] we need to detect all attempts to write to the EBC entry point argument - stack area and adjust the address (which will initially point into the + stack area and adjust the address (which will initially point into the VM stack) to point into the EBC entry point arguments. @param VmPtr A pointer to a VM context. @param Addr Adddress to write to. @param Data Value to write to Addr. - @retval EFI_SUCCESS The instruction is executed successfully. + @retval EFI_SUCCESS The instruction is executed successfully. @retval Other Some error occurs when writing data to the address. **/ @@ -4623,7 +4623,7 @@ VmWriteMem8 ( /** Writes 16-bit data to memory address. - + This routine is called by the EBC data movement instructions that write to memory. Since these writes may be to the stack, which looks like (high address on top) this, @@ -4633,14 +4633,14 @@ VmWriteMem8 ( [EBC stack] we need to detect all attempts to write to the EBC entry point argument - stack area and adjust the address (which will initially point into the + stack area and adjust the address (which will initially point into the VM stack) to point into the EBC entry point arguments. @param VmPtr A pointer to a VM context. @param Addr Adddress to write to. @param Data Value to write to Addr. - @retval EFI_SUCCESS The instruction is executed successfully. + @retval EFI_SUCCESS The instruction is executed successfully. @retval Other Some error occurs when writing data to the address. **/ @@ -4686,7 +4686,7 @@ VmWriteMem16 ( /** Writes 32-bit data to memory address. - + This routine is called by the EBC data movement instructions that write to memory. Since these writes may be to the stack, which looks like (high address on top) this, @@ -4696,14 +4696,14 @@ VmWriteMem16 ( [EBC stack] we need to detect all attempts to write to the EBC entry point argument - stack area and adjust the address (which will initially point into the + stack area and adjust the address (which will initially point into the VM stack) to point into the EBC entry point arguments. @param VmPtr A pointer to a VM context. @param Addr Adddress to write to. @param Data Value to write to Addr. - @retval EFI_SUCCESS The instruction is executed successfully. + @retval EFI_SUCCESS The instruction is executed successfully. @retval Other Some error occurs when writing data to the address. **/ @@ -4749,7 +4749,7 @@ VmWriteMem32 ( /** Writes 64-bit data to memory address. - + This routine is called by the EBC data movement instructions that write to memory. Since these writes may be to the stack, which looks like (high address on top) this, @@ -4759,14 +4759,14 @@ VmWriteMem32 ( [EBC stack] we need to detect all attempts to write to the EBC entry point argument - stack area and adjust the address (which will initially point into the + stack area and adjust the address (which will initially point into the VM stack) to point into the EBC entry point arguments. @param VmPtr A pointer to a VM context. @param Addr Adddress to write to. @param Data Value to write to Addr. - @retval EFI_SUCCESS The instruction is executed successfully. + @retval EFI_SUCCESS The instruction is executed successfully. @retval Other Some error occurs when writing data to the address. **/ @@ -4814,7 +4814,7 @@ VmWriteMem64 ( /** Writes UINTN data to memory address. - + This routine is called by the EBC data movement instructions that write to memory. Since these writes may be to the stack, which looks like (high address on top) this, @@ -4824,14 +4824,14 @@ VmWriteMem64 ( [EBC stack] we need to detect all attempts to write to the EBC entry point argument - stack area and adjust the address (which will initially point into the + stack area and adjust the address (which will initially point into the VM stack) to point into the EBC entry point arguments. @param VmPtr A pointer to a VM context. @param Addr Adddress to write to. @param Data Value to write to Addr. - @retval EFI_SUCCESS The instruction is executed successfully. + @retval EFI_SUCCESS The instruction is executed successfully. @retval Other Some error occurs when writing data to the address. **/ @@ -4862,7 +4862,7 @@ VmWriteMemN ( MemoryFence (); Status = VmWriteMem32 (VmPtr, Addr + Index * sizeof (UINT32), (UINT32) Data); MemoryFence (); - Data = (UINTN)RShiftU64 ((UINT64)Data, 32); + Data = (UINTN) RShiftU64 ((UINT64)Data, 32); } } @@ -4969,8 +4969,8 @@ VmReadImmed32 ( // // Return unaligned data // - Data = (UINT32) VmReadCode16 (VmPtr, Offset); - Data |= (UINT32) (VmReadCode16 (VmPtr, Offset + 2) << 16); + Data = (UINT32) VmReadCode16 (VmPtr, Offset); + Data |= (UINT32)(VmReadCode16 (VmPtr, Offset + 2) << 16); return Data; } @@ -5011,7 +5011,7 @@ VmReadImmed64 ( Ptr = (UINT8 *) &Data64; Data32 = VmReadCode32 (VmPtr, Offset); *(UINT32 *) Ptr = Data32; - Ptr += sizeof (Data32); + Ptr += sizeof (Data32); Data32 = VmReadCode32 (VmPtr, Offset + sizeof (UINT32)); *(UINT32 *) Ptr = Data32; return Data64; @@ -5126,7 +5126,7 @@ VmReadCode64 ( Ptr = (UINT8 *) &Data64; Data32 = VmReadCode32 (VmPtr, Offset); *(UINT32 *) Ptr = Data32; - Ptr += sizeof (Data32); + Ptr += sizeof (Data32); Data32 = VmReadCode32 (VmPtr, Offset + sizeof (UINT32)); *(UINT32 *) Ptr = Data32; return Data64; @@ -5340,7 +5340,7 @@ VmReadMemN ( /** Returns the version of the EBC virtual machine. - + @return The 64-bit version of EBC virtual machine. **/ diff --git a/MdeModulePkg/Universal/EbcDxe/EbcExecute.h b/MdeModulePkg/Universal/EbcDxe/EbcExecute.h index e9805445ea..88bf9d5843 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcExecute.h +++ b/MdeModulePkg/Universal/EbcDxe/EbcExecute.h @@ -245,7 +245,7 @@ EbcExecute ( /** Returns the version of the EBC virtual machine. - + @return The 64-bit version of EBC virtual machine. **/ @@ -256,7 +256,7 @@ GetVmVersion ( /** Writes UINTN data to memory address. - + This routine is called by the EBC data movement instructions that write to memory. Since these writes may be to the stack, which looks like (high address on top) this, @@ -266,14 +266,14 @@ GetVmVersion ( [EBC stack] we need to detect all attempts to write to the EBC entry point argument - stack area and adjust the address (which will initially point into the + stack area and adjust the address (which will initially point into the VM stack) to point into the EBC entry point arguments. @param VmPtr A pointer to a VM context. @param Addr Adddress to write to. @param Data Value to write to Addr. - @retval EFI_SUCCESS The instruction is executed successfully. + @retval EFI_SUCCESS The instruction is executed successfully. @retval Other Some error occurs when writing data to the address. **/ @@ -286,7 +286,7 @@ VmWriteMemN ( /** Writes 64-bit data to memory address. - + This routine is called by the EBC data movement instructions that write to memory. Since these writes may be to the stack, which looks like (high address on top) this, @@ -296,14 +296,14 @@ VmWriteMemN ( [EBC stack] we need to detect all attempts to write to the EBC entry point argument - stack area and adjust the address (which will initially point into the + stack area and adjust the address (which will initially point into the VM stack) to point into the EBC entry point arguments. @param VmPtr A pointer to a VM context. @param Addr Adddress to write to. @param Data Value to write to Addr. - @retval EFI_SUCCESS The instruction is executed successfully. + @retval EFI_SUCCESS The instruction is executed successfully. @retval Other Some error occurs when writing data to the address. **/ diff --git a/MdeModulePkg/Universal/EbcDxe/EbcInt.c b/MdeModulePkg/Universal/EbcDxe/EbcInt.c index e6c463e672..764732c29f 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcInt.c +++ b/MdeModulePkg/Universal/EbcDxe/EbcInt.c @@ -89,7 +89,7 @@ EbcCreateThunk ( @param This A pointer to the EFI_EBC_PROTOCOL instance. @param Version Pointer to where to store the returned version of the interpreter. - + @retval EFI_SUCCESS The function completed successfully. @retval EFI_INVALID_PARAMETER Version pointer is NULL. @@ -184,7 +184,7 @@ InitEbcVmTestProtocol ( /** Returns the EFI_UNSUPPORTED Status. - + @return EFI_UNSUPPORTED This function always return EFI_UNSUPPORTED status. **/ @@ -195,11 +195,11 @@ EbcVmTestUnsupported ( /** Registers a callback function that the EBC interpreter calls to flush the - processor instruction cache following creation of thunks. + processor instruction cache following creation of thunks. @param This A pointer to the EFI_EBC_PROTOCOL instance. @param Flush Pointer to a function of type EBC_ICACH_FLUSH. - + @retval EFI_SUCCESS The function completed successfully. **/ @@ -302,7 +302,7 @@ EbcDebugRegisterExceptionCallback ( @param Start StartSpecifies the physical base of the memory range to be invalidated. @param Length Specifies the minimum number of bytes in the - processor's instruction cache to invalidate. + processor's instruction cache to invalidate. @retval EFI_SUCCESS The function completed successfully. @@ -322,29 +322,29 @@ EbcDebugInvalidateInstructionCache ( // also be global since the execution of an EBC image does not provide // a This pointer. // -STATIC EBC_IMAGE_LIST *mEbcImageList = NULL; +EBC_IMAGE_LIST *mEbcImageList = NULL; // // Callback function to flush the icache after thunk creation // -STATIC EBC_ICACHE_FLUSH mEbcICacheFlush; +EBC_ICACHE_FLUSH mEbcICacheFlush; // // These get set via calls by the debug agent // -STATIC EFI_PERIODIC_CALLBACK mDebugPeriodicCallback = NULL; -STATIC EFI_EXCEPTION_CALLBACK mDebugExceptionCallback[MAX_EBC_EXCEPTION + 1] = {NULL}; -STATIC EFI_GUID mEfiEbcVmTestProtocolGuid = EFI_EBC_VM_TEST_PROTOCOL_GUID; +EFI_PERIODIC_CALLBACK mDebugPeriodicCallback = NULL; +EFI_EXCEPTION_CALLBACK mDebugExceptionCallback[MAX_EBC_EXCEPTION + 1] = {NULL}; +EFI_GUID mEfiEbcVmTestProtocolGuid = EFI_EBC_VM_TEST_PROTOCOL_GUID; -STATIC VOID* mStackBuffer[MAX_STACK_NUM]; -STATIC EFI_HANDLE mStackBufferIndex[MAX_STACK_NUM]; -STATIC UINTN mStackNum = 0; +VOID *mStackBuffer[MAX_STACK_NUM]; +EFI_HANDLE mStackBufferIndex[MAX_STACK_NUM]; +UINTN mStackNum = 0; // // Event for Periodic callback // -STATIC EFI_EVENT mEbcPeriodicEvent; -VM_CONTEXT *mVmPtr = NULL; +EFI_EVENT mEbcPeriodicEvent; +VM_CONTEXT *mVmPtr = NULL; /** @@ -701,7 +701,7 @@ EbcDebugRegisterExceptionCallback ( @param Start StartSpecifies the physical base of the memory range to be invalidated. @param Length Specifies the minimum number of bytes in the - processor's instruction cache to invalidate. + processor's instruction cache to invalidate. @retval EFI_SUCCESS The function completed successfully. @@ -723,7 +723,7 @@ EbcDebugInvalidateInstructionCache ( The VM interpreter calls this function when an exception is detected. @param ExceptionType Specifies the processor exception detected. - @param ExceptionFlags Specifies the exception context. + @param ExceptionFlags Specifies the exception context. @param VmPtr Pointer to a VM context for passing info to the EFI debugger. @@ -1120,11 +1120,11 @@ EbcAddImageThunk ( /** Registers a callback function that the EBC interpreter calls to flush the - processor instruction cache following creation of thunks. + processor instruction cache following creation of thunks. @param This A pointer to the EFI_EBC_PROTOCOL instance. @param Flush Pointer to a function of type EBC_ICACH_FLUSH. - + @retval EFI_SUCCESS The function completed successfully. **/ @@ -1145,7 +1145,7 @@ EbcRegisterICacheFlush ( @param This A pointer to the EFI_EBC_PROTOCOL instance. @param Version Pointer to where to store the returned version of the interpreter. - + @retval EFI_SUCCESS The function completed successfully. @retval EFI_INVALID_PARAMETER Version pointer is NULL. @@ -1168,10 +1168,10 @@ EbcGetVersion ( /** Returns the stack index and buffer assosicated with the Handle parameter. - @param Handle The EFI handle as the index to the EBC stack. + @param Handle The EFI handle as the index to the EBC stack. @param StackBuffer A pointer to hold the returned stack buffer. @param BufferIndex A pointer to hold the returned stack index. - + @retval EFI_OUT_OF_RESOURCES The Handle parameter does not correspond to any existing EBC stack. @retval EFI_SUCCESS The stack index and buffer were found and @@ -1204,10 +1204,10 @@ GetEBCStack( } /** - Returns from the EBC stack by stack Index. - + Returns from the EBC stack by stack Index. + @param Index Specifies which EBC stack to return from. - + @retval EFI_SUCCESS The function completed successfully. **/ @@ -1221,10 +1221,10 @@ ReturnEBCStack( } /** - Returns from the EBC stack associated with the Handle parameter. - + Returns from the EBC stack associated with the Handle parameter. + @param Handle Specifies the EFI handle to find the EBC stack with. - + @retval EFI_SUCCESS The function completed successfully. **/ @@ -1249,7 +1249,7 @@ ReturnEBCStackByHandle( /** Allocates memory to hold all the EBC stacks. - @retval EFI_SUCCESS The EBC stacks were allocated successfully. + @retval EFI_SUCCESS The EBC stacks were allocated successfully. @retval EFI_OUT_OF_RESOURCES Not enough memory available for EBC stacks. **/ @@ -1336,7 +1336,7 @@ InitEbcVmTestProtocol ( /** Returns the EFI_UNSUPPORTED Status. - + @return EFI_UNSUPPORTED This function always return EFI_UNSUPPORTED status. **/ diff --git a/MdeModulePkg/Universal/EbcDxe/EbcInt.h b/MdeModulePkg/Universal/EbcDxe/EbcInt.h index a8767e8957..becd701974 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcInt.h +++ b/MdeModulePkg/Universal/EbcDxe/EbcInt.h @@ -34,11 +34,11 @@ typedef UINT8 *VMIP; // instruction pointer for the VM typedef UINT32 EXCEPTION_FLAGS; typedef struct { - VM_REGISTER R[8]; // General purpose registers. - UINT64 Flags; // Flags register: - // 0 Set to 1 if the result of the last compare was true - // 1 Set to 1 if stepping - // 2..63 Reserved. + VM_REGISTER R[8]; // General purpose registers. + UINT64 Flags; // Flags register: + // 0 Set to 1 if the result of the last compare was true + // 1 Set to 1 if stepping + // 2..63 Reserved. VMIP Ip; // Instruction pointer. UINTN LastException; // EXCEPTION_FLAGS ExceptionFlags; // to keep track of exceptions @@ -132,7 +132,7 @@ EbcAddImageThunk ( The VM interpreter calls this function when an exception is detected. @param ExceptionType Specifies the processor exception detected. - @param ExceptionFlags Specifies the exception context. + @param ExceptionFlags Specifies the exception context. @param VmPtr Pointer to a VM context for passing info to the EFI debugger. @@ -157,13 +157,13 @@ EbcDebugSignalException ( // // External low level functions that are native-processor dependent -// +// /** - The VM thunk code stuffs an EBC entry point into a processor + The VM thunk code stuffs an EBC entry point into a processor register. Since we can't use inline assembly to get it from the interpreter C code, stuff it into the return value register and return. - + @return The contents of the register in which the entry point is passed. **/ @@ -191,7 +191,7 @@ EbcLLGetStackPointer ( /** This function is called to execute an EBC CALLEX instruction. This instruction requires that we thunk out to external native - code. For x64, we switch stacks, copy the arguments to the stack + code. For x64, we switch stacks, copy the arguments to the stack and jump to the specified function. On return, we restore the stack pointer to its original location. Destroys no working registers. @@ -251,10 +251,10 @@ EbcLLGetReturnValue ( /** Returns the stack index and buffer assosicated with the Handle parameter. - @param Handle The EFI handle as the index to the EBC stack. + @param Handle The EFI handle as the index to the EBC stack. @param StackBuffer A pointer to hold the returned stack buffer. @param BufferIndex A pointer to hold the returned stack index. - + @retval EFI_OUT_OF_RESOURCES The Handle parameter does not correspond to any existing EBC stack. @retval EFI_SUCCESS The stack index and buffer were found and @@ -269,10 +269,10 @@ GetEBCStack( ); /** - Returns from the EBC stack by stack Index. - + Returns from the EBC stack by stack Index. + @param Index Specifies which EBC stack to return from. - + @retval EFI_SUCCESS The function completed successfully. **/ @@ -284,7 +284,7 @@ ReturnEBCStack( /** Allocates memory to hold all the EBC stacks. - @retval EFI_SUCCESS The EBC stacks were allocated successfully. + @retval EFI_SUCCESS The EBC stacks were allocated successfully. @retval EFI_OUT_OF_RESOURCES Not enough memory available for EBC stacks. **/ @@ -305,10 +305,10 @@ FreeEBCStack( ); /** - Returns from the EBC stack associated with the Handle parameter. - + Returns from the EBC stack associated with the Handle parameter. + @param Handle Specifies the EFI handle to find the EBC stack with. - + @retval EFI_SUCCESS The function completed successfully. **/ @@ -316,6 +316,8 @@ EFI_STATUS ReturnEBCStackByHandle( IN EFI_HANDLE Handle ); + + // // Defines for a simple EBC debugger interface // @@ -329,23 +331,23 @@ typedef struct _EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL EFI_EBC_SIMPLE_DEBUGGER_PROTOCO typedef EFI_STATUS (*EBC_DEBUGGER_SIGNAL_EXCEPTION) ( - IN EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL * This, - IN VM_CONTEXT * VmPtr, + IN EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL *This, + IN VM_CONTEXT *VmPtr, IN EFI_EXCEPTION_TYPE ExceptionType ); typedef VOID (*EBC_DEBUGGER_DEBUG) ( - IN EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL * This, - IN VM_CONTEXT * VmPtr + IN EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL *This, + IN VM_CONTEXT *VmPtr ); typedef UINT32 (*EBC_DEBUGGER_DASM) ( - IN EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL * This, - IN VM_CONTEXT * VmPtr, + IN EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL *This, + IN VM_CONTEXT *VmPtr, IN UINT16 *DasmString OPTIONAL, IN UINT32 DasmStringSize ); @@ -359,7 +361,7 @@ UINT32 typedef EFI_STATUS (*EBC_DEBUGGER_CONFIGURE) ( - IN EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL * This, + IN EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL *This, IN UINT32 ConfigId, IN UINTN ConfigValue ); diff --git a/MdeModulePkg/Universal/EbcDxe/X64/EbcSupport.c b/MdeModulePkg/Universal/EbcDxe/X64/EbcSupport.c index 2a01c89245..3f84bcc496 100644 --- a/MdeModulePkg/Universal/EbcDxe/X64/EbcSupport.c +++ b/MdeModulePkg/Universal/EbcDxe/X64/EbcSupport.c @@ -273,7 +273,7 @@ ExecuteEbcImageEntryPoint ( // Initialize the stack pointer for the EBC. Get the current system stack // pointer and adjust it down by the max needed for the interpreter. // - Addr = EbcLLGetStackPointer (); + Addr = EbcLLGetStackPointer (); Status = GetEBCStack(ImageHandle, &VmContext.StackPool, &StackIndex); if (EFI_ERROR(Status)) { -- 2.39.2