]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | SMM Services Table Library.\r | |
3 | \r | |
4 | Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r | |
5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r | |
6 | \r | |
7 | **/\r | |
8 | \r | |
9 | #include <PiSmm.h>\r | |
10 | #include <Protocol/SmmBase2.h>\r | |
11 | #include <Library/SmmServicesTableLib.h>\r | |
12 | #include <Library/DebugLib.h>\r | |
13 | \r | |
14 | EFI_SMM_SYSTEM_TABLE2 *gSmst = NULL;\r | |
15 | \r | |
16 | /**\r | |
17 | The constructor function caches the pointer of SMM Services Table.\r | |
18 | \r | |
19 | @param ImageHandle The firmware allocated handle for the EFI image.\r | |
20 | @param SystemTable A pointer to the EFI System Table.\r | |
21 | \r | |
22 | @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.\r | |
23 | \r | |
24 | **/\r | |
25 | EFI_STATUS\r | |
26 | EFIAPI\r | |
27 | SmmServicesTableLibConstructor (\r | |
28 | IN EFI_HANDLE ImageHandle,\r | |
29 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
30 | )\r | |
31 | {\r | |
32 | EFI_STATUS Status;\r | |
33 | EFI_SMM_BASE2_PROTOCOL *InternalSmmBase2;\r | |
34 | \r | |
35 | InternalSmmBase2 = NULL;\r | |
36 | //\r | |
37 | // Retrieve SMM Base2 Protocol, Do not use gBS from UefiBootServicesTableLib on purpose\r | |
38 | // to prevent inclusion of gBS, gST, and gImageHandle from SMM Drivers unless the\r | |
39 | // SMM driver explicitly declares that dependency.\r | |
40 | //\r | |
41 | Status = SystemTable->BootServices->LocateProtocol (\r | |
42 | &gEfiSmmBase2ProtocolGuid,\r | |
43 | NULL,\r | |
44 | (VOID **)&InternalSmmBase2\r | |
45 | );\r | |
46 | ASSERT_EFI_ERROR (Status);\r | |
47 | ASSERT (InternalSmmBase2 != NULL);\r | |
48 | \r | |
49 | //\r | |
50 | // We are in SMM, retrieve the pointer to SMM System Table\r | |
51 | //\r | |
52 | InternalSmmBase2->GetSmstLocation (InternalSmmBase2, &gSmst);\r | |
53 | ASSERT (gSmst != NULL);\r | |
54 | \r | |
55 | return EFI_SUCCESS;\r | |
56 | }\r | |
57 | \r | |
58 | /**\r | |
59 | This function allows the caller to determine if the driver is executing in\r | |
60 | System Management Mode(SMM).\r | |
61 | \r | |
62 | This function returns TRUE if the driver is executing in SMM and FALSE if the\r | |
63 | driver is not executing in SMM.\r | |
64 | \r | |
65 | @retval TRUE The driver is executing in System Management Mode (SMM).\r | |
66 | @retval FALSE The driver is not executing in System Management Mode (SMM).\r | |
67 | \r | |
68 | **/\r | |
69 | BOOLEAN\r | |
70 | EFIAPI\r | |
71 | InSmm (\r | |
72 | VOID\r | |
73 | )\r | |
74 | {\r | |
75 | //\r | |
76 | // We are already in SMM\r | |
77 | //\r | |
78 | return TRUE;\r | |
79 | }\r |