VirtualBox

Ignore:
Timestamp:
Apr 14, 2023 3:17:44 PM (23 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
156854
Message:

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

Location:
trunk/src/VBox/Devices/EFI/FirmwareNew
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/EFI/FirmwareNew

  • trunk/src/VBox/Devices/EFI/FirmwareNew/MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenu.c

    r89983 r99404  
    22  The application to show the Boot Manager Menu.
    33
    4 Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
     4Copyright (c) 2011 - 2021, Intel Corporation. All rights reserved.<BR>
    55SPDX-License-Identifier: BSD-2-Clause-Patent
    66
     
    99#include "BootManagerMenu.h"
    1010
    11 EFI_HII_HANDLE gStringPackHandle;
    12 
    13 BOOLEAN   mModeInitialized = FALSE;
     11EFI_HII_HANDLE  gStringPackHandle;
     12
     13BOOLEAN  mModeInitialized = FALSE;
    1414
    1515//
    1616// Boot video resolution and text mode.
    1717//
    18 UINT32    mBootHorizontalResolution    = 0;
    19 UINT32    mBootVerticalResolution      = 0;
    20 UINT32    mBootTextModeColumn          = 0;
    21 UINT32    mBootTextModeRow             = 0;
     18UINT32  mBootHorizontalResolution = 0;
     19UINT32  mBootVerticalResolution   = 0;
     20UINT32  mBootTextModeColumn       = 0;
     21UINT32  mBootTextModeRow          = 0;
    2222//
    2323// BIOS setup video resolution and text mode.
    2424//
    25 UINT32    mSetupTextModeColumn         = 0;
    26 UINT32    mSetupTextModeRow            = 0;
    27 UINT32    mSetupHorizontalResolution  = 0;
    28 UINT32    mSetupVerticalResolution     = 0;
     25UINT32  mSetupTextModeColumn       = 0;
     26UINT32  mSetupTextModeRow          = 0;
     27UINT32  mSetupHorizontalResolution = 0;
     28UINT32  mSetupVerticalResolution   = 0;
    2929
    3030/**
     
    4141UINTN
    4242PrintStringAt (
    43   IN UINTN     Column,
    44   IN UINTN     Row,
    45   IN CHAR16    *String
     43  IN UINTN   Column,
     44  IN UINTN   Row,
     45  IN CHAR16  *String
    4646  )
    4747{
     48  UINTN       ScreenWidth;
     49  UINTN       ScreenRows;
     50  CHAR16      *TurncateString;
     51  EFI_STATUS  Status;
     52  UINTN       ShowingLength;
    4853
    4954  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  }
    5198}
    5299
     
    64111UINTN
    65112PrintCharAt (
    66   IN UINTN     Column,
    67   IN UINTN     Row,
    68   CHAR16       Character
     113  IN UINTN  Column,
     114  IN UINTN  Row,
     115  CHAR16    Character
    69116  )
    70117{
     118  UINTN  ScreenWidth;
     119  UINTN  ScreenRows;
     120
    71121  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
    72134  return Print (L"%c", Character);
    73135}
     
    84146UINTN
    85147GetLineWidth (
    86   IN EFI_STRING_ID       StringId
     148  IN EFI_STRING_ID  StringId
    87149  )
    88150{
    89   UINTN        Index;
    90   UINTN        IncrementValue;
    91   EFI_STRING   String;
    92   UINTN        LineWidth;
     151  UINTN       Index;
     152  UINTN       IncrementValue;
     153  EFI_STRING  String;
     154  UINTN       LineWidth;
    93155
    94156  LineWidth = 0;
    95   String = HiiGetString (gStringPackHandle, StringId, NULL);
     157  String    = HiiGetString (gStringPackHandle, StringId, NULL);
    96158
    97159  if (String != NULL) {
    98     Index           = 0;
    99     IncrementValue  = 1;
     160    Index          = 0;
     161    IncrementValue = 1;
    100162
    101163    do {
     
    103165      // Advance to the null-terminator or to the first width directive
    104166      //
    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      }
    110173
    111174      //
     
    115178        break;
    116179      }
     180
    117181      //
    118182      // We encountered a narrow directive - strip it from the size calculation since it doesn't get printed
     
    133197      }
    134198    } while (String[Index] != 0);
     199
    135200    FreePool (String);
    136201  }
     
    153218  )
    154219{
    155   UINTN         MaxStrWidth;
    156   UINTN         StrWidth;
    157   UINTN         Index;
    158   UINTN         Column;
    159   UINTN         Row;
    160   UINTN         MaxPrintRows;
    161   UINTN         UnSelectableItmes;
     220  UINTN  MaxStrWidth;
     221  UINTN  StrWidth;
     222  UINTN  Index;
     223  UINTN  Column;
     224  UINTN  Row;
     225  UINTN  MaxPrintRows;
     226  UINTN  UnSelectableItmes;
    162227
    163228  if (BootMenuData == NULL) {
    164229    return EFI_INVALID_PARAMETER;
    165230  }
     231
    166232  //
    167233  // Get maximum string width
     
    169235  MaxStrWidth = 0;
    170236  for (Index = 0; Index < TITLE_TOKEN_COUNT; Index++) {
    171     StrWidth = GetLineWidth (BootMenuData->TitleToken[Index]);
     237    StrWidth    = GetLineWidth (BootMenuData->TitleToken[Index]);
    172238    MaxStrWidth = MaxStrWidth > StrWidth ? MaxStrWidth : StrWidth;
    173239  }
    174240
    175241  for (Index = 0; Index < BootMenuData->ItemCount; Index++) {
    176     StrWidth = GetLineWidth (BootMenuData->PtrTokens[Index]);
     242    StrWidth    = GetLineWidth (BootMenuData->PtrTokens[Index]);
    177243    MaxStrWidth = MaxStrWidth > StrWidth ? MaxStrWidth : StrWidth;
    178244  }
    179245
    180246  for (Index = 0; Index < HELP_TOKEN_COUNT; Index++) {
    181     StrWidth = GetLineWidth (BootMenuData->HelpToken[Index]);
     247    StrWidth    = GetLineWidth (BootMenuData->HelpToken[Index]);
    182248    MaxStrWidth = MaxStrWidth > StrWidth ? MaxStrWidth : StrWidth;
    183249  }
     250
    184251  //
    185252  // query current row and column to calculate boot menu location
     
    192259                 );
    193260
    194   MaxPrintRows = Row - 6;
     261  MaxPrintRows      = Row - 6;
    195262  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
    197269  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;
    200272    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;
    203275  } 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;
    206278    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
    210283  BootMenuData->MenuScreen.StartCol = (Column -  BootMenuData->MenuScreen.Width) / 2;
    211284  BootMenuData->MenuScreen.StartRow = (Row -  BootMenuData->MenuScreen.Height) / 2;
     
    213286  return EFI_SUCCESS;
    214287}
     288
    215289/**
    216290  This function uses check boot option is wheher setup application or no
     
    224298BOOLEAN
    225299IsBootManagerMenu (
    226   IN  EFI_BOOT_MANAGER_LOAD_OPTION    *BootOption
     300  IN  EFI_BOOT_MANAGER_LOAD_OPTION  *BootOption
    227301  )
    228302{
    229   EFI_STATUS                          Status;
    230   EFI_BOOT_MANAGER_LOAD_OPTION        BootManagerMenu;
     303  EFI_STATUS                    Status;
     304  EFI_BOOT_MANAGER_LOAD_OPTION  BootManagerMenu;
    231305
    232306  Status = EfiBootManagerGetBootManagerMenu (&BootManagerMenu);
     
    235309  }
    236310
    237   return (BOOLEAN) (!EFI_ERROR (Status) && (BootOption->OptionNumber == BootManagerMenu.OptionNumber));
     311  return (BOOLEAN)(!EFI_ERROR (Status) && (BootOption->OptionNumber == BootManagerMenu.OptionNumber));
    238312}
    239313
     
    251325  )
    252326{
    253   EFI_STATUS                    Status;
    254   EFI_DEVICE_PATH_PROTOCOL      *ImageDevicePath;
     327  EFI_STATUS                Status;
     328  EFI_DEVICE_PATH_PROTOCOL  *ImageDevicePath;
    255329
    256330  //
    257331  // Ignore myself.
    258332  //
    259   Status = gBS->HandleProtocol (gImageHandle, &gEfiLoadedImageDevicePathProtocolGuid, (VOID **) &ImageDevicePath);
     333  Status = gBS->HandleProtocol (gImageHandle, &gEfiLoadedImageDevicePathProtocolGuid, (VOID **)&ImageDevicePath);
    260334  ASSERT_EFI_ERROR (Status);
    261335  if (CompareMem (BootOption->FilePath, ImageDevicePath, GetDevicePathSize (ImageDevicePath)) == 0) {
     
    298372  )
    299373{
    300   UINTN                         Index;
    301   UINTN                         StrIndex;
    302 
    303   if (BootOption == NULL || BootMenuData == NULL) {
     374  UINTN  Index;
     375  UINTN  StrIndex;
     376
     377  if ((BootOption == NULL) || (BootMenuData == NULL)) {
    304378    return EFI_INVALID_PARAMETER;
    305379  }
     
    326400  }
    327401
    328   BootMenuData->ItemCount           = StrIndex;
     402  BootMenuData->ItemCount    = StrIndex;
    329403  BootMenuData->HelpToken[0] = STRING_TOKEN (STR_BOOT_POPUP_MENU_HELP1_STRING);
    330404  BootMenuData->HelpToken[1] = STRING_TOKEN (STR_BOOT_POPUP_MENU_HELP2_STRING);
     
    352426  )
    353427{
    354   INT32                 SavedAttribute;
    355   EFI_STRING            String;
    356   UINTN                 StartCol;
    357   UINTN                 StartRow;
    358   UINTN                 PrintCol;
    359   UINTN                 PrintRow;
    360   UINTN                 TopShadeNum;
    361   UINTN                 LowShadeNum;
    362   UINTN                 FirstItem;
    363   UINTN                 LastItem;
    364   UINTN                 ItemCountPerScreen;
    365   UINTN                 Index;
    366   BOOLEAN               RePaintItems;
    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)) {
    369443    return EFI_INVALID_PARAMETER;
    370444  }
     445
    371446  ASSERT (BootMenuData->ItemCount != 0);
    372447  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;
    376451  //
    377452  // print selectable items again and adjust scroll bar if need
    378453  //
    379454  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;
    384460    //
    385461    // Set first item and last item
     
    387463    if (WantSelectItem < BootMenuData->ScrollBarControl.FirstItem) {
    388464      BootMenuData->ScrollBarControl.FirstItem = WantSelectItem;
    389       BootMenuData->ScrollBarControl.LastItem = WantSelectItem + ItemCountPerScreen - 1;
     465      BootMenuData->ScrollBarControl.LastItem  = WantSelectItem + ItemCountPerScreen - 1;
    390466    } else if (WantSelectItem > BootMenuData->ScrollBarControl.LastItem) {
    391467      BootMenuData->ScrollBarControl.FirstItem = WantSelectItem - ItemCountPerScreen + 1;
    392       BootMenuData->ScrollBarControl.LastItem = WantSelectItem;
    393     }
     468      BootMenuData->ScrollBarControl.LastItem  = WantSelectItem;
     469    }
     470
    394471    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;
    397474    TopShadeNum = 0;
    398475    if (FirstItem != 0) {
     
    401478        TopShadeNum++;
    402479      }
     480
    403481      PrintCol = StartCol  + BootMenuData->MenuScreen.Width - 2;
    404482      PrintRow = StartRow + TITLE_TOKEN_COUNT + 2;
     
    407485      }
    408486    }
     487
    409488    LowShadeNum = 0;
    410489    if (LastItem != BootMenuData->ItemCount - 1) {
     
    413492        LowShadeNum++;
    414493      }
     494
    415495      PrintCol = StartCol  + BootMenuData->MenuScreen.Width - 2;
    416496      PrintRow = StartRow + TITLE_TOKEN_COUNT + 2 + ItemCountPerScreen - LowShadeNum;
     
    419499      }
    420500    }
     501
    421502    PrintCol = StartCol  + BootMenuData->MenuScreen.Width - 2;
    422503    PrintRow = StartRow + TITLE_TOKEN_COUNT + 2 + TopShadeNum;
     
    425506    }
    426507
    427 
    428508    //
    429509    // Clear selectable items first
     
    431511    PrintCol = StartCol  + 1;
    432512    PrintRow = StartRow + TITLE_TOKEN_COUNT + 2;
    433     String = AllocateZeroPool ((BootMenuData->MenuScreen.Width - 2) * sizeof (CHAR16));
     513    String   = AllocateZeroPool ((BootMenuData->MenuScreen.Width - 2) * sizeof (CHAR16));
    434514    ASSERT (String != NULL);
    435515    for (Index = 0; Index < BootMenuData->MenuScreen.Width - 3; Index++) {
    436516      String[Index] = 0x20;
    437517    }
     518
    438519    for (Index = 0; Index < ItemCountPerScreen; Index++) {
    439520      PrintStringAt (PrintCol, PrintRow + Index, String);
    440521    }
     522
    441523    FreePool (String);
    442524    //
     
    448530      FreePool (String);
    449531    }
     532
    450533    RePaintItems = TRUE;
    451534  }
     
    456539  //
    457540  FirstItem = BootMenuData->ScrollBarControl.FirstItem;
    458   if (WantSelectItem != BootMenuData->SelectItem && !RePaintItems) {
     541  if ((WantSelectItem != BootMenuData->SelectItem) && !RePaintItems) {
    459542    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);
    461544    PrintCol = StartCol  + 1;
    462545    PrintRow = StartRow + 3 + BootMenuData->SelectItem - FirstItem;
     
    469552  //
    470553  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);
    472555  PrintCol = StartCol  + 1;
    473556  PrintRow = StartRow + TITLE_TOKEN_COUNT + 2 + WantSelectItem - FirstItem;
     
    493576  )
    494577{
    495   EFI_STRING            String;
    496   UINTN                 Index;
    497   UINTN                 Width;
    498   UINTN                 StartCol;
    499   UINTN                 StartRow;
    500   UINTN                 PrintRow;
    501   UINTN                 PrintCol;
    502   UINTN                 LineWidth;
    503   INT32                 SavedAttribute;
    504   UINTN                 ItemCountPerScreen;
     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;
    505588
    506589  gST->ConOut->ClearScreen (gST->ConOut);
     
    508591  SavedAttribute = gST->ConOut->Mode->Attribute;
    509592  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;
    513596  ItemCountPerScreen = BootMenuData->ScrollBarControl.ItemCountPerScreen;
    514   PrintRow = StartRow;
     597  PrintRow           = StartRow;
    515598
    516599  gST->ConOut->EnableCursor (gST->ConOut, FALSE);
     
    522605    PrintCharAt (StartCol + Index, PrintRow, BOXDRAW_HORIZONTAL);
    523606  }
     607
    524608  PrintCharAt (StartCol + Width - 1, PrintRow, BOXDRAW_DOWN_LEFT);
    525609
     
    545629    PrintCharAt (StartCol + Index, PrintRow, BOXDRAW_HORIZONTAL);
    546630  }
     631
    547632  PrintCharAt (StartCol + Width - 1, PrintRow, BOXDRAW_VERTICAL_LEFT);
    548633
     
    562647    PrintCharAt (StartCol + Index, PrintRow, BOXDRAW_HORIZONTAL);
    563648  }
     649
    564650  PrintCharAt (StartCol + Width - 1, PrintRow, BOXDRAW_VERTICAL_LEFT);
    565651
     
    573659    PrintCharAt (StartCol + Width - 1, PrintRow, BOXDRAW_VERTICAL);
    574660  }
     661
    575662  FreePool (String);
    576663
     
    580667    PrintCharAt (StartCol + Index, PrintRow, BOXDRAW_HORIZONTAL);
    581668  }
     669
    582670  PrintCharAt (StartCol + Width - 1, PrintRow, BOXDRAW_UP_LEFT);
    583 
    584671
    585672  //
     
    588675  PrintRow = StartRow + 1;
    589676  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);
    591678    LineWidth = GetLineWidth (BootMenuData->TitleToken[Index]);
    592     PrintCol = StartCol + (Width - LineWidth) / 2;
     679    PrintCol  = StartCol + (Width - LineWidth) / 2;
    593680    PrintStringAt (PrintCol, PrintRow, String);
    594681    FreePool (String);
     
    611698  PrintRow++;
    612699  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);
    614701    LineWidth = GetLineWidth (BootMenuData->HelpToken[Index]);
    615     PrintCol = StartCol + (Width - LineWidth) / 2;
     702    PrintCol  = StartCol + (Width - LineWidth) / 2;
    616703    PrintStringAt (PrintCol, PrintRow, String);
    617704    FreePool (String);
     
    653740  )
    654741{
    655   UINTN                 ItemNum;
    656   UINTN                 Index;
     742  UINTN  ItemNum;
     743  UINTN  Index;
    657744
    658745  ASSERT (BootOptions != NULL);
     
    713800                  gST->ConsoleOutHandle,
    714801                  &gEfiGraphicsOutputProtocolGuid,
    715                   (VOID**)&GraphicsOutput
     802                  (VOID **)&GraphicsOutput
    716803                  );
    717804  if (EFI_ERROR (Status)) {
     
    722809                  gST->ConsoleOutHandle,
    723810                  &gEfiSimpleTextOutProtocolGuid,
    724                   (VOID**)&SimpleTextOut
     811                  (VOID **)&SimpleTextOut
    725812                  );
    726813  if (EFI_ERROR (Status)) {
     
    751838
    752839  if (GraphicsOutput != NULL) {
    753     MaxGopMode  = GraphicsOutput->Mode->MaxMode;
     840    MaxGopMode = GraphicsOutput->Mode->MaxMode;
    754841  }
    755842
     
    767854  for (ModeNumber = 0; ModeNumber < MaxGopMode; ModeNumber++) {
    768855    Status = GraphicsOutput->QueryMode (
    769                        GraphicsOutput,
    770                        ModeNumber,
    771                        &SizeOfInfo,
    772                        &Info
    773                        );
     856                               GraphicsOutput,
     857                               ModeNumber,
     858                               &SizeOfInfo,
     859                               &Info
     860                               );
    774861    if (!EFI_ERROR (Status)) {
    775862      if ((Info->HorizontalResolution == NewHorizontalResolution) &&
    776           (Info->VerticalResolution == NewVerticalResolution)) {
     863          (Info->VerticalResolution == NewVerticalResolution))
     864      {
    777865        if ((GraphicsOutput->Mode->Info->HorizontalResolution == NewHorizontalResolution) &&
    778             (GraphicsOutput->Mode->Info->VerticalResolution == NewVerticalResolution)) {
     866            (GraphicsOutput->Mode->Info->VerticalResolution == NewVerticalResolution))
     867        {
    779868          //
    780869          // Current resolution is same with required resolution, check if text mode need be set
     
    782871          Status = SimpleTextOut->QueryMode (SimpleTextOut, SimpleTextOut->Mode->Mode, &CurrentColumn, &CurrentRow);
    783872          ASSERT_EFI_ERROR (Status);
    784           if (CurrentColumn == NewColumns && CurrentRow == NewRows) {
     873          if ((CurrentColumn == NewColumns) && (CurrentRow == NewRows)) {
    785874            //
    786875            // If current text mode is same with required text mode. Do nothing
     
    794883            for (Index = 0; Index < MaxTextMode; Index++) {
    795884              Status = SimpleTextOut->QueryMode (SimpleTextOut, Index, &CurrentColumn, &CurrentRow);
    796               if (!EFI_ERROR(Status)) {
     885              if (!EFI_ERROR (Status)) {
    797886                if ((CurrentColumn == NewColumns) && (CurrentRow == NewRows)) {
    798887                  //
     
    813902              }
    814903            }
     904
    815905            if (Index == MaxTextMode) {
    816906              //
     
    833923        }
    834924      }
     925
    835926      FreePool (Info);
    836927    }
     
    863954  //
    864955  Status = gBS->LocateHandleBuffer (
    865                    ByProtocol,
    866                    &gEfiSimpleTextOutProtocolGuid,
    867                    NULL,
    868                    &HandleCount,
    869                    &HandleBuffer
    870                    );
     956                  ByProtocol,
     957                  &gEfiSimpleTextOutProtocolGuid,
     958                  NULL,
     959                  &HandleCount,
     960                  &HandleBuffer
     961                  );
    871962  if (!EFI_ERROR (Status)) {
    872963    for (Index = 0; Index < HandleCount; Index++) {
    873964      gBS->DisconnectController (HandleBuffer[Index], NULL, NULL);
    874965    }
     966
    875967    for (Index = 0; Index < HandleCount; Index++) {
    876968      gBS->ConnectController (HandleBuffer[Index], NULL, NULL, TRUE);
    877969    }
     970
    878971    if (HandleBuffer != NULL) {
    879972      FreePool (HandleBuffer);
     
    897990EFIAPI
    898991BootManagerMenuEntry (
    899   IN EFI_HANDLE                            ImageHandle,
    900   IN EFI_SYSTEM_TABLE                      *SystemTable
     992  IN EFI_HANDLE        ImageHandle,
     993  IN EFI_SYSTEM_TABLE  *SystemTable
    901994  )
    902995{
    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;
    9161009
    9171010  //
     
    9191012  //
    9201013  BootLogo = NULL;
    921   Status = gBS->LocateProtocol (&gEfiBootLogoProtocolGuid, NULL, (VOID **) &BootLogo);
     1014  Status   = gBS->LocateProtocol (&gEfiBootLogoProtocolGuid, NULL, (VOID **)&BootLogo);
    9221015  if (!EFI_ERROR (Status) && (BootLogo != NULL)) {
    9231016    Status = BootLogo->SetBootLogo (BootLogo, NULL, 0, 0, 0, 0);
     
    9281021
    9291022  gStringPackHandle = HiiAddPackages (
    930                          &gEfiCallerIdGuid,
    931                          gImageHandle,
    932                          BootManagerMenuAppStrings,
    933                          NULL
    934                          );
     1023                        &gEfiCallerIdGuid,
     1024                        gImageHandle,
     1025                        BootManagerMenuAppStrings,
     1026                        NULL
     1027                        );
    9351028  ASSERT (gStringPackHandle != NULL);
    9361029
     
    9511044                    gST->ConsoleOutHandle,
    9521045                    &gEfiGraphicsOutputProtocolGuid,
    953                     (VOID**)&GraphicsOutput
     1046                    (VOID **)&GraphicsOutput
    9541047                    );
    9551048    if (EFI_ERROR (Status)) {
     
    9601053                    gST->ConsoleOutHandle,
    9611054                    &gEfiSimpleTextOutProtocolGuid,
    962                     (VOID**)&SimpleTextOut
     1055                    (VOID **)&SimpleTextOut
    9631056                    );
    9641057    if (EFI_ERROR (Status)) {
     
    10181111    if (!EFI_ERROR (Status)) {
    10191112      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
    10271138          break;
    10281139
    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:
    10351141          gST->ConOut->ClearScreen (gST->ConOut);
    1036           ExitApplication = TRUE;
    10371142          //
    10381143          // Set boot resolution for normal boot
    10391144          //
    10401145          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);
    10411152          break;
    10421153
    10431154        default:
    10441155          break;
    1045         }
    1046         break;
    1047 
    1048       case CHAR_CARRIAGE_RETURN:
    1049         gST->ConOut->ClearScreen (gST->ConOut);
    1050         //
    1051         // Set boot resolution for normal boot
    1052         //
    1053         BdsSetConsoleMode (FALSE);
    1054         BootFromSelectOption (BootOption, BootOptionCount, BootMenuData.SelectItem);
    1055         //
    1056         // Back to boot manager menu again, set back to setup resolution
    1057         //
    1058         BdsSetConsoleMode (TRUE);
    1059         DrawBootPopupMenu (&BootMenuData);
    1060         break;
    1061 
    1062       default:
    1063         break;
    10641156      }
    10651157    }
    10661158  }
     1159
    10671160  EfiBootManagerFreeLoadOptions (BootOption, BootOptionCount);
    10681161  FreePool (BootMenuData.PtrTokens);
     
    10711164
    10721165  return Status;
    1073 
    10741166}
Note: See TracChangeset for help on using the changeset viewer.

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