• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /** @file
2 
3   This library class defines a set of interfaces to customize Ui module
4 
5 Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials are licensed and made available under
7 the terms and conditions of the BSD License that accompanies this distribution.
8 The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php.
10 
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 
14 **/
15 #include <Uefi.h>
16 #include <Protocol/HiiConfigAccess.h>
17 #include <Library/BaseLib.h>
18 #include <Library/MemoryAllocationLib.h>
19 #include "FrontPage.h"
20 #include "FrontPageCustomizedUiSupport.h"
21 
22 extern FRONT_PAGE_CALLBACK_DATA  gFrontPagePrivate;
23 
24 /**
25   Customize menus in the page.
26 
27   @param[in]  HiiHandle             The HII Handle of the form to update.
28   @param[in]  StartOpCodeHandle     The context used to insert opcode.
29   @param[in]  CustomizePageType     The page type need to be customized.
30 
31 **/
32 VOID
UiCustomizeFrontPage(IN EFI_HII_HANDLE HiiHandle,IN VOID * StartOpCodeHandle)33 UiCustomizeFrontPage (
34   IN EFI_HII_HANDLE  HiiHandle,
35   IN VOID            *StartOpCodeHandle
36   )
37 {
38   //
39   // Create "Select Language" menu with Oneof opcode.
40   //
41   UiCreateLanguageMenu (HiiHandle, StartOpCodeHandle);
42 
43   //
44   // Create empty line.
45   //
46   UiCreateEmptyLine(HiiHandle, StartOpCodeHandle);
47 
48   //
49   // Find third party drivers which need to be shown in the front page.
50   //
51   UiListThirdPartyDrivers (HiiHandle, &gEfiIfrFrontPageGuid, NULL, StartOpCodeHandle);
52 
53   //
54   // Create empty line.
55   //
56   UiCreateEmptyLine(HiiHandle, StartOpCodeHandle);
57 
58   //
59   // Create "Continue" menu.
60   //
61   UiCreateContinueMenu(HiiHandle, StartOpCodeHandle);
62 
63   //
64   // Create reset menu.
65   //
66   UiCreateResetMenu(HiiHandle, StartOpCodeHandle);
67 }
68 
69 /**
70   This function processes the results of changes in configuration.
71 
72 
73   @param HiiHandle       Points to the hii handle for this formset.
74   @param Action          Specifies the type of action taken by the browser.
75   @param QuestionId      A unique value which is sent to the original exporting driver
76                          so that it can identify the type of data to expect.
77   @param Type            The type of value for the question.
78   @param Value           A pointer to the data being sent to the original exporting driver.
79   @param ActionRequest   On return, points to the action requested by the callback function.
80 
81   @retval  EFI_SUCCESS           The callback successfully handled the action.
82   @retval  EFI_OUT_OF_RESOURCES  Not enough storage is available to hold the variable and its data.
83   @retval  EFI_DEVICE_ERROR      The variable could not be saved.
84   @retval  EFI_UNSUPPORTED       The specified Action is not supported by the callback.
85 
86 **/
87 EFI_STATUS
UiFrontPageCallbackHandler(IN EFI_HII_HANDLE HiiHandle,IN EFI_BROWSER_ACTION Action,IN EFI_QUESTION_ID QuestionId,IN UINT8 Type,IN EFI_IFR_TYPE_VALUE * Value,OUT EFI_BROWSER_ACTION_REQUEST * ActionRequest)88 UiFrontPageCallbackHandler (
89   IN  EFI_HII_HANDLE                         HiiHandle,
90   IN  EFI_BROWSER_ACTION                     Action,
91   IN  EFI_QUESTION_ID                        QuestionId,
92   IN  UINT8                                  Type,
93   IN  EFI_IFR_TYPE_VALUE                     *Value,
94   OUT EFI_BROWSER_ACTION_REQUEST             *ActionRequest
95   )
96 {
97   EFI_STATUS    Status;
98 
99   if (UiSupportLibCallbackHandler (HiiHandle, Action, QuestionId, Type, Value, ActionRequest, &Status)) {
100     return Status;
101   }
102 
103   return EFI_UNSUPPORTED;
104 }
105 
106 /**
107   Update the banner string in the front page.
108 
109   Current layout for the banner string like below:
110   PS: Totally only 5 lines of banner supported.
111 
112   Line 1: Left BannerStr                           RightBannerStr
113   Line 2: Left BannerStr                           RightBannerStr
114   Line 3: Left BannerStr                           RightBannerStr
115   Line 4: Left BannerStr                           RightBannerStr
116   Line 5: Left BannerStr                           RightBannerStr
117   <EmptyLine>
118   First menu in front page.
119   ...
120 
121   @param  LineIndex         The line index of the banner need to check.
122   @param  LeftOrRight       The left or right banner need to check.
123   @param  BannerStr         Banner string need to update.
124                             Input the current string and user can update
125                             it and return the new string.
126 
127 **/
128 VOID
UiCustomizeFrontPageBanner(IN UINTN LineIndex,IN BOOLEAN LeftOrRight,IN OUT EFI_STRING * BannerStr)129 UiCustomizeFrontPageBanner (
130   IN     UINTN          LineIndex,
131   IN     BOOLEAN        LeftOrRight,
132   IN OUT EFI_STRING     *BannerStr
133   )
134 {
135   if ((LineIndex == 5) && LeftOrRight) {
136     // Update STR_CUSTOMIZE_BANNER_LINE5_LEFT
137     if (PcdGetBool(PcdTestKeyUsed)) {
138       if (BannerStr != NULL) {
139         FreePool(*BannerStr);
140       }
141       *BannerStr = HiiGetString(gFrontPagePrivate.HiiHandle, STRING_TOKEN(STR_TEST_KEY_USED), NULL);
142     }
143   }
144   return;
145 }
146