+/**\r
+ Get question value from the predefined formset.\r
+\r
+ @param DevicePath The driver's device path which produece the formset data.\r
+ @param InputHiiHandle The hii handle associate with the formset data.\r
+ @param FormSetGuid The formset guid which include the question.\r
+ @param QuestionId The question id which need to get value from.\r
+ @param Value The return data about question's value.\r
+ \r
+ @retval TRUE Get the question value success.\r
+ @retval FALSE Get the question value failed.\r
+**/\r
+BOOLEAN \r
+GetQuestionValueFromForm (\r
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
+ IN EFI_HII_HANDLE InputHiiHandle,\r
+ IN EFI_GUID *FormSetGuid,\r
+ IN EFI_QUESTION_ID QuestionId,\r
+ OUT EFI_HII_VALUE *Value\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_HANDLE DriverHandle;\r
+ EFI_HANDLE Handle;\r
+ EFI_HII_HANDLE *HiiHandles;\r
+ EFI_HII_HANDLE HiiHandle;\r
+ UINTN Index;\r
+ FORM_BROWSER_STATEMENT *Question;\r
+ FORM_BROWSER_FORMSET *FormSet;\r
+ FORM_BROWSER_FORM *Form;\r
+ BOOLEAN GetTheVal;\r
+ LIST_ENTRY *Link;\r
+\r
+ // \r
+ // The input parameter DevicePath or InputHiiHandle must have one valid input. \r
+ //\r
+ ASSERT ((DevicePath != NULL && InputHiiHandle == NULL) || \r
+ (DevicePath == NULL && InputHiiHandle != NULL) );\r
+\r
+ GetTheVal = TRUE;\r
+ DriverHandle = NULL;\r
+ HiiHandle = NULL;\r
+ Question = NULL;\r
+ Form = NULL;\r
+\r
+ //\r
+ // Get HiiHandle.\r
+ //\r
+ if (DevicePath != NULL) {\r
+ //\r
+ // 1. Get Driver handle.\r
+ //\r
+ Status = gBS->LocateDevicePath (\r
+ &gEfiDevicePathProtocolGuid,\r
+ &DevicePath,\r
+ &DriverHandle\r
+ );\r
+ if (EFI_ERROR (Status) || (DriverHandle == NULL)) {\r
+ return FALSE;\r
+ }\r
+\r
+ //\r
+ // 2. Get Hii handle\r
+ //\r
+ HiiHandles = HiiGetHiiHandles (NULL);\r
+ if (HiiHandles == NULL) {\r
+ return FALSE;\r
+ }\r
+\r
+ for (Index = 0; HiiHandles[Index] != NULL; Index++) {\r
+ Status = mHiiDatabase->GetPackageListHandle (\r
+ mHiiDatabase,\r
+ HiiHandles[Index],\r
+ &Handle\r
+ );\r
+ if (!EFI_ERROR (Status) && (Handle == DriverHandle)) {\r
+ HiiHandle = HiiHandles[Index];\r
+ break;\r
+ }\r
+ }\r
+ FreePool (HiiHandles);\r
+ } else {\r
+ HiiHandle = InputHiiHandle;\r
+ } \r
+ ASSERT (HiiHandle != NULL);\r
+\r
+ //\r
+ // Get the formset data include this question.\r
+ //\r
+ FormSet = AllocateZeroPool (sizeof (FORM_BROWSER_FORMSET));\r
+ ASSERT (FormSet != NULL);\r
+ Status = InitializeFormSet(HiiHandle, FormSetGuid, FormSet, FALSE);\r
+ if (EFI_ERROR (Status)) {\r
+ GetTheVal = FALSE;\r
+ goto Done;\r
+ }\r
+\r
+ //\r
+ // Base on the Question Id to get the question info.\r
+ // \r
+ Question = IdToQuestion(FormSet, NULL, QuestionId);\r
+ if (Question == NULL) {\r
+ GetTheVal = FALSE;\r
+ goto Done;\r
+ }\r
+\r
+ //\r
+ // Search form in the formset scope\r
+ //\r
+ Link = GetFirstNode (&FormSet->FormListHead);\r
+ while (!IsNull (&FormSet->FormListHead, Link)) {\r
+ Form = FORM_BROWSER_FORM_FROM_LINK (Link);\r
+\r
+ Question = IdToQuestion2 (Form, QuestionId);\r
+ if (Question != NULL) {\r
+ break;\r
+ }\r
+\r
+ Link = GetNextNode (&FormSet->FormListHead, Link);\r
+ Form = NULL;\r
+ }\r
+ ASSERT (Form != NULL);\r
+ \r
+ //\r
+ // Get the question value.\r
+ //\r
+ Status = GetQuestionValue(FormSet, Form, Question, FALSE);\r
+ if (EFI_ERROR (Status)) {\r
+ GetTheVal = FALSE;\r
+ goto Done;\r
+ }\r
+\r
+ CopyMem (Value, &Question->HiiValue, sizeof (EFI_HII_VALUE));\r
+ \r
+Done:\r
+ //\r
+ // Clean the formset structure and restore the global parameter.\r
+ //\r
+ if (FormSet != NULL) {\r
+ DestroyFormSet (FormSet);\r
+ }\r
+ \r
+ return GetTheVal;\r
+}\r
+\r