qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1 | /** @file
|
| 2 | Parser for IFR binary encoding.
|
| 3 |
|
qwang12 | c410589 | 2009-02-06 06:34:43 +0000 | [diff] [blame] | 4 | Copyright (c) 2007 - 2009, Intel Corporation
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 5 | All rights reserved. This program and the accompanying materials
|
| 6 | are licensed and made available under the terms and conditions of the BSD License
|
| 7 | which accompanies this distribution. The full text of the license may be found at
|
| 8 | http://opensource.org/licenses/bsd-license.php
|
| 9 |
|
| 10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
| 11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
| 12 |
|
| 13 | **/
|
| 14 |
|
| 15 | #include "Setup.h"
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 16 |
|
| 17 | UINT16 mStatementIndex;
|
| 18 | UINT16 mExpressionOpCodeIndex;
|
| 19 |
|
| 20 | BOOLEAN mInScopeSubtitle;
|
| 21 | BOOLEAN mInScopeSuppress;
|
| 22 | BOOLEAN mInScopeGrayOut;
|
lgao4 | 0a1147e | 2009-04-22 03:18:37 +0000 | [diff] [blame] | 23 | BOOLEAN mInScopeDisable;
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 24 | FORM_EXPRESSION *mSuppressExpression;
|
| 25 | FORM_EXPRESSION *mGrayOutExpression;
|
lgao4 | 0a1147e | 2009-04-22 03:18:37 +0000 | [diff] [blame] | 26 | FORM_EXPRESSION *mDisableExpression;
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 27 |
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 28 | /**
|
| 29 | Initialize Statement header members.
|
| 30 |
|
| 31 | @param OpCodeData Pointer of the raw OpCode data.
|
| 32 | @param FormSet Pointer of the current FormSe.
|
| 33 | @param Form Pointer of the current Form.
|
| 34 |
|
| 35 | @return The Statement.
|
| 36 |
|
| 37 | **/
|
| 38 | FORM_BROWSER_STATEMENT *
|
| 39 | CreateStatement (
|
| 40 | IN UINT8 *OpCodeData,
|
| 41 | IN OUT FORM_BROWSER_FORMSET *FormSet,
|
| 42 | IN OUT FORM_BROWSER_FORM *Form
|
| 43 | )
|
| 44 | {
|
| 45 | FORM_BROWSER_STATEMENT *Statement;
|
| 46 | EFI_IFR_STATEMENT_HEADER *StatementHdr;
|
| 47 |
|
| 48 | if (Form == NULL) {
|
| 49 | //
|
| 50 | // We are currently not in a Form Scope, so just skip this Statement
|
| 51 | //
|
| 52 | return NULL;
|
| 53 | }
|
| 54 |
|
| 55 | Statement = &FormSet->StatementBuffer[mStatementIndex];
|
| 56 | mStatementIndex++;
|
| 57 |
|
| 58 | InitializeListHead (&Statement->DefaultListHead);
|
| 59 | InitializeListHead (&Statement->OptionListHead);
|
| 60 | InitializeListHead (&Statement->InconsistentListHead);
|
| 61 | InitializeListHead (&Statement->NoSubmitListHead);
|
| 62 |
|
| 63 | Statement->Signature = FORM_BROWSER_STATEMENT_SIGNATURE;
|
| 64 |
|
| 65 | Statement->Operand = ((EFI_IFR_OP_HEADER *) OpCodeData)->OpCode;
|
| 66 |
|
| 67 | StatementHdr = (EFI_IFR_STATEMENT_HEADER *) (OpCodeData + sizeof (EFI_IFR_OP_HEADER));
|
| 68 | CopyMem (&Statement->Prompt, &StatementHdr->Prompt, sizeof (EFI_STRING_ID));
|
| 69 | CopyMem (&Statement->Help, &StatementHdr->Help, sizeof (EFI_STRING_ID));
|
| 70 |
|
| 71 | if (mInScopeSuppress) {
|
| 72 | Statement->SuppressExpression = mSuppressExpression;
|
| 73 | }
|
| 74 |
|
| 75 | if (mInScopeGrayOut) {
|
| 76 | Statement->GrayOutExpression = mGrayOutExpression;
|
| 77 | }
|
| 78 |
|
lgao4 | 0a1147e | 2009-04-22 03:18:37 +0000 | [diff] [blame] | 79 |
|
| 80 | if (mInScopeDisable) {
|
| 81 | Statement->DisableExpression = mDisableExpression;
|
| 82 | }
|
| 83 |
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 84 | Statement->InSubtitle = mInScopeSubtitle;
|
| 85 |
|
| 86 | //
|
| 87 | // Insert this Statement into current Form
|
| 88 | //
|
| 89 | InsertTailList (&Form->StatementListHead, &Statement->Link);
|
| 90 |
|
| 91 | return Statement;
|
| 92 | }
|
| 93 |
|
qwang12 | 7064c0a | 2008-11-19 13:36:34 +0000 | [diff] [blame] | 94 | /**
|
| 95 | Convert a numeric value to a Unicode String and insert it to String Package.
|
| 96 | This string is used as the Unicode Name for the EFI Variable. This is to support
|
| 97 | the deprecated vareqval opcode.
|
xdu2 | 8b0fc5c | 2009-10-26 03:05:16 +0000 | [diff] [blame] | 98 |
|
qwang12 | 7064c0a | 2008-11-19 13:36:34 +0000 | [diff] [blame] | 99 | @param FormSet The FormSet.
|
| 100 | @param Statement The numeric question whose VarStoreInfo.VarName is the
|
| 101 | numeric value which is used to produce the Unicode Name
|
| 102 | for the EFI Variable.
|
xdu2 | 8b0fc5c | 2009-10-26 03:05:16 +0000 | [diff] [blame] | 103 |
|
qwang12 | 7064c0a | 2008-11-19 13:36:34 +0000 | [diff] [blame] | 104 | If the Statement is NULL, the ASSERT.
|
| 105 | If the opcode is not Numeric, then ASSERT.
|
xdu2 | 8b0fc5c | 2009-10-26 03:05:16 +0000 | [diff] [blame] | 106 |
|
qwang12 | 7064c0a | 2008-11-19 13:36:34 +0000 | [diff] [blame] | 107 | @retval EFI_SUCCESS The funtion always succeeds.
|
| 108 | **/
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 109 | EFI_STATUS
|
| 110 | UpdateCheckBoxStringToken (
|
| 111 | IN CONST FORM_BROWSER_FORMSET *FormSet,
|
| 112 | IN FORM_BROWSER_STATEMENT *Statement
|
| 113 | )
|
| 114 | {
|
| 115 | CHAR16 Str[MAXIMUM_VALUE_CHARACTERS];
|
| 116 | EFI_STRING_ID Id;
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 117 |
|
| 118 | ASSERT (Statement != NULL);
|
| 119 | ASSERT (Statement->Operand == EFI_IFR_NUMERIC_OP);
|
xdu2 | 8b0fc5c | 2009-10-26 03:05:16 +0000 | [diff] [blame] | 120 |
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 121 | UnicodeValueToString (Str, 0, Statement->VarStoreInfo.VarName, MAXIMUM_VALUE_CHARACTERS - 1);
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 122 |
|
rsun3 | cb7d01c | 2009-04-14 10:47:19 +0000 | [diff] [blame] | 123 | Id = HiiSetString (FormSet->HiiHandle, 0, Str, NULL);
|
| 124 | if (Id == 0) {
|
| 125 | return EFI_OUT_OF_RESOURCES;
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 126 | }
|
| 127 |
|
| 128 | Statement->VarStoreInfo.VarName = Id;
|
xdu2 | 8b0fc5c | 2009-10-26 03:05:16 +0000 | [diff] [blame] | 129 |
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 130 | return EFI_SUCCESS;
|
| 131 | }
|
| 132 |
|
qwang12 | 7064c0a | 2008-11-19 13:36:34 +0000 | [diff] [blame] | 133 | /**
|
| 134 | Check if the next opcode is the EFI_IFR_EXTEND_OP_VAREQNAME.
|
xdu2 | 8b0fc5c | 2009-10-26 03:05:16 +0000 | [diff] [blame] | 135 |
|
qwang12 | 7064c0a | 2008-11-19 13:36:34 +0000 | [diff] [blame] | 136 | @param OpCodeData The current opcode.
|
xdu2 | 8b0fc5c | 2009-10-26 03:05:16 +0000 | [diff] [blame] | 137 |
|
qwang12 | 7064c0a | 2008-11-19 13:36:34 +0000 | [diff] [blame] | 138 | @retval TRUE Yes.
|
| 139 | @retval FALSE No.
|
| 140 | **/
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 141 | BOOLEAN
|
| 142 | IsNextOpCodeGuidedVarEqName (
|
xdu2 | 8b0fc5c | 2009-10-26 03:05:16 +0000 | [diff] [blame] | 143 | IN UINT8 *OpCodeData
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 144 | )
|
| 145 | {
|
| 146 | //
|
| 147 | // Get next opcode
|
| 148 | //
|
| 149 | OpCodeData += ((EFI_IFR_OP_HEADER *) OpCodeData)->Length;
|
| 150 | if (*OpCodeData == EFI_IFR_GUID_OP) {
|
lgao4 | 5c52673 | 2009-02-23 15:18:48 +0000 | [diff] [blame] | 151 | if (CompareGuid (&gEfiIfrFrameworkGuid, (EFI_GUID *)(OpCodeData + sizeof (EFI_IFR_OP_HEADER)))) {
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 152 | //
|
xdu2 | 8b0fc5c | 2009-10-26 03:05:16 +0000 | [diff] [blame] | 153 | // Specific GUIDed opcodes to support IFR generated from Framework HII VFR
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 154 | //
|
| 155 | if ((((EFI_IFR_GUID_VAREQNAME *) OpCodeData)->ExtendOpCode) == EFI_IFR_EXTEND_OP_VAREQNAME) {
|
| 156 | return TRUE;
|
| 157 | }
|
| 158 | }
|
| 159 | }
|
| 160 |
|
| 161 | return FALSE;
|
| 162 | }
|
| 163 |
|
| 164 | /**
|
| 165 | Initialize Question's members.
|
| 166 |
|
| 167 | @param OpCodeData Pointer of the raw OpCode data.
|
| 168 | @param FormSet Pointer of the current FormSet.
|
| 169 | @param Form Pointer of the current Form.
|
| 170 |
|
| 171 | @return The Question.
|
| 172 |
|
| 173 | **/
|
| 174 | FORM_BROWSER_STATEMENT *
|
| 175 | CreateQuestion (
|
| 176 | IN UINT8 *OpCodeData,
|
| 177 | IN OUT FORM_BROWSER_FORMSET *FormSet,
|
| 178 | IN OUT FORM_BROWSER_FORM *Form
|
| 179 | )
|
| 180 | {
|
| 181 | FORM_BROWSER_STATEMENT *Statement;
|
| 182 | EFI_IFR_QUESTION_HEADER *QuestionHdr;
|
| 183 | LIST_ENTRY *Link;
|
| 184 | FORMSET_STORAGE *Storage;
|
| 185 | NAME_VALUE_NODE *NameValueNode;
|
| 186 | EFI_STATUS Status;
|
| 187 |
|
| 188 | Statement = CreateStatement (OpCodeData, FormSet, Form);
|
| 189 | if (Statement == NULL) {
|
| 190 | return NULL;
|
| 191 | }
|
| 192 |
|
| 193 | QuestionHdr = (EFI_IFR_QUESTION_HEADER *) (OpCodeData + sizeof (EFI_IFR_OP_HEADER));
|
| 194 | CopyMem (&Statement->QuestionId, &QuestionHdr->QuestionId, sizeof (EFI_QUESTION_ID));
|
| 195 | CopyMem (&Statement->VarStoreId, &QuestionHdr->VarStoreId, sizeof (EFI_VARSTORE_ID));
|
| 196 | CopyMem (&Statement->VarStoreInfo.VarOffset, &QuestionHdr->VarStoreInfo.VarOffset, sizeof (UINT16));
|
| 197 |
|
| 198 | Statement->QuestionFlags = QuestionHdr->Flags;
|
| 199 |
|
| 200 | if (Statement->VarStoreId == 0) {
|
| 201 | //
|
| 202 | // VarStoreId of zero indicates no variable storage
|
| 203 | //
|
| 204 | return Statement;
|
| 205 | }
|
| 206 |
|
| 207 | //
|
| 208 | // Take a look at next OpCode to see whether it is a GUIDed opcode to support
|
| 209 | // Framework Compatibility
|
| 210 | //
|
lgao4 | f806dd2 | 2009-02-25 09:04:47 +0000 | [diff] [blame] | 211 | if (FeaturePcdGet (PcdFrameworkCompatibilitySupport)) {
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 212 | if ((*OpCodeData == EFI_IFR_NUMERIC_OP) && IsNextOpCodeGuidedVarEqName (OpCodeData)) {
|
| 213 | Status = UpdateCheckBoxStringToken (FormSet, Statement);
|
| 214 | if (EFI_ERROR (Status)) {
|
| 215 | return NULL;
|
| 216 | }
|
| 217 | }
|
| 218 | }
|
| 219 |
|
| 220 | //
|
| 221 | // Find Storage for this Question
|
| 222 | //
|
| 223 | Link = GetFirstNode (&FormSet->StorageListHead);
|
| 224 | while (!IsNull (&FormSet->StorageListHead, Link)) {
|
| 225 | Storage = FORMSET_STORAGE_FROM_LINK (Link);
|
| 226 |
|
| 227 | if (Storage->VarStoreId == Statement->VarStoreId) {
|
| 228 | Statement->Storage = Storage;
|
| 229 | break;
|
| 230 | }
|
| 231 |
|
| 232 | Link = GetNextNode (&FormSet->StorageListHead, Link);
|
| 233 | }
|
| 234 | ASSERT (Statement->Storage != NULL);
|
| 235 |
|
| 236 | //
|
| 237 | // Initialilze varname for Name/Value or EFI Variable
|
| 238 | //
|
| 239 | if ((Statement->Storage->Type == EFI_HII_VARSTORE_NAME_VALUE) ||
|
| 240 | (Statement->Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE)) {
|
| 241 | Statement->VariableName = GetToken (Statement->VarStoreInfo.VarName, FormSet->HiiHandle);
|
| 242 | ASSERT (Statement->VariableName != NULL);
|
| 243 |
|
| 244 | if (Statement->Storage->Type == EFI_HII_VARSTORE_NAME_VALUE) {
|
| 245 | //
|
| 246 | // Insert to Name/Value varstore list
|
| 247 | //
|
| 248 | NameValueNode = AllocateZeroPool (sizeof (NAME_VALUE_NODE));
|
| 249 | ASSERT (NameValueNode != NULL);
|
| 250 | NameValueNode->Signature = NAME_VALUE_NODE_SIGNATURE;
|
| 251 | NameValueNode->Name = AllocateCopyPool (StrSize (Statement->VariableName), Statement->VariableName);
|
| 252 | ASSERT (NameValueNode->Name != NULL);
|
| 253 | NameValueNode->Value = AllocateZeroPool (0x10);
|
| 254 | ASSERT (NameValueNode->Value != NULL);
|
| 255 | NameValueNode->EditValue = AllocateZeroPool (0x10);
|
| 256 | ASSERT (NameValueNode->EditValue != NULL);
|
| 257 |
|
| 258 | InsertTailList (&Statement->Storage->NameValueListHead, &NameValueNode->Link);
|
| 259 | }
|
| 260 | }
|
| 261 |
|
| 262 | return Statement;
|
| 263 | }
|
| 264 |
|
| 265 |
|
| 266 | /**
|
| 267 | Allocate a FORM_EXPRESSION node.
|
| 268 |
|
| 269 | @param Form The Form associated with this Expression
|
| 270 |
|
| 271 | @return Pointer to a FORM_EXPRESSION data structure.
|
| 272 |
|
| 273 | **/
|
| 274 | FORM_EXPRESSION *
|
| 275 | CreateExpression (
|
| 276 | IN OUT FORM_BROWSER_FORM *Form
|
| 277 | )
|
| 278 | {
|
| 279 | FORM_EXPRESSION *Expression;
|
| 280 |
|
| 281 | Expression = AllocateZeroPool (sizeof (FORM_EXPRESSION));
|
jji4 | 1ac628e | 2009-01-19 07:58:58 +0000 | [diff] [blame] | 282 | ASSERT (Expression != NULL);
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 283 | Expression->Signature = FORM_EXPRESSION_SIGNATURE;
|
| 284 | InitializeListHead (&Expression->OpCodeListHead);
|
| 285 |
|
| 286 | return Expression;
|
| 287 | }
|
| 288 |
|
| 289 |
|
| 290 | /**
|
| 291 | Allocate a FORMSET_STORAGE data structure and insert to FormSet Storage List.
|
| 292 |
|
| 293 | @param FormSet Pointer of the current FormSet
|
| 294 |
|
| 295 | @return Pointer to a FORMSET_STORAGE data structure.
|
| 296 |
|
| 297 | **/
|
| 298 | FORMSET_STORAGE *
|
| 299 | CreateStorage (
|
| 300 | IN FORM_BROWSER_FORMSET *FormSet
|
| 301 | )
|
| 302 | {
|
| 303 | FORMSET_STORAGE *Storage;
|
| 304 |
|
| 305 | Storage = AllocateZeroPool (sizeof (FORMSET_STORAGE));
|
jji4 | 1ac628e | 2009-01-19 07:58:58 +0000 | [diff] [blame] | 306 | ASSERT (Storage != NULL);
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 307 | Storage->Signature = FORMSET_STORAGE_SIGNATURE;
|
| 308 | InitializeListHead (&Storage->NameValueListHead);
|
| 309 | InsertTailList (&FormSet->StorageListHead, &Storage->Link);
|
| 310 |
|
| 311 | return Storage;
|
| 312 | }
|
| 313 |
|
| 314 |
|
| 315 | /**
|
| 316 | Create ConfigHdr string for a storage.
|
| 317 |
|
| 318 | @param FormSet Pointer of the current FormSet
|
| 319 | @param Storage Pointer of the storage
|
| 320 |
|
| 321 | @retval EFI_SUCCESS Initialize ConfigHdr success
|
| 322 |
|
| 323 | **/
|
| 324 | EFI_STATUS
|
| 325 | InitializeConfigHdr (
|
| 326 | IN FORM_BROWSER_FORMSET *FormSet,
|
| 327 | IN OUT FORMSET_STORAGE *Storage
|
| 328 | )
|
| 329 | {
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 330 | CHAR16 *Name;
|
xdu2 | 8b0fc5c | 2009-10-26 03:05:16 +0000 | [diff] [blame] | 331 |
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 332 | if (Storage->Type == EFI_HII_VARSTORE_BUFFER) {
|
| 333 | Name = Storage->Name;
|
| 334 | } else {
|
| 335 | Name = NULL;
|
| 336 | }
|
xdu2 | 8b0fc5c | 2009-10-26 03:05:16 +0000 | [diff] [blame] | 337 |
|
lgao4 | 7e3bccc | 2009-04-13 06:05:15 +0000 | [diff] [blame] | 338 | Storage->ConfigHdr = HiiConstructConfigHdr (
|
| 339 | &Storage->Guid,
|
| 340 | Name,
|
| 341 | FormSet->DriverHandle
|
| 342 | );
|
xdu2 | 8b0fc5c | 2009-10-26 03:05:16 +0000 | [diff] [blame] | 343 |
|
lgao4 | 7e3bccc | 2009-04-13 06:05:15 +0000 | [diff] [blame] | 344 | if (Storage->ConfigHdr == NULL) {
|
| 345 | return EFI_NOT_FOUND;
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 346 | }
|
| 347 |
|
lgao4 | 7e3bccc | 2009-04-13 06:05:15 +0000 | [diff] [blame] | 348 | Storage->ConfigRequest = AllocateCopyPool (StrSize (Storage->ConfigHdr), Storage->ConfigHdr);
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 349 | Storage->SpareStrLen = 0;
|
| 350 |
|
| 351 | return EFI_SUCCESS;
|
| 352 | }
|
| 353 |
|
| 354 |
|
| 355 | /**
|
| 356 | Initialize Request Element of a Question. <RequestElement> ::= '&'<BlockName> | '&'<Label>
|
| 357 |
|
| 358 | @param FormSet Pointer of the current FormSet.
|
| 359 | @param Question The Question to be initialized.
|
| 360 |
|
| 361 | @retval EFI_SUCCESS Function success.
|
| 362 | @retval EFI_INVALID_PARAMETER No storage associated with the Question.
|
| 363 |
|
| 364 | **/
|
| 365 | EFI_STATUS
|
| 366 | InitializeRequestElement (
|
| 367 | IN OUT FORM_BROWSER_FORMSET *FormSet,
|
| 368 | IN OUT FORM_BROWSER_STATEMENT *Question
|
| 369 | )
|
| 370 | {
|
| 371 | FORMSET_STORAGE *Storage;
|
| 372 | UINTN StrLen;
|
| 373 | UINTN StringSize;
|
| 374 | CHAR16 *NewStr;
|
| 375 | CHAR16 RequestElement[30];
|
| 376 |
|
| 377 | Storage = Question->Storage;
|
| 378 | if (Storage == NULL) {
|
| 379 | return EFI_INVALID_PARAMETER;
|
| 380 | }
|
| 381 |
|
| 382 | if (Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE) {
|
| 383 | //
|
| 384 | // <ConfigRequest> is unnecessary for EFI variable storage,
|
| 385 | // GetVariable()/SetVariable() will be used to retrieve/save values
|
| 386 | //
|
| 387 | return EFI_SUCCESS;
|
| 388 | }
|
| 389 |
|
| 390 | //
|
| 391 | // Prepare <RequestElement>
|
| 392 | //
|
| 393 | if (Storage->Type == EFI_HII_VARSTORE_BUFFER) {
|
| 394 | StrLen = UnicodeSPrint (
|
| 395 | RequestElement,
|
| 396 | 30 * sizeof (CHAR16),
|
| 397 | L"&OFFSET=%x&WIDTH=%x",
|
| 398 | Question->VarStoreInfo.VarOffset,
|
| 399 | Question->StorageWidth
|
| 400 | );
|
| 401 | Question->BlockName = AllocateCopyPool ((StrLen + 1) * sizeof (CHAR16), RequestElement);
|
| 402 | } else {
|
| 403 | StrLen = UnicodeSPrint (RequestElement, 30 * sizeof (CHAR16), L"&%s", Question->VariableName);
|
| 404 | }
|
| 405 |
|
| 406 | if ((Question->Operand == EFI_IFR_PASSWORD_OP) && ((Question->QuestionFlags & EFI_IFR_FLAG_CALLBACK) == EFI_IFR_FLAG_CALLBACK)) {
|
| 407 | //
|
| 408 | // Password with CALLBACK flag is stored in encoded format,
|
| 409 | // so don't need to append it to <ConfigRequest>
|
| 410 | //
|
| 411 | return EFI_SUCCESS;
|
| 412 | }
|
| 413 |
|
| 414 | //
|
| 415 | // Append <RequestElement> to <ConfigRequest>
|
| 416 | //
|
| 417 | if (StrLen > Storage->SpareStrLen) {
|
| 418 | //
|
| 419 | // Old String buffer is not sufficient for RequestElement, allocate a new one
|
| 420 | //
|
| 421 | StringSize = (Storage->ConfigRequest != NULL) ? StrSize (Storage->ConfigRequest) : sizeof (CHAR16);
|
| 422 | NewStr = AllocateZeroPool (StringSize + CONFIG_REQUEST_STRING_INCREMENTAL * sizeof (CHAR16));
|
jji4 | 1ac628e | 2009-01-19 07:58:58 +0000 | [diff] [blame] | 423 | ASSERT (NewStr != NULL);
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 424 | if (Storage->ConfigRequest != NULL) {
|
| 425 | CopyMem (NewStr, Storage->ConfigRequest, StringSize);
|
qwang12 | f4113e1 | 2008-11-21 06:59:58 +0000 | [diff] [blame] | 426 | FreePool (Storage->ConfigRequest);
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 427 | }
|
| 428 | Storage->ConfigRequest = NewStr;
|
| 429 | Storage->SpareStrLen = CONFIG_REQUEST_STRING_INCREMENTAL;
|
| 430 | }
|
| 431 |
|
| 432 | StrCat (Storage->ConfigRequest, RequestElement);
|
| 433 | Storage->ElementCount++;
|
| 434 | Storage->SpareStrLen -= StrLen;
|
| 435 |
|
| 436 | return EFI_SUCCESS;
|
| 437 | }
|
| 438 |
|
| 439 |
|
| 440 | /**
|
| 441 | Free resources of a Expression.
|
| 442 |
|
| 443 | @param FormSet Pointer of the Expression
|
| 444 |
|
| 445 | **/
|
| 446 | VOID
|
| 447 | DestroyExpression (
|
| 448 | IN FORM_EXPRESSION *Expression
|
| 449 | )
|
| 450 | {
|
| 451 | LIST_ENTRY *Link;
|
| 452 | EXPRESSION_OPCODE *OpCode;
|
| 453 |
|
| 454 | while (!IsListEmpty (&Expression->OpCodeListHead)) {
|
| 455 | Link = GetFirstNode (&Expression->OpCodeListHead);
|
| 456 | OpCode = EXPRESSION_OPCODE_FROM_LINK (Link);
|
| 457 | RemoveEntryList (&OpCode->Link);
|
| 458 |
|
| 459 | if (OpCode->ValueList != NULL) {
|
| 460 | FreePool (OpCode->ValueList);
|
| 461 | }
|
| 462 | }
|
| 463 |
|
| 464 | //
|
| 465 | // Free this Expression
|
| 466 | //
|
qwang12 | f4113e1 | 2008-11-21 06:59:58 +0000 | [diff] [blame] | 467 | FreePool (Expression);
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 468 | }
|
| 469 |
|
| 470 |
|
| 471 | /**
|
| 472 | Free resources of a storage.
|
| 473 |
|
| 474 | @param Storage Pointer of the storage
|
| 475 |
|
| 476 | **/
|
| 477 | VOID
|
| 478 | DestroyStorage (
|
| 479 | IN FORMSET_STORAGE *Storage
|
| 480 | )
|
| 481 | {
|
| 482 | LIST_ENTRY *Link;
|
| 483 | NAME_VALUE_NODE *NameValueNode;
|
| 484 |
|
| 485 | if (Storage == NULL) {
|
| 486 | return;
|
| 487 | }
|
| 488 |
|
| 489 | if (Storage->Name != NULL) {
|
| 490 | FreePool (Storage->Name);
|
| 491 | }
|
| 492 | if (Storage->Buffer != NULL) {
|
| 493 | FreePool (Storage->Buffer);
|
| 494 | }
|
| 495 | if (Storage->EditBuffer != NULL) {
|
| 496 | FreePool (Storage->EditBuffer);
|
| 497 | }
|
| 498 |
|
| 499 | while (!IsListEmpty (&Storage->NameValueListHead)) {
|
| 500 | Link = GetFirstNode (&Storage->NameValueListHead);
|
| 501 | NameValueNode = NAME_VALUE_NODE_FROM_LINK (Link);
|
| 502 | RemoveEntryList (&NameValueNode->Link);
|
| 503 |
|
| 504 | if (NameValueNode->Name != NULL) {
|
| 505 | FreePool (NameValueNode->Name);
|
| 506 | }
|
| 507 | if (NameValueNode->Value != NULL) {
|
| 508 | FreePool (NameValueNode->Value);
|
| 509 | }
|
| 510 | if (NameValueNode->EditValue != NULL) {
|
| 511 | FreePool (NameValueNode->EditValue);
|
| 512 | }
|
| 513 | FreePool (NameValueNode);
|
| 514 | }
|
| 515 |
|
| 516 | if (Storage->ConfigHdr != NULL) {
|
| 517 | FreePool (Storage->ConfigHdr);
|
| 518 | }
|
| 519 | if (Storage->ConfigRequest != NULL) {
|
| 520 | FreePool (Storage->ConfigRequest);
|
| 521 | }
|
| 522 |
|
| 523 | FreePool (Storage);
|
| 524 | }
|
| 525 |
|
| 526 |
|
| 527 | /**
|
| 528 | Free resources of a Statement.
|
| 529 |
|
| 530 | @param Statement Pointer of the Statement
|
| 531 |
|
| 532 | **/
|
| 533 | VOID
|
| 534 | DestroyStatement (
|
| 535 | IN OUT FORM_BROWSER_STATEMENT *Statement
|
| 536 | )
|
| 537 | {
|
| 538 | LIST_ENTRY *Link;
|
| 539 | QUESTION_DEFAULT *Default;
|
| 540 | QUESTION_OPTION *Option;
|
| 541 | FORM_EXPRESSION *Expression;
|
| 542 |
|
| 543 | //
|
| 544 | // Free Default value List
|
| 545 | //
|
| 546 | while (!IsListEmpty (&Statement->DefaultListHead)) {
|
| 547 | Link = GetFirstNode (&Statement->DefaultListHead);
|
| 548 | Default = QUESTION_DEFAULT_FROM_LINK (Link);
|
| 549 | RemoveEntryList (&Default->Link);
|
| 550 |
|
qwang12 | f4113e1 | 2008-11-21 06:59:58 +0000 | [diff] [blame] | 551 | FreePool (Default);
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 552 | }
|
| 553 |
|
| 554 | //
|
| 555 | // Free Options List
|
| 556 | //
|
| 557 | while (!IsListEmpty (&Statement->OptionListHead)) {
|
| 558 | Link = GetFirstNode (&Statement->OptionListHead);
|
| 559 | Option = QUESTION_OPTION_FROM_LINK (Link);
|
| 560 | RemoveEntryList (&Option->Link);
|
| 561 |
|
qwang12 | f4113e1 | 2008-11-21 06:59:58 +0000 | [diff] [blame] | 562 | FreePool (Option);
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 563 | }
|
| 564 |
|
| 565 | //
|
| 566 | // Free Inconsistent List
|
| 567 | //
|
| 568 | while (!IsListEmpty (&Statement->InconsistentListHead)) {
|
| 569 | Link = GetFirstNode (&Statement->InconsistentListHead);
|
| 570 | Expression = FORM_EXPRESSION_FROM_LINK (Link);
|
| 571 | RemoveEntryList (&Expression->Link);
|
| 572 |
|
| 573 | DestroyExpression (Expression);
|
| 574 | }
|
| 575 |
|
| 576 | //
|
| 577 | // Free NoSubmit List
|
| 578 | //
|
| 579 | while (!IsListEmpty (&Statement->NoSubmitListHead)) {
|
| 580 | Link = GetFirstNode (&Statement->NoSubmitListHead);
|
| 581 | Expression = FORM_EXPRESSION_FROM_LINK (Link);
|
| 582 | RemoveEntryList (&Expression->Link);
|
| 583 |
|
| 584 | DestroyExpression (Expression);
|
| 585 | }
|
| 586 |
|
| 587 | if (Statement->VariableName != NULL) {
|
| 588 | FreePool (Statement->VariableName);
|
| 589 | }
|
| 590 | if (Statement->BlockName != NULL) {
|
| 591 | FreePool (Statement->BlockName);
|
| 592 | }
|
| 593 | }
|
| 594 |
|
| 595 |
|
| 596 | /**
|
| 597 | Free resources of a Form.
|
| 598 |
|
| 599 | @param Form Pointer of the Form.
|
| 600 |
|
| 601 | **/
|
| 602 | VOID
|
| 603 | DestroyForm (
|
| 604 | IN OUT FORM_BROWSER_FORM *Form
|
| 605 | )
|
| 606 | {
|
| 607 | LIST_ENTRY *Link;
|
| 608 | FORM_EXPRESSION *Expression;
|
| 609 | FORM_BROWSER_STATEMENT *Statement;
|
| 610 |
|
| 611 | //
|
| 612 | // Free Form Expressions
|
| 613 | //
|
| 614 | while (!IsListEmpty (&Form->ExpressionListHead)) {
|
| 615 | Link = GetFirstNode (&Form->ExpressionListHead);
|
| 616 | Expression = FORM_EXPRESSION_FROM_LINK (Link);
|
| 617 | RemoveEntryList (&Expression->Link);
|
| 618 |
|
| 619 | DestroyExpression (Expression);
|
| 620 | }
|
| 621 |
|
| 622 | //
|
| 623 | // Free Statements/Questions
|
| 624 | //
|
| 625 | while (!IsListEmpty (&Form->StatementListHead)) {
|
| 626 | Link = GetFirstNode (&Form->StatementListHead);
|
| 627 | Statement = FORM_BROWSER_STATEMENT_FROM_LINK (Link);
|
| 628 | RemoveEntryList (&Statement->Link);
|
| 629 |
|
| 630 | DestroyStatement (Statement);
|
| 631 | }
|
| 632 |
|
| 633 | //
|
| 634 | // Free this Form
|
| 635 | //
|
qwang12 | f4113e1 | 2008-11-21 06:59:58 +0000 | [diff] [blame] | 636 | FreePool (Form);
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 637 | }
|
| 638 |
|
| 639 |
|
| 640 | /**
|
| 641 | Free resources allocated for a FormSet.
|
| 642 |
|
| 643 | @param FormSet Pointer of the FormSet
|
| 644 |
|
| 645 | **/
|
| 646 | VOID
|
| 647 | DestroyFormSet (
|
| 648 | IN OUT FORM_BROWSER_FORMSET *FormSet
|
| 649 | )
|
| 650 | {
|
| 651 | LIST_ENTRY *Link;
|
| 652 | FORMSET_STORAGE *Storage;
|
| 653 | FORMSET_DEFAULTSTORE *DefaultStore;
|
lgao4 | 0c66bc7 | 2009-11-12 01:16:12 +0000 | [diff] [blame] | 654 | FORM_EXPRESSION *Expression;
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 655 | FORM_BROWSER_FORM *Form;
|
| 656 |
|
xdu2 | 4c8358c | 2009-11-13 05:40:21 +0000 | [diff] [blame] | 657 | if (FormSet->IfrBinaryData == NULL) {
|
| 658 | //
|
| 659 | // Uninitialized FormSet
|
| 660 | //
|
| 661 | FreePool (FormSet);
|
| 662 | return;
|
| 663 | }
|
| 664 |
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 665 | //
|
| 666 | // Free IFR binary buffer
|
| 667 | //
|
| 668 | FreePool (FormSet->IfrBinaryData);
|
| 669 |
|
| 670 | //
|
| 671 | // Free FormSet Storage
|
| 672 | //
|
| 673 | if (FormSet->StorageListHead.ForwardLink != NULL) {
|
| 674 | while (!IsListEmpty (&FormSet->StorageListHead)) {
|
| 675 | Link = GetFirstNode (&FormSet->StorageListHead);
|
| 676 | Storage = FORMSET_STORAGE_FROM_LINK (Link);
|
| 677 | RemoveEntryList (&Storage->Link);
|
| 678 |
|
| 679 | DestroyStorage (Storage);
|
| 680 | }
|
| 681 | }
|
| 682 |
|
| 683 | //
|
| 684 | // Free FormSet Default Store
|
| 685 | //
|
| 686 | if (FormSet->DefaultStoreListHead.ForwardLink != NULL) {
|
| 687 | while (!IsListEmpty (&FormSet->DefaultStoreListHead)) {
|
| 688 | Link = GetFirstNode (&FormSet->DefaultStoreListHead);
|
| 689 | DefaultStore = FORMSET_DEFAULTSTORE_FROM_LINK (Link);
|
| 690 | RemoveEntryList (&DefaultStore->Link);
|
| 691 |
|
qwang12 | f4113e1 | 2008-11-21 06:59:58 +0000 | [diff] [blame] | 692 | FreePool (DefaultStore);
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 693 | }
|
| 694 | }
|
| 695 |
|
| 696 | //
|
lgao4 | 0c66bc7 | 2009-11-12 01:16:12 +0000 | [diff] [blame] | 697 | // Free Formset Expressions
|
| 698 | //
|
| 699 | while (!IsListEmpty (&FormSet->ExpressionListHead)) {
|
| 700 | Link = GetFirstNode (&FormSet->ExpressionListHead);
|
| 701 | Expression = FORM_EXPRESSION_FROM_LINK (Link);
|
| 702 | RemoveEntryList (&Expression->Link);
|
| 703 |
|
| 704 | DestroyExpression (Expression);
|
| 705 | }
|
| 706 |
|
| 707 | //
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 708 | // Free Forms
|
| 709 | //
|
| 710 | if (FormSet->FormListHead.ForwardLink != NULL) {
|
| 711 | while (!IsListEmpty (&FormSet->FormListHead)) {
|
| 712 | Link = GetFirstNode (&FormSet->FormListHead);
|
| 713 | Form = FORM_BROWSER_FORM_FROM_LINK (Link);
|
| 714 | RemoveEntryList (&Form->Link);
|
| 715 |
|
| 716 | DestroyForm (Form);
|
| 717 | }
|
| 718 | }
|
| 719 |
|
| 720 | if (FormSet->StatementBuffer != NULL) {
|
| 721 | FreePool (FormSet->StatementBuffer);
|
| 722 | }
|
| 723 | if (FormSet->ExpressionBuffer != NULL) {
|
| 724 | FreePool (FormSet->ExpressionBuffer);
|
| 725 | }
|
| 726 |
|
| 727 | FreePool (FormSet);
|
| 728 | }
|
| 729 |
|
| 730 |
|
| 731 | /**
|
| 732 | Tell whether this Operand is an Expression OpCode or not
|
| 733 |
|
| 734 | @param Operand Operand of an IFR OpCode.
|
| 735 |
|
| 736 | @retval TRUE This is an Expression OpCode.
|
| 737 | @retval FALSE Not an Expression OpCode.
|
| 738 |
|
| 739 | **/
|
| 740 | BOOLEAN
|
| 741 | IsExpressionOpCode (
|
| 742 | IN UINT8 Operand
|
| 743 | )
|
| 744 | {
|
| 745 | if (((Operand >= EFI_IFR_EQ_ID_VAL_OP) && (Operand <= EFI_IFR_NOT_OP)) ||
|
| 746 | ((Operand >= EFI_IFR_MATCH_OP) && (Operand <= EFI_IFR_SPAN_OP)) ||
|
| 747 | (Operand == EFI_IFR_CATENATE_OP) ||
|
| 748 | (Operand == EFI_IFR_TO_LOWER_OP) ||
|
| 749 | (Operand == EFI_IFR_TO_UPPER_OP) ||
|
rsun3 | cbf73e5 | 2009-11-26 09:26:42 +0000 | [diff] [blame^] | 750 | (Operand == EFI_IFR_VERSION_OP) ||
|
| 751 | (Operand == EFI_IFR_SECURITY_OP)) {
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 752 | return TRUE;
|
| 753 | } else {
|
| 754 | return FALSE;
|
| 755 | }
|
| 756 | }
|
| 757 |
|
| 758 |
|
| 759 | /**
|
| 760 | Calculate number of Statemens(Questions) and Expression OpCodes.
|
| 761 |
|
| 762 | @param FormSet The FormSet to be counted.
|
| 763 | @param NumberOfStatement Number of Statemens(Questions)
|
| 764 | @param NumberOfExpression Number of Expression OpCodes
|
| 765 |
|
| 766 | **/
|
| 767 | VOID
|
| 768 | CountOpCodes (
|
| 769 | IN FORM_BROWSER_FORMSET *FormSet,
|
| 770 | IN OUT UINT16 *NumberOfStatement,
|
| 771 | IN OUT UINT16 *NumberOfExpression
|
| 772 | )
|
| 773 | {
|
| 774 | UINT16 StatementCount;
|
| 775 | UINT16 ExpressionCount;
|
| 776 | UINT8 *OpCodeData;
|
| 777 | UINTN Offset;
|
| 778 | UINTN OpCodeLen;
|
| 779 |
|
| 780 | Offset = 0;
|
| 781 | StatementCount = 0;
|
| 782 | ExpressionCount = 0;
|
| 783 |
|
| 784 | while (Offset < FormSet->IfrBinaryLength) {
|
| 785 | OpCodeData = FormSet->IfrBinaryData + Offset;
|
| 786 | OpCodeLen = ((EFI_IFR_OP_HEADER *) OpCodeData)->Length;
|
| 787 | Offset += OpCodeLen;
|
| 788 |
|
| 789 | if (IsExpressionOpCode (((EFI_IFR_OP_HEADER *) OpCodeData)->OpCode)) {
|
| 790 | ExpressionCount++;
|
| 791 | } else {
|
| 792 | StatementCount++;
|
| 793 | }
|
| 794 | }
|
| 795 |
|
| 796 | *NumberOfStatement = StatementCount;
|
| 797 | *NumberOfExpression = ExpressionCount;
|
| 798 | }
|
| 799 |
|
| 800 |
|
| 801 |
|
| 802 | /**
|
| 803 | Parse opcodes in the formset IFR binary.
|
| 804 |
|
| 805 | @param FormSet Pointer of the FormSet data structure.
|
| 806 |
|
| 807 | @retval EFI_SUCCESS Opcode parse success.
|
| 808 | @retval Other Opcode parse fail.
|
| 809 |
|
| 810 | **/
|
| 811 | EFI_STATUS
|
| 812 | ParseOpCodes (
|
| 813 | IN FORM_BROWSER_FORMSET *FormSet
|
| 814 | )
|
| 815 | {
|
| 816 | EFI_STATUS Status;
|
| 817 | UINT16 Index;
|
| 818 | FORM_BROWSER_FORM *CurrentForm;
|
| 819 | FORM_BROWSER_STATEMENT *CurrentStatement;
|
| 820 | EXPRESSION_OPCODE *ExpressionOpCode;
|
| 821 | FORM_EXPRESSION *CurrentExpression;
|
| 822 | UINT8 Operand;
|
| 823 | UINT8 Scope;
|
| 824 | UINTN OpCodeOffset;
|
| 825 | UINTN OpCodeLength;
|
| 826 | UINT8 *OpCodeData;
|
| 827 | UINT8 ScopeOpCode;
|
| 828 | FORMSET_STORAGE *Storage;
|
| 829 | FORMSET_DEFAULTSTORE *DefaultStore;
|
| 830 | QUESTION_DEFAULT *CurrentDefault;
|
| 831 | QUESTION_OPTION *CurrentOption;
|
xdu2 | d02847d | 2009-10-26 03:03:47 +0000 | [diff] [blame] | 832 | UINT8 Width;
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 833 | CHAR8 *AsciiString;
|
| 834 | UINT16 NumberOfStatement;
|
| 835 | UINT16 NumberOfExpression;
|
| 836 | EFI_IMAGE_ID *ImageId;
|
lgao4 | 0c66bc7 | 2009-11-12 01:16:12 +0000 | [diff] [blame] | 837 | BOOLEAN SuppressForQuestion;
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 838 | BOOLEAN SuppressForOption;
|
| 839 | BOOLEAN InScopeOptionSuppress;
|
| 840 | FORM_EXPRESSION *OptionSuppressExpression;
|
lgao4 | 0c66bc7 | 2009-11-12 01:16:12 +0000 | [diff] [blame] | 841 | BOOLEAN InScopeFormSuppress;
|
| 842 | FORM_EXPRESSION *FormSuppressExpression;
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 843 | UINT16 DepthOfDisable;
|
| 844 | BOOLEAN OpCodeDisabled;
|
| 845 | BOOLEAN SingleOpCodeExpression;
|
| 846 | BOOLEAN InScopeDefault;
|
| 847 | EFI_HII_VALUE *Value;
|
| 848 |
|
| 849 | mInScopeSubtitle = FALSE;
|
lgao4 | 0c66bc7 | 2009-11-12 01:16:12 +0000 | [diff] [blame] | 850 | SuppressForQuestion = FALSE;
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 851 | SuppressForOption = FALSE;
|
lgao4 | 0c66bc7 | 2009-11-12 01:16:12 +0000 | [diff] [blame] | 852 | InScopeFormSuppress = FALSE;
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 853 | mInScopeSuppress = FALSE;
|
| 854 | InScopeOptionSuppress = FALSE;
|
| 855 | mInScopeGrayOut = FALSE;
|
lgao4 | 0a1147e | 2009-04-22 03:18:37 +0000 | [diff] [blame] | 856 | mInScopeDisable = FALSE;
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 857 | DepthOfDisable = 0;
|
| 858 | OpCodeDisabled = FALSE;
|
| 859 | SingleOpCodeExpression = FALSE;
|
| 860 | InScopeDefault = FALSE;
|
| 861 | CurrentExpression = NULL;
|
| 862 | CurrentDefault = NULL;
|
| 863 | CurrentOption = NULL;
|
| 864 | OptionSuppressExpression = NULL;
|
lgao4 | 0c66bc7 | 2009-11-12 01:16:12 +0000 | [diff] [blame] | 865 | FormSuppressExpression = NULL;
|
qwang12 | c410589 | 2009-02-06 06:34:43 +0000 | [diff] [blame] | 866 | ImageId = NULL;
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 867 |
|
| 868 | //
|
| 869 | // Get the number of Statements and Expressions
|
| 870 | //
|
| 871 | CountOpCodes (FormSet, &NumberOfStatement, &NumberOfExpression);
|
| 872 |
|
| 873 | mStatementIndex = 0;
|
| 874 | FormSet->StatementBuffer = AllocateZeroPool (NumberOfStatement * sizeof (FORM_BROWSER_STATEMENT));
|
| 875 | if (FormSet->StatementBuffer == NULL) {
|
| 876 | return EFI_OUT_OF_RESOURCES;
|
| 877 | }
|
| 878 |
|
| 879 | mExpressionOpCodeIndex = 0;
|
| 880 | FormSet->ExpressionBuffer = AllocateZeroPool (NumberOfExpression * sizeof (EXPRESSION_OPCODE));
|
| 881 | if (FormSet->ExpressionBuffer == NULL) {
|
| 882 | return EFI_OUT_OF_RESOURCES;
|
| 883 | }
|
| 884 |
|
| 885 | InitializeListHead (&FormSet->StorageListHead);
|
| 886 | InitializeListHead (&FormSet->DefaultStoreListHead);
|
| 887 | InitializeListHead (&FormSet->FormListHead);
|
| 888 |
|
| 889 | CurrentForm = NULL;
|
| 890 | CurrentStatement = NULL;
|
| 891 |
|
| 892 | ResetScopeStack ();
|
| 893 |
|
| 894 | OpCodeOffset = 0;
|
| 895 | while (OpCodeOffset < FormSet->IfrBinaryLength) {
|
| 896 | OpCodeData = FormSet->IfrBinaryData + OpCodeOffset;
|
| 897 |
|
| 898 | OpCodeLength = ((EFI_IFR_OP_HEADER *) OpCodeData)->Length;
|
| 899 | OpCodeOffset += OpCodeLength;
|
| 900 | Operand = ((EFI_IFR_OP_HEADER *) OpCodeData)->OpCode;
|
| 901 | Scope = ((EFI_IFR_OP_HEADER *) OpCodeData)->Scope;
|
| 902 |
|
| 903 | //
|
| 904 | // If scope bit set, push onto scope stack
|
| 905 | //
|
| 906 | if (Scope != 0) {
|
| 907 | PushScope (Operand);
|
| 908 | }
|
| 909 |
|
| 910 | if (OpCodeDisabled) {
|
| 911 | //
|
| 912 | // DisableIf Expression is evaluated to be TRUE, try to find its end.
|
| 913 | // Here only cares the EFI_IFR_DISABLE_IF and EFI_IFR_END
|
| 914 | //
|
| 915 | if (Operand == EFI_IFR_DISABLE_IF_OP) {
|
| 916 | DepthOfDisable++;
|
| 917 | } else if (Operand == EFI_IFR_END_OP) {
|
| 918 | Status = PopScope (&ScopeOpCode);
|
| 919 | if (EFI_ERROR (Status)) {
|
| 920 | return Status;
|
| 921 | }
|
| 922 |
|
| 923 | if (ScopeOpCode == EFI_IFR_DISABLE_IF_OP) {
|
| 924 | if (DepthOfDisable == 0) {
|
lgao4 | 0a1147e | 2009-04-22 03:18:37 +0000 | [diff] [blame] | 925 | mInScopeDisable = FALSE;
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 926 | OpCodeDisabled = FALSE;
|
| 927 | } else {
|
| 928 | DepthOfDisable--;
|
| 929 | }
|
| 930 | }
|
| 931 | }
|
| 932 | continue;
|
| 933 | }
|
| 934 |
|
| 935 | if (IsExpressionOpCode (Operand)) {
|
| 936 | ExpressionOpCode = &FormSet->ExpressionBuffer[mExpressionOpCodeIndex];
|
| 937 | mExpressionOpCodeIndex++;
|
| 938 |
|
| 939 | ExpressionOpCode->Signature = EXPRESSION_OPCODE_SIGNATURE;
|
| 940 | ExpressionOpCode->Operand = Operand;
|
| 941 | Value = &ExpressionOpCode->Value;
|
| 942 |
|
| 943 | switch (Operand) {
|
| 944 | case EFI_IFR_EQ_ID_VAL_OP:
|
| 945 | CopyMem (&ExpressionOpCode->QuestionId, &((EFI_IFR_EQ_ID_VAL *) OpCodeData)->QuestionId, sizeof (EFI_QUESTION_ID));
|
| 946 |
|
| 947 | Value->Type = EFI_IFR_TYPE_NUM_SIZE_16;
|
| 948 | CopyMem (&Value->Value.u16, &((EFI_IFR_EQ_ID_VAL *) OpCodeData)->Value, sizeof (UINT16));
|
| 949 | break;
|
| 950 |
|
| 951 | case EFI_IFR_EQ_ID_ID_OP:
|
| 952 | CopyMem (&ExpressionOpCode->QuestionId, &((EFI_IFR_EQ_ID_ID *) OpCodeData)->QuestionId1, sizeof (EFI_QUESTION_ID));
|
| 953 | CopyMem (&ExpressionOpCode->QuestionId2, &((EFI_IFR_EQ_ID_ID *) OpCodeData)->QuestionId2, sizeof (EFI_QUESTION_ID));
|
| 954 | break;
|
| 955 |
|
| 956 | case EFI_IFR_EQ_ID_LIST_OP:
|
qhuang8 | 2654f64 | 2009-09-21 14:15:35 +0000 | [diff] [blame] | 957 | CopyMem (&ExpressionOpCode->QuestionId, &((EFI_IFR_EQ_ID_VAL_LIST *) OpCodeData)->QuestionId, sizeof (EFI_QUESTION_ID));
|
| 958 | CopyMem (&ExpressionOpCode->ListLength, &((EFI_IFR_EQ_ID_VAL_LIST *) OpCodeData)->ListLength, sizeof (UINT16));
|
| 959 | ExpressionOpCode->ValueList = AllocateCopyPool (ExpressionOpCode->ListLength * sizeof (UINT16), &((EFI_IFR_EQ_ID_VAL_LIST *) OpCodeData)->ValueList);
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 960 | break;
|
| 961 |
|
| 962 | case EFI_IFR_TO_STRING_OP:
|
| 963 | case EFI_IFR_FIND_OP:
|
| 964 | ExpressionOpCode->Format = (( EFI_IFR_TO_STRING *) OpCodeData)->Format;
|
| 965 | break;
|
| 966 |
|
| 967 | case EFI_IFR_STRING_REF1_OP:
|
| 968 | Value->Type = EFI_IFR_TYPE_STRING;
|
| 969 | CopyMem (&Value->Value.string, &(( EFI_IFR_STRING_REF1 *) OpCodeData)->StringId, sizeof (EFI_STRING_ID));
|
| 970 | break;
|
| 971 |
|
| 972 | case EFI_IFR_RULE_REF_OP:
|
| 973 | ExpressionOpCode->RuleId = (( EFI_IFR_RULE_REF *) OpCodeData)->RuleId;
|
| 974 | break;
|
| 975 |
|
| 976 | case EFI_IFR_SPAN_OP:
|
| 977 | ExpressionOpCode->Flags = (( EFI_IFR_SPAN *) OpCodeData)->Flags;
|
| 978 | break;
|
| 979 |
|
| 980 | case EFI_IFR_THIS_OP:
|
qwang12 | d0720b5 | 2009-01-20 01:55:11 +0000 | [diff] [blame] | 981 | ASSERT (CurrentStatement != NULL);
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 982 | ExpressionOpCode->QuestionId = CurrentStatement->QuestionId;
|
| 983 | break;
|
| 984 |
|
rsun3 | cbf73e5 | 2009-11-26 09:26:42 +0000 | [diff] [blame^] | 985 | case EFI_IFR_SECURITY_OP:
|
| 986 | CopyMem (&ExpressionOpCode->Guid, &((EFI_IFR_SECURITY *) OpCodeData)->Permissions, sizeof (EFI_GUID));
|
| 987 | break;
|
| 988 |
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 989 | case EFI_IFR_QUESTION_REF1_OP:
|
qhuang8 | 2654f64 | 2009-09-21 14:15:35 +0000 | [diff] [blame] | 990 | CopyMem (&ExpressionOpCode->QuestionId, &((EFI_IFR_EQ_ID_VAL_LIST *) OpCodeData)->QuestionId, sizeof (EFI_QUESTION_ID));
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 991 | break;
|
| 992 |
|
| 993 | case EFI_IFR_QUESTION_REF3_OP:
|
| 994 | if (OpCodeLength >= sizeof (EFI_IFR_QUESTION_REF3_2)) {
|
| 995 | CopyMem (&ExpressionOpCode->DevicePath, &(( EFI_IFR_QUESTION_REF3_2 *) OpCodeData)->DevicePath, sizeof (EFI_STRING_ID));
|
| 996 |
|
| 997 | if (OpCodeLength >= sizeof (EFI_IFR_QUESTION_REF3_3)) {
|
| 998 | CopyMem (&ExpressionOpCode->Guid, &(( EFI_IFR_QUESTION_REF3_3 *) OpCodeData)->Guid, sizeof (EFI_GUID));
|
| 999 | }
|
| 1000 | }
|
| 1001 | break;
|
| 1002 |
|
| 1003 | //
|
| 1004 | // constant
|
| 1005 | //
|
| 1006 | case EFI_IFR_TRUE_OP:
|
| 1007 | Value->Type = EFI_IFR_TYPE_BOOLEAN;
|
| 1008 | Value->Value.b = TRUE;
|
| 1009 | break;
|
| 1010 |
|
| 1011 | case EFI_IFR_FALSE_OP:
|
| 1012 | Value->Type = EFI_IFR_TYPE_BOOLEAN;
|
| 1013 | Value->Value.b = FALSE;
|
| 1014 | break;
|
| 1015 |
|
| 1016 | case EFI_IFR_ONE_OP:
|
| 1017 | Value->Type = EFI_IFR_TYPE_NUM_SIZE_8;
|
| 1018 | Value->Value.u8 = 1;
|
| 1019 | break;
|
| 1020 |
|
| 1021 | case EFI_IFR_ZERO_OP:
|
| 1022 | Value->Type = EFI_IFR_TYPE_NUM_SIZE_8;
|
| 1023 | Value->Value.u8 = 0;
|
| 1024 | break;
|
| 1025 |
|
| 1026 | case EFI_IFR_ONES_OP:
|
| 1027 | Value->Type = EFI_IFR_TYPE_NUM_SIZE_64;
|
| 1028 | Value->Value.u64 = 0xffffffffffffffffULL;
|
| 1029 | break;
|
| 1030 |
|
| 1031 | case EFI_IFR_UINT8_OP:
|
| 1032 | Value->Type = EFI_IFR_TYPE_NUM_SIZE_8;
|
| 1033 | Value->Value.u8 = (( EFI_IFR_UINT8 *) OpCodeData)->Value;
|
| 1034 | break;
|
| 1035 |
|
| 1036 | case EFI_IFR_UINT16_OP:
|
| 1037 | Value->Type = EFI_IFR_TYPE_NUM_SIZE_16;
|
| 1038 | CopyMem (&Value->Value.u16, &(( EFI_IFR_UINT16 *) OpCodeData)->Value, sizeof (UINT16));
|
| 1039 | break;
|
| 1040 |
|
| 1041 | case EFI_IFR_UINT32_OP:
|
| 1042 | Value->Type = EFI_IFR_TYPE_NUM_SIZE_32;
|
| 1043 | CopyMem (&Value->Value.u32, &(( EFI_IFR_UINT32 *) OpCodeData)->Value, sizeof (UINT32));
|
| 1044 | break;
|
| 1045 |
|
| 1046 | case EFI_IFR_UINT64_OP:
|
| 1047 | Value->Type = EFI_IFR_TYPE_NUM_SIZE_64;
|
| 1048 | CopyMem (&Value->Value.u64, &(( EFI_IFR_UINT64 *) OpCodeData)->Value, sizeof (UINT64));
|
| 1049 | break;
|
| 1050 |
|
| 1051 | case EFI_IFR_UNDEFINED_OP:
|
xdu2 | d02847d | 2009-10-26 03:03:47 +0000 | [diff] [blame] | 1052 | Value->Type = EFI_IFR_TYPE_UNDEFINED;
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1053 | break;
|
| 1054 |
|
| 1055 | case EFI_IFR_VERSION_OP:
|
| 1056 | Value->Type = EFI_IFR_TYPE_NUM_SIZE_16;
|
| 1057 | Value->Value.u16 = EFI_IFR_SPECIFICATION_VERSION;
|
| 1058 | break;
|
| 1059 |
|
| 1060 | default:
|
| 1061 | break;
|
| 1062 | }
|
| 1063 |
|
xdu2 | f8a1c22 | 2009-10-20 03:01:10 +0000 | [diff] [blame] | 1064 | ASSERT (CurrentExpression != NULL);
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1065 | InsertTailList (&CurrentExpression->OpCodeListHead, &ExpressionOpCode->Link);
|
| 1066 |
|
| 1067 | if (SingleOpCodeExpression) {
|
| 1068 | //
|
| 1069 | // There are two cases to indicate the end of an Expression:
|
| 1070 | // for single OpCode expression: one Expression OpCode
|
| 1071 | // for expression consists of more than one OpCode: EFI_IFR_END
|
| 1072 | //
|
| 1073 | SingleOpCodeExpression = FALSE;
|
| 1074 |
|
lgao4 | 0a1147e | 2009-04-22 03:18:37 +0000 | [diff] [blame] | 1075 | if (mInScopeDisable && CurrentForm == NULL) {
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1076 | //
|
lgao4 | 0a1147e | 2009-04-22 03:18:37 +0000 | [diff] [blame] | 1077 | // This is DisableIf expression for Form, it should be a constant expression
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1078 | //
|
| 1079 | Status = EvaluateExpression (FormSet, CurrentForm, CurrentExpression);
|
| 1080 | if (EFI_ERROR (Status)) {
|
| 1081 | return Status;
|
| 1082 | }
|
qwang12 | c410589 | 2009-02-06 06:34:43 +0000 | [diff] [blame] | 1083 |
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1084 | if (CurrentExpression->Result.Type != EFI_IFR_TYPE_BOOLEAN) {
|
| 1085 | return EFI_INVALID_PARAMETER;
|
| 1086 | }
|
| 1087 |
|
| 1088 | OpCodeDisabled = CurrentExpression->Result.Value.b;
|
| 1089 | }
|
| 1090 |
|
| 1091 | CurrentExpression = NULL;
|
| 1092 | }
|
| 1093 |
|
| 1094 | continue;
|
| 1095 | }
|
| 1096 |
|
| 1097 | //
|
| 1098 | // Parse the Opcode
|
| 1099 | //
|
| 1100 | switch (Operand) {
|
| 1101 |
|
| 1102 | case EFI_IFR_FORM_SET_OP:
|
| 1103 | //
|
xdu2 | f8a1c22 | 2009-10-20 03:01:10 +0000 | [diff] [blame] | 1104 | // Check the formset GUID
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1105 | //
|
| 1106 | if (CompareMem (&FormSet->Guid, &((EFI_IFR_FORM_SET *) OpCodeData)->Guid, sizeof (EFI_GUID)) != 0) {
|
| 1107 | return EFI_INVALID_PARAMETER;
|
| 1108 | }
|
| 1109 |
|
| 1110 | CopyMem (&FormSet->FormSetTitle, &((EFI_IFR_FORM_SET *) OpCodeData)->FormSetTitle, sizeof (EFI_STRING_ID));
|
| 1111 | CopyMem (&FormSet->Help, &((EFI_IFR_FORM_SET *) OpCodeData)->Help, sizeof (EFI_STRING_ID));
|
lgao4 | 0a1147e | 2009-04-22 03:18:37 +0000 | [diff] [blame] | 1112 |
|
| 1113 | //
|
| 1114 | // The formset OpCode contains ClassGuid
|
| 1115 | //
|
lgao4 | 7da7367 | 2009-04-23 07:30:09 +0000 | [diff] [blame] | 1116 | FormSet->NumberOfClassGuid = (UINT8) (((EFI_IFR_FORM_SET *) OpCodeData)->Flags & 0x3);
|
lgao4 | 0a1147e | 2009-04-22 03:18:37 +0000 | [diff] [blame] | 1117 | CopyMem (FormSet->ClassGuid, OpCodeData + sizeof (EFI_IFR_FORM_SET), FormSet->NumberOfClassGuid * sizeof (EFI_GUID));
|
lgao4 | 0c66bc7 | 2009-11-12 01:16:12 +0000 | [diff] [blame] | 1118 |
|
| 1119 | InitializeListHead (&FormSet->ExpressionListHead);
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1120 | break;
|
| 1121 |
|
| 1122 | case EFI_IFR_FORM_OP:
|
| 1123 | //
|
| 1124 | // Create a new Form for this FormSet
|
| 1125 | //
|
| 1126 | CurrentForm = AllocateZeroPool (sizeof (FORM_BROWSER_FORM));
|
jji4 | 1ac628e | 2009-01-19 07:58:58 +0000 | [diff] [blame] | 1127 | ASSERT (CurrentForm != NULL);
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1128 | CurrentForm->Signature = FORM_BROWSER_FORM_SIGNATURE;
|
| 1129 | InitializeListHead (&CurrentForm->ExpressionListHead);
|
| 1130 | InitializeListHead (&CurrentForm->StatementListHead);
|
| 1131 |
|
| 1132 | CopyMem (&CurrentForm->FormId, &((EFI_IFR_FORM *) OpCodeData)->FormId, sizeof (UINT16));
|
| 1133 | CopyMem (&CurrentForm->FormTitle, &((EFI_IFR_FORM *) OpCodeData)->FormTitle, sizeof (EFI_STRING_ID));
|
| 1134 |
|
lgao4 | 0c66bc7 | 2009-11-12 01:16:12 +0000 | [diff] [blame] | 1135 | if (InScopeFormSuppress) {
|
| 1136 | //
|
| 1137 | // Form is inside of suppressif
|
| 1138 | //
|
| 1139 | CurrentForm->SuppressExpression = FormSuppressExpression;
|
| 1140 | }
|
| 1141 |
|
| 1142 | if (Scope != 0) {
|
| 1143 | //
|
| 1144 | // Enter scope of a Form, suppressif will be used for Question or Option
|
| 1145 | //
|
| 1146 | SuppressForQuestion = TRUE;
|
| 1147 | }
|
| 1148 |
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1149 | //
|
| 1150 | // Insert into Form list of this FormSet
|
| 1151 | //
|
| 1152 | InsertTailList (&FormSet->FormListHead, &CurrentForm->Link);
|
| 1153 | break;
|
| 1154 |
|
| 1155 | //
|
| 1156 | // Storage
|
| 1157 | //
|
| 1158 | case EFI_IFR_VARSTORE_OP:
|
| 1159 | //
|
| 1160 | // Create a buffer Storage for this FormSet
|
| 1161 | //
|
| 1162 | Storage = CreateStorage (FormSet);
|
| 1163 | Storage->Type = EFI_HII_VARSTORE_BUFFER;
|
| 1164 |
|
| 1165 | CopyMem (&Storage->VarStoreId, &((EFI_IFR_VARSTORE *) OpCodeData)->VarStoreId, sizeof (EFI_VARSTORE_ID));
|
| 1166 | CopyMem (&Storage->Guid, &((EFI_IFR_VARSTORE *) OpCodeData)->Guid, sizeof (EFI_GUID));
|
| 1167 | CopyMem (&Storage->Size, &((EFI_IFR_VARSTORE *) OpCodeData)->Size, sizeof (UINT16));
|
| 1168 |
|
| 1169 | Storage->Buffer = AllocateZeroPool (Storage->Size);
|
| 1170 | Storage->EditBuffer = AllocateZeroPool (Storage->Size);
|
| 1171 |
|
| 1172 | AsciiString = (CHAR8 *) ((EFI_IFR_VARSTORE *) OpCodeData)->Name;
|
| 1173 | Storage->Name = AllocateZeroPool (AsciiStrSize (AsciiString) * 2);
|
| 1174 | ASSERT (Storage->Name != NULL);
|
| 1175 | for (Index = 0; AsciiString[Index] != 0; Index++) {
|
| 1176 | Storage->Name[Index] = (CHAR16) AsciiString[Index];
|
| 1177 | }
|
| 1178 |
|
| 1179 | //
|
| 1180 | // Initialize <ConfigHdr>
|
| 1181 | //
|
| 1182 | InitializeConfigHdr (FormSet, Storage);
|
| 1183 | break;
|
| 1184 |
|
| 1185 | case EFI_IFR_VARSTORE_NAME_VALUE_OP:
|
| 1186 | //
|
| 1187 | // Create a name/value Storage for this FormSet
|
| 1188 | //
|
| 1189 | Storage = CreateStorage (FormSet);
|
| 1190 | Storage->Type = EFI_HII_VARSTORE_NAME_VALUE;
|
| 1191 |
|
| 1192 | CopyMem (&Storage->VarStoreId, &((EFI_IFR_VARSTORE_NAME_VALUE *) OpCodeData)->VarStoreId, sizeof (EFI_VARSTORE_ID));
|
| 1193 | CopyMem (&Storage->Guid, &((EFI_IFR_VARSTORE_NAME_VALUE *) OpCodeData)->Guid, sizeof (EFI_GUID));
|
| 1194 |
|
| 1195 | //
|
| 1196 | // Initialize <ConfigHdr>
|
| 1197 | //
|
| 1198 | InitializeConfigHdr (FormSet, Storage);
|
| 1199 | break;
|
| 1200 |
|
| 1201 | case EFI_IFR_VARSTORE_EFI_OP:
|
| 1202 | //
|
| 1203 | // Create a EFI variable Storage for this FormSet
|
| 1204 | //
|
| 1205 | Storage = CreateStorage (FormSet);
|
| 1206 | Storage->Type = EFI_HII_VARSTORE_EFI_VARIABLE;
|
| 1207 |
|
| 1208 | CopyMem (&Storage->VarStoreId, &((EFI_IFR_VARSTORE_EFI *) OpCodeData)->VarStoreId, sizeof (EFI_VARSTORE_ID));
|
| 1209 | CopyMem (&Storage->Guid, &((EFI_IFR_VARSTORE_EFI *) OpCodeData)->Guid, sizeof (EFI_GUID));
|
| 1210 | CopyMem (&Storage->Attributes, &((EFI_IFR_VARSTORE_EFI *) OpCodeData)->Attributes, sizeof (UINT32));
|
| 1211 | break;
|
| 1212 |
|
| 1213 | //
|
| 1214 | // DefaultStore
|
| 1215 | //
|
| 1216 | case EFI_IFR_DEFAULTSTORE_OP:
|
| 1217 | DefaultStore = AllocateZeroPool (sizeof (FORMSET_DEFAULTSTORE));
|
jji4 | 1ac628e | 2009-01-19 07:58:58 +0000 | [diff] [blame] | 1218 | ASSERT (DefaultStore != NULL);
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1219 | DefaultStore->Signature = FORMSET_DEFAULTSTORE_SIGNATURE;
|
| 1220 |
|
| 1221 | CopyMem (&DefaultStore->DefaultId, &((EFI_IFR_DEFAULTSTORE *) OpCodeData)->DefaultId, sizeof (UINT16));
|
| 1222 | CopyMem (&DefaultStore->DefaultName, &((EFI_IFR_DEFAULTSTORE *) OpCodeData)->DefaultName, sizeof (EFI_STRING_ID));
|
| 1223 |
|
| 1224 | //
|
| 1225 | // Insert to DefaultStore list of this Formset
|
| 1226 | //
|
| 1227 | InsertTailList (&FormSet->DefaultStoreListHead, &DefaultStore->Link);
|
| 1228 | break;
|
| 1229 |
|
| 1230 | //
|
| 1231 | // Statements
|
| 1232 | //
|
| 1233 | case EFI_IFR_SUBTITLE_OP:
|
| 1234 | CurrentStatement = CreateStatement (OpCodeData, FormSet, CurrentForm);
|
qwang12 | bc166db | 2009-02-02 07:18:59 +0000 | [diff] [blame] | 1235 | ASSERT (CurrentStatement != NULL);
|
xdu2 | 8b0fc5c | 2009-10-26 03:05:16 +0000 | [diff] [blame] | 1236 |
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1237 | CurrentStatement->Flags = ((EFI_IFR_SUBTITLE *) OpCodeData)->Flags;
|
| 1238 |
|
| 1239 | if (Scope != 0) {
|
| 1240 | mInScopeSubtitle = TRUE;
|
| 1241 | }
|
| 1242 | break;
|
| 1243 |
|
| 1244 | case EFI_IFR_TEXT_OP:
|
| 1245 | CurrentStatement = CreateStatement (OpCodeData, FormSet, CurrentForm);
|
qwang12 | bc166db | 2009-02-02 07:18:59 +0000 | [diff] [blame] | 1246 | ASSERT (CurrentStatement != NULL);
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1247 |
|
| 1248 | CopyMem (&CurrentStatement->TextTwo, &((EFI_IFR_TEXT *) OpCodeData)->TextTwo, sizeof (EFI_STRING_ID));
|
| 1249 | break;
|
| 1250 |
|
xdu2 | f8a1c22 | 2009-10-20 03:01:10 +0000 | [diff] [blame] | 1251 | case EFI_IFR_RESET_BUTTON_OP:
|
| 1252 | CurrentStatement = CreateStatement (OpCodeData, FormSet, CurrentForm);
|
| 1253 | ASSERT (CurrentStatement != NULL);
|
| 1254 | CopyMem (&CurrentStatement->DefaultId, &((EFI_IFR_RESET_BUTTON *) OpCodeData)->DefaultId, sizeof (EFI_DEFAULT_ID));
|
| 1255 | break;
|
| 1256 |
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1257 | //
|
| 1258 | // Questions
|
| 1259 | //
|
| 1260 | case EFI_IFR_ACTION_OP:
|
| 1261 | CurrentStatement = CreateQuestion (OpCodeData, FormSet, CurrentForm);
|
qwang12 | bc166db | 2009-02-02 07:18:59 +0000 | [diff] [blame] | 1262 | ASSERT (CurrentStatement != NULL);
|
xdu2 | d02847d | 2009-10-26 03:03:47 +0000 | [diff] [blame] | 1263 | CurrentStatement->HiiValue.Type = EFI_IFR_TYPE_ACTION;
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1264 |
|
| 1265 | if (OpCodeLength == sizeof (EFI_IFR_ACTION_1)) {
|
| 1266 | //
|
| 1267 | // No QuestionConfig present, so no configuration string will be processed
|
| 1268 | //
|
| 1269 | CurrentStatement->QuestionConfig = 0;
|
| 1270 | } else {
|
| 1271 | CopyMem (&CurrentStatement->QuestionConfig, &((EFI_IFR_ACTION *) OpCodeData)->QuestionConfig, sizeof (EFI_STRING_ID));
|
| 1272 | }
|
| 1273 | break;
|
| 1274 |
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1275 | case EFI_IFR_REF_OP:
|
| 1276 | CurrentStatement = CreateQuestion (OpCodeData, FormSet, CurrentForm);
|
gikidy | b347c1b | 2009-05-15 03:39:01 +0000 | [diff] [blame] | 1277 | ASSERT (CurrentStatement != NULL);
|
xdu2 | d02847d | 2009-10-26 03:03:47 +0000 | [diff] [blame] | 1278 | CurrentStatement->HiiValue.Type = EFI_IFR_TYPE_UNDEFINED;
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1279 | CopyMem (&CurrentStatement->RefFormId, &((EFI_IFR_REF *) OpCodeData)->FormId, sizeof (EFI_FORM_ID));
|
| 1280 | if (OpCodeLength >= sizeof (EFI_IFR_REF2)) {
|
| 1281 | CopyMem (&CurrentStatement->RefQuestionId, &((EFI_IFR_REF2 *) OpCodeData)->QuestionId, sizeof (EFI_QUESTION_ID));
|
| 1282 |
|
| 1283 | if (OpCodeLength >= sizeof (EFI_IFR_REF3)) {
|
| 1284 | CopyMem (&CurrentStatement->RefFormSetId, &((EFI_IFR_REF3 *) OpCodeData)->FormSetId, sizeof (EFI_GUID));
|
| 1285 |
|
| 1286 | if (OpCodeLength >= sizeof (EFI_IFR_REF4)) {
|
| 1287 | CopyMem (&CurrentStatement->RefDevicePath, &((EFI_IFR_REF4 *) OpCodeData)->DevicePath, sizeof (EFI_STRING_ID));
|
| 1288 | }
|
| 1289 | }
|
| 1290 | }
|
| 1291 | break;
|
| 1292 |
|
| 1293 | case EFI_IFR_ONE_OF_OP:
|
| 1294 | case EFI_IFR_NUMERIC_OP:
|
| 1295 | CurrentStatement = CreateQuestion (OpCodeData, FormSet, CurrentForm);
|
gikidy | 945e3ae | 2009-05-13 09:24:25 +0000 | [diff] [blame] | 1296 | ASSERT(CurrentStatement != NULL);
|
xdu2 | 8b0fc5c | 2009-10-26 03:05:16 +0000 | [diff] [blame] | 1297 |
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1298 | CurrentStatement->Flags = ((EFI_IFR_ONE_OF *) OpCodeData)->Flags;
|
| 1299 | Value = &CurrentStatement->HiiValue;
|
| 1300 |
|
| 1301 | switch (CurrentStatement->Flags & EFI_IFR_NUMERIC_SIZE) {
|
| 1302 | case EFI_IFR_NUMERIC_SIZE_1:
|
| 1303 | CurrentStatement->Minimum = ((EFI_IFR_NUMERIC *) OpCodeData)->data.u8.MinValue;
|
| 1304 | CurrentStatement->Maximum = ((EFI_IFR_NUMERIC *) OpCodeData)->data.u8.MaxValue;
|
| 1305 | CurrentStatement->Step = ((EFI_IFR_NUMERIC *) OpCodeData)->data.u8.Step;
|
| 1306 | CurrentStatement->StorageWidth = sizeof (UINT8);
|
| 1307 | Value->Type = EFI_IFR_TYPE_NUM_SIZE_8;
|
| 1308 | break;
|
| 1309 |
|
| 1310 | case EFI_IFR_NUMERIC_SIZE_2:
|
| 1311 | CopyMem (&CurrentStatement->Minimum, &((EFI_IFR_NUMERIC *) OpCodeData)->data.u16.MinValue, sizeof (UINT16));
|
| 1312 | CopyMem (&CurrentStatement->Maximum, &((EFI_IFR_NUMERIC *) OpCodeData)->data.u16.MaxValue, sizeof (UINT16));
|
| 1313 | CopyMem (&CurrentStatement->Step, &((EFI_IFR_NUMERIC *) OpCodeData)->data.u16.Step, sizeof (UINT16));
|
| 1314 | CurrentStatement->StorageWidth = sizeof (UINT16);
|
| 1315 | Value->Type = EFI_IFR_TYPE_NUM_SIZE_16;
|
| 1316 | break;
|
| 1317 |
|
| 1318 | case EFI_IFR_NUMERIC_SIZE_4:
|
| 1319 | CopyMem (&CurrentStatement->Minimum, &((EFI_IFR_NUMERIC *) OpCodeData)->data.u32.MinValue, sizeof (UINT32));
|
| 1320 | CopyMem (&CurrentStatement->Maximum, &((EFI_IFR_NUMERIC *) OpCodeData)->data.u32.MaxValue, sizeof (UINT32));
|
| 1321 | CopyMem (&CurrentStatement->Step, &((EFI_IFR_NUMERIC *) OpCodeData)->data.u32.Step, sizeof (UINT32));
|
| 1322 | CurrentStatement->StorageWidth = sizeof (UINT32);
|
| 1323 | Value->Type = EFI_IFR_TYPE_NUM_SIZE_32;
|
| 1324 | break;
|
| 1325 |
|
| 1326 | case EFI_IFR_NUMERIC_SIZE_8:
|
| 1327 | CopyMem (&CurrentStatement->Minimum, &((EFI_IFR_NUMERIC *) OpCodeData)->data.u64.MinValue, sizeof (UINT64));
|
| 1328 | CopyMem (&CurrentStatement->Maximum, &((EFI_IFR_NUMERIC *) OpCodeData)->data.u64.MaxValue, sizeof (UINT64));
|
| 1329 | CopyMem (&CurrentStatement->Step, &((EFI_IFR_NUMERIC *) OpCodeData)->data.u64.Step, sizeof (UINT64));
|
| 1330 | CurrentStatement->StorageWidth = sizeof (UINT64);
|
| 1331 | Value->Type = EFI_IFR_TYPE_NUM_SIZE_64;
|
| 1332 | break;
|
| 1333 |
|
| 1334 | default:
|
| 1335 | break;
|
| 1336 | }
|
| 1337 |
|
| 1338 | InitializeRequestElement (FormSet, CurrentStatement);
|
| 1339 |
|
| 1340 | if ((Operand == EFI_IFR_ONE_OF_OP) && Scope != 0) {
|
| 1341 | SuppressForOption = TRUE;
|
| 1342 | }
|
| 1343 | break;
|
| 1344 |
|
| 1345 | case EFI_IFR_ORDERED_LIST_OP:
|
| 1346 | CurrentStatement = CreateQuestion (OpCodeData, FormSet, CurrentForm);
|
gikidy | b347c1b | 2009-05-15 03:39:01 +0000 | [diff] [blame] | 1347 | ASSERT(CurrentStatement != NULL);
|
xdu2 | 8b0fc5c | 2009-10-26 03:05:16 +0000 | [diff] [blame] | 1348 |
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1349 | CurrentStatement->Flags = ((EFI_IFR_ORDERED_LIST *) OpCodeData)->Flags;
|
| 1350 | CurrentStatement->MaxContainers = ((EFI_IFR_ORDERED_LIST *) OpCodeData)->MaxContainers;
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1351 |
|
xdu2 | d02847d | 2009-10-26 03:03:47 +0000 | [diff] [blame] | 1352 | CurrentStatement->HiiValue.Type = EFI_IFR_TYPE_BUFFER;
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1353 |
|
| 1354 | if (Scope != 0) {
|
| 1355 | SuppressForOption = TRUE;
|
| 1356 | }
|
| 1357 | break;
|
| 1358 |
|
| 1359 | case EFI_IFR_CHECKBOX_OP:
|
| 1360 | CurrentStatement = CreateQuestion (OpCodeData, FormSet, CurrentForm);
|
gikidy | b347c1b | 2009-05-15 03:39:01 +0000 | [diff] [blame] | 1361 | ASSERT(CurrentStatement != NULL);
|
xdu2 | 8b0fc5c | 2009-10-26 03:05:16 +0000 | [diff] [blame] | 1362 |
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1363 | CurrentStatement->Flags = ((EFI_IFR_CHECKBOX *) OpCodeData)->Flags;
|
| 1364 | CurrentStatement->StorageWidth = sizeof (BOOLEAN);
|
| 1365 | CurrentStatement->HiiValue.Type = EFI_IFR_TYPE_BOOLEAN;
|
| 1366 |
|
| 1367 | InitializeRequestElement (FormSet, CurrentStatement);
|
| 1368 |
|
| 1369 | break;
|
| 1370 |
|
| 1371 | case EFI_IFR_STRING_OP:
|
| 1372 | CurrentStatement = CreateQuestion (OpCodeData, FormSet, CurrentForm);
|
gikidy | b347c1b | 2009-05-15 03:39:01 +0000 | [diff] [blame] | 1373 | ASSERT (CurrentStatement != NULL);
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1374 | //
|
| 1375 | // MinSize is the minimum number of characters that can be accepted for this opcode,
|
| 1376 | // MaxSize is the maximum number of characters that can be accepted for this opcode.
|
| 1377 | // The characters are stored as Unicode, so the storage width should multiply 2.
|
| 1378 | //
|
| 1379 | CurrentStatement->Minimum = ((EFI_IFR_STRING *) OpCodeData)->MinSize;
|
| 1380 | CurrentStatement->Maximum = ((EFI_IFR_STRING *) OpCodeData)->MaxSize;
|
| 1381 | CurrentStatement->StorageWidth = (UINT16)((UINTN) CurrentStatement->Maximum * sizeof (CHAR16));
|
| 1382 | CurrentStatement->Flags = ((EFI_IFR_STRING *) OpCodeData)->Flags;
|
| 1383 |
|
| 1384 | CurrentStatement->HiiValue.Type = EFI_IFR_TYPE_STRING;
|
| 1385 | CurrentStatement->BufferValue = AllocateZeroPool (CurrentStatement->StorageWidth + sizeof (CHAR16));
|
| 1386 |
|
| 1387 | InitializeRequestElement (FormSet, CurrentStatement);
|
| 1388 | break;
|
| 1389 |
|
| 1390 | case EFI_IFR_PASSWORD_OP:
|
| 1391 | CurrentStatement = CreateQuestion (OpCodeData, FormSet, CurrentForm);
|
gikidy | b347c1b | 2009-05-15 03:39:01 +0000 | [diff] [blame] | 1392 | ASSERT (CurrentStatement != NULL);
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1393 | //
|
| 1394 | // MinSize is the minimum number of characters that can be accepted for this opcode,
|
| 1395 | // MaxSize is the maximum number of characters that can be accepted for this opcode.
|
| 1396 | // The characters are stored as Unicode, so the storage width should multiply 2.
|
| 1397 | //
|
| 1398 | CopyMem (&CurrentStatement->Minimum, &((EFI_IFR_PASSWORD *) OpCodeData)->MinSize, sizeof (UINT16));
|
| 1399 | CopyMem (&CurrentStatement->Maximum, &((EFI_IFR_PASSWORD *) OpCodeData)->MaxSize, sizeof (UINT16));
|
| 1400 | CurrentStatement->StorageWidth = (UINT16)((UINTN) CurrentStatement->Maximum * sizeof (CHAR16));
|
| 1401 |
|
| 1402 | CurrentStatement->HiiValue.Type = EFI_IFR_TYPE_STRING;
|
| 1403 | CurrentStatement->BufferValue = AllocateZeroPool ((CurrentStatement->StorageWidth + sizeof (CHAR16)));
|
| 1404 |
|
| 1405 | InitializeRequestElement (FormSet, CurrentStatement);
|
| 1406 | break;
|
| 1407 |
|
| 1408 | case EFI_IFR_DATE_OP:
|
| 1409 | CurrentStatement = CreateQuestion (OpCodeData, FormSet, CurrentForm);
|
gikidy | b347c1b | 2009-05-15 03:39:01 +0000 | [diff] [blame] | 1410 | ASSERT(CurrentStatement != NULL);
|
xdu2 | 8b0fc5c | 2009-10-26 03:05:16 +0000 | [diff] [blame] | 1411 |
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1412 | CurrentStatement->Flags = ((EFI_IFR_DATE *) OpCodeData)->Flags;
|
| 1413 | CurrentStatement->HiiValue.Type = EFI_IFR_TYPE_DATE;
|
| 1414 |
|
| 1415 | if ((CurrentStatement->Flags & EFI_QF_DATE_STORAGE) == QF_DATE_STORAGE_NORMAL) {
|
| 1416 | CurrentStatement->StorageWidth = sizeof (EFI_HII_DATE);
|
| 1417 |
|
| 1418 | InitializeRequestElement (FormSet, CurrentStatement);
|
| 1419 | } else {
|
| 1420 | //
|
| 1421 | // Don't assign storage for RTC type of date/time
|
| 1422 | //
|
| 1423 | CurrentStatement->Storage = NULL;
|
| 1424 | CurrentStatement->StorageWidth = 0;
|
| 1425 | }
|
| 1426 | break;
|
| 1427 |
|
| 1428 | case EFI_IFR_TIME_OP:
|
| 1429 | CurrentStatement = CreateQuestion (OpCodeData, FormSet, CurrentForm);
|
gikidy | b347c1b | 2009-05-15 03:39:01 +0000 | [diff] [blame] | 1430 | ASSERT(CurrentStatement != NULL);
|
xdu2 | 8b0fc5c | 2009-10-26 03:05:16 +0000 | [diff] [blame] | 1431 |
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1432 | CurrentStatement->Flags = ((EFI_IFR_TIME *) OpCodeData)->Flags;
|
| 1433 | CurrentStatement->HiiValue.Type = EFI_IFR_TYPE_TIME;
|
| 1434 |
|
| 1435 | if ((CurrentStatement->Flags & QF_TIME_STORAGE) == QF_TIME_STORAGE_NORMAL) {
|
| 1436 | CurrentStatement->StorageWidth = sizeof (EFI_IFR_TIME);
|
| 1437 |
|
| 1438 | InitializeRequestElement (FormSet, CurrentStatement);
|
| 1439 | } else {
|
| 1440 | //
|
| 1441 | // Don't assign storage for RTC type of date/time
|
| 1442 | //
|
| 1443 | CurrentStatement->Storage = NULL;
|
| 1444 | CurrentStatement->StorageWidth = 0;
|
| 1445 | }
|
| 1446 | break;
|
| 1447 |
|
| 1448 | //
|
| 1449 | // Default
|
| 1450 | //
|
| 1451 | case EFI_IFR_DEFAULT_OP:
|
| 1452 | //
|
| 1453 | // EFI_IFR_DEFAULT appear in scope of a Question,
|
| 1454 | // It creates a default value for the current question.
|
| 1455 | // A Question may have more than one Default value which have different default types.
|
| 1456 | //
|
| 1457 | CurrentDefault = AllocateZeroPool (sizeof (QUESTION_DEFAULT));
|
jji4 | 1ac628e | 2009-01-19 07:58:58 +0000 | [diff] [blame] | 1458 | ASSERT (CurrentDefault != NULL);
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1459 | CurrentDefault->Signature = QUESTION_DEFAULT_SIGNATURE;
|
| 1460 |
|
| 1461 | CurrentDefault->Value.Type = ((EFI_IFR_DEFAULT *) OpCodeData)->Type;
|
| 1462 | CopyMem (&CurrentDefault->DefaultId, &((EFI_IFR_DEFAULT *) OpCodeData)->DefaultId, sizeof (UINT16));
|
| 1463 | CopyMem (&CurrentDefault->Value.Value, &((EFI_IFR_DEFAULT *) OpCodeData)->Value, sizeof (EFI_IFR_TYPE_VALUE));
|
| 1464 | ExtendValueToU64 (&CurrentDefault->Value);
|
| 1465 |
|
| 1466 | //
|
| 1467 | // Insert to Default Value list of current Question
|
| 1468 | //
|
| 1469 | InsertTailList (&CurrentStatement->DefaultListHead, &CurrentDefault->Link);
|
| 1470 |
|
| 1471 | if (Scope != 0) {
|
| 1472 | InScopeDefault = TRUE;
|
| 1473 | }
|
| 1474 | break;
|
| 1475 |
|
| 1476 | //
|
| 1477 | // Option
|
| 1478 | //
|
| 1479 | case EFI_IFR_ONE_OF_OPTION_OP:
|
| 1480 | //
|
| 1481 | // EFI_IFR_ONE_OF_OPTION appear in scope of a Question.
|
| 1482 | // It create a selection for use in current Question.
|
| 1483 | //
|
| 1484 | CurrentOption = AllocateZeroPool (sizeof (QUESTION_OPTION));
|
jji4 | 1ac628e | 2009-01-19 07:58:58 +0000 | [diff] [blame] | 1485 | ASSERT (CurrentOption != NULL);
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1486 | CurrentOption->Signature = QUESTION_OPTION_SIGNATURE;
|
| 1487 |
|
| 1488 | CurrentOption->Flags = ((EFI_IFR_ONE_OF_OPTION *) OpCodeData)->Flags;
|
| 1489 | CurrentOption->Value.Type = ((EFI_IFR_ONE_OF_OPTION *) OpCodeData)->Type;
|
| 1490 | CopyMem (&CurrentOption->Text, &((EFI_IFR_ONE_OF_OPTION *) OpCodeData)->Option, sizeof (EFI_STRING_ID));
|
| 1491 | CopyMem (&CurrentOption->Value.Value, &((EFI_IFR_ONE_OF_OPTION *) OpCodeData)->Value, sizeof (EFI_IFR_TYPE_VALUE));
|
| 1492 | ExtendValueToU64 (&CurrentOption->Value);
|
| 1493 |
|
| 1494 | if (InScopeOptionSuppress) {
|
| 1495 | CurrentOption->SuppressExpression = OptionSuppressExpression;
|
| 1496 | }
|
| 1497 |
|
| 1498 | //
|
| 1499 | // Insert to Option list of current Question
|
| 1500 | //
|
| 1501 | InsertTailList (&CurrentStatement->OptionListHead, &CurrentOption->Link);
|
xdu2 | d02847d | 2009-10-26 03:03:47 +0000 | [diff] [blame] | 1502 |
|
| 1503 | //
|
| 1504 | // Now we know the Storage width of nested Ordered List
|
| 1505 | //
|
| 1506 | if ((CurrentStatement->Operand == EFI_IFR_ORDERED_LIST_OP) && (CurrentStatement->BufferValue == NULL)) {
|
| 1507 | Width = 1;
|
| 1508 | switch (CurrentOption->Value.Type) {
|
| 1509 | case EFI_IFR_TYPE_NUM_SIZE_8:
|
| 1510 | Width = 1;
|
| 1511 | break;
|
| 1512 |
|
| 1513 | case EFI_IFR_TYPE_NUM_SIZE_16:
|
| 1514 | Width = 2;
|
| 1515 | break;
|
| 1516 |
|
| 1517 | case EFI_IFR_TYPE_NUM_SIZE_32:
|
| 1518 | Width = 4;
|
| 1519 | break;
|
| 1520 |
|
| 1521 | case EFI_IFR_TYPE_NUM_SIZE_64:
|
| 1522 | Width = 8;
|
| 1523 | break;
|
| 1524 |
|
| 1525 | default:
|
| 1526 | //
|
| 1527 | // Invalid type for Ordered List
|
| 1528 | //
|
| 1529 | break;
|
| 1530 | }
|
| 1531 |
|
| 1532 | CurrentStatement->StorageWidth = (UINT16) (CurrentStatement->MaxContainers * Width);
|
| 1533 | CurrentStatement->BufferValue = AllocateZeroPool (CurrentStatement->StorageWidth);
|
| 1534 | CurrentStatement->ValueType = CurrentOption->Value.Type;
|
| 1535 |
|
| 1536 | InitializeRequestElement (FormSet, CurrentStatement);
|
| 1537 | }
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1538 | break;
|
| 1539 |
|
| 1540 | //
|
| 1541 | // Conditional
|
| 1542 | //
|
| 1543 | case EFI_IFR_NO_SUBMIT_IF_OP:
|
| 1544 | case EFI_IFR_INCONSISTENT_IF_OP:
|
| 1545 | //
|
| 1546 | // Create an Expression node
|
| 1547 | //
|
| 1548 | CurrentExpression = CreateExpression (CurrentForm);
|
| 1549 | CopyMem (&CurrentExpression->Error, &((EFI_IFR_INCONSISTENT_IF *) OpCodeData)->Error, sizeof (EFI_STRING_ID));
|
| 1550 |
|
| 1551 | if (Operand == EFI_IFR_NO_SUBMIT_IF_OP) {
|
| 1552 | CurrentExpression->Type = EFI_HII_EXPRESSION_NO_SUBMIT_IF;
|
| 1553 | InsertTailList (&CurrentStatement->NoSubmitListHead, &CurrentExpression->Link);
|
| 1554 | } else {
|
| 1555 | CurrentExpression->Type = EFI_HII_EXPRESSION_INCONSISTENT_IF;
|
| 1556 | InsertTailList (&CurrentStatement->InconsistentListHead, &CurrentExpression->Link);
|
| 1557 | }
|
lgao4 | 0c66bc7 | 2009-11-12 01:16:12 +0000 | [diff] [blame] | 1558 |
|
| 1559 | //
|
| 1560 | // Take a look at next OpCode to see whether current expression consists
|
| 1561 | // of single OpCode
|
| 1562 | //
|
| 1563 | if (((EFI_IFR_OP_HEADER *) (OpCodeData + OpCodeLength))->Scope == 0) {
|
| 1564 | SingleOpCodeExpression = TRUE;
|
| 1565 | }
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1566 | break;
|
| 1567 |
|
| 1568 | case EFI_IFR_SUPPRESS_IF_OP:
|
| 1569 | //
|
| 1570 | // Question and Option will appear in scope of this OpCode
|
| 1571 | //
|
| 1572 | CurrentExpression = CreateExpression (CurrentForm);
|
| 1573 | CurrentExpression->Type = EFI_HII_EXPRESSION_SUPPRESS_IF;
|
lgao4 | 0c66bc7 | 2009-11-12 01:16:12 +0000 | [diff] [blame] | 1574 |
|
| 1575 | if (CurrentForm == NULL) {
|
| 1576 | InsertTailList (&FormSet->ExpressionListHead, &CurrentExpression->Link);
|
| 1577 | } else {
|
| 1578 | InsertTailList (&CurrentForm->ExpressionListHead, &CurrentExpression->Link);
|
| 1579 | }
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1580 |
|
| 1581 | if (SuppressForOption) {
|
| 1582 | InScopeOptionSuppress = TRUE;
|
| 1583 | OptionSuppressExpression = CurrentExpression;
|
lgao4 | 0c66bc7 | 2009-11-12 01:16:12 +0000 | [diff] [blame] | 1584 | } else if (SuppressForQuestion) {
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1585 | mInScopeSuppress = TRUE;
|
| 1586 | mSuppressExpression = CurrentExpression;
|
lgao4 | 0c66bc7 | 2009-11-12 01:16:12 +0000 | [diff] [blame] | 1587 | } else {
|
| 1588 | InScopeFormSuppress = TRUE;
|
| 1589 | FormSuppressExpression = CurrentExpression;
|
| 1590 | }
|
| 1591 |
|
| 1592 | //
|
| 1593 | // Take a look at next OpCode to see whether current expression consists
|
| 1594 | // of single OpCode
|
| 1595 | //
|
| 1596 | if (((EFI_IFR_OP_HEADER *) (OpCodeData + OpCodeLength))->Scope == 0) {
|
| 1597 | SingleOpCodeExpression = TRUE;
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1598 | }
|
| 1599 | break;
|
| 1600 |
|
| 1601 | case EFI_IFR_GRAY_OUT_IF_OP:
|
| 1602 | //
|
| 1603 | // Questions will appear in scope of this OpCode
|
| 1604 | //
|
| 1605 | CurrentExpression = CreateExpression (CurrentForm);
|
| 1606 | CurrentExpression->Type = EFI_HII_EXPRESSION_GRAY_OUT_IF;
|
| 1607 | InsertTailList (&CurrentForm->ExpressionListHead, &CurrentExpression->Link);
|
| 1608 |
|
| 1609 | mInScopeGrayOut = TRUE;
|
| 1610 | mGrayOutExpression = CurrentExpression;
|
lgao4 | 0c66bc7 | 2009-11-12 01:16:12 +0000 | [diff] [blame] | 1611 |
|
| 1612 | //
|
| 1613 | // Take a look at next OpCode to see whether current expression consists
|
| 1614 | // of single OpCode
|
| 1615 | //
|
| 1616 | if (((EFI_IFR_OP_HEADER *) (OpCodeData + OpCodeLength))->Scope == 0) {
|
| 1617 | SingleOpCodeExpression = TRUE;
|
| 1618 | }
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1619 | break;
|
| 1620 |
|
| 1621 | case EFI_IFR_DISABLE_IF_OP:
|
| 1622 | //
|
| 1623 | // The DisableIf expression should only rely on constant, so it could be
|
| 1624 | // evaluated at initialization and it will not be queued
|
| 1625 | //
|
| 1626 | CurrentExpression = AllocateZeroPool (sizeof (FORM_EXPRESSION));
|
jji4 | 1ac628e | 2009-01-19 07:58:58 +0000 | [diff] [blame] | 1627 | ASSERT (CurrentExpression != NULL);
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1628 | CurrentExpression->Signature = FORM_EXPRESSION_SIGNATURE;
|
| 1629 | CurrentExpression->Type = EFI_HII_EXPRESSION_DISABLE_IF;
|
| 1630 | InitializeListHead (&CurrentExpression->OpCodeListHead);
|
| 1631 |
|
lgao4 | 0a1147e | 2009-04-22 03:18:37 +0000 | [diff] [blame] | 1632 | if (CurrentForm != NULL) {
|
| 1633 | //
|
| 1634 | // This is DisableIf for Question, enqueue it to Form expression list
|
| 1635 | //
|
| 1636 | InsertTailList (&CurrentForm->ExpressionListHead, &CurrentExpression->Link);
|
| 1637 | }
|
| 1638 |
|
| 1639 | mDisableExpression = CurrentExpression;
|
| 1640 | mInScopeDisable = TRUE;
|
| 1641 | OpCodeDisabled = FALSE;
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1642 |
|
| 1643 | //
|
| 1644 | // Take a look at next OpCode to see whether current expression consists
|
| 1645 | // of single OpCode
|
| 1646 | //
|
| 1647 | if (((EFI_IFR_OP_HEADER *) (OpCodeData + OpCodeLength))->Scope == 0) {
|
| 1648 | SingleOpCodeExpression = TRUE;
|
| 1649 | }
|
| 1650 | break;
|
| 1651 |
|
| 1652 | //
|
| 1653 | // Expression
|
| 1654 | //
|
| 1655 | case EFI_IFR_VALUE_OP:
|
| 1656 | CurrentExpression = CreateExpression (CurrentForm);
|
| 1657 | CurrentExpression->Type = EFI_HII_EXPRESSION_VALUE;
|
| 1658 | InsertTailList (&CurrentForm->ExpressionListHead, &CurrentExpression->Link);
|
| 1659 |
|
| 1660 | if (InScopeDefault) {
|
| 1661 | //
|
| 1662 | // Used for default (EFI_IFR_DEFAULT)
|
| 1663 | //
|
| 1664 | CurrentDefault->ValueExpression = CurrentExpression;
|
| 1665 | } else {
|
| 1666 | //
|
| 1667 | // If used for a question, then the question will be read-only
|
| 1668 | //
|
qwang12 | bc166db | 2009-02-02 07:18:59 +0000 | [diff] [blame] | 1669 | //
|
| 1670 | // Make sure CurrentStatement is not NULL.
|
| 1671 | // If it is NULL, 1) ParseOpCodes functions may parse the IFR wrongly. Or 2) the IFR
|
| 1672 | // file is wrongly generated by tools such as VFR Compiler. There may be a bug in VFR Compiler.
|
| 1673 | //
|
| 1674 | ASSERT (CurrentStatement != NULL);
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1675 | CurrentStatement->ValueExpression = CurrentExpression;
|
| 1676 | }
|
lgao4 | 0c66bc7 | 2009-11-12 01:16:12 +0000 | [diff] [blame] | 1677 |
|
| 1678 | //
|
| 1679 | // Take a look at next OpCode to see whether current expression consists
|
| 1680 | // of single OpCode
|
| 1681 | //
|
| 1682 | if (((EFI_IFR_OP_HEADER *) (OpCodeData + OpCodeLength))->Scope == 0) {
|
| 1683 | SingleOpCodeExpression = TRUE;
|
| 1684 | }
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1685 | break;
|
| 1686 |
|
| 1687 | case EFI_IFR_RULE_OP:
|
| 1688 | CurrentExpression = CreateExpression (CurrentForm);
|
| 1689 | CurrentExpression->Type = EFI_HII_EXPRESSION_RULE;
|
| 1690 |
|
| 1691 | CurrentExpression->RuleId = ((EFI_IFR_RULE *) OpCodeData)->RuleId;
|
| 1692 | InsertTailList (&CurrentForm->ExpressionListHead, &CurrentExpression->Link);
|
lgao4 | 0c66bc7 | 2009-11-12 01:16:12 +0000 | [diff] [blame] | 1693 |
|
| 1694 | //
|
| 1695 | // Take a look at next OpCode to see whether current expression consists
|
| 1696 | // of single OpCode
|
| 1697 | //
|
| 1698 | if (((EFI_IFR_OP_HEADER *) (OpCodeData + OpCodeLength))->Scope == 0) {
|
| 1699 | SingleOpCodeExpression = TRUE;
|
| 1700 | }
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1701 | break;
|
| 1702 |
|
| 1703 | //
|
| 1704 | // Image
|
| 1705 | //
|
| 1706 | case EFI_IFR_IMAGE_OP:
|
| 1707 | //
|
| 1708 | // Get ScopeOpcode from top of stack
|
| 1709 | //
|
| 1710 | PopScope (&ScopeOpCode);
|
| 1711 | PushScope (ScopeOpCode);
|
| 1712 |
|
| 1713 | switch (ScopeOpCode) {
|
| 1714 | case EFI_IFR_FORM_SET_OP:
|
| 1715 | ImageId = &FormSet->ImageId;
|
| 1716 | break;
|
| 1717 |
|
| 1718 | case EFI_IFR_FORM_OP:
|
qwang12 | d0720b5 | 2009-01-20 01:55:11 +0000 | [diff] [blame] | 1719 | ASSERT (CurrentForm != NULL);
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1720 | ImageId = &CurrentForm->ImageId;
|
| 1721 | break;
|
| 1722 |
|
| 1723 | case EFI_IFR_ONE_OF_OPTION_OP:
|
| 1724 | ImageId = &CurrentOption->ImageId;
|
| 1725 | break;
|
| 1726 |
|
| 1727 | default:
|
qwang12 | bc166db | 2009-02-02 07:18:59 +0000 | [diff] [blame] | 1728 | //
|
| 1729 | // Make sure CurrentStatement is not NULL.
|
| 1730 | // If it is NULL, 1) ParseOpCodes functions may parse the IFR wrongly. Or 2) the IFR
|
| 1731 | // file is wrongly generated by tools such as VFR Compiler.
|
| 1732 | //
|
| 1733 | ASSERT (CurrentStatement != NULL);
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1734 | ImageId = &CurrentStatement->ImageId;
|
| 1735 | break;
|
| 1736 | }
|
| 1737 |
|
qwang12 | c410589 | 2009-02-06 06:34:43 +0000 | [diff] [blame] | 1738 | ASSERT (ImageId != NULL);
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1739 | CopyMem (ImageId, &((EFI_IFR_IMAGE *) OpCodeData)->Id, sizeof (EFI_IMAGE_ID));
|
| 1740 | break;
|
| 1741 |
|
| 1742 | //
|
| 1743 | // Refresh
|
| 1744 | //
|
| 1745 | case EFI_IFR_REFRESH_OP:
|
qwang12 | c410589 | 2009-02-06 06:34:43 +0000 | [diff] [blame] | 1746 | ASSERT (CurrentStatement != NULL);
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1747 | CurrentStatement->RefreshInterval = ((EFI_IFR_REFRESH *) OpCodeData)->RefreshInterval;
|
| 1748 | break;
|
| 1749 |
|
| 1750 | //
|
| 1751 | // Vendor specific
|
| 1752 | //
|
| 1753 | case EFI_IFR_GUID_OP:
|
lgao4 | 5c52673 | 2009-02-23 15:18:48 +0000 | [diff] [blame] | 1754 | if (CompareGuid (&gEfiIfrTianoGuid, (EFI_GUID *)(OpCodeData + sizeof (EFI_IFR_OP_HEADER)))) {
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1755 | //
|
| 1756 | // Tiano specific GUIDed opcodes
|
| 1757 | //
|
| 1758 | switch (((EFI_IFR_GUID_LABEL *) OpCodeData)->ExtendOpCode) {
|
| 1759 | case EFI_IFR_EXTEND_OP_LABEL:
|
| 1760 | //
|
| 1761 | // just ignore label
|
| 1762 | //
|
| 1763 | break;
|
| 1764 |
|
| 1765 | case EFI_IFR_EXTEND_OP_BANNER:
|
lgao4 | 0a1147e | 2009-04-22 03:18:37 +0000 | [diff] [blame] | 1766 | //
|
lgao4 | b9e388d | 2009-04-22 07:30:52 +0000 | [diff] [blame] | 1767 | // By SubClass to get Banner Data from Front Page
|
lgao4 | 0a1147e | 2009-04-22 03:18:37 +0000 | [diff] [blame] | 1768 | //
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1769 | if (FormSet->SubClass == EFI_FRONT_PAGE_SUBCLASS) {
|
| 1770 | CopyMem (
|
lgao4 | 0a1147e | 2009-04-22 03:18:37 +0000 | [diff] [blame] | 1771 | &gBannerData->Banner[((EFI_IFR_GUID_BANNER *) OpCodeData)->LineNumber][
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1772 | ((EFI_IFR_GUID_BANNER *) OpCodeData)->Alignment],
|
| 1773 | &((EFI_IFR_GUID_BANNER *) OpCodeData)->Title,
|
| 1774 | sizeof (EFI_STRING_ID)
|
| 1775 | );
|
| 1776 | }
|
| 1777 | break;
|
| 1778 |
|
| 1779 | case EFI_IFR_EXTEND_OP_CLASS:
|
| 1780 | CopyMem (&FormSet->Class, &((EFI_IFR_GUID_CLASS *) OpCodeData)->Class, sizeof (UINT16));
|
| 1781 | break;
|
| 1782 |
|
| 1783 | case EFI_IFR_EXTEND_OP_SUBCLASS:
|
| 1784 | CopyMem (&FormSet->SubClass, &((EFI_IFR_GUID_SUBCLASS *) OpCodeData)->SubClass, sizeof (UINT16));
|
| 1785 | break;
|
| 1786 |
|
| 1787 | default:
|
| 1788 | break;
|
| 1789 | }
|
| 1790 | }
|
| 1791 |
|
| 1792 | break;
|
| 1793 |
|
| 1794 | //
|
| 1795 | // Scope End
|
| 1796 | //
|
| 1797 | case EFI_IFR_END_OP:
|
| 1798 | Status = PopScope (&ScopeOpCode);
|
| 1799 | if (EFI_ERROR (Status)) {
|
| 1800 | ResetScopeStack ();
|
| 1801 | return Status;
|
| 1802 | }
|
| 1803 |
|
| 1804 | switch (ScopeOpCode) {
|
| 1805 | case EFI_IFR_FORM_SET_OP:
|
| 1806 | //
|
| 1807 | // End of FormSet, update FormSet IFR binary length
|
| 1808 | // to stop parsing substantial OpCodes
|
| 1809 | //
|
| 1810 | FormSet->IfrBinaryLength = OpCodeOffset;
|
| 1811 | break;
|
| 1812 |
|
| 1813 | case EFI_IFR_FORM_OP:
|
| 1814 | //
|
| 1815 | // End of Form
|
| 1816 | //
|
| 1817 | CurrentForm = NULL;
|
lgao4 | 0c66bc7 | 2009-11-12 01:16:12 +0000 | [diff] [blame] | 1818 | SuppressForQuestion = FALSE;
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1819 | break;
|
| 1820 |
|
| 1821 | case EFI_IFR_ONE_OF_OPTION_OP:
|
| 1822 | //
|
| 1823 | // End of Option
|
| 1824 | //
|
| 1825 | CurrentOption = NULL;
|
| 1826 | break;
|
| 1827 |
|
| 1828 | case EFI_IFR_SUBTITLE_OP:
|
| 1829 | mInScopeSubtitle = FALSE;
|
| 1830 | break;
|
| 1831 |
|
| 1832 | case EFI_IFR_NO_SUBMIT_IF_OP:
|
| 1833 | case EFI_IFR_INCONSISTENT_IF_OP:
|
| 1834 | //
|
| 1835 | // Ignore end of EFI_IFR_NO_SUBMIT_IF and EFI_IFR_INCONSISTENT_IF
|
| 1836 | //
|
| 1837 | break;
|
| 1838 |
|
| 1839 | case EFI_IFR_SUPPRESS_IF_OP:
|
| 1840 | if (SuppressForOption) {
|
| 1841 | InScopeOptionSuppress = FALSE;
|
lgao4 | 0c66bc7 | 2009-11-12 01:16:12 +0000 | [diff] [blame] | 1842 | } else if (SuppressForQuestion) {
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1843 | mInScopeSuppress = FALSE;
|
lgao4 | 0c66bc7 | 2009-11-12 01:16:12 +0000 | [diff] [blame] | 1844 | } else {
|
| 1845 | InScopeFormSuppress = FALSE;
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1846 | }
|
| 1847 | break;
|
| 1848 |
|
| 1849 | case EFI_IFR_GRAY_OUT_IF_OP:
|
| 1850 | mInScopeGrayOut = FALSE;
|
| 1851 | break;
|
| 1852 |
|
| 1853 | case EFI_IFR_DISABLE_IF_OP:
|
lgao4 | 0a1147e | 2009-04-22 03:18:37 +0000 | [diff] [blame] | 1854 | mInScopeDisable = FALSE;
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1855 | OpCodeDisabled = FALSE;
|
| 1856 | break;
|
| 1857 |
|
| 1858 | case EFI_IFR_ONE_OF_OP:
|
| 1859 | case EFI_IFR_ORDERED_LIST_OP:
|
| 1860 | SuppressForOption = FALSE;
|
| 1861 | break;
|
| 1862 |
|
| 1863 | case EFI_IFR_DEFAULT_OP:
|
| 1864 | InScopeDefault = FALSE;
|
| 1865 | break;
|
| 1866 |
|
| 1867 | default:
|
| 1868 | if (IsExpressionOpCode (ScopeOpCode)) {
|
lgao4 | 0a1147e | 2009-04-22 03:18:37 +0000 | [diff] [blame] | 1869 | if (mInScopeDisable && CurrentForm == NULL) {
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1870 | //
|
lgao4 | 0a1147e | 2009-04-22 03:18:37 +0000 | [diff] [blame] | 1871 | // This is DisableIf expression for Form, it should be a constant expression
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1872 | //
|
xdu2 | f8a1c22 | 2009-10-20 03:01:10 +0000 | [diff] [blame] | 1873 | ASSERT (CurrentExpression != NULL);
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1874 | Status = EvaluateExpression (FormSet, CurrentForm, CurrentExpression);
|
| 1875 | if (EFI_ERROR (Status)) {
|
| 1876 | return Status;
|
| 1877 | }
|
qwang12 | a935a0d | 2009-02-10 09:40:27 +0000 | [diff] [blame] | 1878 |
|
qhuang8 | c60a061 | 2008-10-31 04:41:33 +0000 | [diff] [blame] | 1879 | if (CurrentExpression->Result.Type != EFI_IFR_TYPE_BOOLEAN) {
|
| 1880 | return EFI_INVALID_PARAMETER;
|
| 1881 | }
|
| 1882 |
|
| 1883 | OpCodeDisabled = CurrentExpression->Result.Value.b;
|
| 1884 | //
|
| 1885 | // DisableIf Expression is only used once and not quequed, free it
|
| 1886 | //
|
| 1887 | DestroyExpression (CurrentExpression);
|
| 1888 | }
|
| 1889 |
|
| 1890 | //
|
| 1891 | // End of current Expression
|
| 1892 | //
|
| 1893 | CurrentExpression = NULL;
|
| 1894 | }
|
| 1895 | break;
|
| 1896 | }
|
| 1897 | break;
|
| 1898 |
|
| 1899 | default:
|
| 1900 | break;
|
| 1901 | }
|
| 1902 | }
|
| 1903 |
|
| 1904 | return EFI_SUCCESS;
|
| 1905 | }
|