]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | DynamicTokenValue class.\r | |
3 | \r | |
4 | This module contains the value type of a dynamic token.\r | |
5 | \r | |
6 | Copyright (c) 2006, Intel Corporation\r | |
7 | All rights reserved. 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 | |
16 | package org.tianocore.pcd.entity;\r | |
17 | \r | |
18 | import java.util.List;\r | |
19 | import java.util.UUID;\r | |
20 | \r | |
21 | import org.tianocore.pcd.exception.EntityException;\r | |
22 | \r | |
23 | /**\r | |
24 | This class is to descript a value type of dynamic PCD.\r | |
25 | For a dynamic or dynamicEx type PCD data, the value type can be:\r | |
26 | 1) Hii type: the value of dynamic or dynamicEx is stored into a variable.\r | |
27 | 2) Vpd type: the value of dynamic or dynamicEx is stored into somewhere set\r | |
28 | by OEM.\r | |
29 | 3) Default type: the value of dynamic or dynamicEx is stored into PCD dynamic\r | |
30 | database.\r | |
31 | **/\r | |
32 | public class DynamicTokenValue {\r | |
33 | ///\r | |
34 | /// Enumeration macro defintion for value type.\r | |
35 | ///\r | |
36 | public static enum VALUE_TYPE {HII_TYPE, VPD_TYPE, DEFAULT_TYPE}\r | |
37 | \r | |
38 | ///\r | |
39 | /// The value type maybe:\r | |
40 | /// HII_TYPE: the value stored into variable area.\r | |
41 | /// VPD_TYPE: the value stored into OEM specific area.\r | |
42 | /// DEFAULT_TYPE: the value stored into PCD runtime database.\r | |
43 | ///\r | |
44 | public VALUE_TYPE type;\r | |
45 | \r | |
46 | ///\r | |
47 | /// ---------------------------------------------------------------------\r | |
48 | /// Following member is for HII case. The value of HII case will be put\r | |
49 | /// into variable area in flash.\r | |
50 | /// ---------------------------------------------------------------------\r | |
51 | ///\r | |
52 | \r | |
53 | ///\r | |
54 | /// variableName is valid only when this token support Hii functionality. variableName\r | |
55 | /// indicates the value of token is associated with what variable.\r | |
56 | /// variableName is defined in FPD.\r | |
57 | public List variableName;\r | |
58 | \r | |
59 | ///\r | |
60 | /// variableGuid is the GUID this token associated with.\r | |
61 | ///\r | |
62 | public UUID variableGuid;\r | |
63 | \r | |
64 | ///\r | |
65 | /// Variable offset indicate the associated variable's offset in NV storage.\r | |
66 | ///\r | |
67 | public String variableOffset;\r | |
68 | \r | |
69 | ///\r | |
70 | /// The default value for HII case.\r | |
71 | ///\r | |
72 | public String hiiDefaultValue;\r | |
73 | \r | |
74 | ///\r | |
75 | /// ---------------------------------------------------------------------\r | |
76 | /// Following member is for VPD case. The value of VPD case will be put into\r | |
77 | /// some flash position pointed by OEM.\r | |
78 | /// ---------------------------------------------------------------------\r | |
79 | ///\r | |
80 | \r | |
81 | public String vpdOffset;\r | |
82 | \r | |
83 | /// ---------------------------------------------------------------------\r | |
84 | /// Following member is for default case. The value of default type will\r | |
85 | /// be put into PCD runtime database.\r | |
86 | /// ---------------------------------------------------------------------\r | |
87 | \r | |
88 | ///\r | |
89 | /// The default value of this PCD in default case.\r | |
90 | ///\r | |
91 | public String value;\r | |
92 | \r | |
93 | /**\r | |
94 | Constructor function for DynamicTokenValue class.\r | |
95 | \r | |
96 | **/\r | |
97 | public DynamicTokenValue() {\r | |
98 | type = VALUE_TYPE.DEFAULT_TYPE;\r | |
99 | variableName = null;\r | |
100 | variableGuid = null;\r | |
101 | variableOffset = null;\r | |
102 | hiiDefaultValue = null;\r | |
103 | vpdOffset = null;\r | |
104 | value = null;\r | |
105 | }\r | |
106 | \r | |
107 | /**\r | |
108 | Set the HII case data.\r | |
109 | \r | |
110 | @param variableName The variable name\r | |
111 | @param variableGuid The variable guid\r | |
112 | @param variableOffset The offset of value in this variable\r | |
113 | @param hiiDefaultValue Default value for this PCD\r | |
114 | **/\r | |
115 | public void setHiiData(List variableName,\r | |
116 | UUID variableGuid,\r | |
117 | String variableOffset,\r | |
118 | String hiiDefaultValue) {\r | |
119 | this.type = VALUE_TYPE.HII_TYPE;\r | |
120 | \r | |
121 | this.variableName = variableName;\r | |
122 | this.variableGuid = variableGuid;\r | |
123 | this.variableOffset = variableOffset;\r | |
124 | this.hiiDefaultValue = hiiDefaultValue;\r | |
125 | }\r | |
126 | \r | |
127 | /**\r | |
128 | Get the string like L"xxx" for a variable Name.\r | |
129 | \r | |
130 | BUGBUG: In fact, it is not correctly, variable name should be\r | |
131 | treated as unicode UINT16 array.\r | |
132 | \r | |
133 | @return String\r | |
134 | **/\r | |
135 | public String getStringOfVariableName()\r | |
136 | throws EntityException {\r | |
137 | String str;\r | |
138 | int index, num;\r | |
139 | int size;\r | |
140 | \r | |
141 | str = "";\r | |
142 | size = variableName.size();\r | |
143 | for (index = 0; index < size; index++) {\r | |
144 | num = Integer.decode(variableName.get(index).toString());\r | |
145 | if ((num > 127 ) || (num < 0)) {\r | |
146 | throw new EntityException(String.format("The variable name contains more than 0x80 characters; this is not supported at thist time!"));\r | |
147 | }\r | |
148 | str += (char)num;\r | |
149 | }\r | |
150 | \r | |
151 | return str;\r | |
152 | }\r | |
153 | \r | |
154 | /**\r | |
155 | Set Vpd case data.\r | |
156 | \r | |
157 | @param vpdOffset the value offset the start address of OEM specific.\r | |
158 | **/\r | |
159 | public void setVpdData(String vpdOffset) {\r | |
160 | this.type = VALUE_TYPE.VPD_TYPE;\r | |
161 | \r | |
162 | this.vpdOffset = vpdOffset;\r | |
163 | }\r | |
164 | \r | |
165 | /**\r | |
166 | Set default case data.\r | |
167 | \r | |
168 | @param value\r | |
169 | **/\r | |
170 | public void setValue(String value) {\r | |
171 | this.type = VALUE_TYPE.DEFAULT_TYPE;\r | |
172 | \r | |
173 | this.value = value;\r | |
174 | }\r | |
175 | }\r | |
176 | \r | |
177 | \r | |
178 | \r | |
179 | \r | |
180 | \r |