VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.c@ 99404

最後變更 在這個檔案從99404是 99404,由 vboxsync 提交於 2 年 前

Devices/EFI/FirmwareNew: Update to edk2-stable202302 and make it build, bugref:4643

  • 屬性 svn:eol-style 設為 native
檔案大小: 26.6 KB
 
1/** @file
2
3 This library class defines a set of interfaces to customize Display module
4
5Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>
6SPDX-License-Identifier: BSD-2-Clause-Patent
7
8**/
9#include "CustomizedDisplayLibInternal.h"
10
11EFI_GUID gCustomizedDisplayLibGuid = {
12 0x99fdc8fd, 0x849b, 0x4eba, { 0xad, 0x13, 0xfb, 0x96, 0x99, 0xc9, 0xa, 0x4d }
13};
14
15EFI_HII_HANDLE mCDLStringPackHandle;
16UINT16 gClassOfVfr; // Formset class information
17BOOLEAN gLibIsFirstForm = TRUE;
18BANNER_DATA *gBannerData;
19
20UINTN gFooterHeight;
21
22/**
23+------------------------------------------------------------------------------+
24| Setup Page |
25+------------------------------------------------------------------------------+
26
27Statement
28Statement
29Statement
30
31
32
33
34
35+------------------------------------------------------------------------------+
36| F9=Reset to Defaults F10=Save |
37| ^"=Move Highlight <Spacebar> Toggles Checkbox Esc=Exit |
38+------------------------------------------------------------------------------+
39 StatusBar
40**/
41
42/**
43 This funtion defines Page Frame and Backgroud.
44
45 Based on the above layout, it will be responsible for HeaderHeight, FooterHeight,
46 StatusBarHeight and Backgroud. And, it will reserve Screen for Statement.
47
48 @param[in] FormData Form Data to be shown in Page.
49 @param[out] ScreenForStatement Screen to be used for Statement. (Prompt, Value and Help)
50
51 @return Status
52**/
53EFI_STATUS
54EFIAPI
55DisplayPageFrame (
56 IN FORM_DISPLAY_ENGINE_FORM *FormData,
57 OUT EFI_SCREEN_DESCRIPTOR *ScreenForStatement
58 )
59{
60 EFI_STATUS Status;
61
62 ASSERT (FormData != NULL && ScreenForStatement != NULL);
63 if ((FormData == NULL) || (ScreenForStatement == NULL)) {
64 return EFI_INVALID_PARAMETER;
65 }
66
67 Status = ScreenDiemensionInfoValidate (FormData);
68 if (EFI_ERROR (Status)) {
69 return Status;
70 }
71
72 gClassOfVfr = FORMSET_CLASS_PLATFORM_SETUP;
73
74 ProcessExternedOpcode (FormData);
75
76 //
77 // Calculate the ScreenForStatement.
78 //
79 ScreenForStatement->BottomRow = gScreenDimensions.BottomRow - STATUS_BAR_HEIGHT - gFooterHeight;
80 if (gClassOfVfr == FORMSET_CLASS_FRONT_PAGE) {
81 ScreenForStatement->TopRow = gScreenDimensions.TopRow + FRONT_PAGE_HEADER_HEIGHT;
82 } else {
83 ScreenForStatement->TopRow = gScreenDimensions.TopRow + NONE_FRONT_PAGE_HEADER_HEIGHT;
84 }
85
86 ScreenForStatement->LeftColumn = gScreenDimensions.LeftColumn;
87 ScreenForStatement->RightColumn = gScreenDimensions.RightColumn;
88
89 if ((gLibIsFirstForm) || ((FormData->Attribute & HII_DISPLAY_MODAL) != 0)) {
90 //
91 // Ensure we are in Text mode
92 //
93 gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK));
94 ClearLines (0, gScreenDimensions.RightColumn, 0, gScreenDimensions.BottomRow, KEYHELP_BACKGROUND);
95 gLibIsFirstForm = FALSE;
96 }
97
98 //
99 // Don't print frame for modal form.
100 //
101 if ((FormData->Attribute & HII_DISPLAY_MODAL) != 0) {
102 return EFI_SUCCESS;
103 }
104
105 if (gClassOfVfr == FORMSET_CLASS_FRONT_PAGE) {
106 PrintBannerInfo (FormData);
107 }
108
109 PrintFramework (FormData);
110
111 UpdateStatusBar (NV_UPDATE_REQUIRED, FormData->SettingChangedFlag);
112
113 return EFI_SUCCESS;
114}
115
116/**
117 This function updates customized key panel's help information.
118 The library will prepare those Strings for the basic key, ESC, Enter, Up/Down/Left/Right, +/-.
119 and arrange them in Footer panel.
120
121 @param[in] FormData Form Data to be shown in Page. FormData has the highlighted statement.
122 @param[in] Statement The statement current selected.
123 @param[in] Selected Whether or not a tag be selected. TRUE means Enter has hit this question.
124**/
125VOID
126EFIAPI
127RefreshKeyHelp (
128 IN FORM_DISPLAY_ENGINE_FORM *FormData,
129 IN FORM_DISPLAY_ENGINE_STATEMENT *Statement,
130 IN BOOLEAN Selected
131 )
132{
133 UINTN SecCol;
134 UINTN ThdCol;
135 UINTN RightColumnOfHelp;
136 UINTN TopRowOfHelp;
137 UINTN BottomRowOfHelp;
138 UINTN StartColumnOfHelp;
139 EFI_IFR_NUMERIC *NumericOp;
140 EFI_IFR_DATE *DateOp;
141 EFI_IFR_TIME *TimeOp;
142 BOOLEAN HexDisplay;
143 UINTN ColumnWidth1;
144 UINTN ColumnWidth2;
145 UINTN ColumnWidth3;
146 CHAR16 *ColumnStr1;
147 CHAR16 *ColumnStr2;
148 CHAR16 *ColumnStr3;
149
150 ASSERT (FormData != NULL);
151 if (FormData == NULL) {
152 return;
153 }
154
155 gST->ConOut->SetAttribute (gST->ConOut, KEYHELP_TEXT | KEYHELP_BACKGROUND);
156
157 if ((FormData->Attribute & HII_DISPLAY_MODAL) != 0) {
158 return;
159 }
160
161 SecCol = gScreenDimensions.LeftColumn + (gScreenDimensions.RightColumn - gScreenDimensions.LeftColumn) / 3;
162 ThdCol = gScreenDimensions.LeftColumn + (gScreenDimensions.RightColumn - gScreenDimensions.LeftColumn) / 3 * 2;
163
164 //
165 // + 2 means leave 1 space before the first hotkey info.
166 //
167 StartColumnOfHelp = gScreenDimensions.LeftColumn + 2;
168 RightColumnOfHelp = gScreenDimensions.RightColumn - 1;
169 TopRowOfHelp = gScreenDimensions.BottomRow - STATUS_BAR_HEIGHT - gFooterHeight + 1;
170 BottomRowOfHelp = gScreenDimensions.BottomRow - STATUS_BAR_HEIGHT - 2;
171
172 ColumnWidth1 = SecCol - StartColumnOfHelp;
173 ColumnWidth2 = ThdCol - SecCol;
174 ColumnWidth3 = RightColumnOfHelp - ThdCol;
175 ColumnStr1 = gLibEmptyString;
176 ColumnStr2 = gLibEmptyString;
177 ColumnStr3 = gLibEmptyString;
178
179 //
180 // Clean the space at gScreenDimensions.LeftColumn + 1.
181 //
182 PrintStringAtWithWidth (StartColumnOfHelp - 1, BottomRowOfHelp, gLibEmptyString, 1);
183 PrintStringAtWithWidth (StartColumnOfHelp - 1, TopRowOfHelp, gLibEmptyString, 1);
184
185 if (Statement == NULL) {
186 //
187 // Print Key for Form without showable statement.
188 //
189 PrintHotKeyHelpString (FormData, TRUE);
190 PrintStringAtWithWidth (StartColumnOfHelp, BottomRowOfHelp, gLibEmptyString, ColumnWidth1);
191 PrintStringAtWithWidth (SecCol, BottomRowOfHelp, gLibEmptyString, ColumnWidth2);
192 PrintStringAtWithWidth (StartColumnOfHelp, TopRowOfHelp, gLibEmptyString, ColumnWidth1);
193 if (gClassOfVfr == FORMSET_CLASS_PLATFORM_SETUP) {
194 ColumnStr3 = gEscapeString;
195 }
196
197 PrintStringAtWithWidth (ThdCol, BottomRowOfHelp, ColumnStr3, ColumnWidth3);
198
199 return;
200 }
201
202 HexDisplay = FALSE;
203 NumericOp = NULL;
204 DateOp = NULL;
205 TimeOp = NULL;
206 if (Statement->OpCode->OpCode == EFI_IFR_NUMERIC_OP) {
207 NumericOp = (EFI_IFR_NUMERIC *)Statement->OpCode;
208 HexDisplay = (NumericOp->Flags & EFI_IFR_DISPLAY_UINT_HEX) == EFI_IFR_DISPLAY_UINT_HEX;
209 } else if (Statement->OpCode->OpCode == EFI_IFR_DATE_OP) {
210 DateOp = (EFI_IFR_DATE *)Statement->OpCode;
211 HexDisplay = (DateOp->Flags & EFI_IFR_DISPLAY_UINT_HEX) == EFI_IFR_DISPLAY_UINT_HEX;
212 } else if (Statement->OpCode->OpCode == EFI_IFR_TIME_OP) {
213 TimeOp = (EFI_IFR_TIME *)Statement->OpCode;
214 HexDisplay = (TimeOp->Flags & EFI_IFR_DISPLAY_UINT_HEX) == EFI_IFR_DISPLAY_UINT_HEX;
215 }
216
217 switch (Statement->OpCode->OpCode) {
218 case EFI_IFR_ORDERED_LIST_OP:
219 case EFI_IFR_ONE_OF_OP:
220 case EFI_IFR_NUMERIC_OP:
221 case EFI_IFR_TIME_OP:
222 case EFI_IFR_DATE_OP:
223 if (!Selected) {
224 PrintHotKeyHelpString (FormData, TRUE);
225
226 if (gClassOfVfr == FORMSET_CLASS_PLATFORM_SETUP) {
227 ColumnStr3 = gEscapeString;
228 }
229
230 PrintStringAtWithWidth (ThdCol, BottomRowOfHelp, ColumnStr3, ColumnWidth3);
231
232 if ((Statement->OpCode->OpCode == EFI_IFR_DATE_OP) ||
233 (Statement->OpCode->OpCode == EFI_IFR_TIME_OP))
234 {
235 PrintAt (
236 ColumnWidth1,
237 StartColumnOfHelp,
238 BottomRowOfHelp,
239 L"%c%c%c%c%s",
240 ARROW_UP,
241 ARROW_DOWN,
242 ARROW_RIGHT,
243 ARROW_LEFT,
244 gMoveHighlight
245 );
246 PrintStringAtWithWidth (SecCol, BottomRowOfHelp, gEnterString, ColumnWidth2);
247 PrintStringAtWithWidth (StartColumnOfHelp, TopRowOfHelp, gAdjustNumber, ColumnWidth1);
248 } else {
249 PrintAt (ColumnWidth1, StartColumnOfHelp, BottomRowOfHelp, L"%c%c%s", ARROW_UP, ARROW_DOWN, gMoveHighlight);
250 if ((Statement->OpCode->OpCode == EFI_IFR_NUMERIC_OP) && (NumericOp != NULL) && (LibGetFieldFromNum (Statement->OpCode) != 0)) {
251 ColumnStr1 = gAdjustNumber;
252 }
253
254 PrintStringAtWithWidth (StartColumnOfHelp, TopRowOfHelp, ColumnStr1, ColumnWidth1);
255 PrintStringAtWithWidth (SecCol, BottomRowOfHelp, gEnterString, ColumnWidth2);
256 }
257 } else {
258 PrintHotKeyHelpString (FormData, FALSE);
259 PrintStringAtWithWidth (SecCol, BottomRowOfHelp, gEnterCommitString, ColumnWidth2);
260
261 //
262 // If it is a selected numeric with manual input, display different message
263 //
264 if ((Statement->OpCode->OpCode == EFI_IFR_NUMERIC_OP) ||
265 (Statement->OpCode->OpCode == EFI_IFR_DATE_OP) ||
266 (Statement->OpCode->OpCode == EFI_IFR_TIME_OP))
267 {
268 ColumnStr2 = HexDisplay ? gHexNumericInput : gDecNumericInput;
269 PrintStringAtWithWidth (StartColumnOfHelp, BottomRowOfHelp, gLibEmptyString, ColumnWidth1);
270 } else {
271 PrintAt (ColumnWidth1, StartColumnOfHelp, BottomRowOfHelp, L"%c%c%s", ARROW_UP, ARROW_DOWN, gMoveHighlight);
272 }
273
274 if (Statement->OpCode->OpCode == EFI_IFR_ORDERED_LIST_OP) {
275 ColumnStr1 = gPlusString;
276 ColumnStr3 = gMinusString;
277 }
278
279 PrintStringAtWithWidth (StartColumnOfHelp, TopRowOfHelp, ColumnStr1, ColumnWidth1);
280 PrintStringAtWithWidth (ThdCol, TopRowOfHelp, ColumnStr3, ColumnWidth3);
281 PrintStringAtWithWidth (SecCol, TopRowOfHelp, ColumnStr2, ColumnWidth2);
282
283 PrintStringAtWithWidth (ThdCol, BottomRowOfHelp, gEnterEscapeString, ColumnWidth3);
284 }
285
286 break;
287
288 case EFI_IFR_CHECKBOX_OP:
289 PrintHotKeyHelpString (FormData, TRUE);
290
291 if (gClassOfVfr == FORMSET_CLASS_PLATFORM_SETUP) {
292 ColumnStr3 = gEscapeString;
293 }
294
295 PrintStringAtWithWidth (ThdCol, BottomRowOfHelp, ColumnStr3, ColumnWidth3);
296
297 PrintAt (ColumnWidth1, StartColumnOfHelp, BottomRowOfHelp, L"%c%c%s", ARROW_UP, ARROW_DOWN, gMoveHighlight);
298 PrintStringAtWithWidth (SecCol, BottomRowOfHelp, gToggleCheckBox, ColumnWidth2);
299 PrintStringAtWithWidth (StartColumnOfHelp, TopRowOfHelp, gLibEmptyString, ColumnWidth1);
300 break;
301
302 case EFI_IFR_REF_OP:
303 case EFI_IFR_PASSWORD_OP:
304 case EFI_IFR_STRING_OP:
305 case EFI_IFR_TEXT_OP:
306 case EFI_IFR_ACTION_OP:
307 case EFI_IFR_RESET_BUTTON_OP:
308 case EFI_IFR_SUBTITLE_OP:
309 if (!Selected) {
310 PrintHotKeyHelpString (FormData, TRUE);
311
312 if (gClassOfVfr == FORMSET_CLASS_PLATFORM_SETUP) {
313 ColumnStr3 = gEscapeString;
314 }
315
316 PrintStringAtWithWidth (ThdCol, BottomRowOfHelp, ColumnStr3, ColumnWidth3);
317
318 PrintAt (ColumnWidth1, StartColumnOfHelp, BottomRowOfHelp, L"%c%c%s", ARROW_UP, ARROW_DOWN, gMoveHighlight);
319 if ((Statement->OpCode->OpCode != EFI_IFR_TEXT_OP) && (Statement->OpCode->OpCode != EFI_IFR_SUBTITLE_OP)) {
320 ColumnStr2 = gEnterString;
321 }
322
323 PrintStringAtWithWidth (SecCol, BottomRowOfHelp, ColumnStr2, ColumnWidth2);
324 PrintStringAtWithWidth (StartColumnOfHelp, TopRowOfHelp, ColumnStr1, ColumnWidth1);
325 } else {
326 PrintHotKeyHelpString (FormData, FALSE);
327 if (Statement->OpCode->OpCode != EFI_IFR_REF_OP) {
328 ColumnStr2 = gEnterCommitString;
329 ColumnStr3 = gEnterEscapeString;
330 }
331
332 PrintStringAtWithWidth (StartColumnOfHelp, TopRowOfHelp, ColumnStr1, ColumnWidth1);
333 PrintStringAtWithWidth (StartColumnOfHelp, BottomRowOfHelp, ColumnStr1, ColumnWidth1);
334 PrintStringAtWithWidth (SecCol, BottomRowOfHelp, ColumnStr2, ColumnWidth2);
335 PrintStringAtWithWidth (ThdCol, BottomRowOfHelp, ColumnStr3, ColumnWidth3);
336 }
337
338 break;
339
340 default:
341 break;
342 }
343}
344
345/**
346 Update status bar.
347
348 This function updates the status bar on the bottom of menu screen. It just shows StatusBar.
349 Original logic in this function should be splitted out.
350
351 @param[in] MessageType The type of message to be shown. InputError or Configuration Changed.
352 @param[in] State Show or Clear Message.
353**/
354VOID
355EFIAPI
356UpdateStatusBar (
357 IN UINTN MessageType,
358 IN BOOLEAN State
359 )
360{
361 UINTN Index;
362 CHAR16 OptionWidth;
363
364 OptionWidth = (CHAR16)((gScreenDimensions.RightColumn - gScreenDimensions.LeftColumn) / 3);
365
366 switch (MessageType) {
367 case INPUT_ERROR:
368 if (State) {
369 gST->ConOut->SetAttribute (gST->ConOut, ERROR_TEXT);
370 PrintStringAt (
371 gScreenDimensions.LeftColumn + OptionWidth,
372 gScreenDimensions.BottomRow - 1,
373 gInputErrorMessage
374 );
375 } else {
376 gST->ConOut->SetAttribute (gST->ConOut, KEYHELP_BACKGROUND);
377 for (Index = 0; Index < (LibGetStringWidth (gInputErrorMessage) - 2) / 2; Index++) {
378 PrintStringAt (gScreenDimensions.LeftColumn + OptionWidth + Index, gScreenDimensions.BottomRow - 1, L" ");
379 }
380 }
381
382 break;
383
384 case NV_UPDATE_REQUIRED:
385 //
386 // Global setting support. Show configuration change on every form.
387 //
388 if (State) {
389 gST->ConOut->SetAttribute (gST->ConOut, INFO_TEXT);
390 PrintStringAt (
391 gScreenDimensions.LeftColumn + OptionWidth * 2,
392 gScreenDimensions.BottomRow - 1,
393 gNvUpdateMessage
394 );
395 } else {
396 gST->ConOut->SetAttribute (gST->ConOut, KEYHELP_BACKGROUND);
397 for (Index = 0; Index < (LibGetStringWidth (gNvUpdateMessage) - 2) / 2; Index++) {
398 PrintStringAt (
399 (gScreenDimensions.LeftColumn + OptionWidth * 2 + Index),
400 gScreenDimensions.BottomRow - 1,
401 L" "
402 );
403 }
404 }
405
406 break;
407
408 default:
409 break;
410 }
411}
412
413/**
414 Create popup window. It will replace CreateDialog().
415
416 This function draws OEM/Vendor specific pop up windows.
417
418 @param[out] Key User Input Key
419 @param ... String to be shown in Popup. The variable argument list is terminated by a NULL.
420
421**/
422VOID
423EFIAPI
424CreateDialog (
425 OUT EFI_INPUT_KEY *Key OPTIONAL,
426 ...
427 )
428{
429 VA_LIST Marker;
430 EFI_INPUT_KEY KeyValue;
431 EFI_STATUS Status;
432 UINTN LargestString;
433 UINTN LineNum;
434 UINTN Index;
435 UINTN Count;
436 CHAR16 Character;
437 UINTN Start;
438 UINTN End;
439 UINTN Top;
440 UINTN Bottom;
441 CHAR16 *String;
442 UINTN DimensionsWidth;
443 UINTN DimensionsHeight;
444 UINTN CurrentAttribute;
445 BOOLEAN CursorVisible;
446
447 //
448 // If screen dimension info is not ready, get it from console.
449 //
450 if ((gScreenDimensions.RightColumn == 0) || (gScreenDimensions.BottomRow == 0)) {
451 ZeroMem (&gScreenDimensions, sizeof (EFI_SCREEN_DESCRIPTOR));
452 gST->ConOut->QueryMode (
453 gST->ConOut,
454 gST->ConOut->Mode->Mode,
455 &gScreenDimensions.RightColumn,
456 &gScreenDimensions.BottomRow
457 );
458 }
459
460 DimensionsWidth = gScreenDimensions.RightColumn - gScreenDimensions.LeftColumn;
461 DimensionsHeight = gScreenDimensions.BottomRow - gScreenDimensions.TopRow;
462
463 LargestString = 0;
464 LineNum = 0;
465 VA_START (Marker, Key);
466 while ((String = VA_ARG (Marker, CHAR16 *)) != NULL) {
467 LineNum++;
468
469 if ((LibGetStringWidth (String) / 2) > LargestString) {
470 LargestString = (LibGetStringWidth (String) / 2);
471 }
472 }
473
474 VA_END (Marker);
475
476 if ((LargestString + 2) > DimensionsWidth) {
477 LargestString = DimensionsWidth - 2;
478 }
479
480 CurrentAttribute = gST->ConOut->Mode->Attribute;
481 CursorVisible = gST->ConOut->Mode->CursorVisible;
482 gST->ConOut->EnableCursor (gST->ConOut, FALSE);
483 gST->ConOut->SetAttribute (gST->ConOut, GetPopupColor ());
484
485 //
486 // Subtract the PopUp width from total Columns, allow for one space extra on
487 // each end plus a border.
488 //
489 Start = (DimensionsWidth - LargestString - 2) / 2 + gScreenDimensions.LeftColumn + 1;
490 End = Start + LargestString + 1;
491
492 Top = ((DimensionsHeight - LineNum - 2) / 2) + gScreenDimensions.TopRow - 1;
493 Bottom = Top + LineNum + 2;
494
495 Character = BOXDRAW_DOWN_RIGHT;
496 PrintCharAt (Start, Top, Character);
497 Character = BOXDRAW_HORIZONTAL;
498 for (Index = Start; Index + 2 < End; Index++) {
499 PrintCharAt ((UINTN)-1, (UINTN)-1, Character);
500 }
501
502 Character = BOXDRAW_DOWN_LEFT;
503 PrintCharAt ((UINTN)-1, (UINTN)-1, Character);
504 Character = BOXDRAW_VERTICAL;
505
506 Count = 0;
507 VA_START (Marker, Key);
508 for (Index = Top; Index + 2 < Bottom; Index++, Count++) {
509 String = VA_ARG (Marker, CHAR16 *);
510
511 if (String[0] == CHAR_NULL) {
512 //
513 // Passing in a NULL results in a blank space
514 //
515 ClearLines (Start, End, Index + 1, Index + 1, GetPopupColor ());
516 } else if (String[0] == L' ') {
517 //
518 // Passing in a space results in the assumption that this is where typing will occur
519 //
520 ClearLines (Start + 1, End - 1, Index + 1, Index + 1, POPUP_INVERSE_TEXT | POPUP_INVERSE_BACKGROUND);
521 PrintStringAt (
522 ((DimensionsWidth - LibGetStringWidth (String) / 2) / 2) + gScreenDimensions.LeftColumn + 1,
523 Index + 1,
524 String + 1
525 );
526 } else {
527 //
528 // This will clear the background of the line - we never know who might have been
529 // here before us. This differs from the next clear in that it used the non-reverse
530 // video for normal printing.
531 //
532 ClearLines (Start, End, Index + 1, Index + 1, GetPopupColor ());
533 PrintStringAt (
534 ((DimensionsWidth - LibGetStringWidth (String) / 2) / 2) + gScreenDimensions.LeftColumn + 1,
535 Index + 1,
536 String
537 );
538 }
539
540 gST->ConOut->SetAttribute (gST->ConOut, GetPopupColor ());
541 PrintCharAt (Start, Index + 1, Character);
542 PrintCharAt (End - 1, Index + 1, Character);
543 }
544
545 VA_END (Marker);
546
547 Character = BOXDRAW_UP_RIGHT;
548 PrintCharAt (Start, Bottom - 1, Character);
549 Character = BOXDRAW_HORIZONTAL;
550 for (Index = Start; Index + 2 < End; Index++) {
551 PrintCharAt ((UINTN)-1, (UINTN)-1, Character);
552 }
553
554 Character = BOXDRAW_UP_LEFT;
555 PrintCharAt ((UINTN)-1, (UINTN)-1, Character);
556
557 if (Key != NULL) {
558 Status = WaitForKeyStroke (&KeyValue);
559 ASSERT_EFI_ERROR (Status);
560 CopyMem (Key, &KeyValue, sizeof (EFI_INPUT_KEY));
561 }
562
563 gST->ConOut->SetAttribute (gST->ConOut, CurrentAttribute);
564 gST->ConOut->EnableCursor (gST->ConOut, CursorVisible);
565}
566
567/**
568 Confirm how to handle the changed data.
569
570 @return Action BROWSER_ACTION_SUBMIT, BROWSER_ACTION_DISCARD or other values.
571**/
572UINTN
573EFIAPI
574ConfirmDataChange (
575 VOID
576 )
577{
578 CHAR16 YesResponse;
579 CHAR16 NoResponse;
580 EFI_INPUT_KEY Key;
581
582 gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
583
584 YesResponse = gYesResponse[0];
585 NoResponse = gNoResponse[0];
586
587 //
588 // If NV flag is up, prompt user
589 //
590 do {
591 CreateDialog (&Key, gLibEmptyString, gSaveChanges, gAreYouSure, gLibEmptyString, NULL);
592 } while
593 (
594 (Key.ScanCode != SCAN_ESC) &&
595 ((Key.UnicodeChar | UPPER_LOWER_CASE_OFFSET) != (NoResponse | UPPER_LOWER_CASE_OFFSET)) &&
596 ((Key.UnicodeChar | UPPER_LOWER_CASE_OFFSET) != (YesResponse | UPPER_LOWER_CASE_OFFSET))
597 );
598
599 if (Key.ScanCode == SCAN_ESC) {
600 return BROWSER_ACTION_NONE;
601 } else if ((Key.UnicodeChar | UPPER_LOWER_CASE_OFFSET) == (YesResponse | UPPER_LOWER_CASE_OFFSET)) {
602 return BROWSER_ACTION_SUBMIT;
603 } else {
604 return BROWSER_ACTION_DISCARD;
605 }
606}
607
608/**
609 OEM specifies whether Setup exits Page by ESC key.
610
611 This function customized the behavior that whether Setup exits Page so that
612 system able to boot when configuration is not changed.
613
614 @retval TRUE Exits FrontPage
615 @retval FALSE Don't exit FrontPage.
616**/
617BOOLEAN
618EFIAPI
619FormExitPolicy (
620 VOID
621 )
622{
623 return gClassOfVfr == FORMSET_CLASS_FRONT_PAGE ? FALSE : TRUE;
624}
625
626/**
627 Set Timeout value for a ceratain Form to get user response.
628
629 This function allows to set timeout value on a ceratain form if necessary.
630 If timeout is not zero, the form will exit if user has no response in timeout.
631
632 @param[in] FormData Form Data to be shown in Page
633
634 @return 0 No timeout for this form.
635 @return > 0 Timeout value in 100 ns units.
636**/
637UINT64
638EFIAPI
639FormExitTimeout (
640 IN FORM_DISPLAY_ENGINE_FORM *FormData
641 )
642{
643 return 0;
644}
645
646//
647// Print Functions
648//
649
650/**
651 Prints a unicode string to the default console, at
652 the supplied cursor position, using L"%s" format.
653
654 @param Column The cursor position to print the string at. When it is -1, use current Position.
655 @param Row The cursor position to print the string at. When it is -1, use current Position.
656 @param String String pointer.
657
658 @return Length of string printed to the console
659
660**/
661UINTN
662EFIAPI
663PrintStringAt (
664 IN UINTN Column,
665 IN UINTN Row,
666 IN CHAR16 *String
667 )
668{
669 return PrintAt (0, Column, Row, L"%s", String);
670}
671
672/**
673 Prints a unicode string to the default console, at
674 the supplied cursor position, using L"%s" format.
675
676 @param Column The cursor position to print the string at. When it is -1, use current Position.
677 @param Row The cursor position to print the string at. When it is -1, use current Position.
678 @param String String pointer.
679 @param Width Width for String.
680
681 @return Length of string printed to the console
682
683**/
684UINTN
685EFIAPI
686PrintStringAtWithWidth (
687 IN UINTN Column,
688 IN UINTN Row,
689 IN CHAR16 *String,
690 IN UINTN Width
691 )
692{
693 return PrintAt (Width, Column, Row, L"%s", String);
694}
695
696/**
697 Prints a character to the default console, at
698 the supplied cursor position, using L"%c" format.
699
700 @param Column The cursor position to print the string at. When it is -1, use current Position.
701 @param Row The cursor position to print the string at. When it is -1, use current Position.
702 @param Character Character to print.
703
704 @return Length of string printed to the console.
705
706**/
707UINTN
708EFIAPI
709PrintCharAt (
710 IN UINTN Column,
711 IN UINTN Row,
712 CHAR16 Character
713 )
714{
715 return PrintAt (0, Column, Row, L"%c", Character);
716}
717
718/**
719 Clear retangle with specified text attribute.
720
721 @param LeftColumn Left column of retangle.
722 @param RightColumn Right column of retangle.
723 @param TopRow Start row of retangle.
724 @param BottomRow End row of retangle.
725 @param TextAttribute The character foreground and background.
726
727**/
728VOID
729EFIAPI
730ClearLines (
731 IN UINTN LeftColumn,
732 IN UINTN RightColumn,
733 IN UINTN TopRow,
734 IN UINTN BottomRow,
735 IN UINTN TextAttribute
736 )
737{
738 CHAR16 *Buffer;
739 UINTN Row;
740
741 //
742 // For now, allocate an arbitrarily long buffer
743 //
744 Buffer = AllocateZeroPool (0x10000);
745 ASSERT (Buffer != NULL);
746
747 //
748 // Set foreground and background as defined
749 //
750 gST->ConOut->SetAttribute (gST->ConOut, TextAttribute);
751
752 //
753 // Much faster to buffer the long string instead of print it a character at a time
754 //
755 LibSetUnicodeMem (Buffer, RightColumn - LeftColumn, L' ');
756
757 //
758 // Clear the desired area with the appropriate foreground/background
759 //
760 for (Row = TopRow; Row <= BottomRow; Row++) {
761 PrintStringAt (LeftColumn, Row, Buffer);
762 }
763
764 gST->ConOut->SetCursorPosition (gST->ConOut, LeftColumn, TopRow);
765
766 FreePool (Buffer);
767}
768
769//
770// Color Setting Functions
771//
772
773/**
774 Get OEM/Vendor specific popup attribute colors.
775
776 @retval Byte code color setting for popup color.
777**/
778UINT8
779EFIAPI
780GetPopupColor (
781 VOID
782 )
783{
784 return POPUP_TEXT | POPUP_BACKGROUND;
785}
786
787/**
788 Get OEM/Vendor specific popup attribute colors.
789
790 @retval Byte code color setting for popup inverse color.
791**/
792UINT8
793EFIAPI
794GetPopupInverseColor (
795 VOID
796 )
797{
798 return POPUP_INVERSE_TEXT | POPUP_INVERSE_BACKGROUND;
799}
800
801/**
802 Get OEM/Vendor specific PickList color attribute.
803
804 @retval Byte code color setting for pick list color.
805**/
806UINT8
807EFIAPI
808GetPickListColor (
809 VOID
810 )
811{
812 return PICKLIST_HIGHLIGHT_TEXT | PICKLIST_HIGHLIGHT_BACKGROUND;
813}
814
815/**
816 Get OEM/Vendor specific arrow color attribute.
817
818 @retval Byte code color setting for arrow color.
819**/
820UINT8
821EFIAPI
822GetArrowColor (
823 VOID
824 )
825{
826 return ARROW_TEXT | ARROW_BACKGROUND;
827}
828
829/**
830 Get OEM/Vendor specific info text color attribute.
831
832 @retval Byte code color setting for info text color.
833**/
834UINT8
835EFIAPI
836GetInfoTextColor (
837 VOID
838 )
839{
840 return INFO_TEXT | FIELD_BACKGROUND;
841}
842
843/**
844 Get OEM/Vendor specific help text color attribute.
845
846 @retval Byte code color setting for help text color.
847**/
848UINT8
849EFIAPI
850GetHelpTextColor (
851 VOID
852 )
853{
854 return HELP_TEXT | FIELD_BACKGROUND;
855}
856
857/**
858 Get OEM/Vendor specific grayed out text color attribute.
859
860 @retval Byte code color setting for grayed out text color.
861**/
862UINT8
863EFIAPI
864GetGrayedTextColor (
865 VOID
866 )
867{
868 return FIELD_TEXT_GRAYED | FIELD_BACKGROUND;
869}
870
871/**
872 Get OEM/Vendor specific highlighted text color attribute.
873
874 @retval Byte code color setting for highlight text color.
875**/
876UINT8
877EFIAPI
878GetHighlightTextColor (
879 VOID
880 )
881{
882 return PcdGet8 (PcdBrowserFieldTextHighlightColor) | PcdGet8 (PcdBrowserFieldBackgroundHighlightColor);
883}
884
885/**
886 Get OEM/Vendor specific field text color attribute.
887
888 @retval Byte code color setting for field text color.
889**/
890UINT8
891EFIAPI
892GetFieldTextColor (
893 VOID
894 )
895{
896 return PcdGet8 (PcdBrowserFieldTextColor) | FIELD_BACKGROUND;
897}
898
899/**
900 Get OEM/Vendor specific subtitle text color attribute.
901
902 @retval Byte code color setting for subtitle text color.
903**/
904UINT8
905EFIAPI
906GetSubTitleTextColor (
907 VOID
908 )
909{
910 return PcdGet8 (PcdBrowserSubtitleTextColor) | FIELD_BACKGROUND;
911}
912
913/**
914 Clear Screen to the initial state.
915**/
916VOID
917EFIAPI
918ClearDisplayPage (
919 VOID
920 )
921{
922 gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK));
923 gST->ConOut->ClearScreen (gST->ConOut);
924 gLibIsFirstForm = TRUE;
925}
926
927/**
928 Constructor of Customized Display Library Instance.
929
930 @param ImageHandle The firmware allocated handle for the EFI image.
931 @param SystemTable A pointer to the EFI System Table.
932
933 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
934
935**/
936EFI_STATUS
937EFIAPI
938CustomizedDisplayLibConstructor (
939 IN EFI_HANDLE ImageHandle,
940 IN EFI_SYSTEM_TABLE *SystemTable
941 )
942{
943 mCDLStringPackHandle = HiiAddPackages (&gCustomizedDisplayLibGuid, ImageHandle, CustomizedDisplayLibStrings, NULL);
944 ASSERT (mCDLStringPackHandle != NULL);
945
946 InitializeLibStrings ();
947
948 return EFI_SUCCESS;
949}
950
951/**
952 Destructor of Customized Display Library Instance.
953
954 @param ImageHandle The firmware allocated handle for the EFI image.
955 @param SystemTable A pointer to the EFI System Table.
956
957 @retval EFI_SUCCESS The destructor completed successfully.
958 @retval Other value The destructor did not complete successfully.
959
960**/
961EFI_STATUS
962EFIAPI
963CustomizedDisplayLibDestructor (
964 IN EFI_HANDLE ImageHandle,
965 IN EFI_SYSTEM_TABLE *SystemTable
966 )
967{
968 HiiRemovePackages (mCDLStringPackHandle);
969
970 FreeLibStrings ();
971
972 return EFI_SUCCESS;
973}
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette