]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.c
MdePkg/Library/Smm: Fix various typos
[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
9344f092 5 SPDX-License-Identifier: BSD-2-Clause-Patent\r
b7c5912a 6\r
7**/\r
8\r
b7c5912a 9#include <PiSmm.h>\r
10#include <Protocol/SmmBase2.h>\r
b7c5912a 11#include <Library/SmmServicesTableLib.h>\r
12#include <Library/DebugLib.h>\r
13\r
53b85bcb 14EFI_SMM_SYSTEM_TABLE2 *gSmst = NULL;\r
b7c5912a 15\r
16/**\r
53b85bcb 17 The constructor function caches the pointer of SMM Services Table.\r
b7c5912a 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
25EFI_STATUS\r
26EFIAPI\r
27SmmServicesTableLibConstructor (\r
28 IN EFI_HANDLE ImageHandle,\r
29 IN EFI_SYSTEM_TABLE *SystemTable\r
30 )\r
31{\r
4e904348
JF
32 EFI_STATUS Status;\r
33 EFI_SMM_BASE2_PROTOCOL *InternalSmmBase2;\r
b7c5912a 34\r
4e904348 35 InternalSmmBase2 = NULL;\r
b7c5912a 36 //\r
53b85bcb 37 // Retrieve SMM Base2 Protocol, Do not use gBS from UefiBootServicesTableLib on purpose\r
9095d37b 38 // to prevent inclusion of gBS, gST, and gImageHandle from SMM Drivers unless the\r
fae43d06 39 // SMM driver explicitly declares that dependency.\r
b7c5912a 40 //\r
53b85bcb 41 Status = SystemTable->BootServices->LocateProtocol (\r
42 &gEfiSmmBase2ProtocolGuid,\r
43 NULL,\r
4e904348 44 (VOID **)&InternalSmmBase2\r
53b85bcb 45 );\r
b7c5912a 46 ASSERT_EFI_ERROR (Status);\r
4e904348 47 ASSERT (InternalSmmBase2 != NULL);\r
b7c5912a 48\r
49 //\r
50 // We are in SMM, retrieve the pointer to SMM System Table\r
51 //\r
4e904348 52 InternalSmmBase2->GetSmstLocation (InternalSmmBase2, &gSmst);\r
b7c5912a 53 ASSERT (gSmst != NULL);\r
54\r
55 return EFI_SUCCESS;\r
56}\r
57\r
b7c5912a 58/**\r
9095d37b 59 This function allows the caller to determine if the driver is executing in\r
b7c5912a 60 System Management Mode(SMM).\r
61\r
9095d37b 62 This function returns TRUE if the driver is executing in SMM and FALSE if the\r
b7c5912a 63 driver is not executing in SMM.\r
64\r
65 @retval TRUE The driver is executing in System Management Mode (SMM).\r
9095d37b 66 @retval FALSE The driver is not executing in System Management Mode (SMM).\r
b7c5912a 67\r
68**/\r
69BOOLEAN\r
70EFIAPI\r
71InSmm (\r
72 VOID\r
73 )\r
74{\r
b7c5912a 75 //\r
4e904348 76 // We are already in SMM\r
b7c5912a 77 //\r
4e904348 78 return TRUE;\r
b7c5912a 79}\r