]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/EbcDxe/X64/EbcSupport.c
MdeModulePkg: Apply uncrustify changes
[mirror_edk2.git] / MdeModulePkg / Universal / EbcDxe / X64 / EbcSupport.c
index 25ca8dbc4cf7c52ea1084e1e8d3a247e37390daf..f9def551583af25f060d5e91358d385db0655c6a 100644 (file)
@@ -17,54 +17,54 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 //       based on whether or not a debugger is present, and other\r
 //       platform-specific configurations.\r
 //\r
-#define VM_STACK_SIZE   (1024 * 8)\r
+#define VM_STACK_SIZE  (1024 * 8)\r
 \r
-#define STACK_REMAIN_SIZE (1024 * 4)\r
+#define STACK_REMAIN_SIZE  (1024 * 4)\r
 \r
 //\r
 // This is instruction buffer used to create EBC thunk\r
 //\r
-#define EBC_ENTRYPOINT_SIGNATURE           0xAFAFAFAFAFAFAFAFull\r
-#define EBC_LL_EBC_ENTRYPOINT_SIGNATURE    0xFAFAFAFAFAFAFAFAull\r
+#define EBC_ENTRYPOINT_SIGNATURE         0xAFAFAFAFAFAFAFAFull\r
+#define EBC_LL_EBC_ENTRYPOINT_SIGNATURE  0xFAFAFAFAFAFAFAFAull\r
 UINT8  mInstructionBufferTemplate[] = {\r
   //\r
   // Add a magic code here to help the VM recognize the thunk..\r
   // mov rax, 0xca112ebcca112ebc  => 48 B8 BC 2E 11 CA BC 2E 11 CA\r
   //\r
-  0x48, 0xB8, 0xBC, 0x2E, 0x11, 0xCA, 0xBC, 0x2E, 0x11, 0xCA,\r
+  0x48,                                                    0xB8, 0xBC, 0x2E, 0x11, 0xCA, 0xBC, 0x2E, 0x11, 0xCA,\r
   //\r
   // Add code bytes to load up a processor register with the EBC entry point.\r
   //  mov r10, EbcEntryPoint  => 49 BA XX XX XX XX XX XX XX XX (To be fixed at runtime)\r
   // These 8 bytes of the thunk entry is the address of the EBC\r
   // entry point.\r
   //\r
-  0x49, 0xBA,\r
-    (UINT8)(EBC_ENTRYPOINT_SIGNATURE & 0xFF),\r
-    (UINT8)((EBC_ENTRYPOINT_SIGNATURE >> 8) & 0xFF),\r
-    (UINT8)((EBC_ENTRYPOINT_SIGNATURE >> 16) & 0xFF),\r
-    (UINT8)((EBC_ENTRYPOINT_SIGNATURE >> 24) & 0xFF),\r
-    (UINT8)((EBC_ENTRYPOINT_SIGNATURE >> 32) & 0xFF),\r
-    (UINT8)((EBC_ENTRYPOINT_SIGNATURE >> 40) & 0xFF),\r
-    (UINT8)((EBC_ENTRYPOINT_SIGNATURE >> 48) & 0xFF),\r
-    (UINT8)((EBC_ENTRYPOINT_SIGNATURE >> 56) & 0xFF),\r
+  0x49,                                                    0xBA,\r
+  (UINT8)(EBC_ENTRYPOINT_SIGNATURE & 0xFF),\r
+  (UINT8)((EBC_ENTRYPOINT_SIGNATURE >> 8) & 0xFF),\r
+  (UINT8)((EBC_ENTRYPOINT_SIGNATURE >> 16) & 0xFF),\r
+  (UINT8)((EBC_ENTRYPOINT_SIGNATURE >> 24) & 0xFF),\r
+  (UINT8)((EBC_ENTRYPOINT_SIGNATURE >> 32) & 0xFF),\r
+  (UINT8)((EBC_ENTRYPOINT_SIGNATURE >> 40) & 0xFF),\r
+  (UINT8)((EBC_ENTRYPOINT_SIGNATURE >> 48) & 0xFF),\r
+  (UINT8)((EBC_ENTRYPOINT_SIGNATURE >> 56) & 0xFF),\r
   //\r
   // Stick in a load of r11 with the address of appropriate VM function.\r
   //  mov r11, EbcLLEbcInterpret  => 49 BB XX XX XX XX XX XX XX XX (To be fixed at runtime)\r
   //\r
-  0x49, 0xBB,\r
-    (UINT8)(EBC_LL_EBC_ENTRYPOINT_SIGNATURE & 0xFF),\r
-    (UINT8)((EBC_LL_EBC_ENTRYPOINT_SIGNATURE >> 8) & 0xFF),\r
-    (UINT8)((EBC_LL_EBC_ENTRYPOINT_SIGNATURE >> 16) & 0xFF),\r
-    (UINT8)((EBC_LL_EBC_ENTRYPOINT_SIGNATURE >> 24) & 0xFF),\r
-    (UINT8)((EBC_LL_EBC_ENTRYPOINT_SIGNATURE >> 32) & 0xFF),\r
-    (UINT8)((EBC_LL_EBC_ENTRYPOINT_SIGNATURE >> 40) & 0xFF),\r
-    (UINT8)((EBC_LL_EBC_ENTRYPOINT_SIGNATURE >> 48) & 0xFF),\r
-    (UINT8)((EBC_LL_EBC_ENTRYPOINT_SIGNATURE >> 56) & 0xFF),\r
+  0x49,                                                    0xBB,\r
+  (UINT8)(EBC_LL_EBC_ENTRYPOINT_SIGNATURE & 0xFF),\r
+  (UINT8)((EBC_LL_EBC_ENTRYPOINT_SIGNATURE >> 8) & 0xFF),\r
+  (UINT8)((EBC_LL_EBC_ENTRYPOINT_SIGNATURE >> 16) & 0xFF),\r
+  (UINT8)((EBC_LL_EBC_ENTRYPOINT_SIGNATURE >> 24) & 0xFF),\r
+  (UINT8)((EBC_LL_EBC_ENTRYPOINT_SIGNATURE >> 32) & 0xFF),\r
+  (UINT8)((EBC_LL_EBC_ENTRYPOINT_SIGNATURE >> 40) & 0xFF),\r
+  (UINT8)((EBC_LL_EBC_ENTRYPOINT_SIGNATURE >> 48) & 0xFF),\r
+  (UINT8)((EBC_LL_EBC_ENTRYPOINT_SIGNATURE >> 56) & 0xFF),\r
   //\r
   // Stick in jump opcode bytes\r
   //  jmp r11 => 41 FF E3\r
   //\r
-  0x41, 0xFF, 0xE3,\r
+  0x41,                                                    0xFF, 0xE3,\r
 };\r
 \r
 /**\r
@@ -102,20 +102,19 @@ EbcLLExecuteEbcImageEntryPoint (
 **/\r
 VOID\r
 PushU64 (\r
-  IN VM_CONTEXT *VmPtr,\r
-  IN UINT64     Arg\r
+  IN VM_CONTEXT  *VmPtr,\r
+  IN UINT64      Arg\r
   )\r
 {\r
   //\r
   // Advance the VM stack down, and then copy the argument to the stack.\r
   // Hope it's aligned.\r
   //\r
-  VmPtr->Gpr[0] -= sizeof (UINT64);\r
-  *(UINT64 *) VmPtr->Gpr[0] = Arg;\r
+  VmPtr->Gpr[0]           -= sizeof (UINT64);\r
+  *(UINT64 *)VmPtr->Gpr[0] = Arg;\r
   return;\r
 }\r
 \r
