2015-01-05 04:38:36 +01:00
|
|
|
/** @file
|
2015-08-25 05:01:56 +02:00
|
|
|
Implementation functions and structures for var check protocol
|
|
|
|
and variable lock protocol based on VarCheckLib.
|
2015-01-05 04:38:36 +01:00
|
|
|
|
|
|
|
Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
|
2015-07-01 05:08:29 +02:00
|
|
|
This program and the accompanying materials
|
|
|
|
are licensed and made available under the terms and conditions of the BSD License
|
|
|
|
which accompanies this distribution. The full text of the license may be found at
|
2015-01-05 04:38:36 +01:00
|
|
|
http://opensource.org/licenses/bsd-license.php
|
|
|
|
|
2015-07-01 05:08:29 +02:00
|
|
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
2015-01-05 04:38:36 +01:00
|
|
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
#include "Variable.h"
|
|
|
|
|
|
|
|
/**
|
2015-08-25 05:01:56 +02:00
|
|
|
Mark a variable that will become read-only after leaving the DXE phase of execution.
|
|
|
|
Write request coming from SMM environment through EFI_SMM_VARIABLE_PROTOCOL is allowed.
|
2015-01-05 04:38:36 +01:00
|
|
|
|
2015-08-25 05:01:56 +02:00
|
|
|
@param[in] This The VARIABLE_LOCK_PROTOCOL instance.
|
|
|
|
@param[in] VariableName A pointer to the variable name that will be made read-only subsequently.
|
|
|
|
@param[in] VendorGuid A pointer to the vendor GUID that will be made read-only subsequently.
|
2015-01-05 04:38:36 +01:00
|
|
|
|
2015-08-25 05:01:56 +02:00
|
|
|
@retval EFI_SUCCESS The variable specified by the VariableName and the VendorGuid was marked
|
|
|
|
as pending to be read-only.
|
|
|
|
@retval EFI_INVALID_PARAMETER VariableName or VendorGuid is NULL.
|
|
|
|
Or VariableName is an empty string.
|
|
|
|
@retval EFI_ACCESS_DENIED EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has
|
|
|
|
already been signaled.
|
|
|
|
@retval EFI_OUT_OF_RESOURCES There is not enough resource to hold the lock request.
|
2015-01-05 04:38:36 +01:00
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
2015-08-25 05:01:56 +02:00
|
|
|
VariableLockRequestToLock (
|
|
|
|
IN CONST EDKII_VARIABLE_LOCK_PROTOCOL *This,
|
|
|
|
IN CHAR16 *VariableName,
|
|
|
|
IN EFI_GUID *VendorGuid
|
2015-01-05 04:38:36 +01:00
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
2015-08-25 05:01:56 +02:00
|
|
|
VAR_CHECK_VARIABLE_PROPERTY Property;
|
2015-01-05 04:38:36 +01:00
|
|
|
|
2015-08-25 05:01:56 +02:00
|
|
|
AcquireLockOnlyAtBootTime (&mVariableModuleGlobal->VariableGlobal.VariableServicesLock);
|
2015-01-05 04:38:36 +01:00
|
|
|
|
2015-08-25 05:01:56 +02:00
|
|
|
Status = VarCheckLibVariablePropertyGet (VariableName, VendorGuid, &Property);
|
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
Property.Property |= VAR_CHECK_VARIABLE_PROPERTY_READ_ONLY;
|
|
|
|
} else {
|
|
|
|
Property.Revision = VAR_CHECK_VARIABLE_PROPERTY_REVISION;
|
|
|
|
Property.Property = VAR_CHECK_VARIABLE_PROPERTY_READ_ONLY;
|
|
|
|
Property.Attributes = 0;
|
|
|
|
Property.MinSize = 1;
|
|
|
|
Property.MaxSize = MAX_UINTN;
|
2015-01-05 04:38:36 +01:00
|
|
|
}
|
2015-08-25 05:01:56 +02:00
|
|
|
Status = VarCheckLibVariablePropertySet (VariableName, VendorGuid, &Property);
|
2015-01-05 04:38:36 +01:00
|
|
|
|
2015-08-25 05:01:56 +02:00
|
|
|
DEBUG ((EFI_D_INFO, "[Variable] Lock: %g:%s %r\n", VendorGuid, VariableName, Status));
|
2015-01-05 04:38:36 +01:00
|
|
|
|
2015-08-25 05:01:56 +02:00
|
|
|
ReleaseLockOnlyAtBootTime (&mVariableModuleGlobal->VariableGlobal.VariableServicesLock);
|
2015-01-05 04:38:36 +01:00
|
|
|
|
2015-08-25 05:01:56 +02:00
|
|
|
return Status;
|
2015-01-05 04:38:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Register SetVariable check handler.
|
|
|
|
|
|
|
|
@param[in] Handler Pointer to check handler.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The SetVariable check handler was registered successfully.
|
|
|
|
@retval EFI_INVALID_PARAMETER Handler is NULL.
|
|
|
|
@retval EFI_ACCESS_DENIED EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has
|
|
|
|
already been signaled.
|
|
|
|
@retval EFI_OUT_OF_RESOURCES There is not enough resource for the SetVariable check handler register request.
|
|
|
|
@retval EFI_UNSUPPORTED This interface is not implemented.
|
|
|
|
For example, it is unsupported in VarCheck protocol if both VarCheck and SmmVarCheck protocols are present.
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
VarCheckRegisterSetVariableCheckHandler (
|
|
|
|
IN VAR_CHECK_SET_VARIABLE_CHECK_HANDLER Handler
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
|
2015-07-01 05:08:29 +02:00
|
|
|
AcquireLockOnlyAtBootTime (&mVariableModuleGlobal->VariableGlobal.VariableServicesLock);
|
2015-08-25 05:01:56 +02:00
|
|
|
Status = VarCheckLibRegisterSetVariableCheckHandler (Handler);
|
2015-07-01 05:08:29 +02:00
|
|
|
ReleaseLockOnlyAtBootTime (&mVariableModuleGlobal->VariableGlobal.VariableServicesLock);
|
|
|
|
|
|
|
|
return Status;
|
2015-01-05 04:38:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Variable property set.
|
|
|
|
|
|
|
|
@param[in] Name Pointer to the variable name.
|
|
|
|
@param[in] Guid Pointer to the vendor GUID.
|
|
|
|
@param[in] VariableProperty Pointer to the input variable property.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The property of variable specified by the Name and Guid was set successfully.
|
|
|
|
@retval EFI_INVALID_PARAMETER Name, Guid or VariableProperty is NULL, or Name is an empty string,
|
|
|
|
or the fields of VariableProperty are not valid.
|
|
|
|
@retval EFI_ACCESS_DENIED EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has
|
|
|
|
already been signaled.
|
|
|
|
@retval EFI_OUT_OF_RESOURCES There is not enough resource for the variable property set request.
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
VarCheckVariablePropertySet (
|
|
|
|
IN CHAR16 *Name,
|
|
|
|
IN EFI_GUID *Guid,
|
|
|
|
IN VAR_CHECK_VARIABLE_PROPERTY *VariableProperty
|
|
|
|
)
|
|
|
|
{
|
2015-08-25 05:01:56 +02:00
|
|
|
EFI_STATUS Status;
|
2015-01-05 04:38:36 +01:00
|
|
|
|
|
|
|
AcquireLockOnlyAtBootTime (&mVariableModuleGlobal->VariableGlobal.VariableServicesLock);
|
2015-08-25 05:01:56 +02:00
|
|
|
Status = VarCheckLibVariablePropertySet (Name, Guid, VariableProperty);
|
2015-01-05 04:38:36 +01:00
|
|
|
ReleaseLockOnlyAtBootTime (&mVariableModuleGlobal->VariableGlobal.VariableServicesLock);
|
|
|
|
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2015-01-27 09:42:47 +01:00
|
|
|
/**
|
|
|
|
Variable property get.
|
|
|
|
|
|
|
|
@param[in] Name Pointer to the variable name.
|
|
|
|
@param[in] Guid Pointer to the vendor GUID.
|
|
|
|
@param[out] VariableProperty Pointer to the output variable property.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The property of variable specified by the Name and Guid was got successfully.
|
|
|
|
@retval EFI_INVALID_PARAMETER Name, Guid or VariableProperty is NULL, or Name is an empty string.
|
|
|
|
@retval EFI_NOT_FOUND The property of variable specified by the Name and Guid was not found.
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
VarCheckVariablePropertyGet (
|
|
|
|
IN CHAR16 *Name,
|
|
|
|
IN EFI_GUID *Guid,
|
|
|
|
OUT VAR_CHECK_VARIABLE_PROPERTY *VariableProperty
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
|
|
|
|
AcquireLockOnlyAtBootTime (&mVariableModuleGlobal->VariableGlobal.VariableServicesLock);
|
2015-08-25 05:01:56 +02:00
|
|
|
Status = VarCheckLibVariablePropertyGet (Name, Guid, VariableProperty);
|
2015-01-05 04:38:36 +01:00
|
|
|
ReleaseLockOnlyAtBootTime (&mVariableModuleGlobal->VariableGlobal.VariableServicesLock);
|
|
|
|
|
2015-01-27 09:42:47 +01:00
|
|
|
return Status;
|
2015-01-05 04:38:36 +01:00
|
|
|
}
|
|
|
|
|