]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Add doxygen style comments for functions in EBC module.
authorqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 13 May 2008 08:46:12 +0000 (08:46 +0000)
committerqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 13 May 2008 08:46:12 +0000 (08:46 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5194 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/EbcDxe/EbcExecute.c
MdeModulePkg/Universal/EbcDxe/EbcExecute.h
MdeModulePkg/Universal/EbcDxe/EbcInt.c
MdeModulePkg/Universal/EbcDxe/EbcInt.h
MdeModulePkg/Universal/EbcDxe/Ia32/EbcSupport.c
MdeModulePkg/Universal/EbcDxe/Ipf/EbcSupport.c
MdeModulePkg/Universal/EbcDxe/Ipf/EbcSupport.h
MdeModulePkg/Universal/EbcDxe/x64/EbcSupport.c

index d44892e84af3b6be9f0b5d3f74db81fb19830f72..c3c7b915f98ea6a5ba0f3edfe0815e1c2ebaaba1 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Contains code that implements the virtual machine.\r
 \r
-Copyright (c) 2006, Intel Corporation\r
+Copyright (c) 2006 - 2008, Intel Corporation\r
 All rights reserved. This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -42,6 +42,28 @@ UINT64
   IN UINT64     Op2\r
   );\r
 \r
+/**\r
+  Decode a 16-bit index to determine the offset. Given an index value:\r
+\r
+    b15     - sign bit\r
+    b14:12  - number of bits in this index assigned to natural units (=a)\r
+    ba:11   - constant units = ConstUnits\r
+    b0:a    - natural units = NaturalUnits\r
+  \r
+  Given this info, the offset can be computed by:\r
+    offset = sign_bit * (ConstUnits + NaturalUnits * sizeof(UINTN))\r
+\r
+  Max offset is achieved with index = 0x7FFF giving an offset of\r
+  0x27B (32-bit machine) or 0x477 (64-bit machine).\r
+  Min offset is achieved with index = \r
+\r
+  @param  VmPtr             A pointer to VM context.\r
+  @param  CodeOffset        Offset from IP of the location of the 16-bit index\r
+                            to decode.\r
+\r
+  @return The decoded offset.\r
+\r
+**/\r
 STATIC\r
 INT16\r
 VmReadIndex16 (\r
@@ -49,6 +71,16 @@ VmReadIndex16 (
   IN UINT32     CodeOffset\r
   );\r
 \r
+/**\r
+  Decode a 32-bit index to determine the offset.\r
+\r
+  @param  VmPtr             A pointer to VM context.\r
+  @param  CodeOffset        Offset from IP of the location of the 32-bit index\r
+                            to decode.\r
+\r
+  @return Converted index per EBC VM specification.\r
+\r
+**/\r
 STATIC\r
 INT32\r
 VmReadIndex32 (\r
@@ -56,6 +88,16 @@ VmReadIndex32 (
   IN UINT32     CodeOffset\r
   );\r
 \r
+/**\r
+  Decode a 64-bit index to determine the offset.\r
+\r
+  @param  VmPtr             A pointer to VM context.s\r
+  @param  CodeOffset        Offset from IP of the location of the 64-bit index\r
+                            to decode.\r
+\r
+  @return Converted index per EBC VM specification\r
+\r
+**/\r
 STATIC\r
 INT64\r
 VmReadIndex64 (\r
@@ -63,6 +105,15 @@ VmReadIndex64 (
   IN UINT32     CodeOffset\r
   );\r
 \r
+/**\r
+  Reads 8-bit data form the memory address.\r
+\r
+  @param  VmPtr             A pointer to VM context.\r
+  @param  Addr              The memory address.\r
+\r
+  @return The 8-bit value from the memory adress.\r
+\r
+**/\r
 STATIC\r
 UINT8\r
 VmReadMem8 (\r
@@ -70,6 +121,15 @@ VmReadMem8 (
   IN UINTN      Addr\r
   );\r
 \r
+/**\r
+  Reads 16-bit data form the memory address.\r
+\r
+  @param  VmPtr             A pointer to VM context.\r
+  @param  Addr              The memory address.\r
+\r
+  @return The 16-bit value from the memory adress.\r
+\r
+**/\r
 STATIC\r
 UINT16\r
 VmReadMem16 (\r
@@ -77,6 +137,15 @@ VmReadMem16 (
   IN UINTN      Addr\r
   );\r
 \r
+/**\r
+  Reads 32-bit data form the memory address.\r
+\r
+  @param  VmPtr             A pointer to VM context.\r
+  @param  Addr              The memory address.\r
+\r
+  @return The 32-bit value from the memory adress.\r
+\r
+**/\r
 STATIC\r
 UINT32\r
 VmReadMem32 (\r
@@ -84,6 +153,15 @@ VmReadMem32 (
   IN UINTN      Addr\r
   );\r
 \r
+/**\r
+  Reads 64-bit data form the memory address.\r
+\r
+  @param  VmPtr             A pointer to VM context.\r
+  @param  Addr              The memory address.\r
+\r
+  @return The 64-bit value from the memory adress.\r
+\r
+**/\r
 STATIC\r
 UINT64\r
 VmReadMem64 (\r
@@ -91,6 +169,15 @@ VmReadMem64 (
   IN UINTN      Addr\r
   );\r
 \r
+/**\r
+  Read a natural value from memory. May or may not be aligned.\r
+\r
+  @param  VmPtr             current VM context\r
+  @param  Addr              the address to read from\r
+\r
+  @return The natural value at address Addr.\r
+\r
+**/\r
 STATIC\r
 UINTN\r
 VmReadMemN (\r
@@ -98,30 +185,111 @@ VmReadMemN (
   IN UINTN      Addr\r
   );\r
 \r
+/**\r
+  Writes 8-bit data to memory address.\r
+   \r
+  This routine is called by the EBC data\r
+  movement instructions that write to memory. Since these writes\r
+  may be to the stack, which looks like (high address on top) this,\r
+\r
+  [EBC entry point arguments]\r
+  [VM stack]\r
+  [EBC stack]\r
+\r
+  we need to detect all attempts to write to the EBC entry point argument\r
+  stack area and adjust the address (which will initially point into the \r
+  VM stack) to point into the EBC entry point arguments.\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+  @param  Addr              Adddress to write to.\r
+  @param  Data              Value to write to Addr.\r
+\r
+  @retval EFI_SUCCESS       The instruction is executed successfully.  \r
+  @retval Other             Some error occurs when writing data to the address.\r
+\r
+**/\r
 STATIC\r
 EFI_STATUS\r
 VmWriteMem8 (\r
   IN VM_CONTEXT *VmPtr,\r
-  UINTN         Addr,\r
+  IN UINTN      Addr,\r
   IN UINT8      Data\r
   );\r
 \r
+/**\r
+  Writes 16-bit data to memory address.\r
+   \r
+  This routine is called by the EBC data\r
+  movement instructions that write to memory. Since these writes\r
+  may be to the stack, which looks like (high address on top) this,\r
+\r
+  [EBC entry point arguments]\r
+  [VM stack]\r
+  [EBC stack]\r
+\r
+  we need to detect all attempts to write to the EBC entry point argument\r
+  stack area and adjust the address (which will initially point into the \r
+  VM stack) to point into the EBC entry point arguments.\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+  @param  Addr              Adddress to write to.\r
+  @param  Data              Value to write to Addr.\r
+\r
+  @retval EFI_SUCCESS       The instruction is executed successfully.  \r
+  @retval Other             Some error occurs when writing data to the address.\r
+\r
+**/\r
 STATIC\r
 EFI_STATUS\r
 VmWriteMem16 (\r
   IN VM_CONTEXT *VmPtr,\r
-  UINTN         Addr,\r
+  IN UINTN      Addr,\r
   IN UINT16     Data\r
   );\r
 \r
+/**\r
+  Writes 32-bit data to memory address.\r
+   \r
+  This routine is called by the EBC data\r
+  movement instructions that write to memory. Since these writes\r
+  may be to the stack, which looks like (high address on top) this,\r
+\r
+  [EBC entry point arguments]\r
+  [VM stack]\r
+  [EBC stack]\r
+\r
+  we need to detect all attempts to write to the EBC entry point argument\r
+  stack area and adjust the address (which will initially point into the \r
+  VM stack) to point into the EBC entry point arguments.\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+  @param  Addr              Adddress to write to.\r
+  @param  Data              Value to write to Addr.\r
+\r
+  @retval EFI_SUCCESS       The instruction is executed successfully.  \r
+  @retval Other             Some error occurs when writing data to the address.\r
+\r
+**/\r
 STATIC\r
 EFI_STATUS\r
 VmWriteMem32 (\r
   IN VM_CONTEXT *VmPtr,\r
-  UINTN         Addr,\r
+  IN UINTN      Addr,\r
   IN UINT32     Data\r
   );\r
 \r
+/**\r
+  Reads 16-bit unsinged data from the code stream.\r
+\r
+  This routine provides the ability to read raw unsigned data from the code\r
+  stream.\r
+\r
+  @param  VmPtr             A pointer to VM context\r
+  @param  Offset            Offset from current IP to the raw data to read.\r
+\r
+  @return The raw unsigned 16-bit value from the code stream.\r
+\r
+**/\r
 STATIC\r
 UINT16\r
 VmReadCode16 (\r
@@ -129,6 +297,18 @@ VmReadCode16 (
   IN UINT32     Offset\r
   );\r
 \r
+/**\r
+  Reads 32-bit unsinged data from the code stream.\r
+\r
+  This routine provides the ability to read raw unsigned data from the code\r
+  stream.\r
+\r
+  @param  VmPtr             A pointer to VM context\r
+  @param  Offset            Offset from current IP to the raw data to read.\r
+\r
+  @return The raw unsigned 32-bit value from the code stream.\r
+\r
+**/\r
 STATIC\r
 UINT32\r
 VmReadCode32 (\r
@@ -136,6 +316,18 @@ VmReadCode32 (
   IN UINT32     Offset\r
   );\r
 \r
+/**\r
+  Reads 64-bit unsinged data from the code stream.\r
+\r
+  This routine provides the ability to read raw unsigned data from the code\r
+  stream.\r
+\r
+  @param  VmPtr             A pointer to VM context\r
+  @param  Offset            Offset from current IP to the raw data to read.\r
+\r
+  @return The raw unsigned 64-bit value from the code stream.\r
+\r
+**/\r
 STATIC\r
 UINT64\r
 VmReadCode64 (\r
@@ -143,6 +335,20 @@ VmReadCode64 (
   IN UINT32     Offset\r
   );\r
 \r
+/**\r
+  Reads 8-bit immediate value at the offset.\r
+\r
+  This routine is called by the EBC execute\r
+  functions to read EBC immediate values from the code stream.\r
+  Since we can't assume alignment, each tries to read in the biggest\r
+  chunks size available, but will revert to smaller reads if necessary.\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+  @param  Offset            offset from IP of the code bytes to read.\r
+\r
+  @return Signed data of the requested size from the specified address.\r
+\r
+**/\r
 STATIC\r
 INT8\r
 VmReadImmed8 (\r
@@ -150,6 +356,20 @@ VmReadImmed8 (
   IN UINT32     Offset\r
   );\r
 \r
+/**\r
+  Reads 16-bit immediate value at the offset.\r
+\r
+  This routine is called by the EBC execute\r
+  functions to read EBC immediate values from the code stream.\r
+  Since we can't assume alignment, each tries to read in the biggest\r
+  chunks size available, but will revert to smaller reads if necessary.\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+  @param  Offset            offset from IP of the code bytes to read.\r
+\r
+  @return Signed data of the requested size from the specified address.\r
+\r
+**/\r
 STATIC\r
 INT16\r
 VmReadImmed16 (\r
@@ -157,6 +377,20 @@ VmReadImmed16 (
   IN UINT32     Offset\r
   );\r
 \r
+/**\r
+  Reads 32-bit immediate value at the offset.\r
+\r
+  This routine is called by the EBC execute\r
+  functions to read EBC immediate values from the code stream.\r
+  Since we can't assume alignment, each tries to read in the biggest\r
+  chunks size available, but will revert to smaller reads if necessary.\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+  @param  Offset            offset from IP of the code bytes to read.\r
+\r
+  @return Signed data of the requested size from the specified address.\r
+\r
+**/\r
 STATIC\r
 INT32\r
 VmReadImmed32 (\r
@@ -164,6 +398,20 @@ VmReadImmed32 (
   IN UINT32     Offset\r
   );\r
 \r
+/**\r
+  Reads 64-bit immediate value at the offset.\r
+\r
+  This routine is called by the EBC execute\r
+  functions to read EBC immediate values from the code stream.\r
+  Since we can't assume alignment, each tries to read in the biggest\r
+  chunks size available, but will revert to smaller reads if necessary.\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+  @param  Offset            offset from IP of the code bytes to read.\r
+\r
+  @return Signed data of the requested size from the specified address.\r
+\r
+**/\r
 STATIC\r
 INT64\r
 VmReadImmed64 (\r
@@ -171,6 +419,25 @@ VmReadImmed64 (
   IN UINT32     Offset\r
   );\r
 \r
+/**\r
+  Given an address that EBC is going to read from or write to, return\r
+  an appropriate address that accounts for a gap in the stack.\r
+  The stack for this application looks like this (high addr on top)\r
+  [EBC entry point arguments]\r
+  [VM stack]\r
+  [EBC stack]\r
+  The EBC assumes that its arguments are at the top of its stack, which\r
+  is where the VM stack is really. Therefore if the EBC does memory\r
+  accesses into the VM stack area, then we need to convert the address\r
+  to point to the EBC entry point arguments area. Do this here.\r
+\r
+  @param  VmPtr             A Pointer to VM context.\r
+  @param  Addr              Address of interest\r
+\r
+  @return The unchanged address if it's not in the VM stack region. Otherwise,\r
+          adjust for the stack gap and return the modified address.\r
+\r
+**/\r
 STATIC\r
 UINTN\r
 ConvertStackAddr (\r
@@ -178,136 +445,459 @@ ConvertStackAddr (
   IN UINTN        Addr\r
   );\r
 \r
+/**\r
+  Execute all the EBC data manipulation instructions.\r
+  Since the EBC data manipulation instructions all have the same basic form,\r
+  they can share the code that does the fetch of operands and the write-back\r
+  of the result. This function performs the fetch of the operands (even if\r
+  both are not needed to be fetched, like NOT instruction), dispatches to the\r
+  appropriate subfunction, then writes back the returned result.\r
+\r
+  Format:\r
+    INSTRUCITON[32|64] {@}R1, {@}R2 {Immed16|Index16}\r
+\r
+  @param  VmPtr             A pointer to VM context.\r
+  @param  IsSignedOp        Indicates whether the operand is signed or not.\r
+\r
+  @retval EFI_UNSUPPORTED   The opcodes/operands is not supported.     \r
+  @retval EFI_SUCCESS       The instruction is executed successfully.\r
+\r
+**/\r
 STATIC\r
 EFI_STATUS\r
 ExecuteDataManip (\r
   IN VM_CONTEXT   *VmPtr,\r
-  IN BOOLEAN      IsSignedOperation\r
+  IN BOOLEAN      IsSignedOp\r
   );\r
 \r
 //\r
 // Functions that execute VM opcodes\r
 //\r
+/**\r
+  Execute the EBC BREAK instruction.\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+\r
+  @retval EFI_SUCCESS       The instruction is executed successfully.\r
+\r
+**/\r
 STATIC\r
 EFI_STATUS\r
 ExecuteBREAK (\r
   IN VM_CONTEXT *VmPtr\r
   );\r
 \r
+/**\r
+  Execute the JMP instruction.\r
+\r
+  Instruction syntax:\r
+    JMP64{cs|cc} Immed64\r
+    JMP32{cs|cc} {@}R1 {Immed32|Index32}\r
+  \r
+  Encoding:\r
+    b0.7 -  immediate data present\r
+    b0.6 -  1 = 64 bit immediate data\r
+            0 = 32 bit immediate data\r
+    b1.7 -  1 = conditional\r
+    b1.6    1 = CS (condition set)\r
+            0 = CC (condition clear)\r
+    b1.4    1 = relative address\r
+            0 = absolute address\r
+    b1.3    1 = operand1 indirect\r
+    b1.2-0  operand 1\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+\r
+  @retval EFI_UNSUPPORTED   The opcodes/operands is not supported.\r
+  @retval EFI_SUCCESS       The instruction is executed successfully.\r
+\r
+**/\r
 STATIC\r
 EFI_STATUS\r
 ExecuteJMP (\r
   IN VM_CONTEXT *VmPtr\r
   );\r
 \r
+/**\r
+  Execute the EBC JMP8 instruction.\r
+\r
+  Instruction syntax:\r
+    JMP8{cs|cc}  Offset/2\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+\r
+  @retval EFI_SUCCESS       The instruction is executed successfully.\r
+\r
+**/\r
 STATIC\r
 EFI_STATUS\r
 ExecuteJMP8 (\r
   IN VM_CONTEXT *VmPtr\r
   );\r
 \r
+/**\r
+  Implements the EBC CALL instruction.\r
+\r
+  Instruction format:\r
+    CALL64 Immed64\r
+    CALL32 {@}R1 {Immed32|Index32}\r
+    CALLEX64 Immed64\r
+    CALLEX16 {@}R1 {Immed32}\r
+\r
+    If Rx == R0, then it's a PC relative call to PC = PC + imm32.\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+\r
+  @retval EFI_SUCCESS       The instruction is executed successfully.\r
+\r
+**/\r
 STATIC\r
 EFI_STATUS\r
 ExecuteCALL (\r
   IN VM_CONTEXT *VmPtr\r
   );\r
 \r
+/**\r
+  Execute the EBC RET instruction.\r
+\r
+  Instruction syntax:\r
+    RET\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+\r
+  @retval EFI_SUCCESS       The instruction is executed successfully.\r
+\r
+**/\r
 STATIC\r
 EFI_STATUS\r
 ExecuteRET (\r
   IN VM_CONTEXT *VmPtr\r
   );\r
 \r
+/**\r
+  Execute the EBC CMP instruction.\r
+\r
+  Instruction syntax:\r
+    CMP[32|64][eq|lte|gte|ulte|ugte] R1, {@}R2 {Index16|Immed16}\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+\r
+  @retval EFI_UNSUPPORTED   The opcodes/operands is not supported.     \r
+  @retval EFI_SUCCESS       The instruction is executed successfully.\r
+\r
+**/\r
 STATIC\r
 EFI_STATUS\r
 ExecuteCMP (\r
   IN VM_CONTEXT *VmPtr\r
   );\r
 \r
+/**\r
+  Execute the EBC CMPI instruction\r
+\r
+  Instruction syntax:\r
+    CMPI[32|64]{w|d}[eq|lte|gte|ulte|ugte] {@}Rx {Index16}, Immed16|Immed32\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+\r
+  @retval EFI_UNSUPPORTED   The opcodes/operands is not supported.     \r
+  @retval EFI_SUCCESS       The instruction is executed successfully.\r
+\r
+**/\r
 STATIC\r
 EFI_STATUS\r
 ExecuteCMPI (\r
   IN VM_CONTEXT *VmPtr\r
   );\r
 \r
+/**\r
+  Execute the MOVxx instructions.\r
+\r
+  Instruction format:\r
+    \r
+    MOV[b|w|d|q|n]{w|d} {@}R1 {Index16|32}, {@}R2 {Index16|32}\r
+    MOVqq {@}R1 {Index64}, {@}R2 {Index64}\r
+  \r
+    Copies contents of [R2] -> [R1], zero extending where required.\r
+  \r
+    First character indicates the size of the move.\r
+    Second character indicates the size of the index(s).\r
+  \r
+    Invalid to have R1 direct with index.\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+\r
+  @retval EFI_UNSUPPORTED   The opcodes/operands is not supported.\r
+  @retval EFI_SUCCESS       The instruction is executed successfully.\r
+\r
+**/\r
 STATIC\r
 EFI_STATUS\r
 ExecuteMOVxx (\r
   IN VM_CONTEXT *VmPtr\r
   );\r
 \r
+/**\r
+  Execute the EBC MOVI.\r
+\r
+  Instruction syntax:\r
+  \r
+    MOVI[b|w|d|q][w|d|q] {@}R1 {Index16}, ImmData16|32|64\r
+  \r
+    First variable character specifies the move size\r
+    Second variable character specifies size of the immediate data\r
+  \r
+    Sign-extend the immediate data to the size of the operation, and zero-extend\r
+    if storing to a register.\r
+  \r
+    Operand1 direct with index/immed is invalid.\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+\r
+  @retval EFI_UNSUPPORTED   The opcodes/operands is not supported.     \r
+  @retval EFI_SUCCESS       The instruction is executed successfully.\r
+\r
+**/\r
 STATIC\r
 EFI_STATUS\r
 ExecuteMOVI (\r
   IN VM_CONTEXT *VmPtr\r
   );\r
 \r
+/**\r
+  Execute the EBC MOV immediate natural. This instruction moves an immediate\r
+  index value into a register or memory location.\r
+\r
+  Instruction syntax:\r
+  \r
+    MOVIn[w|d|q] {@}R1 {Index16}, Index16|32|64\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+\r
+  @retval EFI_UNSUPPORTED   The opcodes/operands is not supported.     \r
+  @retval EFI_SUCCESS       The instruction is executed successfully.\r
+\r
+**/\r
 STATIC\r
 EFI_STATUS\r
 ExecuteMOVIn (\r
   IN VM_CONTEXT *VmPtr\r
   );\r
 \r
+/**\r
+  Execute the EBC MOVREL instruction.\r
+  Dest <- Ip + ImmData\r
+\r
+  Instruction syntax:\r
+  \r
+    MOVREL[w|d|q] {@}R1 {Index16}, ImmData16|32|64\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+\r
+  @retval EFI_UNSUPPORTED   The opcodes/operands is not supported.     \r
+  @retval EFI_SUCCESS       The instruction is executed successfully.\r
+\r
+**/\r
 STATIC\r
 EFI_STATUS\r
 ExecuteMOVREL (\r
   IN VM_CONTEXT *VmPtr\r
   );\r
 \r
+/**\r
+  Execute the EBC PUSHn instruction\r
+\r
+  Instruction syntax:\r
+    PUSHn {@}R1 {Index16|Immed16}\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+\r
+  @retval EFI_SUCCESS       The instruction is executed successfully.\r
+\r
+**/\r
 STATIC\r
 EFI_STATUS\r
 ExecutePUSHn (\r
   IN VM_CONTEXT *VmPtr\r
   );\r
 \r
+/**\r
+  Execute the EBC PUSH instruction.\r
+\r
+  Instruction syntax:\r
+    PUSH[32|64] {@}R1 {Index16|Immed16}\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+\r
+  @retval EFI_SUCCESS       The instruction is executed successfully.\r
+\r
+**/\r
 STATIC\r
 EFI_STATUS\r
 ExecutePUSH (\r
   IN VM_CONTEXT *VmPtr\r
   );\r
 \r
+/**\r
+  Execute the EBC POPn instruction.\r
+\r
+  Instruction syntax:\r
+    POPn {@}R1 {Index16|Immed16}\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+\r
+  @retval EFI_SUCCESS       The instruction is executed successfully.\r
+\r
+**/\r
 STATIC\r
 EFI_STATUS\r
 ExecutePOPn (\r
   IN VM_CONTEXT *VmPtr\r
   );\r
 \r
+/**\r
+  Execute the EBC POP instruction.\r
+\r
+  Instruction syntax:\r
+    POPn {@}R1 {Index16|Immed16}\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+\r
+  @retval EFI_SUCCESS       The instruction is executed successfully.\r
+\r
+**/\r
 STATIC\r
 EFI_STATUS\r
 ExecutePOP (\r
   IN VM_CONTEXT *VmPtr\r
   );\r
 \r
+/**\r
+  Execute all the EBC signed data manipulation instructions.\r
+  Since the EBC data manipulation instructions all have the same basic form,\r
+  they can share the code that does the fetch of operands and the write-back\r
+  of the result. This function performs the fetch of the operands (even if\r
+  both are not needed to be fetched, like NOT instruction), dispatches to the\r
+  appropriate subfunction, then writes back the returned result.\r
+\r
+  Format:\r
+    INSTRUCITON[32|64] {@}R1, {@}R2 {Immed16|Index16}\r
+\r
+  @param  VmPtr             A pointer to VM context.\r
+\r
+  @retval EFI_UNSUPPORTED   The opcodes/operands is not supported.     \r
+  @retval EFI_SUCCESS       The instruction is executed successfully.\r
+\r
+**/\r
 STATIC\r
 EFI_STATUS\r
 ExecuteSignedDataManip (\r
   IN VM_CONTEXT *VmPtr\r
   );\r
 \r
+/**\r
+  Execute all the EBC unsigned data manipulation instructions.\r
+  Since the EBC data manipulation instructions all have the same basic form,\r
+  they can share the code that does the fetch of operands and the write-back\r
+  of the result. This function performs the fetch of the operands (even if\r
+  both are not needed to be fetched, like NOT instruction), dispatches to the\r
+  appropriate subfunction, then writes back the returned result.\r
+\r
+  Format:\r
+    INSTRUCITON[32|64] {@}R1, {@}R2 {Immed16|Index16}\r
+\r
+  @param  VmPtr             A pointer to VM context.\r
+\r
+  @retval EFI_UNSUPPORTED   The opcodes/operands is not supported.     \r
+  @retval EFI_SUCCESS       The instruction is executed successfully.\r
+\r
+**/\r
 STATIC\r
 EFI_STATUS\r
 ExecuteUnsignedDataManip (\r
   IN VM_CONTEXT *VmPtr\r
   );\r
 \r
+/**\r
+  Execute the EBC LOADSP instruction.\r
+\r
+  Instruction syntax:\r
+    LOADSP  SP1, R2\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+\r
+  @retval EFI_UNSUPPORTED   The opcodes/operands is not supported.     \r
+  @retval EFI_SUCCESS       The instruction is executed successfully.\r
+\r
+**/\r
 STATIC\r
 EFI_STATUS\r
 ExecuteLOADSP (\r
   IN VM_CONTEXT *VmPtr\r
   );\r
 \r
+/**\r
+  Execute the EBC STORESP instruction.\r
+\r
+  Instruction syntax:\r
+    STORESP  Rx, FLAGS|IP\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+\r
+  @retval EFI_UNSUPPORTED   The opcodes/operands is not supported.     \r
+  @retval EFI_SUCCESS       The instruction is executed successfully.\r
+\r
+**/\r
 STATIC\r
 EFI_STATUS\r
 ExecuteSTORESP (\r
   IN VM_CONTEXT *VmPtr\r
   );\r
 \r
+/**\r
+  Execute the EBC MOVsnw instruction. This instruction loads a signed\r
+  natural value from memory or register to another memory or register. On\r
+  32-bit machines, the value gets sign-extended to 64 bits if the destination\r
+  is a register.\r
+\r
+  Instruction syntax:\r
+  \r
+    MOVsnd {@}R1 {Indx32}, {@}R2 {Index32|Immed32}\r
+  \r
+    0:7 1=>operand1 index present\r
+    0:6 1=>operand2 index present\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+\r
+  @retval EFI_UNSUPPORTED   The opcodes/operands is not supported.     \r
+  @retval EFI_SUCCESS       The instruction is executed successfully.\r
+\r
+**/\r
 STATIC\r
 EFI_STATUS\r
 ExecuteMOVsnd (\r
   IN VM_CONTEXT *VmPtr\r
   );\r
 \r
+/**\r
+  Execute the EBC MOVsnw instruction. This instruction loads a signed\r
+  natural value from memory or register to another memory or register. On\r
+  32-bit machines, the value gets sign-extended to 64 bits if the destination\r
+  is a register.\r
+\r
+  Instruction syntax:\r
+  \r
+    MOVsnw {@}R1 {Index16}, {@}R2 {Index16|Immed16}\r
+  \r
+    0:7 1=>operand1 index present\r
+    0:6 1=>operand2 index present\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+\r
+  @retval EFI_UNSUPPORTED   The opcodes/operands is not supported.     \r
+  @retval EFI_SUCCESS       The instruction is executed successfully.\r
+\r
+**/\r
 STATIC\r
 EFI_STATUS\r
 ExecuteMOVsnw (\r
@@ -317,6 +907,19 @@ ExecuteMOVsnw (
 //\r
 // Data manipulation subfunctions\r
 //\r
+/**\r
+  Execute the EBC NOT instruction.s\r
+\r
+  Instruction syntax:\r
+    NOT[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+  @param  Op1               Operand 1 from the instruction\r
+  @param  Op2               Operand 2 from the instruction\r
+\r
+  @return ~Op2\r
+\r
+**/\r
 STATIC\r
 UINT64\r
 ExecuteNOT (\r
@@ -325,6 +928,19 @@ ExecuteNOT (
   IN UINT64     Op2\r
   );\r
 \r
+/**\r
+  Execute the EBC NEG instruction.\r
+\r
+  Instruction syntax:\r
+    NEG[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+  @param  Op1               Operand 1 from the instruction\r
+  @param  Op2               Operand 2 from the instruction\r
+\r
+  @return Op2 * -1\r
+\r
+**/\r
 STATIC\r
 UINT64\r
 ExecuteNEG (\r
@@ -333,6 +949,19 @@ ExecuteNEG (
   IN UINT64     Op2\r
   );\r
 \r
+/**\r
+  Execute the EBC ADD instruction.\r
+\r
+  Instruction syntax:\r
+    ADD[32|64] {@}R1, {@}R2 {Index16}\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+  @param  Op1               Operand 1 from the instruction\r
+  @param  Op2               Operand 2 from the instruction\r
+\r
+  @return Op1 + Op2\r
+\r
+**/\r
 STATIC\r
 UINT64\r
 ExecuteADD (\r
@@ -341,6 +970,19 @@ ExecuteADD (
   IN UINT64     Op2\r
   );\r
 \r
+/**\r
+  Execute the EBC SUB instruction.\r
+\r
+  Instruction syntax:\r
+    SUB[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+  @param  Op1               Operand 1 from the instruction\r
+  @param  Op2               Operand 2 from the instruction\r
+\r
+  @return Op1 - Op2\r
+\r
+**/\r
 STATIC\r
 UINT64\r
 ExecuteSUB (\r
@@ -349,6 +991,19 @@ ExecuteSUB (
   IN UINT64     Op2\r
   );\r
 \r
+/**\r
+  Execute the EBC MUL instruction.\r
+\r
+  Instruction syntax:\r
+    SUB[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+  @param  Op1               Operand 1 from the instruction\r
+  @param  Op2               Operand 2 from the instruction\r
+\r
+  @return Op1 * Op2\r
+\r
+**/\r
 STATIC\r
 UINT64\r
 ExecuteMUL (\r
@@ -357,6 +1012,19 @@ ExecuteMUL (
   IN UINT64     Op2\r
   );\r
 \r
+/**\r
+  Execute the EBC MULU instruction\r
+\r
+  Instruction syntax:\r
+    MULU[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+  @param  Op1               Operand 1 from the instruction\r
+  @param  Op2               Operand 2 from the instruction\r
+\r
+  @return (unsigned)Op1 * (unsigned)Op2\r
+\r
+**/\r
 STATIC\r
 UINT64\r
 ExecuteMULU (\r
@@ -365,6 +1033,19 @@ ExecuteMULU (
   IN UINT64     Op2\r
   );\r
 \r
+/**\r
+  Execute the EBC DIV instruction.\r
+\r
+  Instruction syntax:\r
+    DIV[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+  @param  Op1               Operand 1 from the instruction\r
+  @param  Op2               Operand 2 from the instruction\r
+\r
+  @return Op1 / Op2\r
+\r
+**/\r
 STATIC\r
 UINT64\r
 ExecuteDIV (\r
@@ -373,6 +1054,19 @@ ExecuteDIV (
   IN UINT64     Op2\r
   );\r
 \r
+/**\r
+  Execute the EBC DIVU instruction\r
+\r
+  Instruction syntax:\r
+    DIVU[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+  @param  Op1               Operand 1 from the instruction\r
+  @param  Op2               Operand 2 from the instruction\r
+\r
+  @return (unsigned)Op1 / (unsigned)Op2\r
+\r
+**/\r
 STATIC\r
 UINT64\r
 ExecuteDIVU (\r
@@ -381,6 +1075,19 @@ ExecuteDIVU (
   IN UINT64     Op2\r
   );\r
 \r
+/**\r
+  Execute the EBC MOD instruction.\r
+\r
+  Instruction syntax:\r
+    MOD[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+  @param  Op1               Operand 1 from the instruction\r
+  @param  Op2               Operand 2 from the instruction\r
+\r
+  @return Op1 MODULUS Op2\r
+\r
+**/\r
 STATIC\r
 UINT64\r
 ExecuteMOD (\r
@@ -389,6 +1096,19 @@ ExecuteMOD (
   IN UINT64     Op2\r
   );\r
 \r
+/**\r
+  Execute the EBC MODU instruction.\r
+\r
+  Instruction syntax:\r
+    MODU[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+  @param  Op1               Operand 1 from the instruction\r
+  @param  Op2               Operand 2 from the instruction\r
+\r
+  @return Op1 UNSIGNED_MODULUS Op2\r
+\r
+**/\r
 STATIC\r
 UINT64\r
 ExecuteMODU (\r
@@ -397,6 +1117,19 @@ ExecuteMODU (
   IN UINT64     Op2\r
   );\r
 \r
+/**\r
+  Execute the EBC AND instruction.\r
+\r
+  Instruction syntax:\r
+    AND[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+  @param  Op1               Operand 1 from the instruction\r
+  @param  Op2               Operand 2 from the instruction\r
+\r
+  @return Op1 AND Op2\r
+\r
+**/\r
 STATIC\r
 UINT64\r
 ExecuteAND (\r
@@ -405,6 +1138,19 @@ ExecuteAND (
   IN UINT64     Op2\r
   );\r
 \r
+/**\r
+  Execute the EBC OR instruction.\r
+\r
+  Instruction syntax:\r
+    OR[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+  @param  Op1               Operand 1 from the instruction\r
+  @param  Op2               Operand 2 from the instruction\r
+\r
+  @return Op1 OR Op2\r
+\r
+**/\r
 STATIC\r
 UINT64\r
 ExecuteOR (\r
@@ -413,6 +1159,19 @@ ExecuteOR (
   IN UINT64     Op2\r
   );\r
 \r
+/**\r
+  Execute the EBC XOR instruction.\r
+\r
+  Instruction syntax:\r
+    XOR[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+  @param  Op1               Operand 1 from the instruction\r
+  @param  Op2               Operand 2 from the instruction\r
+\r
+  @return Op1 XOR Op2\r
+\r
+**/\r
 STATIC\r
 UINT64\r
 ExecuteXOR (\r
@@ -421,6 +1180,19 @@ ExecuteXOR (
   IN UINT64     Op2\r
   );\r
 \r
+/**\r
+  Execute the EBC SHL shift left instruction.\r
+\r
+  Instruction syntax:\r
+    SHL[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+  @param  Op1               Operand 1 from the instruction\r
+  @param  Op2               Operand 2 from the instruction\r
+\r
+  @return Op1 << Op2\r
+\r
+**/\r
 STATIC\r
 UINT64\r
 ExecuteSHL (\r
@@ -429,6 +1201,19 @@ ExecuteSHL (
   IN UINT64     Op2\r
   );\r
 \r
+/**\r
+  Execute the EBC SHR instruction.\r
+\r
+  Instruction syntax:\r
+    SHR[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+  @param  Op1               Operand 1 from the instruction\r
+  @param  Op2               Operand 2 from the instruction\r
+\r
+  @return Op1 >> Op2  (unsigned operands)\r
+\r
+**/\r
 STATIC\r
 UINT64\r
 ExecuteSHR (\r
@@ -437,6 +1222,19 @@ ExecuteSHR (
   IN UINT64     Op2\r
   );\r
 \r
+/**\r
+  Execute the EBC ASHR instruction.\r
+\r
+  Instruction syntax:\r
+    ASHR[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+  @param  Op1               Operand 1 from the instruction\r
+  @param  Op2               Operand 2 from the instruction\r
+\r
+  @return Op1 >> Op2 (signed)\r
+\r
+**/\r
 STATIC\r
 UINT64\r
 ExecuteASHR (\r
@@ -445,6 +1243,19 @@ ExecuteASHR (
   IN UINT64     Op2\r
   );\r
 \r
+/**\r
+  Execute the EBC EXTNDB instruction to sign-extend a byte value.\r
+\r
+  Instruction syntax:\r
+    EXTNDB[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+  @param  Op1               Operand 1 from the instruction\r
+  @param  Op2               Operand 2 from the instruction\r
+\r
+  @return (INT64)(INT8)Op2\r
+\r
+**/\r
 STATIC\r
 UINT64\r
 ExecuteEXTNDB (\r
@@ -453,6 +1264,19 @@ ExecuteEXTNDB (
   IN UINT64     Op2\r
   );\r
 \r
+/**\r
+  Execute the EBC EXTNDW instruction to sign-extend a 16-bit value.\r
+\r
+  Instruction syntax:\r
+    EXTNDW[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+  @param  Op1               Operand 1 from the instruction\r
+  @param  Op2               Operand 2 from the instruction\r
+\r
+  @return (INT64)(INT16)Op2\r
+\r
+**/\r
 STATIC\r
 UINT64\r
 ExecuteEXTNDW (\r
@@ -461,6 +1285,19 @@ ExecuteEXTNDW (
   IN UINT64     Op2\r
   );\r
 \r
+/**\r
+  Execute the EBC EXTNDD instruction to sign-extend a 32-bit value.\r
+\r
+  Instruction syntax:\r
+    EXTNDD[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+  @param  Op1               Operand 1 from the instruction\r
+  @param  Op2               Operand 2 from the instruction\r
+\r
+  @return (INT64)(INT32)Op2\r
+\r
+**/\r
 STATIC\r
 UINT64\r
 ExecuteEXTNDD (\r
@@ -473,7 +1310,7 @@ ExecuteEXTNDD (
 // Once we retrieve the operands for the data manipulation instructions,\r
 // call these functions to perform the operation.\r
 //\r
-static CONST DATA_MANIP_EXEC_FUNCTION mDataManipDispatchTable[] = {\r
+STATIC CONST DATA_MANIP_EXEC_FUNCTION mDataManipDispatchTable[] = {\r
   ExecuteNOT,\r
   ExecuteNEG,\r
   ExecuteADD,\r
@@ -495,7 +1332,7 @@ static CONST DATA_MANIP_EXEC_FUNCTION mDataManipDispatchTable[] = {
   ExecuteEXTNDD,\r
 };\r
 \r
-static CONST VM_TABLE_ENTRY           mVmOpcodeTable[] = {\r
+STATIC CONST VM_TABLE_ENTRY           mVmOpcodeTable[] = {\r
   { ExecuteBREAK },             // opcode 0x00\r
   { ExecuteJMP },               // opcode 0x01\r
   { ExecuteJMP8 },              // opcode 0x02\r
@@ -559,7 +1396,7 @@ static CONST VM_TABLE_ENTRY           mVmOpcodeTable[] = {
 //\r
 // Length of JMP instructions, depending on upper two bits of opcode.\r
 //\r
-static CONST UINT8                    mJMPLen[] = { 2, 2, 6, 10 };\r
+STATIC CONST UINT8                    mJMPLen[] = { 2, 2, 6, 10 };\r
 \r
 //\r
 // Simple Debugger Protocol GUID\r
@@ -571,12 +1408,14 @@ EFI_GUID mEbcSimpleDebuggerProtocolGuid = EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL_GUID;
   Given a pointer to a new VM context, execute one or more instructions. This\r
   function is only used for test purposes via the EBC VM test protocol.\r
 \r
-  @param  This              pointer to protocol interface\r
-  @param  VmPtr             pointer to a VM context\r
-  @param  InstructionCount  how many instructions to execute. 0 if don't count.\r
+  @param  This              A pointer to the EFI_EBC_VM_TEST_PROTOCOL structure.\r
+  @param  VmPtr             A pointer to a VM context.\r
+  @param  InstructionCount  A pointer to a UINTN value holding the number of\r
+                            instructions to execute. If it holds value of 0,\r
+                            then the instruction to be executed is 1.\r
 \r
-  @return EFI_UNSUPPORTED\r
-  @return EFI_SUCCESS\r
+  @retval EFI_UNSUPPORTED   At least one of the opcodes is not supported.\r
+  @retval EFI_SUCCESS       All of the instructions are executed successfully.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -632,9 +1471,10 @@ EbcExecuteInstructions (
 /**\r
   Execute an EBC image from an entry point or from a published protocol.\r
 \r
-  @param  VmPtr             pointer to prepared VM context.\r
+  @param  VmPtr             A pointer to a VM context.\r
 \r
-  @return Standard EBC status.\r
+  @retval EFI_UNSUPPORTED   At least one of the opcodes is not supported.\r
+  @retval EFI_SUCCESS       All of the instructions are executed successfully.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -755,17 +1595,22 @@ Done:
 /**\r
   Execute the MOVxx instructions.\r
 \r
-  @param  VmPtr             pointer to a VM context.\r
-\r
-  @return EFI_UNSUPPORTED\r
-  @return EFI_SUCCESS\r
-  @return Instruction format:\r
-  @return MOV[b|w|d|q|n]{w|d} {@}R1 {Index16|32}, {@}R2 {Index16|32}\r
-  @return MOVqq {@}R1 {Index64}, {@}R2 {Index64}\r
-  @return Copies contents of [R2] -> [R1], zero extending where required.\r
-  @return First character indicates the size of the move.\r
-  @return Second character indicates the size of the index(s).\r
-  @return Invalid to have R1 direct with index.\r
+  Instruction format:\r
+    \r
+    MOV[b|w|d|q|n]{w|d} {@}R1 {Index16|32}, {@}R2 {Index16|32}\r
+    MOVqq {@}R1 {Index64}, {@}R2 {Index64}\r
+  \r
+    Copies contents of [R2] -> [R1], zero extending where required.\r
+  \r
+    First character indicates the size of the move.\r
+    Second character indicates the size of the index(s).\r
+  \r
+    Invalid to have R1 direct with index.\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+\r
+  @retval EFI_UNSUPPORTED   The opcodes/operands is not supported.\r
+  @retval EFI_SUCCESS       The instruction is executed successfully.\r
 \r
 **/\r
 STATIC\r
@@ -1031,12 +1876,11 @@ ExecuteMOVxx (
 \r
 \r
 /**\r
-  Execute the EBC BREAK instruction\r
+  Execute the EBC BREAK instruction.\r
 \r
-  @param  VmPtr             pointer to current VM context\r
+  @param  VmPtr             A pointer to a VM context.\r
 \r
-  @return EFI_UNSUPPORTED\r
-  @return EFI_SUCCESS\r
+  @retval EFI_SUCCESS       The instruction is executed successfully.\r
 \r
 **/\r
 STATIC\r
@@ -1141,21 +1985,28 @@ ExecuteBREAK (
 \r
 \r
 /**\r
-  Execute the JMP instruction\r
-\r
-  @param  VmPtr             pointer to VM context\r
-\r
-  @return Standard EFI_STATUS\r
-  @return Instruction syntax:\r
-  @return JMP64{cs|cc} Immed64\r
-  @return JMP32{cs|cc} {@}R1 {Immed32|Index32}\r
-  @return Encoding:\r
-  @retval b0.7              immediate data present\r
-  @retval b0.6              1 = 64 bit immediate data 0 = 32 bit immediate data\r
-  @retval b1.7              1 = conditional b1.6    1 = CS (condition set) 0 = CC\r
-                            (condition clear) b1.4    1 = relative address 0 =\r
-                            absolute address b1.3    1 = operand1 indirect b1.2-0\r
-                            operand 1\r
+  Execute the JMP instruction.\r
+\r
+  Instruction syntax:\r
+    JMP64{cs|cc} Immed64\r
+    JMP32{cs|cc} {@}R1 {Immed32|Index32}\r
+  \r
+  Encoding:\r
+    b0.7 -  immediate data present\r
+    b0.6 -  1 = 64 bit immediate data\r
+            0 = 32 bit immediate data\r
+    b1.7 -  1 = conditional\r
+    b1.6    1 = CS (condition set)\r
+            0 = CC (condition clear)\r
+    b1.4    1 = relative address\r
+            0 = absolute address\r
+    b1.3    1 = operand1 indirect\r
+    b1.2-0  operand 1\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+\r
+  @retval EFI_UNSUPPORTED   The opcodes/operands is not supported.\r
+  @retval EFI_SUCCESS       The instruction is executed successfully.\r
 \r
 **/\r
 STATIC\r
@@ -1311,13 +2162,14 @@ ExecuteJMP (
 \r
 \r
 /**\r
-  Execute the EBC JMP8 instruction\r
+  Execute the EBC JMP8 instruction.\r
 \r
-  @param  VmPtr             pointer to a VM context\r
+  Instruction syntax:\r
+    JMP8{cs|cc}  Offset/2\r
 \r
-  @return Standard EFI_STATUS\r
-  @return Instruction syntax:\r
-  @return JMP8{cs|cc}  Offset/2\r
+  @param  VmPtr             A pointer to a VM context.\r
+\r
+  @retval EFI_SUCCESS       The instruction is executed successfully.\r
 \r
 **/\r
 STATIC\r
@@ -1361,18 +2213,24 @@ ExecuteJMP8 (
 \r
 \r
 /**\r
-  Execute the EBC MOVI\r
+  Execute the EBC MOVI.\r
+\r
+  Instruction syntax:\r
+  \r
+    MOVI[b|w|d|q][w|d|q] {@}R1 {Index16}, ImmData16|32|64\r
+  \r
+    First variable character specifies the move size\r
+    Second variable character specifies size of the immediate data\r
+  \r
+    Sign-extend the immediate data to the size of the operation, and zero-extend\r
+    if storing to a register.\r
+  \r
+    Operand1 direct with index/immed is invalid.\r
 \r
-  @param  VmPtr             pointer to a VM context\r
+  @param  VmPtr             A pointer to a VM context.\r
 \r
-  @return Standard EFI_STATUS\r
-  @return Instruction syntax:\r
-  @return MOVI[b|w|d|q][w|d|q] {@}R1 {Index16}, ImmData16|32|64\r
-  @return First variable character specifies the move size\r
-  @return Second variable character specifies size of the immediate data\r
-  @return Sign-extend the immediate data to the size of the operation, and zero-extend\r
-  @return if storing to a register.\r
-  @return Operand1 direct with index/immed is invalid.\r
+  @retval EFI_UNSUPPORTED   The opcodes/operands is not supported.     \r
+  @retval EFI_SUCCESS       The instruction is executed successfully.\r
 \r
 **/\r
 STATIC\r
@@ -1484,11 +2342,14 @@ ExecuteMOVI (
   Execute the EBC MOV immediate natural. This instruction moves an immediate\r
   index value into a register or memory location.\r
 \r
-  @param  VmPtr             pointer to a VM context\r
+  Instruction syntax:\r
+  \r
+    MOVIn[w|d|q] {@}R1 {Index16}, Index16|32|64\r
 \r
-  @return Standard EFI_STATUS\r
-  @return Instruction syntax:\r
-  @return MOVIn[w|d|q] {@}R1 {Index16}, Index16|32|64\r
+  @param  VmPtr             A pointer to a VM context.\r
+\r
+  @retval EFI_UNSUPPORTED   The opcodes/operands is not supported.     \r
+  @retval EFI_SUCCESS       The instruction is executed successfully.\r
 \r
 **/\r
 STATIC\r
@@ -1584,11 +2445,14 @@ ExecuteMOVIn (
   Execute the EBC MOVREL instruction.\r
   Dest <- Ip + ImmData\r
 \r
-  @param  VmPtr             pointer to a VM context\r
+  Instruction syntax:\r
+  \r
+    MOVREL[w|d|q] {@}R1 {Index16}, ImmData16|32|64\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
 \r
-  @return Standard EFI_STATUS\r
-  @return Instruction syntax:\r
-  @return MOVREL[w|d|q] {@}R1 {Index16}, ImmData16|32|64\r
+  @retval EFI_UNSUPPORTED   The opcodes/operands is not supported.     \r
+  @retval EFI_SUCCESS       The instruction is executed successfully.\r
 \r
 **/\r
 STATIC\r
@@ -1685,13 +2549,17 @@ ExecuteMOVREL (
   32-bit machines, the value gets sign-extended to 64 bits if the destination\r
   is a register.\r
 \r
-  @param  VmPtr             pointer to a VM context\r
+  Instruction syntax:\r
+  \r
+    MOVsnw {@}R1 {Index16}, {@}R2 {Index16|Immed16}\r
+  \r
+    0:7 1=>operand1 index present\r
+    0:6 1=>operand2 index present\r
 \r
-  @return Standard EFI_STATUS\r
-  @return Instruction syntax:\r
-  @return MOVsnw {@}R1 {Index16}, {@}R2 {Index16|Immed16}\r
-  @return 0:7 1=>operand1 index present\r
-  @return 0:6 1=>operand2 index present\r
+  @param  VmPtr             A pointer to a VM context.\r
+\r
+  @retval EFI_UNSUPPORTED   The opcodes/operands is not supported.     \r
+  @retval EFI_SUCCESS       The instruction is executed successfully.\r
 \r
 **/\r
 STATIC\r
@@ -1775,13 +2643,17 @@ ExecuteMOVsnw (
   32-bit machines, the value gets sign-extended to 64 bits if the destination\r
   is a register.\r
 \r
-  @param  VmPtr             pointer to a VM context\r
+  Instruction syntax:\r
+  \r
+    MOVsnd {@}R1 {Indx32}, {@}R2 {Index32|Immed32}\r
+  \r
+    0:7 1=>operand1 index present\r
+    0:6 1=>operand2 index present\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
 \r
-  @return Standard EFI_STATUS\r
-  @return Instruction syntax:\r
-  @return MOVsnd {@}R1 {Indx32}, {@}R2 {Index32|Immed32}\r
-  @return 0:7 1=>operand1 index present\r
-  @return 0:6 1=>operand2 index present\r
+  @retval EFI_UNSUPPORTED   The opcodes/operands is not supported.     \r
+  @retval EFI_SUCCESS       The instruction is executed successfully.\r
 \r
 **/\r
 STATIC\r
@@ -1862,11 +2734,12 @@ ExecuteMOVsnd (
 /**\r
   Execute the EBC PUSHn instruction\r
 \r
-  @param  VmPtr             pointer to a VM context\r
+  Instruction syntax:\r
+    PUSHn {@}R1 {Index16|Immed16}\r
 \r
-  @return Standard EFI_STATUS\r
-  @return Instruction syntax:\r
-  @return PUSHn {@}R1 {Index16|Immed16}\r
+  @param  VmPtr             A pointer to a VM context.\r
+\r
+  @retval EFI_SUCCESS       The instruction is executed successfully.\r
 \r
 **/\r
 STATIC\r
@@ -1919,13 +2792,14 @@ ExecutePUSHn (
 \r
 \r
 /**\r
-  Execute the EBC PUSH instruction\r
+  Execute the EBC PUSH instruction.\r
+\r
+  Instruction syntax:\r
+    PUSH[32|64] {@}R1 {Index16|Immed16}\r
 \r
-  @param  VmPtr             pointer to a VM context\r
+  @param  VmPtr             A pointer to a VM context.\r
 \r
-  @return Standard EFI_STATUS\r
-  @return Instruction syntax:\r
-  @return PUSH[32|64] {@}R1 {Index16|Immed16}\r
+  @retval EFI_SUCCESS       The instruction is executed successfully.\r
 \r
 **/\r
 STATIC\r
@@ -1995,13 +2869,14 @@ ExecutePUSH (
 \r
 \r
 /**\r
-  Execute the EBC POPn instruction\r
+  Execute the EBC POPn instruction.\r
 \r
-  @param  VmPtr             pointer to a VM context\r
+  Instruction syntax:\r
+    POPn {@}R1 {Index16|Immed16}\r
 \r
-  @return Standard EFI_STATUS\r
-  @return Instruction syntax:\r
-  @return POPn {@}R1 {Index16|Immed16}\r
+  @param  VmPtr             A pointer to a VM context.\r
+\r
+  @retval EFI_SUCCESS       The instruction is executed successfully.\r
 \r
 **/\r
 STATIC\r
@@ -2054,13 +2929,14 @@ ExecutePOPn (
 \r
 \r
 /**\r
-  Execute the EBC POP instruction\r
+  Execute the EBC POP instruction.\r
+\r
+  Instruction syntax:\r
+    POPn {@}R1 {Index16|Immed16}\r
 \r
-  @param  VmPtr             pointer to a VM context\r
+  @param  VmPtr             A pointer to a VM context.\r
 \r
-  @return Standard EFI_STATUS\r
-  @return Instruction syntax:\r
-  @return POP {@}R1 {Index16|Immed16}\r
+  @retval EFI_SUCCESS       The instruction is executed successfully.\r
 \r
 **/\r
 STATIC\r
@@ -2134,16 +3010,18 @@ ExecutePOP (
 \r
 /**\r
   Implements the EBC CALL instruction.\r
+\r
   Instruction format:\r
-  CALL64 Immed64\r
-  CALL32 {@}R1 {Immed32|Index32}\r
-  CALLEX64 Immed64\r
-  CALLEX16 {@}R1 {Immed32}\r
-  If Rx == R0, then it's a PC relative call to PC = PC + imm32.\r
+    CALL64 Immed64\r
+    CALL32 {@}R1 {Immed32|Index32}\r
+    CALLEX64 Immed64\r
+    CALLEX16 {@}R1 {Immed32}\r
+\r
+    If Rx == R0, then it's a PC relative call to PC = PC + imm32.\r
 \r
-  @param  VmPtr             pointer to a VM context.\r
+  @param  VmPtr             pointer to a VM context.\r
 \r
-  @return Standard EFI_STATUS\r
+  @retval EFI_SUCCESS       The instruction is executed successfully.\r
 \r
 **/\r
 STATIC\r
@@ -2270,13 +3148,14 @@ ExecuteCALL (
 \r
 \r
 /**\r
-  Execute the EBC RET instruction\r
+  Execute the EBC RET instruction.\r
 \r
-  @param  VmPtr             pointer to a VM context\r
+  Instruction syntax:\r
+    RET\r
 \r
-  @return Standard EFI_STATUS\r
-  @return Instruction syntax:\r
-  @return RET\r
+  @param  VmPtr             A pointer to a VM context.\r
+\r
+  @retval EFI_SUCCESS       The instruction is executed successfully.\r
 \r
 **/\r
 STATIC\r
@@ -2317,13 +3196,15 @@ ExecuteRET (
 \r
 \r
 /**\r
-  Execute the EBC CMP instruction\r
+  Execute the EBC CMP instruction.\r
+\r
+  Instruction syntax:\r
+    CMP[32|64][eq|lte|gte|ulte|ugte] R1, {@}R2 {Index16|Immed16}\r
 \r
-  @param  VmPtr             pointer to a VM context\r
+  @param  VmPtr             A pointer to a VM context.\r
 \r
-  @return Standard EFI_STATUS\r
-  @return Instruction syntax:\r
-  @return CMP[32|64][eq|lte|gte|ulte|ugte] R1, {@}R2 {Index16|Immed16}\r
+  @retval EFI_UNSUPPORTED   The opcodes/operands is not supported.     \r
+  @retval EFI_SUCCESS       The instruction is executed successfully.\r
 \r
 **/\r
 STATIC\r
@@ -2479,11 +3360,13 @@ ExecuteCMP (
 /**\r
   Execute the EBC CMPI instruction\r
 \r
-  @param  VmPtr             pointer to a VM context\r
+  Instruction syntax:\r
+    CMPI[32|64]{w|d}[eq|lte|gte|ulte|ugte] {@}Rx {Index16}, Immed16|Immed32\r
 \r
-  @return Standard EFI_STATUS\r
-  @return Instruction syntax:\r
-  @return CMPI[32|64]{w|d}[eq|lte|gte|ulte|ugte] {@}Rx {Index16}, Immed16|Immed32\r
+  @param  VmPtr             A pointer to a VM context.\r
+\r
+  @retval EFI_UNSUPPORTED   The opcodes/operands is not supported.     \r
+  @retval EFI_SUCCESS       The instruction is executed successfully.\r
 \r
 **/\r
 STATIC\r
@@ -2655,15 +3538,16 @@ ExecuteCMPI (
 \r
 \r
 /**\r
-  Execute the EBC NOT instruction\r
+  Execute the EBC NOT instruction.s\r
+\r
+  Instruction syntax:\r
+    NOT[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
 \r
-  @param  VmPtr             pointer to a VM context\r
+  @param  VmPtr             A pointer to a VM context.\r
   @param  Op1               Operand 1 from the instruction\r
   @param  Op2               Operand 2 from the instruction\r
 \r
   @return ~Op2\r
-  @return Instruction syntax:\r
-  @return NOT[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
 \r
 **/\r
 STATIC\r
@@ -2679,15 +3563,16 @@ ExecuteNOT (
 \r
 \r
 /**\r
-  Execute the EBC NEG instruction\r
+  Execute the EBC NEG instruction.\r
 \r
-  @param  VmPtr             pointer to a VM context\r
+  Instruction syntax:\r
+    NEG[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
   @param  Op1               Operand 1 from the instruction\r
   @param  Op2               Operand 2 from the instruction\r
 \r
   @return Op2 * -1\r
-  @return Instruction syntax:\r
-  @return NEG[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
 \r
 **/\r
 STATIC\r
@@ -2703,15 +3588,16 @@ ExecuteNEG (
 \r
 \r
 /**\r
-  Execute the EBC ADD instruction\r
+  Execute the EBC ADD instruction.\r
+\r
+  Instruction syntax:\r
+    ADD[32|64] {@}R1, {@}R2 {Index16}\r
 \r
-  @param  VmPtr             pointer to a VM context\r
+  @param  VmPtr             A pointer to a VM context.\r
   @param  Op1               Operand 1 from the instruction\r
   @param  Op2               Operand 2 from the instruction\r
 \r
   @return Op1 + Op2\r
-  @return Instruction syntax:\r
-  @return ADD[32|64] {@}R1, {@}R2 {Index16}\r
 \r
 **/\r
 STATIC\r
@@ -2727,15 +3613,16 @@ ExecuteADD (
 \r
 \r
 /**\r
-  Execute the EBC SUB instruction\r
+  Execute the EBC SUB instruction.\r
 \r
-  @param  VmPtr             pointer to a VM context\r
+  Instruction syntax:\r
+    SUB[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
   @param  Op1               Operand 1 from the instruction\r
   @param  Op2               Operand 2 from the instruction\r
 \r
-  @retval Op1               Op2 Standard EFI_STATUS\r
-  @return Instruction syntax:\r
-  @return SUB[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
+  @return Op1 - Op2\r
 \r
 **/\r
 STATIC\r
@@ -2755,15 +3642,16 @@ ExecuteSUB (
 \r
 \r
 /**\r
-  Execute the EBC MUL instruction\r
+  Execute the EBC MUL instruction.\r
+\r
+  Instruction syntax:\r
+    SUB[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
 \r
-  @param  VmPtr             pointer to a VM context\r
+  @param  VmPtr             A pointer to a VM context.\r
   @param  Op1               Operand 1 from the instruction\r
   @param  Op2               Operand 2 from the instruction\r
 \r
   @return Op1 * Op2\r
-  @return Instruction syntax:\r
-  @return MUL[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
 \r
 **/\r
 STATIC\r
@@ -2785,13 +3673,14 @@ ExecuteMUL (
 /**\r
   Execute the EBC MULU instruction\r
 \r
-  @param  VmPtr             pointer to a VM context\r
+  Instruction syntax:\r
+    MULU[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
   @param  Op1               Operand 1 from the instruction\r
   @param  Op2               Operand 2 from the instruction\r
 \r
   @return (unsigned)Op1 * (unsigned)Op2\r
-  @return Instruction syntax:\r
-  @return MULU[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
 \r
 **/\r
 STATIC\r
@@ -2811,15 +3700,16 @@ ExecuteMULU (
 \r
 \r
 /**\r
-  Execute the EBC DIV instruction\r
+  Execute the EBC DIV instruction.\r
+\r
+  Instruction syntax:\r
+    DIV[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
 \r
-  @param  VmPtr             pointer to a VM context\r
+  @param  VmPtr             A pointer to a VM context.\r
   @param  Op1               Operand 1 from the instruction\r
   @param  Op2               Operand 2 from the instruction\r
 \r
-  @return Op1/Op2\r
-  @return Instruction syntax:\r
-  @return DIV[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
+  @return Op1 / Op2\r
 \r
 **/\r
 STATIC\r
@@ -2856,13 +3746,14 @@ ExecuteDIV (
 /**\r
   Execute the EBC DIVU instruction\r
 \r
-  @param  VmPtr             pointer to a VM context\r
+  Instruction syntax:\r
+    DIVU[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
   @param  Op1               Operand 1 from the instruction\r
   @param  Op2               Operand 2 from the instruction\r
 \r
   @return (unsigned)Op1 / (unsigned)Op2\r
-  @return Instruction syntax:\r
-  @return DIVU[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
 \r
 **/\r
 STATIC\r
@@ -2899,15 +3790,16 @@ ExecuteDIVU (
 \r
 \r
 /**\r
-  Execute the EBC MOD instruction\r
+  Execute the EBC MOD instruction.\r
+\r
+  Instruction syntax:\r
+    MOD[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
 \r
-  @param  VmPtr             pointer to a VM context\r
+  @param  VmPtr             A pointer to a VM context.\r
   @param  Op1               Operand 1 from the instruction\r
   @param  Op2               Operand 2 from the instruction\r
 \r
   @return Op1 MODULUS Op2\r
-  @return Instruction syntax:\r
-  @return MOD[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
 \r
 **/\r
 STATIC\r
@@ -2938,15 +3830,16 @@ ExecuteMOD (
 \r
 \r
 /**\r
-  Execute the EBC MODU instruction\r
+  Execute the EBC MODU instruction.\r
 \r
-  @param  VmPtr             pointer to a VM context\r
+  Instruction syntax:\r
+    MODU[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
   @param  Op1               Operand 1 from the instruction\r
   @param  Op2               Operand 2 from the instruction\r
 \r
   @return Op1 UNSIGNED_MODULUS Op2\r
-  @return Instruction syntax:\r
-  @return MODU[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
 \r
 **/\r
 STATIC\r
@@ -2977,15 +3870,16 @@ ExecuteMODU (
 \r
 \r
 /**\r
-  Execute the EBC AND instruction\r
+  Execute the EBC AND instruction.\r
+\r
+  Instruction syntax:\r
+    AND[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
 \r
-  @param  VmPtr             pointer to a VM context\r
+  @param  VmPtr             A pointer to a VM context.\r
   @param  Op1               Operand 1 from the instruction\r
   @param  Op2               Operand 2 from the instruction\r
 \r
   @return Op1 AND Op2\r
-  @return Instruction syntax:\r
-  @return AND[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
 \r
 **/\r
 STATIC\r
@@ -3001,15 +3895,16 @@ ExecuteAND (
 \r
 \r
 /**\r
-  Execute the EBC OR instruction\r
+  Execute the EBC OR instruction.\r
 \r
-  @param  VmPtr             pointer to a VM context\r
+  Instruction syntax:\r
+    OR[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
   @param  Op1               Operand 1 from the instruction\r
   @param  Op2               Operand 2 from the instruction\r
 \r
   @return Op1 OR Op2\r
-  @return Instruction syntax:\r
-  @return OR[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
 \r
 **/\r
 STATIC\r
@@ -3025,15 +3920,16 @@ ExecuteOR (
 \r
 \r
 /**\r
-  Execute the EBC XOR instruction\r
+  Execute the EBC XOR instruction.\r
+\r
+  Instruction syntax:\r
+    XOR[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
 \r
-  @param  VmPtr             pointer to a VM context\r
+  @param  VmPtr             A pointer to a VM context.\r
   @param  Op1               Operand 1 from the instruction\r
   @param  Op2               Operand 2 from the instruction\r
 \r
   @return Op1 XOR Op2\r
-  @return Instruction syntax:\r
-  @return XOR[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
 \r
 **/\r
 STATIC\r
@@ -3049,15 +3945,16 @@ ExecuteXOR (
 \r
 \r
 /**\r
-  Execute the EBC SHL shift left instruction\r
+  Execute the EBC SHL shift left instruction.\r
 \r
-  @param  VmPtr             pointer to a VM context\r
+  Instruction syntax:\r
+    SHL[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
   @param  Op1               Operand 1 from the instruction\r
   @param  Op2               Operand 2 from the instruction\r
 \r
   @return Op1 << Op2\r
-  @return Instruction syntax:\r
-  @return SHL[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
 \r
 **/\r
 STATIC\r
@@ -3077,15 +3974,16 @@ ExecuteSHL (
 \r
 \r
 /**\r
-  Execute the EBC SHR instruction\r
+  Execute the EBC SHR instruction.\r
+\r
+  Instruction syntax:\r
+    SHR[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
 \r
-  @param  VmPtr             pointer to a VM context\r
+  @param  VmPtr             A pointer to a VM context.\r
   @param  Op1               Operand 1 from the instruction\r
   @param  Op2               Operand 2 from the instruction\r
 \r
   @return Op1 >> Op2  (unsigned operands)\r
-  @return Instruction syntax:\r
-  @return SHR[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
 \r
 **/\r
 STATIC\r
@@ -3105,15 +4003,16 @@ ExecuteSHR (
 \r
 \r
 /**\r
-  Execute the EBC ASHR instruction\r
+  Execute the EBC ASHR instruction.\r
 \r
-  @param  VmPtr             pointer to a VM context\r
+  Instruction syntax:\r
+    ASHR[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
   @param  Op1               Operand 1 from the instruction\r
   @param  Op2               Operand 2 from the instruction\r
 \r
   @return Op1 >> Op2 (signed)\r
-  @return Instruction syntax:\r
-  @return ASHR[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
 \r
 **/\r
 STATIC\r
@@ -3135,13 +4034,14 @@ ExecuteASHR (
 /**\r
   Execute the EBC EXTNDB instruction to sign-extend a byte value.\r
 \r
-  @param  VmPtr             pointer to a VM context\r
+  Instruction syntax:\r
+    EXTNDB[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
   @param  Op1               Operand 1 from the instruction\r
   @param  Op2               Operand 2 from the instruction\r
 \r
   @return (INT64)(INT8)Op2\r
-  @return Instruction syntax:\r
-  @return EXTNDB[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
 \r
 **/\r
 STATIC\r
@@ -3168,13 +4068,14 @@ ExecuteEXTNDB (
 /**\r
   Execute the EBC EXTNDW instruction to sign-extend a 16-bit value.\r
 \r
-  @param  VmPtr             pointer to a VM context\r
+  Instruction syntax:\r
+    EXTNDW[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
   @param  Op1               Operand 1 from the instruction\r
   @param  Op2               Operand 2 from the instruction\r
 \r
   @return (INT64)(INT16)Op2\r
-  @return Instruction syntax:\r
-  @return EXTNDW[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
 \r
 **/\r
 STATIC\r
@@ -3208,13 +4109,14 @@ ExecuteEXTNDW (
 /**\r
   Execute the EBC EXTNDD instruction to sign-extend a 32-bit value.\r
 \r
-  @param  VmPtr             pointer to a VM context\r
+  Instruction syntax:\r
+    EXTNDD[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
   @param  Op1               Operand 1 from the instruction\r
   @param  Op2               Operand 2 from the instruction\r
 \r
   @return (INT64)(INT32)Op2\r
-  @return Instruction syntax:\r
-  @return EXTNDD[32|64] {@}R1, {@}R2 {Index16|Immed16}\r
 \r
 **/\r
 STATIC\r
@@ -3237,6 +4139,24 @@ ExecuteEXTNDD (
   return (UINT64) Data64;\r
 }\r
 \r
+\r
+/**\r
+  Execute all the EBC signed data manipulation instructions.\r
+  Since the EBC data manipulation instructions all have the same basic form,\r
+  they can share the code that does the fetch of operands and the write-back\r
+  of the result. This function performs the fetch of the operands (even if\r
+  both are not needed to be fetched, like NOT instruction), dispatches to the\r
+  appropriate subfunction, then writes back the returned result.\r
+\r
+  Format:\r
+    INSTRUCITON[32|64] {@}R1, {@}R2 {Immed16|Index16}\r
+\r
+  @param  VmPtr             A pointer to VM context.\r
+\r
+  @retval EFI_UNSUPPORTED   The opcodes/operands is not supported.     \r
+  @retval EFI_SUCCESS       The instruction is executed successfully.\r
+\r
+**/\r
 STATIC\r
 EFI_STATUS\r
 ExecuteSignedDataManip (\r
@@ -3250,6 +4170,24 @@ ExecuteSignedDataManip (
   return ExecuteDataManip (VmPtr, TRUE);\r
 }\r
 \r
+\r
+/**\r
+  Execute all the EBC unsigned data manipulation instructions.\r
+  Since the EBC data manipulation instructions all have the same basic form,\r
+  they can share the code that does the fetch of operands and the write-back\r
+  of the result. This function performs the fetch of the operands (even if\r
+  both are not needed to be fetched, like NOT instruction), dispatches to the\r
+  appropriate subfunction, then writes back the returned result.\r
+\r
+  Format:\r
+    INSTRUCITON[32|64] {@}R1, {@}R2 {Immed16|Index16}\r
+\r
+  @param  VmPtr             A pointer to VM context.\r
+\r
+  @retval EFI_UNSUPPORTED   The opcodes/operands is not supported.     \r
+  @retval EFI_SUCCESS       The instruction is executed successfully.\r
+\r
+**/\r
 STATIC\r
 EFI_STATUS\r
 ExecuteUnsignedDataManip (\r
@@ -3272,11 +4210,14 @@ ExecuteUnsignedDataManip (
   both are not needed to be fetched, like NOT instruction), dispatches to the\r
   appropriate subfunction, then writes back the returned result.\r
 \r
-  @param  VmPtr             pointer to VM context\r
+  Format:\r
+    INSTRUCITON[32|64] {@}R1, {@}R2 {Immed16|Index16}\r
 \r
-  @return Standard EBC status\r
-  @return Format:\r
-  @return INSTRUCITON[32|64] {@}R1, {@}R2 {Immed16|Index16}\r
+  @param  VmPtr             A pointer to VM context.\r
+  @param  IsSignedOp        Indicates whether the operand is signed or not.\r
+\r
+  @retval EFI_UNSUPPORTED   The opcodes/operands is not supported.     \r
+  @retval EFI_SUCCESS       The instruction is executed successfully.\r
 \r
 **/\r
 STATIC\r
@@ -3418,13 +4359,15 @@ ExecuteDataManip (
 \r
 \r
 /**\r
-  Execute the EBC LOADSP instruction\r
+  Execute the EBC LOADSP instruction.\r
+\r
+  Instruction syntax:\r
+    LOADSP  SP1, R2\r
 \r
-  @param  VmPtr             pointer to a VM context\r
+  @param  VmPtr             A pointer to a VM context.\r
 \r
-  @return Standard EFI_STATUS\r
-  @return Instruction syntax:\r
-  @return LOADSP  SP1, R2\r
+  @retval EFI_UNSUPPORTED   The opcodes/operands is not supported.     \r
+  @retval EFI_SUCCESS       The instruction is executed successfully.\r
 \r
 **/\r
 STATIC\r
@@ -3471,13 +4414,15 @@ ExecuteLOADSP (
 \r
 \r
 /**\r
-  Execute the EBC STORESP instruction\r
+  Execute the EBC STORESP instruction.\r
 \r
-  @param  VmPtr             pointer to a VM context\r
+  Instruction syntax:\r
+    STORESP  Rx, FLAGS|IP\r
 \r
-  @return Standard EFI_STATUS\r
-  @return Instruction syntax:\r
-  @return STORESP  Rx, FLAGS|IP\r
+  @param  VmPtr             A pointer to a VM context.\r
+\r
+  @retval EFI_UNSUPPORTED   The opcodes/operands is not supported.     \r
+  @retval EFI_SUCCESS       The instruction is executed successfully.\r
 \r
 **/\r
 STATIC\r
@@ -3532,19 +4477,22 @@ ExecuteSTORESP (
 \r
 /**\r
   Decode a 16-bit index to determine the offset. Given an index value:\r
-  b15     - sign bit\r
-  b14:12  - number of bits in this index assigned to natural units (=a)\r
-  ba:11   - constant units = C\r
-  b0:a    - natural units = N\r
+\r
+    b15     - sign bit\r
+    b14:12  - number of bits in this index assigned to natural units (=a)\r
+    ba:11   - constant units = ConstUnits\r
+    b0:a    - natural units = NaturalUnits\r
+  \r
   Given this info, the offset can be computed by:\r
-  offset = sign_bit * (C + N * sizeof(UINTN))\r
+    offset = sign_bit * (ConstUnits + NaturalUnits * sizeof(UINTN))\r
+\r
   Max offset is achieved with index = 0x7FFF giving an offset of\r
   0x27B (32-bit machine) or 0x477 (64-bit machine).\r
-  Min offset is achieved with index =\r
+  Min offset is achieved with index = \r
 \r
-  @param  VmPtr             pointer to VM context\r
-  @param  CodeOffset        offset from IP of the location of the 16-bit index to\r
-                            decode\r
+  @param  VmPtr             A pointer to VM context.\r
+  @param  CodeOffset        Offset from IP of the location of the 16-bit index\r
+                            to decode.\r
 \r
   @return The decoded offset.\r
 \r
@@ -3558,8 +4506,8 @@ VmReadIndex16 (
 {\r
   UINT16  Index;\r
   INT16   Offset;\r
-  INT16   C;\r
-  INT16   N;\r
+  INT16   ConstUnits;\r
+  INT16   NaturalUnits;\r
   INT16   NBits;\r
   INT16   Mask;\r
 \r
@@ -3569,7 +4517,7 @@ VmReadIndex16 (
   Index = VmReadCode16 (VmPtr, CodeOffset);\r
 \r
   //\r
-  // Get the mask for N. First get the number of bits from the index.\r
+  // Get the mask for NaturalUnits. First get the number of bits from the index.\r
   //\r
   NBits = (INT16) ((Index & 0x7000) >> 12);\r
 \r
@@ -3584,16 +4532,16 @@ VmReadIndex16 (
   Mask = (INT16) ((INT16)~0 << NBits);\r
 \r
   //\r
-  // Now using the mask, extract N from the lower bits of the index.\r
+  // Now using the mask, extract NaturalUnits from the lower bits of the index.\r
   //\r
-  N = (INT16) (Index &~Mask);\r
+  NaturalUnits = (INT16) (Index &~Mask);\r
 \r
   //\r
-  // Now compute C\r
+  // Now compute ConstUnits\r
   //\r
-  C       = (INT16) (((Index &~0xF000) & Mask) >> NBits);\r
+  ConstUnits       = (INT16) (((Index &~0xF000) & Mask) >> NBits);\r
 \r
-  Offset  = (INT16) (N * sizeof (UINTN) + C);\r
+  Offset  = (INT16) (NaturalUnits * sizeof (UINTN) + ConstUnits);\r
 \r
   //\r
   // Now set the sign\r
@@ -3614,11 +4562,11 @@ VmReadIndex16 (
 /**\r
   Decode a 32-bit index to determine the offset.\r
 \r
-  @param  VmPtr             pointer to VM context\r
-  @param  CodeOffset        offset from IP of the location of the 32-bit index to\r
-                            decode\r
+  @param  VmPtr             A pointer to VM context.\r
+  @param  CodeOffset        Offset from IP of the location of the 32-bit index\r
+                            to decode.\r
 \r
-  @return Converted index per EBC VM specification\r
+  @return Converted index per EBC VM specification.\r
 \r
 **/\r
 STATIC\r
@@ -3630,15 +4578,15 @@ VmReadIndex32 (
 {\r
   UINT32  Index;\r
   INT32   Offset;\r
-  INT32   C;\r
-  INT32   N;\r
+  INT32   ConstUnits;\r
+  INT32   NaturalUnits;\r
   INT32   NBits;\r
   INT32   Mask;\r
 \r
   Index = VmReadImmed32 (VmPtr, CodeOffset);\r
 \r
   //\r
-  // Get the mask for N. First get the number of bits from the index.\r
+  // Get the mask for NaturalUnits. First get the number of bits from the index.\r
   //\r
   NBits = (Index & 0x70000000) >> 28;\r
 \r
@@ -3653,16 +4601,16 @@ VmReadIndex32 (
   Mask = (INT32)~0 << NBits;\r
 \r
   //\r
-  // Now using the mask, extract N from the lower bits of the index.\r
+  // Now using the mask, extract NaturalUnits from the lower bits of the index.\r
   //\r
-  N = Index &~Mask;\r
+  NaturalUnits = Index &~Mask;\r
 \r
   //\r
-  // Now compute C\r
+  // Now compute ConstUnits\r
   //\r
-  C       = ((Index &~0xF0000000) & Mask) >> NBits;\r
+  ConstUnits       = ((Index &~0xF0000000) & Mask) >> NBits;\r
 \r
-  Offset  = N * sizeof (UINTN) + C;\r
+  Offset  = NaturalUnits * sizeof (UINTN) + ConstUnits;\r
 \r
   //\r
   // Now set the sign\r
@@ -3678,9 +4626,9 @@ VmReadIndex32 (
 /**\r
   Decode a 64-bit index to determine the offset.\r
 \r
-  @param  VmPtr             pointer to VM context\r
-  @param  CodeOffset        offset from IP of the location of the 64-bit index to\r
-                            decode\r
+  @param  VmPtr             A pointer to VM context.s\r
+  @param  CodeOffset        Offset from IP of the location of the 64-bit index\r
+                            to decode.\r
 \r
   @return Converted index per EBC VM specification\r
 \r
@@ -3694,15 +4642,15 @@ VmReadIndex64 (
 {\r
   UINT64  Index;\r
   INT64   Offset;\r
-  INT64   C;\r
-  INT64   N;\r
+  INT64   ConstUnits;\r
+  INT64   NaturalUnits;\r
   INT64   NBits;\r
   INT64   Mask;\r
 \r
   Index = VmReadCode64 (VmPtr, CodeOffset);\r
 \r
   //\r
-  // Get the mask for N. First get the number of bits from the index.\r
+  // Get the mask for NaturalUnits. First get the number of bits from the index.\r
   //\r
   NBits = RShiftU64 ((Index & 0x7000000000000000ULL), 60);\r
 \r
@@ -3717,16 +4665,16 @@ VmReadIndex64 (
   Mask = (LShiftU64 ((UINT64)~0, (UINTN)NBits));\r
 \r
   //\r
-  // Now using the mask, extract N from the lower bits of the index.\r
+  // Now using the mask, extract NaturalUnits from the lower bits of the index.\r
   //\r
-  N = Index &~Mask;\r
+  NaturalUnits = Index &~Mask;\r
 \r
   //\r
-  // Now compute C\r
+  // Now compute ConstUnits\r
   //\r
-  C       = ARShiftU64 (((Index &~0xF000000000000000ULL) & Mask), (UINTN)NBits);\r
+  ConstUnits = ARShiftU64 (((Index &~0xF000000000000000ULL) & Mask), (UINTN)NBits);\r
 \r
-  Offset  = MultU64x64 (N, sizeof (UINTN)) + C;\r
+  Offset  = MultU64x64 (NaturalUnits, sizeof (UINTN)) + ConstUnits;\r
 \r
   //\r
   // Now set the sign\r
@@ -3740,21 +4688,26 @@ VmReadIndex64 (
 \r
 \r
 /**\r
-  The following VmWriteMem? routines are called by the EBC data\r
+  Writes 8-bit data to memory address.\r
+   \r
+  This routine is called by the EBC data\r
   movement instructions that write to memory. Since these writes\r
   may be to the stack, which looks like (high address on top) this,\r
+\r
   [EBC entry point arguments]\r
   [VM stack]\r
   [EBC stack]\r
+\r
   we need to detect all attempts to write to the EBC entry point argument\r
-  stack area and adjust the address (which will initially point into the\r
+  stack area and adjust the address (which will initially point into the \r
   VM stack) to point into the EBC entry point arguments.\r
 \r
-  @param  VmPtr             pointer to a VM context\r
-  @param  Addr              adddress to write to\r
-  @param  Data              value to write to Addr\r
+  @param  VmPtr             A pointer to a VM context.\r
+  @param  Addr              Adddress to write to.\r
+  @param  Data              Value to write to Addr.\r
 \r
-  @return Standard EFI_STATUS\r
+  @retval EFI_SUCCESS       The instruction is executed successfully.  \r
+  @retval Other             Some error occurs when writing data to the address.\r
 \r
 **/\r
 STATIC\r
@@ -3773,6 +4726,29 @@ VmWriteMem8 (
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Writes 16-bit data to memory address.\r
+   \r
+  This routine is called by the EBC data\r
+  movement instructions that write to memory. Since these writes\r
+  may be to the stack, which looks like (high address on top) this,\r
+\r
+  [EBC entry point arguments]\r
+  [VM stack]\r
+  [EBC stack]\r
+\r
+  we need to detect all attempts to write to the EBC entry point argument\r
+  stack area and adjust the address (which will initially point into the \r
+  VM stack) to point into the EBC entry point arguments.\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+  @param  Addr              Adddress to write to.\r
+  @param  Data              Value to write to Addr.\r
+\r
+  @retval EFI_SUCCESS       The instruction is executed successfully.  \r
+  @retval Other             Some error occurs when writing data to the address.\r
+\r
+**/\r
 STATIC\r
 EFI_STATUS\r
 VmWriteMem16 (\r
@@ -3813,6 +4789,30 @@ VmWriteMem16 (
   return EFI_SUCCESS;\r
 }\r
 \r
+\r
+/**\r
+  Writes 32-bit data to memory address.\r
+   \r
+  This routine is called by the EBC data\r
+  movement instructions that write to memory. Since these writes\r
+  may be to the stack, which looks like (high address on top) this,\r
+\r
+  [EBC entry point arguments]\r
+  [VM stack]\r
+  [EBC stack]\r
+\r
+  we need to detect all attempts to write to the EBC entry point argument\r
+  stack area and adjust the address (which will initially point into the \r
+  VM stack) to point into the EBC entry point arguments.\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+  @param  Addr              Adddress to write to.\r
+  @param  Data              Value to write to Addr.\r
+\r
+  @retval EFI_SUCCESS       The instruction is executed successfully.  \r
+  @retval Other             Some error occurs when writing data to the address.\r
+\r
+**/\r
 STATIC\r
 EFI_STATUS\r
 VmWriteMem32 (\r
@@ -3853,6 +4853,30 @@ VmWriteMem32 (
   return EFI_SUCCESS;\r
 }\r
 \r
+\r
+/**\r
+  Writes 64-bit data to memory address.\r
+   \r
+  This routine is called by the EBC data\r
+  movement instructions that write to memory. Since these writes\r
+  may be to the stack, which looks like (high address on top) this,\r
+\r
+  [EBC entry point arguments]\r
+  [VM stack]\r
+  [EBC stack]\r
+\r
+  we need to detect all attempts to write to the EBC entry point argument\r
+  stack area and adjust the address (which will initially point into the \r
+  VM stack) to point into the EBC entry point arguments.\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+  @param  Addr              Adddress to write to.\r
+  @param  Data              Value to write to Addr.\r
+\r
+  @retval EFI_SUCCESS       The instruction is executed successfully.  \r
+  @retval Other             Some error occurs when writing data to the address.\r
+\r
+**/\r
 EFI_STATUS\r
 VmWriteMem64 (\r
   IN VM_CONTEXT   *VmPtr,\r
@@ -3894,6 +4918,30 @@ VmWriteMem64 (
   return EFI_SUCCESS;\r
 }\r
 \r
+\r
+/**\r
+  Writes UINTN data to memory address.\r
+   \r
+  This routine is called by the EBC data\r
+  movement instructions that write to memory. Since these writes\r
+  may be to the stack, which looks like (high address on top) this,\r
+\r
+  [EBC entry point arguments]\r
+  [VM stack]\r
+  [EBC stack]\r
+\r
+  we need to detect all attempts to write to the EBC entry point argument\r
+  stack area and adjust the address (which will initially point into the \r
+  VM stack) to point into the EBC entry point arguments.\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+  @param  Addr              Adddress to write to.\r
+  @param  Data              Value to write to Addr.\r
+\r
+  @retval EFI_SUCCESS       The instruction is executed successfully.  \r
+  @retval Other             Some error occurs when writing data to the address.\r
+\r
+**/\r
 EFI_STATUS\r
 VmWriteMemN (\r
   IN VM_CONTEXT   *VmPtr,\r
@@ -3930,12 +4978,14 @@ VmWriteMemN (
 \r
 \r
 /**\r
-  The following VmReadImmed routines are called by the EBC execute\r
+  Reads 8-bit immediate value at the offset.\r
+\r
+  This routine is called by the EBC execute\r
   functions to read EBC immediate values from the code stream.\r
   Since we can't assume alignment, each tries to read in the biggest\r
   chunks size available, but will revert to smaller reads if necessary.\r
 \r
-  @param  VmPtr             pointer to a VM context\r
+  @param  VmPtr             A pointer to a VM context.\r
   @param  Offset            offset from IP of the code bytes to read.\r
 \r
   @return Signed data of the requested size from the specified address.\r
@@ -3954,6 +5004,20 @@ VmReadImmed8 (
   return * (INT8 *) (VmPtr->Ip + Offset);\r
 }\r
 \r
+/**\r
+  Reads 16-bit immediate value at the offset.\r
+\r
+  This routine is called by the EBC execute\r
+  functions to read EBC immediate values from the code stream.\r
+  Since we can't assume alignment, each tries to read in the biggest\r
+  chunks size available, but will revert to smaller reads if necessary.\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+  @param  Offset            offset from IP of the code bytes to read.\r
+\r
+  @return Signed data of the requested size from the specified address.\r
+\r
+**/\r
 STATIC\r
 INT16\r
 VmReadImmed16 (\r
@@ -3982,6 +5046,21 @@ VmReadImmed16 (
   return (INT16) (*(UINT8 *) (VmPtr->Ip + Offset) + (*(UINT8 *) (VmPtr->Ip + Offset + 1) << 8));\r
 }\r
 \r
+\r
+/**\r
+  Reads 32-bit immediate value at the offset.\r
+\r
+  This routine is called by the EBC execute\r
+  functions to read EBC immediate values from the code stream.\r
+  Since we can't assume alignment, each tries to read in the biggest\r
+  chunks size available, but will revert to smaller reads if necessary.\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+  @param  Offset            offset from IP of the code bytes to read.\r
+\r
+  @return Signed data of the requested size from the specified address.\r
+\r
+**/\r
 STATIC\r
 INT32\r
 VmReadImmed32 (\r
@@ -4005,6 +5084,21 @@ VmReadImmed32 (
   return Data;\r
 }\r
 \r
+\r
+/**\r
+  Reads 64-bit immediate value at the offset.\r
+\r
+  This routine is called by the EBC execute\r
+  functions to read EBC immediate values from the code stream.\r
+  Since we can't assume alignment, each tries to read in the biggest\r
+  chunks size available, but will revert to smaller reads if necessary.\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+  @param  Offset            offset from IP of the code bytes to read.\r
+\r
+  @return Signed data of the requested size from the specified address.\r
+\r
+**/\r
 STATIC\r
 INT64\r
 VmReadImmed64 (\r
@@ -4036,11 +5130,13 @@ VmReadImmed64 (
 \r
 \r
 /**\r
-  The following VmReadCode() routines provide the ability to read raw\r
-  unsigned data from the code stream.\r
+  Reads 16-bit unsinged data from the code stream.\r
+\r
+  This routine provides the ability to read raw unsigned data from the code\r
+  stream.\r
 \r
-  @param  VmPtr             pointer to VM context\r
-  @param  Offset            offset from current IP to the raw data to read.\r
+  @param  VmPtr             pointer to VM context\r
+  @param  Offset            Offset from current IP to the raw data to read.\r
 \r
   @return The raw unsigned 16-bit value from the code stream.\r
 \r
@@ -4073,6 +5169,19 @@ VmReadCode16 (
   return (UINT16) (*(UINT8 *) (VmPtr->Ip + Offset) + (*(UINT8 *) (VmPtr->Ip + Offset + 1) << 8));\r
 }\r
 \r
+\r
+/**\r
+  Reads 32-bit unsinged data from the code stream.\r
+\r
+  This routine provides the ability to read raw unsigned data from the code\r
+  stream.\r
+\r
+  @param  VmPtr             A pointer to VM context\r
+  @param  Offset            Offset from current IP to the raw data to read.\r
+\r
+  @return The raw unsigned 32-bit value from the code stream.\r
+\r
+**/\r
 STATIC\r
 UINT32\r
 VmReadCode32 (\r
@@ -4095,6 +5204,19 @@ VmReadCode32 (
   return Data;\r
 }\r
 \r
+\r
+/**\r
+  Reads 64-bit unsinged data from the code stream.\r
+\r
+  This routine provides the ability to read raw unsigned data from the code\r
+  stream.\r
+\r
+  @param  VmPtr             A pointer to VM context\r
+  @param  Offset            Offset from current IP to the raw data to read.\r
+\r
+  @return The raw unsigned 64-bit value from the code stream.\r
+\r
+**/\r
 STATIC\r
 UINT64\r
 VmReadCode64 (\r
@@ -4124,6 +5246,16 @@ VmReadCode64 (
   return Data64;\r
 }\r
 \r
+\r
+/**\r
+  Reads 8-bit data form the memory address.\r
+\r
+  @param  VmPtr             A pointer to VM context.\r
+  @param  Addr              The memory address.\r
+\r
+  @return The 8-bit value from the memory adress.\r
+\r
+**/\r
 STATIC\r
 UINT8\r
 VmReadMem8 (\r
@@ -4141,6 +5273,15 @@ VmReadMem8 (
   return * (UINT8 *) Addr;\r
 }\r
 \r
+/**\r
+  Reads 16-bit data form the memory address.\r
+\r
+  @param  VmPtr             A pointer to VM context.\r
+  @param  Addr              The memory address.\r
+\r
+  @return The 16-bit value from the memory adress.\r
+\r
+**/\r
 STATIC\r
 UINT16\r
 VmReadMem16 (\r
@@ -4164,6 +5305,15 @@ VmReadMem16 (
   return (UINT16) (*(UINT8 *) Addr + (*(UINT8 *) (Addr + 1) << 8));\r
 }\r
 \r
+/**\r
+  Reads 32-bit data form the memory address.\r
+\r
+  @param  VmPtr             A pointer to VM context.\r
+  @param  Addr              The memory address.\r
+\r
+  @return The 32-bit value from the memory adress.\r
+\r
+**/\r
 STATIC\r
 UINT32\r
 VmReadMem32 (\r
@@ -4191,6 +5341,15 @@ VmReadMem32 (
   return Data;\r
 }\r
 \r
+/**\r
+  Reads 64-bit data form the memory address.\r
+\r
+  @param  VmPtr             A pointer to VM context.\r
+  @param  Addr              The memory address.\r
+\r
+  @return The 64-bit value from the memory adress.\r
+\r
+**/\r
 STATIC\r
 UINT64\r
 VmReadMem64 (\r
@@ -4234,11 +5393,11 @@ VmReadMem64 (
   accesses into the VM stack area, then we need to convert the address\r
   to point to the EBC entry point arguments area. Do this here.\r
 \r
-  @param  VmPtr             pointer to VM context\r
-  @param  Addr              address of interest\r
+  @param  VmPtr             A Pointer to VM context.\r
+  @param  Addr              Address of interest\r
 \r
   @return The unchanged address if it's not in the VM stack region. Otherwise,\r
-  @return adjust for the stack gap and return the modified address.\r
+          adjust for the stack gap and return the modified address.\r
 \r
 **/\r
 STATIC\r
@@ -4299,6 +5458,12 @@ VmReadMemN (
   return Data;\r
 }\r
 \r
+/**\r
+  Returns the version of the EBC virtual machine.\r
+    \r
+  @return The 64-bit version of EBC virtual machine.\r
+\r
+**/\r
 UINT64\r
 GetVmVersion (\r
   VOID\r
index 91aada0d5551bc67cb73746154643363ad93b6a4..13eea0c9dc24876fc99504d6ba4b1bc3c3556d39 100644 (file)
@@ -227,6 +227,15 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #define OPCODE_MOVIN  0x38\r
 #define OPCODE_MOVREL 0x39\r
 \r
+/**\r
+  Execute an EBC image from an entry point or from a published protocol.\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+\r
+  @retval EFI_UNSUPPORTED   At least one of the opcodes is not supported.\r
+  @retval EFI_SUCCESS       All of the instructions are executed successfully.\r
+\r
+**/\r
 EFI_STATUS\r
 EbcExecute (\r
   IN VM_CONTEXT *VmPtr\r
@@ -235,12 +244,41 @@ EbcExecute (
 \r
 \r
 \r
+/**\r
+  Returns the version of the EBC virtual machine.\r
+    \r
+  @return The 64-bit version of EBC virtual machine.\r
+\r
+**/\r
 UINT64\r
 GetVmVersion (\r
   VOID\r
   )\r
 ;\r
 \r
+/**\r
+  Writes UINTN data to memory address.\r
+   \r
+  This routine is called by the EBC data\r
+  movement instructions that write to memory. Since these writes\r
+  may be to the stack, which looks like (high address on top) this,\r
+\r
+  [EBC entry point arguments]\r
+  [VM stack]\r
+  [EBC stack]\r
+\r
+  we need to detect all attempts to write to the EBC entry point argument\r
+  stack area and adjust the address (which will initially point into the \r
+  VM stack) to point into the EBC entry point arguments.\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+  @param  Addr              Adddress to write to.\r
+  @param  Data              Value to write to Addr.\r
+\r
+  @retval EFI_SUCCESS       The instruction is executed successfully.  \r
+  @retval Other             Some error occurs when writing data to the address.\r
+\r
+**/\r
 EFI_STATUS\r
 VmWriteMemN (\r
   IN VM_CONTEXT   *VmPtr,\r
@@ -249,6 +287,29 @@ VmWriteMemN (
   )\r
 ;\r
 \r
+/**\r
+  Writes 64-bit data to memory address.\r
+   \r
+  This routine is called by the EBC data\r
+  movement instructions that write to memory. Since these writes\r
+  may be to the stack, which looks like (high address on top) this,\r
+\r
+  [EBC entry point arguments]\r
+  [VM stack]\r
+  [EBC stack]\r
+\r
+  we need to detect all attempts to write to the EBC entry point argument\r
+  stack area and adjust the address (which will initially point into the \r
+  VM stack) to point into the EBC entry point arguments.\r
+\r
+  @param  VmPtr             A pointer to a VM context.\r
+  @param  Addr              Adddress to write to.\r
+  @param  Data              Value to write to Addr.\r
+\r
+  @retval EFI_SUCCESS       The instruction is executed successfully.  \r
+  @retval Other             Some error occurs when writing data to the address.\r
+\r
+**/\r
 EFI_STATUS\r
 VmWriteMem64 (\r
   IN VM_CONTEXT *VmPtr,\r
@@ -305,6 +366,20 @@ struct _EFI_EBC_VM_TEST_PROTOCOL {
   EBC_VM_TEST_DASM    Disassemble;\r
 };\r
 \r
+/**\r
+  Given a pointer to a new VM context, execute one or more instructions. This\r
+  function is only used for test purposes via the EBC VM test protocol.\r
+\r
+  @param  This              A pointer to the EFI_EBC_VM_TEST_PROTOCOL structure.\r
+  @param  VmPtr             A pointer to a VM context.\r
+  @param  InstructionCount  A pointer to a UINTN value holding the number of\r
+                            instructions to execute. If it holds value of 0,\r
+                            then the instruction to be executed is 1.\r
+\r
+  @retval EFI_UNSUPPORTED   At least one of the opcodes is not supported.\r
+  @retval EFI_SUCCESS       All of the instructions are executed successfully.\r
+\r
+**/\r
 EFI_STATUS\r
 EbcExecuteInstructions (\r
   IN EFI_EBC_VM_TEST_PROTOCOL *This,\r
index 37a2b7f6b005f9008d9c6f352ae0302079bfcad9..b3fe0d5e4fc8dac152751c22b548038d2ba8875d 100644 (file)
@@ -1,9 +1,9 @@
 /** @file\r
   Top level module for the EBC virtual machine implementation.\r
-  Provides auxilliary support routines for the VM. That is, routines\r
+  Provides auxiliary support routines for the VM. That is, routines\r
   that are not particularly related to VM execution of EBC instructions.\r
 \r
-Copyright (c) 2006, Intel Corporation\r
+Copyright (c) 2006 - 2008, Intel Corporation\r
 All rights reserved. This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -34,6 +34,20 @@ typedef struct _EBC_IMAGE_LIST {
   EBC_THUNK_LIST          *ThunkList;\r
 } EBC_IMAGE_LIST;\r
 \r
+/**\r
+  This routine is called by the core when an image is being unloaded from\r
+  memory. Basically we now have the opportunity to do any necessary cleanup.\r
+  Typically this will include freeing any memory allocated for thunk-creation.\r
+\r
+  @param  This                  A pointer to the EFI_EBC_PROTOCOL instance.\r
+  @param  ImageHandle           Handle of image for which the thunk is being\r
+                                created.\r
+\r
+  @retval EFI_INVALID_PARAMETER The ImageHandle passed in was not found in the\r
+                                internal list of EBC image handles.\r
+  @retval EFI_SUCCESS           The function completed successfully.\r
+\r
+**/\r
 STATIC\r
 EFI_STATUS\r
 EFIAPI\r
@@ -42,6 +56,25 @@ EbcUnloadImage (
   IN EFI_HANDLE           ImageHandle\r
   );\r
 \r
+/**\r
+  This is the top-level routine plugged into the EBC protocol. Since thunks\r
+  are very processor-specific, from here we dispatch directly to the very\r
+  processor-specific routine EbcCreateThunks().\r
+\r
+  @param  This                  A pointer to the EFI_EBC_PROTOCOL instance.\r
+  @param  ImageHandle           Handle of image for which the thunk is being\r
+                                created. The EBC interpreter may use this to\r
+                                keep track of any resource allocations\r
+                                performed in loading and executing the image.\r
+  @param  EbcEntryPoint         Address of the actual EBC entry point or\r
+                                protocol service the thunk should call.\r
+  @param  Thunk                 Returned pointer to a thunk created.\r
+\r
+  @retval EFI_SUCCESS           The function completed successfully.\r
+  @retval EFI_INVALID_PARAMETER Image entry point is not 2-byte aligned.\r
+  @retval EFI_OUT_OF_RESOURCES  Memory could not be allocated for the thunk.\r
+\r
+**/\r
 STATIC\r
 EFI_STATUS\r
 EFIAPI\r
@@ -52,6 +85,17 @@ EbcCreateThunk (
   OUT VOID                **Thunk\r
   );\r
 \r
+/**\r
+  Called to get the version of the interpreter.\r
+\r
+  @param  This                  A pointer to the EFI_EBC_PROTOCOL instance.\r
+  @param  Version               Pointer to where to store the returned version\r
+                                of the interpreter.\r
+   \r
+  @retval EFI_SUCCESS           The function completed successfully.\r
+  @retval EFI_INVALID_PARAMETER Version pointer is NULL.\r
+\r
+**/\r
 STATIC\r
 EFI_STATUS\r
 EFIAPI\r
@@ -60,6 +104,16 @@ EbcGetVersion (
   IN OUT UINT64           *Version\r
   );\r
 \r
+/**\r
+  To install default Callback function for the VM interpreter.\r
+\r
+  @param  This                  A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL\r
+                                instance.\r
+\r
+  @retval EFI_SUCCESS           The function completed successfully.\r
+  @retval Others                Some error occurs when creating periodic event.\r
+\r
+**/\r
 STATIC\r
 EFI_STATUS\r
 EFIAPI\r
@@ -67,6 +121,15 @@ InitializeEbcCallback (
   IN EFI_DEBUG_SUPPORT_PROTOCOL  *This\r
   );\r
 \r
+/**\r
+  The default Exception Callback for the VM interpreter.\r
+  In this function, we report status code, and print debug information\r
+  about EBC_CONTEXT, then dead loop.\r
+\r
+  @param  InterruptType          Interrupt type.\r
+  @param  SystemContext          EBC system context.\r
+\r
+**/\r
 STATIC\r
 VOID\r
 EFIAPI\r
@@ -75,6 +138,14 @@ CommonEbcExceptionHandler (
   IN EFI_SYSTEM_CONTEXT   SystemContext\r
   );\r
 \r
+/**\r
+  The periodic callback function for EBC VM interpreter, which is used\r
+  to support the EFI debug support protocol.\r
+\r
+  @param  Event                  The Periodic Callback Event.\r
+  @param  Context                It should be the address of VM_CONTEXT pointer.\r
+\r
+**/\r
 STATIC\r
 VOID\r
 EFIAPI\r
@@ -83,6 +154,16 @@ EbcPeriodicNotifyFunction (
   IN VOID          *Context\r
   );\r
 \r
+/**\r
+  The VM interpreter calls this function on a periodic basis to support\r
+  the EFI debug support protocol.\r
+\r
+  @param  VmPtr                  Pointer to a VM context for passing info to the\r
+                                 debugger.\r
+\r
+  @retval EFI_SUCCESS            The function completed successfully.\r
+\r
+**/\r
 STATIC\r
 EFI_STATUS\r
 EFIAPI\r
@@ -94,18 +175,43 @@ EbcDebugPeriodic (
 // These two functions and the  GUID are used to produce an EBC test protocol.\r
 // This functionality is definitely not required for execution.\r
 //\r
+/**\r
+  Produces an EBC VM test protocol that can be used for regression tests.\r
+\r
+  @param  IHandle                Handle on which to install the protocol.\r
+\r
+  @retval EFI_OUT_OF_RESOURCES   Memory allocation failed.\r
+  @retval EFI_SUCCESS            The function completed successfully.\r
+\r
+**/\r
 STATIC\r
 EFI_STATUS\r
 InitEbcVmTestProtocol (\r
   IN EFI_HANDLE     *Handle\r
   );\r
 \r
+/**\r
+  Returns the EFI_UNSUPPORTED Status.\r
+   \r
+  @return EFI_UNSUPPORTED  This function always return EFI_UNSUPPORTED status.\r
+\r
+**/\r
 STATIC\r
 EFI_STATUS\r
 EbcVmTestUnsupported (\r
   VOID\r
   );\r
 \r
+/**\r
+  Registers a callback function that the EBC interpreter calls to flush the\r
+  processor instruction cache following creation of thunks. \r
+\r
+  @param  This        A pointer to the EFI_EBC_PROTOCOL instance.\r
+  @param  Flush       Pointer to a function of type EBC_ICACH_FLUSH.\r
+   \r
+  @retval EFI_SUCCESS The function completed successfully.\r
+\r
+**/\r
 STATIC\r
 EFI_STATUS\r
 EFIAPI\r
@@ -114,6 +220,17 @@ EbcRegisterICacheFlush (
   IN EBC_ICACHE_FLUSH               Flush\r
   );\r
 \r
+/**\r
+  This EBC debugger protocol service is called by the debug agent\r
+\r
+  @param  This                  A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL\r
+                                instance.\r
+  @param  MaxProcessorIndex     Pointer to a caller-allocated UINTN in which the\r
+                                maximum supported processor index is returned.\r
+\r
+  @retval EFI_SUCCESS           The function completed successfully.\r
+\r
+**/\r
 STATIC\r
 EFI_STATUS\r
 EFIAPI\r
@@ -122,6 +239,27 @@ EbcDebugGetMaximumProcessorIndex (
   OUT UINTN                         *MaxProcessorIndex\r
   );\r
 \r
+/**\r
+  This protocol service is called by the debug agent to register a function\r
+  for us to call on a periodic basis.\r
+\r
+  @param  This                  A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL\r
+                                instance.\r
+  @param  ProcessorIndex        Specifies which processor the callback function\r
+                                applies to.\r
+  @param  PeriodicCallback      A pointer to a function of type\r
+                                PERIODIC_CALLBACK that is the main periodic\r
+                                entry point of the debug agent. It receives as a\r
+                                parameter a pointer to the full context of the\r
+                                interrupted execution thread.\r
+\r
+  @retval EFI_SUCCESS           The function completed successfully.\r
+  @retval EFI_ALREADY_STARTED   Non-NULL PeriodicCallback parameter when a\r
+                                callback function was previously registered.\r
+  @retval EFI_INVALID_PARAMETER Null PeriodicCallback parameter when no\r
+                                callback function was previously registered.\r
+\r
+**/\r
 STATIC\r
 EFI_STATUS\r
 EFIAPI\r
@@ -131,6 +269,31 @@ EbcDebugRegisterPeriodicCallback (
   IN EFI_PERIODIC_CALLBACK          PeriodicCallback\r
   );\r
 \r
+/**\r
+  This protocol service is called by the debug agent to register a function\r
+  for us to call when we detect an exception.\r
+\r
+  @param  This                  A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL\r
+                                instance.\r
+  @param  ProcessorIndex        Specifies which processor the callback function\r
+                                applies to.\r
+  @param  ExceptionCallback     A pointer to a function of type\r
+                                EXCEPTION_CALLBACK that is called when the\r
+                                processor exception specified by ExceptionType\r
+                                occurs. Passing NULL unregisters any previously\r
+                                registered function associated with\r
+                                ExceptionType.\r
+  @param  ExceptionType         Specifies which processor exception to hook.\r
+\r
+  @retval EFI_SUCCESS           The function completed successfully.\r
+  @retval EFI_ALREADY_STARTED   Non-NULL ExceptionCallback parameter when a\r
+                                callback function was previously registered.\r
+  @retval EFI_INVALID_PARAMETER ExceptionType parameter is negative or exceeds\r
+                                MAX_EBC_EXCEPTION.\r
+  @retval EFI_INVALID_PARAMETER Null ExceptionCallback parameter when no\r
+                                callback function was previously registered.\r
+\r
+**/\r
 STATIC\r
 EFI_STATUS\r
 EFIAPI\r
@@ -141,6 +304,22 @@ EbcDebugRegisterExceptionCallback (
   IN EFI_EXCEPTION_TYPE             ExceptionType\r
   );\r
 \r
+/**\r
+  This EBC debugger protocol service is called by the debug agent.  Required\r
+  for DebugSupport compliance but is only stubbed out for EBC.\r
+\r
+  @param  This                  A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL\r
+                                instance.\r
+  @param  ProcessorIndex        Specifies which processor the callback function\r
+                                applies to.\r
+  @param  Start                 StartSpecifies the physical base of the memory\r
+                                range to be invalidated.\r
+  @param  Length                Specifies the minimum number of bytes in the\r
+                                processor's instruction cache to invalidate. \r
+\r
+  @retval EFI_SUCCESS           The function completed successfully.\r
+\r
+**/\r
 STATIC\r
 EFI_STATUS\r
 EFIAPI\r
@@ -157,28 +336,28 @@ EbcDebugInvalidateInstructionCache (
 // also be global since the execution of an EBC image does not provide\r
 // a This pointer.\r
 //\r
-static EBC_IMAGE_LIST         *mEbcImageList = NULL;\r
+STATIC EBC_IMAGE_LIST         *mEbcImageList = NULL;\r
 \r
 //\r
 // Callback function to flush the icache after thunk creation\r
 //\r
-static EBC_ICACHE_FLUSH       mEbcICacheFlush;\r
+STATIC EBC_ICACHE_FLUSH       mEbcICacheFlush;\r
 \r
 //\r
 // These get set via calls by the debug agent\r
 //\r
-static EFI_PERIODIC_CALLBACK  mDebugPeriodicCallback                            = NULL;\r
-static EFI_EXCEPTION_CALLBACK mDebugExceptionCallback[MAX_EBC_EXCEPTION + 1] = {NULL};\r
-static EFI_GUID               mEfiEbcVmTestProtocolGuid = EFI_EBC_VM_TEST_PROTOCOL_GUID;\r
+STATIC EFI_PERIODIC_CALLBACK  mDebugPeriodicCallback                            = NULL;\r
+STATIC EFI_EXCEPTION_CALLBACK mDebugExceptionCallback[MAX_EBC_EXCEPTION + 1] = {NULL};\r
+STATIC EFI_GUID               mEfiEbcVmTestProtocolGuid = EFI_EBC_VM_TEST_PROTOCOL_GUID;\r
 \r
-static VOID*      mStackBuffer[MAX_STACK_NUM];\r
-static EFI_HANDLE mStackBufferIndex[MAX_STACK_NUM];\r
-static UINTN      mStackNum = 0;\r
+STATIC VOID*      mStackBuffer[MAX_STACK_NUM];\r
+STATIC EFI_HANDLE mStackBufferIndex[MAX_STACK_NUM];\r
+STATIC UINTN      mStackNum = 0;\r
 \r
 //\r
 // Event for Periodic callback\r
 //\r
-static EFI_EVENT              mEbcPeriodicEvent;\r
+STATIC EFI_EVENT              mEbcPeriodicEvent;\r
 VM_CONTEXT                    *mVmPtr = NULL;\r
 \r
 \r
@@ -378,16 +557,18 @@ ErrorExit:
   are very processor-specific, from here we dispatch directly to the very\r
   processor-specific routine EbcCreateThunks().\r
 \r
-  @param  This                   protocol instance pointer\r
-  @param  ImageHandle            handle to the image. The EBC interpreter may use\r
-                                 this to keep track of any resource allocations\r
-                                 performed in loading and executing the image.\r
-  @param  EbcEntryPoint          the entry point for the image (as defined in the\r
-                                 file header)\r
-  @param  Thunk                  pointer to thunk pointer where the address of the\r
-                                 created thunk is returned.\r
+  @param  This                  A pointer to the EFI_EBC_PROTOCOL instance.\r
+  @param  ImageHandle           Handle of image for which the thunk is being\r
+                                created. The EBC interpreter may use this to\r
+                                keep track of any resource allocations\r
+                                performed in loading and executing the image.\r
+  @param  EbcEntryPoint         Address of the actual EBC entry point or\r
+                                protocol service the thunk should call.\r
+  @param  Thunk                 Returned pointer to a thunk created.\r
 \r
-  @return EFI_STATUS\r
+  @retval EFI_SUCCESS           The function completed successfully.\r
+  @retval EFI_INVALID_PARAMETER Image entry point is not 2-byte aligned.\r
+  @retval EFI_OUT_OF_RESOURCES  Memory could not be allocated for the thunk.\r
 \r
 **/\r
 STATIC\r
@@ -415,12 +596,12 @@ EbcCreateThunk (
 /**\r
   This EBC debugger protocol service is called by the debug agent\r
 \r
-  @param  This                   pointer to the caller's debug support protocol\r
-                                 interface\r
-  @param  MaxProcessorIndex      pointer to a caller allocated UINTN in which the\r
-                                 maximum processor index is returned.\r
+  @param  This                  A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL\r
+                                instance.\r
+  @param  MaxProcessorIndex     Pointer to a caller-allocated UINTN in which the\r
+                                maximum supported processor index is returned.\r
 \r
-  @return Standard EFI_STATUS\r
+  @retval EFI_SUCCESS           The function completed successfully.\r
 \r
 **/\r
 STATIC\r
@@ -440,11 +621,21 @@ EbcDebugGetMaximumProcessorIndex (
   This protocol service is called by the debug agent to register a function\r
   for us to call on a periodic basis.\r
 \r
-  @param  This                   pointer to the caller's debug support protocol\r
-                                 interface\r
-  @param  PeriodicCallback       pointer to the function to call periodically\r
-\r
-  @return Always EFI_SUCCESS\r
+  @param  This                  A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL\r
+                                instance.\r
+  @param  ProcessorIndex        Specifies which processor the callback function\r
+                                applies to.\r
+  @param  PeriodicCallback      A pointer to a function of type\r
+                                PERIODIC_CALLBACK that is the main periodic\r
+                                entry point of the debug agent. It receives as a\r
+                                parameter a pointer to the full context of the\r
+                                interrupted execution thread.\r
+\r
+  @retval EFI_SUCCESS           The function completed successfully.\r
+  @retval EFI_ALREADY_STARTED   Non-NULL PeriodicCallback parameter when a\r
+                                callback function was previously registered.\r
+  @retval EFI_INVALID_PARAMETER Null PeriodicCallback parameter when no\r
+                                callback function was previously registered.\r
 \r
 **/\r
 STATIC\r
@@ -472,11 +663,25 @@ EbcDebugRegisterPeriodicCallback (
   This protocol service is called by the debug agent to register a function\r
   for us to call when we detect an exception.\r
 \r
-  @param  This                   pointer to the caller's debug support protocol\r
-                                 interface\r
-  @param  ExceptionCallback      pointer to the function to the exception\r
-\r
-  @return Always EFI_SUCCESS\r
+  @param  This                  A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL\r
+                                instance.\r
+  @param  ProcessorIndex        Specifies which processor the callback function\r
+                                applies to.\r
+  @param  ExceptionCallback     A pointer to a function of type\r
+                                EXCEPTION_CALLBACK that is called when the\r
+                                processor exception specified by ExceptionType\r
+                                occurs. Passing NULL unregisters any previously\r
+                                registered function associated with\r
+                                ExceptionType.\r
+  @param  ExceptionType         Specifies which processor exception to hook.\r
+\r
+  @retval EFI_SUCCESS           The function completed successfully.\r
+  @retval EFI_ALREADY_STARTED   Non-NULL ExceptionCallback parameter when a\r
+                                callback function was previously registered.\r
+  @retval EFI_INVALID_PARAMETER ExceptionType parameter is negative or exceeds\r
+                                MAX_EBC_EXCEPTION.\r
+  @retval EFI_INVALID_PARAMETER Null ExceptionCallback parameter when no\r
+                                callback function was previously registered.\r
 \r
 **/\r
 STATIC\r
@@ -507,8 +712,16 @@ EbcDebugRegisterExceptionCallback (
   This EBC debugger protocol service is called by the debug agent.  Required\r
   for DebugSupport compliance but is only stubbed out for EBC.\r
 \r
+  @param  This                  A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL\r
+                                instance.\r
+  @param  ProcessorIndex        Specifies which processor the callback function\r
+                                applies to.\r
+  @param  Start                 StartSpecifies the physical base of the memory\r
+                                range to be invalidated.\r
+  @param  Length                Specifies the minimum number of bytes in the\r
+                                processor's instruction cache to invalidate. \r
 \r
-  @return EFI_SUCCESS\r
+  @retval EFI_SUCCESS           The function completed successfully.\r
 \r
 **/\r
 STATIC\r
@@ -528,10 +741,12 @@ EbcDebugInvalidateInstructionCache (
 /**\r
   The VM interpreter calls this function when an exception is detected.\r
 \r
-  @param  VmPtr                  pointer to a VM context for passing info to the\r
+  @param  ExceptionType          Specifies the processor exception detected.\r
+  @param  ExceptionFlags         Specifies the exception context. \r
+  @param  VmPtr                  Pointer to a VM context for passing info to the\r
                                  EFI debugger.\r
 \r
-  @return EFI_SUCCESS if it returns at all\r
+  @retval EFI_SUCCESS            This function completed successfully.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -605,13 +820,16 @@ EbcDebugSignalException (
 /**\r
   To install default Callback function for the VM interpreter.\r
 \r
-  @param  This                   pointer to the instance of DebugSupport protocol\r
+  @param  This                  A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL\r
+                                instance.\r
 \r
-  @return None\r
+  @retval EFI_SUCCESS           The function completed successfully.\r
+  @retval Others                Some error occurs when creating periodic event.\r
 \r
 **/\r
 STATIC\r
 EFI_STATUS\r
+EFIAPI\r
 InitializeEbcCallback (\r
   IN EFI_DEBUG_SUPPORT_PROTOCOL  *This\r
   )\r
@@ -666,11 +884,10 @@ InitializeEbcCallback (
   @param  InterruptType          Interrupt type.\r
   @param  SystemContext          EBC system context.\r
 \r
-  @return None\r
-\r
 **/\r
 STATIC\r
 VOID\r
+EFIAPI\r
 CommonEbcExceptionHandler (\r
   IN EFI_EXCEPTION_TYPE   InterruptType,\r
   IN EFI_SYSTEM_CONTEXT   SystemContext\r
@@ -692,8 +909,6 @@ CommonEbcExceptionHandler (
   @param  Event                  The Periodic Callback Event.\r
   @param  Context                It should be the address of VM_CONTEXT pointer.\r
 \r
-  @return None.\r
-\r
 **/\r
 STATIC\r
 VOID\r
@@ -719,14 +934,15 @@ EbcPeriodicNotifyFunction (
   The VM interpreter calls this function on a periodic basis to support\r
   the EFI debug support protocol.\r
 \r
-  @param  VmPtr                  pointer to a VM context for passing info to the\r
+  @param  VmPtr                  Pointer to a VM context for passing info to the\r
                                  debugger.\r
 \r
-  @return Standard EFI status.\r
+  @retval EFI_SUCCESS            The function completed successfully.\r
 \r
 **/\r
 STATIC\r
 EFI_STATUS\r
+EFIAPI\r
 EbcDebugPeriodic (\r
   IN VM_CONTEXT *VmPtr\r
   )\r
@@ -781,12 +997,13 @@ EbcDebugPeriodic (
   memory. Basically we now have the opportunity to do any necessary cleanup.\r
   Typically this will include freeing any memory allocated for thunk-creation.\r
 \r
-  @param  This                   protocol instance pointer\r
-  @param  ImageHandle            handle to the image being unloaded.\r
+  @param  This                  A pointer to the EFI_EBC_PROTOCOL instance.\r
+  @param  ImageHandle           Handle of image for which the thunk is being\r
+                                created.\r
 \r
-  @retval EFI_INVALID_PARAMETER  the ImageHandle passed in was not found in the\r
-                                 internal list of EBC image handles.\r
-  @retval EFI_STATUS             completed successfully\r
+  @retval EFI_INVALID_PARAMETER The ImageHandle passed in was not found in the\r
+                                internal list of EBC image handles.\r
+  @retval EFI_SUCCESS           The function completed successfully.\r
 \r
 **/\r
 STATIC\r
@@ -855,12 +1072,12 @@ EbcUnloadImage (
   Also flush the instruction cache since we've written thunk code\r
   to memory that will be executed eventually.\r
 \r
-  @param  ImageHandle            the image handle to which the thunk is tied\r
-  @param  ThunkBuffer            the buffer we've created/allocated\r
-  @param  ThunkSize              the size of the thunk memory allocated\r
+  @param  ImageHandle            The image handle to which the thunk is tied.\r
+  @param  ThunkBuffer            The buffer that has been created/allocated.\r
+  @param  ThunkSize              The size of the thunk memory allocated.\r
 \r
-  @retval EFI_OUT_OF_RESOURCES   memory allocation failed\r
-  @retval EFI_SUCCESS            successful completion\r
+  @retval EFI_OUT_OF_RESOURCES   Memory allocation failed.\r
+  @retval EFI_SUCCESS            The function completed successfully.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -925,6 +1142,16 @@ EbcAddImageThunk (
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Registers a callback function that the EBC interpreter calls to flush the\r
+  processor instruction cache following creation of thunks. \r
+\r
+  @param  This        A pointer to the EFI_EBC_PROTOCOL instance.\r
+  @param  Flush       Pointer to a function of type EBC_ICACH_FLUSH.\r
+   \r
+  @retval EFI_SUCCESS The function completed successfully.\r
+\r
+**/\r
 STATIC\r
 EFI_STATUS\r
 EFIAPI\r
@@ -937,6 +1164,17 @@ EbcRegisterICacheFlush (
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Called to get the version of the interpreter.\r
+\r
+  @param  This                  A pointer to the EFI_EBC_PROTOCOL instance.\r
+  @param  Version               Pointer to where to store the returned version\r
+                                of the interpreter.\r
+   \r
+  @retval EFI_SUCCESS           The function completed successfully.\r
+  @retval EFI_INVALID_PARAMETER Version pointer is NULL.\r
+\r
+**/\r
 STATIC\r
 EFI_STATUS\r
 EFIAPI\r
@@ -953,11 +1191,24 @@ EbcGetVersion (
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Returns the stack index and buffer assosicated with the Handle parameter.\r
+\r
+  @param  Handle                The EFI handle as the index to the EBC stack. \r
+  @param  StackBuffer           A pointer to hold the returned stack buffer.\r
+  @param  BufferIndex           A pointer to hold the returned stack index.\r
+   \r
+  @retval EFI_OUT_OF_RESOURCES  The Handle parameter does not correspond to any\r
+                                existing EBC stack.\r
+  @retval EFI_SUCCESS           The stack index and buffer were found and\r
+                                returned to the caller.\r
+\r
+**/\r
 EFI_STATUS\r
 GetEBCStack(\r
-  EFI_HANDLE Handle,\r
-  VOID       **StackBuffer,\r
-  UINTN      *BufferIndex\r
+  IN  EFI_HANDLE Handle,\r
+  OUT VOID       **StackBuffer,\r
+  OUT UINTN      *BufferIndex\r
   )\r
 {\r
   UINTN   Index;\r
@@ -978,18 +1229,34 @@ GetEBCStack(
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Returns from the EBC stack by stack Index. \r
+   \r
+  @param  Index        Specifies which EBC stack to return from.\r
+   \r
+  @retval EFI_SUCCESS  The function completed successfully.\r
+\r
+**/\r
 EFI_STATUS\r
 ReturnEBCStack(\r
-  UINTN Index\r
+  IN UINTN Index\r
   )\r
 {\r
-  mStackBufferIndex[Index] =NULL;\r
+  mStackBufferIndex[Index] = NULL;\r
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Returns from the EBC stack associated with the Handle parameter. \r
+   \r
+  @param  Handle      Specifies the EFI handle to find the EBC stack with.\r
+   \r
+  @retval EFI_SUCCESS The function completed successfully.\r
+\r
+**/\r
 EFI_STATUS\r
 ReturnEBCStackByHandle(\r
-  EFI_HANDLE Handle\r
+  IN EFI_HANDLE Handle\r
   )\r
 {\r
   UINTN Index;\r
@@ -1005,6 +1272,13 @@ ReturnEBCStackByHandle(
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Allocates memory to hold all the EBC stacks.\r
+\r
+  @retval EFI_SUCCESS          The EBC stacks were allocated successfully. \r
+  @retval EFI_OUT_OF_RESOURCES Not enough memory available for EBC stacks.\r
+\r
+**/\r
 EFI_STATUS\r
 InitEBCStack (\r
   VOID\r
@@ -1023,6 +1297,13 @@ InitEBCStack (
   return EFI_SUCCESS;\r
 }\r
 \r
+\r
+/**\r
+  Free all EBC stacks allocated before.\r
+\r
+  @retval EFI_SUCCESS   All the EBC stacks were freed.\r
+\r
+**/\r
 EFI_STATUS\r
 FreeEBCStack(\r
   VOID\r
@@ -1036,12 +1317,12 @@ FreeEBCStack(
 }\r
 \r
 /**\r
-  Produce an EBC VM test protocol that can be used for regression tests.\r
+  Produces an EBC VM test protocol that can be used for regression tests.\r
 \r
-  @param  IHandle                handle on which to install the protocol.\r
+  @param  IHandle                Handle on which to install the protocol.\r
 \r
-  @retval EFI_OUT_OF_RESOURCES   memory allocation failed\r
-  @retval EFI_SUCCESS            successful completion\r
+  @retval EFI_OUT_OF_RESOURCES   Memory allocation failed.\r
+  @retval EFI_SUCCESS            The function completed successfully.\r
 \r
 **/\r
 STATIC\r
@@ -1078,9 +1359,19 @@ InitEbcVmTestProtocol (
   }\r
   return Status;\r
 }\r
+\r
+\r
+/**\r
+  Returns the EFI_UNSUPPORTED Status.\r
+   \r
+  @return EFI_UNSUPPORTED  This function always return EFI_UNSUPPORTED status.\r
+\r
+**/\r
 STATIC\r
 EFI_STATUS\r
-EbcVmTestUnsupported ()\r
+EbcVmTestUnsupported (\r
+  VOID\r
+  )\r
 {\r
   return EFI_UNSUPPORTED;\r
 }\r
index c9f2b825f14be10b5709e85f2af58b9394329c1a..720ee2668a2124c26989f48697f3f91645c434f7 100644 (file)
@@ -79,6 +79,23 @@ extern VM_CONTEXT                    *mVmPtr;
 //\r
 #define VM_STACK_KEY_VALUE  0xDEADBEEF\r
 \r
+/**\r
+  Create thunks for an EBC image entry point, or an EBC protocol service.\r
+\r
+  @param  ImageHandle           Image handle for the EBC image. If not null, then\r
+                                we're creating a thunk for an image entry point.\r
+  @param  EbcEntryPoint         Address of the EBC code that the thunk is to call\r
+  @param  Thunk                 Returned thunk we create here\r
+  @param  Flags                 Flags indicating options for creating the thunk\r
+\r
+  @retval EFI_SUCCESS           The thunk was created successfully.\r
+  @retval EFI_INVALID_PARAMETER The parameter of EbcEntryPoint is not 16-bit\r
+                                aligned.\r
+  @retval EFI_OUT_OF_RESOURCES  There is not enough memory to created the EBC\r
+                                Thunk.\r
+  @retval EFI_BUFFER_TOO_SMALL  EBC_THUNK_SIZE is not larger enough.\r
+\r
+**/\r
 EFI_STATUS\r
 EbcCreateThunks (\r
   IN EFI_HANDLE           ImageHandle,\r
@@ -88,6 +105,19 @@ EbcCreateThunks (
   )\r
 ;\r
 \r
+/**\r
+  Add a thunk to our list of thunks for a given image handle.\r
+  Also flush the instruction cache since we've written thunk code\r
+  to memory that will be executed eventually.\r
+\r
+  @param  ImageHandle            The image handle to which the thunk is tied.\r
+  @param  ThunkBuffer            The buffer that has been created/allocated.\r
+  @param  ThunkSize              The size of the thunk memory allocated.\r
+\r
+  @retval EFI_OUT_OF_RESOURCES   Memory allocation failed.\r
+  @retval EFI_SUCCESS            The function completed successfully.\r
+\r
+**/\r
 EFI_STATUS\r
 EbcAddImageThunk (\r
   IN EFI_HANDLE     ImageHandle,\r
@@ -100,6 +130,17 @@ EbcAddImageThunk (
 // The interpreter calls these when an exception is detected,\r
 // or as a periodic callback.\r
 //\r
+/**\r
+  The VM interpreter calls this function when an exception is detected.\r
+\r
+  @param  ExceptionType          Specifies the processor exception detected.\r
+  @param  ExceptionFlags         Specifies the exception context. \r
+  @param  VmPtr                  Pointer to a VM context for passing info to the\r
+                                 EFI debugger.\r
+\r
+  @retval EFI_SUCCESS            This function completed successfully.\r
+\r
+**/\r
 EFI_STATUS\r
 EbcDebugSignalException (\r
   IN EFI_EXCEPTION_TYPE ExceptionType,\r
@@ -117,28 +158,56 @@ EbcDebugSignalException (
 #define STACK_POOL_SIZE               (1024 * 1020)\r
 #define MAX_STACK_NUM                 4\r
 \r
-EFI_STATUS\r
-EbcDebugSignalPeriodic (\r
-  IN VM_CONTEXT   *VmPtr\r
-  )\r
-;\r
-\r
 //\r
 // External low level functions that are native-processor dependent\r
-//\r
+// \r
+/** \r
+  The VM thunk code stuffs an EBC entry point into a processor \r
+  register. Since we can't use inline assembly to get it from\r
+  the interpreter C code, stuff it into the return value\r
+  register and return.\r
\r
+  @return  The contents of the register in which the entry point is passed.\r
\r
+**/ \r
 UINTN\r
+EFIAPI\r
 EbcLLGetEbcEntryPoint (\r
   VOID\r
   )\r
 ;\r
 \r
+/**\r
+  Returns the caller's value of the stack pointer.\r
+\r
+  We adjust it by 4 here because when they called us, the return address\r
+  is put on the stack, thereby lowering it by 4 bytes.\r
+\r
+  @return The current value of the stack pointer for the caller. \r
+\r
+**/\r
 UINTN\r
+EFIAPI\r
 EbcLLGetStackPointer (\r
   VOID\r
   )\r
 ;\r
 \r
+/**\r
+  This function is called to execute an EBC CALLEX instruction.\r
+  This instruction requires that we thunk out to external native\r
+  code. For x64, we switch stacks, copy the arguments to the stack \r
+  and jump to the specified function.\r
+  On return, we restore the stack pointer to its original location.\r
+  Destroys no working registers.\r
+\r
+  @param  CallAddr     The function address.\r
+  @param  EbcSp        The new EBC stack pointer.\r
+  @param  FramePtr     The frame pointer.\r
+   \r
+**/\r
 VOID\r
+EFIAPI\r
 EbcLLCALLEXNative (\r
   IN UINTN        CallAddr,\r
   IN UINTN        EbcSp,\r
@@ -146,47 +215,114 @@ EbcLLCALLEXNative (
   )\r
 ;\r
 \r
+/**\r
+  This function is called to execute an EBC CALLEX instruction.\r
+  The function check the callee's content to see whether it is common native\r
+  code or a thunk to another piece of EBC code.\r
+  If the callee is common native code, use EbcLLCAllEXASM to manipulate,\r
+  otherwise, set the VM->IP to target EBC code directly to avoid another VM\r
+  be startup which cost time and stack space.\r
+\r
+  @param  VmPtr            Pointer to a VM context.\r
+  @param  FuncAddr         Callee's address\r
+  @param  NewStackPointer  New stack pointer after the call\r
+  @param  FramePtr         New frame pointer after the call\r
+  @param  Size             The size of call instruction\r
+\r
+**/\r
 VOID\r
 EbcLLCALLEX (\r
   IN VM_CONTEXT   *VmPtr,\r
-  IN UINTN        CallAddr,\r
-  IN UINTN        EbcSp,\r
+  IN UINTN        FuncAddr,\r
+  IN UINTN        NewStackPointer,\r
   IN VOID         *FramePtr,\r
   IN UINT8        Size\r
   )\r
 ;\r
 \r
+/**\r
+  When EBC calls native, on return the VM has to stuff the return\r
+  value into a VM register. It's assumed here that the value is still\r
+  in the register, so simply return and the caller should get the\r
+  return result properly.\r
+\r
+  @return The unmodified value returned by the native code. \r
+\r
+**/\r
 INT64\r
+EFIAPI\r
 EbcLLGetReturnValue (\r
   VOID\r
   )\r
 ;\r
 \r
+/**\r
+  Returns the stack index and buffer assosicated with the Handle parameter.\r
+\r
+  @param  Handle                The EFI handle as the index to the EBC stack. \r
+  @param  StackBuffer           A pointer to hold the returned stack buffer.\r
+  @param  BufferIndex           A pointer to hold the returned stack index.\r
+   \r
+  @retval EFI_OUT_OF_RESOURCES  The Handle parameter does not correspond to any\r
+                                existing EBC stack.\r
+  @retval EFI_SUCCESS           The stack index and buffer were found and\r
+                                returned to the caller.\r
+\r
+**/\r
 EFI_STATUS\r
 GetEBCStack(\r
-  EFI_HANDLE Handle,\r
-  VOID       **StackBuffer,\r
-  UINTN      *BufferIndex\r
+  IN  EFI_HANDLE Handle,\r
+  OUT VOID       **StackBuffer,\r
+  OUT UINTN      *BufferIndex\r
   );\r
 \r
+/**\r
+  Returns from the EBC stack by stack Index. \r
+   \r
+  @param  Index        Specifies which EBC stack to return from.\r
+   \r
+  @retval EFI_SUCCESS  The function completed successfully.\r
+\r
+**/\r
 EFI_STATUS\r
 ReturnEBCStack(\r
-  UINTN Index\r
+  IN UINTN Index\r
   );\r
 \r
+/**\r
+  Allocates memory to hold all the EBC stacks.\r
+\r
+  @retval EFI_SUCCESS          The EBC stacks were allocated successfully. \r
+  @retval EFI_OUT_OF_RESOURCES Not enough memory available for EBC stacks.\r
+\r
+**/\r
 EFI_STATUS\r
 InitEBCStack (\r
   VOID\r
   );\r
 \r
+/**\r
+  Free all EBC stacks allocated before.\r
+\r
+  @retval EFI_SUCCESS   All the EBC stacks were freed.\r
+\r
+**/\r
 EFI_STATUS\r
 FreeEBCStack(\r
   VOID\r
   );\r
 \r
+/**\r
+  Returns from the EBC stack associated with the Handle parameter. \r
+   \r
+  @param  Handle      Specifies the EFI handle to find the EBC stack with.\r
+   \r
+  @retval EFI_SUCCESS The function completed successfully.\r
+\r
+**/\r
 EFI_STATUS\r
 ReturnEBCStackByHandle(\r
-  EFI_HANDLE Handle\r
+  IN EFI_HANDLE Handle\r
   );\r
 //\r
 // Defines for a simple EBC debugger interface\r
@@ -255,13 +391,6 @@ typedef struct {
 \r
 #define EBC_PROTOCOL_PRIVATE_DATA_SIGNATURE EFI_SIGNATURE_32 ('e', 'b', 'c', 'p')\r
 \r
-struct _EBC_PROTOCOL_PRIVATE_DATA {\r
-  UINT32            Signature;\r
-  EFI_EBC_PROTOCOL  EbcProtocol;\r
-  UINTN             StackBase;\r
-  UINTN             StackTop;\r
-  UINTN             StackSize;\r
-} ;\r
 \r
 #define EBC_PROTOCOL_PRIVATE_DATA_FROM_THIS(a) \\r
       CR(a, EBC_PROTOCOL_PRIVATE_DATA, EbcProtocol, EBC_PROTOCOL_PRIVATE_DATA_SIGNATURE)\r
index 1d008ac7822bc3510c9f21b422a4545df2e371e2..11fa4e6659343fcc0c0fd2ee6adb0779dda1dc9b 100644 (file)
@@ -36,13 +36,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
   otherwise, set the VM->IP to target EBC code directly to avoid another VM\r
   be startup which cost time and stack space.\r
 \r
-  @parm VmPtr              Pointer to a VM context.\r
-  @parm FuncAddr           Callee's address\r
-  @parm NewStackPointer    New stack pointer after the call\r
-  @parm FramePtr           New frame pointer after the call\r
-  @parm Size               The size of call instruction\r
-\r
-  @return None.\r
+  @param  VmPtr            Pointer to a VM context.\r
+  @param  FuncAddr         Callee's address\r
+  @param  NewStackPointer  New stack pointer after the call\r
+  @param  FramePtr         New frame pointer after the call\r
+  @param  Size             The size of call instruction\r
 \r
 **/\r
 VOID\r
@@ -137,9 +135,26 @@ Action:
   in via a processor register, so we'll need to make a call to get the\r
   value.\r
 \r
-  None. Since we're called from a fixed up thunk (which we want to keep\r
-  small), our only so-called argument is the EBC entry point passed in\r
-  to us in a processor register.\r
+  This is a thunk function. Microsoft x64 compiler only provide fast_call\r
+  calling convention, so the first four arguments are passed by rcx, rdx,\r
+  r8, and r9, while other arguments are passed in stack.\r
+\r
+  @param  Arg1                  The 1st argument.\r
+  @param  Arg2                  The 2nd argument.\r
+  @param  Arg3                  The 3rd argument.\r
+  @param  Arg4                  The 4th argument.\r
+  @param  Arg5                  The 5th argument.\r
+  @param  Arg6                  The 6th argument.\r
+  @param  Arg7                  The 7th argument.\r
+  @param  Arg8                  The 8th argument.\r
+  @param  Arg9                  The 9th argument.\r
+  @param  Arg10                 The 10th argument.\r
+  @param  Arg11                 The 11th argument.\r
+  @param  Arg12                 The 12th argument.\r
+  @param  Arg13                 The 13th argument.\r
+  @param  Arg14                 The 14th argument.\r
+  @param  Arg15                 The 15th argument.\r
+  @param  Arg16                 The 16th argument.\r
 \r
   @return The value returned by the EBC application we're going to run.\r
 \r
@@ -286,8 +301,9 @@ EbcInterpret (
   in via a processor register, so we'll need to make a call to get the\r
   value.\r
 \r
-  @param  ImageHandle    image handle for the EBC application we're executing\r
-  @param  SystemTable    standard system table passed into an driver's entry point\r
+  @param  ImageHandle      image handle for the EBC application we're executing\r
+  @param  SystemTable      standard system table passed into an driver's entry\r
+                           point\r
 \r
   @return The value returned by the EBC application we're going to run.\r
 \r
@@ -385,13 +401,20 @@ ExecuteEbcImageEntryPoint (
 \r
 \r
 /**\r
-  Create an IA32 thunk for the given EBC entry point.\r
+  Create thunks for an EBC image entry point, or an EBC protocol service.\r
 \r
-  @param  ImageHandle    Handle of image for which this thunk is being created\r
-  @param  EbcEntryPoint  Address of the EBC code that the thunk is to call\r
-  @param  Thunk          Returned thunk we create here\r
+  @param  ImageHandle           Image handle for the EBC image. If not null, then\r
+                                we're creating a thunk for an image entry point.\r
+  @param  EbcEntryPoint         Address of the EBC code that the thunk is to call\r
+  @param  Thunk                 Returned thunk we create here\r
+  @param  Flags                 Flags indicating options for creating the thunk\r
 \r
-  @return Standard EFI status.\r
+  @retval EFI_SUCCESS           The thunk was created successfully.\r
+  @retval EFI_INVALID_PARAMETER The parameter of EbcEntryPoint is not 16-bit\r
+                                aligned.\r
+  @retval EFI_OUT_OF_RESOURCES  There is not enough memory to created the EBC\r
+                                Thunk.\r
+  @retval EFI_BUFFER_TOO_SMALL  EBC_THUNK_SIZE is not larger enough.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -404,7 +427,7 @@ EbcCreateThunks (
 {\r
   UINT8       *Ptr;\r
   UINT8       *ThunkBase;\r
-  UINT32      I;\r
+  UINT32      Index;\r
   UINT32      Addr;\r
   INT32       Size;\r
   INT32       ThunkSize;\r
@@ -444,7 +467,7 @@ EbcCreateThunks (
   Ptr++;\r
   Size--;\r
   Addr = (UINT32) 0xCA112EBC;\r
-  for (I = 0; I < sizeof (Addr); I++) {\r
+  for (Index = 0; Index < sizeof (Addr); Index++) {\r
     *Ptr = (UINT8) (UINTN) Addr;\r
     Addr >>= 8;\r
     Ptr++;\r
@@ -461,7 +484,7 @@ EbcCreateThunks (
   Ptr++;\r
   Size--;\r
   Addr = (UINT32) EbcEntryPoint;\r
-  for (I = 0; I < sizeof (Addr); I++) {\r
+  for (Index = 0; Index < sizeof (Addr); Index++) {\r
     *Ptr = (UINT8) (UINTN) Addr;\r
     Addr >>= 8;\r
     Ptr++;\r
@@ -483,7 +506,7 @@ EbcCreateThunks (
   *Ptr = 0xB9;\r
   Ptr++;\r
   Size--;\r
-  for (I = 0; I < sizeof (Addr); I++) {\r
+  for (Index = 0; Index < sizeof (Addr); Index++) {\r
     *Ptr = (UINT8) Addr;\r
     Addr >>= 8;\r
     Ptr++;\r
index b2cb6f6be060fec430a7c48fd4ac795ee460e49e..83d596c4c7e4c5fb383d60049268507bb4ae7fb0 100644 (file)
@@ -17,6 +17,23 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include "EbcExecute.h"\r
 #include "EbcSupport.h"\r
 \r
+/**\r
+  Given raw bytes of Itanium based code, format them into a bundle and\r
+  write them out.\r
+\r
+  @param  MemPtr                 pointer to memory location to write the bundles\r
+                                 to.\r
+  @param  Template               5-bit template.\r
+  @param  Slot0                  Instruction slot 0 data for the bundle.\r
+  @param  Slot1                  Instruction slot 1 data for the bundle.\r
+  @param  Slot2                  Instruction slot 2 data for the bundle.\r
+\r
+  @retval EFI_INVALID_PARAMETER  Pointer is not aligned\r
+  @retval EFI_INVALID_PARAMETER  No more than 5 bits in template\r
+  @retval EFI_INVALID_PARAMETER  More than 41 bits used in code\r
+  @retval EFI_SUCCESS            All data is written.\r
+\r
+**/\r
 STATIC\r
 EFI_STATUS\r
 WriteBundle (\r
@@ -27,11 +44,18 @@ WriteBundle (
   IN    UINT64  Slot2\r
   );\r
 \r
+/**\r
+  Pushes a 64 bit unsigned value to the VM stack.\r
+\r
+  @param VmPtr  The pointer to current VM context.\r
+  @param Arg    The value to be pushed.\r
+\r
+**/\r
 STATIC\r
 VOID\r
 PushU64 (\r
-  VM_CONTEXT *VmPtr,\r
-  UINT64     Arg\r
+  IN VM_CONTEXT *VmPtr,\r
+  IN UINT64     Arg\r
   )\r
 {\r
   //\r
@@ -42,6 +66,21 @@ PushU64 (
   *(UINT64 *) VmPtr->R[0] = Arg;\r
 }\r
 \r
+/**\r
+  Begin executing an EBC image. The address of the entry point is passed\r
+  in via a processor register, so we'll need to make a call to get the\r
+  value.\r
+\r
+  This is a thunk function. Microsoft x64 compiler only provide fast_call\r
+  calling convention, so the first four arguments are passed by rcx, rdx,\r
+  r8, and r9, while other arguments are passed in stack.\r
+\r
+  @param  Arg1                  The 1st argument.\r
+  @param  ...                   The variable arguments list.\r
+\r
+  @return The value returned by the EBC application we're going to run.\r
+\r
+**/\r
 STATIC\r
 UINT64\r
 EbcInterpret (\r
@@ -189,15 +228,13 @@ EbcInterpret (
 \r
 \r
 /**\r
-  IPF implementation.\r
   Begin executing an EBC image. The address of the entry point is passed\r
   in via a processor register, so we'll need to make a call to get the\r
   value.\r
 \r
-  @param  ImageHandle            image handle for the EBC application we're\r
-                                 executing\r
-  @param  SystemTable            standard system table passed into an driver's\r
-                                 entry point\r
+  @param  ImageHandle      image handle for the EBC application we're executing\r
+  @param  SystemTable      standard system table passed into an driver's entry\r
+                           point\r
 \r
   @return The value returned by the EBC application we're going to run.\r
 \r
@@ -312,13 +349,18 @@ ExecuteEbcImageEntryPoint (
 /**\r
   Create thunks for an EBC image entry point, or an EBC protocol service.\r
 \r
-  @param  ImageHandle            Image handle for the EBC image. If not null, then\r
-                                 we're creating a thunk for an image entry point.\r
-  @param  EbcEntryPoint          Address of the EBC code that the thunk is to call\r
-  @param  Thunk                  Returned thunk we create here\r
-  @param  Flags                  Flags indicating options for creating the thunk\r
+  @param  ImageHandle           Image handle for the EBC image. If not null, then\r
+                                we're creating a thunk for an image entry point.\r
+  @param  EbcEntryPoint         Address of the EBC code that the thunk is to call\r
+  @param  Thunk                 Returned thunk we create here\r
+  @param  Flags                 Flags indicating options for creating the thunk\r
 \r
-  @return Standard EFI status.\r
+  @retval EFI_SUCCESS           The thunk was created successfully.\r
+  @retval EFI_INVALID_PARAMETER The parameter of EbcEntryPoint is not 16-bit\r
+                                aligned.\r
+  @retval EFI_OUT_OF_RESOURCES  There is not enough memory to created the EBC\r
+                                Thunk.\r
+  @retval EFI_BUFFER_TOO_SMALL  EBC_THUNK_SIZE is not larger enough.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -334,11 +376,11 @@ EbcCreateThunks (
   UINT64      Addr;\r
   UINT64      Code[3];    // Code in a bundle\r
   UINT64      RegNum;     // register number for MOVL\r
-  UINT64      I;          // bits of MOVL immediate data\r
-  UINT64      Ic;         // bits of MOVL immediate data\r
-  UINT64      Imm5c;      // bits of MOVL immediate data\r
-  UINT64      Imm9d;      // bits of MOVL immediate data\r
-  UINT64      Imm7b;      // bits of MOVL immediate data\r
+  UINT64      BitI;       // bits of MOVL immediate data\r
+  UINT64      BitIc;         // bits of MOVL immediate data\r
+  UINT64      BitImm5c;      // bits of MOVL immediate data\r
+  UINT64      BitImm9d;      // bits of MOVL immediate data\r
+  UINT64      BitImm7b;      // bits of MOVL immediate data\r
   UINT64      Br;         // branch register for loading and jumping\r
   UINT64      *Data64Ptr;\r
   UINT32      ThunkSize;\r
@@ -436,23 +478,23 @@ EbcCreateThunks (
   // Extract bits from the address for insertion into the instruction\r
   // i = Addr[63:63]\r
   //\r
-  I = RShiftU64 (Addr, 63) & 0x01;\r
+  BitI = RShiftU64 (Addr, 63) & 0x01;\r
   //\r
   // ic = Addr[21:21]\r
   //\r
-  Ic = RShiftU64 (Addr, 21) & 0x01;\r
+  BitIc = RShiftU64 (Addr, 21) & 0x01;\r
   //\r
   // imm5c = Addr[20:16] for 5 bits\r
   //\r
-  Imm5c = RShiftU64 (Addr, 16) & 0x1F;\r
+  BitImm5c = RShiftU64 (Addr, 16) & 0x1F;\r
   //\r
   // imm9d = Addr[15:7] for 9 bits\r
   //\r
-  Imm9d = RShiftU64 (Addr, 7) & 0x1FF;\r
+  BitImm9d = RShiftU64 (Addr, 7) & 0x1FF;\r
   //\r
   // imm7b = Addr[6:0] for 7 bits\r
   //\r
-  Imm7b = Addr & 0x7F;\r
+  BitImm7b = Addr & 0x7F;\r
 \r
   //\r
   // The EBC entry point will be put into r8, so r8 can be used here\r
@@ -463,12 +505,12 @@ EbcCreateThunks (
   //\r
   // Next is jumbled data, including opcode and rest of address\r
   //\r
-  Code[2] = LShiftU64 (Imm7b, 13);\r
+  Code[2] = LShiftU64 (BitImm7b, 13);\r
   Code[2] = Code[2] | LShiftU64 (0x00, 20);   // vc\r
-  Code[2] = Code[2] | LShiftU64 (Ic, 21);\r
-  Code[2] = Code[2] | LShiftU64 (Imm5c, 22);\r
-  Code[2] = Code[2] | LShiftU64 (Imm9d, 27);\r
-  Code[2] = Code[2] | LShiftU64 (I, 36);\r
+  Code[2] = Code[2] | LShiftU64 (BitIc, 21);\r
+  Code[2] = Code[2] | LShiftU64 (BitImm5c, 22);\r
+  Code[2] = Code[2] | LShiftU64 (BitImm9d, 27);\r
+  Code[2] = Code[2] | LShiftU64 (BitI, 36);\r
   Code[2] = Code[2] | LShiftU64 ((UINT64)MOVL_OPCODE, 37);\r
   Code[2] = Code[2] | LShiftU64 ((RegNum & 0x7F), 6);\r
 \r
@@ -501,23 +543,23 @@ EbcCreateThunks (
   // Extract bits from the address for insertion into the instruction\r
   // i = Addr[63:63]\r
   //\r
-  I = RShiftU64 (Addr, 63) & 0x01;\r
+  BitI = RShiftU64 (Addr, 63) & 0x01;\r
   //\r
   // ic = Addr[21:21]\r
   //\r
-  Ic = RShiftU64 (Addr, 21) & 0x01;\r
+  BitIc = RShiftU64 (Addr, 21) & 0x01;\r
   //\r
   // imm5c = Addr[20:16] for 5 bits\r
   //\r
-  Imm5c = RShiftU64 (Addr, 16) & 0x1F;\r
+  BitImm5c = RShiftU64 (Addr, 16) & 0x1F;\r
   //\r
   // imm9d = Addr[15:7] for 9 bits\r
   //\r
-  Imm9d = RShiftU64 (Addr, 7) & 0x1FF;\r
+  BitImm9d = RShiftU64 (Addr, 7) & 0x1FF;\r
   //\r
   // imm7b = Addr[6:0] for 7 bits\r
   //\r
-  Imm7b = Addr & 0x7F;\r
+  BitImm7b = Addr & 0x7F;\r
 \r
   //\r
   // Put the EBC entry point in r8, which is the location of the return value\r
@@ -528,12 +570,12 @@ EbcCreateThunks (
   //\r
   // Next is jumbled data, including opcode and rest of address\r
   //\r
-  Code[2] = LShiftU64 (Imm7b, 13);\r
+  Code[2] = LShiftU64 (BitImm7b, 13);\r
   Code[2] = Code[2] | LShiftU64 (0x00, 20);   // vc\r
-  Code[2] = Code[2] | LShiftU64 (Ic, 21);\r
-  Code[2] = Code[2] | LShiftU64 (Imm5c, 22);\r
-  Code[2] = Code[2] | LShiftU64 (Imm9d, 27);\r
-  Code[2] = Code[2] | LShiftU64 (I, 36);\r
+  Code[2] = Code[2] | LShiftU64 (BitIc, 21);\r
+  Code[2] = Code[2] | LShiftU64 (BitImm5c, 22);\r
+  Code[2] = Code[2] | LShiftU64 (BitImm9d, 27);\r
+  Code[2] = Code[2] | LShiftU64 (BitI, 36);\r
   Code[2] = Code[2] | LShiftU64 ((UINT64)MOVL_OPCODE, 37);\r
   Code[2] = Code[2] | LShiftU64 ((RegNum & 0x7F), 6);\r
 \r
@@ -573,23 +615,23 @@ EbcCreateThunks (
   // Extract bits from the address for insertion into the instruction\r
   // i = Addr[63:63]\r
   //\r
-  I = RShiftU64 (Addr, 63) & 0x01;\r
+  BitI = RShiftU64 (Addr, 63) & 0x01;\r
   //\r
   // ic = Addr[21:21]\r
   //\r
-  Ic = RShiftU64 (Addr, 21) & 0x01;\r
+  BitIc = RShiftU64 (Addr, 21) & 0x01;\r
   //\r
   // imm5c = Addr[20:16] for 5 bits\r
   //\r
-  Imm5c = RShiftU64 (Addr, 16) & 0x1F;\r
+  BitImm5c = RShiftU64 (Addr, 16) & 0x1F;\r
   //\r
   // imm9d = Addr[15:7] for 9 bits\r
   //\r
-  Imm9d = RShiftU64 (Addr, 7) & 0x1FF;\r
+  BitImm9d = RShiftU64 (Addr, 7) & 0x1FF;\r
   //\r
   // imm7b = Addr[6:0] for 7 bits\r
   //\r
-  Imm7b = Addr & 0x7F;\r
+  BitImm7b = Addr & 0x7F;\r
 \r
   //\r
   // Put it in r31, a scratch register\r
@@ -599,12 +641,12 @@ EbcCreateThunks (
   //\r
   // Next is jumbled data, including opcode and rest of address\r
   //\r
-  Code[2] =   LShiftU64(Imm7b, 13);\r
+  Code[2] =   LShiftU64(BitImm7b, 13);\r
   Code[2] = Code[2] | LShiftU64 (0x00, 20);   // vc\r
-  Code[2] = Code[2] | LShiftU64 (Ic, 21);\r
-  Code[2] = Code[2] | LShiftU64 (Imm5c, 22);\r
-  Code[2] = Code[2] | LShiftU64 (Imm9d, 27);\r
-  Code[2] = Code[2] | LShiftU64 (I, 36);\r
+  Code[2] = Code[2] | LShiftU64 (BitIc, 21);\r
+  Code[2] = Code[2] | LShiftU64 (BitImm5c, 22);\r
+  Code[2] = Code[2] | LShiftU64 (BitImm9d, 27);\r
+  Code[2] = Code[2] | LShiftU64 (BitI, 36);\r
   Code[2] = Code[2] | LShiftU64 ((UINT64)MOVL_OPCODE, 37);\r
   Code[2] = Code[2] | LShiftU64 ((RegNum & 0x7F), 6);\r
 \r
@@ -667,13 +709,16 @@ EbcCreateThunks (
   Given raw bytes of Itanium based code, format them into a bundle and\r
   write them out.\r
 \r
-  @param  MemPtr                 pointer to memory location to write the bundles to\r
-  @param  Template               5-bit template\r
-  @param  Slot0-2                instruction slot data for the bundle\r
+  @param  MemPtr                 pointer to memory location to write the bundles\r
+                                 to.\r
+  @param  Template               5-bit template.\r
+  @param  Slot0                  Instruction slot 0 data for the bundle.\r
+  @param  Slot1                  Instruction slot 1 data for the bundle.\r
+  @param  Slot2                  Instruction slot 2 data for the bundle.\r
 \r
   @retval EFI_INVALID_PARAMETER  Pointer is not aligned\r
-  @retval      No                more than 5 bits in template\r
-  @retval      More              than 41 bits used in code\r
+  @retval EFI_INVALID_PARAMETER  No more than 5 bits in template\r
+  @retval EFI_INVALID_PARAMETER  More than 41 bits used in code\r
   @retval EFI_SUCCESS            All data is written.\r
 \r
 **/\r
@@ -745,13 +790,11 @@ WriteBundle (
   otherwise, set the VM->IP to target EBC code directly to avoid another VM\r
   be startup which cost time and stack space.\r
 \r
-  @param  VmPtr                  Pointer to a VM context.\r
-  @param  FuncAddr               Callee's address\r
-  @param  NewStackPointer        New stack pointer after the call\r
-  @param  FramePtr               New frame pointer after the call\r
-  @param  Size                   The size of call instruction\r
-\r
-  @return None.\r
+  @param  VmPtr            Pointer to a VM context.\r
+  @param  FuncAddr         Callee's address\r
+  @param  NewStackPointer  New stack pointer after the call\r
+  @param  FramePtr         New frame pointer after the call\r
+  @param  Size             The size of call instruction\r
 \r
 **/\r
 VOID\r
index 7b554f3e65a7b39b6579801bca8268e11333fea9..9d8de3eee25a51deb7e6547ed72c4d5c072df00e 100644 (file)
@@ -38,10 +38,4 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 //\r
 #define MOVL_OPCODE 0x06\r
 \r
-VOID\r
-EbcAsmLLCALLEX (\r
-  IN UINTN    CallAddr,\r
-  IN UINTN    EbcSp\r
-  );\r
-\r
 #endif\r
index 90db1669d9a1dc8cddd327ed891c6d6489fe5921..d72facd8e2c970ee532193ebd7e9f16f676c69e0 100644 (file)
@@ -27,28 +27,20 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #define STACK_REMAIN_SIZE (1024 * 4)\r
 \r
+\r
+/**\r
+  Pushes a 64 bit unsigned value to the VM stack.\r
+\r
+  @param VmPtr  The pointer to current VM context.\r
+  @param Arg    The value to be pushed.\r
+\r
+**/\r
 STATIC\r
 VOID\r
 PushU64 (\r
-  VM_CONTEXT *VmPtr,\r
-  UINT64     Arg\r
+  IN VM_CONTEXT *VmPtr,\r
+  IN UINT64     Arg\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  Push a 64 bit unsigned value to the VM stack.\r
-\r
-Arguments:\r
-\r
-  VmPtr   -  The pointer to current VM context.\r
-  Arg     -  The value to be pushed\r
-\r
-Returns:\r
-\r
-  VOID\r
-\r
---*/\r
 {\r
   //\r
   // Advance the VM stack down, and then copy the argument to the stack.\r
@@ -69,28 +61,45 @@ Returns:
   calling convention, so the first four arguments are passed by rcx, rdx,\r
   r8, and r9, while other arguments are passed in stack.\r
 \r
+  @param  Arg1                  The 1st argument.\r
+  @param  Arg2                  The 2nd argument.\r
+  @param  Arg3                  The 3rd argument.\r
+  @param  Arg4                  The 4th argument.\r
+  @param  Arg5                  The 5th argument.\r
+  @param  Arg6                  The 6th argument.\r
+  @param  Arg7                  The 7th argument.\r
+  @param  Arg8                  The 8th argument.\r
+  @param  Arg9                  The 9th argument.\r
+  @param  Arg10                 The 10th argument.\r
+  @param  Arg11                 The 11th argument.\r
+  @param  Arg12                 The 12th argument.\r
+  @param  Arg13                 The 13th argument.\r
+  @param  Arg14                 The 14th argument.\r
+  @param  Arg15                 The 15th argument.\r
+  @param  Arg16                 The 16th argument.\r
+\r
   @return The value returned by the EBC application we're going to run.\r
 \r
 **/\r
 STATIC\r
 UINT64\r
 EbcInterpret (\r
-  UINTN      Arg1,\r
-  UINTN      Arg2,\r
-  UINTN      Arg3,\r
-  UINTN      Arg4,\r
-  UINTN      Arg5,\r
-  UINTN      Arg6,\r
-  UINTN      Arg7,\r
-  UINTN      Arg8,\r
-  UINTN      Arg9,\r
-  UINTN      Arg10,\r
-  UINTN      Arg11,\r
-  UINTN      Arg12,\r
-  UINTN      Arg13,\r
-  UINTN      Arg14,\r
-  UINTN      Arg15,\r
-  UINTN      Arg16\r
+  IN OUT UINTN      Arg1,\r
+  IN OUT UINTN      Arg2,\r
+  IN OUT UINTN      Arg3,\r
+  IN OUT UINTN      Arg4,\r
+  IN OUT UINTN      Arg5,\r
+  IN OUT UINTN      Arg6,\r
+  IN OUT UINTN      Arg7,\r
+  IN OUT UINTN      Arg8,\r
+  IN OUT UINTN      Arg9,\r
+  IN OUT UINTN      Arg10,\r
+  IN OUT UINTN      Arg11,\r
+  IN OUT UINTN      Arg12,\r
+  IN OUT UINTN      Arg13,\r
+  IN OUT UINTN      Arg14,\r
+  IN OUT UINTN      Arg15,\r
+  IN OUT UINTN      Arg16\r
   )\r
 {\r
   //\r
@@ -328,13 +337,20 @@ ExecuteEbcImageEntryPoint (
 \r
 \r
 /**\r
-  Create an IA32 thunk for the given EBC entry point.\r
+  Create thunks for an EBC image entry point, or an EBC protocol service.\r
 \r
-  @param  ImageHandle      Handle of image for which this thunk is being created\r
-  @param  EbcEntryPoint    Address of the EBC code that the thunk is to call\r
-  @param  Thunk            Returned thunk we create here\r
+  @param  ImageHandle           Image handle for the EBC image. If not null, then\r
+                                we're creating a thunk for an image entry point.\r
+  @param  EbcEntryPoint         Address of the EBC code that the thunk is to call\r
+  @param  Thunk                 Returned thunk we create here\r
+  @param  Flags                 Flags indicating options for creating the thunk\r
 \r
-  @return Standard EFI status.\r
+  @retval EFI_SUCCESS           The thunk was created successfully.\r
+  @retval EFI_INVALID_PARAMETER The parameter of EbcEntryPoint is not 16-bit\r
+                                aligned.\r
+  @retval EFI_OUT_OF_RESOURCES  There is not enough memory to created the EBC\r
+                                Thunk.\r
+  @retval EFI_BUFFER_TOO_SMALL  EBC_THUNK_SIZE is not larger enough.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -347,7 +363,7 @@ EbcCreateThunks (
 {\r
   UINT8       *Ptr;\r
   UINT8       *ThunkBase;\r
-  UINT32      I;\r
+  UINT32      Index;\r
   UINT64      Addr;\r
   INT32       Size;\r
   INT32       ThunkSize;\r
@@ -390,7 +406,7 @@ EbcCreateThunks (
   Ptr++;\r
   Size--;\r
   Addr = (UINT64) 0xCA112EBCCA112EBCULL;\r
-  for (I = 0; I < sizeof (Addr); I++) {\r
+  for (Index = 0; Index < sizeof (Addr); Index++) {\r
     *Ptr = (UINT8) (UINTN) Addr;\r
     Addr >>= 8;\r
     Ptr++;\r
@@ -410,7 +426,7 @@ EbcCreateThunks (
   Ptr++;\r
   Size--;\r
   Addr = (UINT64) EbcEntryPoint;\r
-  for (I = 0; I < sizeof (Addr); I++) {\r
+  for (Index = 0; Index < sizeof (Addr); Index++) {\r
     *Ptr = (UINT8) (UINTN) Addr;\r
     Addr >>= 8;\r
     Ptr++;\r
@@ -438,7 +454,7 @@ EbcCreateThunks (
   *Ptr = 0xBB;\r
   Ptr++;\r
   Size--;\r
-  for (I = 0; I < sizeof (Addr); I++) {\r
+  for (Index = 0; Index < sizeof (Addr); Index++) {\r
     *Ptr = (UINT8) Addr;\r
     Addr >>= 8;\r
     Ptr++;\r
@@ -487,8 +503,6 @@ EbcCreateThunks (
   @param  FramePtr         New frame pointer after the call\r
   @param  Size             The size of call instruction\r
 \r
-  @return None.\r
-\r
 **/\r
 VOID\r
 EbcLLCALLEX (\r