]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/Common/VariableAttributes.py
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / BaseTools / Source / Python / Common / VariableAttributes.py
1 # # @file
2 #
3 # This file is used to handle the variable attributes and property information
4 #
5 #
6 # Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>
7 # SPDX-License-Identifier: BSD-2-Clause-Patent
8 #
9
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
15 VarAttributesMap = {
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
20 }
21
22 def __init__(self):
23 pass
24
25 @staticmethod
26 def GetVarAttributes(var_attr_str):
27 VarAttr = 0x00000000
28 VarProp = 0x00000000
29
30 attr_list = var_attr_str.split(",")
31 for attr in attr_list:
32 attr = attr.strip()
33 if attr == 'RO':
34 VarProp = VariableAttributes.VAR_CHECK_VARIABLE_PROPERTY_READ_ONLY
35 else:
36 VarAttr = VarAttr | VariableAttributes.VarAttributesMap.get(attr, 0x00000000)
37 return VarAttr, VarProp
38 @staticmethod
39 def ValidateVarAttributes(var_attr_str):
40 if not var_attr_str:
41 return True, ""
42 attr_list = var_attr_str.split(",")
43 attr_temp = []
44 for attr in attr_list:
45 attr = attr.strip()
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"
51 return True, ""