]> git.proxmox.com Git - mirror_edk2.git/blame - BaseTools/Source/Python/Common/VariableAttributes.py
BaseTools: cleanup class heirarchy
[mirror_edk2.git] / BaseTools / Source / Python / Common / VariableAttributes.py
CommitLineData
82a6a960
BF
1# # @file\r
2# \r
3# This file is used to handle the variable attributes and property information\r
4#\r
5#\r
6# Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
7# This program and the accompanying materials\r
8# are licensed and made available under the terms and conditions of the BSD License\r
9# which accompanies this distribution. The full text of the license may be found at\r
10# http://opensource.org/licenses/bsd-license.php\r
11#\r
12# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
13# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
14#\r
15 \r
16class VariableAttributes(object):\r
17 EFI_VARIABLE_NON_VOLATILE = 0x00000001\r
18 EFI_VARIABLE_BOOTSERVICE_ACCESS = 0x00000002\r
19 EFI_VARIABLE_RUNTIME_ACCESS = 0x00000004\r
20 VAR_CHECK_VARIABLE_PROPERTY_READ_ONLY = 0x00000001\r
21 VarAttributesMap = {\r
22 "NV":EFI_VARIABLE_NON_VOLATILE,\r
23 "BS":EFI_VARIABLE_BOOTSERVICE_ACCESS,\r
24 "RT":EFI_VARIABLE_RUNTIME_ACCESS,\r
25 "RO":VAR_CHECK_VARIABLE_PROPERTY_READ_ONLY\r
26 }\r
27 \r
28 def __init__(self):\r
29 pass\r
30 \r
31 @staticmethod\r
32 def GetVarAttributes(var_attr_str):\r
33 VarAttr = 0x00000000\r
34 VarProp = 0x00000000\r
35 \r
36 attr_list = var_attr_str.split(",")\r
37 for attr in attr_list:\r
38 attr = attr.strip()\r
39 if attr == 'RO':\r
40 VarProp = VariableAttributes.VAR_CHECK_VARIABLE_PROPERTY_READ_ONLY\r
41 else:\r
42 VarAttr = VarAttr | VariableAttributes.VarAttributesMap.get(attr, 0x00000000) \r
43 return VarAttr, VarProp\r
44 @staticmethod\r
45 def ValidateVarAttributes(var_attr_str):\r
46 if not var_attr_str:\r
47 return True, ""\r
48 attr_list = var_attr_str.split(",")\r
49 attr_temp = []\r
50 for attr in attr_list:\r
51 attr = attr.strip()\r
52 attr_temp.append(attr)\r
53 if attr not in VariableAttributes.VarAttributesMap:\r
54 return False, "The variable attribute %s is not support to be specified in dsc file. Supported variable attribute are ['BS','NV','RT','RO'] "\r
55 if 'RT' in attr_temp and 'BS' not in attr_temp:\r
56 return False, "the RT attribute need the BS attribute to be present"\r
57 return True, ""\r