--- qemu/roms/seabios/src/boot.c 2018/04/24 18:58:35 1.1.1.5 +++ qemu/roms/seabios/src/boot.c 2018/04/24 19:23:43 1.1.1.6 @@ -26,6 +26,9 @@ static int BootorderCount; static void loadBootOrder(void) { + if (!CONFIG_BOOTORDER) + return; + char *f = romfile_loadfile("bootorder", NULL); if (!f) return; @@ -96,66 +99,70 @@ find_prio(const char *glob) #define FW_PCI_DOMAIN "/pci@i0cf8" static char * -build_pci_path(char *buf, int max, const char *devname, int bdf) +build_pci_path(char *buf, int max, const char *devname, struct pci_device *pci) { // Build the string path of a bdf - for example: /pci@i0cf8/isa@1,2 char *p = buf; - int parent = pci_bdf_to_bus(bdf); - if (PCIpaths) - parent = PCIpaths[parent]; - int parentdev = parent & 0xffff; - if (parent & PP_PCIBRIDGE) { - p = build_pci_path(p, max, "pci-bridge", parentdev); + if (pci->parent) { + p = build_pci_path(p, max, "pci-bridge", pci->parent); } else { - if (parentdev) - p += snprintf(p, max, "/pci-root@%x", parentdev); + if (pci->rootbus) + p += snprintf(p, max, "/pci-root@%x", pci->rootbus); p += snprintf(p, buf+max-p, "%s", FW_PCI_DOMAIN); } - int dev = pci_bdf_to_dev(bdf), fn = pci_bdf_to_fn(bdf); + int dev = pci_bdf_to_dev(pci->bdf), fn = pci_bdf_to_fn(pci->bdf); p += snprintf(p, buf+max-p, "/%s@%x", devname, dev); if (fn) p += snprintf(p, buf+max-p, ",%x", fn); return p; } -int bootprio_find_pci_device(int bdf) +int bootprio_find_pci_device(struct pci_device *pci) { + if (!CONFIG_BOOTORDER) + return -1; // Find pci device - for example: /pci@i0cf8/ethernet@5 char desc[256]; - build_pci_path(desc, sizeof(desc), "*", bdf); + build_pci_path(desc, sizeof(desc), "*", 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 (bdf == -1) + if (!CONFIG_BOOTORDER) + return -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), "*", 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); } -int bootprio_find_fdc_device(int bdf, int port, int fdid) +int bootprio_find_fdc_device(struct pci_device *pci, int port, int fdid) { - if (bdf == -1) + if (!CONFIG_BOOTORDER) + return -1; + if (!pci) // support only pci machine for now return -1; // Find floppy - for example: /pci@i0cf8/isa@1/fdc@03f1/floppy@0 char desc[256], *p; - p = build_pci_path(desc, sizeof(desc), "isa", bdf); + p = build_pci_path(desc, sizeof(desc), "isa", pci); snprintf(p, desc+sizeof(desc)-p, "/fdc@%04x/floppy@%x", port, 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), "*", bdf); + p = build_pci_path(desc, sizeof(desc), "*", pci); if (instance) snprintf(p, desc+sizeof(desc)-p, ":rom%d", instance); return find_prio(desc); @@ -163,6 +170,8 @@ int bootprio_find_pci_rom(int bdf, int i int bootprio_find_named_rom(const char *name, int instance) { + if (!CONFIG_BOOTORDER) + return -1; // Find named rom - for example: /rom@genroms/linuxboot.bin char desc[256], *p; p = desc + snprintf(desc, sizeof(desc), "/rom@%s", name); @@ -171,12 +180,14 @@ int bootprio_find_named_rom(const char * return find_prio(desc); } -int bootprio_find_usb(int bdf, u64 path) +int bootprio_find_usb(struct pci_device *pci, u64 path) { + if (!CONFIG_BOOTORDER) + return -1; // Find usb - for example: /pci@i0cf8/usb@1,2/hub@1/network@0/ethernet@0 int i; char desc[256], *p; - p = build_pci_path(desc, sizeof(desc), "usb", bdf); + p = build_pci_path(desc, sizeof(desc), "usb", pci); for (i=56; i>0; i-=8) { int port = (path >> i) & 0xff; if (port != 0xff) @@ -353,6 +364,8 @@ boot_add_cbfs(void *data, const char *de * Boot menu and BCV execution ****************************************************************/ +#define DEFAULT_BOOTMENU_WAIT 2500 + // Show IPL option menu. static void interactive_bootmenu(void) @@ -365,8 +378,9 @@ interactive_bootmenu(void) printf("Press F12 for boot menu.\n\n"); + u32 menutime = romfile_loadint("etc/boot-menu-wait", DEFAULT_BOOTMENU_WAIT); enable_bootsplash(); - int scan_code = get_keystroke(CONFIG_BOOTMENU_WAIT); + int scan_code = get_keystroke(menutime); disable_bootsplash(); if (scan_code != 0x86) /* not F12 */