[SeaBIOS] [PATCH 7/7] ahci: bootprio support

Gerd Hoffmann kraxel at redhat.com
Thu Jul 14 16:24:05 CEST 2011


Wind up bootprio support in the ahci driver so boot device ordering
works for ahci disks too.  No extra work needed on qemu side.

Signed-off-by: Gerd Hoffmann <kraxel at redhat.com>
---
 src/ahci.c |   15 ++++++++++-----
 src/ahci.h |    3 ++-
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/src/ahci.c b/src/ahci.c
index 1f119bb..99bd0bb 100644
--- a/src/ahci.c
+++ b/src/ahci.c
@@ -541,7 +541,8 @@ static int ahci_port_init(struct ahci_port_s *port)
         dprintf(1, "%s\n", desc);
 
         // Register with bcv system.
-        boot_add_hd(&port->drive, desc, -1);
+        int prio = bootprio_find_ata_device(ctrl->pci_tmp, pnr, 0);
+        boot_add_hd(&port->drive, desc, prio);
     } else {
         // found cdrom (atapi)
         port->drive.blksize = CDROM_SECTOR_SIZE;
@@ -556,8 +557,10 @@ static int ahci_port_init(struct ahci_port_s *port)
         dprintf(1, "%s\n", desc);
 
         // fill cdidmap
-        if (iscd)
-            boot_add_cd(&port->drive, desc, -1);
+        if (iscd) {
+            int prio = bootprio_find_ata_device(ctrl->pci_tmp, pnr, 0);
+            boot_add_cd(&port->drive, desc, prio);
+        }
     }
     return 0;
 }
@@ -590,9 +593,10 @@ ahci_detect(void *data)
 
 // Initialize an ata controller and detect its drives.
 static void
-ahci_init_controller(int bdf)
+ahci_init_controller(struct pci_device *pci)
 {
     struct ahci_ctrl_s *ctrl = malloc_fseg(sizeof(*ctrl));
+    u16 bdf = pci->bdf;
     u32 val;
 
     if (!ctrl) {
@@ -606,6 +610,7 @@ ahci_init_controller(int bdf)
         return;
     }
 
+    ctrl->pci_tmp = pci;
     ctrl->pci_bdf = bdf;
     ctrl->iobase = pci_config_readl(bdf, PCI_BASE_ADDRESS_5);
     ctrl->irq = pci_config_readb(bdf, PCI_INTERRUPT_LINE);
@@ -637,7 +642,7 @@ ahci_init(void)
             continue;
         if (pci->prog_if != 1 /* AHCI rev 1 */)
             continue;
-        ahci_init_controller(pci->bdf);
+        ahci_init_controller(pci);
     }
 }
 
diff --git a/src/ahci.h b/src/ahci.h
index 0e13e00..98ade63 100644
--- a/src/ahci.h
+++ b/src/ahci.h
@@ -26,7 +26,8 @@ struct sata_cmd_fis {
 };
 
 struct ahci_ctrl_s {
-    int pci_bdf;
+    struct pci_device *pci_tmp;
+    u16 pci_bdf;
     u8  irq;
     u32 iobase;
     u32 caps;
-- 
1.7.1




More information about the SeaBIOS mailing list