X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=src%2Framdisk.c;h=bae30e213d419f25bb36aee6a938341512ef9ee5;hb=refs%2Fheads%2Fcoreboot;hp=83aa7c4aabdf76cab70ab71a3e868338247c3516;hpb=36c93a5e97931eedab98350d12d8a5ee7d8872bb;p=seabios.git diff --git a/src/ramdisk.c b/src/ramdisk.c index 83aa7c4..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(int driveid) +ramdisk_setup(void) { - printf("%s", Drives.drives[driveid].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,17 +42,19 @@ ramdisk_setup() cbfs_copyfile(file, pos, size); // Setup driver. - dprintf(1, "Mapping CBFS floppy %s to addr %p\n", cbfs_filename(file), pos); - int driveid = addFloppy((u32)pos, ftype, DTYPE_RAMDISK); - if (driveid >= 0) - strtcpy(Drives.drives[driveid].model, cbfs_filename(file) - , ARRAY_SIZE(Drives.drives[driveid].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 ramdisk_copy(struct disk_op_s *op, int iswrite) { - u32 offset = GET_GLOBAL(Drives.drives[op->driveid].cntl_id); + u32 offset = GET_GLOBAL(op->drive_g->cntl_id); offset += (u32)op->lba * DISK_SECTOR_SIZE; u64 opd = GDT_DATA | GDT_LIMIT(0xfffff) | GDT_BASE((u32)op->buf_fl); u64 ramd = GDT_DATA | GDT_LIMIT(0xfffff) | GDT_BASE(offset); @@ -73,7 +71,7 @@ ramdisk_copy(struct disk_op_s *op, int iswrite) // Call int 1587 to copy data. struct bregs br; memset(&br, 0, sizeof(br)); - br.flags = F_CF; + br.flags = F_CF|F_IF; br.ah = 0x87; br.es = GET_SEG(SS); br.si = (u32)gdt; @@ -88,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) {