2008-11-05 09:44:03 +01:00
|
|
|
/** @file
|
2008-12-16 10:21:45 +01:00
|
|
|
IPF specific types, macros, and definitions for Debug Support Driver.
|
2009-01-08 09:21:40 +01:00
|
|
|
|
2010-04-24 11:33:45 +02:00
|
|
|
Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
|
|
|
|
This program and the accompanying materials
|
2009-01-08 09:21:40 +01:00
|
|
|
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.
|
2007-07-03 16:09:20 +02:00
|
|
|
|
|
|
|
**/
|
|
|
|
|
2008-11-05 09:44:03 +01:00
|
|
|
#ifndef _PLDEBUG_SUPPORT_H_
|
|
|
|
#define _PLDEBUG_SUPPORT_H_
|
2007-07-03 16:09:20 +02:00
|
|
|
|
2008-08-30 16:09:38 +02:00
|
|
|
#include <Uefi.h>
|
2007-07-20 08:10:09 +02:00
|
|
|
|
2007-07-03 16:09:20 +02:00
|
|
|
#include <Protocol/DebugSupport.h>
|
|
|
|
#include <Protocol/LoadedImage.h>
|
2007-07-20 08:10:09 +02:00
|
|
|
|
2007-07-03 16:09:20 +02:00
|
|
|
#include <Library/DebugLib.h>
|
|
|
|
#include <Library/UefiDriverEntryPoint.h>
|
|
|
|
#include <Library/BaseMemoryLib.h>
|
|
|
|
#include <Library/MemoryAllocationLib.h>
|
|
|
|
#include <Library/UefiBootServicesTableLib.h>
|
|
|
|
|
|
|
|
#define DISABLE_INTERRUPTS 0UL
|
|
|
|
|
|
|
|
#define EFI_ISA IsaIpf
|
|
|
|
|
2008-12-11 09:38:20 +01:00
|
|
|
typedef struct {
|
2010-01-19 07:42:21 +01:00
|
|
|
UINT64 Low;
|
|
|
|
UINT64 High;
|
2008-12-11 09:38:20 +01:00
|
|
|
} BUNDLE;
|
|
|
|
|
2010-01-19 07:42:21 +01:00
|
|
|
typedef
|
|
|
|
VOID
|
|
|
|
(*CALLBACK_FUNC) (
|
|
|
|
);
|
|
|
|
|
2008-11-05 09:44:03 +01:00
|
|
|
/**
|
2009-01-08 09:21:40 +01:00
|
|
|
IPF specific DebugSupport driver initialization.
|
2007-07-03 16:09:20 +02:00
|
|
|
|
2008-11-05 09:44:03 +01:00
|
|
|
Must be public because it's referenced from DebugSupport.c
|
2007-07-03 16:09:20 +02:00
|
|
|
|
2008-11-05 09:44:03 +01:00
|
|
|
@retval EFI_SUCCESS Always.
|
2007-07-03 16:09:20 +02:00
|
|
|
|
2008-11-05 09:44:03 +01:00
|
|
|
**/
|
2007-07-03 16:09:20 +02:00
|
|
|
EFI_STATUS
|
2008-11-05 09:44:03 +01:00
|
|
|
PlInitializeDebugSupportDriver (
|
|
|
|
VOID
|
|
|
|
);
|
2007-07-03 16:09:20 +02:00
|
|
|
|
2008-11-05 09:44:03 +01:00
|
|
|
/**
|
2007-07-03 16:09:20 +02:00
|
|
|
Unload handler that is called during UnloadImage() - deallocates pool memory
|
2009-01-08 09:21:40 +01:00
|
|
|
used by the driver.
|
2008-12-16 10:21:45 +01:00
|
|
|
|
|
|
|
Must be public because it's referenced from DebugSuport.c
|
2007-07-03 16:09:20 +02:00
|
|
|
|
2008-11-05 09:44:03 +01:00
|
|
|
@param ImageHandle The firmware allocated handle for the EFI image.
|
2007-07-03 16:09:20 +02:00
|
|
|
|
2008-11-05 09:44:03 +01:00
|
|
|
@retval EFI_SUCCESS Always.
|
2007-07-03 16:09:20 +02:00
|
|
|
|
2008-11-05 09:44:03 +01:00
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
PlUnloadDebugSupportDriver (
|
|
|
|
IN EFI_HANDLE ImageHandle
|
|
|
|
);
|
2007-07-03 16:09:20 +02:00
|
|
|
|
2008-11-05 09:44:03 +01:00
|
|
|
/**
|
|
|
|
C callable function to obtain the current value of IVA.
|
2007-07-03 16:09:20 +02:00
|
|
|
|
2008-11-05 09:44:03 +01:00
|
|
|
@return Current value of IVA.
|
|
|
|
|
|
|
|
**/
|
2007-07-03 16:09:20 +02:00
|
|
|
VOID *
|
|
|
|
GetIva (
|
|
|
|
VOID
|
2008-11-05 09:44:03 +01:00
|
|
|
);
|
2007-07-03 16:09:20 +02:00
|
|
|
|
2008-11-05 09:44:03 +01:00
|
|
|
/**
|
2008-12-16 10:21:45 +01:00
|
|
|
C callable function that HookStub will be copied from it's loaded location into the IVT when
|
2008-11-05 09:44:03 +01:00
|
|
|
an IVT entry is hooked.
|
2007-07-03 16:09:20 +02:00
|
|
|
|
2008-11-05 09:44:03 +01:00
|
|
|
**/
|
2007-07-03 16:09:20 +02:00
|
|
|
VOID
|
|
|
|
HookStub (
|
|
|
|
VOID
|
2008-11-05 09:44:03 +01:00
|
|
|
);
|
2007-07-03 16:09:20 +02:00
|
|
|
|
2008-11-05 09:44:03 +01:00
|
|
|
/**
|
2008-12-16 10:21:45 +01:00
|
|
|
C callable function to chain an interrupt handler.
|
2007-07-03 16:09:20 +02:00
|
|
|
|
2008-11-05 09:44:03 +01:00
|
|
|
**/
|
2007-07-03 16:09:20 +02:00
|
|
|
VOID
|
|
|
|
ChainHandler (
|
|
|
|
VOID
|
2008-11-05 09:44:03 +01:00
|
|
|
);
|
2007-07-03 16:09:20 +02:00
|
|
|
|
2008-11-05 09:44:03 +01:00
|
|
|
/**
|
2008-12-16 10:21:45 +01:00
|
|
|
C callable function to unchain an interrupt handler.
|
2007-07-03 16:09:20 +02:00
|
|
|
|
2008-11-05 09:44:03 +01:00
|
|
|
**/
|
2007-07-03 16:09:20 +02:00
|
|
|
VOID
|
|
|
|
UnchainHandler (
|
|
|
|
VOID
|
2008-11-05 09:44:03 +01:00
|
|
|
);
|
2007-07-03 16:09:20 +02:00
|
|
|
|
2008-11-05 09:44:03 +01:00
|
|
|
/**
|
|
|
|
C callable function to enable/disable interrupts.
|
2007-07-03 16:09:20 +02:00
|
|
|
|
2008-11-05 09:44:03 +01:00
|
|
|
@param NewInterruptState New Interrupt State.
|
2007-07-03 16:09:20 +02:00
|
|
|
|
2008-11-05 09:44:03 +01:00
|
|
|
@return Previous state of psr.ic.
|
2007-07-03 16:09:20 +02:00
|
|
|
|
2008-11-05 09:44:03 +01:00
|
|
|
**/
|
2007-07-03 16:09:20 +02:00
|
|
|
UINT64
|
|
|
|
ProgramInterruptFlags (
|
|
|
|
IN UINT64 NewInterruptState
|
2008-11-05 09:44:03 +01:00
|
|
|
);
|
2007-07-03 16:09:20 +02:00
|
|
|
|
2008-11-05 09:44:03 +01:00
|
|
|
/**
|
|
|
|
Flushes instruction cache for specified number of bytes.
|
2007-07-03 16:09:20 +02:00
|
|
|
|
2008-11-05 09:44:03 +01:00
|
|
|
@param StartAddress Cache Start Address.
|
|
|
|
@param SizeInBytes Cache Size.
|
2007-07-03 16:09:20 +02:00
|
|
|
|
2008-11-05 09:44:03 +01:00
|
|
|
**/
|
2007-07-03 16:09:20 +02:00
|
|
|
VOID
|
|
|
|
InstructionCacheFlush (
|
|
|
|
IN VOID *StartAddress,
|
|
|
|
IN UINTN SizeInBytes
|
2008-11-05 09:44:03 +01:00
|
|
|
);
|
2007-07-03 16:09:20 +02:00
|
|
|
|
2008-11-05 09:44:03 +01:00
|
|
|
/**
|
2008-12-16 10:21:45 +01:00
|
|
|
Returns the maximum value that may be used for the ProcessorIndex parameter in
|
2009-01-08 09:21:40 +01:00
|
|
|
RegisterPeriodicCallback() and RegisterExceptionCallback().
|
|
|
|
|
2008-12-16 10:21:45 +01:00
|
|
|
Hard coded to support only 1 processor for now.
|
2007-07-03 16:09:20 +02:00
|
|
|
|
2008-12-16 10:21:45 +01:00
|
|
|
@param This A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL instance.
|
|
|
|
@param MaxProcessorIndex Pointer to a caller-allocated UINTN in which the maximum supported
|
2009-01-08 09:21:40 +01:00
|
|
|
processor index is returned. Always 0 returned.
|
|
|
|
|
2008-12-16 10:21:45 +01:00
|
|
|
@retval EFI_SUCCESS Always returned with **MaxProcessorIndex set to 0.
|
2007-07-03 16:09:20 +02:00
|
|
|
|
2008-11-05 09:44:03 +01:00
|
|
|
**/
|
2007-07-03 16:09:20 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
GetMaximumProcessorIndex (
|
|
|
|
IN EFI_DEBUG_SUPPORT_PROTOCOL *This,
|
|
|
|
OUT UINTN *MaxProcessorIndex
|
2008-11-05 09:44:03 +01:00
|
|
|
);
|
2007-07-03 16:09:20 +02:00
|
|
|
|
2008-11-05 09:44:03 +01:00
|
|
|
/**
|
2008-12-16 10:21:45 +01:00
|
|
|
Registers a function to be called back periodically in interrupt context.
|
2009-01-08 09:21:40 +01:00
|
|
|
|
2008-12-16 10:21:45 +01:00
|
|
|
@param This A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL instance.
|
|
|
|
@param ProcessorIndex Specifies which processor the callback function applies to.
|
|
|
|
@param PeriodicCallback A pointer to a function of type PERIODIC_CALLBACK that is the main
|
|
|
|
periodic entry point of the debug agent.
|
2009-01-08 09:21:40 +01:00
|
|
|
|
|
|
|
@retval EFI_SUCCESS The function completed successfully.
|
2008-12-16 10:21:45 +01:00
|
|
|
@retval EFI_ALREADY_STARTED Non-NULL PeriodicCallback parameter when a callback
|
2009-01-08 09:21:40 +01:00
|
|
|
function was previously registered.
|
|
|
|
@retval EFI_OUT_OF_RESOURCES System has insufficient memory resources to register new callback
|
|
|
|
function.
|
2008-11-05 09:44:03 +01:00
|
|
|
**/
|
2007-07-03 16:09:20 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
RegisterPeriodicCallback (
|
|
|
|
IN EFI_DEBUG_SUPPORT_PROTOCOL *This,
|
|
|
|
IN UINTN ProcessorIndex,
|
|
|
|
IN EFI_PERIODIC_CALLBACK PeriodicCallback
|
2008-11-05 09:44:03 +01:00
|
|
|
);
|
2007-07-03 16:09:20 +02:00
|
|
|
|
2008-11-05 09:44:03 +01:00
|
|
|
/**
|
2008-12-16 10:21:45 +01:00
|
|
|
Registers a function to be called when a given processor exception occurs.
|
|
|
|
|
|
|
|
This code executes in boot services context.
|
2009-01-08 09:21:40 +01:00
|
|
|
|
2008-12-16 10:21:45 +01:00
|
|
|
@param This A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL instance.
|
|
|
|
@param ProcessorIndex Specifies which processor the callback function applies to.
|
|
|
|
@param ExceptionCallback A pointer to a function of type EXCEPTION_CALLBACK that is called
|
|
|
|
when the processor exception specified by ExceptionType occurs.
|
2009-01-08 09:21:40 +01:00
|
|
|
@param ExceptionType Specifies which processor exception to hook.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The function completed successfully.
|
2008-12-16 10:21:45 +01:00
|
|
|
@retval EFI_ALREADY_STARTED Non-NULL PeriodicCallback parameter when a callback
|
2009-01-08 09:21:40 +01:00
|
|
|
function was previously registered.
|
|
|
|
@retval EFI_OUT_OF_RESOURCES System has insufficient memory resources to register new callback
|
2008-12-16 10:21:45 +01:00
|
|
|
function.
|
2008-11-05 09:44:03 +01:00
|
|
|
**/
|
2007-07-03 16:09:20 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
RegisterExceptionCallback (
|
|
|
|
IN EFI_DEBUG_SUPPORT_PROTOCOL *This,
|
|
|
|
IN UINTN ProcessorIndex,
|
2009-01-08 09:21:40 +01:00
|
|
|
IN EFI_EXCEPTION_CALLBACK ExceptionCallback,
|
2007-07-03 16:09:20 +02:00
|
|
|
IN EFI_EXCEPTION_TYPE ExceptionType
|
2008-11-05 09:44:03 +01:00
|
|
|
);
|
2007-07-03 16:09:20 +02:00
|
|
|
|
2008-11-05 09:44:03 +01:00
|
|
|
/**
|
2008-12-16 10:21:45 +01:00
|
|
|
Invalidates processor instruction cache for a memory range. Subsequent execution in this range
|
2009-01-08 09:21:40 +01:00
|
|
|
causes a fresh memory fetch to retrieve code to be executed.
|
|
|
|
|
2008-12-16 10:21:45 +01:00
|
|
|
@param This A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL instance.
|
|
|
|
@param ProcessorIndex Specifies which processor's instruction cache is to be invalidated.
|
2009-01-08 09:21:40 +01:00
|
|
|
@param Start Specifies the physical base of the memory range to be invalidated.
|
2008-12-16 10:21:45 +01:00
|
|
|
@param Length Specifies the minimum number of bytes in the processor's instruction
|
2009-01-08 09:21:40 +01:00
|
|
|
cache to invalidate.
|
|
|
|
|
2008-12-16 10:21:45 +01:00
|
|
|
@retval EFI_SUCCESS Always returned.
|
2007-07-03 16:09:20 +02:00
|
|
|
|
2008-11-05 09:44:03 +01:00
|
|
|
**/
|
2007-07-03 16:09:20 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
InvalidateInstructionCache (
|
|
|
|
IN EFI_DEBUG_SUPPORT_PROTOCOL *This,
|
|
|
|
IN UINTN ProcessorIndex,
|
|
|
|
IN VOID *Start,
|
|
|
|
IN UINTN Length
|
2008-11-05 09:44:03 +01:00
|
|
|
);
|
2007-07-03 16:09:20 +02:00
|
|
|
|
2008-11-05 09:44:03 +01:00
|
|
|
/**
|
|
|
|
C routine that is called for all registered exceptions. This is the main
|
2009-01-08 09:21:40 +01:00
|
|
|
exception dispatcher.
|
2008-12-16 10:21:45 +01:00
|
|
|
|
|
|
|
Must be public because it's referenced from AsmFuncs.s.
|
2007-07-03 16:09:20 +02:00
|
|
|
|
2008-12-16 10:21:45 +01:00
|
|
|
@param ExceptionType Specifies which processor exception.
|
|
|
|
@param Context System Context.
|
2008-11-05 09:44:03 +01:00
|
|
|
**/
|
2007-07-03 16:09:20 +02:00
|
|
|
VOID
|
|
|
|
CommonHandler (
|
|
|
|
IN EFI_EXCEPTION_TYPE ExceptionType,
|
|
|
|
IN EFI_SYSTEM_CONTEXT Context
|
2008-11-05 09:44:03 +01:00
|
|
|
);
|
2007-07-03 16:09:20 +02:00
|
|
|
|
2008-12-11 09:38:20 +01:00
|
|
|
/**
|
|
|
|
This is the worker function that uninstalls and removes all handlers.
|
|
|
|
|
2008-12-16 10:21:45 +01:00
|
|
|
@param ExceptionType Specifies which processor exception.
|
|
|
|
@param NewBundles New Boundles.
|
|
|
|
@param NewCallback A pointer to the new function to be registered.
|
2008-12-11 09:38:20 +01:00
|
|
|
|
|
|
|
@retval EFI_ALEADY_STARTED Ivt already hooked.
|
|
|
|
@retval EFI_SUCCESS Successfully uninstalled.
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
ManageIvtEntryTable (
|
|
|
|
IN EFI_EXCEPTION_TYPE ExceptionType,
|
|
|
|
IN BUNDLE NewBundles[4],
|
2010-01-19 07:42:21 +01:00
|
|
|
IN CALLBACK_FUNC NewCallback
|
2008-12-11 09:38:20 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Saves original IVT contents and inserts a few new bundles which are fixed up
|
|
|
|
to store the ExceptionType and then call the common handler.
|
|
|
|
|
2008-12-16 10:21:45 +01:00
|
|
|
@param ExceptionType Specifies which processor exception.
|
|
|
|
@param NewBundles New Boundles.
|
|
|
|
@param NewCallback A pointer to the new function to be hooked.
|
2008-12-11 09:38:20 +01:00
|
|
|
|
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
HookEntry (
|
|
|
|
IN EFI_EXCEPTION_TYPE ExceptionType,
|
|
|
|
IN BUNDLE NewBundles[4],
|
2010-01-19 07:42:21 +01:00
|
|
|
IN CALLBACK_FUNC NewCallback
|
2008-12-11 09:38:20 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Restores original IVT contents when unregistering a callback function.
|
|
|
|
|
2008-12-16 10:21:45 +01:00
|
|
|
@param ExceptionType Specifies which processor exception.
|
2008-12-11 09:38:20 +01:00
|
|
|
|
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
UnhookEntry (
|
|
|
|
IN EFI_EXCEPTION_TYPE ExceptionType
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets up cache flush and calls assembly function to chain external interrupt.
|
|
|
|
|
|
|
|
Records new callback in IvtEntryTable.
|
|
|
|
|
2008-12-16 10:21:45 +01:00
|
|
|
@param NewCallback A pointer to the interrupt handle.
|
2008-12-11 09:38:20 +01:00
|
|
|
|
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
ChainExternalInterrupt (
|
2010-01-19 07:42:21 +01:00
|
|
|
IN CALLBACK_FUNC NewCallback
|
2008-12-11 09:38:20 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets up cache flush and calls assembly function to restore external interrupt.
|
|
|
|
Removes registered callback from IvtEntryTable.
|
|
|
|
|
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
UnchainExternalInterrupt (
|
|
|
|
VOID
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Given an integer number, return the physical address of the entry point in the IFT.
|
|
|
|
|
2009-01-08 09:21:40 +01:00
|
|
|
@param HandlerIndex Index of the Handler
|
2008-12-11 09:38:20 +01:00
|
|
|
@param EntryPoint IFT Entrypoint
|
|
|
|
|
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
GetHandlerEntryPoint (
|
|
|
|
UINTN HandlerIndex,
|
|
|
|
VOID **EntryPoint
|
|
|
|
);
|
|
|
|
|
2007-07-03 16:09:20 +02:00
|
|
|
#endif
|