]>
Commit | Line | Data |
---|---|---|
2b5778c6 AA |
1 | /** @file\r |
2 | UEFI Dxe DebugLib constructor that prevent some debug service after ExitBootServices event,\r | |
3 | because some pointer is nulled at that phase.\r | |
4 | \r | |
5 | Copyright (c) 2018, Microsoft Corporation\r | |
6 | Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.<BR>\r | |
7 | \r | |
8 | SPDX-License-Identifier: BSD-2-Clause-Patent\r | |
9 | **/\r | |
10 | \r | |
11 | #include <Uefi.h>\r | |
12 | #include <Library/BaseLib.h>\r | |
13 | #include <Library/BaseMemoryLib.h>\r | |
14 | \r | |
15 | //\r | |
16 | // BOOLEAN value to indicate if it is at the post ExitBootServices pahse\r | |
17 | //\r | |
18 | BOOLEAN mPostEBS = FALSE;\r | |
19 | \r | |
7eef3813 | 20 | static EFI_EVENT mExitBootServicesEvent;\r |
2b5778c6 AA |
21 | \r |
22 | //\r | |
23 | // Pointer to SystemTable\r | |
24 | // This library instance may have a cycle consume with UefiBootServicesTableLib\r | |
25 | // because of the constructors.\r | |
26 | //\r | |
27 | EFI_BOOT_SERVICES *mDebugBS;\r | |
28 | \r | |
29 | /**\r | |
30 | This routine sets the mPostEBS for exit boot servies true\r | |
31 | to prevent DebugPort protocol dereferences when the pointer is nulled.\r | |
32 | \r | |
33 | @param Event Event whose notification function is being invoked.\r | |
34 | @param Context Pointer to the notification function's context.\r | |
35 | \r | |
36 | **/\r | |
37 | VOID\r | |
38 | EFIAPI\r | |
39 | ExitBootServicesCallback (\r | |
40 | EFI_EVENT Event,\r | |
41 | VOID* Context\r | |
42 | )\r | |
43 | {\r | |
44 | mPostEBS = TRUE;\r | |
45 | return;\r | |
46 | }\r | |
47 | \r | |
48 | /**\r | |
49 | The constructor gets the pointers to boot services table.\r | |
50 | And create a event to indicate it is after ExitBootServices.\r | |
51 | \r | |
52 | @param ImageHandle The firmware allocated handle for the EFI image.\r | |
53 | @param SystemTable A pointer to the EFI System Table.\r | |
54 | \r | |
55 | @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.\r | |
56 | \r | |
57 | **/\r | |
58 | EFI_STATUS\r | |
59 | EFIAPI\r | |
60 | DxeDebugLibConstructor(\r | |
61 | IN EFI_HANDLE ImageHandle,\r | |
62 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
63 | )\r | |
64 | {\r | |
65 | mDebugBS = SystemTable->BootServices;\r | |
66 | \r | |
67 | mDebugBS->CreateEventEx (\r | |
68 | EVT_NOTIFY_SIGNAL,\r | |
69 | TPL_NOTIFY,\r | |
70 | ExitBootServicesCallback,\r | |
71 | NULL,\r | |
72 | &gEfiEventExitBootServicesGuid,\r | |
73 | &mExitBootServicesEvent\r | |
74 | );\r | |
75 | \r | |
76 | return EFI_SUCCESS;\r | |
77 | }\r |