2 MM Services Table Library.
4 Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
5 Copyright (c) 2018, Linaro, Ltd. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php.
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 #include <Protocol/MmBase.h>
18 #include <Library/MmServicesTableLib.h>
19 #include <Library/DebugLib.h>
21 EFI_MM_SYSTEM_TABLE
*gMmst
= NULL
;
24 The constructor function caches the pointer of the MM 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 MmServicesTableLibConstructor (
35 IN EFI_HANDLE ImageHandle
,
36 IN EFI_SYSTEM_TABLE
*SystemTable
40 EFI_MM_BASE_PROTOCOL
*InternalMmBase
;
42 InternalMmBase
= NULL
;
44 // Retrieve MM Base Protocol, Do not use gBS from UefiBootServicesTableLib on purpose
45 // to prevent inclusion of gBS, gST, and gImageHandle from SMM Drivers unless the
46 // MM driver explicity declares that dependency.
48 Status
= SystemTable
->BootServices
->LocateProtocol (
49 &gEfiMmBaseProtocolGuid
,
51 (VOID
**)&InternalMmBase
53 ASSERT_EFI_ERROR (Status
);
54 ASSERT (InternalMmBase
!= NULL
);
57 // We are in MM, retrieve the pointer to MM System Table
59 InternalMmBase
->GetMmstLocation (InternalMmBase
, &gMmst
);
60 ASSERT (gMmst
!= NULL
);