2 SMM Services Table Library.
4 Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php.
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #include <Protocol/SmmBase2.h>
17 #include <Library/SmmServicesTableLib.h>
18 #include <Library/DebugLib.h>
20 EFI_SMM_SYSTEM_TABLE2
*gSmst
= NULL
;
21 EFI_SMM_BASE2_PROTOCOL
*mInternalSmmBase2
= NULL
;
24 The constructor function caches the pointer of SMM Services Table.
26 @param ImageHandle The firmware allocated handle for the EFI image.
27 @param SystemTable A pointer to the EFI System Table.
29 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
34 SmmServicesTableLibConstructor (
35 IN EFI_HANDLE ImageHandle
,
36 IN EFI_SYSTEM_TABLE
*SystemTable
42 // Retrieve SMM Base2 Protocol, Do not use gBS from UefiBootServicesTableLib on purpose
43 // to prevent inclusion of gBS, gST, and gImageHandle from SMM Drivers unless the
44 // SMM driver explicity declares that dependency.
46 Status
= SystemTable
->BootServices
->LocateProtocol (
47 &gEfiSmmBase2ProtocolGuid
,
49 (VOID
**)&mInternalSmmBase2
51 ASSERT_EFI_ERROR (Status
);
52 ASSERT (mInternalSmmBase2
!= NULL
);
55 // Check to see if we are already in SMM
59 // We are not in SMM, so SMST is not needed
65 // We are in SMM, retrieve the pointer to SMM System Table
67 mInternalSmmBase2
->GetSmstLocation (mInternalSmmBase2
, &gSmst
);
68 ASSERT (gSmst
!= NULL
);
74 This function allows the caller to determine if the driver is executing in
75 System Management Mode(SMM).
77 This function returns TRUE if the driver is executing in SMM and FALSE if the
78 driver is not executing in SMM.
80 @retval TRUE The driver is executing in System Management Mode (SMM).
81 @retval FALSE The driver is not executing in System Management Mode (SMM).
93 // Check to see if we are already in SMM
95 mInternalSmmBase2
->InSmm (mInternalSmmBase2
, &InSmm
);