2 The functions for Boot Maintainence Main menu.
4 Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #include "BootMaintenanceManager.h"
17 #include "BootMaintenanceManagerCustomizedUiSupport.h"
19 #define UI_HII_DRIVER_LIST_SIZE 0x8
22 EFI_STRING_ID PromptId
;
24 EFI_STRING_ID DevicePathId
;
26 BOOLEAN EmptyLineAfter
;
27 } UI_HII_DRIVER_INSTANCE
;
29 UI_HII_DRIVER_INSTANCE
*gHiiDriverList
;
33 Create the dynamic item to allow user to set the "BootNext" vaule.
35 @param CallbackData The BMM context data.
39 BmmCreateBootNextMenu(
40 IN EFI_HII_HANDLE HiiHandle
,
41 IN VOID
*StartOpCodeHandle
44 BM_MENU_ENTRY
*NewMenuEntry
;
45 UINTN NumberOfOptions
;
47 VOID
*OptionsOpCodeHandle
;
49 EFI_STRING_ID OptionId
;
51 NumberOfOptions
= BootOptionMenu
.MenuNumber
;
52 if (NumberOfOptions
== 0) {
56 OptionsOpCodeHandle
= HiiAllocateOpCodeHandle ();
57 ASSERT (OptionsOpCodeHandle
!= NULL
);
59 for (Index
= 0; Index
< BootOptionMenu
.MenuNumber
; Index
++) {
60 NewMenuEntry
= BOpt_GetMenuEntry (&BootOptionMenu
, Index
);
62 StringBuffer
= HiiGetString (HiiHandle
, NewMenuEntry
->DisplayStringToken
, NULL
);
63 ASSERT (StringBuffer
!= NULL
);
64 OptionId
= HiiSetString (HiiHandle
, 0, StringBuffer
, NULL
);
65 FreePool (StringBuffer
);
67 HiiCreateOneOfOptionOpCode (
71 EFI_IFR_TYPE_NUM_SIZE_16
,
76 StringBuffer
= HiiGetString (HiiHandle
, STRING_TOKEN (STR_NONE
), NULL
);
77 ASSERT (StringBuffer
!= NULL
);
78 OptionId
= HiiSetString (HiiHandle
, 0, StringBuffer
, NULL
);
79 FreePool (StringBuffer
);
82 // Set no Boot Next Value as default.
84 HiiCreateOneOfOptionOpCode (
87 EFI_IFR_OPTION_DEFAULT
,
88 EFI_IFR_TYPE_NUM_SIZE_16
,
92 HiiCreateOneOfOpCode (
94 (EFI_QUESTION_ID
) BOOT_NEXT_QUESTION_ID
,
95 VARSTORE_ID_BOOT_MAINT
,
97 STRING_TOKEN (STR_BOOT_NEXT
),
98 STRING_TOKEN (STR_BOOT_NEXT_HELP
),
100 EFI_IFR_NUMERIC_SIZE_2
,
105 HiiFreeOpCodeHandle (OptionsOpCodeHandle
);
110 Create Time Out Menu in the page.
112 @param[in] HiiHandle The hii handle for the Uiapp driver.
113 @param[in] StartOpCodeHandle The opcode handle to save the new opcode.
114 @param[in] PromptId The Prompt string id.
115 @param[in] HelpId The help string id.
116 @param[in] FormId The Form id for the dest form.
117 @param[in] QuestionId The question id for this goto question.
121 BmmCreateTimeOutMenu (
122 IN EFI_HII_HANDLE HiiHandle
,
123 IN VOID
*StartOpCodeHandle
126 HiiCreateNumericOpCode (
128 (EFI_QUESTION_ID
) FORM_TIME_OUT_ID
,
129 VARSTORE_ID_BOOT_MAINT
,
130 BOOT_TIME_OUT_VAR_OFFSET
,
131 STRING_TOKEN(STR_NUM_AUTO_BOOT
),
132 STRING_TOKEN(STR_HLP_AUTO_BOOT
),
133 EFI_IFR_FLAG_CALLBACK
,
134 EFI_IFR_NUMERIC_SIZE_2
| EFI_IFR_DISPLAY_UINT_DEC
,
143 Create Boot Option menu in the page.
145 @param[in] HiiHandle The hii handle for the Uiapp driver.
146 @param[in] StartOpCodeHandle The opcode handle to save the new opcode.
150 BmmCreateBootOptionMenu (
151 IN EFI_HII_HANDLE HiiHandle
,
152 IN VOID
*StartOpCodeHandle
155 HiiCreateGotoOpCode (
158 STRING_TOKEN (STR_FORM_BOOT_SETUP_TITLE
),
159 STRING_TOKEN (STR_FORM_BOOT_SETUP_HELP
),
160 EFI_IFR_FLAG_CALLBACK
,
166 Create Driver Option menu in the page.
168 @param[in] HiiHandle The hii handle for the Uiapp driver.
169 @param[in] StartOpCodeHandle The opcode handle to save the new opcode.
173 BmmCreateDriverOptionMenu (
174 IN EFI_HII_HANDLE HiiHandle
,
175 IN VOID
*StartOpCodeHandle
178 HiiCreateGotoOpCode (
180 FORM_DRIVER_SETUP_ID
,
181 STRING_TOKEN (STR_FORM_DRIVER_SETUP_TITLE
),
182 STRING_TOKEN (STR_FORM_DRIVER_SETUP_HELP
),
183 EFI_IFR_FLAG_CALLBACK
,
189 Create Com Option menu in the page.
191 @param[in] HiiHandle The hii handle for the Uiapp driver.
192 @param[in] StartOpCodeHandle The opcode handle to save the new opcode.
196 BmmCreateComOptionMenu (
197 IN EFI_HII_HANDLE HiiHandle
,
198 IN VOID
*StartOpCodeHandle
201 HiiCreateGotoOpCode (
204 STRING_TOKEN (STR_FORM_CON_MAIN_TITLE
),
205 STRING_TOKEN (STR_FORM_CON_MAIN_HELP
),
206 EFI_IFR_FLAG_CALLBACK
,
212 Create Com Option menu in the page.
214 @param[in] HiiHandle The hii handle for the Uiapp driver.
215 @param[in] StartOpCodeHandle The opcode handle to save the new opcode.
216 @param[in] PromptId The Prompt string id.
217 @param[in] HelpId The help string id.
218 @param[in] FormId The Form id for the dest form.
219 @param[in] QuestionId The question id for this goto question.
223 BmmCreateBootFromFileMenu (
224 IN EFI_HII_HANDLE HiiHandle
,
225 IN VOID
*StartOpCodeHandle
228 HiiCreateGotoOpCode (
231 STRING_TOKEN (STR_BOOT_FROM_FILE
),
232 STRING_TOKEN (STR_BOOT_FROM_FILE_HELP
),
233 EFI_IFR_FLAG_CALLBACK
,
234 KEY_VALUE_BOOT_FROM_FILE
239 Create empty line menu in the front page.
241 @param HiiHandle The hii handle for the Uiapp driver.
242 @param StartOpCodeHandle The opcode handle to save the new opcode.
247 IN EFI_HII_HANDLE HiiHandle
,
248 IN VOID
*StartOpCodeHandle
251 HiiCreateSubTitleOpCode (StartOpCodeHandle
, STRING_TOKEN (STR_NULL_STRING
), 0, 0, 0);
255 Extract device path for given HII handle and class guid.
257 @param Handle The HII handle.
259 @retval NULL Fail to get the device path string.
260 @return PathString Get the device path string.
264 ExtractDevicePathFromHandle (
265 IN EFI_HII_HANDLE Handle
269 EFI_HANDLE DriverHandle
;
271 ASSERT (Handle
!= NULL
);
273 if (Handle
== NULL
) {
277 Status
= gHiiDatabase
->GetPackageListHandle (gHiiDatabase
, Handle
, &DriverHandle
);
278 if (EFI_ERROR (Status
)) {
282 return ConvertDevicePathToText(DevicePathFromHandle (DriverHandle
), FALSE
, FALSE
);
286 Check whether this driver need to be shown in the front page.
288 @param HiiHandle The hii handle for the driver.
289 @param Guid The special guid for the driver which is the target.
290 @param PromptId Return the prompt string id.
291 @param HelpId Return the help string id.
292 @param FormsetGuid Return the formset guid info.
294 @retval EFI_SUCCESS Search the driver success
299 IN EFI_HII_HANDLE HiiHandle
,
301 OUT EFI_STRING_ID
*PromptId
,
302 OUT EFI_STRING_ID
*HelpId
,
303 OUT VOID
*FormsetGuid
309 EFI_IFR_FORM_SET
*Buffer
;
315 Status
= HiiGetFormSetFromHiiHandle(HiiHandle
, &Buffer
,&BufferSize
);
316 if (EFI_ERROR (Status
)) {
322 Ptr
= (UINT8
*) Buffer
;
323 while(TempSize
< BufferSize
) {
324 TempSize
+= ((EFI_IFR_OP_HEADER
*) Ptr
)->Length
;
326 if (((EFI_IFR_OP_HEADER
*) Ptr
)->Length
<= OFFSET_OF (EFI_IFR_FORM_SET
, Flags
)){
327 Ptr
+= ((EFI_IFR_OP_HEADER
*) Ptr
)->Length
;
331 ClassGuidNum
= (UINT8
) (((EFI_IFR_FORM_SET
*)Ptr
)->Flags
& 0x3);
332 ClassGuid
= (EFI_GUID
*) (VOID
*)(Ptr
+ sizeof (EFI_IFR_FORM_SET
));
333 while (ClassGuidNum
-- > 0) {
334 if (!CompareGuid (Guid
, ClassGuid
)){
339 *PromptId
= ((EFI_IFR_FORM_SET
*)Ptr
)->FormSetTitle
;
340 *HelpId
= ((EFI_IFR_FORM_SET
*)Ptr
)->Help
;
341 CopyMem (FormsetGuid
, &((EFI_IFR_FORM_SET
*) Ptr
)->Guid
, sizeof (EFI_GUID
));
352 Search the drivers in the system which need to show in the front page
353 and insert the menu to the front page.
355 @param HiiHandle The hii handle for the Uiapp driver.
356 @param ClassGuid The class guid for the driver which is the target.
357 @param StartOpCodeHandle The opcode handle to save the new opcode.
358 @param SpecialHandler The pointer to the specail handler function, if any.
360 @retval EFI_SUCCESS Search the driver success
364 BmmListThirdPartyDrivers (
365 IN EFI_HII_HANDLE HiiHandle
,
366 IN EFI_GUID
*ClassGuid
,
367 IN DRIVER_SPECIAL_HANDLER SpecialHandlerFn
,
368 IN VOID
*StartOpCodeHandle
374 EFI_STRING_ID TokenHelp
;
375 EFI_HII_HANDLE
*HiiHandles
;
376 CHAR16
*DevicePathStr
;
379 UI_HII_DRIVER_INSTANCE
*DriverListPtr
;
381 BOOLEAN EmptyLineAfter
;
383 if (gHiiDriverList
!= NULL
) {
384 FreePool (gHiiDriverList
);
387 HiiHandles
= HiiGetHiiHandles (NULL
);
388 ASSERT (HiiHandles
!= NULL
);
390 gHiiDriverList
= AllocateZeroPool (UI_HII_DRIVER_LIST_SIZE
* sizeof (UI_HII_DRIVER_INSTANCE
));
391 ASSERT (gHiiDriverList
!= NULL
);
392 DriverListPtr
= gHiiDriverList
;
393 CurrentSize
= UI_HII_DRIVER_LIST_SIZE
;
395 for (Index
= 0, Count
= 0; HiiHandles
[Index
] != NULL
; Index
++) {
396 if (!IsRequiredDriver (HiiHandles
[Index
], ClassGuid
, &Token
, &TokenHelp
, &gHiiDriverList
[Count
].FormSetGuid
)) {
400 String
= HiiGetString (HiiHandles
[Index
], Token
, NULL
);
401 if (String
== NULL
) {
402 String
= HiiGetString (HiiHandle
, STRING_TOKEN (STR_MISSING_STRING
), NULL
);
403 ASSERT (String
!= NULL
);
404 } else if (SpecialHandlerFn
!= NULL
) {
406 // Check whether need to rename the driver name.
408 EmptyLineAfter
= FALSE
;
409 if (SpecialHandlerFn (String
, &NewName
, &EmptyLineAfter
)) {
412 DriverListPtr
[Count
].EmptyLineAfter
= EmptyLineAfter
;
415 DriverListPtr
[Count
].PromptId
= HiiSetString (HiiHandle
, 0, String
, NULL
);
418 String
= HiiGetString (HiiHandles
[Index
], TokenHelp
, NULL
);
419 if (String
== NULL
) {
420 String
= HiiGetString (HiiHandle
, STRING_TOKEN (STR_MISSING_STRING
), NULL
);
421 ASSERT (String
!= NULL
);
423 DriverListPtr
[Count
].HelpId
= HiiSetString (HiiHandle
, 0, String
, NULL
);
426 DevicePathStr
= ExtractDevicePathFromHandle(HiiHandles
[Index
]);
427 if (DevicePathStr
!= NULL
){
428 DriverListPtr
[Count
].DevicePathId
= HiiSetString (HiiHandle
, 0, DevicePathStr
, NULL
);
429 FreePool (DevicePathStr
);
431 DriverListPtr
[Count
].DevicePathId
= 0;
435 if (Count
>= CurrentSize
) {
436 DriverListPtr
= AllocateCopyPool ((Count
+ UI_HII_DRIVER_LIST_SIZE
) * sizeof (UI_HII_DRIVER_INSTANCE
), gHiiDriverList
);
437 ASSERT (DriverListPtr
!= NULL
);
438 FreePool (gHiiDriverList
);
439 gHiiDriverList
= DriverListPtr
;
440 CurrentSize
+= UI_HII_DRIVER_LIST_SIZE
;
444 FreePool (HiiHandles
);
447 while (gHiiDriverList
[Index
].PromptId
!= 0) {
448 HiiCreateGotoExOpCode (
451 gHiiDriverList
[Index
].PromptId
,
452 gHiiDriverList
[Index
].HelpId
,
456 &gHiiDriverList
[Index
].FormSetGuid
,
457 gHiiDriverList
[Index
].DevicePathId
460 if (gHiiDriverList
[Index
].EmptyLineAfter
) {
461 BmmCreateEmptyLine (HiiHandle
, StartOpCodeHandle
);