]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/EbcDxe/EbcInt.h
MdeModulePkg/RamDiskDxe: Use BaseLib linked list iteration macros
[mirror_edk2.git] / MdeModulePkg / Universal / EbcDxe / EbcInt.h
index 5ad58c0ffed6cc8f59227aa9b78c98c49cc351ab..16f5ed4eb1a516e8e97ac1163c72e7cb55fb9aef 100644 (file)
@@ -2,14 +2,8 @@
   Main routines for the EBC interpreter.  Includes the initialization and\r
   main interpreter routines.\r
 \r
-Copyright (c) 2006 - 2008, Intel Corporation. <BR>\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
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -21,53 +15,21 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #include <Protocol/DebugSupport.h>\r
 #include <Protocol/Ebc.h>\r
+#include <Protocol/EbcVmTest.h>\r
+#include <Protocol/EbcSimpleDebugger.h>\r
+#include <Protocol/PeCoffImageEmulator.h>\r
 \r
 #include <Library/BaseLib.h>\r
+#include <Library/CacheMaintenanceLib.h>\r
 #include <Library/DebugLib.h>\r
+#include <Library/PeCoffLib.h>\r
 #include <Library/UefiDriverEntryPoint.h>\r
 #include <Library/BaseMemoryLib.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
 \r
-typedef INT64   VM_REGISTER;\r
-typedef UINT8   *VMIP;      // instruction pointer for the VM\r
-typedef UINT32  EXCEPTION_FLAGS;\r
-\r
-typedef struct {\r
-  VM_REGISTER       R[8];                   // General purpose registers.\r
-  UINT64            Flags;                  // Flags register:\r
-                                            //   0   Set to 1 if the result of the last compare was true\r
-                                            //   1  Set to 1 if stepping\r
-                                            //   2..63 Reserved.\r
-  VMIP              Ip;                     // Instruction pointer.\r
-  UINTN             LastException;          //\r
-  EXCEPTION_FLAGS   ExceptionFlags;         // to keep track of exceptions\r
-  UINT32            StopFlags;\r
-  UINT32            CompilerVersion;        // via break(6)\r
-  UINTN             HighStackBottom;        // bottom of the upper stack\r
-  UINTN             LowStackTop;            // top of the lower stack\r
-  UINT64            StackRetAddr;           // location of final return address on stack\r
-  UINTN             *StackMagicPtr;         // pointer to magic value on stack to detect corruption\r
-  EFI_HANDLE        ImageHandle;            // for this EBC driver\r
-  EFI_SYSTEM_TABLE  *SystemTable;           // for debugging only\r
-  UINTN             LastAddrConverted;      // for debug\r
-  UINTN             LastAddrConvertedValue; // for debug\r
-  VOID              *FramePtr;\r
-  VOID              *EntryPoint;            // entry point of EBC image\r
-  UINTN             ImageBase;\r
-  VOID              *StackPool;\r
-  VOID              *StackTop;\r
-} VM_CONTEXT;\r
-\r
 extern VM_CONTEXT                    *mVmPtr;\r
 \r
-//\r
-// Bits of exception flags field of VM context\r
-//\r
-#define EXCEPTION_FLAG_FATAL    0x80000000  // can't continue\r
-#define EXCEPTION_FLAG_ERROR    0x40000000  // bad, but try to continue\r
-#define EXCEPTION_FLAG_WARNING  0x20000000  // harmless problem\r
-#define EXCEPTION_FLAG_NONE     0x00000000  // for normal return\r
 //\r
 // Flags passed to the internal create-thunks function.\r
 //\r
@@ -124,28 +86,6 @@ EbcAddImageThunk (
   IN UINT32          ThunkSize\r
   );\r
 \r
-//\r
-// 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
-  IN EXCEPTION_FLAGS                      ExceptionFlags,\r
-  IN VM_CONTEXT                           *VmPtr\r
-  );\r
-\r
 //\r
 // Define a constant of how often to call the debugger periodic callback\r
 // function.\r
