grml...
[seabios.git] / src / boot.c
index f769339ff27debc8c662a682cb0a577506ed358b..9dd37fd57478d7522fb5251f85f64db88f9b479e 100644 (file)
@@ -98,22 +98,9 @@ find_prio(const char *glob)
 
 #define FW_PCI_DOMAIN "/pci@i0cf8"
 
-static struct pci_device *
-find_pci(u16 bdf)
-{
-    struct pci_device *pci;
-    foreachpci(pci) {
-        if (pci->bdf == bdf)
-            return pci;
-    }
-    return NULL;
-}
-
 static char *
 build_pci_path(char *buf, int max, const char *devname, struct pci_device *pci)
 {
-    if (!pci)
-        return buf;
     // Build the string path of a bdf - for example: /pci@i0cf8/isa@1,2
     char *p = buf;
     if (pci->parent) {
@@ -141,16 +128,16 @@ int bootprio_find_pci_device(struct pci_device *pci)
     return find_prio(desc);
 }
 
-int bootprio_find_ata_device(int bdf, int chanid, int slave)
+int bootprio_find_ata_device(struct pci_device *pci, int chanid, int slave)
 {
     if (!CONFIG_BOOTORDER)
         return -1;
-    if (bdf == -1)
+    if (!pci)
         // support only pci machine for now
         return -1;
     // Find ata drive - for example: /pci@i0cf8/ide@1,1/drive@1/disk@0
     char desc[256], *p;
-    p = build_pci_path(desc, sizeof(desc), "*", find_pci(bdf));
+    p = build_pci_path(desc, sizeof(desc), "*", pci);
     snprintf(p, desc+sizeof(desc)-p, "/drive@%x/disk@%x", chanid, slave);
     return find_prio(desc);
 }
@@ -169,13 +156,13 @@ int bootprio_find_fdc_device(struct pci_device *pci, int port, int fdid)
     return find_prio(desc);
 }
 
-int bootprio_find_pci_rom(int bdf, int instance)
+int bootprio_find_pci_rom(struct pci_device *pci, int instance)
 {
     if (!CONFIG_BOOTORDER)
         return -1;
     // Find pci rom - for example: /pci@i0cf8/scsi@3:rom2
     char desc[256], *p;
-    p = build_pci_path(desc, sizeof(desc), "*", find_pci(bdf));
+    p = build_pci_path(desc, sizeof(desc), "*", pci);
     if (instance)
         snprintf(p, desc+sizeof(desc)-p, ":rom%d", instance);
     return find_prio(desc);
@@ -204,9 +191,9 @@ int bootprio_find_usb(struct pci_device *pci, u64 path)
     for (i=56; i>0; i-=8) {
         int port = (path >> i) & 0xff;
         if (port != 0xff)
-            p += snprintf(p, desc+sizeof(desc)-p, "/hub@%x", port);
+            p += snprintf(p, desc+sizeof(desc)-p, "/hub@%x", port+1);
     }
-    snprintf(p, desc+sizeof(desc)-p, "/*@%x", (u32)(path & 0xff));
+    snprintf(p, desc+sizeof(desc)-p, "/*@%x", (u32)(path & 0xff)+1);
     return find_prio(desc);
 }
 
@@ -339,7 +326,7 @@ boot_add_bev(u16 seg, u16 bev, u16 desc, int prio)
 void
 boot_add_bcv(u16 seg, u16 ip, u16 desc, int prio)
 {
-    bootentry_add(IPL_TYPE_BCV, defPrio(prio, DEFAULT_PRIO)
+    bootentry_add(IPL_TYPE_BCV, defPrio(prio, DefaultHDPrio)
                   , SEGOFF(seg, ip).segoff
                   , desc ? MAKE_FLATPTR(seg, desc) : "Legacy option rom");
 }
@@ -393,6 +380,9 @@ interactive_bootmenu(void)
 
     u32 menutime = romfile_loadint("etc/boot-menu-wait", DEFAULT_BOOTMENU_WAIT);
     enable_bootsplash();
+       if (1 == 1) {
+               return;
+       }
     int scan_code = get_keystroke(menutime);
     disable_bootsplash();
     if (scan_code != 0x86)
@@ -474,11 +464,14 @@ boot_prep(void)
     // XXX - show available drives?
 
     // Allow user to modify BCV/IPL order.
+       dprintf(3, "[wurm] bp1\n");
     interactive_bootmenu();
+       dprintf(3, "[wurm] bp2\n");
     wait_threads();
 
     // Map drives and populate BEV list
     struct bootentry_s *pos = BootList;
+       dprintf(3, "[wurm] bp3\n");
     while (pos) {
         switch (pos->type) {
         case IPL_TYPE_BCV:
@@ -502,10 +495,12 @@ boot_prep(void)
         }
         pos = pos->next;
     }
+       dprintf(3, "[wurm] bp4\n");
 
     // If nothing added a floppy/hd boot - add it manually.
     add_bev(IPL_TYPE_FLOPPY, 0);
     add_bev(IPL_TYPE_HARDDISK, 0);
+       dprintf(3, "[wurm] bp5\n");
 }