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