X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=src%2Framdisk.c;h=bae30e213d419f25bb36aee6a938341512ef9ee5;hb=refs%2Fheads%2Fcoreboot;hp=c1e0b8af0516f8cb38ec31a52b64443d1279946a;hpb=77d227b650c50a7dd0dbaf0ff2ec8681084ddc5f;p=seabios.git diff --git a/src/ramdisk.c b/src/ramdisk.c index c1e0b8a..bae30e2 100644 --- a/src/ramdisk.c +++ b/src/ramdisk.c @@ -9,25 +9,21 @@ #include "memmap.h" // add_e820 #include "biosvar.h" // GET_GLOBAL #include "bregs.h" // struct bregs +#include "boot.h" // boot_add_floppy void -describe_ramdisk(struct drive_s *drive_g) +ramdisk_setup(void) { - printf("%s", drive_g->model); -} - -void -ramdisk_setup() -{ - 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"); @@ -37,7 +33,7 @@ ramdisk_setup() // Allocate ram for image. void *pos = memalign_tmphigh(PAGE_SIZE, size); if (!pos) { - dprintf(3, "Not enough memory for ramdisk\n"); + warn_noalloc(); return; } add_e820((u32)pos, size, E820_RESERVED); @@ -46,10 +42,13 @@ ramdisk_setup() 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); - if (drive_g) - strtcpy(drive_g->model, cbfs_filename(file), ARRAY_SIZE(drive_g->model)); + struct drive_s *drive_g = init_floppy((u32)pos, ftype); + if (!drive_g) + 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 @@ -87,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) {