]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/EbcDxe/Ipf/EbcSupport.c
Add doxygen style comments for functions in EBC module.
[mirror_edk2.git] / MdeModulePkg / Universal / EbcDxe / Ipf / EbcSupport.c
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