FrontPageCustomizedUiSupport.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672
  1. /** @file
  2. This library class defines a set of interfaces to customize Ui module
  3. Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #include <Uefi.h>
  7. #include <Guid/MdeModuleHii.h>
  8. #include <Guid/GlobalVariable.h>
  9. #include <Protocol/HiiConfigAccess.h>
  10. #include <Protocol/HiiString.h>
  11. #include <Library/HiiLib.h>
  12. #include <Library/DebugLib.h>
  13. #include <Library/UefiLib.h>
  14. #include <Library/BaseMemoryLib.h>
  15. #include <Library/PcdLib.h>
  16. #include <Library/MemoryAllocationLib.h>
  17. #include <Library/UefiRuntimeServicesTableLib.h>
  18. #include <Library/UefiHiiServicesLib.h>
  19. #include <Library/DevicePathLib.h>
  20. #include <Library/UefiBootServicesTableLib.h>
  21. #include "FrontPageCustomizedUiSupport.h"
  22. //
  23. // This is the VFR compiler generated header file which defines the
  24. // string identifiers.
  25. //
  26. #define PRINTABLE_LANGUAGE_NAME_STRING_ID 0x0001
  27. #define UI_HII_DRIVER_LIST_SIZE 0x8
  28. #define FRONT_PAGE_KEY_CONTINUE 0x1000
  29. #define FRONT_PAGE_KEY_RESET 0x1001
  30. #define FRONT_PAGE_KEY_LANGUAGE 0x1002
  31. #define FRONT_PAGE_KEY_DRIVER 0x2000
  32. typedef struct {
  33. EFI_STRING_ID PromptId;
  34. EFI_STRING_ID HelpId;
  35. EFI_STRING_ID DevicePathId;
  36. EFI_GUID FormSetGuid;
  37. BOOLEAN EmptyLineAfter;
  38. } UI_HII_DRIVER_INSTANCE;
  39. CHAR8 *gLanguageString;
  40. EFI_STRING_ID *gLanguageToken;
  41. UI_HII_DRIVER_INSTANCE *gHiiDriverList;
  42. extern EFI_HII_HANDLE gStringPackHandle;
  43. UINT8 gCurrentLanguageIndex;
  44. /**
  45. Get next language from language code list (with separator ';').
  46. If LangCode is NULL, then ASSERT.
  47. If Lang is NULL, then ASSERT.
  48. @param LangCode On input: point to first language in the list. On
  49. output: point to next language in the list, or
  50. NULL if no more language in the list.
  51. @param Lang The first language in the list.
  52. **/
  53. VOID
  54. GetNextLanguage (
  55. IN OUT CHAR8 **LangCode,
  56. OUT CHAR8 *Lang
  57. )
  58. {
  59. UINTN Index;
  60. CHAR8 *StringPtr;
  61. ASSERT (LangCode != NULL);
  62. ASSERT (*LangCode != NULL);
  63. ASSERT (Lang != NULL);
  64. Index = 0;
  65. StringPtr = *LangCode;
  66. while (StringPtr[Index] != 0 && StringPtr[Index] != ';') {
  67. Index++;
  68. }
  69. CopyMem (Lang, StringPtr, Index);
  70. Lang[Index] = 0;
  71. if (StringPtr[Index] == ';') {
  72. Index++;
  73. }
  74. *LangCode = StringPtr + Index;
  75. }
  76. /**
  77. This function processes the language changes in configuration.
  78. @param Value A pointer to the data being sent to the original exporting driver.
  79. @retval TRUE The callback successfully handled the action.
  80. @retval FALSE The callback not supported in this handler.
  81. **/
  82. EFI_STATUS
  83. LanguageChangeHandler (
  84. IN EFI_IFR_TYPE_VALUE *Value
  85. )
  86. {
  87. CHAR8 *LangCode;
  88. CHAR8 *Lang;
  89. UINTN Index;
  90. EFI_STATUS Status;
  91. //
  92. // Allocate working buffer for RFC 4646 language in supported LanguageString.
  93. //
  94. Lang = AllocatePool (AsciiStrSize (gLanguageString));
  95. ASSERT (Lang != NULL);
  96. Index = 0;
  97. LangCode = gLanguageString;
  98. while (*LangCode != 0) {
  99. GetNextLanguage (&LangCode, Lang);
  100. if (Index == Value->u8) {
  101. gCurrentLanguageIndex = Value->u8;
  102. break;
  103. }
  104. Index++;
  105. }
  106. if (Index == Value->u8) {
  107. Status = gRT->SetVariable (
  108. L"PlatformLang",
  109. &gEfiGlobalVariableGuid,
  110. EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
  111. AsciiStrSize (Lang),
  112. Lang
  113. );
  114. if (EFI_ERROR (Status)) {
  115. FreePool (Lang);
  116. return EFI_DEVICE_ERROR;
  117. }
  118. } else {
  119. ASSERT (FALSE);
  120. }
  121. FreePool (Lang);
  122. return EFI_SUCCESS;
  123. }
  124. /**
  125. This function processes the results of changes in configuration.
  126. @param HiiHandle Points to the hii handle for this formset.
  127. @param Action Specifies the type of action taken by the browser.
  128. @param QuestionId A unique value which is sent to the original exporting driver
  129. so that it can identify the type of data to expect.
  130. @param Type The type of value for the question.
  131. @param Value A pointer to the data being sent to the original exporting driver.
  132. @param ActionRequest On return, points to the action requested by the callback function.
  133. @param Status Return the handle status.
  134. @retval TRUE The callback successfully handled the action.
  135. @retval FALSE The callback not supported in this handler.
  136. **/
  137. BOOLEAN
  138. UiSupportLibCallbackHandler (
  139. IN EFI_HII_HANDLE HiiHandle,
  140. IN EFI_BROWSER_ACTION Action,
  141. IN EFI_QUESTION_ID QuestionId,
  142. IN UINT8 Type,
  143. IN EFI_IFR_TYPE_VALUE *Value,
  144. OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest,
  145. OUT EFI_STATUS *Status
  146. )
  147. {
  148. if (QuestionId != FRONT_PAGE_KEY_CONTINUE &&
  149. QuestionId != FRONT_PAGE_KEY_RESET &&
  150. QuestionId != FRONT_PAGE_KEY_LANGUAGE) {
  151. return FALSE;
  152. }
  153. if (Action == EFI_BROWSER_ACTION_RETRIEVE) {
  154. if (QuestionId == FRONT_PAGE_KEY_LANGUAGE) {
  155. Value->u8 = gCurrentLanguageIndex;
  156. *Status = EFI_SUCCESS;
  157. } else {
  158. *Status = EFI_UNSUPPORTED;
  159. }
  160. return TRUE;
  161. }
  162. if (Action != EFI_BROWSER_ACTION_CHANGED) {
  163. //
  164. // Do nothing for other UEFI Action. Only do call back when data is changed.
  165. //
  166. *Status = EFI_UNSUPPORTED;
  167. return TRUE;
  168. }
  169. if (Action == EFI_BROWSER_ACTION_CHANGED) {
  170. if ((Value == NULL) || (ActionRequest == NULL)) {
  171. *Status = EFI_INVALID_PARAMETER;
  172. return TRUE;
  173. }
  174. *Status = EFI_SUCCESS;
  175. switch (QuestionId) {
  176. case FRONT_PAGE_KEY_CONTINUE:
  177. //
  178. // This is the continue - clear the screen and return an error to get out of FrontPage loop
  179. //
  180. *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT;
  181. break;
  182. case FRONT_PAGE_KEY_LANGUAGE:
  183. *Status = LanguageChangeHandler(Value);
  184. break;
  185. case FRONT_PAGE_KEY_RESET:
  186. //
  187. // Reset
  188. //
  189. gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);
  190. *Status = EFI_UNSUPPORTED;
  191. default:
  192. break;
  193. }
  194. }
  195. return TRUE;
  196. }
  197. /**
  198. Create Select language menu in the front page with oneof opcode.
  199. @param[in] HiiHandle The hii handle for the Uiapp driver.
  200. @param[in] StartOpCodeHandle The opcode handle to save the new opcode.
  201. **/
  202. VOID
  203. UiCreateLanguageMenu (
  204. IN EFI_HII_HANDLE HiiHandle,
  205. IN VOID *StartOpCodeHandle
  206. )
  207. {
  208. CHAR8 *LangCode;
  209. CHAR8 *Lang;
  210. UINTN LangSize;
  211. CHAR8 *CurrentLang;
  212. UINTN OptionCount;
  213. CHAR16 *StringBuffer;
  214. VOID *OptionsOpCodeHandle;
  215. UINTN StringSize;
  216. EFI_STATUS Status;
  217. EFI_HII_STRING_PROTOCOL *HiiString;
  218. Lang = NULL;
  219. StringBuffer = NULL;
  220. //
  221. // Init OpCode Handle and Allocate space for creation of UpdateData Buffer
  222. //
  223. OptionsOpCodeHandle = HiiAllocateOpCodeHandle ();
  224. ASSERT (OptionsOpCodeHandle != NULL);
  225. GetEfiGlobalVariable2 (L"PlatformLang", (VOID**)&CurrentLang, NULL);
  226. //
  227. // Get Support language list from variable.
  228. //
  229. GetEfiGlobalVariable2 (L"PlatformLangCodes", (VOID**)&gLanguageString, NULL);
  230. if (gLanguageString == NULL) {
  231. gLanguageString = AllocateCopyPool (
  232. AsciiStrSize ((CHAR8 *) PcdGetPtr (PcdUefiVariableDefaultPlatformLangCodes)),
  233. (CHAR8 *) PcdGetPtr (PcdUefiVariableDefaultPlatformLangCodes)
  234. );
  235. ASSERT (gLanguageString != NULL);
  236. }
  237. if (gLanguageToken == NULL) {
  238. //
  239. // Count the language list number.
  240. //
  241. LangCode = gLanguageString;
  242. Lang = AllocatePool (AsciiStrSize (gLanguageString));
  243. ASSERT (Lang != NULL);
  244. OptionCount = 0;
  245. while (*LangCode != 0) {
  246. GetNextLanguage (&LangCode, Lang);
  247. OptionCount ++;
  248. }
  249. //
  250. // Allocate extra 1 as the end tag.
  251. //
  252. gLanguageToken = AllocateZeroPool ((OptionCount + 1) * sizeof (EFI_STRING_ID));
  253. ASSERT (gLanguageToken != NULL);
  254. Status = gBS->LocateProtocol (&gEfiHiiStringProtocolGuid, NULL, (VOID **) &HiiString);
  255. ASSERT_EFI_ERROR (Status);
  256. LangCode = gLanguageString;
  257. OptionCount = 0;
  258. while (*LangCode != 0) {
  259. GetNextLanguage (&LangCode, Lang);
  260. StringSize = 0;
  261. Status = HiiString->GetString (HiiString, Lang, HiiHandle, PRINTABLE_LANGUAGE_NAME_STRING_ID, StringBuffer, &StringSize, NULL);
  262. if (Status == EFI_BUFFER_TOO_SMALL) {
  263. StringBuffer = AllocateZeroPool (StringSize);
  264. ASSERT (StringBuffer != NULL);
  265. Status = HiiString->GetString (HiiString, Lang, HiiHandle, PRINTABLE_LANGUAGE_NAME_STRING_ID, StringBuffer, &StringSize, NULL);
  266. ASSERT_EFI_ERROR (Status);
  267. }
  268. if (EFI_ERROR (Status)) {
  269. LangSize = AsciiStrSize (Lang);
  270. StringBuffer = AllocatePool (LangSize * sizeof (CHAR16));
  271. ASSERT (StringBuffer != NULL);
  272. AsciiStrToUnicodeStrS (Lang, StringBuffer, LangSize);
  273. }
  274. ASSERT (StringBuffer != NULL);
  275. gLanguageToken[OptionCount] = HiiSetString (HiiHandle, 0, StringBuffer, NULL);
  276. FreePool (StringBuffer);
  277. OptionCount++;
  278. }
  279. }
  280. ASSERT (gLanguageToken != NULL);
  281. LangCode = gLanguageString;
  282. OptionCount = 0;
  283. if (Lang == NULL) {
  284. Lang = AllocatePool (AsciiStrSize (gLanguageString));
  285. ASSERT (Lang != NULL);
  286. }
  287. while (*LangCode != 0) {
  288. GetNextLanguage (&LangCode, Lang);
  289. if (CurrentLang != NULL && AsciiStrCmp (Lang, CurrentLang) == 0) {
  290. HiiCreateOneOfOptionOpCode (
  291. OptionsOpCodeHandle,
  292. gLanguageToken[OptionCount],
  293. EFI_IFR_OPTION_DEFAULT,
  294. EFI_IFR_NUMERIC_SIZE_1,
  295. (UINT8) OptionCount
  296. );
  297. gCurrentLanguageIndex = (UINT8) OptionCount;
  298. } else {
  299. HiiCreateOneOfOptionOpCode (
  300. OptionsOpCodeHandle,
  301. gLanguageToken[OptionCount],
  302. 0,
  303. EFI_IFR_NUMERIC_SIZE_1,
  304. (UINT8) OptionCount
  305. );
  306. }
  307. OptionCount++;
  308. }
  309. if (CurrentLang != NULL) {
  310. FreePool (CurrentLang);
  311. }
  312. FreePool (Lang);
  313. HiiCreateOneOfOpCode (
  314. StartOpCodeHandle,
  315. FRONT_PAGE_KEY_LANGUAGE,
  316. 0,
  317. 0,
  318. STRING_TOKEN (STR_LANGUAGE_SELECT),
  319. STRING_TOKEN (STR_LANGUAGE_SELECT_HELP),
  320. EFI_IFR_FLAG_CALLBACK,
  321. EFI_IFR_NUMERIC_SIZE_1,
  322. OptionsOpCodeHandle,
  323. NULL
  324. );
  325. }
  326. /**
  327. Create continue menu in the front page.
  328. @param[in] HiiHandle The hii handle for the Uiapp driver.
  329. @param[in] StartOpCodeHandle The opcode handle to save the new opcode.
  330. **/
  331. VOID
  332. UiCreateContinueMenu (
  333. IN EFI_HII_HANDLE HiiHandle,
  334. IN VOID *StartOpCodeHandle
  335. )
  336. {
  337. HiiCreateActionOpCode (
  338. StartOpCodeHandle,
  339. FRONT_PAGE_KEY_CONTINUE,
  340. STRING_TOKEN (STR_CONTINUE_PROMPT),
  341. STRING_TOKEN (STR_CONTINUE_PROMPT),
  342. EFI_IFR_FLAG_CALLBACK,
  343. 0
  344. );
  345. }
  346. /**
  347. Create empty line menu in the front page.
  348. @param HiiHandle The hii handle for the Uiapp driver.
  349. @param StartOpCodeHandle The opcode handle to save the new opcode.
  350. **/
  351. VOID
  352. UiCreateEmptyLine (
  353. IN EFI_HII_HANDLE HiiHandle,
  354. IN VOID *StartOpCodeHandle
  355. )
  356. {
  357. HiiCreateSubTitleOpCode (StartOpCodeHandle, STRING_TOKEN (STR_NULL_STRING), 0, 0, 0);
  358. }
  359. /**
  360. Create Reset menu in the front page.
  361. @param[in] HiiHandle The hii handle for the Uiapp driver.
  362. @param[in] StartOpCodeHandle The opcode handle to save the new opcode.
  363. **/
  364. VOID
  365. UiCreateResetMenu (
  366. IN EFI_HII_HANDLE HiiHandle,
  367. IN VOID *StartOpCodeHandle
  368. )
  369. {
  370. HiiCreateActionOpCode (
  371. StartOpCodeHandle,
  372. FRONT_PAGE_KEY_RESET,
  373. STRING_TOKEN (STR_RESET_STRING),
  374. STRING_TOKEN (STR_RESET_STRING),
  375. EFI_IFR_FLAG_CALLBACK,
  376. 0
  377. );
  378. }
  379. /**
  380. Extract device path for given HII handle and class guid.
  381. @param Handle The HII handle.
  382. @retval NULL Fail to get the device path string.
  383. @return PathString Get the device path string.
  384. **/
  385. CHAR16 *
  386. ExtractDevicePathFromHiiHandle (
  387. IN EFI_HII_HANDLE Handle
  388. )
  389. {
  390. EFI_STATUS Status;
  391. EFI_HANDLE DriverHandle;
  392. ASSERT (Handle != NULL);
  393. if (Handle == NULL) {
  394. return NULL;
  395. }
  396. Status = gHiiDatabase->GetPackageListHandle (gHiiDatabase, Handle, &DriverHandle);
  397. if (EFI_ERROR (Status)) {
  398. return NULL;
  399. }
  400. return ConvertDevicePathToText(DevicePathFromHandle (DriverHandle), FALSE, FALSE);
  401. }
  402. /**
  403. Check whether this driver need to be shown in the front page.
  404. @param HiiHandle The hii handle for the driver.
  405. @param Guid The special guid for the driver which is the target.
  406. @param PromptId Return the prompt string id.
  407. @param HelpId Return the help string id.
  408. @param FormsetGuid Return the formset guid info.
  409. @retval EFI_SUCCESS Search the driver success
  410. **/
  411. BOOLEAN
  412. RequiredDriver (
  413. IN EFI_HII_HANDLE HiiHandle,
  414. IN EFI_GUID *Guid,
  415. OUT EFI_STRING_ID *PromptId,
  416. OUT EFI_STRING_ID *HelpId,
  417. OUT VOID *FormsetGuid
  418. )
  419. {
  420. EFI_STATUS Status;
  421. UINT8 ClassGuidNum;
  422. EFI_GUID *ClassGuid;
  423. EFI_IFR_FORM_SET *Buffer;
  424. UINTN BufferSize;
  425. UINT8 *Ptr;
  426. UINTN TempSize;
  427. BOOLEAN RetVal;
  428. Status = HiiGetFormSetFromHiiHandle(HiiHandle, &Buffer,&BufferSize);
  429. if (EFI_ERROR (Status)) {
  430. return FALSE;
  431. }
  432. RetVal = FALSE;
  433. TempSize = 0;
  434. Ptr = (UINT8 *) Buffer;
  435. while(TempSize < BufferSize) {
  436. TempSize += ((EFI_IFR_OP_HEADER *) Ptr)->Length;
  437. if (((EFI_IFR_OP_HEADER *) Ptr)->Length <= OFFSET_OF (EFI_IFR_FORM_SET, Flags)){
  438. Ptr += ((EFI_IFR_OP_HEADER *) Ptr)->Length;
  439. continue;
  440. }
  441. ClassGuidNum = (UINT8) (((EFI_IFR_FORM_SET *)Ptr)->Flags & 0x3);
  442. ClassGuid = (EFI_GUID *) (VOID *)(Ptr + sizeof (EFI_IFR_FORM_SET));
  443. while (ClassGuidNum-- > 0) {
  444. if (!CompareGuid (Guid, ClassGuid)){
  445. ClassGuid ++;
  446. continue;
  447. }
  448. *PromptId = ((EFI_IFR_FORM_SET *)Ptr)->FormSetTitle;
  449. *HelpId = ((EFI_IFR_FORM_SET *)Ptr)->Help;
  450. CopyMem (FormsetGuid, &((EFI_IFR_FORM_SET *) Ptr)->Guid, sizeof (EFI_GUID));
  451. RetVal = TRUE;
  452. }
  453. }
  454. FreePool (Buffer);
  455. return RetVal;
  456. }
  457. /**
  458. Search the drivers in the system which need to show in the front page
  459. and insert the menu to the front page.
  460. @param HiiHandle The hii handle for the Uiapp driver.
  461. @param ClassGuid The class guid for the driver which is the target.
  462. @param SpecialHandlerFn The pointer to the specail handler function, if any.
  463. @param StartOpCodeHandle The opcode handle to save the new opcode.
  464. @retval EFI_SUCCESS Search the driver success
  465. **/
  466. EFI_STATUS
  467. UiListThirdPartyDrivers (
  468. IN EFI_HII_HANDLE HiiHandle,
  469. IN EFI_GUID *ClassGuid,
  470. IN DRIVER_SPECIAL_HANDLER SpecialHandlerFn,
  471. IN VOID *StartOpCodeHandle
  472. )
  473. {
  474. UINTN Index;
  475. EFI_STRING String;
  476. EFI_STRING_ID Token;
  477. EFI_STRING_ID TokenHelp;
  478. EFI_HII_HANDLE *HiiHandles;
  479. CHAR16 *DevicePathStr;
  480. UINTN Count;
  481. UINTN CurrentSize;
  482. UI_HII_DRIVER_INSTANCE *DriverListPtr;
  483. EFI_STRING NewName;
  484. BOOLEAN EmptyLineAfter;
  485. if (gHiiDriverList != NULL) {
  486. FreePool (gHiiDriverList);
  487. }
  488. HiiHandles = HiiGetHiiHandles (NULL);
  489. ASSERT (HiiHandles != NULL);
  490. gHiiDriverList = AllocateZeroPool (UI_HII_DRIVER_LIST_SIZE * sizeof (UI_HII_DRIVER_INSTANCE));
  491. ASSERT (gHiiDriverList != NULL);
  492. DriverListPtr = gHiiDriverList;
  493. CurrentSize = UI_HII_DRIVER_LIST_SIZE;
  494. for (Index = 0, Count = 0; HiiHandles[Index] != NULL; Index++) {
  495. if (!RequiredDriver (HiiHandles[Index], ClassGuid, &Token, &TokenHelp, &gHiiDriverList[Count].FormSetGuid)) {
  496. continue;
  497. }
  498. String = HiiGetString (HiiHandles[Index], Token, NULL);
  499. if (String == NULL) {
  500. String = HiiGetString (gStringPackHandle, STRING_TOKEN (STR_MISSING_STRING), NULL);
  501. ASSERT (String != NULL);
  502. } else if (SpecialHandlerFn != NULL) {
  503. //
  504. // Check whether need to rename the driver name.
  505. //
  506. EmptyLineAfter = FALSE;
  507. if (SpecialHandlerFn (String, &NewName, &EmptyLineAfter)) {
  508. FreePool (String);
  509. String = NewName;
  510. DriverListPtr[Count].EmptyLineAfter = EmptyLineAfter;
  511. }
  512. }
  513. DriverListPtr[Count].PromptId = HiiSetString (HiiHandle, 0, String, NULL);
  514. FreePool (String);
  515. String = HiiGetString (HiiHandles[Index], TokenHelp, NULL);
  516. if (String == NULL) {
  517. String = HiiGetString (gStringPackHandle, STRING_TOKEN (STR_MISSING_STRING), NULL);
  518. ASSERT (String != NULL);
  519. }
  520. DriverListPtr[Count].HelpId = HiiSetString (HiiHandle, 0, String, NULL);
  521. FreePool (String);
  522. DevicePathStr = ExtractDevicePathFromHiiHandle(HiiHandles[Index]);
  523. if (DevicePathStr != NULL){
  524. DriverListPtr[Count].DevicePathId = HiiSetString (HiiHandle, 0, DevicePathStr, NULL);
  525. FreePool (DevicePathStr);
  526. } else {
  527. DriverListPtr[Count].DevicePathId = 0;
  528. }
  529. Count++;
  530. if (Count >= CurrentSize) {
  531. DriverListPtr = ReallocatePool (
  532. CurrentSize * sizeof (UI_HII_DRIVER_INSTANCE),
  533. (Count + UI_HII_DRIVER_LIST_SIZE)
  534. * sizeof (UI_HII_DRIVER_INSTANCE),
  535. gHiiDriverList
  536. );
  537. ASSERT (DriverListPtr != NULL);
  538. gHiiDriverList = DriverListPtr;
  539. CurrentSize += UI_HII_DRIVER_LIST_SIZE;
  540. }
  541. }
  542. FreePool (HiiHandles);
  543. Index = 0;
  544. while (gHiiDriverList[Index].PromptId != 0) {
  545. HiiCreateGotoExOpCode (
  546. StartOpCodeHandle,
  547. 0,
  548. gHiiDriverList[Index].PromptId,
  549. gHiiDriverList[Index].HelpId,
  550. 0,
  551. (EFI_QUESTION_ID) (Index + FRONT_PAGE_KEY_DRIVER),
  552. 0,
  553. &gHiiDriverList[Index].FormSetGuid,
  554. gHiiDriverList[Index].DevicePathId
  555. );
  556. if (gHiiDriverList[Index].EmptyLineAfter) {
  557. UiCreateEmptyLine (HiiHandle, StartOpCodeHandle);
  558. }
  559. Index ++;
  560. }
  561. return EFI_SUCCESS;
  562. }