VirtualBox

Ignore:
Timestamp:
Sep 11, 2019 8:46:37 AM (5 years ago)
Author:
vboxsync
Message:

Devices/EFI/FirmwareNew: Start upgrade process to edk2-stable201908 (compiles on Windows and works to some extent), bugref:4643

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

Legend:

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

  • trunk/src/VBox/Devices/EFI/FirmwareNew/OvmfPkg/Library/QemuBootOrderLib/ExtraRootBusMap.c

    r77662 r80721  
    44  Copyright (C) 2015, Red Hat, Inc.
    55
    6   This program and the accompanying materials are licensed and made available
    7   under the terms and conditions of the BSD License which accompanies this
    8   distribution.  The full text of the license may be found at
    9   http://opensource.org/licenses/bsd-license.php
    10 
    11   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
    12   WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     6  SPDX-License-Identifier: BSD-2-Clause-Patent
    137**/
    148
  • trunk/src/VBox/Devices/EFI/FirmwareNew/OvmfPkg/Library/QemuBootOrderLib/ExtraRootBusMap.h

    r77662 r80721  
    44  Copyright (C) 2015, Red Hat, Inc.
    55
    6   This program and the accompanying materials are licensed and made available
    7   under the terms and conditions of the BSD License which accompanies this
    8   distribution.  The full text of the license may be found at
    9   http://opensource.org/licenses/bsd-license.php
    10 
    11   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
    12   WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     6  SPDX-License-Identifier: BSD-2-Clause-Patent
    137**/
    148
  • trunk/src/VBox/Devices/EFI/FirmwareNew/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c

    r77662 r80721  
    55  Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved.<BR>
    66
    7   This program and the accompanying materials are licensed and made available
    8   under the terms and conditions of the BSD License which accompanies this
    9   distribution.  The full text of the license may be found at
    10   http://opensource.org/licenses/bsd-license.php
    11 
    12   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
    13   WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     7  SPDX-License-Identifier: BSD-2-Clause-Patent
    148**/
    159
     
    12181212    //                base address of virtio-mmio register block
    12191213    //
    1220     // UEFI device path prefix (dependent on presence of nonzero PCI function):
    1221     //
    1222     //   <VenHwString>/MAC(
     1214    // UEFI device path prefix:
     1215    //
     1216    //   <VenHwString>
    12231217    //
    12241218    Written = UnicodeSPrintAsciiFormat (
    12251219                Translated,
    12261220                *TranslatedSize * sizeof (*Translated), // BufferSize in bytes
    1227                 "%s/MAC(",
     1221                "%s",
    12281222                VenHwString
    12291223                );
     
    14501444    ASSERT (0);
    14511445  }
     1446  return Status;
     1447}
     1448
     1449
     1450/**
     1451  Connect devices based on the boot order retrieved from QEMU.
     1452
     1453  Attempt to retrieve the "bootorder" fw_cfg file from QEMU. Translate the
     1454  OpenFirmware device paths therein to UEFI device path fragments. Connect the
     1455  devices identified by the UEFI devpath prefixes as narrowly as possible, then
     1456  connect all their child devices, recursively.
     1457
     1458  If this function fails, then platform BDS should fall back to
     1459  EfiBootManagerConnectAll(), or some other method for connecting any expected
     1460  boot devices.
     1461
     1462  @retval RETURN_SUCCESS            The "bootorder" fw_cfg file has been
     1463                                    parsed, and the referenced device-subtrees
     1464                                    have been connected.
     1465
     1466  @retval RETURN_UNSUPPORTED        QEMU's fw_cfg is not supported.
     1467
     1468  @retval RETURN_NOT_FOUND          Empty or nonexistent "bootorder" fw_cfg
     1469                                    file.
     1470
     1471  @retval RETURN_INVALID_PARAMETER  Parse error in the "bootorder" fw_cfg file.
     1472
     1473  @retval RETURN_OUT_OF_RESOURCES   Memory allocation failed.
     1474
     1475  @return                           Error statuses propagated from underlying
     1476                                    functions.
     1477**/
     1478RETURN_STATUS
     1479EFIAPI
     1480ConnectDevicesFromQemu (
     1481  VOID
     1482  )
     1483{
     1484  RETURN_STATUS        Status;
     1485  FIRMWARE_CONFIG_ITEM FwCfgItem;
     1486  UINTN                FwCfgSize;
     1487  CHAR8                *FwCfg;
     1488  EFI_STATUS           EfiStatus;
     1489  EXTRA_ROOT_BUS_MAP   *ExtraPciRoots;
     1490  CONST CHAR8          *FwCfgPtr;
     1491  UINTN                NumConnected;
     1492  UINTN                TranslatedSize;
     1493  CHAR16               Translated[TRANSLATION_OUTPUT_SIZE];
     1494
     1495  Status = QemuFwCfgFindFile ("bootorder", &FwCfgItem, &FwCfgSize);
     1496  if (RETURN_ERROR (Status)) {
     1497    return Status;
     1498  }
     1499
     1500  if (FwCfgSize == 0) {
     1501    return RETURN_NOT_FOUND;
     1502  }
     1503
     1504  FwCfg = AllocatePool (FwCfgSize);
     1505  if (FwCfg == NULL) {
     1506    return RETURN_OUT_OF_RESOURCES;
     1507  }
     1508
     1509  QemuFwCfgSelectItem (FwCfgItem);
     1510  QemuFwCfgReadBytes (FwCfgSize, FwCfg);
     1511  if (FwCfg[FwCfgSize - 1] != '\0') {
     1512    Status = RETURN_INVALID_PARAMETER;
     1513    goto FreeFwCfg;
     1514  }
     1515  DEBUG ((DEBUG_VERBOSE, "%a: FwCfg:\n", __FUNCTION__));
     1516  DEBUG ((DEBUG_VERBOSE, "%a\n", FwCfg));
     1517  DEBUG ((DEBUG_VERBOSE, "%a: FwCfg: <end>\n", __FUNCTION__));
     1518
     1519  if (FeaturePcdGet (PcdQemuBootOrderPciTranslation)) {
     1520    EfiStatus = CreateExtraRootBusMap (&ExtraPciRoots);
     1521    if (EFI_ERROR (EfiStatus)) {
     1522      Status = (RETURN_STATUS)EfiStatus;
     1523      goto FreeFwCfg;
     1524    }
     1525  } else {
     1526    ExtraPciRoots = NULL;
     1527  }
     1528
     1529  //
     1530  // Translate each OpenFirmware path to a UEFI devpath prefix.
     1531  //
     1532  FwCfgPtr = FwCfg;
     1533  NumConnected = 0;
     1534  TranslatedSize = ARRAY_SIZE (Translated);
     1535  Status = TranslateOfwPath (&FwCfgPtr, ExtraPciRoots, Translated,
     1536             &TranslatedSize);
     1537  while (!RETURN_ERROR (Status)) {
     1538    EFI_DEVICE_PATH_PROTOCOL *DevicePath;
     1539    EFI_HANDLE               Controller;
     1540
     1541    //
     1542    // Convert the UEFI devpath prefix to binary representation.
     1543    //
     1544    ASSERT (Translated[TranslatedSize] == L'\0');
     1545    DevicePath = ConvertTextToDevicePath (Translated);
     1546    if (DevicePath == NULL) {
     1547      Status = RETURN_OUT_OF_RESOURCES;
     1548      goto FreeExtraPciRoots;
     1549    }
     1550    //
     1551    // Advance along DevicePath, connecting the nodes individually, and asking
     1552    // drivers not to produce sibling nodes. Retrieve the controller handle
     1553    // associated with the full DevicePath -- this is the device that QEMU's
     1554    // OFW devpath refers to.
     1555    //
     1556    EfiStatus = EfiBootManagerConnectDevicePath (DevicePath, &Controller);
     1557    FreePool (DevicePath);
     1558    if (EFI_ERROR (EfiStatus)) {
     1559      Status = (RETURN_STATUS)EfiStatus;
     1560      goto FreeExtraPciRoots;
     1561    }
     1562    //
     1563    // Because QEMU's OFW devpaths have lesser expressive power than UEFI
     1564    // devpaths (i.e., DevicePath is considered a prefix), connect the tree
     1565    // rooted at Controller, recursively. If no children are produced
     1566    // (EFI_NOT_FOUND), that's OK.
     1567    //
     1568    EfiStatus = gBS->ConnectController (Controller, NULL, NULL, TRUE);
     1569    if (EFI_ERROR (EfiStatus) && EfiStatus != EFI_NOT_FOUND) {
     1570      Status = (RETURN_STATUS)EfiStatus;
     1571      goto FreeExtraPciRoots;
     1572    }
     1573    ++NumConnected;
     1574    //
     1575    // Move to the next OFW devpath.
     1576    //
     1577    TranslatedSize = ARRAY_SIZE (Translated);
     1578    Status = TranslateOfwPath (&FwCfgPtr, ExtraPciRoots, Translated,
     1579               &TranslatedSize);
     1580  }
     1581
     1582  if (Status == RETURN_NOT_FOUND && NumConnected > 0) {
     1583    DEBUG ((DEBUG_INFO, "%a: %Lu OpenFirmware device path(s) connected\n",
     1584      __FUNCTION__, (UINT64)NumConnected));
     1585    Status = RETURN_SUCCESS;
     1586  }
     1587
     1588FreeExtraPciRoots:
     1589  if (ExtraPciRoots != NULL) {
     1590    DestroyExtraRootBusMap (ExtraPciRoots);
     1591  }
     1592
     1593FreeFwCfg:
     1594  FreePool (FwCfg);
     1595
    14521596  return Status;
    14531597}
     
    17441888  the BootOrder NvVar so that it corresponds to the order described in fw_cfg.
    17451889
    1746   Platform BDS should call this function after EfiBootManagerConnectAll () and
    1747   EfiBootManagerRefreshAllBootOption () return.
     1890  Platform BDS should call this function after connecting any expected boot
     1891  devices and calling EfiBootManagerRefreshAllBootOption ().
    17481892
    17491893  @retval RETURN_SUCCESS            BootOrder NvVar rewritten.
     
    17641908**/
    17651909RETURN_STATUS
     1910EFIAPI
    17661911SetBootOrderFromQemu (
    17671912  VOID
     
    19102055                    );
    19112056    if (EFI_ERROR (Status)) {
    1912       DEBUG ((DEBUG_ERROR, "%a: setting BootOrder: %r\n", __FUNCTION__, Status));
     2057      DEBUG ((DEBUG_ERROR, "%a: setting BootOrder: %r\n", __FUNCTION__,
     2058        Status));
    19132059      goto ErrorFreeExtraPciRoots;
    19142060    }
     
    19462092**/
    19472093UINT16
     2094EFIAPI
    19482095GetFrontPageTimeoutFromQemu (
    19492096  VOID
  • trunk/src/VBox/Devices/EFI/FirmwareNew/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf

    r77662 r80721  
    33#
    44#  Copyright (C) 2012 - 2014, Red Hat, Inc.
    5 #  Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
     5#  Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
    66#
    7 #  This program and the accompanying materials are licensed and made available
    8 #  under the terms and conditions of the BSD License which accompanies this
    9 #  distribution.  The full text of the license may be found at
    10 #  http://opensource.org/licenses/bsd-license.php
    11 #
    12 #  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
    13 #  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR
    14 #  IMPLIED.
     7#  SPDX-License-Identifier: BSD-2-Clause-Patent
    158#
    169##
     
    2821# tools.
    2922#
    30 #  VALID_ARCHITECTURES           = IA32 X64 IPF EBC ARM AARCH64
     23#  VALID_ARCHITECTURES           = IA32 X64 EBC ARM AARCH64
    3124#
    3225
    3326[Sources]
     27  ExtraRootBusMap.c
     28  ExtraRootBusMap.h
    3429  QemuBootOrderLib.c
    35   ExtraRootBusMap.c
    3630
    3731[Packages]
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