]>
Commit | Line | Data |
---|---|---|
82a6a960 | 1 | # # @file\r |
f7496d71 | 2 | #\r |
82a6a960 BF |
3 | # This file is used to handle the variable attributes and property information\r |
4 | #\r | |
5 | #\r | |
f7496d71 | 6 | # Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>\r |
2e351cbe | 7 | # SPDX-License-Identifier: BSD-2-Clause-Patent\r |
82a6a960 | 8 | #\r |
f7496d71 | 9 | \r |
82a6a960 BF |
10 | class VariableAttributes(object):\r |
11 | EFI_VARIABLE_NON_VOLATILE = 0x00000001\r | |
12 | EFI_VARIABLE_BOOTSERVICE_ACCESS = 0x00000002\r | |
13 | EFI_VARIABLE_RUNTIME_ACCESS = 0x00000004\r | |
14 | VAR_CHECK_VARIABLE_PROPERTY_READ_ONLY = 0x00000001\r | |
15 | VarAttributesMap = {\r | |
16 | "NV":EFI_VARIABLE_NON_VOLATILE,\r | |
17 | "BS":EFI_VARIABLE_BOOTSERVICE_ACCESS,\r | |
18 | "RT":EFI_VARIABLE_RUNTIME_ACCESS,\r | |
19 | "RO":VAR_CHECK_VARIABLE_PROPERTY_READ_ONLY\r | |
20 | }\r | |
f7496d71 | 21 | \r |
82a6a960 BF |
22 | def __init__(self):\r |
23 | pass\r | |
f7496d71 | 24 | \r |
82a6a960 BF |
25 | @staticmethod\r |
26 | def GetVarAttributes(var_attr_str):\r | |
27 | VarAttr = 0x00000000\r | |
28 | VarProp = 0x00000000\r | |
f7496d71 | 29 | \r |
82a6a960 BF |
30 | attr_list = var_attr_str.split(",")\r |
31 | for attr in attr_list:\r | |
32 | attr = attr.strip()\r | |
33 | if attr == 'RO':\r | |
34 | VarProp = VariableAttributes.VAR_CHECK_VARIABLE_PROPERTY_READ_ONLY\r | |
35 | else:\r | |
f7496d71 | 36 | VarAttr = VarAttr | VariableAttributes.VarAttributesMap.get(attr, 0x00000000)\r |
82a6a960 BF |
37 | return VarAttr, VarProp\r |
38 | @staticmethod\r | |
39 | def ValidateVarAttributes(var_attr_str):\r | |
40 | if not var_attr_str:\r | |
41 | return True, ""\r | |
42 | attr_list = var_attr_str.split(",")\r | |
43 | attr_temp = []\r | |
44 | for attr in attr_list:\r | |
45 | attr = attr.strip()\r | |
46 | attr_temp.append(attr)\r | |
47 | if attr not in VariableAttributes.VarAttributesMap:\r | |
48 | return False, "The variable attribute %s is not support to be specified in dsc file. Supported variable attribute are ['BS','NV','RT','RO'] "\r | |
49 | if 'RT' in attr_temp and 'BS' not in attr_temp:\r | |
50 | return False, "the RT attribute need the BS attribute to be present"\r | |
51 | return True, ""\r |