Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support the platform specific event hooks which can be customized. #469

Closed
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions MsCorePkg/Include/Library/BdsPlatformEventLib.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
This file include the platform specific event hooks which can be customized by IBV/OEM.

Copyright (C) Microsoft Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

**/

#ifndef _BDS_PLATFORM_EVENT_LIB_H_
#define _BDS_PLATFORM_EVENT_LIB_H_

/**
The Hook Before End Of Dxe Event. it used for customized porting.
**/
VOID
BeforeEndOfDxeEventHook (
VOID
);

/**
The Hook After End Of Dxe Event. it used for customized porting.
**/
VOID
AfterEndOfDxeEventHook (
VOID
);

/**
The Hook Dispatch the deferred 3rd party images Event. it used for customized porting.
**/
VOID
AfterDispatchDeferredImagesHook (
VOID
);

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/** @file
This file include the platform specific event hooks which can be customized by IBV/OEM.

Copyright (C) Microsoft Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

**/

#include <Uefi.h>

/**
The Hook Before End Of Dxe Event. it used for customized porting.
**/
VOID
BeforeEndOfDxeEventHook (
VOID
)
{
return;
}

/**
The Hook After End Of Dxe Event. it used for customized porting.
**/
VOID
AfterEndOfDxeEventHook (
VOID
)
{
return;
}

/**
The Hook Dispatch the deferred 3rd party images Event. it used for customized porting.
**/
VOID
AfterDispatchDeferredImagesHook (
VOID
)
{
return;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/** @file
*This file include the platform specific event hooks which can be customized by IBV/OEM.

Copyright (C) Microsoft Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

**/


[Defines]
INF_VERSION = 0x00010018
BASE_NAME = BdsPlatformEventLibNull
FILE_GUID = 55000994-06FB-43AB-A648-CD9CB2A7B273
VERSION_STRING = 1.0
MODULE_TYPE = DXE_DRIVER
UEFI_SPECIFICATION_VERSION = 2.7
LIBRARY_CLASS = BdsPlatformEventLib|DXE_DRIVER

#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 EBC
#

[Sources]
BdsPlatformEventLibNull.c

[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
MsCorePkg/MsCorePkg.dec

[LibraryClasses]
BaseLib
6 changes: 6 additions & 0 deletions MsCorePkg/Library/PlatformBootManagerLib/BdsPlatform.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,15 @@ ExitPmAuth (

DEBUG ((DEBUG_INFO, "ExitPmAuth ()- Start\n"));

BeforeEndOfDxeEventHook (); // MS_CHANGE
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is in MU_PLUS, we should not need to use MS_CHANGE tags in this PR.


//
// Since PI1.2.1, we need signal EndOfDxe as ExitPmAuth
//
EfiEventGroupSignal (&gEfiEndOfDxeEventGroupGuid);

AfterEndOfDxeEventHook (); // MS_CHANGE
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the usage of these hooks?

Also, is the abstraction method better than the event signaling? i.e. line 49?

@apop5 @spbrogan thoughts?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In practical cases, we would use these hooks to send platform-specific events to enable the functionality to be activated properly.

Why I choose to use a library instead of send EventGroupSignal, the reason is that after the platform receives the event callback, the callback function will send its platform-specific events. I'm concerned about potential nesting of muti-events.


DEBUG ((DEBUG_INFO, "All EndOfDxe callbacks have returned successfully\n"));

//
Expand Down Expand Up @@ -267,6 +271,8 @@ PlatformBootManagerBeforeConsole (
// Dispatch the deferred 3rd party images.
//
EfiBootManagerDispatchDeferredImages ();

AfterDispatchDeferredImagesHook (); // MS_CHANGE
}

VOID
Expand Down
1 change: 1 addition & 0 deletions MsCorePkg/Library/PlatformBootManagerLib/BdsPlatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/DeviceBootManagerLib.h>
#include <Library/HobLib.h>
#include <Library/PerformanceLib.h>
#include <Library/BdsPlatformEventLib.h> // MS_CHANGE

#include <IndustryStandard/Pci30.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ CONSTRUCTOR = PlatformBootManagerEntry
UefiBootServicesTableLib
UefiLib
UefiRuntimeServicesTableLib
BdsPlatformEventLib # MS_CHANGE

[Protocols]
gEfiPciRootBridgeIoProtocolGuid ## CONSUMES
Expand Down
4 changes: 4 additions & 0 deletions MsCorePkg/MsCorePkg.dec
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@
#
MacAddressEmulationPlatformLib|Include/Library/MacAddressEmulationPlatformLib.h

## @libraryclass Supports the platform specific event hooks.
#
BdsPlatformEventLib|Include/Library/BdsPlatformEventLib.h

[Guids]
# {a2966407-1f6b-4c86-b21e-fcc474c6f28e}
gMsCorePkgTokenSpaceGuid = { 0xa2966407, 0x1f6b, 0x4c86, { 0xb2, 0x1e, 0xfc, 0xc4, 0x74, 0xc6, 0xf2, 0x8e }}
Expand Down
3 changes: 3 additions & 0 deletions MsCorePkg/MsCorePkg.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@

MacAddressEmulationPlatformLib|MsCorePkg/Library/MacAddressEmulationPlatformLibNull/MacAddressEmulationPlatformLibNull.inf

BdsPlatformEventLib|MsCorePkg/Library/BdsPlatformEventLibNull/BdsPlatformEventLibNull.inf

[LibraryClasses.common.UEFI_APPLICATION]
UnitTestPersistenceLib|UnitTestFrameworkPkg/Library/UnitTestPersistenceLibSimpleFileSystem/UnitTestPersistenceLibSimpleFileSystem.inf
UnitTestResultReportLib|XmlSupportPkg/Library/UnitTestResultReportJUnitFormatLib/UnitTestResultReportLib.inf
Expand Down Expand Up @@ -206,6 +208,7 @@
}
MsCorePkg/MacAddressEmulationDxe/MacAddressEmulationDxe.inf
MsCorePkg/Library/MacAddressEmulationPlatformLibNull/MacAddressEmulationPlatformLibNull.inf
MsCorePkg/Library/BdsPlatformEventLibNull/BdsPlatformEventLibNull.inf

[Components.AARCH64, Components.AARCH64]
MsCorePkg/Library/MemoryProtectionExceptionHandlerLib/MemoryProtectionExceptionHandlerLib.inf
Expand Down
Loading