--- /dev/null
+/** @file -- VariablePolicy.h\r
+\r
+This protocol allows communication with Variable Policy Engine.\r
+\r
+Copyright (c) Microsoft Corporation.\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
+**/\r
+\r
+#ifndef __EDKII_VARIABLE_POLICY_PROTOCOL__\r
+#define __EDKII_VARIABLE_POLICY_PROTOCOL__\r
+\r
+#define EDKII_VARIABLE_POLICY_PROTOCOL_REVISION 0x0000000000010000\r
+\r
+#define EDKII_VARIABLE_POLICY_PROTOCOL_GUID \\r
+ { \\r
+ 0x81D1675C, 0x86F6, 0x48DF, { 0xBD, 0x95, 0x9A, 0x6E, 0x4F, 0x09, 0x25, 0xC3 } \\r
+ }\r
+\r
+#define VARIABLE_POLICY_ENTRY_REVISION 0x00010000\r
+\r
+#pragma pack(push, 1)\r
+typedef struct {\r
+ UINT32 Version;\r
+ UINT16 Size;\r
+ UINT16 OffsetToName;\r
+ EFI_GUID Namespace;\r
+ UINT32 MinSize;\r
+ UINT32 MaxSize;\r
+ UINT32 AttributesMustHave;\r
+ UINT32 AttributesCantHave;\r
+ UINT8 LockPolicyType;\r
+ UINT8 Padding[3];\r
+ // UINT8 LockPolicy[]; // Variable Length Field\r
+ // CHAR16 Name[] // Variable Length Field\r
+} VARIABLE_POLICY_ENTRY;\r
+\r
+#define VARIABLE_POLICY_NO_MIN_SIZE 0\r
+#define VARIABLE_POLICY_NO_MAX_SIZE MAX_UINT32\r
+#define VARIABLE_POLICY_NO_MUST_ATTR 0\r
+#define VARIABLE_POLICY_NO_CANT_ATTR 0\r
+\r
+#define VARIABLE_POLICY_TYPE_NO_LOCK 0\r
+#define VARIABLE_POLICY_TYPE_LOCK_NOW 1\r
+#define VARIABLE_POLICY_TYPE_LOCK_ON_CREATE 2\r
+#define VARIABLE_POLICY_TYPE_LOCK_ON_VAR_STATE 3\r
+\r
+typedef struct {\r
+ EFI_GUID Namespace;\r
+ UINT8 Value;\r
+ UINT8 Padding;\r
+ // CHAR16 Name[]; // Variable Length Field\r
+} VARIABLE_LOCK_ON_VAR_STATE_POLICY;\r
+#pragma pack(pop)\r
+\r
+/**\r
+ This API function disables the variable policy enforcement. If it's\r
+ already been called once, will return EFI_ALREADY_STARTED.\r
+\r
+ @retval EFI_SUCCESS\r
+ @retval EFI_ALREADY_STARTED Has already been called once this boot.\r
+ @retval EFI_WRITE_PROTECTED Interface has been locked until reboot.\r
+ @retval EFI_WRITE_PROTECTED Interface option is disabled by platform PCD.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *DISABLE_VARIABLE_POLICY)(\r
+ VOID\r
+ );\r
+\r
+/**\r
+ This API function returns whether or not the policy engine is\r
+ currently being enforced.\r
+\r
+ @param[out] State Pointer to a return value for whether the policy enforcement\r
+ is currently enabled.\r
+\r
+ @retval EFI_SUCCESS\r
+ @retval Others An error has prevented this command from completing.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *IS_VARIABLE_POLICY_ENABLED)(\r
+ OUT BOOLEAN *State\r
+ );\r
+\r
+/**\r
+ This API function validates and registers a new policy with\r
+ the policy enforcement engine.\r
+\r
+ @param[in] NewPolicy Pointer to the incoming policy structure.\r
+\r
+ @retval EFI_SUCCESS\r
+ @retval EFI_INVALID_PARAMETER NewPolicy is NULL or is internally inconsistent.\r
+ @retval EFI_ALREADY_STARTED An identical matching policy already exists.\r
+ @retval EFI_WRITE_PROTECTED The interface has been locked until the next reboot.\r
+ @retval EFI_ABORTED A calculation error has prevented this function from completing.\r
+ @retval EFI_OUT_OF_RESOURCES Cannot grow the table to hold any more policies.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *REGISTER_VARIABLE_POLICY)(\r
+ IN CONST VARIABLE_POLICY_ENTRY *PolicyEntry\r
+ );\r
+\r
+/**\r
+ This API function will dump the entire contents of the variable policy table.\r
+\r
+ Similar to GetVariable, the first call can be made with a 0 size and it will return\r
+ the size of the buffer required to hold the entire table.\r
+\r
+ @param[out] Policy Pointer to the policy buffer. Can be NULL if Size is 0.\r
+ @param[in,out] Size On input, the size of the output buffer. On output, the size\r
+ of the data returned.\r
+\r
+ @retval EFI_SUCCESS Policy data is in the output buffer and Size has been updated.\r
+ @retval EFI_INVALID_PARAMETER Size is NULL, or Size is non-zero and Policy is NULL.\r
+ @retval EFI_BUFFER_TOO_SMALL Size is insufficient to hold policy. Size updated with required size.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *DUMP_VARIABLE_POLICY)(\r
+ IN OUT UINT8 *Policy,\r
+ IN OUT UINT32 *Size\r
+ );\r
+\r
+/**\r
+ This API function locks the interface so that no more policy updates\r
+ can be performed or changes made to the enforcement until the next boot.\r
+\r
+ @retval EFI_SUCCESS\r
+ @retval Others An error has prevented this command from completing.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *LOCK_VARIABLE_POLICY)(\r
+ VOID\r
+ );\r
+\r
+typedef struct {\r
+ UINT64 Revision;\r
+ DISABLE_VARIABLE_POLICY DisableVariablePolicy;\r
+ IS_VARIABLE_POLICY_ENABLED IsVariablePolicyEnabled;\r
+ REGISTER_VARIABLE_POLICY RegisterVariablePolicy;\r
+ DUMP_VARIABLE_POLICY DumpVariablePolicy;\r
+ LOCK_VARIABLE_POLICY LockVariablePolicy;\r
+} _EDKII_VARIABLE_POLICY_PROTOCOL;\r
+\r
+typedef _EDKII_VARIABLE_POLICY_PROTOCOL EDKII_VARIABLE_POLICY_PROTOCOL;\r
+\r
+extern EFI_GUID gEdkiiVariablePolicyProtocolGuid;\r
+\r
+#endif\r
# Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>\r
# (C) Copyright 2016 - 2019 Hewlett Packard Enterprise Development LP<BR>\r
# Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>\r
-# Copyright (c) 2016, Microsoft Corporation<BR>\r
+# Copyright (c) Microsoft Corporation.<BR>\r
# SPDX-License-Identifier: BSD-2-Clause-Patent\r
#\r
##\r
# 0x80000006 | Incorrect error code provided.\r
#\r
\r
+ ## Include/Protocol/VariablePolicy.h\r
+ gEdkiiVariablePolicyProtocolGuid = { 0x81D1675C, 0x86F6, 0x48DF, { 0xBD, 0x95, 0x9A, 0x6E, 0x4F, 0x09, 0x25, 0xC3 } }\r
+\r
[PcdsFeatureFlag]\r
## Indicates if the platform can support update capsule across a system reset.<BR><BR>\r
# TRUE - Supports update capsule across a system reset.<BR>\r
# @Prompt Variable storage size.\r
gEfiMdeModulePkgTokenSpaceGuid.PcdVariableStoreSize|0x10000|UINT32|0x30000005\r
\r
+ ## Toggle for whether the VariablePolicy engine should allow disabling.\r
+ # The engine is enabled at power-on, but the interface allows the platform to\r
+ # disable enforcement for servicing flexibility. If this PCD is disabled, it will block the ability to\r
+ # disable the enforcement and VariablePolicy enforcement will always be ON.\r
+ # TRUE - VariablePolicy can be disabled by request through the interface (until interface is locked)\r
+ # FALSE - VariablePolicy interface will not accept requests to disable and is ALWAYS ON\r
+ # @Prompt Allow VariablePolicy enforcement to be disabled.\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdAllowVariablePolicyEnforcementDisable|FALSE|BOOLEAN|0x30000020\r
+\r
## FFS filename to find the ACPI tables.\r
# @Prompt FFS name of ACPI tables storage.\r
gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiTableStorageFile|{ 0x25, 0x4e, 0x37, 0x7e, 0x01, 0x8e, 0xee, 0x4f, 0x87, 0xf2, 0x39, 0xc, 0x23, 0xc6, 0x6, 0xcd }|VOID*|0x30000016\r