TianoCore EDK2 master
Loading...
Searching...
No Matches
VariableLockRequestToLock.c
Go to the documentation of this file.
1
10#include <Uefi.h>
11#include <Library/DebugLib.h>
13#include <Library/VariablePolicyLib.h>
14#include <Library/VariablePolicyHelperLib.h>
16
41EFIAPI
44 IN CHAR16 *VariableName,
45 IN EFI_GUID *VendorGuid
46 )
47{
48 EFI_STATUS Status;
49 VARIABLE_POLICY_ENTRY *NewPolicy;
50
51 DEBUG ((DEBUG_WARN, "!!! DEPRECATED INTERFACE !!! %a() will go away soon!\n", __func__));
52 DEBUG ((DEBUG_WARN, "!!! DEPRECATED INTERFACE !!! Please move to use Variable Policy!\n"));
53 DEBUG ((DEBUG_WARN, "!!! DEPRECATED INTERFACE !!! Variable: %g %s\n", VendorGuid, VariableName));
54
55 NewPolicy = NULL;
56 Status = CreateBasicVariablePolicy (
57 VendorGuid,
58 VariableName,
59 VARIABLE_POLICY_NO_MIN_SIZE,
60 VARIABLE_POLICY_NO_MAX_SIZE,
61 VARIABLE_POLICY_NO_MUST_ATTR,
62 VARIABLE_POLICY_NO_CANT_ATTR,
63 VARIABLE_POLICY_TYPE_LOCK_NOW,
64 &NewPolicy
65 );
66 if (!EFI_ERROR (Status)) {
67 Status = RegisterVariablePolicy (NewPolicy);
68
69 //
70 // If the error returned is EFI_ALREADY_STARTED, we need to check the
71 // current database for the variable and see whether it's locked. If it's
72 // locked, we're still fine, but also generate a DEBUG_WARN message so the
73 // duplicate lock can be removed.
74 //
75 if (Status == EFI_ALREADY_STARTED) {
76 Status = ValidateSetVariable (VariableName, VendorGuid, 0, 0, NULL);
77 if (Status == EFI_WRITE_PROTECTED) {
78 DEBUG ((DEBUG_WARN, " Variable: %g %s is already locked!\n", VendorGuid, VariableName));
79 Status = EFI_SUCCESS;
80 } else {
81 DEBUG ((DEBUG_ERROR, " Variable: %g %s can not be locked!\n", VendorGuid, VariableName));
82 Status = EFI_ACCESS_DENIED;
83 }
84 }
85 }
86
87 if (EFI_ERROR (Status)) {
88 DEBUG ((DEBUG_ERROR, "%a - Failed to lock variable %s! %r\n", __func__, VariableName, Status));
89 }
90
91 if (NewPolicy != NULL) {
92 FreePool (NewPolicy);
93 }
94
95 return Status;
96}
VOID EFIAPI FreePool(IN VOID *Buffer)
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define IN
Definition: Base.h:279
#define DEBUG(Expression)
Definition: DebugLib.h:434
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_STATUS EFIAPI VariableLockRequestToLock(IN CONST EDKII_VARIABLE_LOCK_PROTOCOL *This, IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid)
=== CODE UNDER TEST ===========================================================================
Definition: Base.h:213