2 TCG MOR (Memory Overwrite Request) Lock Control Driver SMM wrapper.
4 Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #include <Library/SmmServicesTableLib.h>
17 #include <Library/DebugLib.h>
18 #include <Protocol/SmmVarCheck.h>
19 #include <Protocol/SmmVariable.h>
20 #include "TcgMorLock.h"
22 EFI_SMM_VARIABLE_PROTOCOL
*mSmmVariable
;
25 This service is a wrapper for the UEFI Runtime Service GetVariable().
27 @param VariableName the name of the vendor's variable, it's a Null-Terminated Unicode String
28 @param VendorGuid Unify identifier for vendor.
29 @param Attributes Point to memory location to return the attributes of variable. If the point
30 is NULL, the parameter would be ignored.
31 @param DataSize As input, point to the maximum size of return Data-Buffer.
32 As output, point to the actual size of the returned Data-Buffer.
33 @param Data Point to return Data-Buffer.
35 @retval EFI_SUCCESS The function completed successfully.
36 @retval EFI_NOT_FOUND The variable was not found.
37 @retval EFI_BUFFER_TOO_SMALL The DataSize is too small for the result. DataSize has
38 been updated with the size needed to complete the request.
39 @retval EFI_INVALID_PARAMETER VariableName is NULL.
40 @retval EFI_INVALID_PARAMETER VendorGuid is NULL.
41 @retval EFI_INVALID_PARAMETER DataSize is NULL.
42 @retval EFI_INVALID_PARAMETER The DataSize is not too small and Data is NULL.
43 @retval EFI_DEVICE_ERROR The variable could not be retrieved due to a hardware error.
44 @retval EFI_SECURITY_VIOLATION The variable could not be retrieved due to an authentication failure.
49 IN CHAR16
*VariableName
,
50 IN EFI_GUID
*VendorGuid
,
51 OUT UINT32
*Attributes OPTIONAL
,
52 IN OUT UINTN
*DataSize
,
56 return mSmmVariable
->SmmGetVariable (
66 This service is a wrapper for the UEFI Runtime Service SetVariable()
68 @param VariableName the name of the vendor's variable, as a
69 Null-Terminated Unicode String
70 @param VendorGuid Unify identifier for vendor.
71 @param Attributes Point to memory location to return the attributes of variable. If the point
72 is NULL, the parameter would be ignored.
73 @param DataSize The size in bytes of Data-Buffer.
74 @param Data Point to the content of the variable.
76 @retval EFI_SUCCESS The firmware has successfully stored the variable and its data as
77 defined by the Attributes.
78 @retval EFI_INVALID_PARAMETER An invalid combination of attribute bits was supplied, or the
79 DataSize exceeds the maximum allowed.
80 @retval EFI_INVALID_PARAMETER VariableName is an empty Unicode string.
81 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.
82 @retval EFI_DEVICE_ERROR The variable could not be saved due to a hardware failure.
83 @retval EFI_WRITE_PROTECTED The variable in question is read-only.
84 @retval EFI_WRITE_PROTECTED The variable in question cannot be deleted.
85 @retval EFI_SECURITY_VIOLATION The variable could not be written due to EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS
86 set but the AuthInfo does NOT pass the validation check carried
88 @retval EFI_NOT_FOUND The variable trying to be updated or deleted was not found.
94 IN CHAR16
*VariableName
,
95 IN EFI_GUID
*VendorGuid
,
101 return mSmmVariable
->SmmSetVariable (
111 Entry Point for MOR Lock Control driver.
113 @param[in] ImageHandle The firmware allocated handle for the EFI image.
114 @param[in] SystemTable A pointer to the EFI System Table.
116 @retval EFI_SUCCESS EntryPoint runs successfully.
121 MorLockDriverEntryPointSmm (
122 IN EFI_HANDLE ImageHandle
,
123 IN EFI_SYSTEM_TABLE
*SystemTable
127 EDKII_SMM_VAR_CHECK_PROTOCOL
*SmmVarCheck
;
130 // This driver link to Smm Variable driver
132 DEBUG ((EFI_D_INFO
, "MorLockDriverEntryPointSmm\n"));
134 Status
= gSmst
->SmmLocateProtocol (
135 &gEfiSmmVariableProtocolGuid
,
137 (VOID
**) &mSmmVariable
139 ASSERT_EFI_ERROR (Status
);
141 Status
= gSmst
->SmmLocateProtocol (
142 &gEdkiiSmmVarCheckProtocolGuid
,
144 (VOID
**) &SmmVarCheck
146 ASSERT_EFI_ERROR (Status
);
148 Status
= MorLockDriverInit ();
149 if (EFI_ERROR (Status
)) {
153 Status
= SmmVarCheck
->SmmRegisterSetVariableCheckHandler (SetVariableCheckHandlerMor
);
154 ASSERT_EFI_ERROR (Status
);