X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FEbcDxe%2FEbcInt.h;h=16f5ed4eb1a516e8e97ac1163c72e7cb55fb9aef;hp=becd7019748c42ca671254b37e81c56deacab552;hb=HEAD;hpb=34e4e297bf61ae304e6b9a339b3a6954dd7a668f diff --git a/MdeModulePkg/Universal/EbcDxe/EbcInt.h b/MdeModulePkg/Universal/EbcDxe/EbcInt.h index becd701974..646e3a613b 100644 --- a/MdeModulePkg/Universal/EbcDxe/EbcInt.h +++ b/MdeModulePkg/Universal/EbcDxe/EbcInt.h @@ -2,72 +2,33 @@ Main routines for the EBC interpreter. Includes the initialization and main interpreter routines. -Copyright (c) 2006 - 2008, Intel Corporation.
-All rights reserved. This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent **/ #ifndef _EBC_INT_H_ #define _EBC_INT_H_ - -#include +#include #include #include +#include +#include +#include #include +#include #include +#include #include #include #include #include -typedef INT64 VM_REGISTER; -typedef UINT8 *VMIP; // instruction pointer for the VM -typedef UINT32 EXCEPTION_FLAGS; +extern VM_CONTEXT *mVmPtr; -typedef struct { - VM_REGISTER R[8]; // General purpose registers. - UINT64 Flags; // Flags register: - // 0 Set to 1 if the result of the last compare was true - // 1 Set to 1 if stepping - // 2..63 Reserved. - VMIP Ip; // Instruction pointer. - UINTN LastException; // - EXCEPTION_FLAGS ExceptionFlags; // to keep track of exceptions - UINT32 StopFlags; - UINT32 CompilerVersion; // via break(6) - UINTN HighStackBottom; // bottom of the upper stack - UINTN LowStackTop; // top of the lower stack - UINT64 StackRetAddr; // location of final return address on stack - UINTN *StackMagicPtr; // pointer to magic value on stack to detect corruption - EFI_HANDLE ImageHandle; // for this EBC driver - EFI_SYSTEM_TABLE *SystemTable; // for debugging only - UINTN LastAddrConverted; // for debug - UINTN LastAddrConvertedValue; // for debug - VOID *FramePtr; - VOID *EntryPoint; // entry point of EBC image - UINTN ImageBase; - VOID *StackPool; - VOID *StackTop; -} VM_CONTEXT; - -extern VM_CONTEXT *mVmPtr; - -// -// Bits of exception flags field of VM context -// -#define EXCEPTION_FLAG_FATAL 0x80000000 // can't continue -#define EXCEPTION_FLAG_ERROR 0x40000000 // bad, but try to continue -#define EXCEPTION_FLAG_WARNING 0x20000000 // harmless problem -#define EXCEPTION_FLAG_NONE 0x00000000 // for normal return // // Flags passed to the internal create-thunks function. // @@ -98,10 +59,10 @@ extern VM_CONTEXT *mVmPtr; **/ EFI_STATUS EbcCreateThunks ( - IN EFI_HANDLE ImageHandle, - IN VOID *EbcEntryPoint, - OUT VOID **Thunk, - IN UINT32 Flags + IN EFI_HANDLE ImageHandle, + IN VOID *EbcEntryPoint, + OUT VOID **Thunk, + IN UINT32 Flags ); /** @@ -119,45 +80,24 @@ EbcCreateThunks ( **/ EFI_STATUS EbcAddImageThunk ( - IN EFI_HANDLE ImageHandle, - IN VOID *ThunkBuffer, - IN UINT32 ThunkSize - ); - -// -// The interpreter calls these when an exception is detected, -// or as a periodic callback. -// -/** - The VM interpreter calls this function when an exception is detected. - - @param ExceptionType Specifies the processor exception detected. - @param ExceptionFlags Specifies the exception context. - @param VmPtr Pointer to a VM context for passing info to the - EFI debugger. - - @retval EFI_SUCCESS This function completed successfully. - -**/ -EFI_STATUS -EbcDebugSignalException ( - IN EFI_EXCEPTION_TYPE ExceptionType, - IN EXCEPTION_FLAGS ExceptionFlags, - IN VM_CONTEXT *VmPtr + IN EFI_HANDLE ImageHandle, + IN VOID *ThunkBuffer, + IN UINT32 ThunkSize ); // // Define a constant of how often to call the debugger periodic callback // function. // -#define EFI_TIMER_UNIT_1MS (1000 * 10) -#define EBC_VM_PERIODIC_CALLBACK_RATE (1000 * EFI_TIMER_UNIT_1MS) -#define STACK_POOL_SIZE (1024 * 1020) -#define MAX_STACK_NUM 4 +#define EFI_TIMER_UNIT_1MS (1000 * 10) +#define EBC_VM_PERIODIC_CALLBACK_RATE (1000 * EFI_TIMER_UNIT_1MS) +#define STACK_POOL_SIZE (1024 * 1020) +#define MAX_STACK_NUM 4 // // External low level functions that are native-processor dependent // + /** The VM thunk code stuffs an EBC entry point into a processor register. Since we can't use inline assembly to get it from @@ -173,21 +113,6 @@ EbcLLGetEbcEntryPoint ( VOID ); -/** - Returns the caller's value of the stack pointer. - - We adjust it by 4 here because when they called us, the return address - is put on the stack, thereby lowering it by 4 bytes. - - @return The current value of the stack pointer for the caller. - -**/ -UINTN -EFIAPI -EbcLLGetStackPointer ( - VOID - ); - /** This function is called to execute an EBC CALLEX instruction. This instruction requires that we thunk out to external native @@ -200,13 +125,15 @@ EbcLLGetStackPointer ( @param EbcSp The new EBC stack pointer. @param FramePtr The frame pointer. + @return The unmodified value returned by the native code. + **/ -VOID +INT64 EFIAPI EbcLLCALLEXNative ( - IN UINTN CallAddr, - IN UINTN EbcSp, - IN VOID *FramePtr + IN UINTN CallAddr, + IN UINTN EbcSp, + IN VOID *FramePtr ); /** @@ -226,26 +153,11 @@ EbcLLCALLEXNative ( **/ VOID EbcLLCALLEX ( - IN VM_CONTEXT *VmPtr, - IN UINTN FuncAddr, - IN UINTN NewStackPointer, - IN VOID *FramePtr, - IN UINT8 Size - ); - -/** - When EBC calls native, on return the VM has to stuff the return - value into a VM register. It's assumed here that the value is still - in the register, so simply return and the caller should get the - return result properly. - - @return The unmodified value returned by the native code. - -**/ -INT64 -EFIAPI -EbcLLGetReturnValue ( - VOID + IN VM_CONTEXT *VmPtr, + IN UINTN FuncAddr, + IN UINTN NewStackPointer, + IN VOID *FramePtr, + IN UINT8 Size ); /** @@ -262,10 +174,10 @@ EbcLLGetReturnValue ( **/ EFI_STATUS -GetEBCStack( - IN EFI_HANDLE Handle, - OUT VOID **StackBuffer, - OUT UINTN *BufferIndex +GetEBCStack ( + IN EFI_HANDLE Handle, + OUT VOID **StackBuffer, + OUT UINTN *BufferIndex ); /** @@ -277,8 +189,8 @@ GetEBCStack( **/ EFI_STATUS -ReturnEBCStack( - IN UINTN Index +ReturnEBCStack ( + IN UINTN Index ); /** @@ -300,7 +212,7 @@ InitEBCStack ( **/ EFI_STATUS -FreeEBCStack( +FreeEBCStack ( VOID ); @@ -313,81 +225,34 @@ FreeEBCStack( **/ EFI_STATUS -ReturnEBCStackByHandle( - IN EFI_HANDLE Handle - ); - - -// -// Defines for a simple EBC debugger interface -// -typedef struct _EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL; - -#define EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL_GUID \ - { \ - 0x2a72d11e, 0x7376, 0x40f6, { 0x9c, 0x68, 0x23, 0xfa, 0x2f, 0xe3, 0x63, 0xf1 } \ - } - -typedef -EFI_STATUS -(*EBC_DEBUGGER_SIGNAL_EXCEPTION) ( - IN EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL *This, - IN VM_CONTEXT *VmPtr, - IN EFI_EXCEPTION_TYPE ExceptionType +ReturnEBCStackByHandle ( + IN EFI_HANDLE Handle ); -typedef -VOID -(*EBC_DEBUGGER_DEBUG) ( - IN EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL *This, - IN VM_CONTEXT *VmPtr - ); - -typedef -UINT32 -(*EBC_DEBUGGER_DASM) ( - IN EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL *This, - IN VM_CONTEXT *VmPtr, - IN UINT16 *DasmString OPTIONAL, - IN UINT32 DasmStringSize - ); - -// -// This interface allows you to configure the EBC debug support -// driver. For example, turn on or off saving and printing of -// delta VM even if called. Or to even disable the entire interface, -// in which case all functions become no-ops. -// -typedef -EFI_STATUS -(*EBC_DEBUGGER_CONFIGURE) ( - IN EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL *This, - IN UINT32 ConfigId, - IN UINTN ConfigValue - ); - -// -// Prototype for the actual EBC debug support protocol interface -// -struct _EFI_EBC_SIMPLE_DEBUGGER_PROTOCOL { - EBC_DEBUGGER_DEBUG Debugger; - EBC_DEBUGGER_SIGNAL_EXCEPTION SignalException; - EBC_DEBUGGER_DASM Dasm; - EBC_DEBUGGER_CONFIGURE Configure; -}; - typedef struct { - EFI_EBC_PROTOCOL *This; - VOID *EntryPoint; - EFI_HANDLE ImageHandle; - VM_CONTEXT VmContext; + EFI_EBC_PROTOCOL *This; + VOID *EntryPoint; + EFI_HANDLE ImageHandle; + VM_CONTEXT VmContext; } EFI_EBC_THUNK_DATA; -#define EBC_PROTOCOL_PRIVATE_DATA_SIGNATURE EFI_SIGNATURE_32 ('e', 'b', 'c', 'p') - +#define EBC_PROTOCOL_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('e', 'b', 'c', 'p') #define EBC_PROTOCOL_PRIVATE_DATA_FROM_THIS(a) \ CR(a, EBC_PROTOCOL_PRIVATE_DATA, EbcProtocol, EBC_PROTOCOL_PRIVATE_DATA_SIGNATURE) +/** + Allocates a buffer of type EfiBootServicesCode. + + @param AllocationSize The number of bytes to allocate. + + @return A pointer to the allocated buffer or NULL if allocation fails. + +**/ +VOID * +EFIAPI +EbcAllocatePoolForThunk ( + IN UINTN AllocationSize + ); #endif // #ifndef _EBC_INT_H_