@@ -173,21 +113,6 @@ EbcLLGetEbcEntryPoint (
   VOID\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
   This function is called to execute an EBC CALLEX instruction.\r
   This instruction requires that we thunk out to external native\r
@@ -200,8 +125,10 @@ EbcLLGetStackPointer (
   @param  EbcSp        The new EBC stack pointer.\r
   @param  FramePtr     The frame pointer.\r
 \r
+  @return The unmodified value returned by the native code.\r
+\r
 **/\r
-VOID\r
+INT64\r
 EFIAPI\r
 EbcLLCALLEXNative (\r
   IN UINTN        CallAddr,\r
@@ -233,21 +160,6 @@ EbcLLCALLEX (
   IN UINT8        Size\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
   Returns the stack index and buffer assosicated with the Handle parameter.\r
 \r
@@ -317,65 +229,6 @@ ReturnEBCStackByHandle(
   IN EFI_HANDLE Handle\r
   );\r
 \r
-\r
-//\r
-// Defines for a simple EBC debugger interface\r
-//\r
-typedef struct _EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL;\r
-\r
-#define EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL_GUID \\r
-  { \\r
-    0x2a72d11e, 0x7376, 0x40f6, { 0x9c, 0x68, 0x23, 0xfa, 0x2f, 0xe3, 0x63, 0xf1 } \\r
-  }\r
-\r
-typedef\r
-EFI_STATUS\r
-(*EBC_DEBUGGER_SIGNAL_EXCEPTION) (\r
-  IN EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL           *This,\r
-  IN VM_CONTEXT                                 *VmPtr,\r
-  IN EFI_EXCEPTION_TYPE                         ExceptionType\r
-  );\r
-\r
-typedef\r
-VOID\r
-(*EBC_DEBUGGER_DEBUG) (\r
-  IN EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL           *This,\r
-  IN VM_CONTEXT                                 *VmPtr\r
-  );\r
-\r
-typedef\r
-UINT32\r
-(*EBC_DEBUGGER_DASM) (\r
-  IN EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL           *This,\r
-  IN VM_CONTEXT                                 *VmPtr,\r
-  IN UINT16                                     *DasmString OPTIONAL,\r
-  IN UINT32                                     DasmStringSize\r
-  );\r
-\r
-//\r
-// This interface allows you to configure the EBC debug support\r
-// driver. For example, turn on or off saving and printing of\r
-// delta VM even if called. Or to even disable the entire interface,\r
-// in which case all functions become no-ops.\r
-//\r
-typedef\r
-EFI_STATUS\r
-(*EBC_DEBUGGER_CONFIGURE) (\r
-  IN EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL           *This,\r
-  IN UINT32                                     ConfigId,\r
-  IN UINTN                                      ConfigValue\r
-  );\r
-\r
-//\r
-// Prototype for the actual EBC debug support protocol interface\r
-//\r
-struct _EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL {\r
-  EBC_DEBUGGER_DEBUG            Debugger;\r
-  EBC_DEBUGGER_SIGNAL_EXCEPTION SignalException;\r
-  EBC_DEBUGGER_DASM             Dasm;\r
-  EBC_DEBUGGER_CONFIGURE        Configure;\r
-};\r
-\r
 typedef struct {\r
   EFI_EBC_PROTOCOL  *This;\r
   VOID              *EntryPoint;\r
@@ -383,11 +236,25 @@ typedef struct {
   VM_CONTEXT        VmContext;\r
 } EFI_EBC_THUNK_DATA;\r
 \r
-#define EBC_PROTOCOL_PRIVATE_DATA_SIGNATURE EFI_SIGNATURE_32 ('e', 'b', 'c', 'p')\r
+#define EBC_PROTOCOL_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('e', 'b', 'c', 'p')\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
 \r
 \r
+/**\r
+  Allocates a buffer of type EfiBootServicesCode.\r
+\r
+  @param  AllocationSize        The number of bytes to allocate.\r
+\r
+  @return A pointer to the allocated buffer or NULL if allocation fails.\r
+\r
+**/\r
+VOID *\r
+EFIAPI\r
+EbcAllocatePoolForThunk (\r
+  IN UINTN  AllocationSize\r
+  );\r
+\r
 #endif // #ifndef _EBC_INT_H_\r