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