Exemplo n.º 1
0
static void file_system_detach_disk_single(unsigned int unit)
{
    vdrive_t *vdrive;

    vdrive = file_system_get_vdrive(unit);
    if (vdrive != NULL)
        detach_disk_image_and_free(vdrive->image, vdrive, (unsigned int)unit);

    set_file_system_device(file_system_device_enabled[unit - 8], (void *)unit);
    ui_display_drive_current_image(unit - 8, "");
}
Exemplo n.º 2
0
static int file_system_attach_disk_internal(unsigned int unit,
                                            const char *filename)
{
    vdrive_t *vdrive;

    vdrive = file_system_get_vdrive(unit);
    /* FIXME: Is this clever?  */
    vdrive_device_setup(vdrive, unit);
    serial_device_type_set(SERIAL_DEVICE_VIRT, unit);

    if (attach_disk_image(&(vdrive->image), vdrive, filename, unit,
                          file_system_device_enabled[unit - 8]) < 0) {
        return -1;
    } else {
        file_system_set_serial_hooks(unit, 0);
        fliplist_set_current(unit, filename);
        ui_display_drive_current_image(unit - 8, filename);
    }

    event_record_attach_image(unit, filename, vdrive->image->read_only);

    return 0;
}
Exemplo n.º 3
0
static int set_file_system_device(int val, void *param)
{
    vdrive_t *vdrive;
    unsigned int unit = vice_ptr_to_uint(param);
    unsigned int idx;
    int old_device_enabled;

    if ((unit < 8) || (unit > 11)) {
        DBG(("set_file_system_device invalid dev #%d\n", unit));
        return -1;
    }
    idx = unit - 8;
    old_device_enabled = file_system_device_enabled[idx];

    vdrive = file_system_get_vdrive(unit);

    DBG(("set_file_system_device dev #%d old dev:%d new dev:%d\n", unit, old_device_enabled, val));

    switch (val) {
        case ATTACH_DEVICE_NONE:
            if (old_device_enabled == ATTACH_DEVICE_REAL) {
                serial_realdevice_disable();
            }
            if (old_device_enabled == ATTACH_DEVICE_RAW) {
                detach_disk_image(vdrive->image, vdrive, unit);
            }

            if (vdrive != NULL && vdrive->image == NULL) {
                vdrive_device_setup(vdrive, unit);
                serial_device_type_set(SERIAL_DEVICE_NONE, unit);
                file_system_set_serial_hooks(unit, 0);
            }
            break;
        case ATTACH_DEVICE_VIRT:
            if (old_device_enabled == ATTACH_DEVICE_REAL) {
                serial_realdevice_disable();
            }
            if (old_device_enabled == ATTACH_DEVICE_RAW) {
                detach_disk_image(vdrive->image, vdrive, unit);
            }

            if (vdrive != NULL && vdrive->image == NULL) {
                vdrive_device_setup(vdrive, unit);
                serial_device_type_set(SERIAL_DEVICE_VIRT, unit);
                file_system_set_serial_hooks(unit, 0);
            }
            break;
        case ATTACH_DEVICE_FS:
            if (old_device_enabled == ATTACH_DEVICE_REAL) {
                serial_realdevice_disable();
            }
            if (old_device_enabled == ATTACH_DEVICE_RAW) {
                detach_disk_image(vdrive->image, vdrive, unit);
            }

            if (vdrive != NULL && vdrive->image != NULL) {
                detach_disk_image_and_free(vdrive->image, vdrive, unit);
                ui_display_drive_current_image(idx, "");
            }
            if (vdrive != NULL && vdrive->image == NULL) {
                vdrive_device_setup(vdrive, unit);
                serial_device_type_set(SERIAL_DEVICE_FS, unit);
                file_system_set_serial_hooks(unit, 1);
            }
            break;
#ifdef HAVE_OPENCBM
        case ATTACH_DEVICE_REAL:
            if (old_device_enabled == ATTACH_DEVICE_RAW) {
                detach_disk_image(vdrive->image, vdrive, unit);
            }
            if (serial_realdevice_enable() < 0) {
                log_warning(attach_log, "Falling back to fs device.");
                return set_file_system_device(ATTACH_DEVICE_FS, param);
            }
            if (vdrive != NULL && vdrive->image != NULL) {
                detach_disk_image_and_free(vdrive->image, vdrive, unit);
                ui_display_drive_current_image(idx, "");
                vdrive_device_setup(vdrive, unit);
            }
            serial_device_type_set(SERIAL_DEVICE_REAL, unit);
            break;
#endif
#ifdef HAVE_RAWDRIVE
        case ATTACH_DEVICE_RAW:
            if (old_device_enabled == ATTACH_DEVICE_REAL) {
                serial_realdevice_disable();
            }
            if (vdrive != NULL && vdrive->image != NULL) {
                detach_disk_image_and_free(vdrive->image, vdrive, unit);
                ui_display_drive_current_image(idx, "");
                vdrive_device_setup(vdrive, unit);
            }
            attach_disk_image(&(vdrive->image), vdrive, "DUMMY", unit,
                              ATTACH_DEVICE_RAW);
            file_system_set_serial_hooks(unit, 0);
            serial_device_type_set(SERIAL_DEVICE_RAW, unit);
            break;
#endif
        default:
            return -1;
    }

    file_system_device_enabled[idx] = val;

    return 0;
}
Exemplo n.º 4
0
static int set_file_system_device(int val, void *param)
{
    vdrive_t *vdrive;
    unsigned int unit;
    int old_device_enabled;

    unit = (unsigned int)param;
    old_device_enabled = file_system_device_enabled[unit - 8];

    vdrive = file_system_get_vdrive(unit);

    switch (val) {
      case ATTACH_DEVICE_NONE:
        if (old_device_enabled == ATTACH_DEVICE_REAL)
            serial_realdevice_disable();
        if (old_device_enabled == ATTACH_DEVICE_RAW)
            detach_disk_image(vdrive->image, vdrive, unit);
        if (vdrive != NULL && vdrive->image == NULL) {
            vdrive_device_setup(vdrive, unit);
            serial_device_type_set(SERIAL_DEVICE_VIRT, unit);
            file_system_set_serial_hooks(unit, 0);
        }
        break;
      case ATTACH_DEVICE_FS:
        if (old_device_enabled == ATTACH_DEVICE_REAL)
            serial_realdevice_disable();
        if (old_device_enabled == ATTACH_DEVICE_RAW)
            detach_disk_image(vdrive->image, vdrive, unit);
        if (vdrive != NULL && vdrive->image == NULL) {
            vdrive_device_setup(vdrive, unit);
            serial_device_type_set(SERIAL_DEVICE_FS, unit);
            file_system_set_serial_hooks(unit, 1);
        }
        break;
#ifdef HAVE_OPENCBM
      case ATTACH_DEVICE_REAL:
        if (old_device_enabled == ATTACH_DEVICE_RAW)
            detach_disk_image(vdrive->image, vdrive, unit);
        if (serial_realdevice_enable() < 0) {
            log_warning(attach_log, "Falling back to fs device.");
            return set_file_system_device(ATTACH_DEVICE_FS, param);
        }
        if (vdrive != NULL && vdrive->image != NULL) {
            detach_disk_image_and_free(vdrive->image, vdrive, unit);
            ui_display_drive_current_image(unit - 8, "");
            vdrive_device_setup(vdrive, unit);
        }
        serial_device_type_set(SERIAL_DEVICE_REAL, unit);
        break;
#endif
#ifdef HAVE_RAWDRIVE
      case ATTACH_DEVICE_RAW:
        if (old_device_enabled == ATTACH_DEVICE_REAL)
            serial_realdevice_disable();
        if (vdrive != NULL && vdrive->image != NULL) {
            detach_disk_image_and_free(vdrive->image, vdrive, unit);
            ui_display_drive_current_image(unit - 8, "");
            vdrive_device_setup(vdrive, unit);
        }
        attach_disk_image(&(vdrive->image), vdrive, "DUMMY", unit,
                          ATTACH_DEVICE_RAW);
        file_system_set_serial_hooks(unit, 0);
        serial_device_type_set(SERIAL_DEVICE_RAW, unit);
        break;
#endif
      default:
        return -1;
    }

    file_system_device_enabled[unit - 8] = val;

    return 0;
}