No idea why we were setting the NumberBbsEntries field to such a low
value, rather than the whole size of the table...

We're going to need to do SCSI disks too (and in fact fairly much
everything else that BdsLibEnumerateBootOption finds, which means we'd
probably do well to consolidate that code and use it from both places).
But this will do for now, since virtio-blk is by far the most
interesting target after plain IDE.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: David Woodhouse <david.woodho...@intel.com>
---
 .../Csm/LegacyBiosDxe/LegacyBbs.c                  | 54 ++++++++++++++++++++++
 .../Csm/LegacyBiosDxe/LegacyBios.c                 |  2 +-
 2 files changed, 55 insertions(+), 1 deletion(-)

diff --git a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBbs.c 
b/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBbs.c
index 6ee43ad..39bd7aa 100644
--- a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBbs.c
+++ b/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBbs.c
@@ -259,6 +259,60 @@ LegacyBiosBuildBbs (
     }
   }
 
+  BbsIndex = HddIndex * 2 + 1;
+
+  EFI_HANDLE *BlockIoHandles;
+  UINTN NumberBlockIoHandles;
+  UINTN BlockIndex;
+
+  gBS->LocateHandleBuffer (
+        ByProtocol,
+        &gEfiBlockIoProtocolGuid,
+        NULL,
+        &NumberBlockIoHandles,
+        &BlockIoHandles
+        );
+
+  for (BlockIndex = 0; BlockIndex < NumberBlockIoHandles; BlockIndex++) {
+    EFI_PCI_IO_PROTOCOL *PciIo;
+    EFI_STATUS Status;
+
+    Status = gBS->HandleProtocol (
+                    BlockIoHandles[BlockIndex],
+                    &gEfiPciIoProtocolGuid,
+                    (VOID **) &PciIo
+                    );
+    if (!EFI_ERROR(Status)) {
+      // This must be a VirtIO device. Ick, is there really no better way to 
work that out?
+      UINTN Segment, Bus, Device, Function;
+
+      PciIo->GetLocation (
+               PciIo,
+               &Segment,
+               &Bus,
+               &Device,
+               &Function
+               );
+
+      DEBUG((EFI_D_INFO, "Got VirtIO disk at %d/%d/%d\n", Bus, Device, 
Function));
+
+      BbsTable[BbsIndex].Bus                      = Bus;
+      BbsTable[BbsIndex].Device                   = Device;
+      BbsTable[BbsIndex].Function                 = Function;
+      BbsTable[BbsIndex].Class                    = 1;
+      BbsTable[BbsIndex].SubClass                 = 0x80;
+      BbsTable[BbsIndex].StatusFlags.OldPosition  = 0;
+      BbsTable[BbsIndex].StatusFlags.Reserved1    = 0;
+      BbsTable[BbsIndex].StatusFlags.Enabled      = 0;
+      BbsTable[BbsIndex].StatusFlags.Failed       = 0;
+      BbsTable[BbsIndex].StatusFlags.MediaPresent = 0;
+      BbsTable[BbsIndex].StatusFlags.Reserved2    = 0;
+      BbsTable[BbsIndex].DeviceType               = BBS_HARDDISK;
+      BbsTable[BbsIndex].BootPriority             = BBS_UNPRIORITIZED_ENTRY;
+      BbsIndex++;
+    }
+  }
+
   return EFI_SUCCESS;
 
 }
diff --git a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBios.c 
b/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBios.c
index 99a76c9..9e7eff7 100644
--- a/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBios.c
+++ b/IntelFrameworkModulePkg/Csm/LegacyBiosDxe/LegacyBios.c
@@ -543,7 +543,7 @@ ShadowAndStartLegacy16 (
   //
   // Skip Floppy and possible onboard IDE drives
   //
-  EfiToLegacy16BootTable->NumberBbsEntries = 1 + 2 * MAX_IDE_CONTROLLER;
+  EfiToLegacy16BootTable->NumberBbsEntries = 
sizeof(Private->IntThunk->BbsTable) / sizeof(BBS_TABLE);
 
   for (Index = 0; Index < (sizeof (Private->IntThunk->BbsTable) / sizeof 
(BBS_TABLE)); Index++) {
     BbsTable[Index].BootPriority = BBS_IGNORE_ENTRY;
-- 
1.8.0.2


-- 
dwmw2

Attachment: smime.p7s
Description: S/MIME cryptographic signature

------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to