]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | \r | |
3 | Parts of the SMM/MM implementation that are specific to traditional MM\r | |
4 | \r | |
5 | Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved. <BR>\r | |
6 | Copyright (c) 2018, Linaro, Ltd. All rights reserved. <BR>\r | |
7 | SPDX-License-Identifier: BSD-2-Clause-Patent\r | |
8 | \r | |
9 | **/\r | |
10 | \r | |
11 | #include <Library/UefiBootServicesTableLib.h>\r | |
12 | #include <Library/SmmMemLib.h>\r | |
13 | #include "Variable.h"\r | |
14 | \r | |
15 | /**\r | |
16 | This function checks if the buffer is valid per processor architecture and\r | |
17 | does not overlap with SMRAM.\r | |
18 | \r | |
19 | @param Buffer The buffer start address to be checked.\r | |
20 | @param Length The buffer length to be checked.\r | |
21 | \r | |
22 | @retval TRUE This buffer is valid per processor architecture and does not\r | |
23 | overlap with SMRAM.\r | |
24 | @retval FALSE This buffer is not valid per processor architecture or overlaps\r | |
25 | with SMRAM.\r | |
26 | **/\r | |
27 | BOOLEAN\r | |
28 | VariableSmmIsBufferOutsideSmmValid (\r | |
29 | IN EFI_PHYSICAL_ADDRESS Buffer,\r | |
30 | IN UINT64 Length\r | |
31 | )\r | |
32 | {\r | |
33 | return SmmIsBufferOutsideSmmValid (Buffer, Length);\r | |
34 | }\r | |
35 | \r | |
36 | /**\r | |
37 | Notify the system that the SMM variable driver is ready.\r | |
38 | **/\r | |
39 | VOID\r | |
40 | VariableNotifySmmReady (\r | |
41 | VOID\r | |
42 | )\r | |
43 | {\r | |
44 | EFI_STATUS Status;\r | |
45 | EFI_HANDLE Handle;\r | |
46 | \r | |
47 | Handle = NULL;\r | |
48 | Status = gBS->InstallProtocolInterface (\r | |
49 | &Handle,\r | |
50 | &gEfiSmmVariableProtocolGuid,\r | |
51 | EFI_NATIVE_INTERFACE,\r | |
52 | NULL\r | |
53 | );\r | |
54 | ASSERT_EFI_ERROR (Status);\r | |
55 | }\r | |
56 | \r | |
57 | /**\r | |
58 | Notify the system that the SMM variable write driver is ready.\r | |
59 | **/\r | |
60 | VOID\r | |
61 | VariableNotifySmmWriteReady (\r | |
62 | VOID\r | |
63 | )\r | |
64 | {\r | |
65 | EFI_STATUS Status;\r | |
66 | EFI_HANDLE Handle;\r | |
67 | \r | |
68 | Handle = NULL;\r | |
69 | Status = gBS->InstallProtocolInterface (\r | |
70 | &Handle,\r | |
71 | &gSmmVariableWriteGuid,\r | |
72 | EFI_NATIVE_INTERFACE,\r | |
73 | NULL\r | |
74 | );\r | |
75 | ASSERT_EFI_ERROR (Status);\r | |
76 | }\r | |
77 | \r | |
78 | /**\r | |
79 | Variable service MM driver entry point\r | |
80 | \r | |
81 | @param[in] ImageHandle A handle for the image that is initializing this\r | |
82 | driver\r | |
83 | @param[in] SystemTable A pointer to the EFI system table\r | |
84 | \r | |
85 | @retval EFI_SUCCESS Variable service successfully initialized.\r | |
86 | **/\r | |
87 | EFI_STATUS\r | |
88 | EFIAPI\r | |
89 | VariableServiceInitialize (\r | |
90 | IN EFI_HANDLE ImageHandle,\r | |
91 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
92 | )\r | |
93 | {\r | |
94 | return MmVariableServiceInitialize ();\r | |
95 | }\r | |
96 | \r | |
97 | /**\r | |
98 | Whether the TCG or TCG2 protocols are installed in the UEFI protocol database.\r | |
99 | This information is used by the MorLock code to infer whether an existing\r | |
100 | MOR variable is legitimate or not.\r | |
101 | \r | |
102 | @retval TRUE Either the TCG or TCG2 protocol is installed in the UEFI\r | |
103 | protocol database\r | |
104 | @retval FALSE Neither the TCG nor the TCG2 protocol is installed in the UEFI\r | |
105 | protocol database\r | |
106 | **/\r | |
107 | BOOLEAN\r | |
108 | VariableHaveTcgProtocols (\r | |
109 | VOID\r | |
110 | )\r | |
111 | {\r | |
112 | EFI_STATUS Status;\r | |
113 | VOID *Interface;\r | |
114 | \r | |
115 | Status = gBS->LocateProtocol (\r | |
116 | &gEfiTcg2ProtocolGuid,\r | |
117 | NULL, // Registration\r | |
118 | &Interface\r | |
119 | );\r | |
120 | if (!EFI_ERROR (Status)) {\r | |
121 | return TRUE;\r | |
122 | }\r | |
123 | \r | |
124 | Status = gBS->LocateProtocol (\r | |
125 | &gEfiTcgProtocolGuid,\r | |
126 | NULL, // Registration\r | |
127 | &Interface\r | |
128 | );\r | |
129 | return !EFI_ERROR (Status);\r | |
130 | }\r |