2 SMM Services Table Library.
4 Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #include <Protocol/SmmBase2.h>
11 #include <Library/SmmServicesTableLib.h>
12 #include <Library/DebugLib.h>
14 EFI_SMM_SYSTEM_TABLE2
*gSmst
= NULL
;
17 The constructor function caches the pointer of SMM Services Table.
19 @param ImageHandle The firmware allocated handle for the EFI image.
20 @param SystemTable A pointer to the EFI System Table.
22 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
27 SmmServicesTableLibConstructor (
28 IN EFI_HANDLE ImageHandle
,
29 IN EFI_SYSTEM_TABLE
*SystemTable
33 EFI_SMM_BASE2_PROTOCOL
*InternalSmmBase2
;
35 InternalSmmBase2
= NULL
;
37 // Retrieve SMM Base2 Protocol, Do not use gBS from UefiBootServicesTableLib on purpose
38 // to prevent inclusion of gBS, gST, and gImageHandle from SMM Drivers unless the
39 // SMM driver explicitly declares that dependency.
41 Status
= SystemTable
->BootServices
->LocateProtocol (
42 &gEfiSmmBase2ProtocolGuid
,
44 (VOID
**)&InternalSmmBase2
46 ASSERT_EFI_ERROR (Status
);
47 ASSERT (InternalSmmBase2
!= NULL
);
50 // We are in SMM, retrieve the pointer to SMM System Table
52 InternalSmmBase2
->GetSmstLocation (InternalSmmBase2
, &gSmst
);
53 ASSERT (gSmst
!= NULL
);
59 This function allows the caller to determine if the driver is executing in
60 System Management Mode(SMM).
62 This function returns TRUE if the driver is executing in SMM and FALSE if the
63 driver is not executing in SMM.
65 @retval TRUE The driver is executing in System Management Mode (SMM).
66 @retval FALSE The driver is not executing in System Management Mode (SMM).
76 // We are already in SMM