]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.c
MdePkg: Clean up source files
[mirror_edk2.git] / MdePkg / Library / SmmServicesTableLib / SmmServicesTableLib.c
CommitLineData
b7c5912a 1/** @file\r
2 SMM Services Table Library.\r
3\r
9095d37b 4 Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
19388d29 5 This program and the accompanying materials\r
b7c5912a 6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
2fc59a00 8 http://opensource.org/licenses/bsd-license.php.\r
b7c5912a 9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
b7c5912a 15#include <PiSmm.h>\r
16#include <Protocol/SmmBase2.h>\r
b7c5912a 17#include <Library/SmmServicesTableLib.h>\r
18#include <Library/DebugLib.h>\r
19\r
53b85bcb 20EFI_SMM_SYSTEM_TABLE2 *gSmst = NULL;\r
b7c5912a 21\r
22/**\r
53b85bcb 23 The constructor function caches the pointer of SMM Services Table.\r
b7c5912a 24\r
25 @param ImageHandle The firmware allocated handle for the EFI image.\r
26 @param SystemTable A pointer to the EFI System Table.\r
27\r
28 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.\r
29\r
30**/\r
31EFI_STATUS\r
32EFIAPI\r
33SmmServicesTableLibConstructor (\r
34 IN EFI_HANDLE ImageHandle,\r
35 IN EFI_SYSTEM_TABLE *SystemTable\r
36 )\r
37{\r
4e904348
JF
38 EFI_STATUS Status;\r
39 EFI_SMM_BASE2_PROTOCOL *InternalSmmBase2;\r
b7c5912a 40\r
4e904348 41 InternalSmmBase2 = NULL;\r
b7c5912a 42 //\r
53b85bcb 43 // Retrieve SMM Base2 Protocol, Do not use gBS from UefiBootServicesTableLib on purpose\r
9095d37b
LG
44 // to prevent inclusion of gBS, gST, and gImageHandle from SMM Drivers unless the\r
45 // SMM driver explicity declares that dependency.\r
b7c5912a 46 //\r
53b85bcb 47 Status = SystemTable->BootServices->LocateProtocol (\r
48 &gEfiSmmBase2ProtocolGuid,\r
49 NULL,\r
4e904348 50 (VOID **)&InternalSmmBase2\r
53b85bcb 51 );\r
b7c5912a 52 ASSERT_EFI_ERROR (Status);\r
4e904348 53 ASSERT (InternalSmmBase2 != NULL);\r
b7c5912a 54\r
55 //\r
56 // We are in SMM, retrieve the pointer to SMM System Table\r
57 //\r
4e904348 58 InternalSmmBase2->GetSmstLocation (InternalSmmBase2, &gSmst);\r
b7c5912a 59 ASSERT (gSmst != NULL);\r
60\r
61 return EFI_SUCCESS;\r
62}\r
63\r
b7c5912a 64/**\r
9095d37b 65 This function allows the caller to determine if the driver is executing in\r
b7c5912a 66 System Management Mode(SMM).\r
67\r
9095d37b 68 This function returns TRUE if the driver is executing in SMM and FALSE if the\r
b7c5912a 69 driver is not executing in SMM.\r
70\r
71 @retval TRUE The driver is executing in System Management Mode (SMM).\r
9095d37b 72 @retval FALSE The driver is not executing in System Management Mode (SMM).\r
b7c5912a 73\r
74**/\r
75BOOLEAN\r
76EFIAPI\r
77InSmm (\r
78 VOID\r
79 )\r
80{\r
b7c5912a 81 //\r
4e904348 82 // We are already in SMM\r
b7c5912a 83 //\r
4e904348 84 return TRUE;\r
b7c5912a 85}\r