Skip to content

Commit f6ad557

Browse files
committed
System76PayloadPkg: Import boot manager modules
Import main firmware app and related libraries from MdeModulePkg for customizing. Signed-off-by: Tim Crawford <tcrawford@system76.com>
1 parent 526e9ea commit f6ad557

50 files changed

Lines changed: 23312 additions & 6 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

System76PayloadPkg/Application/UiApp/FrontPage.c

Lines changed: 1117 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
1+
/** @file
2+
Head file for front page.
3+
4+
Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>
5+
SPDX-License-Identifier: BSD-2-Clause-Patent
6+
7+
**/
8+
9+
#ifndef _FRONT_PAGE_H_
10+
#define _FRONT_PAGE_H_
11+
12+
#include "String.h"
13+
#include "Ui.h"
14+
15+
#include <Protocol/BootLogo.h>
16+
//
17+
// These is the VFR compiler generated data representing our VFR data.
18+
//
19+
extern UINT8 FrontPageVfrBin[];
20+
21+
extern EFI_FORM_BROWSER2_PROTOCOL *gFormBrowser2;
22+
23+
#define SMBIOS_TYPE4_CPU_SOCKET_POPULATED BIT6
24+
25+
//
26+
// This is the VFR compiler generated header file which defines the
27+
// string identifiers.
28+
//
29+
#define PRINTABLE_LANGUAGE_NAME_STRING_ID 0x0001
30+
31+
//
32+
// These are defined as the same with vfr file
33+
//
34+
#define FRONT_PAGE_FORM_ID 0x1000
35+
36+
#define LABEL_FRONTPAGE_INFORMATION 0x1000
37+
#define LABEL_END 0xffff
38+
39+
#define FRONT_PAGE_FORMSET_GUID \
40+
{ \
41+
0x9e0c30bc, 0x3f06, 0x4ba6, {0x82, 0x88, 0x9, 0x17, 0x9b, 0x85, 0x5d, 0xbe} \
42+
}
43+
44+
#define FRONT_PAGE_CALLBACK_DATA_SIGNATURE SIGNATURE_32 ('F', 'P', 'C', 'B')
45+
46+
typedef struct {
47+
UINTN Signature;
48+
49+
//
50+
// HII relative handles
51+
//
52+
EFI_HII_HANDLE HiiHandle;
53+
EFI_HANDLE DriverHandle;
54+
EFI_STRING_ID *LanguageToken;
55+
56+
//
57+
// Produced protocols
58+
//
59+
EFI_HII_CONFIG_ACCESS_PROTOCOL ConfigAccess;
60+
} FRONT_PAGE_CALLBACK_DATA;
61+
62+
#define EFI_FP_CALLBACK_DATA_FROM_THIS(a) \
63+
CR (a, \
64+
FRONT_PAGE_CALLBACK_DATA, \
65+
ConfigAccess, \
66+
FRONT_PAGE_CALLBACK_DATA_SIGNATURE \
67+
)
68+
69+
/**
70+
This function allows a caller to extract the current configuration for one
71+
or more named elements from the target driver.
72+
73+
74+
@param This - Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
75+
@param Request - A null-terminated Unicode string in <ConfigRequest> format.
76+
@param Progress - On return, points to a character in the Request string.
77+
Points to the string's null terminator if request was successful.
78+
Points to the most recent '&' before the first failing name/value
79+
pair (or the beginning of the string if the failure is in the
80+
first name/value pair) if the request was not successful.
81+
@param Results - A null-terminated Unicode string in <ConfigAltResp> format which
82+
has all values filled in for the names in the Request string.
83+
String to be allocated by the called function.
84+
85+
@retval EFI_SUCCESS The Results is filled with the requested values.
86+
@retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.
87+
@retval EFI_INVALID_PARAMETER Request is NULL, illegal syntax, or unknown name.
88+
@retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.
89+
90+
**/
91+
EFI_STATUS
92+
EFIAPI
93+
FakeExtractConfig (
94+
IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
95+
IN CONST EFI_STRING Request,
96+
OUT EFI_STRING *Progress,
97+
OUT EFI_STRING *Results
98+
);
99+
100+
/**
101+
This function processes the results of changes in configuration.
102+
103+
104+
@param This - Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
105+
@param Configuration - A null-terminated Unicode string in <ConfigResp> format.
106+
@param Progress - A pointer to a string filled in with the offset of the most
107+
recent '&' before the first failing name/value pair (or the
108+
beginning of the string if the failure is in the first
109+
name/value pair) or the terminating NULL if all was successful.
110+
111+
@retval EFI_SUCCESS The Results is processed successfully.
112+
@retval EFI_INVALID_PARAMETER Configuration is NULL.
113+
@retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.
114+
115+
**/
116+
EFI_STATUS
117+
EFIAPI
118+
FakeRouteConfig (
119+
IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
120+
IN CONST EFI_STRING Configuration,
121+
OUT EFI_STRING *Progress
122+
);
123+
124+
/**
125+
This function processes the results of changes in configuration.
126+
127+
128+
@param This - Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
129+
@param Action - Specifies the type of action taken by the browser.
130+
@param QuestionId - A unique value which is sent to the original exporting driver
131+
so that it can identify the type of data to expect.
132+
@param Type - The type of value for the question.
133+
@param Value - A pointer to the data being sent to the original exporting driver.
134+
@param ActionRequest - On return, points to the action requested by the callback function.
135+
136+
@retval EFI_SUCCESS The callback successfully handled the action.
137+
@retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.
138+
@retval EFI_DEVICE_ERROR The variable could not be saved.
139+
@retval EFI_UNSUPPORTED The specified Action is not supported by the callback.
140+
141+
**/
142+
EFI_STATUS
143+
EFIAPI
144+
FrontPageCallback (
145+
IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
146+
IN EFI_BROWSER_ACTION Action,
147+
IN EFI_QUESTION_ID QuestionId,
148+
IN UINT8 Type,
149+
IN EFI_IFR_TYPE_VALUE *Value,
150+
OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
151+
);
152+
153+
/**
154+
Initialize HII information for the FrontPage
155+
156+
@retval EFI_SUCCESS The operation is successful.
157+
@retval EFI_DEVICE_ERROR If the dynamic opcode creation failed.
158+
159+
**/
160+
EFI_STATUS
161+
InitializeFrontPage (
162+
VOID
163+
);
164+
165+
/**
166+
Acquire the string associated with the ProducerGuid and return it.
167+
168+
169+
@param ProducerGuid - The Guid to search the HII database for
170+
@param Token - The token value of the string to extract
171+
@param String - The string that is extracted
172+
173+
@retval EFI_SUCCESS The function returns EFI_SUCCESS always.
174+
175+
**/
176+
EFI_STATUS
177+
GetProducerString (
178+
IN EFI_GUID *ProducerGuid,
179+
IN EFI_STRING_ID Token,
180+
OUT CHAR16 **String
181+
);
182+
183+
/**
184+
This function is the main entry of the UI entry.
185+
The function will present the main menu of the system UI.
186+
187+
@param ConnectAllHappened Caller passes the value to UI to avoid unnecessary connect-all.
188+
189+
**/
190+
VOID
191+
EFIAPI
192+
UiEntry (
193+
IN BOOLEAN ConnectAllHappened
194+
);
195+
196+
/**
197+
Extract device path for given HII handle and class guid.
198+
199+
@param Handle The HII handle.
200+
201+
@retval NULL Fail to get the device path string.
202+
@return PathString Get the device path string.
203+
204+
**/
205+
CHAR16 *
206+
ExtractDevicePathFromHiiHandle (
207+
IN EFI_HII_HANDLE Handle
208+
);
209+
210+
#endif // _FRONT_PAGE_H_
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
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+
}

0 commit comments

Comments
 (0)