]>
Commit | Line | Data |
---|---|---|
17f5fd92 AB |
1 | /** @file\r |
2 | MM Services Table Library.\r | |
3 | \r | |
4 | Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r | |
5 | Copyright (c) 2018, Linaro, Ltd. All rights reserved.<BR>\r | |
9344f092 | 6 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
17f5fd92 AB |
7 | \r |
8 | **/\r | |
9 | \r | |
10 | #include <PiMm.h>\r | |
11 | #include <Protocol/MmBase.h>\r | |
12 | #include <Library/MmServicesTableLib.h>\r | |
13 | #include <Library/DebugLib.h>\r | |
14 | \r | |
15 | EFI_MM_SYSTEM_TABLE *gMmst = NULL;\r | |
16 | \r | |
17 | /**\r | |
18 | The constructor function caches the pointer of the MM Services Table.\r | |
19 | \r | |
20 | @param ImageHandle The firmware allocated handle for the EFI image.\r | |
21 | @param SystemTable A pointer to the EFI System Table.\r | |
22 | \r | |
23 | @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.\r | |
24 | \r | |
25 | **/\r | |
26 | EFI_STATUS\r | |
27 | EFIAPI\r | |
28 | MmServicesTableLibConstructor (\r | |
29 | IN EFI_HANDLE ImageHandle,\r | |
30 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
31 | )\r | |
32 | {\r | |
33 | EFI_STATUS Status;\r | |
34 | EFI_MM_BASE_PROTOCOL *InternalMmBase;\r | |
35 | \r | |
36 | InternalMmBase = NULL;\r | |
37 | //\r | |
38 | // Retrieve MM Base Protocol, Do not use gBS from UefiBootServicesTableLib on purpose\r | |
39 | // to prevent inclusion of gBS, gST, and gImageHandle from SMM Drivers unless the\r | |
40 | // MM driver explicity declares that dependency.\r | |
41 | //\r | |
42 | Status = SystemTable->BootServices->LocateProtocol (\r | |
43 | &gEfiMmBaseProtocolGuid,\r | |
44 | NULL,\r | |
45 | (VOID **)&InternalMmBase\r | |
46 | );\r | |
47 | ASSERT_EFI_ERROR (Status);\r | |
48 | ASSERT (InternalMmBase != NULL);\r | |
49 | \r | |
50 | //\r | |
51 | // We are in MM, retrieve the pointer to MM System Table\r | |
52 | //\r | |
53 | InternalMmBase->GetMmstLocation (InternalMmBase, &gMmst);\r | |
54 | ASSERT (gMmst != NULL);\r | |
55 | \r | |
56 | return EFI_SUCCESS;\r | |
57 | }\r |