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 SPDX-License-Identifier: BSD-2-Clause-Patent
11 #include <Protocol/MmBase.h>
12 #include <Library/MmServicesTableLib.h>
13 #include <Library/DebugLib.h>
15 EFI_MM_SYSTEM_TABLE
*gMmst
= NULL
;
18 The constructor function caches the pointer of the MM Services Table.
20 @param ImageHandle The firmware allocated handle for the EFI image.
21 @param SystemTable A pointer to the EFI System Table.
23 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
28 MmServicesTableLibConstructor (
29 IN EFI_HANDLE ImageHandle
,
30 IN EFI_SYSTEM_TABLE
*SystemTable
34 EFI_MM_BASE_PROTOCOL
*InternalMmBase
;
36 InternalMmBase
= NULL
;
38 // Retrieve MM Base Protocol, Do not use gBS from UefiBootServicesTableLib on purpose
39 // to prevent inclusion of gBS, gST, and gImageHandle from SMM Drivers unless the
40 // MM driver explicity declares that dependency.
42 Status
= SystemTable
->BootServices
->LocateProtocol (
43 &gEfiMmBaseProtocolGuid
,
45 (VOID
**)&InternalMmBase
47 ASSERT_EFI_ERROR (Status
);
48 ASSERT (InternalMmBase
!= NULL
);
51 // We are in MM, retrieve the pointer to MM System Table
53 InternalMmBase
->GetMmstLocation (InternalMmBase
, &gMmst
);
54 ASSERT (gMmst
!= NULL
);