Changeset 99404 in vbox for trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenu.c
- Timestamp:
- Apr 14, 2023 3:17:44 PM (23 months ago)
- svn:sync-xref-src-repo-rev:
- 156854
- Location:
- trunk/src/VBox/Devices/EFI/FirmwareNew
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/EFI/FirmwareNew
-
Property svn:mergeinfo
changed from (toggle deleted branches)
to (toggle deleted branches)/vendor/edk2/current 103735-103757,103769-103776,129194-145445 /vendor/edk2/current 103735-103757,103769-103776,129194-156846
-
Property svn:mergeinfo
changed from (toggle deleted branches)
-
trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenu.c
r89983 r99404 2 2 The application to show the Boot Manager Menu. 3 3 4 Copyright (c) 2011 - 20 18, Intel Corporation. All rights reserved.<BR>4 Copyright (c) 2011 - 2021, Intel Corporation. All rights reserved.<BR> 5 5 SPDX-License-Identifier: BSD-2-Clause-Patent 6 6 … … 9 9 #include "BootManagerMenu.h" 10 10 11 EFI_HII_HANDLE gStringPackHandle;12 13 BOOLEAN 11 EFI_HII_HANDLE gStringPackHandle; 12 13 BOOLEAN mModeInitialized = FALSE; 14 14 15 15 // 16 16 // Boot video resolution and text mode. 17 17 // 18 UINT32 mBootHorizontalResolution= 0;19 UINT32 mBootVerticalResolution= 0;20 UINT32 mBootTextModeColumn= 0;21 UINT32 mBootTextModeRow= 0;18 UINT32 mBootHorizontalResolution = 0; 19 UINT32 mBootVerticalResolution = 0; 20 UINT32 mBootTextModeColumn = 0; 21 UINT32 mBootTextModeRow = 0; 22 22 // 23 23 // BIOS setup video resolution and text mode. 24 24 // 25 UINT32 mSetupTextModeColumn= 0;26 UINT32 mSetupTextModeRow= 0;27 UINT32 mSetupHorizontalResolution= 0;28 UINT32 mSetupVerticalResolution= 0;25 UINT32 mSetupTextModeColumn = 0; 26 UINT32 mSetupTextModeRow = 0; 27 UINT32 mSetupHorizontalResolution = 0; 28 UINT32 mSetupVerticalResolution = 0; 29 29 30 30 /** … … 41 41 UINTN 42 42 PrintStringAt ( 43 IN UINTN 44 IN UINTN 45 IN CHAR16 43 IN UINTN Column, 44 IN UINTN Row, 45 IN CHAR16 *String 46 46 ) 47 47 { 48 UINTN ScreenWidth; 49 UINTN ScreenRows; 50 CHAR16 *TurncateString; 51 EFI_STATUS Status; 52 UINTN ShowingLength; 48 53 49 54 gST->ConOut->SetCursorPosition (gST->ConOut, Column, Row); 50 return Print (L"%s", String); 55 56 gST->ConOut->QueryMode ( 57 gST->ConOut, 58 gST->ConOut->Mode->Mode, 59 &ScreenWidth, 60 &ScreenRows 61 ); 62 63 if ((Column > (ScreenWidth - 1)) || (Row > (ScreenRows - 1))) { 64 return 0; 65 } 66 67 if ((StrLen (String) + Column) > (ScreenWidth - 1)) { 68 // 69 // | - ScreenWidth - | 70 // ...Column..................... 71 // TurncateString length should leave one character for draw box and 72 // require one character for string end. 73 // 74 ShowingLength = ScreenWidth - Column - 1; 75 TurncateString = AllocatePool ((ShowingLength + 1) * sizeof (CHAR16)); 76 77 if (TurncateString == NULL) { 78 return 0; 79 } 80 81 Status = StrnCpyS (TurncateString, ShowingLength + 1, String, ShowingLength - 3); 82 83 if (EFI_ERROR (Status)) { 84 FreePool (TurncateString); 85 return 0; 86 } 87 88 *(TurncateString + ShowingLength - 3) = L'.'; 89 *(TurncateString + ShowingLength - 2) = L'.'; 90 *(TurncateString + ShowingLength - 1) = L'.'; 91 *(TurncateString + ShowingLength) = L'\0'; 92 ShowingLength = Print (L"%s", TurncateString); 93 FreePool (TurncateString); 94 return ShowingLength; 95 } else { 96 return Print (L"%s", String); 97 } 51 98 } 52 99 … … 64 111 UINTN 65 112 PrintCharAt ( 66 IN UINTN 67 IN UINTN 68 CHAR16 113 IN UINTN Column, 114 IN UINTN Row, 115 CHAR16 Character 69 116 ) 70 117 { 118 UINTN ScreenWidth; 119 UINTN ScreenRows; 120 71 121 gST->ConOut->SetCursorPosition (gST->ConOut, Column, Row); 122 123 gST->ConOut->QueryMode ( 124 gST->ConOut, 125 gST->ConOut->Mode->Mode, 126 &ScreenWidth, 127 &ScreenRows 128 ); 129 130 if ((Column > (ScreenWidth - 1)) || (Row > (ScreenRows - 1))) { 131 return 0; 132 } 133 72 134 return Print (L"%c", Character); 73 135 } … … 84 146 UINTN 85 147 GetLineWidth ( 86 IN EFI_STRING_ID 148 IN EFI_STRING_ID StringId 87 149 ) 88 150 { 89 UINTN 90 UINTN 91 EFI_STRING 92 UINTN 151 UINTN Index; 152 UINTN IncrementValue; 153 EFI_STRING String; 154 UINTN LineWidth; 93 155 94 156 LineWidth = 0; 95 String = HiiGetString (gStringPackHandle, StringId, NULL);157 String = HiiGetString (gStringPackHandle, StringId, NULL); 96 158 97 159 if (String != NULL) { 98 Index 99 IncrementValue 160 Index = 0; 161 IncrementValue = 1; 100 162 101 163 do { … … 103 165 // Advance to the null-terminator or to the first width directive 104 166 // 105 for (; 106 (String[Index] != NARROW_CHAR) && (String[Index] != WIDE_CHAR) && (String[Index] != 0); 107 Index++, LineWidth = LineWidth + IncrementValue 108 ) 109 ; 167 for ( ; 168 (String[Index] != NARROW_CHAR) && (String[Index] != WIDE_CHAR) && (String[Index] != 0); 169 Index++, LineWidth = LineWidth + IncrementValue 170 ) 171 { 172 } 110 173 111 174 // … … 115 178 break; 116 179 } 180 117 181 // 118 182 // We encountered a narrow directive - strip it from the size calculation since it doesn't get printed … … 133 197 } 134 198 } while (String[Index] != 0); 199 135 200 FreePool (String); 136 201 } … … 153 218 ) 154 219 { 155 UINTN 156 UINTN 157 UINTN 158 UINTN 159 UINTN 160 UINTN 161 UINTN 220 UINTN MaxStrWidth; 221 UINTN StrWidth; 222 UINTN Index; 223 UINTN Column; 224 UINTN Row; 225 UINTN MaxPrintRows; 226 UINTN UnSelectableItmes; 162 227 163 228 if (BootMenuData == NULL) { 164 229 return EFI_INVALID_PARAMETER; 165 230 } 231 166 232 // 167 233 // Get maximum string width … … 169 235 MaxStrWidth = 0; 170 236 for (Index = 0; Index < TITLE_TOKEN_COUNT; Index++) { 171 StrWidth = GetLineWidth (BootMenuData->TitleToken[Index]);237 StrWidth = GetLineWidth (BootMenuData->TitleToken[Index]); 172 238 MaxStrWidth = MaxStrWidth > StrWidth ? MaxStrWidth : StrWidth; 173 239 } 174 240 175 241 for (Index = 0; Index < BootMenuData->ItemCount; Index++) { 176 StrWidth = GetLineWidth (BootMenuData->PtrTokens[Index]);242 StrWidth = GetLineWidth (BootMenuData->PtrTokens[Index]); 177 243 MaxStrWidth = MaxStrWidth > StrWidth ? MaxStrWidth : StrWidth; 178 244 } 179 245 180 246 for (Index = 0; Index < HELP_TOKEN_COUNT; Index++) { 181 StrWidth = GetLineWidth (BootMenuData->HelpToken[Index]);247 StrWidth = GetLineWidth (BootMenuData->HelpToken[Index]); 182 248 MaxStrWidth = MaxStrWidth > StrWidth ? MaxStrWidth : StrWidth; 183 249 } 250 184 251 // 185 252 // query current row and column to calculate boot menu location … … 192 259 ); 193 260 194 MaxPrintRows = Row - 6;261 MaxPrintRows = Row - 6; 195 262 UnSelectableItmes = TITLE_TOKEN_COUNT + 2 + HELP_TOKEN_COUNT + 2; 196 BootMenuData->MenuScreen.Width = MaxStrWidth + 8; 263 if (MaxStrWidth + 8 > Column) { 264 BootMenuData->MenuScreen.Width = Column; 265 } else { 266 BootMenuData->MenuScreen.Width = MaxStrWidth + 8; 267 } 268 197 269 if (BootMenuData->ItemCount + UnSelectableItmes > MaxPrintRows) { 198 BootMenuData->MenuScreen.Height = MaxPrintRows;199 BootMenuData->ScrollBarControl.HasScrollBar = TRUE;270 BootMenuData->MenuScreen.Height = MaxPrintRows; 271 BootMenuData->ScrollBarControl.HasScrollBar = TRUE; 200 272 BootMenuData->ScrollBarControl.ItemCountPerScreen = MaxPrintRows - UnSelectableItmes; 201 BootMenuData->ScrollBarControl.FirstItem = 0;202 BootMenuData->ScrollBarControl.LastItem = MaxPrintRows - UnSelectableItmes - 1;273 BootMenuData->ScrollBarControl.FirstItem = 0; 274 BootMenuData->ScrollBarControl.LastItem = MaxPrintRows - UnSelectableItmes - 1; 203 275 } else { 204 BootMenuData->MenuScreen.Height = BootMenuData->ItemCount + UnSelectableItmes;205 BootMenuData->ScrollBarControl.HasScrollBar = FALSE;276 BootMenuData->MenuScreen.Height = BootMenuData->ItemCount + UnSelectableItmes; 277 BootMenuData->ScrollBarControl.HasScrollBar = FALSE; 206 278 BootMenuData->ScrollBarControl.ItemCountPerScreen = BootMenuData->ItemCount; 207 BootMenuData->ScrollBarControl.FirstItem = 0; 208 BootMenuData->ScrollBarControl.LastItem = BootMenuData->ItemCount - 1; 209 } 279 BootMenuData->ScrollBarControl.FirstItem = 0; 280 BootMenuData->ScrollBarControl.LastItem = BootMenuData->ItemCount - 1; 281 } 282 210 283 BootMenuData->MenuScreen.StartCol = (Column - BootMenuData->MenuScreen.Width) / 2; 211 284 BootMenuData->MenuScreen.StartRow = (Row - BootMenuData->MenuScreen.Height) / 2; … … 213 286 return EFI_SUCCESS; 214 287 } 288 215 289 /** 216 290 This function uses check boot option is wheher setup application or no … … 224 298 BOOLEAN 225 299 IsBootManagerMenu ( 226 IN EFI_BOOT_MANAGER_LOAD_OPTION 300 IN EFI_BOOT_MANAGER_LOAD_OPTION *BootOption 227 301 ) 228 302 { 229 EFI_STATUS 230 EFI_BOOT_MANAGER_LOAD_OPTION 303 EFI_STATUS Status; 304 EFI_BOOT_MANAGER_LOAD_OPTION BootManagerMenu; 231 305 232 306 Status = EfiBootManagerGetBootManagerMenu (&BootManagerMenu); … … 235 309 } 236 310 237 return (BOOLEAN) 311 return (BOOLEAN)(!EFI_ERROR (Status) && (BootOption->OptionNumber == BootManagerMenu.OptionNumber)); 238 312 } 239 313 … … 251 325 ) 252 326 { 253 EFI_STATUS 254 EFI_DEVICE_PATH_PROTOCOL 327 EFI_STATUS Status; 328 EFI_DEVICE_PATH_PROTOCOL *ImageDevicePath; 255 329 256 330 // 257 331 // Ignore myself. 258 332 // 259 Status = gBS->HandleProtocol (gImageHandle, &gEfiLoadedImageDevicePathProtocolGuid, (VOID **) 333 Status = gBS->HandleProtocol (gImageHandle, &gEfiLoadedImageDevicePathProtocolGuid, (VOID **)&ImageDevicePath); 260 334 ASSERT_EFI_ERROR (Status); 261 335 if (CompareMem (BootOption->FilePath, ImageDevicePath, GetDevicePathSize (ImageDevicePath)) == 0) { … … 298 372 ) 299 373 { 300 UINTN 301 UINTN 302 303 if ( BootOption == NULL || BootMenuData == NULL) {374 UINTN Index; 375 UINTN StrIndex; 376 377 if ((BootOption == NULL) || (BootMenuData == NULL)) { 304 378 return EFI_INVALID_PARAMETER; 305 379 } … … 326 400 } 327 401 328 BootMenuData->ItemCount 402 BootMenuData->ItemCount = StrIndex; 329 403 BootMenuData->HelpToken[0] = STRING_TOKEN (STR_BOOT_POPUP_MENU_HELP1_STRING); 330 404 BootMenuData->HelpToken[1] = STRING_TOKEN (STR_BOOT_POPUP_MENU_HELP2_STRING); … … 352 426 ) 353 427 { 354 INT32 355 EFI_STRING 356 UINTN 357 UINTN 358 UINTN 359 UINTN 360 UINTN 361 UINTN 362 UINTN 363 UINTN 364 UINTN 365 UINTN 366 BOOLEAN 367 368 if ( BootMenuData == NULL || WantSelectItem >= BootMenuData->ItemCount) {428 INT32 SavedAttribute; 429 EFI_STRING String; 430 UINTN StartCol; 431 UINTN StartRow; 432 UINTN PrintCol; 433 UINTN PrintRow; 434 UINTN TopShadeNum; 435 UINTN LowShadeNum; 436 UINTN FirstItem; 437 UINTN LastItem; 438 UINTN ItemCountPerScreen; 439 UINTN Index; 440 BOOLEAN RePaintItems; 441 442 if ((BootMenuData == NULL) || (WantSelectItem >= BootMenuData->ItemCount)) { 369 443 return EFI_INVALID_PARAMETER; 370 444 } 445 371 446 ASSERT (BootMenuData->ItemCount != 0); 372 447 SavedAttribute = gST->ConOut->Mode->Attribute; 373 RePaintItems = FALSE;374 StartCol = BootMenuData->MenuScreen.StartCol;375 StartRow = BootMenuData->MenuScreen.StartRow;448 RePaintItems = FALSE; 449 StartCol = BootMenuData->MenuScreen.StartCol; 450 StartRow = BootMenuData->MenuScreen.StartRow; 376 451 // 377 452 // print selectable items again and adjust scroll bar if need 378 453 // 379 454 if (BootMenuData->ScrollBarControl.HasScrollBar && 380 (WantSelectItem < BootMenuData->ScrollBarControl.FirstItem || 381 WantSelectItem > BootMenuData->ScrollBarControl.LastItem || 382 WantSelectItem == BootMenuData->SelectItem)) { 383 ItemCountPerScreen = BootMenuData->ScrollBarControl.ItemCountPerScreen; 455 ((WantSelectItem < BootMenuData->ScrollBarControl.FirstItem) || 456 (WantSelectItem > BootMenuData->ScrollBarControl.LastItem) || 457 (WantSelectItem == BootMenuData->SelectItem))) 458 { 459 ItemCountPerScreen = BootMenuData->ScrollBarControl.ItemCountPerScreen; 384 460 // 385 461 // Set first item and last item … … 387 463 if (WantSelectItem < BootMenuData->ScrollBarControl.FirstItem) { 388 464 BootMenuData->ScrollBarControl.FirstItem = WantSelectItem; 389 BootMenuData->ScrollBarControl.LastItem = WantSelectItem + ItemCountPerScreen - 1;465 BootMenuData->ScrollBarControl.LastItem = WantSelectItem + ItemCountPerScreen - 1; 390 466 } else if (WantSelectItem > BootMenuData->ScrollBarControl.LastItem) { 391 467 BootMenuData->ScrollBarControl.FirstItem = WantSelectItem - ItemCountPerScreen + 1; 392 BootMenuData->ScrollBarControl.LastItem = WantSelectItem; 393 } 468 BootMenuData->ScrollBarControl.LastItem = WantSelectItem; 469 } 470 394 471 gST->ConOut->SetAttribute (gST->ConOut, EFI_WHITE | EFI_BACKGROUND_BLUE); 395 FirstItem = BootMenuData->ScrollBarControl.FirstItem;396 LastItem = BootMenuData->ScrollBarControl.LastItem;472 FirstItem = BootMenuData->ScrollBarControl.FirstItem; 473 LastItem = BootMenuData->ScrollBarControl.LastItem; 397 474 TopShadeNum = 0; 398 475 if (FirstItem != 0) { … … 401 478 TopShadeNum++; 402 479 } 480 403 481 PrintCol = StartCol + BootMenuData->MenuScreen.Width - 2; 404 482 PrintRow = StartRow + TITLE_TOKEN_COUNT + 2; … … 407 485 } 408 486 } 487 409 488 LowShadeNum = 0; 410 489 if (LastItem != BootMenuData->ItemCount - 1) { … … 413 492 LowShadeNum++; 414 493 } 494 415 495 PrintCol = StartCol + BootMenuData->MenuScreen.Width - 2; 416 496 PrintRow = StartRow + TITLE_TOKEN_COUNT + 2 + ItemCountPerScreen - LowShadeNum; … … 419 499 } 420 500 } 501 421 502 PrintCol = StartCol + BootMenuData->MenuScreen.Width - 2; 422 503 PrintRow = StartRow + TITLE_TOKEN_COUNT + 2 + TopShadeNum; … … 425 506 } 426 507 427 428 508 // 429 509 // Clear selectable items first … … 431 511 PrintCol = StartCol + 1; 432 512 PrintRow = StartRow + TITLE_TOKEN_COUNT + 2; 433 String = AllocateZeroPool ((BootMenuData->MenuScreen.Width - 2) * sizeof (CHAR16));513 String = AllocateZeroPool ((BootMenuData->MenuScreen.Width - 2) * sizeof (CHAR16)); 434 514 ASSERT (String != NULL); 435 515 for (Index = 0; Index < BootMenuData->MenuScreen.Width - 3; Index++) { 436 516 String[Index] = 0x20; 437 517 } 518 438 519 for (Index = 0; Index < ItemCountPerScreen; Index++) { 439 520 PrintStringAt (PrintCol, PrintRow + Index, String); 440 521 } 522 441 523 FreePool (String); 442 524 // … … 448 530 FreePool (String); 449 531 } 532 450 533 RePaintItems = TRUE; 451 534 } … … 456 539 // 457 540 FirstItem = BootMenuData->ScrollBarControl.FirstItem; 458 if ( WantSelectItem != BootMenuData->SelectItem&& !RePaintItems) {541 if ((WantSelectItem != BootMenuData->SelectItem) && !RePaintItems) { 459 542 gST->ConOut->SetAttribute (gST->ConOut, EFI_WHITE | EFI_BACKGROUND_BLUE); 460 String = HiiGetString (gStringPackHandle, BootMenuData->PtrTokens[BootMenuData->SelectItem], NULL);543 String = HiiGetString (gStringPackHandle, BootMenuData->PtrTokens[BootMenuData->SelectItem], NULL); 461 544 PrintCol = StartCol + 1; 462 545 PrintRow = StartRow + 3 + BootMenuData->SelectItem - FirstItem; … … 469 552 // 470 553 gST->ConOut->SetAttribute (gST->ConOut, EFI_WHITE | EFI_BACKGROUND_BLACK); 471 String = HiiGetString (gStringPackHandle, BootMenuData->PtrTokens[WantSelectItem], NULL);554 String = HiiGetString (gStringPackHandle, BootMenuData->PtrTokens[WantSelectItem], NULL); 472 555 PrintCol = StartCol + 1; 473 556 PrintRow = StartRow + TITLE_TOKEN_COUNT + 2 + WantSelectItem - FirstItem; … … 493 576 ) 494 577 { 495 EFI_STRING 496 UINTN 497 UINTN 498 UINTN 499 UINTN 500 UINTN 501 UINTN 502 UINTN 503 INT32 504 UINTN 578 EFI_STRING String; 579 UINTN Index; 580 UINTN Width; 581 UINTN StartCol; 582 UINTN StartRow; 583 UINTN PrintRow; 584 UINTN PrintCol; 585 UINTN LineWidth; 586 INT32 SavedAttribute; 587 UINTN ItemCountPerScreen; 505 588 506 589 gST->ConOut->ClearScreen (gST->ConOut); … … 508 591 SavedAttribute = gST->ConOut->Mode->Attribute; 509 592 gST->ConOut->SetAttribute (gST->ConOut, EFI_WHITE | EFI_BACKGROUND_BLUE); 510 Width = BootMenuData->MenuScreen.Width;511 StartCol = BootMenuData->MenuScreen.StartCol;512 StartRow = BootMenuData->MenuScreen.StartRow;593 Width = BootMenuData->MenuScreen.Width; 594 StartCol = BootMenuData->MenuScreen.StartCol; 595 StartRow = BootMenuData->MenuScreen.StartRow; 513 596 ItemCountPerScreen = BootMenuData->ScrollBarControl.ItemCountPerScreen; 514 PrintRow = StartRow;597 PrintRow = StartRow; 515 598 516 599 gST->ConOut->EnableCursor (gST->ConOut, FALSE); … … 522 605 PrintCharAt (StartCol + Index, PrintRow, BOXDRAW_HORIZONTAL); 523 606 } 607 524 608 PrintCharAt (StartCol + Width - 1, PrintRow, BOXDRAW_DOWN_LEFT); 525 609 … … 545 629 PrintCharAt (StartCol + Index, PrintRow, BOXDRAW_HORIZONTAL); 546 630 } 631 547 632 PrintCharAt (StartCol + Width - 1, PrintRow, BOXDRAW_VERTICAL_LEFT); 548 633 … … 562 647 PrintCharAt (StartCol + Index, PrintRow, BOXDRAW_HORIZONTAL); 563 648 } 649 564 650 PrintCharAt (StartCol + Width - 1, PrintRow, BOXDRAW_VERTICAL_LEFT); 565 651 … … 573 659 PrintCharAt (StartCol + Width - 1, PrintRow, BOXDRAW_VERTICAL); 574 660 } 661 575 662 FreePool (String); 576 663 … … 580 667 PrintCharAt (StartCol + Index, PrintRow, BOXDRAW_HORIZONTAL); 581 668 } 669 582 670 PrintCharAt (StartCol + Width - 1, PrintRow, BOXDRAW_UP_LEFT); 583 584 671 585 672 // … … 588 675 PrintRow = StartRow + 1; 589 676 for (Index = 0; Index < TITLE_TOKEN_COUNT; Index++, PrintRow++) { 590 String = HiiGetString (gStringPackHandle, BootMenuData->TitleToken[Index], NULL);677 String = HiiGetString (gStringPackHandle, BootMenuData->TitleToken[Index], NULL); 591 678 LineWidth = GetLineWidth (BootMenuData->TitleToken[Index]); 592 PrintCol = StartCol + (Width - LineWidth) / 2;679 PrintCol = StartCol + (Width - LineWidth) / 2; 593 680 PrintStringAt (PrintCol, PrintRow, String); 594 681 FreePool (String); … … 611 698 PrintRow++; 612 699 for (Index = 0; Index < HELP_TOKEN_COUNT; Index++, PrintRow++) { 613 String = HiiGetString (gStringPackHandle, BootMenuData->HelpToken[Index], NULL);700 String = HiiGetString (gStringPackHandle, BootMenuData->HelpToken[Index], NULL); 614 701 LineWidth = GetLineWidth (BootMenuData->HelpToken[Index]); 615 PrintCol = StartCol + (Width - LineWidth) / 2;702 PrintCol = StartCol + (Width - LineWidth) / 2; 616 703 PrintStringAt (PrintCol, PrintRow, String); 617 704 FreePool (String); … … 653 740 ) 654 741 { 655 UINTN 656 UINTN 742 UINTN ItemNum; 743 UINTN Index; 657 744 658 745 ASSERT (BootOptions != NULL); … … 713 800 gST->ConsoleOutHandle, 714 801 &gEfiGraphicsOutputProtocolGuid, 715 (VOID **)&GraphicsOutput802 (VOID **)&GraphicsOutput 716 803 ); 717 804 if (EFI_ERROR (Status)) { … … 722 809 gST->ConsoleOutHandle, 723 810 &gEfiSimpleTextOutProtocolGuid, 724 (VOID **)&SimpleTextOut811 (VOID **)&SimpleTextOut 725 812 ); 726 813 if (EFI_ERROR (Status)) { … … 751 838 752 839 if (GraphicsOutput != NULL) { 753 MaxGopMode 840 MaxGopMode = GraphicsOutput->Mode->MaxMode; 754 841 } 755 842 … … 767 854 for (ModeNumber = 0; ModeNumber < MaxGopMode; ModeNumber++) { 768 855 Status = GraphicsOutput->QueryMode ( 769 GraphicsOutput,770 ModeNumber,771 &SizeOfInfo,772 &Info773 );856 GraphicsOutput, 857 ModeNumber, 858 &SizeOfInfo, 859 &Info 860 ); 774 861 if (!EFI_ERROR (Status)) { 775 862 if ((Info->HorizontalResolution == NewHorizontalResolution) && 776 (Info->VerticalResolution == NewVerticalResolution)) { 863 (Info->VerticalResolution == NewVerticalResolution)) 864 { 777 865 if ((GraphicsOutput->Mode->Info->HorizontalResolution == NewHorizontalResolution) && 778 (GraphicsOutput->Mode->Info->VerticalResolution == NewVerticalResolution)) { 866 (GraphicsOutput->Mode->Info->VerticalResolution == NewVerticalResolution)) 867 { 779 868 // 780 869 // Current resolution is same with required resolution, check if text mode need be set … … 782 871 Status = SimpleTextOut->QueryMode (SimpleTextOut, SimpleTextOut->Mode->Mode, &CurrentColumn, &CurrentRow); 783 872 ASSERT_EFI_ERROR (Status); 784 if ( CurrentColumn == NewColumns && CurrentRow == NewRows) {873 if ((CurrentColumn == NewColumns) && (CurrentRow == NewRows)) { 785 874 // 786 875 // If current text mode is same with required text mode. Do nothing … … 794 883 for (Index = 0; Index < MaxTextMode; Index++) { 795 884 Status = SimpleTextOut->QueryMode (SimpleTextOut, Index, &CurrentColumn, &CurrentRow); 796 if (!EFI_ERROR (Status)) {885 if (!EFI_ERROR (Status)) { 797 886 if ((CurrentColumn == NewColumns) && (CurrentRow == NewRows)) { 798 887 // … … 813 902 } 814 903 } 904 815 905 if (Index == MaxTextMode) { 816 906 // … … 833 923 } 834 924 } 925 835 926 FreePool (Info); 836 927 } … … 863 954 // 864 955 Status = gBS->LocateHandleBuffer ( 865 866 867 868 869 870 956 ByProtocol, 957 &gEfiSimpleTextOutProtocolGuid, 958 NULL, 959 &HandleCount, 960 &HandleBuffer 961 ); 871 962 if (!EFI_ERROR (Status)) { 872 963 for (Index = 0; Index < HandleCount; Index++) { 873 964 gBS->DisconnectController (HandleBuffer[Index], NULL, NULL); 874 965 } 966 875 967 for (Index = 0; Index < HandleCount; Index++) { 876 968 gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE); 877 969 } 970 878 971 if (HandleBuffer != NULL) { 879 972 FreePool (HandleBuffer); … … 897 990 EFIAPI 898 991 BootManagerMenuEntry ( 899 IN EFI_HANDLE 900 IN EFI_SYSTEM_TABLE 992 IN EFI_HANDLE ImageHandle, 993 IN EFI_SYSTEM_TABLE *SystemTable 901 994 ) 902 995 { 903 EFI_BOOT_MANAGER_LOAD_OPTION *BootOption;904 UINTN BootOptionCount;905 EFI_STATUS Status;906 BOOT_MENU_POPUP_DATA BootMenuData;907 UINTN Index;908 EFI_INPUT_KEY Key;909 BOOLEAN ExitApplication;910 UINTN SelectItem;911 EFI_BOOT_LOGO_PROTOCOL *BootLogo;912 EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;913 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut;914 UINTN BootTextColumn;915 UINTN BootTextRow;996 EFI_BOOT_MANAGER_LOAD_OPTION *BootOption; 997 UINTN BootOptionCount; 998 EFI_STATUS Status; 999 BOOT_MENU_POPUP_DATA BootMenuData; 1000 UINTN Index; 1001 EFI_INPUT_KEY Key; 1002 BOOLEAN ExitApplication; 1003 UINTN SelectItem; 1004 EFI_BOOT_LOGO_PROTOCOL *BootLogo; 1005 EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput; 1006 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut; 1007 UINTN BootTextColumn; 1008 UINTN BootTextRow; 916 1009 917 1010 // … … 919 1012 // 920 1013 BootLogo = NULL; 921 Status = gBS->LocateProtocol (&gEfiBootLogoProtocolGuid, NULL, (VOID **)&BootLogo);1014 Status = gBS->LocateProtocol (&gEfiBootLogoProtocolGuid, NULL, (VOID **)&BootLogo); 922 1015 if (!EFI_ERROR (Status) && (BootLogo != NULL)) { 923 1016 Status = BootLogo->SetBootLogo (BootLogo, NULL, 0, 0, 0, 0); … … 928 1021 929 1022 gStringPackHandle = HiiAddPackages ( 930 931 932 933 934 1023 &gEfiCallerIdGuid, 1024 gImageHandle, 1025 BootManagerMenuAppStrings, 1026 NULL 1027 ); 935 1028 ASSERT (gStringPackHandle != NULL); 936 1029 … … 951 1044 gST->ConsoleOutHandle, 952 1045 &gEfiGraphicsOutputProtocolGuid, 953 (VOID **)&GraphicsOutput1046 (VOID **)&GraphicsOutput 954 1047 ); 955 1048 if (EFI_ERROR (Status)) { … … 960 1053 gST->ConsoleOutHandle, 961 1054 &gEfiSimpleTextOutProtocolGuid, 962 (VOID **)&SimpleTextOut1055 (VOID **)&SimpleTextOut 963 1056 ); 964 1057 if (EFI_ERROR (Status)) { … … 1018 1111 if (!EFI_ERROR (Status)) { 1019 1112 switch (Key.UnicodeChar) { 1020 1021 case CHAR_NULL: 1022 switch (Key.ScanCode) { 1023 1024 case SCAN_UP: 1025 SelectItem = BootMenuData.SelectItem == 0 ? BootMenuData.ItemCount - 1 : BootMenuData.SelectItem - 1; 1026 BootMenuSelectItem (SelectItem, &BootMenuData); 1113 case CHAR_NULL: 1114 switch (Key.ScanCode) { 1115 case SCAN_UP: 1116 SelectItem = BootMenuData.SelectItem == 0 ? BootMenuData.ItemCount - 1 : BootMenuData.SelectItem - 1; 1117 BootMenuSelectItem (SelectItem, &BootMenuData); 1118 break; 1119 1120 case SCAN_DOWN: 1121 SelectItem = BootMenuData.SelectItem == BootMenuData.ItemCount - 1 ? 0 : BootMenuData.SelectItem + 1; 1122 BootMenuSelectItem (SelectItem, &BootMenuData); 1123 break; 1124 1125 case SCAN_ESC: 1126 gST->ConOut->ClearScreen (gST->ConOut); 1127 ExitApplication = TRUE; 1128 // 1129 // Set boot resolution for normal boot 1130 // 1131 BdsSetConsoleMode (FALSE); 1132 break; 1133 1134 default: 1135 break; 1136 } 1137 1027 1138 break; 1028 1139 1029 case SCAN_DOWN: 1030 SelectItem = BootMenuData.SelectItem == BootMenuData.ItemCount - 1 ? 0 : BootMenuData.SelectItem + 1; 1031 BootMenuSelectItem (SelectItem, &BootMenuData); 1032 break; 1033 1034 case SCAN_ESC: 1140 case CHAR_CARRIAGE_RETURN: 1035 1141 gST->ConOut->ClearScreen (gST->ConOut); 1036 ExitApplication = TRUE;1037 1142 // 1038 1143 // Set boot resolution for normal boot 1039 1144 // 1040 1145 BdsSetConsoleMode (FALSE); 1146 BootFromSelectOption (BootOption, BootOptionCount, BootMenuData.SelectItem); 1147 // 1148 // Back to boot manager menu again, set back to setup resolution 1149 // 1150 BdsSetConsoleMode (TRUE); 1151 DrawBootPopupMenu (&BootMenuData); 1041 1152 break; 1042 1153 1043 1154 default: 1044 1155 break; 1045 }1046 break;1047 1048 case CHAR_CARRIAGE_RETURN:1049 gST->ConOut->ClearScreen (gST->ConOut);1050 //1051 // Set boot resolution for normal boot1052 //1053 BdsSetConsoleMode (FALSE);1054 BootFromSelectOption (BootOption, BootOptionCount, BootMenuData.SelectItem);1055 //1056 // Back to boot manager menu again, set back to setup resolution1057 //1058 BdsSetConsoleMode (TRUE);1059 DrawBootPopupMenu (&BootMenuData);1060 break;1061 1062 default:1063 break;1064 1156 } 1065 1157 } 1066 1158 } 1159 1067 1160 EfiBootManagerFreeLoadOptions (BootOption, BootOptionCount); 1068 1161 FreePool (BootMenuData.PtrTokens); … … 1071 1164 1072 1165 return Status; 1073 1074 1166 }
Note:
See TracChangeset
for help on using the changeset viewer.