mirror of https://github.com/acidanthera/audk.git
UefiCpuPkg/ExceptionLib: Import PeiCpuExceptionHandlerLib module
This module could be linked by CpuMpPei driver to handle reserved vector list and provide spin lock for BSP/APs to prevent dump message corrupted. Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Feng Tian <feng.tian@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Feng Tian <feng.tian@intel.com>
This commit is contained in:
parent
d91225cfad
commit
a81abf1616
|
@ -31,6 +31,11 @@
|
||||||
|
|
||||||
#include "ArchInterruptDefs.h"
|
#include "ArchInterruptDefs.h"
|
||||||
|
|
||||||
|
#define CPU_EXCEPTION_HANDLER_LIB_HOB_GUID \
|
||||||
|
{ \
|
||||||
|
0xb21d9148, 0x9211, 0x4d8f, { 0xad, 0xd3, 0x66, 0xb1, 0x89, 0xc9, 0x2c, 0x83 } \
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Record exception handler information
|
// Record exception handler information
|
||||||
//
|
//
|
||||||
|
|
|
@ -0,0 +1,184 @@
|
||||||
|
/** @file
|
||||||
|
CPU exception handler library implementation for PEIM module.
|
||||||
|
|
||||||
|
Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
|
||||||
|
This program and the accompanying materials are licensed and made available under
|
||||||
|
the terms and conditions of the BSD License that 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.
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include <PiPei.h>
|
||||||
|
#include "CpuExceptionCommon.h"
|
||||||
|
#include <Library/DebugLib.h>
|
||||||
|
#include <Library/HobLib.h>
|
||||||
|
#include <Library/MemoryAllocationLib.h>
|
||||||
|
|
||||||
|
//
|
||||||
|
// Image Alignment size for PEI phase
|
||||||
|
//
|
||||||
|
CONST UINTN mImageAlignSize = 4;
|
||||||
|
CONST UINTN mDoFarReturnFlag = 0;
|
||||||
|
|
||||||
|
EFI_GUID mCpuExceptrionHandlerLibHobGuid = CPU_EXCEPTION_HANDLER_LIB_HOB_GUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Get exception handler data pointer from GUIDed HOb.
|
||||||
|
|
||||||
|
@return pointer to exception handler data.
|
||||||
|
**/
|
||||||
|
EXCEPTION_HANDLER_DATA *
|
||||||
|
GetExceptionHandlerData (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_HOB_GUID_TYPE *GuidHob;
|
||||||
|
VOID *DataInHob;
|
||||||
|
EXCEPTION_HANDLER_DATA *ExceptionHandlerData;
|
||||||
|
|
||||||
|
ExceptionHandlerData = NULL;
|
||||||
|
GuidHob = GetFirstGuidHob (&mCpuExceptrionHandlerLibHobGuid);
|
||||||
|
if (GuidHob != NULL) {
|
||||||
|
DataInHob = GET_GUID_HOB_DATA (GuidHob);
|
||||||
|
ExceptionHandlerData = (EXCEPTION_HANDLER_DATA *)(*(UINTN *)DataInHob);
|
||||||
|
}
|
||||||
|
ASSERT (ExceptionHandlerData != NULL);
|
||||||
|
return ExceptionHandlerData;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Common exception handler.
|
||||||
|
|
||||||
|
@param ExceptionType Exception type.
|
||||||
|
@param SystemContext Pointer to EFI_SYSTEM_CONTEXT.
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
EFIAPI
|
||||||
|
CommonExceptionHandler (
|
||||||
|
IN EFI_EXCEPTION_TYPE ExceptionType,
|
||||||
|
IN EFI_SYSTEM_CONTEXT SystemContext
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EXCEPTION_HANDLER_DATA *ExceptionHandlerData;
|
||||||
|
|
||||||
|
ExceptionHandlerData = GetExceptionHandlerData ();
|
||||||
|
CommonExceptionHandlerWorker (ExceptionType, SystemContext, ExceptionHandlerData);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Initializes all CPU exceptions entries and provides the default exception handlers.
|
||||||
|
|
||||||
|
Caller should try to get an array of interrupt and/or exception vectors that are in use and need to
|
||||||
|
persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification.
|
||||||
|
If caller cannot get reserved vector list or it does not exists, set VectorInfo to NULL.
|
||||||
|
If VectorInfo is not NULL, the exception vectors will be initialized per vector attribute accordingly.
|
||||||
|
Note: Before invoking this API, caller must allocate memory for IDT table and load
|
||||||
|
IDTR by AsmWriteIdtr().
|
||||||
|
|
||||||
|
@param[in] VectorInfo Pointer to reserved vector list.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS CPU Exception Entries have been successfully initialized
|
||||||
|
with default exception handlers.
|
||||||
|
@retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL.
|
||||||
|
@retval EFI_UNSUPPORTED This function is not supported.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
InitializeCpuExceptionHandlers (
|
||||||
|
IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
EXCEPTION_HANDLER_DATA *ExceptionHandlerData;
|
||||||
|
RESERVED_VECTORS_DATA *ReservedVectors;
|
||||||
|
|
||||||
|
ReservedVectors = AllocatePool (sizeof (RESERVED_VECTORS_DATA) * CPU_EXCEPTION_NUM);
|
||||||
|
ASSERT (ReservedVectors != NULL);
|
||||||
|
|
||||||
|
ExceptionHandlerData = AllocatePool (sizeof (EXCEPTION_HANDLER_DATA));
|
||||||
|
ASSERT (ExceptionHandlerData != NULL);
|
||||||
|
ExceptionHandlerData->ReservedVectors = ReservedVectors;
|
||||||
|
ExceptionHandlerData->ExternalInterruptHandler = NULL;
|
||||||
|
InitializeSpinLock (&ExceptionHandlerData->DisplayMessageSpinLock);
|
||||||
|
|
||||||
|
Status = InitializeCpuExceptionHandlersWorker (VectorInfo, ExceptionHandlerData);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
FreePool (ReservedVectors);
|
||||||
|
FreePool (ExceptionHandlerData);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Build location of CPU MP DATA buffer in HOB
|
||||||
|
//
|
||||||
|
BuildGuidDataHob (
|
||||||
|
&mCpuExceptrionHandlerLibHobGuid,
|
||||||
|
(VOID *)&ExceptionHandlerData,
|
||||||
|
sizeof(UINT64)
|
||||||
|
);
|
||||||
|
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Initializes all CPU interrupt/exceptions entries and provides the default interrupt/exception handlers.
|
||||||
|
|
||||||
|
Caller should try to get an array of interrupt and/or exception vectors that are in use and need to
|
||||||
|
persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification.
|
||||||
|
If caller cannot get reserved vector list or it does not exists, set VectorInfo to NULL.
|
||||||
|
If VectorInfo is not NULL, the exception vectors will be initialized per vector attribute accordingly.
|
||||||
|
|
||||||
|
@param[in] VectorInfo Pointer to reserved vector list.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS All CPU interrupt/exception entries have been successfully initialized
|
||||||
|
with default interrupt/exception handlers.
|
||||||
|
@retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL.
|
||||||
|
@retval EFI_UNSUPPORTED This function is not supported.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
InitializeCpuInterruptHandlers (
|
||||||
|
IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return EFI_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Registers a function to be called from the processor interrupt handler.
|
||||||
|
|
||||||
|
This function registers and enables the handler specified by InterruptHandler for a processor
|
||||||
|
interrupt or exception type specified by InterruptType. If InterruptHandler is NULL, then the
|
||||||
|
handler for the processor interrupt or exception type specified by InterruptType is uninstalled.
|
||||||
|
The installed handler is called once for each processor interrupt or exception.
|
||||||
|
NOTE: This function should be invoked after InitializeCpuExceptionHandlers() or
|
||||||
|
InitializeCpuInterruptHandlers() invoked, otherwise EFI_UNSUPPORTED returned.
|
||||||
|
|
||||||
|
@param[in] InterruptType Defines which interrupt or exception to hook.
|
||||||
|
@param[in] InterruptHandler A pointer to a function of type EFI_CPU_INTERRUPT_HANDLER that is called
|
||||||
|
when a processor interrupt occurs. If this parameter is NULL, then the handler
|
||||||
|
will be uninstalled.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The handler for the processor interrupt was successfully installed or uninstalled.
|
||||||
|
@retval EFI_ALREADY_STARTED InterruptHandler is not NULL, and a handler for InterruptType was
|
||||||
|
previously installed.
|
||||||
|
@retval EFI_INVALID_PARAMETER InterruptHandler is NULL, and a handler for InterruptType was not
|
||||||
|
previously installed.
|
||||||
|
@retval EFI_UNSUPPORTED The interrupt specified by InterruptType is not supported,
|
||||||
|
or this function is not supported.
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
RegisterCpuInterruptHandler (
|
||||||
|
IN EFI_EXCEPTION_TYPE InterruptType,
|
||||||
|
IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return EFI_UNSUPPORTED;
|
||||||
|
}
|
|
@ -0,0 +1,61 @@
|
||||||
|
## @file
|
||||||
|
# CPU Exception Handler library instance for PEI module.
|
||||||
|
#
|
||||||
|
# Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
##
|
||||||
|
|
||||||
|
[Defines]
|
||||||
|
INF_VERSION = 0x00010005
|
||||||
|
BASE_NAME = PeiCpuExceptionHandlerLib
|
||||||
|
MODULE_UNI_FILE = PeiCpuExceptionHandlerLib.uni
|
||||||
|
FILE_GUID = 980DDA67-44A6-4897-99E6-275290B71F9E
|
||||||
|
MODULE_TYPE = PEIM
|
||||||
|
VERSION_STRING = 1.1
|
||||||
|
LIBRARY_CLASS = CpuExceptionHandlerLib|PEI_CORE PEIM
|
||||||
|
|
||||||
|
#
|
||||||
|
# The following information is for reference only and not required by the build tools.
|
||||||
|
#
|
||||||
|
# VALID_ARCHITECTURES = IA32 X64
|
||||||
|
#
|
||||||
|
|
||||||
|
[Sources.Ia32]
|
||||||
|
Ia32/ExceptionHandlerAsm.asm
|
||||||
|
Ia32/ExceptionHandlerAsm.S |GCC
|
||||||
|
Ia32/ArchExceptionHandler.c
|
||||||
|
Ia32/ArchInterruptDefs.h
|
||||||
|
|
||||||
|
[Sources.X64]
|
||||||
|
X64/ExceptionHandlerAsm.asm
|
||||||
|
X64/ExceptionHandlerAsm.S |GCC
|
||||||
|
X64/ArchExceptionHandler.c
|
||||||
|
X64/ArchInterruptDefs.h
|
||||||
|
|
||||||
|
[Sources.common]
|
||||||
|
CpuExceptionCommon.h
|
||||||
|
CpuExceptionCommon.c
|
||||||
|
PeiCpuException.c
|
||||||
|
PeiDxeSmmCpuException.c
|
||||||
|
|
||||||
|
[Packages]
|
||||||
|
MdePkg/MdePkg.dec
|
||||||
|
MdeModulePkg/MdeModulePkg.dec
|
||||||
|
UefiCpuPkg/UefiCpuPkg.dec
|
||||||
|
|
||||||
|
[LibraryClasses]
|
||||||
|
BaseLib
|
||||||
|
SerialPortLib
|
||||||
|
PrintLib
|
||||||
|
LocalApicLib
|
||||||
|
PeCoffGetEntryPointLib
|
||||||
|
HobLib
|
||||||
|
MemoryAllocationLib
|
||||||
|
SynchronizationLib
|
|
@ -0,0 +1,22 @@
|
||||||
|
// /** @file
|
||||||
|
// CPU Exception Handler library instance for PEI module.
|
||||||
|
//
|
||||||
|
// CPU Exception Handler library instance for PEI module.
|
||||||
|
//
|
||||||
|
// Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
|
||||||
|
//
|
||||||
|
// 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.
|
||||||
|
//
|
||||||
|
// **/
|
||||||
|
|
||||||
|
|
||||||
|
#string STR_MODULE_ABSTRACT #language en-US "CPU Exception Handler library instance for PEI module."
|
||||||
|
|
||||||
|
#string STR_MODULE_DESCRIPTION #language en-US "CPU Exception Handler library instance for PEI module."
|
||||||
|
|
|
@ -73,6 +73,7 @@
|
||||||
|
|
||||||
[LibraryClasses.IA32.PEIM, LibraryClasses.X64.PEIM]
|
[LibraryClasses.IA32.PEIM, LibraryClasses.X64.PEIM]
|
||||||
PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf
|
PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf
|
||||||
|
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf
|
||||||
|
|
||||||
[LibraryClasses.IPF.PEIM]
|
[LibraryClasses.IPF.PEIM]
|
||||||
PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibKr7/PeiServicesTablePointerLibKr7.inf
|
PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibKr7/PeiServicesTablePointerLibKr7.inf
|
||||||
|
@ -113,6 +114,7 @@
|
||||||
UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
|
UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
|
||||||
UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf
|
UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf
|
||||||
UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf
|
UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf
|
||||||
|
UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf
|
||||||
UefiCpuPkg/Library/MtrrLib/MtrrLib.inf
|
UefiCpuPkg/Library/MtrrLib/MtrrLib.inf
|
||||||
UefiCpuPkg/Library/PlatformSecLibNull/PlatformSecLibNull.inf
|
UefiCpuPkg/Library/PlatformSecLibNull/PlatformSecLibNull.inf
|
||||||
UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.inf
|
UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.inf
|
||||||
|
|
Loading…
Reference in New Issue