• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /** @file
2   Variable check definitions.
3 
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
9 
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.
12 
13 **/
14 
15 #ifndef _VARIABLE_CHECK_H_
16 #define _VARIABLE_CHECK_H_
17 
18 #include <Uefi/UefiSpec.h>
19 
20 typedef struct _EDKII_VAR_CHECK_PROTOCOL    EDKII_VAR_CHECK_PROTOCOL;
21 
22 #define EDKII_VAR_CHECK_PROTOCOL_GUID { \
23   0xaf23b340, 0x97b4, 0x4685, { 0x8d, 0x4f, 0xa3, 0xf2, 0x81, 0x69, 0xb2, 0x1d } \
24 };
25 
26 typedef EFI_SET_VARIABLE VAR_CHECK_SET_VARIABLE_CHECK_HANDLER;
27 
28 /**
29   Register SetVariable check handler.
30   Variable driver will call the handler to do check before
31   really setting the variable into variable storage.
32 
33   @param[in] Handler            Pointer to the check handler.
34 
35   @retval EFI_SUCCESS           The SetVariable check handler was registered successfully.
36   @retval EFI_INVALID_PARAMETER Handler is NULL.
37   @retval EFI_ACCESS_DENIED     EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has already been signaled.
38   @retval EFI_OUT_OF_RESOURCES  There is not enough resource for the SetVariable check handler register request.
39   @retval EFI_UNSUPPORTED       This interface is not implemented.
40                                 For example, it is unsupported in VarCheck protocol if both VarCheck and SmmVarCheck protocols are present.
41 
42 **/
43 typedef
44 EFI_STATUS
45 (EFIAPI * EDKII_VAR_CHECK_REGISTER_SET_VARIABLE_CHECK_HANDLER) (
46   IN VAR_CHECK_SET_VARIABLE_CHECK_HANDLER   Handler
47   );
48 
49 #define VAR_CHECK_VARIABLE_PROPERTY_REVISION      0x0001
50 //
51 // 1. Set by VariableLock PROTOCOL
52 // 2. Set by VarCheck PROTOCOL
53 //
54 // If set, other fields for check will be ignored.
55 //
56 #define VAR_CHECK_VARIABLE_PROPERTY_READ_ONLY     BIT0
57 
58 typedef struct {
59   UINT16                            Revision;
60   UINT16                            Property;
61   UINT32                            Attributes;
62   UINTN                             MinSize;
63   UINTN                             MaxSize;
64 } VAR_CHECK_VARIABLE_PROPERTY;
65 
66 typedef struct {
67   EFI_GUID                      *Guid;
68   CHAR16                        *Name;
69   VAR_CHECK_VARIABLE_PROPERTY   VariableProperty;
70 } VARIABLE_ENTRY_PROPERTY;
71 
72 /**
73   Variable property set.
74   Variable driver will do check according to the VariableProperty before
75   really setting the variable into variable storage.
76 
77   @param[in] Name               Pointer to the variable name.
78   @param[in] Guid               Pointer to the vendor GUID.
79   @param[in] VariableProperty   Pointer to the input variable property.
80 
81   @retval EFI_SUCCESS           The property of variable specified by the Name and Guid was set successfully.
82   @retval EFI_INVALID_PARAMETER Name, Guid or VariableProperty is NULL, or Name is an empty string,
83                                 or the fields of VariableProperty are not valid.
84   @retval EFI_ACCESS_DENIED     EFI_END_OF_DXE_EVENT_GROUP_GUID or EFI_EVENT_GROUP_READY_TO_BOOT has
85                                 already been signaled.
86   @retval EFI_OUT_OF_RESOURCES  There is not enough resource for the variable property set request.
87 
88 **/
89 typedef
90 EFI_STATUS
91 (EFIAPI * EDKII_VAR_CHECK_VARIABLE_PROPERTY_SET) (
92   IN CHAR16                         *Name,
93   IN EFI_GUID                       *Guid,
94   IN VAR_CHECK_VARIABLE_PROPERTY    *VariableProperty
95   );
96 
97 /**
98   Variable property get.
99 
100   @param[in]  Name              Pointer to the variable name.
101   @param[in]  Guid              Pointer to the vendor GUID.
102   @param[out] VariableProperty  Pointer to the output variable property.
103 
104   @retval EFI_SUCCESS           The property of variable specified by the Name and Guid was got successfully.
105   @retval EFI_INVALID_PARAMETER Name, Guid or VariableProperty is NULL, or Name is an empty string.
106   @retval EFI_NOT_FOUND         The property of variable specified by the Name and Guid was not found.
107 
108 **/
109 typedef
110 EFI_STATUS
111 (EFIAPI * EDKII_VAR_CHECK_VARIABLE_PROPERTY_GET) (
112   IN CHAR16                         *Name,
113   IN EFI_GUID                       *Guid,
114   OUT VAR_CHECK_VARIABLE_PROPERTY   *VariableProperty
115   );
116 
117 struct _EDKII_VAR_CHECK_PROTOCOL {
118   EDKII_VAR_CHECK_REGISTER_SET_VARIABLE_CHECK_HANDLER   RegisterSetVariableCheckHandler;
119   EDKII_VAR_CHECK_VARIABLE_PROPERTY_SET                 VariablePropertySet;
120   EDKII_VAR_CHECK_VARIABLE_PROPERTY_GET                 VariablePropertyGet;
121 };
122 
123 extern EFI_GUID gEdkiiVarCheckProtocolGuid;
124 
125 #endif
126 
127