FrontPageCustomizedUi.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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 <Protocol/HiiConfigAccess.h>
  8. #include <Library/BaseLib.h>
  9. #include <Library/MemoryAllocationLib.h>
  10. #include "FrontPage.h"
  11. #include "FrontPageCustomizedUiSupport.h"
  12. extern FRONT_PAGE_CALLBACK_DATA gFrontPagePrivate;
  13. /**
  14. Customize menus in the page.
  15. @param[in] HiiHandle The HII Handle of the form to update.
  16. @param[in] StartOpCodeHandle The context used to insert opcode.
  17. @param[in] CustomizePageType The page type need to be customized.
  18. **/
  19. VOID
  20. UiCustomizeFrontPage (
  21. IN EFI_HII_HANDLE HiiHandle,
  22. IN VOID *StartOpCodeHandle
  23. )
  24. {
  25. //
  26. // Create "Select Language" menu with Oneof opcode.
  27. //
  28. UiCreateLanguageMenu (HiiHandle, StartOpCodeHandle);
  29. //
  30. // Create empty line.
  31. //
  32. UiCreateEmptyLine(HiiHandle, StartOpCodeHandle);
  33. //
  34. // Find third party drivers which need to be shown in the front page.
  35. //
  36. UiListThirdPartyDrivers (HiiHandle, &gEfiIfrFrontPageGuid, NULL, StartOpCodeHandle);
  37. //
  38. // Create empty line.
  39. //
  40. UiCreateEmptyLine(HiiHandle, StartOpCodeHandle);
  41. //
  42. // Create "Continue" menu.
  43. //
  44. UiCreateContinueMenu(HiiHandle, StartOpCodeHandle);
  45. //
  46. // Create reset menu.
  47. //
  48. UiCreateResetMenu(HiiHandle, StartOpCodeHandle);
  49. }
  50. /**
  51. This function processes the results of changes in configuration.
  52. @param HiiHandle Points to the hii handle for this formset.
  53. @param Action Specifies the type of action taken by the browser.
  54. @param QuestionId A unique value which is sent to the original exporting driver
  55. so that it can identify the type of data to expect.
  56. @param Type The type of value for the question.
  57. @param Value A pointer to the data being sent to the original exporting driver.
  58. @param ActionRequest On return, points to the action requested by the callback function.
  59. @retval EFI_SUCCESS The callback successfully handled the action.
  60. @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.
  61. @retval EFI_DEVICE_ERROR The variable could not be saved.
  62. @retval EFI_UNSUPPORTED The specified Action is not supported by the callback.
  63. **/
  64. EFI_STATUS
  65. UiFrontPageCallbackHandler (
  66. IN EFI_HII_HANDLE HiiHandle,
  67. IN EFI_BROWSER_ACTION Action,
  68. IN EFI_QUESTION_ID QuestionId,
  69. IN UINT8 Type,
  70. IN EFI_IFR_TYPE_VALUE *Value,
  71. OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
  72. )
  73. {
  74. EFI_STATUS Status;
  75. if (UiSupportLibCallbackHandler (HiiHandle, Action, QuestionId, Type, Value, ActionRequest, &Status)) {
  76. return Status;
  77. }
  78. return EFI_UNSUPPORTED;
  79. }
  80. /**
  81. Update the banner string in the front page.
  82. Current layout for the banner string like below:
  83. PS: Totally only 5 lines of banner supported.
  84. Line 1: Left BannerStr RightBannerStr
  85. Line 2: Left BannerStr RightBannerStr
  86. Line 3: Left BannerStr RightBannerStr
  87. Line 4: Left BannerStr RightBannerStr
  88. Line 5: Left BannerStr RightBannerStr
  89. <EmptyLine>
  90. First menu in front page.
  91. ...
  92. @param LineIndex The line index of the banner need to check.
  93. @param LeftOrRight The left or right banner need to check.
  94. @param BannerStr Banner string need to update.
  95. Input the current string and user can update
  96. it and return the new string.
  97. **/
  98. VOID
  99. UiCustomizeFrontPageBanner (
  100. IN UINTN LineIndex,
  101. IN BOOLEAN LeftOrRight,
  102. IN OUT EFI_STRING *BannerStr
  103. )
  104. {
  105. if ((LineIndex == 5) && LeftOrRight) {
  106. // Update STR_CUSTOMIZE_BANNER_LINE5_LEFT
  107. if (PcdGetBool(PcdTestKeyUsed)) {
  108. if (BannerStr != NULL) {
  109. FreePool(*BannerStr);
  110. }
  111. *BannerStr = HiiGetString(gFrontPagePrivate.HiiHandle, STRING_TOKEN(STR_TEST_KEY_USED), NULL);
  112. }
  113. }
  114. return;
  115. }