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