Initial bootsplash support.
[seabios.git] / src / optionroms.c
index ad88e0caadd1298cf6d0cdf40311a72f161ccbed..cde5b4d125a4c92d4971f7927ed3a93dd79f36df 100644 (file)
@@ -227,47 +227,31 @@ lookup_hardcode(u32 vendev)
         && ((OPTIONROM_VENDEV_2 >> 16)
             | ((OPTIONROM_VENDEV_2 & 0xffff)) << 16) == vendev)
         return copy_rom((void*)OPTIONROM_MEM_2);
-    int ret = cbfs_copy_optionrom((void*)RomEnd, max_rom() - RomEnd, vendev);
-    if (ret < 0)
+    char fname[17];
+    snprintf(fname, sizeof(fname), "pci%04x,%04x.rom"
+             , pci_vd_to_ven(vendev), pci_vd_to_dev(vendev));
+    int ret = romfile_copy(romfile_find(fname), (void*)RomEnd
+                           , max_rom() - RomEnd);
+    if (ret <= 0)
         return NULL;
     return (void*)RomEnd;
 }
 
 // Run all roms in a given CBFS directory.
 static void
-run_cbfs_roms(const char *prefix, int isvga)
+run_file_roms(const char *prefix, int isvga)
 {
-    struct cbfs_file *file = NULL;
+    u32 file = 0;
     for (;;) {
-        file = cbfs_findprefix(prefix, file);
+        file = romfile_findprefix(prefix, file);
         if (!file)
             break;
-        int ret = cbfs_copyfile(file, (void*)RomEnd, max_rom() - RomEnd);
+        int ret = romfile_copy(file, (void*)RomEnd, max_rom() - RomEnd);
         if (ret > 0)
             init_optionrom((void*)RomEnd, 0, isvga);
     }
 }
 
-static void
-run_qemu_roms(const char *prefix, int isvga)
-{
-    struct QemuCfgFile entry;
-    int plen = strlen(prefix);
-    int rc, dlen;
-
-    rc = qemu_cfg_first_file(&entry);
-    while (rc > 0) {
-        if (memcmp(prefix, entry.name, plen) == 0) {
-            dlen = qemu_cfg_read_file(&entry, (void*)RomEnd, max_rom() - RomEnd);
-            if (dlen > 0) {
-                dprintf(1, "init qemu rom: %s\n", entry.name);
-                init_optionrom((void*)RomEnd, 0, isvga);
-            }
-        }
-        rc = qemu_cfg_next_file(&entry);
-    }
-}
-
 
 /****************************************************************
  * PCI roms
@@ -307,8 +291,10 @@ map_pcirom(u16 bdf, u32 vendev)
 
     struct rom_header *rom = (void*)orig;
     for (;;) {
-        dprintf(5, "Inspecting possible rom at %p (dv=%08x bdf=%x)\n"
-                , rom, vendev, bdf);
+        dprintf(5, "Inspecting possible rom at %p (vd=%04x:%04x"
+                " bdf=%02x:%02x.%x)\n"
+                , rom, pci_vd_to_ven(vendev), pci_vd_to_dev(vendev)
+                , pci_bdf_to_bus(bdf), pci_bdf_to_dev(bdf), pci_bdf_to_fn(bdf));
         if (rom->signature != OPTION_ROM_SIGNATURE) {
             dprintf(6, "No option rom signature (got %x)\n", rom->signature);
             goto fail;
@@ -319,7 +305,7 @@ map_pcirom(u16 bdf, u32 vendev)
             goto fail;
         }
 
-        u32 vd = (pci->device << 16) | pci->vendor;
+        u32 vd = pci_vd(pci->vendor, pci->device);
         if (vd == vendev && pci->type == PCIROM_CODETYPE_X86)
             // A match
             break;
@@ -346,9 +332,9 @@ static int
 init_pcirom(u16 bdf, int isvga)
 {
     u32 vendev = pci_config_readl(bdf, PCI_VENDOR_ID);
-    dprintf(4, "Attempting to init PCI bdf %02x:%02x.%x (dev/ven %08x)\n"
+    dprintf(4, "Attempting to init PCI bdf %02x:%02x.%x (vd %04x:%04x)\n"
             , pci_bdf_to_bus(bdf), pci_bdf_to_dev(bdf), pci_bdf_to_fn(bdf)
-            , vendev);
+            , pci_vd_to_ven(vendev), pci_vd_to_dev(vendev));
     struct rom_header *rom = lookup_hardcode(vendev);
     if (! rom)
         rom = map_pcirom(bdf, vendev);
@@ -395,8 +381,7 @@ optionrom_setup(void)
         }
 
         // Find and deploy CBFS roms not associated with a device.
-        run_cbfs_roms("genroms/", 0);
-        run_qemu_roms("genroms/", 0);
+        run_file_roms("genroms/", 0);
     }
 
     // All option roms found and deployed - now build BEV/BCV vectors.
@@ -455,8 +440,7 @@ vga_setup(void)
             init_pcirom(bdf, 1);
 
         // Find and deploy CBFS vga-style roms not associated with a device.
-        run_cbfs_roms("vgaroms/", 1);
-        run_qemu_roms("vgaroms/", 1);
+        run_file_roms("vgaroms/", 1);
     }
 
     if (RomEnd == BUILD_ROM_START) {
@@ -465,17 +449,7 @@ vga_setup(void)
         return;
     }
 
-    dprintf(1, "Turning on vga console\n");
-    struct bregs br;
-    memset(&br, 0, sizeof(br));
-    br.flags = F_IF;
-    br.ax = 0x0003;
-    start_preempt();
-    call16_int(0x10, &br);
-    finish_preempt();
-
-    // Write to screen.
-    printf("Starting SeaBIOS (version %s)\n\n", VERSION);
+    enable_vga_console();
 }
 
 void