2 SMM Services Table Library.
4 Copyright (c) 2009, Intel Corporation<BR>
5 All rights reserved. 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.
17 #include <Protocol/SmmBase2.h>
18 #include <Library/UefiBootServicesTableLib.h>
19 #include <Library/SmmServicesTableLib.h>
20 #include <Library/DebugLib.h>
22 EFI_SMM_SYSTEM_TABLE2
*gSmst
= NULL
;
23 EFI_SMM_BASE2_PROTOCOL
*mInternalSmmBase2
= NULL
;
27 The constructor function caches the pointer of Smm Services Table.
29 @param ImageHandle The firmware allocated handle for the EFI image.
30 @param SystemTable A pointer to the EFI System Table.
32 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
37 SmmServicesTableLibConstructor (
38 IN EFI_HANDLE ImageHandle
,
39 IN EFI_SYSTEM_TABLE
*SystemTable
46 // Retrieve SMM Base2 Protocol
48 Status
= gBS
->LocateProtocol (
49 &gEfiSmmBase2ProtocolGuid
,
51 (VOID
**) &mInternalSmmBase2
53 ASSERT_EFI_ERROR (Status
);
54 ASSERT (mInternalSmmBase2
!= NULL
);
57 // Check to see if we are already in SMM
59 mInternalSmmBase2
->InSmm (mInternalSmmBase2
, &InSmm
);
63 // We are not in SMM, so SMST is not needed
69 // We are in SMM, retrieve the pointer to SMM System Table
71 mInternalSmmBase2
->GetSmstLocation (mInternalSmmBase2
, &gSmst
);
73 ASSERT (gSmst
!= NULL
);
80 This function allows the caller to determine if the driver is executing in
81 System Management Mode(SMM).
83 This function returns TRUE if the driver is executing in SMM and FALSE if the
84 driver is not executing in SMM.
86 @retval TRUE The driver is executing in System Management Mode (SMM).
87 @retval FALSE The driver is not executing in System Management Mode (SMM).
99 // Check to see if we are already in SMM
101 mInternalSmmBase2
->InSmm (mInternalSmmBase2
, &InSmm
);