MdeModulePkg: StatusCodeHandler: StatusCodeHandler driver in StandaloneMm

This change added support of StandaloneMm for StatusCodeHandler. It
adds a new instance of StatusCodeHandler of MM_STANDALONE type, and
abstracts the driver entrypoint into separate files, replaced gSmst with
gMmst, and switched to MM version of RscHandlerProtocol.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Jiewen Yao <jiewen.yao@intel.com>

Signed-off-by: Kun Qin <kun.q@outlook.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
This commit is contained in:
Kun Qin
2020-12-31 01:56:51 -08:00
parent 5625c1fdf7
commit 8a09cdd7be
9 changed files with 180 additions and 45 deletions

View File

@ -476,6 +476,7 @@
MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCodeLib.inf MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCodeLib.inf
MdeModulePkg/Library/SmmReportStatusCodeLib/StandaloneMmReportStatusCodeLib.inf MdeModulePkg/Library/SmmReportStatusCodeLib/StandaloneMmReportStatusCodeLib.inf
MdeModulePkg/Universal/StatusCodeHandler/Smm/StatusCodeHandlerSmm.inf MdeModulePkg/Universal/StatusCodeHandler/Smm/StatusCodeHandlerSmm.inf
MdeModulePkg/Universal/StatusCodeHandler/Smm/StatusCodeHandlerStandaloneMm.inf
MdeModulePkg/Universal/ReportStatusCodeRouter/Smm/ReportStatusCodeRouterSmm.inf MdeModulePkg/Universal/ReportStatusCodeRouter/Smm/ReportStatusCodeRouterSmm.inf
MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.inf MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.inf
MdeModulePkg/Library/SmmMemoryAllocationProfileLib/SmmMemoryAllocationProfileLib.inf MdeModulePkg/Library/SmmMemoryAllocationProfileLib/SmmMemoryAllocationProfileLib.inf

View File

