]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/MmServicesTableLib/MmServicesTableLib.c
MdePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdePkg / Library / MmServicesTableLib / MmServicesTableLib.c
1 /** @file
2 MM Services Table Library.
3
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
7
8 **/
9
10 #include <PiMm.h>
11 #include <Protocol/MmBase.h>
12 #include <Library/MmServicesTableLib.h>
13 #include <Library/DebugLib.h>
14
15 EFI_MM_SYSTEM_TABLE *gMmst = NULL;
16
17 /**
18 The constructor function caches the pointer of the MM Services Table.
19
20 @param ImageHandle The firmware allocated handle for the EFI image.
21 @param SystemTable A pointer to the EFI System Table.
22
23 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
24
25 **/
26 EFI_STATUS
27 EFIAPI
28 MmServicesTableLibConstructor (
29 IN EFI_HANDLE ImageHandle,
30 IN EFI_SYSTEM_TABLE *SystemTable
31 )
32 {
33 EFI_STATUS Status;
34 EFI_MM_BASE_PROTOCOL *InternalMmBase;
35
36 InternalMmBase = NULL;
37 //
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.
41 //
42 Status = SystemTable->BootServices->LocateProtocol (
43 &gEfiMmBaseProtocolGuid,
44 NULL,
45 (VOID **)&InternalMmBase
46 );
47 ASSERT_EFI_ERROR (Status);
48 ASSERT (InternalMmBase != NULL);
49
50 //
51 // We are in MM, retrieve the pointer to MM System Table
52 //
53 InternalMmBase->GetMmstLocation (InternalMmBase, &gMmst);
54 ASSERT (gMmst != NULL);
55
56 return EFI_SUCCESS;
57 }