grml...
[seabios.git] / src / ramdisk.c
index 01648402b0e159e4f8cb7d0461e608092a49d5b4..bae30e213d419f25bb36aee6a938341512ef9ee5 100644 (file)
@@ -9,19 +9,21 @@
 #include "memmap.h" // add_e820
 #include "biosvar.h" // GET_GLOBAL
 #include "bregs.h" // struct bregs
+#include "boot.h" // boot_add_floppy
 
 void
 ramdisk_setup(void)
 {
-    if (!CONFIG_COREBOOT_FLASH || !CONFIG_FLASH_FLOPPY)
+    if (!CONFIG_COREBOOT || !CONFIG_COREBOOT_FLASH || !CONFIG_FLASH_FLOPPY)
         return;
 
     // Find image.
     struct cbfs_file *file = cbfs_findprefix("floppyimg/", NULL);
     if (!file)
         return;
+    const char *filename = cbfs_filename(file);
     u32 size = cbfs_datasize(file);
-    dprintf(3, "Found floppy file %s of size %d\n", cbfs_filename(file), size);
+    dprintf(3, "Found floppy file %s of size %d\n", filename, size);
     int ftype = find_floppy_type(size);
     if (ftype < 0) {
         dprintf(3, "No floppy type found for ramdisk size\n");
@@ -40,10 +42,13 @@ ramdisk_setup(void)
     cbfs_copyfile(file, pos, size);
 
     // Setup driver.
-    dprintf(1, "Mapping CBFS floppy %s to addr %p\n", cbfs_filename(file), pos);
-    struct drive_s *drive_g = addFloppy((u32)pos, ftype, DTYPE_RAMDISK);
+    struct drive_s *drive_g = init_floppy((u32)pos, ftype);
     if (!drive_g)
-        strtcpy(drive_g->desc, cbfs_filename(file), MAXDESCSIZE);
+        return;
+    drive_g->type = DTYPE_RAMDISK;
+    dprintf(1, "Mapping CBFS floppy %s to addr %p\n", filename, pos);
+    char *desc = znprintf(MAXDESCSIZE, "Ramdisk [%s]", &filename[10]);
+    boot_add_floppy(drive_g, desc, bootprio_find_named_rom(filename, 0));
 }
 
 static int
@@ -81,7 +86,7 @@ ramdisk_copy(struct disk_op_s *op, int iswrite)
 int
 process_ramdisk_op(struct disk_op_s *op)
 {
-    if (!CONFIG_COREBOOT_FLASH || !CONFIG_FLASH_FLOPPY)
+    if (!CONFIG_COREBOOT || !CONFIG_COREBOOT_FLASH || !CONFIG_FLASH_FLOPPY)
         return 0;
 
     switch (op->command) {