]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/EbcDxe/EbcExecute.c
Clean up the private GUID definition in module Level.
[mirror_edk2.git] / MdeModulePkg / Universal / EbcDxe / EbcExecute.c
index 29fcb2c418cdda69a62b79a1fc4ae295ef7f720b..07e2f0a9f7fcdf0ca7038a2f07bf388068359c53 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Contains code that implements the virtual machine.\r
 \r
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
 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
@@ -1344,12 +1344,6 @@ CONST VM_TABLE_ENTRY           mVmOpcodeTable[] = {
 //\r
 CONST UINT8                    mJMPLen[] = { 2, 2, 6, 10 };\r
 \r
-//\r
-// Simple Debugger Protocol GUID\r
-//\r
-EFI_GUID mEbcSimpleDebuggerProtocolGuid = EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL_GUID;\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
@@ -1365,6 +1359,7 @@ EFI_GUID mEbcSimpleDebuggerProtocolGuid = EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL_GUID;
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 EbcExecuteInstructions (\r
   IN EFI_EBC_VM_TEST_PROTOCOL *This,\r
   IN VM_CONTEXT               *VmPtr,\r
@@ -1452,7 +1447,7 @@ EbcExecute (
   //\r
   DEBUG_CODE_BEGIN ();\r
     Status = gBS->LocateProtocol (\r
-                    &mEbcSimpleDebuggerProtocolGuid,\r
+                    &gEfiEbcSimpleDebuggerProtocolGuid,\r
                     NULL,\r
                     (VOID **) &EbcSimpleDebugger\r
                     );\r
@@ -1718,7 +1713,7 @@ ExecuteMOVxx (
     //\r
     // Not indirect source: MOVxx {@}Rx, Ry [Index]\r
     //\r
-    Data64 = VmPtr->Gpr[OPERAND2_REGNUM (Operands)] + Index64Op2;\r
+    Data64 = (UINT64) (VmPtr->Gpr[OPERAND2_REGNUM (Operands)] + Index64Op2);\r
     //\r
     // Did Operand2 have an index? If so, treat as two signed values since\r
     // indexes are signed values.\r
@@ -2005,7 +2000,7 @@ ExecuteJMP (
     // 64-bit immediate data is full address. Read the immediate data,\r
     // check for alignment, and jump absolute.\r
     //\r
-    Data64 = VmReadImmed64 (VmPtr, 2);\r
+    Data64 = (UINT64) VmReadImmed64 (VmPtr, 2);\r
     if (!IS_ALIGNED ((UINTN) Data64, sizeof (UINT16))) {\r
       EbcDebugSignalException (\r
         EXCEPT_EBC_ALIGNMENT_CHECK,\r
@@ -2049,7 +2044,7 @@ ExecuteJMP (
   if (OPERAND1_REGNUM (Operand) == 0) {\r
     Data64 = 0;\r
   } else {\r
-    Data64 = OPERAND1_REGDATA (VmPtr, Operand);\r
+    Data64 = (UINT64) OPERAND1_REGDATA (VmPtr, Operand);\r
   }\r
   //\r
   // Decode the forms\r
@@ -2264,7 +2259,7 @@ ExecuteMOVI (
     } else if ((Operands & MOVI_M_MOVEWIDTH) == MOVI_MOVEWIDTH32) {\r
       VmWriteMem32 (VmPtr, (UINTN) Op1, (UINT32) ImmData64);\r
     } else {\r
-      VmWriteMem64 (VmPtr, (UINTN) Op1, ImmData64);\r
+      VmWriteMem64 (VmPtr, (UINTN) Op1, (UINT64) ImmData64);\r
     }\r
   }\r
   //\r
@@ -2367,7 +2362,7 @@ ExecuteMOVIn (
     // Get the address\r
     //\r
     Op1 = (UINT64) VmPtr->Gpr[OPERAND1_REGNUM (Operands)] + Index16;\r
-    VmWriteMemN (VmPtr, (UINTN) Op1, (INTN) ImmedIndex64);\r
+    VmWriteMemN (VmPtr, (UINTN) Op1, (UINTN)(INTN) ImmedIndex64);\r
   }\r
   //\r
   // Advance the instruction pointer\r
@@ -2551,9 +2546,9 @@ ExecuteMOVsnw (
   //\r
   // Get the data from the source.\r
   //\r
-  Op2 = (INT64) ((INTN) (VmPtr->Gpr[OPERAND2_REGNUM (Operands)] + Op2Index));\r
+  Op2 = (UINT64) (VmPtr->Gpr[OPERAND2_REGNUM (Operands)] + Op2Index);\r
   if (OPERAND2_INDIRECT (Operands)) {\r
-    Op2 = (INT64) (INTN) VmReadMemN (VmPtr, (UINTN) Op2);\r
+    Op2 = (UINT64) VmReadMemN (VmPtr, (UINTN) Op2);\r
   }\r
   //\r
   // Now write back the result.\r
@@ -2644,9 +2639,9 @@ ExecuteMOVsnd (
   //\r
   // Get the data from the source.\r
   //\r
-  Op2 = (INT64) ((INTN) (VmPtr->Gpr[OPERAND2_REGNUM (Operands)] + Op2Index));\r
+  Op2 = (UINT64) (VmPtr->Gpr[OPERAND2_REGNUM (Operands)] + Op2Index);\r
   if (OPERAND2_INDIRECT (Operands)) {\r
-    Op2 = (INT64) (INTN) VmReadMemN (VmPtr, (UINTN) Op2);\r
+    Op2 = (UINT64) VmReadMemN (VmPtr, (UINTN) Op2);\r
   }\r
   //\r
   // Now write back the result.\r
@@ -3698,7 +3693,7 @@ ExecuteDIVU (
     // Get the destination register\r
     //\r
     if ((*VmPtr->Ip & DATAMANIP_M_64) != 0) {\r
-      return (UINT64) (DivU64x64Remainder ((INT64)Op1, (INT64)Op2, &Remainder));\r
+      return (UINT64) (DivU64x64Remainder (Op1, Op2, &Remainder));\r
     } else {\r
       return (UINT64) ((UINT32) Op1 / (UINT32) Op2);\r
     }\r
@@ -4195,7 +4190,7 @@ ExecuteDataManip (
   // Get operand1 (destination and sometimes also an actual operand)\r
   // of form {@}R1\r
   //\r
-  Op1 = VmPtr->Gpr[OPERAND1_REGNUM (Operands)];\r
+  Op1 = (UINT64) VmPtr->Gpr[OPERAND1_REGNUM (Operands)];\r
   if (OPERAND1_INDIRECT (Operands)) {\r
     if ((Opcode & DATAMANIP_M_64) != 0) {\r
       Op1 = VmReadMem64 (VmPtr, (UINTN) Op1);\r
@@ -4238,7 +4233,7 @@ ExecuteDataManip (
   // Write back the result.\r
   //\r
   if (OPERAND1_INDIRECT (Operands)) {\r
-    Op1 = VmPtr->Gpr[OPERAND1_REGNUM (Operands)];\r
+    Op1 = (UINT64) VmPtr->Gpr[OPERAND1_REGNUM (Operands)];\r
     if ((Opcode & DATAMANIP_M_64) != 0) {\r
       VmWriteMem64 (VmPtr, (UINTN) Op1, Op2);\r
     } else {\r
@@ -4573,7 +4568,7 @@ VmReadIndex64 (
   //\r
   ConstUnits = ARShiftU64 (((Index &~0xF000000000000000ULL) & Mask), (UINTN)NBits);\r
 \r
-  Offset  = MultU64x64 (NaturalUnits, sizeof (UINTN)) + ConstUnits;\r
+  Offset  = MultU64x64 ((UINT64) NaturalUnits, sizeof (UINTN)) + ConstUnits;\r
 \r
   //\r
   // Now set the sign\r
@@ -4781,7 +4776,6 @@ VmWriteMem64 (
   )\r
 {\r
   EFI_STATUS  Status;\r
-  UINT32      Data32;\r
 \r
   //\r
   // Convert the address if it's in the stack gap\r
@@ -4803,8 +4797,7 @@ VmWriteMem64 (
     }\r
 \r
     MemoryFence ();\r
-    Data32 = (UINT32) (((UINT32 *) &Data)[1]);\r
-    if ((Status = VmWriteMem32 (VmPtr, Addr + sizeof (UINT32), Data32)) != EFI_SUCCESS) {\r
+    if ((Status = VmWriteMem32 (VmPtr, Addr + sizeof (UINT32), (UINT32) RShiftU64(Data, 32))) != EFI_SUCCESS) {\r
       return Status;\r
     }\r
 \r
@@ -5259,9 +5252,9 @@ VmReadMem64 (
   //\r
   // Return unaligned data. Assume little endian.\r
   //\r
-  Data    = (UINT64) VmReadMem32 (VmPtr, Addr);\r
-  Data32  = VmReadMem32 (VmPtr, Addr + sizeof (UINT32));\r
-  *(UINT32 *) ((UINT32 *) &Data + 1) = Data32;\r
+  Data32 = VmReadMem32 (VmPtr, Addr);\r
+  Data  = (UINT64) VmReadMem32 (VmPtr, Addr + sizeof (UINT32));\r
+  Data  = LShiftU64 (Data, 32) | Data32;\r
   return Data;\r
 }\r
 \r