From d2bf9913a6fa689b17e53722adaba6a42ccf98d2 Mon Sep 17 00:00:00 2001 From: jljusten Date: Thu, 18 Oct 2012 17:08:01 +0000 Subject: [PATCH] OvmfPkg: QemuBootOrder: recognize virtio-scsi devices Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek Reviewed-by: Jordan Justen git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13868 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Library/PlatformBdsLib/QemuBootOrder.c | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/OvmfPkg/Library/PlatformBdsLib/QemuBootOrder.c b/OvmfPkg/Library/PlatformBdsLib/QemuBootOrder.c index 9807039f2f..d2d60c389f 100644 --- a/OvmfPkg/Library/PlatformBdsLib/QemuBootOrder.c +++ b/OvmfPkg/Library/PlatformBdsLib/QemuBootOrder.c @@ -632,6 +632,51 @@ TranslateOfwNodes ( PciDevFun[0], PciDevFun[1] ); + } else if (NumNodes >= 4 && + SubstringEq (OfwNode[1].DriverName, "scsi") && + SubstringEq (OfwNode[2].DriverName, "channel") && + SubstringEq (OfwNode[3].DriverName, "disk") + ) { + // + // OpenFirmware device path (virtio-scsi disk): + // + // /pci@i0cf8/scsi@7[,3]/channel@0/disk@2,3 + // ^ ^ ^ ^ ^ + // | | | | LUN + // | | | target + // | | channel (unused, fixed 0) + // | PCI slot[, function] holding SCSI controller + // PCI root at system bus port, PIO + // + // UEFI device path prefix: + // + // PciRoot(0x0)/Pci(0x7,0x0)/Scsi(0x2,0x3) + // -- if PCI function is 0 or absent + // PciRoot(0x0)/Pci(0x7,0x3)/Scsi(0x2,0x3) + // -- if PCI function is present and nonzero + // + UINT32 TargetLun[2]; + + TargetLun[1] = 0; + NumEntries = sizeof (TargetLun) / sizeof (TargetLun[0]); + if (ParseUnitAddressHexList ( + OfwNode[3].UnitAddress, + TargetLun, + &NumEntries + ) != RETURN_SUCCESS + ) { + return RETURN_UNSUPPORTED; + } + + Written = UnicodeSPrintAsciiFormat ( + Translated, + *TranslatedSize * sizeof (*Translated), // BufferSize in bytes + "PciRoot(0x0)/Pci(0x%x,0x%x)/Scsi(0x%x,0x%x)", + PciDevFun[0], + PciDevFun[1], + TargetLun[0], + TargetLun[1] + ); } else { return RETURN_UNSUPPORTED; } -- 2.39.2