]>
Commit | Line | Data |
---|---|---|
124b3f92 BB |
1 | /** @file -- VariableLockRequestToLock.c\r |
2 | Temporary location of the RequestToLock shim code while\r | |
3 | projects are moved to VariablePolicy. Should be removed when deprecated.\r | |
4 | \r | |
5 | Copyright (c) Microsoft Corporation.\r | |
6 | SPDX-License-Identifier: BSD-2-Clause-Patent\r | |
7 | \r | |
8 | **/\r | |
9 | \r | |
10 | #include <Uefi.h>\r | |
11 | \r | |
12 | #include <Library/DebugLib.h>\r | |
13 | #include <Library/MemoryAllocationLib.h>\r | |
14 | \r | |
15 | #include <Protocol/VariableLock.h>\r | |
16 | \r | |
17 | #include <Protocol/VariablePolicy.h>\r | |
18 | #include <Library/VariablePolicyLib.h>\r | |
19 | #include <Library/VariablePolicyHelperLib.h>\r | |
20 | \r | |
21 | \r | |
22 | /**\r | |
23 | DEPRECATED. THIS IS ONLY HERE AS A CONVENIENCE WHILE PORTING.\r | |
24 | Mark a variable that will become read-only after leaving the DXE phase of execution.\r | |
25 | Write request coming from SMM environment through EFI_SMM_VARIABLE_PROTOCOL is allowed.\r | |
26 | \r | |
27 | @param[in] This The VARIABLE_LOCK_PROTOCOL instance.\r | |
28 | @param[in] VariableName A pointer to the variable name that will be made read-only subsequently.\r | |
29 | @param[in] VendorGuid A pointer to the vendor GUID that will be made read-only subsequently.\r | |
30 | \r | |
31 | @retval EFI_SUCCESS The variable specified by the VariableName and the VendorGuid was marked\r | |
32 | as pending to be read-only.\r | |
33 | @retval EFI_INVALID_PARAMETER VariableName or VendorGuid is NULL.\r | |
34 | Or VariableName is an empty string.\r | |
35 | @retval EFI_ACCESS_DENIED EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has\r | |
36 | already been signaled.\r | |
37 | @retval EFI_OUT_OF_RESOURCES There is not enough resource to hold the lock request.\r | |
38 | **/\r | |
39 | EFI_STATUS\r | |
40 | EFIAPI\r | |
41 | VariableLockRequestToLock (\r | |
42 | IN CONST EDKII_VARIABLE_LOCK_PROTOCOL *This,\r | |
43 | IN CHAR16 *VariableName,\r | |
44 | IN EFI_GUID *VendorGuid\r | |
45 | )\r | |
46 | {\r | |
47 | EFI_STATUS Status;\r | |
48 | VARIABLE_POLICY_ENTRY *NewPolicy;\r | |
49 | \r | |
50 | NewPolicy = NULL;\r | |
51 | Status = CreateBasicVariablePolicy( VendorGuid,\r | |
52 | VariableName,\r | |
53 | VARIABLE_POLICY_NO_MIN_SIZE,\r | |
54 | VARIABLE_POLICY_NO_MAX_SIZE,\r | |
55 | VARIABLE_POLICY_NO_MUST_ATTR,\r | |
56 | VARIABLE_POLICY_NO_CANT_ATTR,\r | |
57 | VARIABLE_POLICY_TYPE_LOCK_NOW,\r | |
58 | &NewPolicy );\r | |
59 | if (!EFI_ERROR( Status )) {\r | |
60 | Status = RegisterVariablePolicy( NewPolicy );\r | |
61 | }\r | |
62 | if (EFI_ERROR( Status )) {\r | |
63 | DEBUG(( DEBUG_ERROR, "%a - Failed to lock variable %s! %r\n", __FUNCTION__, VariableName, Status ));\r | |
64 | ASSERT_EFI_ERROR( Status );\r | |
65 | }\r | |
66 | if (NewPolicy != NULL) {\r | |
67 | FreePool( NewPolicy );\r | |
68 | }\r | |
69 | \r | |
70 | return Status;\r | |
71 | }\r |