]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/ConfigAccess.c
Fix an issue that an assert occurrs if user inputs a password whose length is less...
[mirror_edk2.git] / EdkCompatibilityPkg / Compatibility / FrameworkHiiOnUefiHiiThunk / ConfigAccess.c
CommitLineData
ebbd2793 1/**@file\r
a9d85320 2 This file implements functions related to Config Access Protocols installed by\r
3 by HII Thunk Modules. These Config access Protocols are used to thunk UEFI Config \r
4 Access Callback to Framework HII Callback and EFI Variable Set/Get operations.\r
ebbd2793 5 \r
6Copyright (c) 2008, Intel Corporation\r
7All rights reserved. This program and the accompanying materials\r
8are licensed and made available under the terms and conditions of the BSD License\r
9which accompanies this distribution. The full text of the license may be found at\r
10http://opensource.org/licenses/bsd-license.php\r
11\r
12THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
13WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
14\r
15**/\r
16\r
17#include "HiiDatabase.h"\r
a9d85320 18#include "UefiIfrParser.h"\r
ebbd2793 19\r
a9d85320 20BOOLEAN mHiiPackageListUpdated = FALSE;\r
0368663f 21\r
f6f910dd 22HII_VENDOR_DEVICE_PATH mUefiHiiVendorDevicePath = {\r
23 {\r
24 {\r
f6f910dd 25 {\r
6d931089
LG
26 HARDWARE_DEVICE_PATH,\r
27 HW_VENDOR_DP,\r
28 {\r
29 (UINT8) (sizeof (HII_VENDOR_DEVICE_PATH_NODE)),\r
30 (UINT8) ((sizeof (HII_VENDOR_DEVICE_PATH_NODE)) >> 8)\r
31 }\r
32 },\r
33 EFI_CALLER_ID_GUID\r
f6f910dd 34 },\r
6d931089
LG
35 0,\r
36 0\r
f6f910dd 37 },\r
38 {\r
39 END_DEVICE_PATH_TYPE,\r
40 END_ENTIRE_DEVICE_PATH_SUBTYPE,\r
41 { \r
6d931089
LG
42 (UINT8) (sizeof (EFI_DEVICE_PATH_PROTOCOL)),\r
43 (UINT8) ((sizeof (EFI_DEVICE_PATH_PROTOCOL)) >> 8)\r
f6f910dd 44 }\r
45 }\r
46};\r
47\r
0368663f 48CONFIG_ACCESS_PRIVATE gConfigAccessPrivateTempate = {\r
49 CONFIG_ACCESS_PRIVATE_SIGNATURE,\r
ebbd2793 50 {\r
51 ThunkExtractConfig,\r
52 ThunkRouteConfig,\r
53 ThunkCallback\r
54 }, //ConfigAccessProtocol\r
0368663f 55 NULL, //FormCallbackProtocol\r
0368663f 56 NULL \r
ebbd2793 57};\r
58\r
1a6cdbd9 59/**\r
a9d85320 60 Get the first EFI_IFR_VARSTORE from the FormSet. \r
61 \r
62 @param FormSet The Form Set.\r
63 \r
64 @retval FORMSET_STORAGE * Return the first EFI_IFR_VARSTORE.\r
65 @retval NULL If the Form Set does not have EFI_IFR_VARSTORE.\r
66**/\r
67FORMSET_STORAGE *\r
68GetFirstStorageOfFormSet (\r
69 IN CONST FORM_BROWSER_FORMSET * FormSet\r
70 ) \r
71{\r
72 LIST_ENTRY *StorageList;\r
73 FORMSET_STORAGE *Storage;\r
74\r
75 StorageList = GetFirstNode (&FormSet->StorageListHead);\r
76\r
77 if (!IsNull (&FormSet->StorageListHead, StorageList)) {\r
78 Storage = FORMSET_STORAGE_FROM_LINK (StorageList);\r
79 return Storage;\r
80 }\r
81 \r
82 return NULL;\r
83}\r
84\r
85/**\r
86 Get the EFI_IFR_VARSTORE where the Question's value is stored.\r
1a6cdbd9 87 \r
a9d85320 88 @param FormSet The Form Set.\r
1a6cdbd9 89 \r
a9d85320 90 @retval FORMSET_STORAGE * The EFI_IFR_VARSTORE where the Question's value is stored.\r
91 @retval NULL If the Form Set does not have EFI_IFR_VARSTORE.\r
1a6cdbd9 92**/\r
a9d85320 93FORMSET_STORAGE *\r
94GetStorageFromQuestionId (\r
95 IN CONST FORM_BROWSER_FORMSET * FormSet,\r
96 IN EFI_QUESTION_ID QuestionId\r
ebbd2793 97 )\r
98{\r
a9d85320 99 LIST_ENTRY *FormList;\r
100 LIST_ENTRY *StatementList;\r
101 FORM_BROWSER_FORM *Form;\r
102 FORM_BROWSER_STATEMENT *Statement;\r
103\r
104 FormList = GetFirstNode (&FormSet->FormListHead);\r
105\r
106 while (!IsNull (&FormSet->FormListHead, FormList)) {\r
107 Form = FORM_BROWSER_FORM_FROM_LINK (FormList);\r
108\r
109 StatementList = GetFirstNode (&Form->StatementListHead);\r
110\r
111 while (!IsNull (&Form->StatementListHead, StatementList)) {\r
112 Statement = FORM_BROWSER_STATEMENT_FROM_LINK (StatementList);\r
113 if ((QuestionId == Statement->QuestionId) && (Statement->Storage != NULL)) {\r
114 //\r
115 // UEFI Question ID is unique in a FormSet.\r
116 //\r
117 ASSERT (Statement->Storage->Type == EFI_HII_VARSTORE_BUFFER);\r
118 return Statement->Storage;\r
119 }\r
120 StatementList = GetNextNode (&Form->StatementListHead, StatementList);\r
121 }\r
ebbd2793 122\r
a9d85320 123 FormList = GetNextNode (&FormSet->FormListHead, FormList);\r
124 }\r
125 \r
126 return NULL;\r
127}\r
ebbd2793 128\r
a9d85320 129/**\r
130 Get the EFI_IFR_VARSTORE based the ID.\r
131 \r
132 @param FormSet The Form Set.\r
133 \r
134 @retval FORMSET_STORAGE * The EFI_IFR_VARSTORE with the ID.\r
135 @retval NULL If the Form Set does not have EFI_IFR_VARSTORE with such ID.\r
136**/\r
137FORMSET_STORAGE *\r
138GetStorageFromVarStoreId (\r
139 IN CONST FORM_BROWSER_FORMSET * FormSet,\r
140 IN EFI_VARSTORE_ID VarStoreId\r
141 )\r
142{\r
143 LIST_ENTRY *StorageList;\r
144 FORMSET_STORAGE *Storage;\r
ebbd2793 145\r
a9d85320 146 StorageList = GetFirstNode (&FormSet->StorageListHead);\r
ebbd2793 147\r
a9d85320 148 while (!IsNull (&FormSet->StorageListHead, StorageList)) {\r
149 Storage = FORMSET_STORAGE_FROM_LINK (StorageList);\r
ebbd2793 150\r
a9d85320 151 if (VarStoreId == Storage->VarStoreId) {\r
152 return Storage;\r
ebbd2793 153 }\r
ebbd2793 154\r
a9d85320 155 StorageList = GetNextNode (&FormSet->StorageListHead, StorageList);\r
156 }\r
157 \r
158 return NULL;\r
ebbd2793 159}\r
160\r
1a6cdbd9 161/**\r
a9d85320 162 Get the EFI_IFR_VARSTORE based the <ConfigHdr> string in a <ConfigRequest>\r
163 or a <ConfigResp> string.\r
164 \r
165 @param FormSet The Form Set.\r
166 @param ConfigString The Configuration String which is defined by UEFI HII.\r
1a6cdbd9 167 \r
a9d85320 168 @retval FORMSET_STORAGE * The EFI_IFR_VARSTORE where the Question's value is stored.\r
169 @retval NULL If the Form Set does not have EFI_IFR_VARSTORE with such ID.\r
1a6cdbd9 170**/\r
a9d85320 171FORMSET_STORAGE *\r
172GetStorageFromConfigString (\r
173 IN CONST FORM_BROWSER_FORMSET *FormSet,\r
174 IN CONST EFI_STRING ConfigString\r
ebbd2793 175 )\r
176{\r
a9d85320 177 LIST_ENTRY *StorageList;\r
178 FORMSET_STORAGE *Storage;\r
dee207ee 179 CHAR16 *Name;\r
ebbd2793 180\r
a9d85320 181 StorageList = GetFirstNode (&FormSet->StorageListHead);\r
ebbd2793 182\r
a9d85320 183 while (!IsNull (&FormSet->StorageListHead, StorageList)) {\r
184 Storage = FORMSET_STORAGE_FROM_LINK (StorageList);\r
ebbd2793 185\r
dee207ee 186 if ((Storage->VarStoreId == FormSet->DefaultVarStoreId) && (FormSet->OriginalDefaultVarStoreName != NULL)) {\r
187 Name = FormSet->OriginalDefaultVarStoreName;\r
188 } else {\r
189 Name = Storage->Name;\r
190 }\r
191 \r
192 if (IsConfigHdrMatch (ConfigString, &Storage->Guid, Name)) {\r
a9d85320 193 return Storage;\r
ebbd2793 194 }\r
a9d85320 195\r
196 StorageList = GetNextNode (&FormSet->StorageListHead, StorageList);\r
ebbd2793 197 }\r
1a6cdbd9 198\r
a9d85320 199 return NULL;\r
ebbd2793 200}\r
0368663f 201\r
1a6cdbd9 202/**\r
203 This function installs a EFI_CONFIG_ACCESS_PROTOCOL instance for a form package registered\r
204 by a module using Framework HII Protocol Interfaces.\r
205\r
a9d85320 206 UEFI HII require EFI_HII_CONFIG_ACCESS_PROTOCOL to be installed on a EFI_HANDLE, so\r
207 that Setup Utility can load the Buffer Storage using this protocol.\r
1a6cdbd9 208 \r
a9d85320 209 @param Packages The Package List.\r
210 @param ThunkContext The Thunk Context.\r
1a6cdbd9 211 \r
a9d85320 212 @retval EFI_SUCCESS The Config Access Protocol is installed successfully.\r
213 @retval EFI_OUT_RESOURCE There is not enough memory.\r
1a6cdbd9 214 \r
215**/\r
ebbd2793 216EFI_STATUS\r
0368663f 217InstallDefaultConfigAccessProtocol (\r
218 IN CONST EFI_HII_PACKAGES *Packages,\r
219 IN OUT HII_THUNK_CONTEXT *ThunkContext\r
ebbd2793 220 )\r
221{\r
ebbd2793 222 EFI_STATUS Status;\r
0368663f 223 CONFIG_ACCESS_PRIVATE *ConfigAccessInstance;\r
6d931089 224 HII_VENDOR_DEVICE_PATH *HiiVendorPath;\r
ebbd2793 225\r
a9d85320 226 ASSERT (ThunkContext->IfrPackageCount != 0);\r
227\r
ebbd2793 228 ConfigAccessInstance = AllocateCopyPool (\r
0368663f 229 sizeof (CONFIG_ACCESS_PRIVATE), \r
230 &gConfigAccessPrivateTempate\r
ebbd2793 231 );\r
1a6cdbd9 232 ASSERT (ConfigAccessInstance != NULL);\r
6d931089
LG
233\r
234 //\r
235 // Use memory address as unique ID to distinguish from different device paths\r
236 // This function may be called multi times by the framework HII driver.\r
237 //\r
238 HiiVendorPath = AllocateCopyPool (\r
239 sizeof (HII_VENDOR_DEVICE_PATH), \r
240 &mUefiHiiVendorDevicePath\r
241 );\r
242 ASSERT (HiiVendorPath != NULL);\r
243\r
244 HiiVendorPath->Node.UniqueId = (UINT64) ((UINTN) HiiVendorPath);\r
245\r
ebbd2793 246 Status = gBS->InstallMultipleProtocolInterfaces (\r
0368663f 247 &ThunkContext->UefiHiiDriverHandle,\r
f6f910dd 248 &gEfiDevicePathProtocolGuid, \r
6d931089 249 HiiVendorPath,\r
ebbd2793 250 &gEfiHiiConfigAccessProtocolGuid,\r
251 &ConfigAccessInstance->ConfigAccessProtocol,\r
252 NULL\r
253 );\r
254 ASSERT_EFI_ERROR (Status);\r
0368663f 255 \r
0368663f 256 ConfigAccessInstance->ThunkContext = ThunkContext;\r
ebbd2793 257 \r
258 return EFI_SUCCESS;\r
259}\r
260\r
a9d85320 261/**\r
262 This function un-installs the EFI_CONFIG_ACCESS_PROTOCOL instance for a form package registered\r
263 by a module using Framework HII Protocol Interfaces.\r
0368663f 264\r
a9d85320 265 ASSERT if no Config Access is found for such pakcage list or failed to uninstall the protocol.\r
0368663f 266\r
a9d85320 267 @param ThunkContext The Thunk Context.\r
268 \r
269**/\r
0368663f 270VOID\r
271UninstallDefaultConfigAccessProtocol (\r
272 IN HII_THUNK_CONTEXT *ThunkContext\r
ebbd2793 273 )\r
274{\r
0368663f 275 EFI_STATUS Status;\r
276 EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess;\r
647a768d 277 HII_VENDOR_DEVICE_PATH *HiiVendorPath;\r
278\r
0368663f 279 Status = gBS->HandleProtocol (\r
280 ThunkContext->UefiHiiDriverHandle,\r
281 &gEfiHiiConfigAccessProtocolGuid,\r
282 (VOID **) &ConfigAccess\r
283 );\r
0368663f 284 ASSERT_EFI_ERROR (Status);\r
285\r
647a768d 286 Status = gBS->HandleProtocol (\r
287 ThunkContext->UefiHiiDriverHandle,\r
288 &gEfiDevicePathProtocolGuid,\r
289 (VOID **) &HiiVendorPath\r
290 );\r
291 ASSERT_EFI_ERROR (Status);\r
292\r
f6f910dd 293 Status = gBS->UninstallMultipleProtocolInterfaces (\r
0368663f 294 ThunkContext->UefiHiiDriverHandle,\r
f6f910dd 295 &gEfiDevicePathProtocolGuid,\r
647a768d 296 HiiVendorPath,\r
0368663f 297 &gEfiHiiConfigAccessProtocolGuid,\r
f6f910dd 298 ConfigAccess,\r
299 NULL\r
0368663f 300 );\r
301 ASSERT_EFI_ERROR (Status);\r
302\r
ebbd2793 303}\r
0368663f 304 \r
ebbd2793 305\r
1a6cdbd9 306/**\r
307 Wrap the EFI_HII_CONFIG_ACCESS_PROTOCOL.ExtractConfig to a call to EFI_FORM_CALLBACK_PROTOCOL.NvRead.\r
308 \r
0368663f 309 @param BufferStorage The key with all attributes needed to call EFI_FORM_CALLBACK_PROTOCOL.NvRead.\r
310 @param FwFormCallBack The EFI_FORM_CALLBACK_PROTOCOL registered by Framework HII module.\r
311 @param Data The data read.\r
312 @param DataSize The size of data.\r
1a6cdbd9 313 \r
0368663f 314 @retval EFI_STATUS The status returned by the EFI_FORM_CALLBACK_PROTOCOL.NvWrite.\r
1a6cdbd9 315 @retval EFI_INVALID_PARAMETER If the EFI_FORM_CALLBACK_PROTOCOL.NvRead return the size information of the data\r
0368663f 316 does not match what has been recorded early in he BUFFER_STORAGE_ENTRY.\r
1a6cdbd9 317 **/\r
ebbd2793 318EFI_STATUS\r
0368663f 319CallFormCallBack (\r
a9d85320 320 IN FORMSET_STORAGE *BufferStorage,\r
0368663f 321 IN EFI_FORM_CALLBACK_PROTOCOL *FwFormCallBack,\r
ebbd2793 322 OUT VOID **Data,\r
323 OUT UINTN *DataSize\r
324 )\r
325{\r
326 EFI_STATUS Status;\r
327\r
328 *DataSize = 0;\r
329 *Data = NULL;\r
330 \r
0368663f 331 Status = FwFormCallBack->NvRead (\r
332 FwFormCallBack, \r
333 BufferStorage->Name,\r
334 &BufferStorage->Guid,\r
ebbd2793 335 NULL,\r
336 DataSize,\r
337 *Data\r
338 );\r
339 if (Status == EFI_BUFFER_TOO_SMALL) {\r
0368663f 340 if (BufferStorage->Size != *DataSize) {\r
ebbd2793 341 ASSERT (FALSE);\r
342 return EFI_INVALID_PARAMETER;\r
343 }\r
344\r
345 *Data = AllocateZeroPool (*DataSize);\r
346 if (Data == NULL) {\r
347 return EFI_OUT_OF_RESOURCES;\r
348 }\r
349\r
0368663f 350 FwFormCallBack->NvRead (\r
351 FwFormCallBack, \r
352 BufferStorage->Name,\r
353 &BufferStorage->Guid,\r
ebbd2793 354 NULL,\r
355 DataSize,\r
356 *Data\r
357 );\r
358 }\r
359\r
360 return Status;\r
361}\r
362\r
1a6cdbd9 363\r
364/**\r
365 Wrap the EFI_HII_CONFIG_ACCESS_PROTOCOL.ExtractConfig to a call to UEFI Variable Get Service.\r
366 \r
0368663f 367 @param BufferStorage The key with all attributes needed to call a UEFI Variable Get Service.\r
368 @param Data The data read.\r
369 @param DataSize The size of data.\r
1a6cdbd9 370\r
371 If the UEFI Variable Get Service return the size information of the data\r
0368663f 372 does not match what has been recorded early in he BUFFER_STORAGE_ENTRY.\r
1a6cdbd9 373 then ASSERT.\r
374 \r
0368663f 375 @retval EFI_STATUS The status returned by the UEFI Variable Get Service.\r
1a6cdbd9 376 @retval EFI_INVALID_PARAMETER If the UEFI Variable Get Service return the size information of the data\r
0368663f 377 does not match what has been recorded early in he BUFFER_STORAGE_ENTRY.\r
1a6cdbd9 378 **/\r
379\r
ebbd2793 380EFI_STATUS\r
0368663f 381GetUefiVariable (\r
a9d85320 382 IN FORMSET_STORAGE *BufferStorage,\r
ebbd2793 383 OUT VOID **Data,\r
384 OUT UINTN *DataSize\r
385 )\r
386{\r
387 EFI_STATUS Status;\r
388\r
389 *DataSize = 0;\r
390 *Data = NULL;\r
391 Status = gRT->GetVariable (\r
0368663f 392 BufferStorage->Name,\r
393 &BufferStorage->Guid,\r
ebbd2793 394 NULL,\r
395 DataSize,\r
396 *Data\r
397 );\r
398 if (Status == EFI_BUFFER_TOO_SMALL) {\r
399\r
0368663f 400 if (BufferStorage->Size != *DataSize) {\r
ebbd2793 401 ASSERT (FALSE);\r
402 return EFI_INVALID_PARAMETER;\r
403 }\r
404\r
405 *Data = AllocateZeroPool (*DataSize);\r
406 if (Data == NULL) {\r
407 return EFI_OUT_OF_RESOURCES;\r
408 }\r
409\r
410 Status = gRT->GetVariable (\r
0368663f 411 BufferStorage->Name,\r
412 &BufferStorage->Guid,\r
ebbd2793 413 NULL,\r
414 DataSize,\r
415 *Data\r
416 );\r
417 }\r
418\r
419 return Status;\r
420}\r
421\r
1a6cdbd9 422/**\r
423\r
424 This function implement the EFI_HII_CONFIG_ACCESS_PROTOCOL.ExtractConfig\r
425 so that data can be read from the data storage such as UEFI Variable or module's\r
426 customized storage exposed by EFI_FRAMEWORK_CALLBACK.\r
427\r
0368663f 428 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL\r
1a6cdbd9 429 @param Request A null-terminated Unicode string in <ConfigRequest> format. Note that this\r
0368663f 430 includes the routing information as well as the configurable name / value pairs. It is\r
431 invalid for this string to be in <MultiConfigRequest> format.\r
1a6cdbd9 432\r
0368663f 433 @param Progress On return, points to a character in the Request string. Points to the string's null\r
434 terminator if request was successful. Points to the most recent '&' before the first\r
435 failing name / value pair (or the beginning of the string if the failure is in the first\r
436 name / value pair) if the request was not successful\r
1a6cdbd9 437 @param Results A null-terminated Unicode string in <ConfigAltResp> format which has all\r
0368663f 438 values filled in for the names in the Request string. String to be allocated by the called\r
439 function.\r
1a6cdbd9 440 \r
441 @retval EFI_INVALID_PARAMETER If there is no Buffer Storage for this Config Access instance.\r
0368663f 442 @retval EFI_SUCCESS The setting is retrived successfully.\r
443 @retval !EFI_SUCCESS The error returned by UEFI Get Variable or Framework Form Callback Nvread.\r
1a6cdbd9 444 **/\r
ebbd2793 445EFI_STATUS\r
446EFIAPI\r
447ThunkExtractConfig (\r
448 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r
449 IN CONST EFI_STRING Request,\r
450 OUT EFI_STRING *Progress,\r
451 OUT EFI_STRING *Results\r
452 )\r
453{\r
454 EFI_STATUS Status;\r
0368663f 455 CONFIG_ACCESS_PRIVATE *ConfigAccess;\r
a9d85320 456 FORMSET_STORAGE *BufferStorage;\r
ebbd2793 457 VOID *Data;\r
458 UINTN DataSize;\r
459\r
6a179dca 460 if (Request == NULL) {\r
461 return EFI_NOT_FOUND;\r
462 }\r
463\r
ebbd2793 464 Data = NULL;\r
0368663f 465 ConfigAccess = CONFIG_ACCESS_PRIVATE_FROM_PROTOCOL (This);\r
ebbd2793 466\r
a9d85320 467 BufferStorage = GetStorageFromConfigString (ConfigAccess->ThunkContext->FormSet, Request);\r
ebbd2793 468\r
6a179dca 469 if (BufferStorage == NULL) {\r
470 *Progress = (EFI_STRING) Request;\r
471 return EFI_NOT_FOUND;\r
472 }\r
473\r
133a9dfb 474 if (ConfigAccess->ThunkContext->NvMapOverride == NULL) {\r
a9d85320 475 //\r
476 // NvMapOverride is not used. Get the Storage data from EFI Variable or Framework Form Callback.\r
477 //\r
133a9dfb 478 if (ConfigAccess->FormCallbackProtocol == NULL ||\r
479 ConfigAccess->FormCallbackProtocol->NvRead == NULL) {\r
480 Status = GetUefiVariable (\r
481 BufferStorage,\r
482 &Data,\r
483 &DataSize\r
484 );\r
485 } else {\r
486 Status = CallFormCallBack (\r
487 BufferStorage,\r
488 ConfigAccess->FormCallbackProtocol,\r
489 &Data,\r
490 &DataSize\r
491 );\r
492 }\r
ebbd2793 493 } else {\r
a9d85320 494 //\r
495 // Use the NvMapOverride.\r
496 //\r
133a9dfb 497 DataSize = BufferStorage->Size;\r
498 Data = AllocateCopyPool (DataSize, ConfigAccess->ThunkContext->NvMapOverride);\r
499 \r
500 if (Data != NULL) {\r
501 Status = EFI_SUCCESS;\r
502 } else {\r
503 Status = EFI_OUT_OF_RESOURCES;\r
504 }\r
ebbd2793 505 }\r
506 \r
507 if (!EFI_ERROR (Status)) {\r
59336178 508 Status = mHiiConfigRoutingProtocol->BlockToConfig (\r
509 mHiiConfigRoutingProtocol,\r
ebbd2793 510 Request,\r
511 Data,\r
512 DataSize,\r
513 Results,\r
514 Progress\r
515 );\r
516 }\r
517\r
7001eaf8 518 if (Data != NULL) {\r
519 FreePool (Data);\r
520 }\r
ebbd2793 521 return Status;\r
522}\r
523\r
1a6cdbd9 524/**\r
1a6cdbd9 525 This function implement the EFI_HII_CONFIG_ACCESS_PROTOCOL.RouteConfig\r
526 so that data can be written to the data storage such as UEFI Variable or module's\r
527 customized storage exposed by EFI_FRAMEWORK_CALLBACK.\r
528 \r
0368663f 529 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL\r
530 @param Configuration A null-terminated Unicode string in <ConfigResp> format.\r
fd0d281b 531 @param Progress A pointer to a string filled in with the offset of the most recent '&' before the first\r
0368663f 532 failing name / value pair (or the beginning of the string if the failure is in the first\r
533 name / value pair) or the terminating NULL if all was successful.\r
1a6cdbd9 534 \r
535 @retval EFI_INVALID_PARAMETER If there is no Buffer Storage for this Config Access instance.\r
0368663f 536 @retval EFI_SUCCESS The setting is saved successfully.\r
537 @retval !EFI_SUCCESS The error returned by UEFI Set Variable or Framework Form Callback Nvwrite.\r
1a6cdbd9 538**/ \r
ebbd2793 539EFI_STATUS\r
540EFIAPI\r
541ThunkRouteConfig (\r
542 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r
543 IN CONST EFI_STRING Configuration,\r
544 OUT EFI_STRING *Progress\r
545 )\r
546{\r
547 EFI_STATUS Status;\r
0368663f 548 CONFIG_ACCESS_PRIVATE *ConfigAccess;\r
a9d85320 549 FORMSET_STORAGE *BufferStorage;\r
98b16b9d 550 VOID *Data;\r
ebbd2793 551 UINTN DataSize;\r
0368663f 552 UINTN DataSize2;\r
ebbd2793 553 UINTN LastModifiedByteIndex;\r
0368663f 554 BOOLEAN ResetRequired;\r
555 BOOLEAN DataAllocated;\r
ebbd2793 556\r
6a179dca 557 if (Configuration == NULL) {\r
558 return EFI_INVALID_PARAMETER;\r
559 }\r
560\r
ebbd2793 561 Data = NULL;\r
0368663f 562 ConfigAccess = CONFIG_ACCESS_PRIVATE_FROM_PROTOCOL (This);\r
ebbd2793 563\r
a9d85320 564 BufferStorage = GetStorageFromConfigString (ConfigAccess->ThunkContext->FormSet, Configuration);\r
ebbd2793 565\r
6a179dca 566 if (BufferStorage == NULL) {\r
567 *Progress = Configuration;\r
568 return EFI_NOT_FOUND;\r
569 }\r
570\r
0368663f 571 DataSize2 = BufferStorage->Size;\r
572 if (ConfigAccess->ThunkContext->NvMapOverride == NULL) {\r
133a9dfb 573 DataAllocated = TRUE;\r
0368663f 574 if (ConfigAccess->FormCallbackProtocol == NULL ||\r
575 ConfigAccess->FormCallbackProtocol->NvRead == NULL) {\r
576 Status = GetUefiVariable (\r
577 BufferStorage,\r
578 &Data,\r
579 &DataSize\r
580 );\r
0368663f 581 } else {\r
582 Status = CallFormCallBack (\r
583 BufferStorage,\r
584 ConfigAccess->FormCallbackProtocol,\r
585 &Data,\r
586 &DataSize\r
587 );\r
0368663f 588 }\r
589 } else {\r
133a9dfb 590 //\r
591 // ConfigToBlock will convert the Config String and update the NvMapOverride accordingly.\r
592 //\r
0368663f 593 Status = EFI_SUCCESS;\r
594 Data = ConfigAccess->ThunkContext->NvMapOverride;\r
595 DataSize = DataSize2;\r
596 DataAllocated = FALSE;\r
597 } \r
133a9dfb 598 if (EFI_ERROR (Status) || (DataSize2 != DataSize)) {\r
599 if (Data == NULL) {\r
600 Data = AllocateZeroPool (DataSize2);\r
601 }\r
ebbd2793 602 }\r
0368663f 603\r
59336178 604 Status = mHiiConfigRoutingProtocol->ConfigToBlock (\r
605 mHiiConfigRoutingProtocol,\r
ebbd2793 606 Configuration,\r
607 Data,\r
608 &LastModifiedByteIndex,\r
609 Progress\r
610 );\r
ebbd2793 611 if (EFI_ERROR (Status)) {\r
612 goto Done;\r
613 }\r
614\r
133a9dfb 615 if (ConfigAccess->ThunkContext->NvMapOverride == NULL) {\r
616 if (ConfigAccess->FormCallbackProtocol == NULL ||\r
617 ConfigAccess->FormCallbackProtocol->NvWrite == NULL) {\r
618 Status = gRT->SetVariable (\r
619 BufferStorage->Name,\r
620 &BufferStorage->Guid,\r
621 EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
622 DataSize2,\r
623 Data\r
624 );\r
625 } else {\r
626 Status = ConfigAccess->FormCallbackProtocol->NvWrite (\r
627 ConfigAccess->FormCallbackProtocol, \r
628 BufferStorage->Name,\r
629 &BufferStorage->Guid,\r
630 EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
631 DataSize2,\r
632 Data,\r
633 &ResetRequired\r
634 );\r
635 \r
636 }\r
ebbd2793 637 }\r
638\r
0368663f 639Done: \r
640 if (DataAllocated && (Data != NULL)) {\r
641 FreePool (Data);\r
642 }\r
643 \r
ebbd2793 644 return Status;\r
645}\r
646\r
a9d85320 647/**\r
648 Build the FRAMEWORK_EFI_IFR_DATA_ARRAY which will be used to pass to \r
649 EFI_FORM_CALLBACK_PROTOCOL.Callback. Check definition of FRAMEWORK_EFI_IFR_DATA_ARRAY\r
650 for details.\r
651\r
652 ASSERT if the Question Type is not EFI_IFR_TYPE_NUM_SIZE_* or EFI_IFR_TYPE_STRING.\r
653 \r
654 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL\r
655 @param QuestionId The Question ID.\r
656 @param Type The Question Type.\r
657 @param Value The Question Value.\r
658 @param NvMapAllocated On output indicates if a buffer is allocated for NvMap.\r
659 \r
660 @return A pointer to FRAMEWORK_EFI_IFR_DATA_ARRAY. The caller must free this buffer allocated.\r
661**/ \r
0368663f 662FRAMEWORK_EFI_IFR_DATA_ARRAY *\r
663CreateIfrDataArray (\r
664 IN CONFIG_ACCESS_PRIVATE *ConfigAccess,\r
665 IN EFI_QUESTION_ID QuestionId,\r
666 IN UINT8 Type,\r
667 IN EFI_IFR_TYPE_VALUE *Value,\r
668 OUT BOOLEAN *NvMapAllocated\r
669 )\r
670{\r
671 FRAMEWORK_EFI_IFR_DATA_ARRAY *IfrDataArray;\r
672 FRAMEWORK_EFI_IFR_DATA_ENTRY *IfrDataEntry;\r
673 UINTN BrowserDataSize;\r
a9d85320 674 FORMSET_STORAGE *BufferStorage;\r
133a9dfb 675 EFI_STATUS Status;\r
286f0de7 676 UINTN Size;\r
286f0de7 677 EFI_STRING String;\r
678\r
a9d85320 679 *NvMapAllocated = FALSE;\r
0368663f 680\r
a9d85320 681 String = NULL;\r
286f0de7 682\r
683 switch (Type) {\r
684 case EFI_IFR_TYPE_NUM_SIZE_8:\r
685 case EFI_IFR_TYPE_NUM_SIZE_16:\r
686 case EFI_IFR_TYPE_NUM_SIZE_32:\r
687 case EFI_IFR_TYPE_NUM_SIZE_64:\r
688 case EFI_IFR_TYPE_BOOLEAN:\r
689 Size = sizeof (*Value);\r
690 break;\r
691\r
692 case EFI_IFR_TYPE_STRING:\r
887c077d 693 if (Value->string == 0) {\r
694 Size = 0;\r
695 } else {\r
696 String = HiiGetString (ConfigAccess->ThunkContext->UefiHiiHandle, Value->string, NULL);\r
697 ASSERT (String != NULL);\r
286f0de7 698\r
887c077d 699 Size = StrSize (String);\r
700 }\r
286f0de7 701 break;\r
702 \r
703 default:\r
704 ASSERT (FALSE);\r
705 Size = 0;\r
706 break;\r
707 }\r
708\r
709 IfrDataArray = AllocateZeroPool (sizeof (FRAMEWORK_EFI_IFR_DATA_ARRAY) + sizeof (FRAMEWORK_EFI_IFR_DATA_ENTRY) + Size);\r
0368663f 710 ASSERT (IfrDataArray != NULL);\r
711\r
a9d85320 712 BufferStorage = GetStorageFromQuestionId (ConfigAccess->ThunkContext->FormSet, QuestionId);\r
0368663f 713\r
a9d85320 714 if (BufferStorage == NULL) {\r
715 //\r
716 // The QuestionId is not associated with a Buffer Storage.\r
717 // Try to get the first Buffer Storage then.\r
718 //\r
719 BufferStorage = GetFirstStorageOfFormSet (ConfigAccess->ThunkContext->FormSet);\r
0368663f 720 }\r
133a9dfb 721 \r
a9d85320 722 if (BufferStorage != NULL) {\r
723 BrowserDataSize = BufferStorage->Size;\r
0368663f 724\r
a9d85320 725 if (ConfigAccess->ThunkContext->NvMapOverride == NULL) {\r
726 *NvMapAllocated = TRUE;\r
727 IfrDataArray->NvRamMap = AllocateZeroPool (BrowserDataSize);\r
728 } else {\r
729 *NvMapAllocated = FALSE;\r
730 IfrDataArray->NvRamMap = ConfigAccess->ThunkContext->NvMapOverride;\r
731 }\r
732 \r
733 Status = GetBrowserData (&BufferStorage->Guid, BufferStorage->Name, &BrowserDataSize, IfrDataArray->NvRamMap);\r
734 ASSERT_EFI_ERROR (Status);\r
0368663f 735\r
a9d85320 736 IfrDataEntry = (FRAMEWORK_EFI_IFR_DATA_ENTRY *) (IfrDataArray + 1);\r
0368663f 737\r
a9d85320 738 switch (Type) {\r
739 case EFI_IFR_TYPE_NUM_SIZE_8:\r
740 case EFI_IFR_TYPE_NUM_SIZE_16:\r
741 case EFI_IFR_TYPE_NUM_SIZE_32:\r
742 case EFI_IFR_TYPE_NUM_SIZE_64:\r
743 case EFI_IFR_TYPE_BOOLEAN:\r
744 CopyMem (&IfrDataEntry->Data, &(Value->u8), sizeof (*Value));\r
745 break;\r
746\r
747 case EFI_IFR_TYPE_STRING:\r
887c077d 748 if (Size != 0) {\r
749 ASSERT (String != NULL);\r
750 StrCpy ((CHAR16 *) &IfrDataEntry->Data, String);\r
751 FreePool (String);\r
752 }\r
a9d85320 753 break;\r
754 default:\r
755 ASSERT (FALSE);\r
756 break;\r
757 }\r
758\r
759 //\r
760 // Need to fiil in the information for the rest of field for FRAMEWORK_EFI_IFR_DATA_ENTRY.\r
761 // It seems that no implementation is found to use other fields. Leave them uninitialized for now.\r
762 //\r
763 //UINT8 OpCode; // Likely a string, numeric, or one-of\r
764 //UINT8 Length; // Length of the FRAMEWORK_EFI_IFR_DATA_ENTRY packet\r
765 //UINT16 Flags; // Flags settings to determine what behavior is desired from the browser after the callback\r
766 //VOID *Data; // The data in the form based on the op-code type - this is not a pointer to the data, the data follows immediately\r
767 // If the OpCode is a OneOf or Numeric type - Data is a UINT16 value\r
768 // If the OpCode is a String type - Data is a CHAR16[x] type\r
769 // If the OpCode is a Checkbox type - Data is a UINT8 value\r
770 // If the OpCode is a NV Access type - Data is a FRAMEWORK_EFI_IFR_NV_DATA structure\r
0368663f 771 }\r
772\r
773 return IfrDataArray;\r
774}\r
775\r
a9d85320 776/**\r
777 If a NvMapOverride is passed in to EFI_FORM_BROWSER_PROTOCOL.SendForm, the Form Browser\r
778 needs to be informed when data changed in NvMapOverride. This function will invoke\r
779 SetBrowserData () to set internal data of Form Browser.\r
780\r
781 @param ConfigAccess The Config Access Private Context.\r
782 @param QuestionId The Question Id that invokes the callback.\r
783 \r
784\r
785**/\r
133a9dfb 786VOID\r
787SyncBrowserDataForNvMapOverride (\r
a9d85320 788 IN CONST CONFIG_ACCESS_PRIVATE *ConfigAccess,\r
789 IN EFI_QUESTION_ID QuestionId\r
133a9dfb 790 )\r
791{\r
a9d85320 792 FORMSET_STORAGE *BufferStorage;\r
133a9dfb 793 EFI_STATUS Status;\r
794 UINTN BrowserDataSize;\r
795\r
796 if (ConfigAccess->ThunkContext->NvMapOverride != NULL) {\r
a9d85320 797\r
798 BufferStorage = GetStorageFromQuestionId (ConfigAccess->ThunkContext->FormSet, QuestionId);\r
799\r
800 if (BufferStorage == NULL) {\r
801 //\r
802 // QuestionId is a statement without Storage.\r
803 // 1) It is a Goto. \r
804 // \r
805 //\r
806 BufferStorage = GetFirstStorageOfFormSet (ConfigAccess->ThunkContext->FormSet);\r
807 }\r
808\r
809 //\r
810 // If NvMapOverride is not NULL, this Form must have at least one Buffer Type Variable Storage.\r
811 //\r
812 ASSERT (BufferStorage != NULL);\r
133a9dfb 813 \r
a9d85320 814 BrowserDataSize = BufferStorage->Size;\r
133a9dfb 815\r
a9d85320 816 Status = SetBrowserData (&BufferStorage->Guid, BufferStorage->Name, BrowserDataSize, ConfigAccess->ThunkContext->NvMapOverride, NULL);\r
133a9dfb 817 ASSERT_EFI_ERROR (Status);\r
818 }\r
819\r
820}\r
821\r
a9d85320 822/**\r
823 Free up resource allocated for a FRAMEWORK_EFI_IFR_DATA_ARRAY by CreateIfrDataArray ().\r
824\r
825 @param Array The FRAMEWORK_EFI_IFR_DATA_ARRAY allocated.\r
826 @param NvMapAllocated If the NvRamMap is allocated for FRAMEWORK_EFI_IFR_DATA_ARRAY.\r
827\r
828**/\r
0368663f 829VOID\r
830DestroyIfrDataArray (\r
831 IN FRAMEWORK_EFI_IFR_DATA_ARRAY *Array,\r
832 IN BOOLEAN NvMapAllocated\r
833 )\r
834{\r
d4775f2a 835 if (Array != NULL) {\r
836 if (NvMapAllocated) {\r
837 FreePool (Array->NvRamMap);\r
838 }\r
0368663f 839\r
d4775f2a 840 FreePool (Array);\r
841 }\r
0368663f 842}\r
843\r
a9d85320 844/**\r
845 Get the ONE_OF_OPTION_MAP_ENTRY for a QuestionId that invokes the \r
846 EFI_FORM_CALLBACK_PROTOCOL.Callback. The information is needed as\r
847 the callback mechanism for EFI_IFR_ONE_OF_OPTION is changed from \r
848 EFI_IFR_ONE_OF_OPTION in Framework IFR. Check EFI_IFR_GUID_OPTIONKEY\r
849 for detailed information.\r
850\r
851 @param ThunkContext The Thunk Context.\r
852 @param QuestionId The Question Id.\r
853 @param Type The Question Type.\r
854 @param Value The One Of Option's value.\r
855\r
856 @return The ONE_OF_OPTION_MAP_ENTRY found.\r
857 @retval NULL If no entry is found.\r
858**/\r
0368663f 859ONE_OF_OPTION_MAP_ENTRY *\r
860GetOneOfOptionMapEntry (\r
861 IN HII_THUNK_CONTEXT *ThunkContext,\r
862 IN EFI_QUESTION_ID QuestionId,\r
863 IN UINT8 Type,\r
864 IN EFI_IFR_TYPE_VALUE *Value\r
865 )\r
866{\r
867 LIST_ENTRY *Link;\r
868 LIST_ENTRY *Link2;\r
869 ONE_OF_OPTION_MAP_ENTRY *OneOfOptionMapEntry;\r
870 ONE_OF_OPTION_MAP *OneOfOptionMap;\r
a9d85320 871 FORM_BROWSER_FORMSET *FormSet;\r
0368663f 872\r
a9d85320 873 FormSet = ThunkContext->FormSet;\r
0368663f 874\r
a9d85320 875 Link = GetFirstNode (&FormSet->OneOfOptionMapListHead);\r
876\r
877 while (!IsNull (&FormSet->OneOfOptionMapListHead, Link)) {\r
0368663f 878 OneOfOptionMap = ONE_OF_OPTION_MAP_FROM_LINK(Link);\r
879 if (OneOfOptionMap->QuestionId == QuestionId) {\r
880 ASSERT (OneOfOptionMap->ValueType == Type);\r
881\r
882 Link2 = GetFirstNode (&OneOfOptionMap->OneOfOptionMapEntryListHead);\r
883\r
884 while (!IsNull (&OneOfOptionMap->OneOfOptionMapEntryListHead, Link2)) {\r
885 OneOfOptionMapEntry = ONE_OF_OPTION_MAP_ENTRY_FROM_LINK (Link2);\r
886\r
887 if (CompareMem (Value, &OneOfOptionMapEntry->Value, sizeof (EFI_IFR_TYPE_VALUE)) == 0) {\r
888 return OneOfOptionMapEntry;\r
889 }\r
890\r
891 Link2 = GetNextNode (&OneOfOptionMap->OneOfOptionMapEntryListHead, Link2);\r
892 }\r
893 }\r
894\r
a9d85320 895 Link = GetNextNode (&FormSet->OneOfOptionMapListHead, Link);\r
0368663f 896 }\r
897\r
898\r
899 return NULL;\r
900}\r
901\r
902/**\r
903 Functions which are registered to receive notification of\r
904 database events have this prototype. The actual event is encoded\r
905 in NotifyType. The following table describes how PackageType,\r
906 PackageGuid, Handle, and Package are used for each of the\r
907 notification types.\r
908\r
a9d85320 909 If any Pakcage List in database is updated, mHiiPackageListUpdated\r
910 will be set. If mHiiPackageListUpdated is set, Framework ThunkCallback()\r
911 will force the UEFI Setup Browser to save the uncommitted data. This\r
912 is needed as Framework's Callback function may dynamically update\r
913 opcode in a Package List. UEFI Setup Browser will quit itself and reparse\r
914 the Package List's IFR and display it. UEFI Config Access's implementation\r
915 is required to save the modified (SetBrowserData or directly save the data\r
916 to NV storage). But Framework HII Modules is not aware of this rule. Therefore,\r
917 we will enforce the rule in ThunkCallback (). The side effect of force saving\r
918 of NV data is the NV flag in browser may not flag a update as data has already\r
919 been saved to NV storage.\r
920\r
0368663f 921 @param PackageType Package type of the notification.\r
922\r
923 @param PackageGuid If PackageType is\r
924 EFI_HII_PACKAGE_TYPE_GUID, then this is\r
925 the pointer to the GUID from the Guid\r
926 field of EFI_HII_PACKAGE_GUID_HEADER.\r
927 Otherwise, it must be NULL.\r
928\r
929 @param Package Points to the package referred to by the\r
930 notification Handle The handle of the package\r
931 list which contains the specified package.\r
932\r
933 @param Handle The HII handle.\r
934\r
935 @param NotifyType The type of change concerning the\r
936 database. See\r
937 EFI_HII_DATABASE_NOTIFY_TYPE.\r
938\r
939**/\r
940EFI_STATUS\r
941EFIAPI\r
942FormUpdateNotify (\r
943 IN UINT8 PackageType,\r
944 IN CONST EFI_GUID *PackageGuid,\r
945 IN CONST EFI_HII_PACKAGE_HEADER *Package,\r
946 IN EFI_HII_HANDLE Handle,\r
947 IN EFI_HII_DATABASE_NOTIFY_TYPE NotifyType\r
948 )\r
949{\r
950 mHiiPackageListUpdated = TRUE;\r
951\r
952 return EFI_SUCCESS;\r
953}\r
954\r
1a6cdbd9 955/**\r
956 Wrap the EFI_HII_CONFIG_ACCESS_PROTOCOL.CallBack to EFI_FORM_CALLBACK_PROTOCOL.Callback. Therefor,\r
a9d85320 957 the framework HII module willl do no porting and work with a UEFI HII SetupBrowser.\r
1a6cdbd9 958 \r
0368663f 959 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
960 @param Action Specifies the type of action taken by the browser. See EFI_BROWSER_ACTION_x.\r
1a6cdbd9 961 @param QuestionId A unique value which is sent to the original exporting driver so that it can identify the\r
0368663f 962 type of data to expect. The format of the data tends to vary based on the opcode that\r
963 generated the callback.\r
964 @param Type The type of value for the question. See EFI_IFR_TYPE_x in\r
965 EFI_IFR_ONE_OF_OPTION.\r
966 @param Value A pointer to the data being sent to the original exporting driver. The type is specified\r
967 by Type. Type EFI_IFR_TYPE_VALUE is defined in\r
968 EFI_IFR_ONE_OF_OPTION.\r
1a6cdbd9 969 @param ActionRequest On return, points to the action requested by the callback function. Type\r
0368663f 970 EFI_BROWSER_ACTION_REQUEST is specified in SendForm() in the Form\r
971 Browser Protocol.\r
1a6cdbd9 972 \r
0368663f 973 @retval EFI_UNSUPPORTED If the Framework HII module does not register Callback although it specify the opcode under\r
974 focuse to be INTERRACTIVE.\r
1a6cdbd9 975 @retval EFI_SUCCESS The callback complete successfully.\r
976 @retval !EFI_SUCCESS The error code returned by EFI_FORM_CALLBACK_PROTOCOL.Callback.\r
977 \r
978 **/\r
ebbd2793 979EFI_STATUS\r
980EFIAPI\r
981ThunkCallback (\r
982 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r
983 IN EFI_BROWSER_ACTION Action,\r
984 IN EFI_QUESTION_ID QuestionId,\r
985 IN UINT8 Type,\r
986 IN EFI_IFR_TYPE_VALUE *Value,\r
987 OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest\r
988 )\r
989{\r
990 EFI_STATUS Status;\r
0368663f 991 CONFIG_ACCESS_PRIVATE *ConfigAccess;\r
992 EFI_FORM_CALLBACK_PROTOCOL *FormCallbackProtocol;\r
ebbd2793 993 EFI_HII_CALLBACK_PACKET *Packet;\r
0368663f 994 FRAMEWORK_EFI_IFR_DATA_ARRAY *Data;\r
ebbd2793 995 FRAMEWORK_EFI_IFR_DATA_ENTRY *DataEntry;\r
0368663f 996 UINT16 KeyValue;\r
997 ONE_OF_OPTION_MAP_ENTRY *OneOfOptionMapEntry;\r
998 EFI_HANDLE NotifyHandle;\r
999 EFI_INPUT_KEY Key; \r
1000 BOOLEAN NvMapAllocated;\r
ebbd2793 1001\r
1002 ASSERT (This != NULL);\r
1003 ASSERT (Value != NULL);\r
1004 ASSERT (ActionRequest != NULL);\r
1005\r
1006 *ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;\r
1007\r
0368663f 1008 ConfigAccess = CONFIG_ACCESS_PRIVATE_FROM_PROTOCOL (This);\r
ebbd2793 1009\r
0368663f 1010 FormCallbackProtocol = ConfigAccess->FormCallbackProtocol;\r
1011 if (FormCallbackProtocol == NULL) {\r
1012 ASSERT (FALSE);\r
ebbd2793 1013 return EFI_UNSUPPORTED;\r
1014 }\r
ebbd2793 1015\r
0368663f 1016 //\r
1017 // Check if the QuestionId match a OneOfOption.\r
1018 //\r
1019 OneOfOptionMapEntry = GetOneOfOptionMapEntry (ConfigAccess->ThunkContext, QuestionId, Type, Value);\r
1020\r
1021 if (OneOfOptionMapEntry == NULL) {\r
1022 //\r
1023 // This is not a One-Of-Option opcode. QuestionId is the KeyValue\r
1024 //\r
1025 KeyValue = QuestionId;\r
1026 } else {\r
a9d85320 1027 //\r
1028 // Otherwise, use the original Key specified in One Of Option in the Framework VFR syntax.\r
1029 //\r
0368663f 1030 KeyValue = OneOfOptionMapEntry->FwKey;\r
1031 }\r
1032\r
1033 //\r
1034 // Build the FRAMEWORK_EFI_IFR_DATA_ARRAY\r
1035 //\r
1036 Data = CreateIfrDataArray (ConfigAccess, QuestionId, Type, Value, &NvMapAllocated);\r
1037\r
1038 Status = mHiiDatabase->RegisterPackageNotify (\r
1039 mHiiDatabase,\r
4dd76ade 1040 EFI_HII_PACKAGE_FORMS,\r
0368663f 1041 NULL,\r
1042 FormUpdateNotify,\r
1043 EFI_HII_DATABASE_NOTIFY_REMOVE_PACK,\r
1044 &NotifyHandle\r
1045 );\r
1046 //\r
a9d85320 1047 //Call the Framework Callback function.\r
0368663f 1048 //\r
1049 Packet = NULL;\r
1050 Status = FormCallbackProtocol->Callback (\r
1051 FormCallbackProtocol,\r
1052 KeyValue,\r
1053 Data,\r
ebbd2793 1054 &Packet\r
1055 );\r
a9d85320 1056 SyncBrowserDataForNvMapOverride (ConfigAccess, QuestionId);\r
ebbd2793 1057\r
1058 //\r
1059 // Callback require browser to perform action\r
1060 //\r
0368663f 1061 if (EFI_ERROR (Status)) {\r
1062 if (Packet != NULL) {\r
0368663f 1063 do {\r
1064 IfrLibCreatePopUp (1, &Key, Packet->String);\r
0368663f 1065 } while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);\r
ebbd2793 1066 }\r
0368663f 1067 //\r
1068 // Error Code in Status is discarded.\r
1069 //\r
1070 } else {\r
1071 if (Packet != NULL) {\r
1072 if (Packet->DataArray.EntryCount == 1 && Packet->DataArray.NvRamMap == NULL) {\r
1073 DataEntry = (FRAMEWORK_EFI_IFR_DATA_ENTRY *) ((UINT8 *) Packet + sizeof (FRAMEWORK_EFI_IFR_DATA_ARRAY));\r
1074 if ((DataEntry->Flags & EXIT_REQUIRED) == EXIT_REQUIRED) {\r
1075 *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT;\r
1076 }\r
1077\r
1078 if ((DataEntry->Flags & SAVE_REQUIRED) == SAVE_REQUIRED) {\r
1079 Status = ConfigAccess->ConfigAccessProtocol.RouteConfig (\r
1080 &ConfigAccess->ConfigAccessProtocol,\r
1081 NULL,\r
1082 NULL\r
1083 );\r
1084 }\r
1085 }\r
1086 FreePool (Packet);\r
1087 }\r
1088 }\r
1089\r
1090 //\r
1091 // Unregister notify for Form package update\r
1092 //\r
1093 Status = mHiiDatabase->UnregisterPackageNotify (\r
1094 mHiiDatabase,\r
1095 NotifyHandle\r
1096 );\r
1097 //\r
a3318eaf 1098 // UEFI SetupBrowser behaves differently with Framework SetupBrowser when call back function \r
0368663f 1099 // update any forms in HII database. UEFI SetupBrowser will re-parse the displaying form package and load\r
1100 // the values from variable storages. Framework SetupBrowser will only re-parse the displaying form packages.\r
1101 // To make sure customer's previous changes is saved and the changing question behaves as expected, we\r
1102 // issue a EFI_BROWSER_ACTION_REQUEST_SUBMIT to ask UEFI SetupBrowser to save the changes proceed to re-parse\r
1103 // the form and load all the variable storages.\r
1104 //\r
1105 if (*ActionRequest == EFI_BROWSER_ACTION_REQUEST_NONE && mHiiPackageListUpdated) {\r
a9d85320 1106 mHiiPackageListUpdated= FALSE;\r
0368663f 1107 *ActionRequest = EFI_BROWSER_ACTION_REQUEST_SUBMIT;\r
fed39e58 1108 } else {\r
a9d85320 1109 if (ConfigAccess->ThunkContext->FormSet->SubClass == EFI_FRONT_PAGE_SUBCLASS ||\r
1110 ConfigAccess->ThunkContext->FormSet->SubClass == EFI_SINGLE_USE_SUBCLASS) {\r
fed39e58 1111 *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT;\r
1112 }\r
ebbd2793 1113 }\r
0368663f 1114\r
d4775f2a 1115\r
a9d85320 1116 //\r
1117 // Clean up.\r
1118 //\r
0368663f 1119 DestroyIfrDataArray (Data, NvMapAllocated);\r
ebbd2793 1120 \r
1121 return Status;\r
1122}\r
1123\r