VirtualBox

Changeset 67918 in vbox


Ignore:
Timestamp:
Jul 12, 2017 9:30:24 AM (7 years ago)
Author:
vboxsync
Message:

Main/Console: EFI graphics resolution cleanup, prepare for resolution based mode selection by default
Devices/EFI: use new CFGM keys (fall back to old ones if necessary), clean up variable and info field naming
Devices/EFI/Firmware: for both GOP and UGA (which is very deprecated) try to find the mode by resolution if possible

Location:
trunk/src/VBox
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/EFI/DevEFI.cpp

    r67586 r67918  
    222222    /** Virtual machine CPU frequency. */
    223223    uint64_t                u64CpuFrequency;
    224     /** GOP mode. */
    225     uint32_t                u32GopMode;
    226     /** Uga mode horizontal resolution. */
    227     uint32_t                cxUgaResolution;
    228     /** Uga mode vertical resolution. */
    229     uint32_t                cyUgaResolution;
     224    /** EFI Graphics mode (used as fallback if resolution is not known). */
     225    uint32_t                u32GraphicsMode;
     226    /** EFI Graphics (GOP or UGA) horizontal resolution. */
     227    uint32_t                u32HorizontalResolution;
     228    /** EFI Graphics (GOP or UGA) vertical resolution. */
     229    uint32_t                u32VerticalResolution;
    230230    /** Physical address of PCI config space MMIO region */
    231231    uint64_t                u64McfgBase;
     
    11051105        case EFI_INFO_INDEX_STACK_BASE:
    11061106        case EFI_INFO_INDEX_STACK_SIZE:
    1107         case EFI_INFO_INDEX_GOP_MODE:
    1108         case EFI_INFO_INDEX_UGA_VERTICAL_RESOLUTION:
    1109         case EFI_INFO_INDEX_UGA_HORIZONTAL_RESOLUTION:
     1107        case EFI_INFO_INDEX_GRAPHICS_MODE:
     1108        case EFI_INFO_INDEX_VERTICAL_RESOLUTION:
     1109        case EFI_INFO_INDEX_HORIZONTAL_RESOLUTION:
    11101110            return 4;
    11111111        case EFI_INFO_INDEX_BOOT_ARGS:
     
    11901190        case EFI_INFO_INDEX_BOOT_ARGS:          return efiInfoNextByteBuf(pThis, pThis->szBootArgs, sizeof(pThis->szBootArgs));
    11911191        case EFI_INFO_INDEX_DEVICE_PROPS:       return efiInfoNextByteBuf(pThis, pThis->pbDeviceProps, pThis->cbDeviceProps);
    1192         case EFI_INFO_INDEX_GOP_MODE:           return efiInfoNextByteU32(pThis, pThis->u32GopMode);
    1193         case EFI_INFO_INDEX_UGA_HORIZONTAL_RESOLUTION:  return efiInfoNextByteU32(pThis, pThis->cxUgaResolution);
    1194         case EFI_INFO_INDEX_UGA_VERTICAL_RESOLUTION:    return efiInfoNextByteU32(pThis, pThis->cyUgaResolution);
     1192        case EFI_INFO_INDEX_GRAPHICS_MODE:      return efiInfoNextByteU32(pThis, pThis->u32GraphicsMode);
     1193        case EFI_INFO_INDEX_HORIZONTAL_RESOLUTION:  return efiInfoNextByteU32(pThis, pThis->u32HorizontalResolution);
     1194        case EFI_INFO_INDEX_VERTICAL_RESOLUTION:    return efiInfoNextByteU32(pThis, pThis->u32VerticalResolution);
    11951195
    11961196        /* Keep in sync with value in EfiThunk.asm */
     
    14671467                pThis->szMsg[pThis->iMsg] = '\0';
    14681468                if (pThis->iMsg)
    1469                     Log(("efi: %s\n", pThis->szMsg));
     1469                    LogRel(("efi: %s\n", pThis->szMsg));
    14701470                pThis->iMsg = 0;
    14711471            }
     
    14751475                {
    14761476                    pThis->szMsg[pThis->iMsg] = '\0';
    1477                     Log(("efi: %s\n", pThis->szMsg));
     1477                    LogRel(("efi: %s\n", pThis->szMsg));
    14781478                    pThis->iMsg = 0;
    14791479                }
     
    21892189                              "BootArgs\0"
    21902190                              "DeviceProps\0"
    2191                               "GopMode\0"
    2192                               "UgaHorizontalResolution\0"
    2193                               "UgaVerticalResolution\0"))
     2191                              "GopMode\0"                   // legacy
     2192                              "GraphicsMode\0"
     2193                              "UgaHorizontalResolution\0"   // legacy
     2194                              "UgaVerticalResolution\0"     // legacy
     2195                              "HorizontalResolution\0"
     2196                              "VerticalResolution\0"))
    21942197        return PDMDEV_SET_ERROR(pDevIns, VERR_PDM_DEVINS_UNKNOWN_CFG_VALUES,
    21952198                                N_("Configuration error: Invalid config value(s) for the EFI device"));
     
    23192322
    23202323    /*
    2321      * GOP graphics.
    2322      */
    2323     rc = CFGMR3QueryU32Def(pCfg, "GopMode", &pThis->u32GopMode, 2 /* 1024x768 */);
     2324     * EFI graphics mode (with new EFI VGA code used only as a fallback, for
     2325     * old EFI VGA code the only way to select the GOP mode).
     2326     */
     2327    rc = CFGMR3QueryU32Def(pCfg, "GraphicsMode", &pThis->u32GraphicsMode, UINT32_MAX);
    23242328    if (RT_FAILURE(rc))
    23252329        return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS,
    2326                                    N_("Configuration error: Querying \"GopMode\" as a 32-bit int failed"));
    2327     if (pThis->u32GopMode == UINT32_MAX)
    2328         pThis->u32GopMode = 2; /* 1024x768 */
    2329 
    2330     /*
    2331      * Uga graphics, default to 1024x768.
    2332      */
    2333     rc = CFGMR3QueryU32Def(pCfg, "UgaHorizontalResolution", &pThis->cxUgaResolution, 0);
     2330                                   N_("Configuration error: Querying \"GraphicsMode\" as a 32-bit int failed"));
     2331    if (pThis->u32GraphicsMode == UINT32_MAX)
     2332    {
     2333        /* get the legacy value if nothing else was specified */
     2334        rc = CFGMR3QueryU32Def(pCfg, "GopMode", &pThis->u32GraphicsMode, UINT32_MAX);
     2335        if (RT_FAILURE(rc))
     2336            return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS,
     2337                                       N_("Configuration error: Querying \"GopMode\" as a 32-bit int failed"));
     2338    }
     2339    if (pThis->u32GraphicsMode == UINT32_MAX)
     2340        pThis->u32GraphicsMode = 2; /* 1024x768 */
     2341
     2342    /*
     2343     * EFI graphics resolution, defaults to 1024x768 (used to be UGA only, now
     2344     * is the main config setting as the mode number is so hard to predict).
     2345     */
     2346    rc = CFGMR3QueryU32Def(pCfg, "HorizontalResolution", &pThis->u32HorizontalResolution, 0);
    23342347    AssertRCReturn(rc, rc);
    2335     rc = CFGMR3QueryU32Def(pCfg, "UgaVerticalResolution", &pThis->cyUgaResolution, 0);
     2348    rc = CFGMR3QueryU32Def(pCfg, "VerticalResolution", &pThis->u32VerticalResolution, 0);
    23362349    AssertRCReturn(rc, rc);
    2337     if (pThis->cxUgaResolution == 0 || pThis->cyUgaResolution == 0)
    2338     {
    2339         pThis->cxUgaResolution = 1024;
    2340         pThis->cyUgaResolution = 768;
     2350    if (pThis->u32HorizontalResolution == 0 || pThis->u32VerticalResolution == 0)
     2351    {
     2352        /* get the legacy values if nothing else was specified */
     2353        rc = CFGMR3QueryU32Def(pCfg, "UgaHorizontalResolution", &pThis->u32HorizontalResolution, 0);
     2354        AssertRCReturn(rc, rc);
     2355        rc = CFGMR3QueryU32Def(pCfg, "UgaVerticalResolution", &pThis->u32VerticalResolution, 0);
     2356        AssertRCReturn(rc, rc);
     2357    }
     2358    if (pThis->u32HorizontalResolution == 0 || pThis->u32VerticalResolution == 0)
     2359    {
     2360        pThis->u32HorizontalResolution = 1024;
     2361        pThis->u32VerticalResolution = 768;
    23412362    }
    23422363
  • trunk/src/VBox/Devices/EFI/DevEFI.h

    r67912 r67918  
    6666    EFI_INFO_INDEX_CPU_FREQUENCY,
    6767    EFI_INFO_INDEX_TSC_FREQUENCY,
    68     EFI_INFO_INDEX_GOP_MODE,
    69     EFI_INFO_INDEX_UGA_HORIZONTAL_RESOLUTION,
    70     EFI_INFO_INDEX_UGA_VERTICAL_RESOLUTION,
     68    EFI_INFO_INDEX_GRAPHICS_MODE,
     69    EFI_INFO_INDEX_HORIZONTAL_RESOLUTION,
     70    EFI_INFO_INDEX_VERTICAL_RESOLUTION,
    7171    EFI_INFO_INDEX_MCFG_BASE,
    7272    EFI_INFO_INDEX_MCFG_SIZE,
  • trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/VBoxVgaDxe/VBoxVgaGraphicsOutput.c

    r67356 r67918  
    426426  )
    427427{
    428   EFI_STATUS                   Status;
    429   EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
    430   UINT32                        GopMode = 2;
     428  EFI_STATUS                    Status;
     429  EFI_GRAPHICS_OUTPUT_PROTOCOL  *GraphicsOutput;
     430  UINT32                        Index;
     431  UINT32                        HorizontalResolution = 1024;
     432  UINT32                        VerticalResolution = 768;
     433  UINT32                        ColorDepth = 32;
     434
     435  DEBUG((DEBUG_INFO, "%a:%d construct\n", __FILE__, __LINE__));
    431436
    432437  GraphicsOutput            = &Private->GraphicsOutput;
     
    461466  // Initialize the hardware
    462467  //
    463   VBoxVgaGetVmVariable(EFI_INFO_INDEX_GOP_MODE, (CHAR8 *)&GopMode, sizeof(GopMode));
    464 
    465   GraphicsOutput->SetMode (GraphicsOutput, GopMode);
     468  VBoxVgaGetVmVariable(EFI_INFO_INDEX_HORIZONTAL_RESOLUTION, (CHAR8 *)&HorizontalResolution,
     469                       sizeof(HorizontalResolution));
     470  VBoxVgaGetVmVariable(EFI_INFO_INDEX_VERTICAL_RESOLUTION, (CHAR8 *)&VerticalResolution,
     471                       sizeof(VerticalResolution));
     472  for (Index = 0; Index < Private->MaxMode; Index++)
     473  {
     474    if (   HorizontalResolution == Private->ModeData[Index].HorizontalResolution
     475        && VerticalResolution == Private->ModeData[Index].VerticalResolution
     476        && ColorDepth == Private->ModeData[Index].ColorDepth)
     477      break;
     478  }
     479  // not found? try mode number
     480  if (Index >= Private->MaxMode)
     481  {
     482    VBoxVgaGetVmVariable(EFI_INFO_INDEX_GRAPHICS_MODE, (CHAR8 *)&Index, sizeof(Index));
     483    // try with mode 2 (usually 1024x768) as a fallback
     484    if (Index >= Private->MaxMode)
     485      Index = 2;
     486    // try with mode 0 (usually 640x480) as a fallback
     487    if (Index >= Private->MaxMode)
     488      Index = 0;
     489  }
     490
     491  // skip mode setting completely if there is no valid mode
     492  if (Index >= Private->MaxMode)
     493    return EFI_UNSUPPORTED;
     494
     495  GraphicsOutput->SetMode (GraphicsOutput, Index);
    466496
    467497  DrawLogo (
  • trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/VBoxVgaDxe/VBoxVgaUgaDraw.c

    r67356 r67918  
    9090  )
    9191{
    92   VBOX_VGA_PRIVATE_DATA  *Private;
    93   UINTN                           Index;
     92  VBOX_VGA_PRIVATE_DATA *Private;
     93  UINTN                 Index;
    9494
    9595  DEBUG((DEBUG_INFO, "%a:%d VIDEO: %dx%d %d bpp\n", __FILE__, __LINE__, HorizontalResolution, VerticalResolution, ColorDepth));
     
    328328{
    329329  EFI_UGA_DRAW_PROTOCOL *UgaDraw;
     330  UINT32                Index;
    330331  UINT32                HorizontalResolution = 1024;
    331332  UINT32                VerticalResolution = 768;
     333  UINT32                ColorDepth = 32;
    332334
    333335  //
     
    349351  // Initialize the hardware
    350352  //
    351   VBoxVgaGetVmVariable(EFI_INFO_INDEX_UGA_HORIZONTAL_RESOLUTION, (CHAR8 *)&HorizontalResolution,
     353  VBoxVgaGetVmVariable(EFI_INFO_INDEX_HORIZONTAL_RESOLUTION, (CHAR8 *)&HorizontalResolution,
    352354                       sizeof(HorizontalResolution));
    353   VBoxVgaGetVmVariable(EFI_INFO_INDEX_UGA_VERTICAL_RESOLUTION, (CHAR8 *)&VerticalResolution,
     355  VBoxVgaGetVmVariable(EFI_INFO_INDEX_VERTICAL_RESOLUTION, (CHAR8 *)&VerticalResolution,
    354356                       sizeof(VerticalResolution));
     357  for (Index = 0; Index < Private->MaxMode; Index++)
     358  {
     359    if (   HorizontalResolution == Private->ModeData[Index].HorizontalResolution
     360        && VerticalResolution == Private->ModeData[Index].VerticalResolution
     361        && ColorDepth == Private->ModeData[Index].ColorDepth)
     362      break;
     363  }
     364  // not found? try mode number
     365  if (Index >= Private->MaxMode)
     366  {
     367    VBoxVgaGetVmVariable(EFI_INFO_INDEX_GRAPHICS_MODE, (CHAR8 *)&Index, sizeof(Index));
     368    // try with mode 2 (usually 1024x768) as a fallback
     369    if (Index >= Private->MaxMode)
     370      Index = 2;
     371    // try with mode 0 (usually 640x480) as a fallback
     372    if (Index >= Private->MaxMode)
     373      Index = 0;
     374
     375    // get the resolution from the mode if valid
     376    if (Index < Private->MaxMode)
     377    {
     378      HorizontalResolution = Private->ModeData[Index].HorizontalResolution;
     379      VerticalResolution = Private->ModeData[Index].VerticalResolution;
     380      ColorDepth = Private->ModeData[Index].ColorDepth;
     381    }
     382  }
     383
     384  // skip mode setting completely if there is no valid mode
     385  if (Index >= Private->MaxMode)
     386    return EFI_UNSUPPORTED;
    355387
    356388  UgaDraw->SetMode (
     
    358390            HorizontalResolution,
    359391            VerticalResolution,
    360             32,
     392            ColorDepth,
    361393            60
    362394            );
  • trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp

    r67914 r67918  
    17781778            GetExtraDataBoth(virtualBox, pMachine, "VBoxInternal2/EfiDeviceProps", &deviceProps);
    17791779
    1780             /* Get GOP mode settings */
    1781             uint32_t u32GopMode = UINT32_MAX;
    1782             GetExtraDataBoth(virtualBox, pMachine, "VBoxInternal2/EfiGopMode", &strTmp);
     1780            /* Get graphics mode settings */
     1781            uint32_t u32GraphicsMode = UINT32_MAX;
     1782            GetExtraDataBoth(virtualBox, pMachine, "VBoxInternal2/EfiGraphicsMode", &strTmp);
     1783            if (strTmp.isEmpty())
     1784                GetExtraDataBoth(virtualBox, pMachine, "VBoxInternal2/EfiGopMode", &strTmp);
    17831785            if (!strTmp.isEmpty())
    1784                 u32GopMode = strTmp.toUInt32();
    1785 
    1786             /* UGA mode settings */
    1787             uint32_t u32UgaHorizontal = 0;
    1788             GetExtraDataBoth(virtualBox, pMachine, "VBoxInternal2/EfiUgaHorizontalResolution", &strTmp);
     1786                u32GraphicsMode = strTmp.toUInt32();
     1787
     1788            /* Get graphics resolution settings */
     1789            uint32_t u32HorizontalResolution = 0;
     1790            GetExtraDataBoth(virtualBox, pMachine, "VBoxInternal2/EfiHorizontalResolution", &strTmp);
     1791            if (strTmp.isEmpty())
     1792                GetExtraDataBoth(virtualBox, pMachine, "VBoxInternal2/EfiUgaHorizontalResolution", &strTmp);
    17891793            if (!strTmp.isEmpty())
    1790                 u32UgaHorizontal = strTmp.toUInt32();
    1791 
    1792             uint32_t u32UgaVertical = 0;
    1793             GetExtraDataBoth(virtualBox, pMachine, "VBoxInternal2/EfiUgaVerticalResolution", &strTmp);
     1794                u32HorizontalResolution = strTmp.toUInt32();
     1795
     1796            uint32_t u32VerticalResolution = 0;
     1797            GetExtraDataBoth(virtualBox, pMachine, "VBoxInternal2/EfiVerticalResolution", &strTmp);
     1798            if (strTmp.isEmpty())
     1799                GetExtraDataBoth(virtualBox, pMachine, "VBoxInternal2/EfiUgaVerticalResolution", &strTmp);
    17941800            if (!strTmp.isEmpty())
    1795                 u32UgaVertical = strTmp.toUInt32();
     1801                u32VerticalResolution = strTmp.toUInt32();
    17961802
    17971803            /*
     
    18121818            InsertConfigBytes(pCfg,    "UUID", &HardwareUuid,sizeof(HardwareUuid));
    18131819            InsertConfigInteger(pCfg,  "64BitEntry",  f64BitEntry); /* boolean */
    1814             InsertConfigInteger(pCfg,  "GopMode",     u32GopMode);
    1815             InsertConfigInteger(pCfg,  "UgaHorizontalResolution", u32UgaHorizontal);
    1816             InsertConfigInteger(pCfg,  "UgaVerticalResolution", u32UgaVertical);
     1820            InsertConfigInteger(pCfg,  "GraphicsMode",  u32GraphicsMode);
     1821            InsertConfigInteger(pCfg,  "HorizontalResolution", u32HorizontalResolution);
     1822            InsertConfigInteger(pCfg,  "VerticalResolution", u32VerticalResolution);
    18171823
    18181824            /* For OS X guests we'll force passing host's DMI info to the guest */
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