TianoCore EDK2 master
Loading...
Searching...
No Matches
BootMaintenanceManagerCustomizedUiSupport.c
Go to the documentation of this file.
1
11
12#define UI_HII_DRIVER_LIST_SIZE 0x8
13
14typedef struct {
15 EFI_STRING_ID PromptId;
16 EFI_STRING_ID HelpId;
17 EFI_STRING_ID DevicePathId;
18 EFI_GUID FormSetGuid;
19 BOOLEAN EmptyLineAfter;
21
22STATIC UI_HII_DRIVER_INSTANCE *gHiiDriverList;
23
31VOID
33 IN EFI_HII_HANDLE HiiHandle,
34 IN VOID *StartOpCodeHandle
35 )
36{
37 BM_MENU_ENTRY *NewMenuEntry;
38 BM_LOAD_CONTEXT *NewLoadContext;
39 UINT16 Index;
40 VOID *OptionsOpCodeHandle;
41 UINT32 BootNextIndex;
42
43 if (BootOptionMenu.MenuNumber == 0) {
44 return;
45 }
46
47 BootNextIndex = NONE_BOOTNEXT_VALUE;
48
49 OptionsOpCodeHandle = HiiAllocateOpCodeHandle ();
50 ASSERT (OptionsOpCodeHandle != NULL);
51
52 for (Index = 0; Index < BootOptionMenu.MenuNumber; Index++) {
53 NewMenuEntry = BOpt_GetMenuEntry (&BootOptionMenu, Index);
54 NewLoadContext = (BM_LOAD_CONTEXT *)NewMenuEntry->VariableContext;
55
56 if (NewLoadContext->IsBootNext) {
58 OptionsOpCodeHandle,
59 NewMenuEntry->DisplayStringToken,
60 EFI_IFR_OPTION_DEFAULT,
61 EFI_IFR_TYPE_NUM_SIZE_32,
62 Index
63 );
64 BootNextIndex = Index;
65 } else {
67 OptionsOpCodeHandle,
68 NewMenuEntry->DisplayStringToken,
69 0,
70 EFI_IFR_TYPE_NUM_SIZE_32,
71 Index
72 );
73 }
74 }
75
76 if (BootNextIndex == NONE_BOOTNEXT_VALUE) {
78 OptionsOpCodeHandle,
79 STRING_TOKEN (STR_NONE),
80 EFI_IFR_OPTION_DEFAULT,
81 EFI_IFR_TYPE_NUM_SIZE_32,
82 NONE_BOOTNEXT_VALUE
83 );
84 } else {
86 OptionsOpCodeHandle,
87 STRING_TOKEN (STR_NONE),
88 0,
89 EFI_IFR_TYPE_NUM_SIZE_32,
90 NONE_BOOTNEXT_VALUE
91 );
92 }
93
95 StartOpCodeHandle,
96 (EFI_QUESTION_ID)BOOT_NEXT_QUESTION_ID,
97 VARSTORE_ID_BOOT_MAINT,
98 BOOT_NEXT_VAR_OFFSET,
99 STRING_TOKEN (STR_BOOT_NEXT),
100 STRING_TOKEN (STR_BOOT_NEXT_HELP),
101 0,
102 EFI_IFR_NUMERIC_SIZE_4,
103 OptionsOpCodeHandle,
104 NULL
105 );
106
107 HiiFreeOpCodeHandle (OptionsOpCodeHandle);
108}
109
117VOID
119 IN EFI_HII_HANDLE HiiHandle,
120 IN VOID *StartOpCodeHandle
121 )
122{
124 StartOpCodeHandle,
125 (EFI_QUESTION_ID)FORM_TIME_OUT_ID,
126 VARSTORE_ID_BOOT_MAINT,
127 BOOT_TIME_OUT_VAR_OFFSET,
128 STRING_TOKEN (STR_NUM_AUTO_BOOT),
129 STRING_TOKEN (STR_HLP_AUTO_BOOT),
130 EFI_IFR_FLAG_CALLBACK,
131 EFI_IFR_NUMERIC_SIZE_2 | EFI_IFR_DISPLAY_UINT_DEC,
132 0,
133 65535,
134 0,
135 NULL
136 );
137}
138
146VOID
148 IN EFI_HII_HANDLE HiiHandle,
149 IN VOID *StartOpCodeHandle
150 )
151{
153 StartOpCodeHandle,
154 FORM_BOOT_SETUP_ID,
155 STRING_TOKEN (STR_FORM_BOOT_SETUP_TITLE),
156 STRING_TOKEN (STR_FORM_BOOT_SETUP_HELP),
157 EFI_IFR_FLAG_CALLBACK,
158 FORM_BOOT_SETUP_ID
159 );
160}
161
169VOID
171 IN EFI_HII_HANDLE HiiHandle,
172 IN VOID *StartOpCodeHandle
173 )
174{
176 StartOpCodeHandle,
177 FORM_DRIVER_SETUP_ID,
178 STRING_TOKEN (STR_FORM_DRIVER_SETUP_TITLE),
179 STRING_TOKEN (STR_FORM_DRIVER_SETUP_HELP),
180 EFI_IFR_FLAG_CALLBACK,
181 FORM_DRIVER_SETUP_ID
182 );
183}
184
192VOID
194 IN EFI_HII_HANDLE HiiHandle,
195 IN VOID *StartOpCodeHandle
196 )
197{
199 StartOpCodeHandle,
200 FORM_CON_MAIN_ID,
201 STRING_TOKEN (STR_FORM_CON_MAIN_TITLE),
202 STRING_TOKEN (STR_FORM_CON_MAIN_HELP),
203 EFI_IFR_FLAG_CALLBACK,
204 FORM_CON_MAIN_ID
205 );
206}
207
215VOID
217 IN EFI_HII_HANDLE HiiHandle,
218 IN VOID *StartOpCodeHandle
219 )
220{
222 StartOpCodeHandle,
223 FORM_MAIN_ID,
224 STRING_TOKEN (STR_BOOT_FROM_FILE),
225 STRING_TOKEN (STR_BOOT_FROM_FILE_HELP),
226 EFI_IFR_FLAG_CALLBACK,
227 KEY_VALUE_BOOT_FROM_FILE
228 );
229}
230
238VOID
240 IN EFI_HII_HANDLE HiiHandle,
241 IN VOID *StartOpCodeHandle
242 )
243{
244 HiiCreateSubTitleOpCode (StartOpCodeHandle, STRING_TOKEN (STR_NULL_STRING), 0, 0, 0);
245}
246
256CHAR16 *
258 IN EFI_HII_HANDLE Handle
259 )
260{
261 EFI_STATUS Status;
262 EFI_HANDLE DriverHandle;
263
264 ASSERT (Handle != NULL);
265
266 if (Handle == NULL) {
267 return NULL;
268 }
269
270 Status = gHiiDatabase->GetPackageListHandle (gHiiDatabase, Handle, &DriverHandle);
271 if (EFI_ERROR (Status)) {
272 return NULL;
273 }
274
276}
277
290BOOLEAN
292 IN EFI_HII_HANDLE HiiHandle,
293 IN EFI_GUID *Guid,
294 OUT EFI_STRING_ID *PromptId,
295 OUT EFI_STRING_ID *HelpId,
296 OUT VOID *FormsetGuid
297 )
298{
299 EFI_STATUS Status;
300 UINT8 ClassGuidNum;
301 EFI_GUID *ClassGuid;
302 EFI_IFR_FORM_SET *Buffer;
303 UINTN BufferSize;
304 UINT8 *Ptr;
305 UINTN TempSize;
306 BOOLEAN RetVal;
307
308 Status = HiiGetFormSetFromHiiHandle (HiiHandle, &Buffer, &BufferSize);
309 if (EFI_ERROR (Status)) {
310 return FALSE;
311 }
312
313 RetVal = FALSE;
314 TempSize = 0;
315 Ptr = (UINT8 *)Buffer;
316 while (TempSize < BufferSize) {
317 TempSize += ((EFI_IFR_OP_HEADER *)Ptr)->Length;
318
319 if (((EFI_IFR_OP_HEADER *)Ptr)->Length <= OFFSET_OF (EFI_IFR_FORM_SET, Flags)) {
320 Ptr += ((EFI_IFR_OP_HEADER *)Ptr)->Length;
321 continue;
322 }
323
324 ClassGuidNum = (UINT8)(((EFI_IFR_FORM_SET *)Ptr)->Flags & 0x3);
325 ClassGuid = (EFI_GUID *)(VOID *)(Ptr + sizeof (EFI_IFR_FORM_SET));
326 while (ClassGuidNum-- > 0) {
327 if (!CompareGuid (Guid, ClassGuid)) {
328 ClassGuid++;
329 continue;
330 }
331
332 *PromptId = ((EFI_IFR_FORM_SET *)Ptr)->FormSetTitle;
333 *HelpId = ((EFI_IFR_FORM_SET *)Ptr)->Help;
334 CopyMem (FormsetGuid, &((EFI_IFR_FORM_SET *)Ptr)->Guid, sizeof (EFI_GUID));
335 RetVal = TRUE;
336 }
337 }
338
339 FreePool (Buffer);
340
341 return RetVal;
342}
343
358 IN EFI_HII_HANDLE HiiHandle,
359 IN EFI_GUID *ClassGuid,
360 IN DRIVER_SPECIAL_HANDLER SpecialHandlerFn,
361 IN VOID *StartOpCodeHandle
362 )
363{
364 UINTN Index;
365 EFI_STRING String;
366 EFI_STRING_ID Token;
367 EFI_STRING_ID TokenHelp;
368 EFI_HII_HANDLE *HiiHandles;
369 CHAR16 *DevicePathStr;
370 UINTN Count;
371 UINTN CurrentSize;
372 UI_HII_DRIVER_INSTANCE *DriverListPtr;
373 EFI_STRING NewName;
374 BOOLEAN EmptyLineAfter;
375
376 if (gHiiDriverList != NULL) {
377 FreePool (gHiiDriverList);
378 }
379
380 HiiHandles = HiiGetHiiHandles (NULL);
381 ASSERT (HiiHandles != NULL);
382
383 gHiiDriverList = AllocateZeroPool (UI_HII_DRIVER_LIST_SIZE * sizeof (UI_HII_DRIVER_INSTANCE));
384 ASSERT (gHiiDriverList != NULL);
385 DriverListPtr = gHiiDriverList;
386 CurrentSize = UI_HII_DRIVER_LIST_SIZE;
387
388 for (Index = 0, Count = 0; HiiHandles[Index] != NULL; Index++) {
389 if (!IsRequiredDriver (HiiHandles[Index], ClassGuid, &Token, &TokenHelp, &gHiiDriverList[Count].FormSetGuid)) {
390 continue;
391 }
392
393 String = HiiGetString (HiiHandles[Index], Token, NULL);
394 if (String == NULL) {
395 String = HiiGetString (HiiHandle, STRING_TOKEN (STR_MISSING_STRING), NULL);
396 ASSERT (String != NULL);
397 } else if (SpecialHandlerFn != NULL) {
398 //
399 // Check whether need to rename the driver name.
400 //
401 EmptyLineAfter = FALSE;
402 if (SpecialHandlerFn (String, &NewName, &EmptyLineAfter)) {
403 FreePool (String);
404 String = NewName;
405 DriverListPtr[Count].EmptyLineAfter = EmptyLineAfter;
406 }
407 }
408
409 DriverListPtr[Count].PromptId = HiiSetString (HiiHandle, 0, String, NULL);
410 FreePool (String);
411
412 String = HiiGetString (HiiHandles[Index], TokenHelp, NULL);
413 if (String == NULL) {
414 String = HiiGetString (HiiHandle, STRING_TOKEN (STR_MISSING_STRING), NULL);
415 ASSERT (String != NULL);
416 }
417
418 DriverListPtr[Count].HelpId = HiiSetString (HiiHandle, 0, String, NULL);
419 FreePool (String);
420
421 DevicePathStr = ExtractDevicePathFromHandle (HiiHandles[Index]);
422 if (DevicePathStr != NULL) {
423 DriverListPtr[Count].DevicePathId = HiiSetString (HiiHandle, 0, DevicePathStr, NULL);
424 FreePool (DevicePathStr);
425 } else {
426 DriverListPtr[Count].DevicePathId = 0;
427 }
428
429 Count++;
430 if (Count >= CurrentSize) {
431 DriverListPtr = ReallocatePool (
432 CurrentSize * sizeof (UI_HII_DRIVER_INSTANCE),
433 (Count + UI_HII_DRIVER_LIST_SIZE)
434 * sizeof (UI_HII_DRIVER_INSTANCE),
435 gHiiDriverList
436 );
437 ASSERT (DriverListPtr != NULL);
438 gHiiDriverList = DriverListPtr;
439 CurrentSize += UI_HII_DRIVER_LIST_SIZE;
440 }
441 }
442
443 FreePool (HiiHandles);
444
445 Index = 0;
446 while (gHiiDriverList[Index].PromptId != 0) {
448 StartOpCodeHandle,
449 0,
450 gHiiDriverList[Index].PromptId,
451 gHiiDriverList[Index].HelpId,
452 0,
453 0,
454 0,
455 &gHiiDriverList[Index].FormSetGuid,
456 gHiiDriverList[Index].DevicePathId
457 );
458
459 if (gHiiDriverList[Index].EmptyLineAfter) {
460 BmmCreateEmptyLine (HiiHandle, StartOpCodeHandle);
461 }
462
463 Index++;
464 }
465
466 return EFI_SUCCESS;
467}
UINT64 UINTN
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
Definition: MemLibGuid.c:73
BM_MENU_ENTRY * BOpt_GetMenuEntry(BM_MENU_OPTION *MenuOption, UINTN MenuNumber)
Definition: BootOption.c:229
BM_MENU_OPTION BootOptionMenu
Definition: Data.c:74
VOID BmmCreateBootOptionMenu(IN EFI_HII_HANDLE HiiHandle, IN VOID *StartOpCodeHandle)
VOID BmmCreateBootNextMenu(IN EFI_HII_HANDLE HiiHandle, IN VOID *StartOpCodeHandle)
VOID BmmCreateBootFromFileMenu(IN EFI_HII_HANDLE HiiHandle, IN VOID *StartOpCodeHandle)
VOID BmmCreateTimeOutMenu(IN EFI_HII_HANDLE HiiHandle, IN VOID *StartOpCodeHandle)
CHAR16 * ExtractDevicePathFromHandle(IN EFI_HII_HANDLE Handle)
VOID BmmCreateEmptyLine(IN EFI_HII_HANDLE HiiHandle, IN VOID *StartOpCodeHandle)
VOID BmmCreateComOptionMenu(IN EFI_HII_HANDLE HiiHandle, IN VOID *StartOpCodeHandle)
VOID BmmCreateDriverOptionMenu(IN EFI_HII_HANDLE HiiHandle, IN VOID *StartOpCodeHandle)
EFI_STATUS BmmListThirdPartyDrivers(IN EFI_HII_HANDLE HiiHandle, IN EFI_GUID *ClassGuid, IN DRIVER_SPECIAL_HANDLER SpecialHandlerFn, IN VOID *StartOpCodeHandle)
BOOLEAN IsRequiredDriver(IN EFI_HII_HANDLE HiiHandle, IN EFI_GUID *Guid, OUT EFI_STRING_ID *PromptId, OUT EFI_STRING_ID *HelpId, OUT VOID *FormsetGuid)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI DevicePathFromHandle(IN EFI_HANDLE Handle)
CHAR16 *EFIAPI ConvertDevicePathToText(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN BOOLEAN DisplayOnly, IN BOOLEAN AllowShortcuts)
VOID *EFIAPI ReallocatePool(IN UINTN OldSize, IN UINTN NewSize, IN VOID *OldBuffer OPTIONAL)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
BOOLEAN(EFIAPI * DRIVER_SPECIAL_HANDLER)(IN CHAR16 *DriverName, OUT CHAR16 **NewName, OUT BOOLEAN *EmptyLineAfter)
UINT8 *EFIAPI HiiCreateSubTitleOpCode(IN VOID *OpCodeHandle, IN EFI_STRING_ID Prompt, IN EFI_STRING_ID Help, IN UINT8 Flags, IN UINT8 Scope)
Definition: HiiLib.c:3504
UINT8 *EFIAPI HiiCreateNumericOpCode(IN VOID *OpCodeHandle, IN EFI_QUESTION_ID QuestionId, IN EFI_VARSTORE_ID VarStoreId, IN UINT16 VarOffset, IN EFI_STRING_ID Prompt, IN EFI_STRING_ID Help, IN UINT8 QuestionFlags, IN UINT8 NumericFlags, IN UINT64 Minimum, IN UINT64 Maximum, IN UINT64 Step, IN VOID *DefaultsOpCodeHandle OPTIONAL)
Definition: HiiLib.c:3740
UINT8 *EFIAPI HiiCreateGotoOpCode(IN VOID *OpCodeHandle, IN EFI_FORM_ID FormId, IN EFI_STRING_ID Prompt, IN EFI_STRING_ID Help, IN UINT8 QuestionFlags, IN EFI_QUESTION_ID QuestionId)
Definition: HiiLib.c:3551
VOID *EFIAPI HiiAllocateOpCodeHandle(VOID)
Definition: HiiLib.c:3051
VOID EFIAPI HiiFreeOpCodeHandle(VOID *OpCodeHandle)
Definition: HiiLib.c:3085
EFI_HII_HANDLE *EFIAPI HiiGetHiiHandles(IN CONST EFI_GUID *PackageListGuid OPTIONAL)
Definition: HiiLib.c:286
EFI_STRING EFIAPI HiiGetString(IN EFI_HII_HANDLE HiiHandle, IN EFI_STRING_ID StringId, IN CONST CHAR8 *Language OPTIONAL)
Definition: HiiString.c:211
UINT8 *EFIAPI HiiCreateOneOfOptionOpCode(IN VOID *OpCodeHandle, IN UINT16 StringId, IN UINT8 Flags, IN UINT8 Type, IN UINT64 Value)
Definition: HiiLib.c:3329
UINT8 *EFIAPI HiiCreateOneOfOpCode(IN VOID *OpCodeHandle, IN EFI_QUESTION_ID QuestionId, IN EFI_VARSTORE_ID VarStoreId, IN UINT16 VarOffset, IN EFI_STRING_ID Prompt, IN EFI_STRING_ID Help, IN UINT8 QuestionFlags, IN UINT8 OneOfFlags, IN VOID *OptionsOpCodeHandle, IN VOID *DefaultsOpCodeHandle OPTIONAL)
Definition: HiiLib.c:3908
EFI_STRING_ID EFIAPI HiiSetString(IN EFI_HII_HANDLE HiiHandle, IN EFI_STRING_ID StringId OPTIONAL, IN CONST EFI_STRING String, IN CONST CHAR8 *SupportedLanguages OPTIONAL)
Definition: HiiString.c:52
UINT8 *EFIAPI HiiCreateGotoExOpCode(IN VOID *OpCodeHandle, IN EFI_FORM_ID RefFormId, IN EFI_STRING_ID Prompt, IN EFI_STRING_ID Help, IN UINT8 QuestionFlags, IN EFI_QUESTION_ID QuestionId, IN EFI_QUESTION_ID RefQuestionId, IN EFI_GUID *RefFormSetId OPTIONAL, IN EFI_STRING_ID RefDevicePath)
Definition: HiiLib.c:3605
EFI_STATUS EFIAPI HiiGetFormSetFromHiiHandle(IN EFI_HII_HANDLE Handle, OUT EFI_IFR_FORM_SET **Buffer, OUT UINTN *BufferSize)
Definition: HiiLib.c:394
#define NULL
Definition: Base.h:319
#define STATIC
Definition: Base.h:264
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
#define OFFSET_OF(TYPE, Field)
Definition: Base.h:758
#define OUT
Definition: Base.h:284
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_HII_DATABASE_PROTOCOL * gHiiDatabase
#define STRING_TOKEN(t)
VOID * EFI_HII_HANDLE
Definition: Base.h:213