4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Top level module for the EBC virtual machine implementation.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Provides auxiliary support routines for the VM. That is, routines
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync that are not particularly related to VM execution of EBC instructions.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncCopyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncThis program and the accompanying materials
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncare licensed and made available under the terms and conditions of the BSD License
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncwhich accompanies this distribution. The full text of the license may be found at
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncTHE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncWITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync// We'll keep track of all thunks we create in a linked list. Each
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync// thunk is tied to an image handle, so we have a linked list of
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync// image handles, with each having a linked list of thunks allocated
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync// to that image handle.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync This routine is called by the core when an image is being unloaded from
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync memory. Basically we now have the opportunity to do any necessary cleanup.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Typically this will include freeing any memory allocated for thunk-creation.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param This A pointer to the EFI_EBC_PROTOCOL instance.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param ImageHandle Handle of image for which the thunk is being
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_INVALID_PARAMETER The ImageHandle passed in was not found in the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync internal list of EBC image handles.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS The function completed successfully.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync This is the top-level routine plugged into the EBC protocol. Since thunks
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync are very processor-specific, from here we dispatch directly to the very
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync processor-specific routine EbcCreateThunks().
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param This A pointer to the EFI_EBC_PROTOCOL instance.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param ImageHandle Handle of image for which the thunk is being
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync created. The EBC interpreter may use this to
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync keep track of any resource allocations
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync performed in loading and executing the image.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param EbcEntryPoint Address of the actual EBC entry point or
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync protocol service the thunk should call.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param Thunk Returned pointer to a thunk created.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS The function completed successfully.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_INVALID_PARAMETER Image entry point is not 2-byte aligned.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_OUT_OF_RESOURCES Memory could not be allocated for the thunk.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Called to get the version of the interpreter.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param This A pointer to the EFI_EBC_PROTOCOL instance.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param Version Pointer to where to store the returned version
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync of the interpreter.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS The function completed successfully.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_INVALID_PARAMETER Version pointer is NULL.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync To install default Callback function for the VM interpreter.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param This A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS The function completed successfully.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval Others Some error occurs when creating periodic event.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The default Exception Callback for the VM interpreter.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync In this function, we report status code, and print debug information
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync about EBC_CONTEXT, then dead loop.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param InterruptType Interrupt type.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param SystemContext EBC system context.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The periodic callback function for EBC VM interpreter, which is used
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync to support the EFI debug support protocol.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param Event The Periodic Callback Event.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param Context It should be the address of VM_CONTEXT pointer.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The VM interpreter calls this function on a periodic basis to support
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync the EFI debug support protocol.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param VmPtr Pointer to a VM context for passing info to the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS The function completed successfully.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync// These two functions and the GUID are used to produce an EBC test protocol.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync// This functionality is definitely not required for execution.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Produces an EBC VM test protocol that can be used for regression tests.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param IHandle Handle on which to install the protocol.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_OUT_OF_RESOURCES Memory allocation failed.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS The function completed successfully.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Returns the EFI_UNSUPPORTED Status.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @return EFI_UNSUPPORTED This function always return EFI_UNSUPPORTED status.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Registers a callback function that the EBC interpreter calls to flush the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync processor instruction cache following creation of thunks.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param This A pointer to the EFI_EBC_PROTOCOL instance.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param Flush Pointer to a function of type EBC_ICACH_FLUSH.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS The function completed successfully.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync This EBC debugger protocol service is called by the debug agent
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param This A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param MaxProcessorIndex Pointer to a caller-allocated UINTN in which the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync maximum supported processor index is returned.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS The function completed successfully.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync This protocol service is called by the debug agent to register a function
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync for us to call on a periodic basis.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param This A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param ProcessorIndex Specifies which processor the callback function
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync applies to.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param PeriodicCallback A pointer to a function of type
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync PERIODIC_CALLBACK that is the main periodic
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync entry point of the debug agent. It receives as a
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync parameter a pointer to the full context of the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync interrupted execution thread.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS The function completed successfully.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_ALREADY_STARTED Non-NULL PeriodicCallback parameter when a
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync callback function was previously registered.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_INVALID_PARAMETER Null PeriodicCallback parameter when no
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync callback function was previously registered.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync This protocol service is called by the debug agent to register a function
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync for us to call when we detect an exception.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param This A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param ProcessorIndex Specifies which processor the callback function
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync applies to.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param ExceptionCallback A pointer to a function of type
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync EXCEPTION_CALLBACK that is called when the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync processor exception specified by ExceptionType
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync occurs. Passing NULL unregisters any previously
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync registered function associated with
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync ExceptionType.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param ExceptionType Specifies which processor exception to hook.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS The function completed successfully.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_ALREADY_STARTED Non-NULL ExceptionCallback parameter when a
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync callback function was previously registered.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_INVALID_PARAMETER ExceptionType parameter is negative or exceeds
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync MAX_EBC_EXCEPTION.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_INVALID_PARAMETER Null ExceptionCallback parameter when no
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync callback function was previously registered.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync This EBC debugger protocol service is called by the debug agent. Required
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync for DebugSupport compliance but is only stubbed out for EBC.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param This A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param ProcessorIndex Specifies which processor the callback function
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync applies to.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param Start StartSpecifies the physical base of the memory
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync range to be invalidated.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param Length Specifies the minimum number of bytes in the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync processor's instruction cache to invalidate.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS The function completed successfully.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync// We have one linked list of image handles for the whole world. Since
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync// there should only be one interpreter, make them global. They must
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync// also be global since the execution of an EBC image does not provide
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync// a This pointer.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync// Callback function to flush the icache after thunk creation
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync// These get set via calls by the debug agent
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncEFI_PERIODIC_CALLBACK mDebugPeriodicCallback = NULL;
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncEFI_EXCEPTION_CALLBACK mDebugExceptionCallback[MAX_EBC_EXCEPTION + 1] = {NULL};
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync// Event for Periodic callback
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Initializes the VM EFI interface. Allocates memory for the VM interface
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync and registers the VM protocol.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param ImageHandle EFI image handle.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param SystemTable Pointer to the EFI system table.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @return Standard EFI status code.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Allocate memory for our protocol. Then fill in the blanks.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync EbcProtocol = AllocatePool (sizeof (EFI_EBC_PROTOCOL));
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync EbcProtocol->RegisterICacheFlush = EbcRegisterICacheFlush;
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Find any already-installed EBC protocols and uninstall them
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Loop through the handles
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Add the protocol so someone can locate us if we haven't already.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Allocate memory for our debug protocol. Then fill in the blanks.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync EbcDebugProtocol = AllocatePool (sizeof (EFI_DEBUG_SUPPORT_PROTOCOL));
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync EbcDebugProtocol->GetMaximumProcessorIndex = EbcDebugGetMaximumProcessorIndex;
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync EbcDebugProtocol->RegisterPeriodicCallback = EbcDebugRegisterPeriodicCallback;
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync EbcDebugProtocol->RegisterExceptionCallback = EbcDebugRegisterExceptionCallback;
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync EbcDebugProtocol->InvalidateInstructionCache = EbcDebugInvalidateInstructionCache;
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Add the protocol so the debug agent can find us
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // This is recoverable, so free the memory and continue.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Install EbcDebugSupport Protocol Successfully
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Now we need to initialize the Ebc default Callback
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Produce a VM test interface protocol. Not required for execution.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Loop through the handles
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync This is the top-level routine plugged into the EBC protocol. Since thunks
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync are very processor-specific, from here we dispatch directly to the very
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync processor-specific routine EbcCreateThunks().
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param This A pointer to the EFI_EBC_PROTOCOL instance.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param ImageHandle Handle of image for which the thunk is being
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync created. The EBC interpreter may use this to
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync keep track of any resource allocations
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync performed in loading and executing the image.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param EbcEntryPoint Address of the actual EBC entry point or
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync protocol service the thunk should call.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param Thunk Returned pointer to a thunk created.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS The function completed successfully.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_INVALID_PARAMETER Image entry point is not 2-byte aligned.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_OUT_OF_RESOURCES Memory could not be allocated for the thunk.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync This EBC debugger protocol service is called by the debug agent
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param This A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param MaxProcessorIndex Pointer to a caller-allocated UINTN in which the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync maximum supported processor index is returned.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS The function completed successfully.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync This protocol service is called by the debug agent to register a function
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync for us to call on a periodic basis.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param This A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param ProcessorIndex Specifies which processor the callback function
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync applies to.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param PeriodicCallback A pointer to a function of type
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync PERIODIC_CALLBACK that is the main periodic
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync entry point of the debug agent. It receives as a
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync parameter a pointer to the full context of the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync interrupted execution thread.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS The function completed successfully.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_ALREADY_STARTED Non-NULL PeriodicCallback parameter when a
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync callback function was previously registered.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_INVALID_PARAMETER Null PeriodicCallback parameter when no
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync callback function was previously registered.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync if ((mDebugPeriodicCallback == NULL) && (PeriodicCallback == NULL)) {
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync if ((mDebugPeriodicCallback != NULL) && (PeriodicCallback != NULL)) {
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync This protocol service is called by the debug agent to register a function
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync for us to call when we detect an exception.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param This A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param ProcessorIndex Specifies which processor the callback function
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync applies to.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param ExceptionCallback A pointer to a function of type
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync EXCEPTION_CALLBACK that is called when the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync processor exception specified by ExceptionType
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync occurs. Passing NULL unregisters any previously
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync registered function associated with
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync ExceptionType.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param ExceptionType Specifies which processor exception to hook.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS The function completed successfully.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_ALREADY_STARTED Non-NULL ExceptionCallback parameter when a
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync callback function was previously registered.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_INVALID_PARAMETER ExceptionType parameter is negative or exceeds
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync MAX_EBC_EXCEPTION.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_INVALID_PARAMETER Null ExceptionCallback parameter when no
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync callback function was previously registered.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync if ((ExceptionType < 0) || (ExceptionType > MAX_EBC_EXCEPTION)) {
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync if ((mDebugExceptionCallback[ExceptionType] == NULL) && (ExceptionCallback == NULL)) {
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync if ((mDebugExceptionCallback[ExceptionType] != NULL) && (ExceptionCallback != NULL)) {
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync mDebugExceptionCallback[ExceptionType] = ExceptionCallback;
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync This EBC debugger protocol service is called by the debug agent. Required
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync for DebugSupport compliance but is only stubbed out for EBC.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param This A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param ProcessorIndex Specifies which processor the callback function
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync applies to.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param Start StartSpecifies the physical base of the memory
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync range to be invalidated.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param Length Specifies the minimum number of bytes in the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync processor's instruction cache to invalidate.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS The function completed successfully.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The VM interpreter calls this function when an exception is detected.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param ExceptionType Specifies the processor exception detected.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param ExceptionFlags Specifies the exception context.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param VmPtr Pointer to a VM context for passing info to the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync EFI debugger.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS This function completed successfully.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync ASSERT ((ExceptionType >= 0) && (ExceptionType <= MAX_EBC_EXCEPTION));
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Save the exception in the context passed in
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // If it's a fatal exception, then flag it in the VM context in case an
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // attached debugger tries to return from it.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync if ((ExceptionFlags & EXCEPTION_FLAG_FATAL) != 0) {
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // If someone's registered for exception callbacks, then call them.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // EBC driver will register default exception callback to report the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // status code via the status code API
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync if (mDebugExceptionCallback[ExceptionType] != NULL) {
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Initialize the context structure
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync mDebugExceptionCallback[ExceptionType] (ExceptionType, SystemContext);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Restore the context structure and continue to execute
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync To install default Callback function for the VM interpreter.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param This A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS The function completed successfully.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval Others Some error occurs when creating periodic event.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // For ExceptionCallback
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync for (Index = 0; Index <= MAX_EBC_EXCEPTION; Index++) {
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // For PeriodicCallback
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The default Exception Callback for the VM interpreter.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync In this function, we report status code, and print debug information
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync about EBC_CONTEXT, then dead loop.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param InterruptType Interrupt type.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param SystemContext EBC system context.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // We print debug information to let user know what happen.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync "EBC Interrupter Version - 0x%016lx\n",
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync (UINT64) (((VM_MAJOR_VERSION & 0xFFFF) << 16) | ((VM_MINOR_VERSION & 0xFFFF)))
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync "Exception Type - 0x%016lx\n",
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync " R0 - 0x%016lx, R1 - 0x%016lx\n",
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync " R2 - 0x%016lx, R3 - 0x%016lx\n",
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync " R4 - 0x%016lx, R5 - 0x%016lx\n",
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync " R6 - 0x%016lx, R7 - 0x%016lx\n",
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync " Flags - 0x%016lx\n",
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync " ControlFlags - 0x%016lx\n",
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync " Ip - 0x%016lx\n\n",
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // We deadloop here to make it easy to debug this issue.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The periodic callback function for EBC VM interpreter, which is used
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync to support the EFI debug support protocol.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param Event The Periodic Callback Event.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param Context It should be the address of VM_CONTEXT pointer.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The VM interpreter calls this function on a periodic basis to support
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync the EFI debug support protocol.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param VmPtr Pointer to a VM context for passing info to the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS The function completed successfully.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // If someone's registered for periodic callbacks, then call them.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Initialize the context structure
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Restore the context structure and continue to execute
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync This routine is called by the core when an image is being unloaded from
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync memory. Basically we now have the opportunity to do any necessary cleanup.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Typically this will include freeing any memory allocated for thunk-creation.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param This A pointer to the EFI_EBC_PROTOCOL instance.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param ImageHandle Handle of image for which the thunk is being
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_INVALID_PARAMETER The ImageHandle passed in was not found in the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync internal list of EBC image handles.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS The function completed successfully.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // First go through our list of known image handles and see if we've already
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // created an image list element for this image handle.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync for (ImageList = mEbcImageList; ImageList != NULL; ImageList = ImageList->Next) {
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Save the previous so we can connect the lists when we remove this one
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Free up all the thunk buffers and thunks list elements for this image
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Now remove this image list element from the chain
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Remove from head
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Now free up the image list element
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Add a thunk to our list of thunks for a given image handle.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Also flush the instruction cache since we've written thunk code
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync to memory that will be executed eventually.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param ImageHandle The image handle to which the thunk is tied.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param ThunkBuffer The buffer that has been created/allocated.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param ThunkSize The size of the thunk memory allocated.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_OUT_OF_RESOURCES Memory allocation failed.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS The function completed successfully.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // It so far so good, then flush the instruction cache
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Status = mEbcICacheFlush ((EFI_PHYSICAL_ADDRESS) (UINTN) ThunkBuffer, ThunkSize);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Go through our list of known image handles and see if we've already
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // created a image list element for this image handle.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync for (ImageList = mEbcImageList; ImageList != NULL; ImageList = ImageList->Next) {
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Allocate a new one
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync ImageList = AllocatePool (sizeof (EBC_IMAGE_LIST));
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Ok, now create a new thunk element to add to the list
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync ThunkList = AllocatePool (sizeof (EBC_THUNK_LIST));
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Add it to the head of the list
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Registers a callback function that the EBC interpreter calls to flush the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync processor instruction cache following creation of thunks.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param This A pointer to the EFI_EBC_PROTOCOL instance.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param Flush Pointer to a function of type EBC_ICACH_FLUSH.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS The function completed successfully.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Called to get the version of the interpreter.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param This A pointer to the EFI_EBC_PROTOCOL instance.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param Version Pointer to where to store the returned version
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync of the interpreter.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS The function completed successfully.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_INVALID_PARAMETER Version pointer is NULL.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Returns the stack index and buffer assosicated with the Handle parameter.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param Handle The EFI handle as the index to the EBC stack.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param StackBuffer A pointer to hold the returned stack buffer.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param BufferIndex A pointer to hold the returned stack index.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_OUT_OF_RESOURCES The Handle parameter does not correspond to any
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync existing EBC stack.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS The stack index and buffer were found and
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync returned to the caller.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Returns from the EBC stack by stack Index.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param Index Specifies which EBC stack to return from.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS The function completed successfully.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Returns from the EBC stack associated with the Handle parameter.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param Handle Specifies the EFI handle to find the EBC stack with.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS The function completed successfully.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Allocates memory to hold all the EBC stacks.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS The EBC stacks were allocated successfully.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_OUT_OF_RESOURCES Not enough memory available for EBC stacks.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync for (mStackNum = 0; mStackNum < MAX_STACK_NUM; mStackNum ++) {
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync mStackBuffer[mStackNum] = AllocatePool(STACK_POOL_SIZE);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Free all EBC stacks allocated before.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS All the EBC stacks were freed.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Produces an EBC VM test protocol that can be used for regression tests.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param IHandle Handle on which to install the protocol.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_OUT_OF_RESOURCES Memory allocation failed.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS The function completed successfully.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Allocate memory for the protocol, then fill in the fields
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync EbcVmTestProtocol = AllocatePool (sizeof (EFI_EBC_VM_TEST_PROTOCOL));
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync EbcVmTestProtocol->Execute = (EBC_VM_TEST_EXECUTE) EbcExecuteInstructions;
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync EbcVmTestProtocol->Assemble = (EBC_VM_TEST_ASM) EbcVmTestUnsupported;
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync EbcVmTestProtocol->Disassemble = (EBC_VM_TEST_DASM) EbcVmTestUnsupported;
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Publish the protocol
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Status = gBS->InstallProtocolInterface (&Handle, &gEfiEbcVmTestProtocolGuid, EFI_NATIVE_INTERFACE, EbcVmTestProtocol);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Returns the EFI_UNSUPPORTED Status.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @return EFI_UNSUPPORTED This function always return EFI_UNSUPPORTED status.