@ -7,15 +7,15 @@
**/ **/
#include "StatusCodeHandlerSmm.h" #include "StatusCodeHandlerMm.h"
RUNTIME_MEMORY_STATUSCODE_HEADER *mSmmMemoryStatusCodeTable; RUNTIME_MEMORY_STATUSCODE_HEADER *mMmMemoryStatusCodeTable;
/** /**
Initialize SMM memory status code table as initialization for memory status code worker Initialize MM memory status code table as initialization for memory status code worker
@retval EFI_SUCCESS SMM memory status code table successfully initialized. @retval EFI_SUCCESS MM memory status code table successfully initialized.
@retval others Errors from gSmst->SmmInstallConfigurationTable(). @retval others Errors from gMmst->MmInstallConfigurationTable().
**/ **/
EFI_STATUS EFI_STATUS
MemoryStatusCodeInitializeWorker ( MemoryStatusCodeInitializeWorker (
@ -25,17 +25,17 @@ MemoryStatusCodeInitializeWorker (
EFI_STATUS Status; EFI_STATUS Status;
// //
// Allocate SMM memory status code pool. // Allocate MM memory status code pool.
// //
mSmmMemoryStatusCodeTable = (RUNTIME_MEMORY_STATUSCODE_HEADER *)AllocateZeroPool (sizeof (RUNTIME_MEMORY_STATUSCODE_HEADER) + PcdGet16 (PcdStatusCodeMemorySize) * 1024); mMmMemoryStatusCodeTable = (RUNTIME_MEMORY_STATUSCODE_HEADER *)AllocateZeroPool (sizeof (RUNTIME_MEMORY_STATUSCODE_HEADER) + PcdGet16 (PcdStatusCodeMemorySize) * 1024);
ASSERT (mSmmMemoryStatusCodeTable != NULL); ASSERT (mMmMemoryStatusCodeTable != NULL);
mSmmMemoryStatusCodeTable->MaxRecordsNumber = (PcdGet16 (PcdStatusCodeMemorySize) * 1024) / sizeof (MEMORY_STATUSCODE_RECORD); mMmMemoryStatusCodeTable->MaxRecordsNumber = (PcdGet16 (PcdStatusCodeMemorySize) * 1024) / sizeof (MEMORY_STATUSCODE_RECORD);
Status = gSmst->SmmInstallConfigurationTable ( Status = gMmst->MmInstallConfigurationTable (
gSmst, gMmst,
&gMemoryStatusCodeRecordGuid, &gMemoryStatusCodeRecordGuid,
&mSmmMemoryStatusCodeTable, &mMmMemoryStatusCodeTable,
sizeof (mSmmMemoryStatusCodeTable) sizeof (mMmMemoryStatusCodeTable)
); );
return Status; return Status;
} }
@ -74,8 +74,8 @@ MemoryStatusCodeReportWorker (
// //
// Locate current record buffer. // Locate current record buffer.
// //
Record = (MEMORY_STATUSCODE_RECORD *) (mSmmMemoryStatusCodeTable + 1); Record = (MEMORY_STATUSCODE_RECORD *) (mMmMemoryStatusCodeTable + 1);
Record = &Record[mSmmMemoryStatusCodeTable->RecordIndex++]; Record = &Record[mMmMemoryStatusCodeTable->RecordIndex++];
// //
// Save status code. // Save status code.
@ -92,12 +92,12 @@ MemoryStatusCodeReportWorker (
// so the first record is pointed by record index. // so the first record is pointed by record index.
// If it is less then max number, index of the first record is zero. // If it is less then max number, index of the first record is zero.
// //
mSmmMemoryStatusCodeTable->NumberOfRecords++; mMmMemoryStatusCodeTable->NumberOfRecords++;
if (mSmmMemoryStatusCodeTable->RecordIndex == mSmmMemoryStatusCodeTable->MaxRecordsNumber) { if (mMmMemoryStatusCodeTable->RecordIndex == mMmMemoryStatusCodeTable->MaxRecordsNumber) {
// //
// Wrap around record index. // Wrap around record index.
// //
mSmmMemoryStatusCodeTable->RecordIndex = 0; mMmMemoryStatusCodeTable->RecordIndex = 0;
} }
return EFI_SUCCESS; return EFI_SUCCESS;

View File

@ -6,7 +6,7 @@
**/ **/
#include "StatusCodeHandlerSmm.h" #include "StatusCodeHandlerMm.h"
/** /**
Convert status code value and extended data to readable ASCII string, send string to serial I/O device. Convert status code value and extended data to readable ASCII string, send string to serial I/O device.

View File

@ -1,15 +1,15 @@
/** @file /** @file
Status Code Handler Driver which produces general handlers and hook them Status Code Handler Driver which produces general handlers and hook them
onto the SMM status code router. onto the MM status code router.
Copyright (c) 2009 - 2020, Intel Corporation. All rights reserved.<BR> Copyright (c) 2009 - 2020, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent SPDX-License-Identifier: BSD-2-Clause-Patent
**/ **/
#include "StatusCodeHandlerSmm.h" #include "StatusCodeHandlerMm.h"
EFI_SMM_RSC_HANDLER_PROTOCOL *mRscHandlerProtocol = NULL; EFI_MM_RSC_HANDLER_PROTOCOL *mRscHandlerProtocol = NULL;
/** /**
@ -42,27 +42,22 @@ InitializationDispatcherWorker (
} }
/** /**
Entry point of SMM Status Code Driver. Entry point of Common MM Status Code Driver.
This function is the entry point of SMM Status Code Driver. This function is the entry point of MM Status Code Driver.
@param ImageHandle The firmware allocated handle for the EFI image.
@param SystemTable A pointer to the EFI System Table.
@retval EFI_SUCCESS The entry point is executed successfully. @retval EFI_SUCCESS The entry point is executed successfully.
**/ **/
EFI_STATUS EFI_STATUS
EFIAPI StatusCodeHandlerCommonEntry (
StatusCodeHandlerSmmEntry ( VOID
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
) )
{ {
EFI_STATUS Status; EFI_STATUS Status;
Status = gSmst->SmmLocateProtocol ( Status = gMmst->MmLocateProtocol (
&gEfiSmmRscHandlerProtocolGuid, &gEfiMmRscHandlerProtocolGuid,
NULL, NULL,
(VOID **) &mRscHandlerProtocol (VOID **) &mRscHandlerProtocol
); );

View File

@ -7,10 +7,10 @@
**/ **/
#ifndef __STATUS_CODE_HANDLER_SMM_H__ #ifndef __STATUS_CODE_HANDLER_MM_H__
#define __STATUS_CODE_HANDLER_SMM_H__ #define __STATUS_CODE_HANDLER_MM_H__
#include <Protocol/SmmReportStatusCodeHandler.h> #include <Protocol/MmReportStatusCodeHandler.h>
#include <Guid/MemoryStatusCodeRecord.h> #include <Guid/MemoryStatusCodeRecord.h>
#include <Guid/StatusCodeDataTypeId.h> #include <Guid/StatusCodeDataTypeId.h>
@ -22,7 +22,7 @@
#include <Library/PrintLib.h> #include <Library/PrintLib.h>
#include <Library/PcdLib.h> #include <Library/PcdLib.h>
#include <Library/UefiDriverEntryPoint.h> #include <Library/UefiDriverEntryPoint.h>
#include <Library/SmmServicesTableLib.h> #include <Library/MmServicesTableLib.h>
#include <Library/SerialPortLib.h> #include <Library/SerialPortLib.h>
#include <Library/MemoryAllocationLib.h> #include <Library/MemoryAllocationLib.h>
#include <Library/BaseMemoryLib.h> #include <Library/BaseMemoryLib.h>
@ -32,7 +32,7 @@
// //
#define MAX_DEBUG_MESSAGE_LENGTH 0x100 #define MAX_DEBUG_MESSAGE_LENGTH 0x100
extern RUNTIME_MEMORY_STATUSCODE_HEADER *mSmmMemoryStatusCodeTable; extern RUNTIME_MEMORY_STATUSCODE_HEADER *mMmMemoryStatusCodeTable;
/** /**
Locates Serial I/O Protocol as initialization for serial status code worker. Locates Serial I/O Protocol as initialization for serial status code worker.
@ -114,4 +114,17 @@ MemoryStatusCodeReportWorker (
IN EFI_STATUS_CODE_DATA *Data OPTIONAL IN EFI_STATUS_CODE_DATA *Data OPTIONAL
); );
/**
Entry point of Common MM Status Code Driver.
This function is the entry point of MM Status Code Driver.
@retval EFI_SUCCESS The entry point is executed successfully.
**/
EFI_STATUS
StatusCodeHandlerCommonEntry (
VOID
);
#endif #endif

View File

@ -1,5 +1,5 @@
## @file ## @file
# Status Code Handler Driver which produces general handlers and hook them onto the SMM status code router. # Status Code Handler Driver which produces general handlers and hook them onto the MM status code router.
# #
# Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR> # Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
# (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR> # (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
@ -17,7 +17,7 @@
MODULE_TYPE = DXE_SMM_DRIVER MODULE_TYPE = DXE_SMM_DRIVER
PI_SPECIFICATION_VERSION = 0x0001000A PI_SPECIFICATION_VERSION = 0x0001000A
VERSION_STRING = 1.0 VERSION_STRING = 1.0
ENTRY_POINT = StatusCodeHandlerSmmEntry ENTRY_POINT = StatusCodeHandlerTraditionalMmEntry
# #
# The following information is for reference only and not required by the build tools. # The following information is for reference only and not required by the build tools.
@ -26,8 +26,9 @@
# #
[Sources] [Sources]
StatusCodeHandlerSmm.c StatusCodeHandlerMm.c
StatusCodeHandlerSmm.h StatusCodeHandlerMm.h
StatusCodeHandlerTraditional.c
SerialStatusCodeWorker.c SerialStatusCodeWorker.c
MemoryStatusCodeWorker.c MemoryStatusCodeWorker.c
@ -37,7 +38,7 @@
[LibraryClasses] [LibraryClasses]
SerialPortLib SerialPortLib
SmmServicesTableLib MmServicesTableLib
UefiDriverEntryPoint UefiDriverEntryPoint
PcdLib PcdLib
PrintLib PrintLib
@ -51,7 +52,7 @@
gMemoryStatusCodeRecordGuid ## SOMETIMES_PRODUCES ## UNDEFINED # SmmSystemTable gMemoryStatusCodeRecordGuid ## SOMETIMES_PRODUCES ## UNDEFINED # SmmSystemTable
[Protocols] [Protocols]
gEfiSmmRscHandlerProtocolGuid ## CONSUMES gEfiMmRscHandlerProtocolGuid ## CONSUMES
[Pcd] [Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseSerial ## CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseSerial ## CONSUMES
@ -59,7 +60,7 @@
gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize |128| gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseMemory ## SOMETIMES_CONSUMES gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize |128| gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseMemory ## SOMETIMES_CONSUMES
[Depex] [Depex]
gEfiSmmRscHandlerProtocolGuid gEfiMmRscHandlerProtocolGuid
[UserExtensions.TianoCore."ExtraFiles"] [UserExtensions.TianoCore."ExtraFiles"]
StatusCodeHandlerSmmExtra.uni StatusCodeHandlerSmmExtra.uni

View File

@ -0,0 +1,31 @@
/** @file
Abstraction layer that contains Standalone MM specific implementation for
Status Code Handler Driver.
Copyright (c) Microsoft Corporation.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include "StatusCodeHandlerMm.h"
/**
Entry point of Standalone MM Status Code Driver.
This function is the entry point of Standalone MM Status Code Driver.
@param ImageHandle The firmware allocated handle for the EFI image.
@param SystemTable A pointer to the EFI MM System Table.
@retval EFI_SUCCESS The entry point is executed successfully.
**/
EFI_STATUS
EFIAPI
StatusCodeHandlerStandaloneMmEntry (
IN EFI_HANDLE ImageHandle,
IN EFI_MM_SYSTEM_TABLE *SystemTable
)
{
return StatusCodeHandlerCommonEntry ();
}

View File

@ -0,0 +1,63 @@
## @file
# Status Code Handler Driver which produces general handlers and hook them onto the MM status code router.
#
# Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
# (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
# Copyright (c) Microsoft Corporation.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
#
##
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = StatusCodeHandlerStandaloneMm
FILE_GUID = EBE7802F-5E11-4D4E-B463-22D2425D156B
MODULE_TYPE = MM_STANDALONE
PI_SPECIFICATION_VERSION = 0x00010032
VERSION_STRING = 1.0
ENTRY_POINT = StatusCodeHandlerStandaloneMmEntry
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64
#
[Sources]
StatusCodeHandlerMm.c
StatusCodeHandlerMm.h
StatusCodeHandlerStandalone.c
SerialStatusCodeWorker.c
MemoryStatusCodeWorker.c
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
[LibraryClasses]
SerialPortLib
MmServicesTableLib
StandaloneMmDriverEntryPoint
PcdLib
PrintLib
ReportStatusCodeLib
DebugLib
MemoryAllocationLib
BaseMemoryLib
[Guids]
gEfiStatusCodeDataTypeStringGuid ## SOMETIMES_CONSUMES ## UNDEFINED
gMemoryStatusCodeRecordGuid ## SOMETIMES_PRODUCES ## UNDEFINED # MmSystemTable
[Protocols]
gEfiMmRscHandlerProtocolGuid ## CONSUMES
[Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseSerial ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseMemory ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeMemorySize |128| gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseMemory ## SOMETIMES_CONSUMES
[Depex]
gEfiMmRscHandlerProtocolGuid

View File

@ -0,0 +1,31 @@
/** @file
Abstraction layer that contains Standalone MM specific implementation for
Status Code Handler Driver.
Copyright (c) Microsoft Corporation.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include "StatusCodeHandlerMm.h"
/**
Entry point of Traditional MM Status Code Driver.
This function is the entry point of Traditional MM Status Code Driver.
@param ImageHandle The firmware allocated handle for the EFI image.
@param SystemTable A pointer to the EFI System Table.
@retval EFI_SUCCESS The entry point is executed successfully.
**/
EFI_STATUS
EFIAPI
StatusCodeHandlerTraditionalMmEntry (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
return StatusCodeHandlerCommonEntry ();
}