]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Compatibility/FrameworkHiiOnUefiHiiThunk/ConfigAccess.c
Pass correct device path to uninstall the handle on which default config access proto...
[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
677 UINTN StringSize;\r
678 EFI_STRING String;\r
679\r
a9d85320 680 *NvMapAllocated = FALSE;\r
0368663f 681\r
a9d85320 682 String = NULL;\r
286f0de7 683\r
684 switch (Type) {\r
685 case EFI_IFR_TYPE_NUM_SIZE_8:\r
686 case EFI_IFR_TYPE_NUM_SIZE_16:\r
687 case EFI_IFR_TYPE_NUM_SIZE_32:\r
688 case EFI_IFR_TYPE_NUM_SIZE_64:\r
689 case EFI_IFR_TYPE_BOOLEAN:\r
690 Size = sizeof (*Value);\r
691 break;\r
692\r
693 case EFI_IFR_TYPE_STRING:\r
694 StringSize = 0;\r
695 Status = HiiLibGetString (ConfigAccess->ThunkContext->UefiHiiHandle, Value->string, String, &StringSize);\r
696 ASSERT (Status == EFI_BUFFER_TOO_SMALL);\r
697\r
698 String = AllocateZeroPool (StringSize);\r
699 ASSERT (String != NULL);\r
700\r
701 Status = HiiLibGetString (ConfigAccess->ThunkContext->UefiHiiHandle, Value->string, String, &StringSize);\r
702 ASSERT_EFI_ERROR (Status);\r
703\r
704 Size = StringSize;\r
705 break;\r
706 \r
707 default:\r
708 ASSERT (FALSE);\r
709 Size = 0;\r
710 break;\r
711 }\r
712\r
713 IfrDataArray = AllocateZeroPool (sizeof (FRAMEWORK_EFI_IFR_DATA_ARRAY) + sizeof (FRAMEWORK_EFI_IFR_DATA_ENTRY) + Size);\r
0368663f 714 ASSERT (IfrDataArray != NULL);\r
715\r
a9d85320 716 BufferStorage = GetStorageFromQuestionId (ConfigAccess->ThunkContext->FormSet, QuestionId);\r
0368663f 717\r
a9d85320 718 if (BufferStorage == NULL) {\r
719 //\r
720 // The QuestionId is not associated with a Buffer Storage.\r
721 // Try to get the first Buffer Storage then.\r
722 //\r
723 BufferStorage = GetFirstStorageOfFormSet (ConfigAccess->ThunkContext->FormSet);\r
0368663f 724 }\r
133a9dfb 725 \r
a9d85320 726 if (BufferStorage != NULL) {\r
727 BrowserDataSize = BufferStorage->Size;\r
0368663f 728\r
a9d85320 729 if (ConfigAccess->ThunkContext->NvMapOverride == NULL) {\r
730 *NvMapAllocated = TRUE;\r
731 IfrDataArray->NvRamMap = AllocateZeroPool (BrowserDataSize);\r
732 } else {\r
733 *NvMapAllocated = FALSE;\r
734 IfrDataArray->NvRamMap = ConfigAccess->ThunkContext->NvMapOverride;\r
735 }\r
736 \r
737 Status = GetBrowserData (&BufferStorage->Guid, BufferStorage->Name, &BrowserDataSize, IfrDataArray->NvRamMap);\r
738 ASSERT_EFI_ERROR (Status);\r
0368663f 739\r
a9d85320 740 IfrDataEntry = (FRAMEWORK_EFI_IFR_DATA_ENTRY *) (IfrDataArray + 1);\r
0368663f 741\r
a9d85320 742 switch (Type) {\r
743 case EFI_IFR_TYPE_NUM_SIZE_8:\r
744 case EFI_IFR_TYPE_NUM_SIZE_16:\r
745 case EFI_IFR_TYPE_NUM_SIZE_32:\r
746 case EFI_IFR_TYPE_NUM_SIZE_64:\r
747 case EFI_IFR_TYPE_BOOLEAN:\r
748 CopyMem (&IfrDataEntry->Data, &(Value->u8), sizeof (*Value));\r
749 break;\r
750\r
751 case EFI_IFR_TYPE_STRING:\r
752 ASSERT (String != NULL);\r
753 StrCpy ((CHAR16 *) &IfrDataEntry->Data, String);\r
754 FreePool (String);\r
755 break;\r
756 default:\r
757 ASSERT (FALSE);\r
758 break;\r
759 }\r
760\r
761 //\r
762 // Need to fiil in the information for the rest of field for FRAMEWORK_EFI_IFR_DATA_ENTRY.\r
763 // It seems that no implementation is found to use other fields. Leave them uninitialized for now.\r
764 //\r
765 //UINT8 OpCode; // Likely a string, numeric, or one-of\r
766 //UINT8 Length; // Length of the FRAMEWORK_EFI_IFR_DATA_ENTRY packet\r
767 //UINT16 Flags; // Flags settings to determine what behavior is desired from the browser after the callback\r
768 //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
769 // If the OpCode is a OneOf or Numeric type - Data is a UINT16 value\r
770 // If the OpCode is a String type - Data is a CHAR16[x] type\r
771 // If the OpCode is a Checkbox type - Data is a UINT8 value\r
772 // If the OpCode is a NV Access type - Data is a FRAMEWORK_EFI_IFR_NV_DATA structure\r
0368663f 773 }\r
774\r
775 return IfrDataArray;\r
776}\r
777\r
a9d85320 778/**\r
779 If a NvMapOverride is passed in to EFI_FORM_BROWSER_PROTOCOL.SendForm, the Form Browser\r
780 needs to be informed when data changed in NvMapOverride. This function will invoke\r
781 SetBrowserData () to set internal data of Form Browser.\r
782\r
783 @param ConfigAccess The Config Access Private Context.\r
784 @param QuestionId The Question Id that invokes the callback.\r
785 \r
786\r
787**/\r
133a9dfb 788VOID\r
789SyncBrowserDataForNvMapOverride (\r
a9d85320 790 IN CONST CONFIG_ACCESS_PRIVATE *ConfigAccess,\r
791 IN EFI_QUESTION_ID QuestionId\r
133a9dfb 792 )\r
793{\r
a9d85320 794 FORMSET_STORAGE *BufferStorage;\r
133a9dfb 795 EFI_STATUS Status;\r
796 UINTN BrowserDataSize;\r
797\r
798 if (ConfigAccess->ThunkContext->NvMapOverride != NULL) {\r
a9d85320 799\r
800 BufferStorage = GetStorageFromQuestionId (ConfigAccess->ThunkContext->FormSet, QuestionId);\r
801\r
802 if (BufferStorage == NULL) {\r
803 //\r
804 // QuestionId is a statement without Storage.\r
805 // 1) It is a Goto. \r
806 // \r
807 //\r
808 BufferStorage = GetFirstStorageOfFormSet (ConfigAccess->ThunkContext->FormSet);\r
809 }\r
810\r
811 //\r
812 // If NvMapOverride is not NULL, this Form must have at least one Buffer Type Variable Storage.\r
813 //\r
814 ASSERT (BufferStorage != NULL);\r
133a9dfb 815 \r
a9d85320 816 BrowserDataSize = BufferStorage->Size;\r
133a9dfb 817\r
a9d85320 818 Status = SetBrowserData (&BufferStorage->Guid, BufferStorage->Name, BrowserDataSize, ConfigAccess->ThunkContext->NvMapOverride, NULL);\r
133a9dfb 819 ASSERT_EFI_ERROR (Status);\r
820 }\r
821\r
822}\r
823\r
a9d85320 824/**\r
825 Free up resource allocated for a FRAMEWORK_EFI_IFR_DATA_ARRAY by CreateIfrDataArray ().\r
826\r
827 @param Array The FRAMEWORK_EFI_IFR_DATA_ARRAY allocated.\r
828 @param NvMapAllocated If the NvRamMap is allocated for FRAMEWORK_EFI_IFR_DATA_ARRAY.\r
829\r
830**/\r
0368663f 831VOID\r
832DestroyIfrDataArray (\r
833 IN FRAMEWORK_EFI_IFR_DATA_ARRAY *Array,\r
834 IN BOOLEAN NvMapAllocated\r
835 )\r
836{\r
d4775f2a 837 if (Array != NULL) {\r
838 if (NvMapAllocated) {\r
839 FreePool (Array->NvRamMap);\r
840 }\r
0368663f 841\r
d4775f2a 842 FreePool (Array);\r
843 }\r
0368663f 844}\r
845\r
a9d85320 846/**\r
847 Get the ONE_OF_OPTION_MAP_ENTRY for a QuestionId that invokes the \r
848 EFI_FORM_CALLBACK_PROTOCOL.Callback. The information is needed as\r
849 the callback mechanism for EFI_IFR_ONE_OF_OPTION is changed from \r
850 EFI_IFR_ONE_OF_OPTION in Framework IFR. Check EFI_IFR_GUID_OPTIONKEY\r
851 for detailed information.\r
852\r
853 @param ThunkContext The Thunk Context.\r
854 @param QuestionId The Question Id.\r
855 @param Type The Question Type.\r
856 @param Value The One Of Option's value.\r
857\r
858 @return The ONE_OF_OPTION_MAP_ENTRY found.\r
859 @retval NULL If no entry is found.\r
860**/\r
0368663f 861ONE_OF_OPTION_MAP_ENTRY *\r
862GetOneOfOptionMapEntry (\r
863 IN HII_THUNK_CONTEXT *ThunkContext,\r
864 IN EFI_QUESTION_ID QuestionId,\r
865 IN UINT8 Type,\r
866 IN EFI_IFR_TYPE_VALUE *Value\r
867 )\r
868{\r
869 LIST_ENTRY *Link;\r
870 LIST_ENTRY *Link2;\r
871 ONE_OF_OPTION_MAP_ENTRY *OneOfOptionMapEntry;\r
872 ONE_OF_OPTION_MAP *OneOfOptionMap;\r
a9d85320 873 FORM_BROWSER_FORMSET *FormSet;\r
0368663f 874\r
a9d85320 875 FormSet = ThunkContext->FormSet;\r
0368663f 876\r
a9d85320 877 Link = GetFirstNode (&FormSet->OneOfOptionMapListHead);\r
878\r
879 while (!IsNull (&FormSet->OneOfOptionMapListHead, Link)) {\r
0368663f 880 OneOfOptionMap = ONE_OF_OPTION_MAP_FROM_LINK(Link);\r
881 if (OneOfOptionMap->QuestionId == QuestionId) {\r
882 ASSERT (OneOfOptionMap->ValueType == Type);\r
883\r
884 Link2 = GetFirstNode (&OneOfOptionMap->OneOfOptionMapEntryListHead);\r
885\r
886 while (!IsNull (&OneOfOptionMap->OneOfOptionMapEntryListHead, Link2)) {\r
887 OneOfOptionMapEntry = ONE_OF_OPTION_MAP_ENTRY_FROM_LINK (Link2);\r
888\r
889 if (CompareMem (Value, &OneOfOptionMapEntry->Value, sizeof (EFI_IFR_TYPE_VALUE)) == 0) {\r
890 return OneOfOptionMapEntry;\r
891 }\r
892\r
893 Link2 = GetNextNode (&OneOfOptionMap->OneOfOptionMapEntryListHead, Link2);\r
894 }\r
895 }\r
896\r
a9d85320 897 Link = GetNextNode (&FormSet->OneOfOptionMapListHead, Link);\r
0368663f 898 }\r
899\r
900\r
901 return NULL;\r
902}\r
903\r
904/**\r
905 Functions which are registered to receive notification of\r
906 database events have this prototype. The actual event is encoded\r
907 in NotifyType. The following table describes how PackageType,\r
908 PackageGuid, Handle, and Package are used for each of the\r
909 notification types.\r
910\r
a9d85320 911 If any Pakcage List in database is updated, mHiiPackageListUpdated\r
912 will be set. If mHiiPackageListUpdated is set, Framework ThunkCallback()\r
913 will force the UEFI Setup Browser to save the uncommitted data. This\r
914 is needed as Framework's Callback function may dynamically update\r
915 opcode in a Package List. UEFI Setup Browser will quit itself and reparse\r
916 the Package List's IFR and display it. UEFI Config Access's implementation\r
917 is required to save the modified (SetBrowserData or directly save the data\r
918 to NV storage). But Framework HII Modules is not aware of this rule. Therefore,\r
919 we will enforce the rule in ThunkCallback (). The side effect of force saving\r
920 of NV data is the NV flag in browser may not flag a update as data has already\r
921 been saved to NV storage.\r
922\r
0368663f 923 @param PackageType Package type of the notification.\r
924\r
925 @param PackageGuid If PackageType is\r
926 EFI_HII_PACKAGE_TYPE_GUID, then this is\r
927 the pointer to the GUID from the Guid\r
928 field of EFI_HII_PACKAGE_GUID_HEADER.\r
929 Otherwise, it must be NULL.\r
930\r
931 @param Package Points to the package referred to by the\r
932 notification Handle The handle of the package\r
933 list which contains the specified package.\r
934\r
935 @param Handle The HII handle.\r
936\r
937 @param NotifyType The type of change concerning the\r
938 database. See\r
939 EFI_HII_DATABASE_NOTIFY_TYPE.\r
940\r
941**/\r
942EFI_STATUS\r
943EFIAPI\r
944FormUpdateNotify (\r
945 IN UINT8 PackageType,\r
946 IN CONST EFI_GUID *PackageGuid,\r
947 IN CONST EFI_HII_PACKAGE_HEADER *Package,\r
948 IN EFI_HII_HANDLE Handle,\r
949 IN EFI_HII_DATABASE_NOTIFY_TYPE NotifyType\r
950 )\r
951{\r
952 mHiiPackageListUpdated = TRUE;\r
953\r
954 return EFI_SUCCESS;\r
955}\r
956\r
1a6cdbd9 957/**\r
958 Wrap the EFI_HII_CONFIG_ACCESS_PROTOCOL.CallBack to EFI_FORM_CALLBACK_PROTOCOL.Callback. Therefor,\r
a9d85320 959 the framework HII module willl do no porting and work with a UEFI HII SetupBrowser.\r
1a6cdbd9 960 \r
0368663f 961 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
962 @param Action Specifies the type of action taken by the browser. See EFI_BROWSER_ACTION_x.\r
1a6cdbd9 963 @param QuestionId A unique value which is sent to the original exporting driver so that it can identify the\r
0368663f 964 type of data to expect. The format of the data tends to vary based on the opcode that\r
965 generated the callback.\r
966 @param Type The type of value for the question. See EFI_IFR_TYPE_x in\r
967 EFI_IFR_ONE_OF_OPTION.\r
968 @param Value A pointer to the data being sent to the original exporting driver. The type is specified\r
969 by Type. Type EFI_IFR_TYPE_VALUE is defined in\r
970 EFI_IFR_ONE_OF_OPTION.\r
1a6cdbd9 971 @param ActionRequest On return, points to the action requested by the callback function. Type\r
0368663f 972 EFI_BROWSER_ACTION_REQUEST is specified in SendForm() in the Form\r
973 Browser Protocol.\r
1a6cdbd9 974 \r
0368663f 975 @retval EFI_UNSUPPORTED If the Framework HII module does not register Callback although it specify the opcode under\r
976 focuse to be INTERRACTIVE.\r
1a6cdbd9 977 @retval EFI_SUCCESS The callback complete successfully.\r
978 @retval !EFI_SUCCESS The error code returned by EFI_FORM_CALLBACK_PROTOCOL.Callback.\r
979 \r
980 **/\r
ebbd2793 981EFI_STATUS\r
982EFIAPI\r
983ThunkCallback (\r
984 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r
985 IN EFI_BROWSER_ACTION Action,\r
986 IN EFI_QUESTION_ID QuestionId,\r
987 IN UINT8 Type,\r
988 IN EFI_IFR_TYPE_VALUE *Value,\r
989 OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest\r
990 )\r
991{\r
992 EFI_STATUS Status;\r
0368663f 993 CONFIG_ACCESS_PRIVATE *ConfigAccess;\r
994 EFI_FORM_CALLBACK_PROTOCOL *FormCallbackProtocol;\r
ebbd2793 995 EFI_HII_CALLBACK_PACKET *Packet;\r
0368663f 996 FRAMEWORK_EFI_IFR_DATA_ARRAY *Data;\r
ebbd2793 997 FRAMEWORK_EFI_IFR_DATA_ENTRY *DataEntry;\r
0368663f 998 UINT16 KeyValue;\r
999 ONE_OF_OPTION_MAP_ENTRY *OneOfOptionMapEntry;\r
1000 EFI_HANDLE NotifyHandle;\r
1001 EFI_INPUT_KEY Key; \r
1002 BOOLEAN NvMapAllocated;\r
ebbd2793 1003\r
1004 ASSERT (This != NULL);\r
1005 ASSERT (Value != NULL);\r
1006 ASSERT (ActionRequest != NULL);\r
1007\r
1008 *ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;\r
1009\r
0368663f 1010 ConfigAccess = CONFIG_ACCESS_PRIVATE_FROM_PROTOCOL (This);\r
ebbd2793 1011\r
0368663f 1012 FormCallbackProtocol = ConfigAccess->FormCallbackProtocol;\r
1013 if (FormCallbackProtocol == NULL) {\r
1014 ASSERT (FALSE);\r
ebbd2793 1015 return EFI_UNSUPPORTED;\r
1016 }\r
ebbd2793 1017\r
0368663f 1018 //\r
1019 // Check if the QuestionId match a OneOfOption.\r
1020 //\r
1021 OneOfOptionMapEntry = GetOneOfOptionMapEntry (ConfigAccess->ThunkContext, QuestionId, Type, Value);\r
1022\r
1023 if (OneOfOptionMapEntry == NULL) {\r
1024 //\r
1025 // This is not a One-Of-Option opcode. QuestionId is the KeyValue\r
1026 //\r
1027 KeyValue = QuestionId;\r
1028 } else {\r
a9d85320 1029 //\r
1030 // Otherwise, use the original Key specified in One Of Option in the Framework VFR syntax.\r
1031 //\r
0368663f 1032 KeyValue = OneOfOptionMapEntry->FwKey;\r
1033 }\r
1034\r
1035 //\r
1036 // Build the FRAMEWORK_EFI_IFR_DATA_ARRAY\r
1037 //\r
1038 Data = CreateIfrDataArray (ConfigAccess, QuestionId, Type, Value, &NvMapAllocated);\r
1039\r
1040 Status = mHiiDatabase->RegisterPackageNotify (\r
1041 mHiiDatabase,\r
4dd76ade 1042 EFI_HII_PACKAGE_FORMS,\r
0368663f 1043 NULL,\r
1044 FormUpdateNotify,\r
1045 EFI_HII_DATABASE_NOTIFY_REMOVE_PACK,\r
1046 &NotifyHandle\r
1047 );\r
1048 //\r
a9d85320 1049 //Call the Framework Callback function.\r
0368663f 1050 //\r
1051 Packet = NULL;\r
1052 Status = FormCallbackProtocol->Callback (\r
1053 FormCallbackProtocol,\r
1054 KeyValue,\r
1055 Data,\r
ebbd2793 1056 &Packet\r
1057 );\r
a9d85320 1058 SyncBrowserDataForNvMapOverride (ConfigAccess, QuestionId);\r
ebbd2793 1059\r
1060 //\r
1061 // Callback require browser to perform action\r
1062 //\r
0368663f 1063 if (EFI_ERROR (Status)) {\r
1064 if (Packet != NULL) {\r
0368663f 1065 do {\r
1066 IfrLibCreatePopUp (1, &Key, Packet->String);\r
0368663f 1067 } while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);\r
ebbd2793 1068 }\r
0368663f 1069 //\r
1070 // Error Code in Status is discarded.\r
1071 //\r
1072 } else {\r
1073 if (Packet != NULL) {\r
1074 if (Packet->DataArray.EntryCount == 1 && Packet->DataArray.NvRamMap == NULL) {\r
1075 DataEntry = (FRAMEWORK_EFI_IFR_DATA_ENTRY *) ((UINT8 *) Packet + sizeof (FRAMEWORK_EFI_IFR_DATA_ARRAY));\r
1076 if ((DataEntry->Flags & EXIT_REQUIRED) == EXIT_REQUIRED) {\r
1077 *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT;\r
1078 }\r
1079\r
1080 if ((DataEntry->Flags & SAVE_REQUIRED) == SAVE_REQUIRED) {\r
1081 Status = ConfigAccess->ConfigAccessProtocol.RouteConfig (\r
1082 &ConfigAccess->ConfigAccessProtocol,\r
1083 NULL,\r
1084 NULL\r
1085 );\r
1086 }\r
1087 }\r
1088 FreePool (Packet);\r
1089 }\r
1090 }\r
1091\r
1092 //\r
1093 // Unregister notify for Form package update\r
1094 //\r
1095 Status = mHiiDatabase->UnregisterPackageNotify (\r
1096 mHiiDatabase,\r
1097 NotifyHandle\r
1098 );\r
1099 //\r
a3318eaf 1100 // UEFI SetupBrowser behaves differently with Framework SetupBrowser when call back function \r
0368663f 1101 // update any forms in HII database. UEFI SetupBrowser will re-parse the displaying form package and load\r
1102 // the values from variable storages. Framework SetupBrowser will only re-parse the displaying form packages.\r
1103 // To make sure customer's previous changes is saved and the changing question behaves as expected, we\r
1104 // issue a EFI_BROWSER_ACTION_REQUEST_SUBMIT to ask UEFI SetupBrowser to save the changes proceed to re-parse\r
1105 // the form and load all the variable storages.\r
1106 //\r
1107 if (*ActionRequest == EFI_BROWSER_ACTION_REQUEST_NONE && mHiiPackageListUpdated) {\r
a9d85320 1108 mHiiPackageListUpdated= FALSE;\r
0368663f 1109 *ActionRequest = EFI_BROWSER_ACTION_REQUEST_SUBMIT;\r
fed39e58 1110 } else {\r
a9d85320 1111 if (ConfigAccess->ThunkContext->FormSet->SubClass == EFI_FRONT_PAGE_SUBCLASS ||\r
1112 ConfigAccess->ThunkContext->FormSet->SubClass == EFI_SINGLE_USE_SUBCLASS) {\r
fed39e58 1113 *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT;\r
1114 }\r
ebbd2793 1115 }\r
0368663f 1116\r
d4775f2a 1117\r
a9d85320 1118 //\r
1119 // Clean up.\r
1120 //\r
0368663f 1121 DestroyIfrDataArray (Data, NvMapAllocated);\r
ebbd2793 1122 \r
1123 return Status;\r
1124}\r
1125\r