ahci: bootprio support
authorGerd Hoffmann <kraxel@redhat.com>
Thu, 14 Jul 2011 14:24:05 +0000 (16:24 +0200)
committerKevin O'Connor <kevin@koconnor.net>
Mon, 25 Jul 2011 03:28:57 +0000 (23:28 -0400)
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@redhat.com>
src/ahci.c
src/ahci.h

index 1f119bb4fdfaefb80eb69dd78513a8f5804a5c78..99bd0bb4b833d7a30d24bef6e6016cc4e267f34b 100644 (file)
@@ -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);
     }
 }
 
index 0e13e00d2db6dcb248eb2a60792e09f79c83887f..98ade63d6547bc8d599b833a3f9c05df6d7422e1 100644 (file)
@@ -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;