>From 9ca6590769692b99e98acf48acc3ce700238e451 Mon Sep 17 00:00:00 2001
From: gaobin <gao...@amazon.com>
Date: Thu, 19 Sep 2019 22:47:43 -0700
Subject: [PATCH 3/4] csm: Enable boot from pci option rom

In csm mode, the bev pointer of the pci option rom was not
added to the bootentry list, resulting in failure to boot
from pci option rom. This patch fixed it.

Signed-off-by: gaobin <gao...@amazon.com>
---
 src/fw/csm.c     | 18 ++++++++++++++++++
 src/optionroms.c |  2 +-
 src/util.h       |  1 +
 3 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/src/fw/csm.c b/src/fw/csm.c
index c8111cd..8e2a1aa 100644
--- a/src/fw/csm.c
+++ b/src/fw/csm.c
@@ -19,6 +19,7 @@
 #include "std/acpi.h" // RSDP_SIGNATURE
 #include "std/bda.h" // struct bios_data_area_s
 #include "std/optionrom.h" // struct rom_header
+#include "std/pnpbios.h" // PNP_SIGNATURE
 #include "util.h" // copy_smbios
 
 #define UINT8 u8
@@ -218,12 +219,16 @@ handle_csm_0003(struct bregs *regs)
     regs->ax = 1;
 }
 
+static int rom_instance;
+
 /* Legacy16DispatchOprom */
 static void
 handle_csm_0005(struct bregs *regs)
 {
     EFI_DISPATCH_OPROM_TABLE *table = MAKE_FLATPTR(regs->es, regs->bx);
     struct rom_header *rom;
+    struct pnp_data *pnp;
+    u64 sources[(BUILD_BIOS_ADDR - BUILD_ROM_START) / OPTION_ROM_ALIGN];
     u16 bdf;
 
     if (!CONFIG_OPTIONROMS) {
@@ -250,6 +255,19 @@ handle_csm_0005(struct bregs *regs)
 
     rom_confirm(rom->size * 512);
 
+    // PnP rom - check for BEV and BCV boot capabilities.
+    pnp = (void*)((u8*)rom + rom->pnpoffset);
+    if (pnp->signature == PNP_SIGNATURE) {
+        if (pnp->bev)
+            boot_add_bev(FLATPTR_TO_SEG(rom), pnp->bev, pnp->productname,
+                            getRomPriority(sources, rom, rom_instance++));
+        else if (pnp->bcv)
+            boot_add_bcv(FLATPTR_TO_SEG(rom), pnp->bcv, pnp->productname,
+                            getRomPriority(sources, rom, rom_instance++));
+    } else {
+        dprintf(1, "rom 0x%p is not PnP rom, no BEV and BCV capability\n", 
table);
+    }
+
     regs->bx = 0; // FIXME
     regs->ax = 0;
 }
diff --git a/src/optionroms.c b/src/optionroms.c
index e906ab9..4f3848d 100644
--- a/src/optionroms.c
+++ b/src/optionroms.c
@@ -153,7 +153,7 @@ setRomSource(u64 *sources, struct rom_header *rom, u64 
source)
         sources[((u32)rom - BUILD_ROM_START) / OPTION_ROM_ALIGN] = source;
 }
 
-static int
+int
 getRomPriority(u64 *sources, struct rom_header *rom, int instance)
 {
     u64 source = sources[((u32)rom - BUILD_ROM_START) / OPTION_ROM_ALIGN];
diff --git a/src/util.h b/src/util.h
index b173fa8..0a52338 100644
--- a/src/util.h
+++ b/src/util.h
@@ -217,6 +217,7 @@ int is_pci_vga(struct pci_device *pci);
 void optionrom_setup(void);
 void vgarom_setup(void);
 void s3_resume_vga(void);
+int getRomPriority(u64 *sources, struct rom_header *rom, int instance);
 extern int ScreenAndDebug;
 
 // pcibios.c
-- 
2.17.1
_______________________________________________
SeaBIOS mailing list -- seabios@seabios.org
To unsubscribe send an email to seabios-le...@seabios.org

Reply via email to