Changeset 80721 in vbox for trunk/src/VBox/Devices/EFI/FirmwareNew/OvmfPkg/Library/QemuBootOrderLib
- Timestamp:
- Sep 11, 2019 8:46:37 AM (5 years ago)
- Location:
- trunk/src/VBox/Devices/EFI/FirmwareNew
- Files:
-
- 5 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-129237 /vendor/edk2/current 103735-103757,103769-103776,129194-133213
-
Property svn:mergeinfo
changed from (toggle deleted branches)
-
trunk/src/VBox/Devices/EFI/FirmwareNew/OvmfPkg/Library/QemuBootOrderLib/ExtraRootBusMap.c
r77662 r80721 4 4 Copyright (C) 2015, Red Hat, Inc. 5 5 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 13 7 **/ 14 8 -
trunk/src/VBox/Devices/EFI/FirmwareNew/OvmfPkg/Library/QemuBootOrderLib/ExtraRootBusMap.h
r77662 r80721 4 4 Copyright (C) 2015, Red Hat, Inc. 5 5 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 13 7 **/ 14 8 -
trunk/src/VBox/Devices/EFI/FirmwareNew/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.c
r77662 r80721 5 5 Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved.<BR> 6 6 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 14 8 **/ 15 9 … … 1218 1212 // base address of virtio-mmio register block 1219 1213 // 1220 // UEFI device path prefix (dependent on presence of nonzero PCI function):1221 // 1222 // <VenHwString> /MAC(1214 // UEFI device path prefix: 1215 // 1216 // <VenHwString> 1223 1217 // 1224 1218 Written = UnicodeSPrintAsciiFormat ( 1225 1219 Translated, 1226 1220 *TranslatedSize * sizeof (*Translated), // BufferSize in bytes 1227 "%s /MAC(",1221 "%s", 1228 1222 VenHwString 1229 1223 ); … … 1450 1444 ASSERT (0); 1451 1445 } 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 **/ 1478 RETURN_STATUS 1479 EFIAPI 1480 ConnectDevicesFromQemu ( 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 1588 FreeExtraPciRoots: 1589 if (ExtraPciRoots != NULL) { 1590 DestroyExtraRootBusMap (ExtraPciRoots); 1591 } 1592 1593 FreeFwCfg: 1594 FreePool (FwCfg); 1595 1452 1596 return Status; 1453 1597 } … … 1744 1888 the BootOrder NvVar so that it corresponds to the order described in fw_cfg. 1745 1889 1746 Platform BDS should call this function after EfiBootManagerConnectAll () and1747 EfiBootManagerRefreshAllBootOption () return.1890 Platform BDS should call this function after connecting any expected boot 1891 devices and calling EfiBootManagerRefreshAllBootOption (). 1748 1892 1749 1893 @retval RETURN_SUCCESS BootOrder NvVar rewritten. … … 1764 1908 **/ 1765 1909 RETURN_STATUS 1910 EFIAPI 1766 1911 SetBootOrderFromQemu ( 1767 1912 VOID … … 1910 2055 ); 1911 2056 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)); 1913 2059 goto ErrorFreeExtraPciRoots; 1914 2060 } … … 1946 2092 **/ 1947 2093 UINT16 2094 EFIAPI 1948 2095 GetFrontPageTimeoutFromQemu ( 1949 2096 VOID -
trunk/src/VBox/Devices/EFI/FirmwareNew/OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf
r77662 r80721 3 3 # 4 4 # Copyright (C) 2012 - 2014, Red Hat, Inc. 5 # Copyright (c) 2007 - 201 6, Intel Corporation. All rights reserved.<BR>5 # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR> 6 6 # 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 15 8 # 16 9 ## … … 28 21 # tools. 29 22 # 30 # VALID_ARCHITECTURES = IA32 X64 IPFEBC ARM AARCH6423 # VALID_ARCHITECTURES = IA32 X64 EBC ARM AARCH64 31 24 # 32 25 33 26 [Sources] 27 ExtraRootBusMap.c 28 ExtraRootBusMap.h 34 29 QemuBootOrderLib.c 35 ExtraRootBusMap.c36 30 37 31 [Packages]
Note:
See TracChangeset
for help on using the changeset viewer.