3 # This file is used to handle the variable attributes and property information
6 # Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>
7 # This program and the accompanying materials
8 # are licensed and made available under the terms and conditions of the BSD License
9 # which accompanies this distribution. The full text of the license may be found at
10 # http://opensource.org/licenses/bsd-license.php
12 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 class VariableAttributes(object):
17 EFI_VARIABLE_NON_VOLATILE
= 0x00000001
18 EFI_VARIABLE_BOOTSERVICE_ACCESS
= 0x00000002
19 EFI_VARIABLE_RUNTIME_ACCESS
= 0x00000004
20 VAR_CHECK_VARIABLE_PROPERTY_READ_ONLY
= 0x00000001
22 "NV":EFI_VARIABLE_NON_VOLATILE
,
23 "BS":EFI_VARIABLE_BOOTSERVICE_ACCESS
,
24 "RT":EFI_VARIABLE_RUNTIME_ACCESS
,
25 "RO":VAR_CHECK_VARIABLE_PROPERTY_READ_ONLY
32 def GetVarAttributes(var_attr_str
):
36 attr_list
= var_attr_str
.split(",")
37 for attr
in attr_list
:
40 VarProp
= VariableAttributes
.VAR_CHECK_VARIABLE_PROPERTY_READ_ONLY
42 VarAttr
= VarAttr | VariableAttributes
.VarAttributesMap
.get(attr
, 0x00000000)
43 return VarAttr
, VarProp
45 def ValidateVarAttributes(var_attr_str
):
48 attr_list
= var_attr_str
.split(",")
50 for attr
in attr_list
:
52 attr_temp
.append(attr
)
53 if attr
not in VariableAttributes
.VarAttributesMap
:
54 return False, "The variable attribute %s is not support to be specified in dsc file. Supported variable attribute are ['BS','NV','RT','RO'] "
55 if 'RT' in attr_temp
and 'BS' not in attr_temp
:
56 return False, "the RT attribute need the BS attribute to be present"