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