-\r
 /**\r
   Begin executing an EBC image.\r
 \r
@@ -147,23 +146,23 @@ PushU64 (
 UINT64\r
 EFIAPI\r
 EbcInterpret (\r
-  IN UINTN      EntryPoint,\r
-  IN UINTN      Arg1,\r
-  IN UINTN      Arg2,\r
-  IN UINTN      Arg3,\r
-  IN UINTN      Arg4,\r
-  IN UINTN      Arg5,\r
-  IN UINTN      Arg6,\r
-  IN UINTN      Arg7,\r
-  IN UINTN      Arg8,\r
-  IN UINTN      Arg9,\r
-  IN UINTN      Arg10,\r
-  IN UINTN      Arg11,\r
-  IN UINTN      Arg12,\r
-  IN UINTN      Arg13,\r
-  IN UINTN      Arg14,\r
-  IN UINTN      Arg15,\r
-  IN UINTN      Arg16\r
+  IN UINTN  EntryPoint,\r
+  IN UINTN  Arg1,\r
+  IN UINTN  Arg2,\r
+  IN UINTN  Arg3,\r
+  IN UINTN  Arg4,\r
+  IN UINTN  Arg5,\r
+  IN UINTN  Arg6,\r
+  IN UINTN  Arg7,\r
+  IN UINTN  Arg8,\r
+  IN UINTN  Arg9,\r
+  IN UINTN  Arg10,\r
+  IN UINTN  Arg11,\r
+  IN UINTN  Arg12,\r
+  IN UINTN  Arg13,\r
+  IN UINTN  Arg14,\r
+  IN UINTN  Arg15,\r
+  IN UINTN  Arg16\r
   )\r
 {\r
   //\r
@@ -182,12 +181,12 @@ EbcInterpret (
   //\r
   // Now clear out our context\r
   //\r
-  ZeroMem ((VOID *) &VmContext, sizeof (VM_CONTEXT));\r
+  ZeroMem ((VOID *)&VmContext, sizeof (VM_CONTEXT));\r
 \r
   //\r
   // Set the VM instruction pointer to the correct location in memory.\r
   //\r
-  VmContext.Ip = (VMIP) Addr;\r
+  VmContext.Ip = (VMIP)Addr;\r
 \r
   //\r
   // Initialize the stack pointer for the EBC. Get the current system stack\r
@@ -198,14 +197,15 @@ EbcInterpret (
   // Adjust the VM's stack pointer down.\r
   //\r
 \r
-  Status = GetEBCStack((EFI_HANDLE)(UINTN)-1, &VmContext.StackPool, &StackIndex);\r
-  if (EFI_ERROR(Status)) {\r
+  Status = GetEBCStack ((EFI_HANDLE)(UINTN)-1, &VmContext.StackPool, &StackIndex);\r
+  if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
-  VmContext.StackTop = (UINT8*)VmContext.StackPool + (STACK_REMAIN_SIZE);\r
-  VmContext.Gpr[0] = (UINT64) ((UINT8*)VmContext.StackPool + STACK_POOL_SIZE);\r
-  VmContext.HighStackBottom = (UINTN) VmContext.Gpr[0];\r
-  VmContext.Gpr[0] -= sizeof (UINTN);\r
+\r
+  VmContext.StackTop        = (UINT8 *)VmContext.StackPool + (STACK_REMAIN_SIZE);\r
+  VmContext.Gpr[0]          = (UINT64)((UINT8 *)VmContext.StackPool + STACK_POOL_SIZE);\r
+  VmContext.HighStackBottom = (UINTN)VmContext.Gpr[0];\r
+  VmContext.Gpr[0]         -= sizeof (UINTN);\r
 \r
   //\r
   // Align the stack on a natural boundary.\r
@@ -215,46 +215,46 @@ EbcInterpret (
   //\r
   // Put a magic value in the stack gap, then adjust down again.\r
   //\r
-  *(UINTN *) (UINTN) (VmContext.Gpr[0]) = (UINTN) VM_STACK_KEY_VALUE;\r
-  VmContext.StackMagicPtr             = (UINTN *) (UINTN) VmContext.Gpr[0];\r
+  *(UINTN *)(UINTN)(VmContext.Gpr[0]) = (UINTN)VM_STACK_KEY_VALUE;\r
+  VmContext.StackMagicPtr             = (UINTN *)(UINTN)VmContext.Gpr[0];\r
 \r
   //\r
   // The stack upper to LowStackTop is belong to the VM.\r
   //\r
-  VmContext.LowStackTop   = (UINTN) VmContext.Gpr[0];\r
+  VmContext.LowStackTop = (UINTN)VmContext.Gpr[0];\r
 \r
   //\r
   // For the worst case, assume there are 4 arguments passed in registers, store\r
   // them to VM's stack.\r
   //\r
-  PushU64 (&VmContext, (UINT64) Arg16);\r
-  PushU64 (&VmContext, (UINT64) Arg15);\r
-  PushU64 (&VmContext, (UINT64) Arg14);\r
-  PushU64 (&VmContext, (UINT64) Arg13);\r
-  PushU64 (&VmContext, (UINT64) Arg12);\r
-  PushU64 (&VmContext, (UINT64) Arg11);\r
-  PushU64 (&VmContext, (UINT64) Arg10);\r
-  PushU64 (&VmContext, (UINT64) Arg9);\r
-  PushU64 (&VmContext, (UINT64) Arg8);\r
-  PushU64 (&VmContext, (UINT64) Arg7);\r
-  PushU64 (&VmContext, (UINT64) Arg6);\r
-  PushU64 (&VmContext, (UINT64) Arg5);\r
-  PushU64 (&VmContext, (UINT64) Arg4);\r
-  PushU64 (&VmContext, (UINT64) Arg3);\r
-  PushU64 (&VmContext, (UINT64) Arg2);\r
-  PushU64 (&VmContext, (UINT64) Arg1);\r
+  PushU64 (&VmContext, (UINT64)Arg16);\r
+  PushU64 (&VmContext, (UINT64)Arg15);\r
+  PushU64 (&VmContext, (UINT64)Arg14);\r
+  PushU64 (&VmContext, (UINT64)Arg13);\r
+  PushU64 (&VmContext, (UINT64)Arg12);\r
+  PushU64 (&VmContext, (UINT64)Arg11);\r
+  PushU64 (&VmContext, (UINT64)Arg10);\r
+  PushU64 (&VmContext, (UINT64)Arg9);\r
+  PushU64 (&VmContext, (UINT64)Arg8);\r
+  PushU64 (&VmContext, (UINT64)Arg7);\r
+  PushU64 (&VmContext, (UINT64)Arg6);\r
+  PushU64 (&VmContext, (UINT64)Arg5);\r
+  PushU64 (&VmContext, (UINT64)Arg4);\r
+  PushU64 (&VmContext, (UINT64)Arg3);\r
+  PushU64 (&VmContext, (UINT64)Arg2);\r
+  PushU64 (&VmContext, (UINT64)Arg1);\r
 \r
   //\r
   // Interpreter assumes 64-bit return address is pushed on the stack.\r
   // The x64 does not do this so pad the stack accordingly.\r
   //\r
-  PushU64 (&VmContext, (UINT64) 0);\r
-  PushU64 (&VmContext, (UINT64) 0x1234567887654321ULL);\r
+  PushU64 (&VmContext, (UINT64)0);\r
+  PushU64 (&VmContext, (UINT64)0x1234567887654321ULL);\r
 \r
   //\r
   // For x64, this is where we say our return address is\r
   //\r
-  VmContext.StackRetAddr  = (UINT64) VmContext.Gpr[0];\r
+  VmContext.StackRetAddr = (UINT64)VmContext.Gpr[0];\r
 \r
   //\r
   // We need to keep track of where the EBC stack starts. This way, if the EBC\r
@@ -279,11 +279,10 @@ EbcInterpret (
   //\r
   // Return the value in Gpr[7] unless there was an error\r
   //\r
-  ReturnEBCStack(StackIndex);\r
-  return (UINT64) VmContext.Gpr[7];\r
+  ReturnEBCStack (StackIndex);\r
+  return (UINT64)VmContext.Gpr[7];\r
 }\r
 \r
-\r
 /**\r
   Begin executing an EBC image.\r
 \r
@@ -298,9 +297,9 @@ EbcInterpret (
 UINT64\r
 EFIAPI\r
 ExecuteEbcImageEntryPoint (\r
-  IN UINTN                EntryPoint,\r
-  IN EFI_HANDLE           ImageHandle,\r
-  IN EFI_SYSTEM_TABLE     *SystemTable\r
+  IN UINTN             EntryPoint,\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
   )\r
 {\r
   //\r
@@ -319,7 +318,7 @@ ExecuteEbcImageEntryPoint (
   //\r
   // Now clear out our context\r
   //\r
-  ZeroMem ((VOID *) &VmContext, sizeof (VM_CONTEXT));\r
+  ZeroMem ((VOID *)&VmContext, sizeof (VM_CONTEXT));\r
 \r
   //\r
   // Save the image handle so we can track the thunks created for this image\r
@@ -330,52 +329,52 @@ ExecuteEbcImageEntryPoint (
   //\r
   // Set the VM instruction pointer to the correct location in memory.\r
   //\r
-  VmContext.Ip = (VMIP) Addr;\r
+  VmContext.Ip = (VMIP)Addr;\r
 \r
   //\r
   // Initialize the stack pointer for the EBC. Get the current system stack\r
   // pointer and adjust it down by the max needed for the interpreter.\r
   //\r
 \r
-  Status = GetEBCStack(ImageHandle, &VmContext.StackPool, &StackIndex);\r
-  if (EFI_ERROR(Status)) {\r
+  Status = GetEBCStack (ImageHandle, &VmContext.StackPool, &StackIndex);\r
+  if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
-  VmContext.StackTop = (UINT8*)VmContext.StackPool + (STACK_REMAIN_SIZE);\r
-  VmContext.Gpr[0] = (UINT64) ((UINT8*)VmContext.StackPool + STACK_POOL_SIZE);\r
-  VmContext.HighStackBottom = (UINTN) VmContext.Gpr[0];\r
-  VmContext.Gpr[0] -= sizeof (UINTN);\r
 \r
+  VmContext.StackTop        = (UINT8 *)VmContext.StackPool + (STACK_REMAIN_SIZE);\r
+  VmContext.Gpr[0]          = (UINT64)((UINT8 *)VmContext.StackPool + STACK_POOL_SIZE);\r
+  VmContext.HighStackBottom = (UINTN)VmContext.Gpr[0];\r
+  VmContext.Gpr[0]         -= sizeof (UINTN);\r
 \r
   //\r
   // Put a magic value in the stack gap, then adjust down again\r
   //\r
-  *(UINTN *) (UINTN) (VmContext.Gpr[0]) = (UINTN) VM_STACK_KEY_VALUE;\r
-  VmContext.StackMagicPtr             = (UINTN *) (UINTN) VmContext.Gpr[0];\r
+  *(UINTN *)(UINTN)(VmContext.Gpr[0]) = (UINTN)VM_STACK_KEY_VALUE;\r
+  VmContext.StackMagicPtr             = (UINTN *)(UINTN)VmContext.Gpr[0];\r
 \r
   //\r
   // Align the stack on a natural boundary\r
-  VmContext.Gpr[0] &= ~(VM_REGISTER)(sizeof(UINTN) - 1);\r
+  VmContext.Gpr[0] &= ~(VM_REGISTER)(sizeof (UINTN) - 1);\r
   //\r
-  VmContext.LowStackTop   = (UINTN) VmContext.Gpr[0];\r
+  VmContext.LowStackTop = (UINTN)VmContext.Gpr[0];\r
 \r
   //\r
   // Simply copy the image handle and system table onto the EBC stack.\r
   // Greatly simplifies things by not having to spill the args.\r
   //\r
-  PushU64 (&VmContext, (UINT64) SystemTable);\r
-  PushU64 (&VmContext, (UINT64) ImageHandle);\r
+  PushU64 (&VmContext, (UINT64)SystemTable);\r
+  PushU64 (&VmContext, (UINT64)ImageHandle);\r
 \r
   //\r
   // VM pushes 16-bytes for return address. Simulate that here.\r
   //\r
-  PushU64 (&VmContext, (UINT64) 0);\r
-  PushU64 (&VmContext, (UINT64) 0x1234567887654321ULL);\r
+  PushU64 (&VmContext, (UINT64)0);\r
+  PushU64 (&VmContext, (UINT64)0x1234567887654321ULL);\r
 \r
   //\r
   // For x64, this is where we say our return address is\r
   //\r
-  VmContext.StackRetAddr  = (UINT64) VmContext.Gpr[0];\r
+  VmContext.StackRetAddr = (UINT64)VmContext.Gpr[0];\r
 \r
   //\r
   // Entry function needn't access high stack context, simply\r
@@ -391,11 +390,10 @@ ExecuteEbcImageEntryPoint (
   //\r
   // Return the value in Gpr[7] unless there was an error\r
   //\r
-  ReturnEBCStack(StackIndex);\r
-  return (UINT64) VmContext.Gpr[7];\r
+  ReturnEBCStack (StackIndex);\r
+  return (UINT64)VmContext.Gpr[7];\r
 }\r
 \r
-\r
 /**\r
   Create thunks for an EBC image entry point, or an EBC protocol service.\r
 \r
@@ -415,31 +413,32 @@ ExecuteEbcImageEntryPoint (
 **/\r
 EFI_STATUS\r
 EbcCreateThunks (\r
-  IN EFI_HANDLE           ImageHandle,\r
-  IN VOID                 *EbcEntryPoint,\r
-  OUT VOID                **Thunk,\r
-  IN  UINT32              Flags\r
+  IN EFI_HANDLE  ImageHandle,\r
+  IN VOID        *EbcEntryPoint,\r
+  OUT VOID       **Thunk,\r
+  IN  UINT32     Flags\r
   )\r
 {\r
-  UINT8       *Ptr;\r
-  UINT8       *ThunkBase;\r
-  UINT32      Index;\r
-  INT32       ThunkSize;\r
+  UINT8   *Ptr;\r
+  UINT8   *ThunkBase;\r
+  UINT32  Index;\r
+  INT32   ThunkSize;\r
 \r
   //\r
   // Check alignment of pointer to EBC code\r
   //\r
-  if ((UINT32) (UINTN) EbcEntryPoint & 0x01) {\r
+  if ((UINT32)(UINTN)EbcEntryPoint & 0x01) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  ThunkSize = sizeof(mInstructionBufferTemplate);\r
+  ThunkSize = sizeof (mInstructionBufferTemplate);\r
 \r
-  Ptr = EbcAllocatePoolForThunk (sizeof(mInstructionBufferTemplate));\r
+  Ptr = EbcAllocatePoolForThunk (sizeof (mInstructionBufferTemplate));\r
 \r
   if (Ptr == NULL) {\r
     return EFI_OUT_OF_RESOURCES;\r
   }\r
+\r
   //\r
   //  Print(L"Allocate TH: 0x%X\n", (UINT32)Ptr);\r
   //\r
@@ -450,20 +449,21 @@ EbcCreateThunks (
   //\r
   // Give them the address of our buffer we're going to fix up\r
   //\r
-  *Thunk = (VOID *) Ptr;\r
+  *Thunk = (VOID *)Ptr;\r
 \r
   //\r
   // Copy whole thunk instruction buffer template\r
   //\r
-  CopyMem (Ptr, mInstructionBufferTemplate, sizeof(mInstructionBufferTemplate));\r
+  CopyMem (Ptr, mInstructionBufferTemplate, sizeof (mInstructionBufferTemplate));\r
 \r
   //\r
   // Patch EbcEntryPoint and EbcLLEbcInterpret\r
   //\r
-  for (Index = 0; Index < sizeof(mInstructionBufferTemplate) - sizeof(UINTN); Index++) {\r
+  for (Index = 0; Index < sizeof (mInstructionBufferTemplate) - sizeof (UINTN); Index++) {\r
     if (*(UINTN *)&Ptr[Index] == EBC_ENTRYPOINT_SIGNATURE) {\r
       *(UINTN *)&Ptr[Index] = (UINTN)EbcEntryPoint;\r
     }\r
+\r
     if (*(UINTN *)&Ptr[Index] == EBC_LL_EBC_ENTRYPOINT_SIGNATURE) {\r
       if ((Flags & FLAG_THUNK_ENTRY_POINT) != 0) {\r
         *(UINTN *)&Ptr[Index] = (UINTN)EbcLLExecuteEbcImageEntryPoint;\r
@@ -477,12 +477,11 @@ EbcCreateThunks (
   // Add the thunk to the list for this image. Do this last since the add\r
   // function flushes the cache for us.\r
   //\r
-  EbcAddImageThunk (ImageHandle, (VOID *) ThunkBase, ThunkSize);\r
+  EbcAddImageThunk (ImageHandle, (VOID *)ThunkBase, ThunkSize);\r
 \r
   return EFI_SUCCESS;\r
 }\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
@@ -500,60 +499,62 @@ EbcCreateThunks (
 **/\r
 VOID\r
 EbcLLCALLEX (\r
-  IN VM_CONTEXT   *VmPtr,\r
-  IN UINTN        FuncAddr,\r
-  IN UINTN        NewStackPointer,\r
-  IN VOID         *FramePtr,\r
-  IN UINT8        Size\r
+  IN VM_CONTEXT  *VmPtr,\r
+  IN UINTN       FuncAddr,\r
+  IN UINTN       NewStackPointer,\r
+  IN VOID        *FramePtr,\r
+  IN UINT8       Size\r
   )\r
 {\r
-  UINTN    IsThunk;\r
-  UINTN    TargetEbcAddr;\r
-  UINT8    InstructionBuffer[sizeof(mInstructionBufferTemplate)];\r
-  UINTN    Index;\r
-  UINTN    IndexOfEbcEntrypoint;\r
-\r
-  IsThunk       = 1;\r
-  TargetEbcAddr = 0;\r
+  UINTN  IsThunk;\r
+  UINTN  TargetEbcAddr;\r
+  UINT8  InstructionBuffer[sizeof (mInstructionBufferTemplate)];\r
+  UINTN  Index;\r
+  UINTN  IndexOfEbcEntrypoint;\r
+\r
+  IsThunk              = 1;\r
+  TargetEbcAddr        = 0;\r
   IndexOfEbcEntrypoint = 0;\r
 \r
   //\r
   // Processor specific code to check whether the callee is a thunk to EBC.\r
   //\r
-  CopyMem (InstructionBuffer, (VOID *)FuncAddr, sizeof(InstructionBuffer));\r
+  CopyMem (InstructionBuffer, (VOID *)FuncAddr, sizeof (InstructionBuffer));\r
   //\r
   // Fill the signature according to mInstructionBufferTemplate\r
   //\r
-  for (Index = 0; Index < sizeof(mInstructionBufferTemplate) - sizeof(UINTN); Index++) {\r
+  for (Index = 0; Index < sizeof (mInstructionBufferTemplate) - sizeof (UINTN); Index++) {\r
     if (*(UINTN *)&mInstructionBufferTemplate[Index] == EBC_ENTRYPOINT_SIGNATURE) {\r
       *(UINTN *)&InstructionBuffer[Index] = EBC_ENTRYPOINT_SIGNATURE;\r
-      IndexOfEbcEntrypoint = Index;\r
+      IndexOfEbcEntrypoint                = Index;\r
     }\r
+\r
     if (*(UINTN *)&mInstructionBufferTemplate[Index] == EBC_LL_EBC_ENTRYPOINT_SIGNATURE) {\r
       *(UINTN *)&InstructionBuffer[Index] = EBC_LL_EBC_ENTRYPOINT_SIGNATURE;\r
     }\r
   }\r
+\r
   //\r
   // Check if we need thunk to native\r
   //\r
-  if (CompareMem (InstructionBuffer, mInstructionBufferTemplate, sizeof(mInstructionBufferTemplate)) != 0) {\r
+  if (CompareMem (InstructionBuffer, mInstructionBufferTemplate, sizeof (mInstructionBufferTemplate)) != 0) {\r
     IsThunk = 0;\r
   }\r
 \r
-  if (IsThunk == 1){\r
+  if (IsThunk == 1) {\r
     //\r
     // The callee is a thunk to EBC, adjust the stack pointer down 16 bytes and\r
     // put our return address and frame pointer on the VM stack.\r
     // Then set the VM's IP to new EBC code.\r
     //\r
     VmPtr->Gpr[0] -= 8;\r
-    VmWriteMemN (VmPtr, (UINTN) VmPtr->Gpr[0], (UINTN) FramePtr);\r
-    VmPtr->FramePtr = (VOID *) (UINTN) VmPtr->Gpr[0];\r
-    VmPtr->Gpr[0] -= 8;\r
-    VmWriteMem64 (VmPtr, (UINTN) VmPtr->Gpr[0], (UINT64) (UINTN) (VmPtr->Ip + Size));\r
+    VmWriteMemN (VmPtr, (UINTN)VmPtr->Gpr[0], (UINTN)FramePtr);\r
+    VmPtr->FramePtr = (VOID *)(UINTN)VmPtr->Gpr[0];\r
+    VmPtr->Gpr[0]  -= 8;\r
+    VmWriteMem64 (VmPtr, (UINTN)VmPtr->Gpr[0], (UINT64)(UINTN)(VmPtr->Ip + Size));\r
 \r
-    CopyMem (&TargetEbcAddr, (UINT8 *)FuncAddr + IndexOfEbcEntrypoint, sizeof(UINTN));\r
-    VmPtr->Ip = (VMIP) (UINTN) TargetEbcAddr;\r
+    CopyMem (&TargetEbcAddr, (UINT8 *)FuncAddr + IndexOfEbcEntrypoint, sizeof (UINTN));\r
+    VmPtr->Ip = (VMIP)(UINTN)TargetEbcAddr;\r
   } else {\r
     //\r
     // The callee is not a thunk to EBC, call native code,\r
@@ -567,4 +568,3 @@ EbcLLCALLEX (
     VmPtr->Ip += Size;\r
   }\r
 }\r
-\r