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