2 UEFI Dxe DebugLib constructor that prevent some debug service after ExitBootServices event,
3 because some pointer is nulled at that phase.
5 Copyright (c) 2018, Microsoft Corporation
6 Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.<BR>
8 SPDX-License-Identifier: BSD-2-Clause-Patent
12 #include <Library/BaseLib.h>
13 #include <Library/BaseMemoryLib.h>
16 // BOOLEAN value to indicate if it is at the post ExitBootServices pahse
18 BOOLEAN mPostEBS
= FALSE
;
20 static EFI_EVENT mExitBootServicesEvent
;
23 // Pointer to SystemTable
24 // This library instance may have a cycle consume with UefiBootServicesTableLib
25 // because of the constructors.
27 EFI_SYSTEM_TABLE
*mDebugST
;
30 This routine sets the mPostEBS for exit boot servies true
31 to prevent DebugPort protocol dereferences when the pointer is nulled.
33 @param Event Event whose notification function is being invoked.
34 @param Context Pointer to the notification function's context.
39 ExitBootServicesCallback (
49 The constructor gets the pointers to the system table.
50 And create a event to indicate it is after ExitBootServices.
52 @param ImageHandle The firmware allocated handle for the EFI image.
53 @param SystemTable A pointer to the EFI System Table.
55 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
60 DxeDebugLibConstructor (
61 IN EFI_HANDLE ImageHandle
,
62 IN EFI_SYSTEM_TABLE
*SystemTable
65 mDebugST
= SystemTable
;
67 SystemTable
->BootServices
->CreateEvent (
68 EVT_SIGNAL_EXIT_BOOT_SERVICES
,
70 ExitBootServicesCallback
,
72 &mExitBootServicesEvent
79 The destructor closes Exit Boot Services Event.
81 @param ImageHandle The firmware allocated handle for the EFI image.
82 @param SystemTable A pointer to the EFI System Table.
84 @retval EFI_SUCCESS The destructor always returns EFI_SUCCESS.
89 DxeDebugLibDestructor (
90 IN EFI_HANDLE ImageHandle
,
91 IN EFI_SYSTEM_TABLE
*SystemTable
94 if (mExitBootServicesEvent
!= NULL
) {
95 SystemTable
->BootServices
->CloseEvent (mExitBootServicesEvent
);