All the floppy images available at CBFS will be found and listed in a
boot menu, instead of the first found. Could be highly valuable if you
are participating in a hobby OS development - would like to test
multiple versions of your floppy in the same coreboot image, to reduce
the amount of re-flashes and accelerate the development at bare metal
- or simply would like to access multiple floppies as a coreboot user;
for example: KolibriOS (nice assembly OS with GUI), FreeDOS, Visopsys
and memtest (coreboot's own memtest version is a bit buggy, e.g.
external USB keyboard isn't working there at some laptops)
Shortened patch description message:
All the available floppy images will be found and listed in a boot
menu, instead of the first found. Useful if you are participating in a
hobby OS development or would like to access multiple floppies as a
coreboot user.
Signed-off-by: Mike Banon <mikebdp2(a)gmail.com>
---
diff --git a/src/hw/ramdisk.c b/src/hw/ramdisk.c
index b9e9baa..0cd8470 100644
--- a/src/hw/ramdisk.c
+++ b/src/hw/ramdisk.c
@@ -23,40 +23,51 @@ ramdisk_setup(void)
if (!CONFIG_FLASH_FLOPPY)
return;
+ struct romfile_s *file = NULL;
+ char *filename, *desc;
+ u32 size;
+ int ftype, ret;
+ void *pos;
+ struct drive_s *drive;
+
+ for (;;) {
+
- // Find image.
- struct romfile_s *file = romfile_findprefix("floppyimg/", NULL);
- if (!file)
- return;
+ // Find the next image.
+ file = romfile_findprefix("floppyimg/", file);
+ if (!file)
+ return;
- const char *filename = file->name;
- u32 size = 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");
- return;
- }
+ filename = file->name;
+ size = file->size;
+ dprintf(3, "Found floppy file %s of size %d\n", filename, size);
+ ftype = find_floppy_type(size);
+ if (ftype < 0) {
+ dprintf(3, "No floppy type found for ramdisk size\n");
+ return;
+ }
- // Allocate ram for image.
- void *pos = memalign_tmphigh(PAGE_SIZE, size);
- if (!pos) {
- warn_noalloc();
- return;
- }
- e820_add((u32)pos, size, E820_RESERVED);
+ // Allocate ram for image.
+ pos = memalign_tmphigh(PAGE_SIZE, size);
+ if (!pos) {
+ warn_noalloc();
+ return;
+ }
+ e820_add((u32)pos, size, E820_RESERVED);
- // Copy image into ram.
- int ret = file->copy(file, pos, size);
- if (ret < 0)
- return;
+ // Copy image into ram.
+ ret = file->copy(file, pos, size);
+ if (ret < 0)
+ return;
- // Setup driver.
- struct drive_s *drive = init_floppy((u32)pos, ftype);
- if (!drive)
- return;
+ // Setup driver.
+ drive = init_floppy((u32)pos, ftype);
+ if (!drive)
+ return;
- drive->type = DTYPE_RAMDISK;
- dprintf(1, "Mapping floppy %s to addr %p\n", filename, pos);
- char *desc = znprintf(MAXDESCSIZE, "Ramdisk [%s]", &filename[10]);
- boot_add_floppy(drive, desc, bootprio_find_named_rom(filename, 0));
+ drive->type = DTYPE_RAMDISK;
+ dprintf(1, "Mapping floppy %s to addr %p\n", filename, pos);
+ desc = znprintf(MAXDESCSIZE, "Ramdisk [%s]", &filename[10]);
+ boot_add_floppy(drive, desc, bootprio_find_named_rom(filename, 0));
+
+ }
}
static int