2 TCG MOR (Memory Overwrite Request) Lock Control Driver SMM wrapper.
4 Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #include <Library/SmmServicesTableLib.h>
11 #include <Library/DebugLib.h>
12 #include <Protocol/SmmVarCheck.h>
13 #include <Protocol/SmmVariable.h>
14 #include "TcgMorLock.h"
16 EFI_SMM_VARIABLE_PROTOCOL
*mSmmVariable
;
19 This service is a wrapper for the UEFI Runtime Service GetVariable().
21 @param VariableName the name of the vendor's variable, it's a Null-Terminated Unicode String
22 @param VendorGuid Unify identifier for vendor.
23 @param Attributes Point to memory location to return the attributes of variable. If the point
24 is NULL, the parameter would be ignored.
25 @param DataSize As input, point to the maximum size of return Data-Buffer.
26 As output, point to the actual size of the returned Data-Buffer.
27 @param Data Point to return Data-Buffer.
29 @retval EFI_SUCCESS The function completed successfully.
30 @retval EFI_NOT_FOUND The variable was not found.
31 @retval EFI_BUFFER_TOO_SMALL The DataSize is too small for the result. DataSize has
32 been updated with the size needed to complete the request.
33 @retval EFI_INVALID_PARAMETER VariableName is NULL.
34 @retval EFI_INVALID_PARAMETER VendorGuid is NULL.
35 @retval EFI_INVALID_PARAMETER DataSize is NULL.
36 @retval EFI_INVALID_PARAMETER The DataSize is not too small and Data is NULL.
37 @retval EFI_DEVICE_ERROR The variable could not be retrieved due to a hardware error.
38 @retval EFI_SECURITY_VIOLATION The variable could not be retrieved due to an authentication failure.
43 IN CHAR16
*VariableName
,
44 IN EFI_GUID
*VendorGuid
,
45 OUT UINT32
*Attributes OPTIONAL
,
46 IN OUT UINTN
*DataSize
,
50 return mSmmVariable
->SmmGetVariable (
60 This service is a wrapper for the UEFI Runtime Service SetVariable()
62 @param VariableName the name of the vendor's variable, as a
63 Null-Terminated Unicode String
64 @param VendorGuid Unify identifier for vendor.
65 @param Attributes Point to memory location to return the attributes of variable. If the point
66 is NULL, the parameter would be ignored.
67 @param DataSize The size in bytes of Data-Buffer.
68 @param Data Point to the content of the variable.
70 @retval EFI_SUCCESS The firmware has successfully stored the variable and its data as
71 defined by the Attributes.
72 @retval EFI_INVALID_PARAMETER An invalid combination of attribute bits was supplied, or the
73 DataSize exceeds the maximum allowed.
74 @retval EFI_INVALID_PARAMETER VariableName is an empty Unicode string.
75 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.
76 @retval EFI_DEVICE_ERROR The variable could not be saved due to a hardware failure.
77 @retval EFI_WRITE_PROTECTED The variable in question is read-only.
78 @retval EFI_WRITE_PROTECTED The variable in question cannot be deleted.
79 @retval EFI_SECURITY_VIOLATION The variable could not be written due to EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS
80 set but the AuthInfo does NOT pass the validation check carried
82 @retval EFI_NOT_FOUND The variable trying to be updated or deleted was not found.
88 IN CHAR16
*VariableName
,
89 IN EFI_GUID
*VendorGuid
,
95 return mSmmVariable
->SmmSetVariable (
105 Entry Point for MOR Lock Control driver.
107 @param[in] ImageHandle The firmware allocated handle for the EFI image.
108 @param[in] SystemTable A pointer to the EFI System Table.
110 @retval EFI_SUCCESS EntryPoint runs successfully.
115 MorLockDriverEntryPointSmm (
116 IN EFI_HANDLE ImageHandle
,
117 IN EFI_SYSTEM_TABLE
*SystemTable
121 EDKII_SMM_VAR_CHECK_PROTOCOL
*SmmVarCheck
;
124 // This driver link to Smm Variable driver
126 DEBUG ((EFI_D_INFO
, "MorLockDriverEntryPointSmm\n"));
128 Status
= gSmst
->SmmLocateProtocol (
129 &gEfiSmmVariableProtocolGuid
,
131 (VOID
**) &mSmmVariable
133 ASSERT_EFI_ERROR (Status
);
135 Status
= gSmst
->SmmLocateProtocol (
136 &gEdkiiSmmVarCheckProtocolGuid
,
138 (VOID
**) &SmmVarCheck
140 ASSERT_EFI_ERROR (Status
);
142 Status
= MorLockDriverInit ();
143 if (EFI_ERROR (Status
)) {
147 Status
= SmmVarCheck
->SmmRegisterSetVariableCheckHandler (SetVariableCheckHandlerMor
);
148 ASSERT_EFI_ERROR (Status
);