]>
Commit | Line | Data |
---|---|---|
a855f63e AB |
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 | This program and the accompanying materials\r | |
8 | are licensed and made available under the terms and conditions of the BSD License\r | |
9 | which accompanies this distribution. The full text of the license may be found at\r | |
10 | http://opensource.org/licenses/bsd-license.php\r | |
11 | \r | |
12 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
13 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
14 | \r | |
15 | **/\r | |
16 | \r | |
17 | #include <Library/UefiBootServicesTableLib.h>\r | |
18 | #include <Library/SmmMemLib.h>\r | |
19 | #include "Variable.h"\r | |
20 | \r | |
21 | /**\r | |
22 | This function checks if the buffer is valid per processor architecture and\r | |
23 | does not overlap with SMRAM.\r | |
24 | \r | |
25 | @param Buffer The buffer start address to be checked.\r | |
26 | @param Length The buffer length to be checked.\r | |
27 | \r | |
28 | @retval TRUE This buffer is valid per processor architecture and does not\r | |
29 | overlap with SMRAM.\r | |
30 | @retval FALSE This buffer is not valid per processor architecture or overlaps\r | |
31 | with SMRAM.\r | |
32 | **/\r | |
33 | BOOLEAN\r | |
34 | VariableSmmIsBufferOutsideSmmValid (\r | |
35 | IN EFI_PHYSICAL_ADDRESS Buffer,\r | |
36 | IN UINT64 Length\r | |
37 | )\r | |
38 | {\r | |
39 | return SmmIsBufferOutsideSmmValid (Buffer, Length);\r | |
40 | }\r | |
41 | \r | |
42 | /**\r | |
44289eea | 43 | Notify the system that the SMM variable driver is ready.\r |
a855f63e AB |
44 | **/\r |
45 | VOID\r | |
46 | VariableNotifySmmReady (\r | |
47 | VOID\r | |
48 | )\r | |
49 | {\r | |
50 | EFI_STATUS Status;\r | |
51 | EFI_HANDLE Handle;\r | |
52 | \r | |
53 | Handle = NULL;\r | |
54 | Status = gBS->InstallProtocolInterface (\r | |
55 | &Handle,\r | |
56 | &gEfiSmmVariableProtocolGuid,\r | |
57 | EFI_NATIVE_INTERFACE,\r | |
58 | NULL\r | |
59 | );\r | |
60 | ASSERT_EFI_ERROR (Status);\r | |
61 | }\r | |
62 | \r | |
63 | /**\r | |
44289eea | 64 | Notify the system that the SMM variable write driver is ready.\r |
a855f63e AB |
65 | **/\r |
66 | VOID\r | |
67 | VariableNotifySmmWriteReady (\r | |
68 | VOID\r | |
69 | )\r | |
70 | {\r | |
71 | EFI_STATUS Status;\r | |
72 | EFI_HANDLE Handle;\r | |
73 | \r | |
74 | Handle = NULL;\r | |
75 | Status = gBS->InstallProtocolInterface (\r | |
76 | &Handle,\r | |
77 | &gSmmVariableWriteGuid,\r | |
78 | EFI_NATIVE_INTERFACE,\r | |
79 | NULL\r | |
80 | );\r | |
81 | ASSERT_EFI_ERROR (Status);\r | |
82 | }\r | |
83 | \r | |
84 | /**\r | |
85 | Variable service MM driver entry point\r | |
86 | \r | |
87 | @param[in] ImageHandle A handle for the image that is initializing this\r | |
88 | driver\r | |
89 | @param[in] SystemTable A pointer to the EFI system table\r | |
90 | \r | |
91 | @retval EFI_SUCCESS Variable service successfully initialized.\r | |
92 | **/\r | |
93 | EFI_STATUS\r | |
94 | EFIAPI\r | |
95 | VariableServiceInitialize (\r | |
96 | IN EFI_HANDLE ImageHandle,\r | |
97 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
98 | )\r | |
99 | {\r | |
100 | return MmVariableServiceInitialize ();\r | |
101 | }\r | |
102 | \r | |
103 | /**\r | |
104 | Whether the TCG or TCG2 protocols are installed in the UEFI protocol database.\r | |
105 | This information is used by the MorLock code to infer whether an existing\r | |
106 | MOR variable is legitimate or not.\r | |
107 | \r | |
108 | @retval TRUE Either the TCG or TCG2 protocol is installed in the UEFI\r | |
109 | protocol database\r | |
110 | @retval FALSE Neither the TCG nor the TCG2 protocol is installed in the UEFI\r | |
111 | protocol database\r | |
112 | **/\r | |
113 | BOOLEAN\r | |
114 | VariableHaveTcgProtocols (\r | |
115 | VOID\r | |
116 | )\r | |
117 | {\r | |
118 | EFI_STATUS Status;\r | |
119 | VOID *Interface;\r | |
120 | \r | |
121 | Status = gBS->LocateProtocol (\r | |
122 | &gEfiTcg2ProtocolGuid,\r | |
123 | NULL, // Registration\r | |
124 | &Interface\r | |
125 | );\r | |
126 | if (!EFI_ERROR (Status)) {\r | |
127 | return TRUE;\r | |
128 | }\r | |
129 | \r | |
130 | Status = gBS->LocateProtocol (\r | |
131 | &gEfiTcgProtocolGuid,\r | |
132 | NULL, // Registration\r | |
133 | &Interface\r | |
134 | );\r | |
135 | return !EFI_ERROR (Status);\r | |
136 | }\r |