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 # SPDX-License-Identifier: BSD-2-Clause-Patent
10 class VariableAttributes(object):
11 EFI_VARIABLE_NON_VOLATILE
= 0x00000001
12 EFI_VARIABLE_BOOTSERVICE_ACCESS
= 0x00000002
13 EFI_VARIABLE_RUNTIME_ACCESS
= 0x00000004
14 VAR_CHECK_VARIABLE_PROPERTY_READ_ONLY
= 0x00000001
16 "NV":EFI_VARIABLE_NON_VOLATILE
,
17 "BS":EFI_VARIABLE_BOOTSERVICE_ACCESS
,
18 "RT":EFI_VARIABLE_RUNTIME_ACCESS
,
19 "RO":VAR_CHECK_VARIABLE_PROPERTY_READ_ONLY
26 def GetVarAttributes(var_attr_str
):
30 attr_list
= var_attr_str
.split(",")
31 for attr
in attr_list
:
34 VarProp
= VariableAttributes
.VAR_CHECK_VARIABLE_PROPERTY_READ_ONLY
36 VarAttr
= VarAttr | VariableAttributes
.VarAttributesMap
.get(attr
, 0x00000000)
37 return VarAttr
, VarProp
39 def ValidateVarAttributes(var_attr_str
):
42 attr_list
= var_attr_str
.split(",")
44 for attr
in attr_list
:
46 attr_temp
.append(attr
)
47 if attr
not in VariableAttributes
.VarAttributesMap
:
48 return False, "The variable attribute %s is not support to be specified in dsc file. Supported variable attribute are ['BS','NV','RT','RO'] "
49 if 'RT' in attr_temp
and 'BS' not in attr_temp
:
50 return False, "the RT attribute need the BS attribute to be present"