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