示例#1
0
image_contents_t *diskcontents_read(const char *file_name, unsigned int unit)
{
    switch (machine_bus_device_type_get(unit)) {
        default:
            return diskcontents_filesystem_read(file_name);
        case SERIAL_DEVICE_REAL:
            return machine_diskcontents_bus_read(unit);
        case SERIAL_DEVICE_RAW:
            return diskcontents_block_read(file_system_get_vdrive(unit));
    }
}
示例#2
0
文件: attach.c 项目: martinpiper/VICE
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, "");
}
示例#3
0
void mon_drive_execute_disk_cmd(char *cmd)
{
    unsigned int len;
    vdrive_t *vdrive;

    /* FIXME */
    vdrive = file_system_get_vdrive(8);

    len = (unsigned int)strlen(cmd);

    vdrive_command_execute(vdrive, (BYTE *)cmd, len);
}
示例#4
0
int vdrive_bam_set_disk_id(unsigned int unit, BYTE *id)
{
    vdrive_t *vdrive;

    vdrive = file_system_get_vdrive(unit);

    if (vdrive == NULL || id == NULL || vdrive->bam == NULL) {
        return -1;
    }

    memcpy(vdrive->bam + vdrive->bam_id, id, 2);

    return 0;
}
示例#5
0
文件: attach.c 项目: martinpiper/VICE
void file_system_detach_disk_shutdown(void)
{
    vdrive_t *vdrive;
    unsigned int i;

    for (i = 0; i <= 3; i++) {
        vdrive = file_system_get_vdrive(i + 8);
        if (vdrive != NULL) {
            if (file_system_device_enabled[i] == ATTACH_DEVICE_REAL)
                serial_realdevice_disable();
            else
                detach_disk_image_and_free(vdrive->image, vdrive, i + 8);
        }
    }
}
示例#6
0
文件: attach.c 项目: martinpiper/VICE
const char *file_system_get_disk_name(unsigned int unit)
{
    vdrive_t *vdrive;

    vdrive = file_system_get_vdrive(unit);

    if (vdrive == NULL)
        return NULL;
    if (vdrive->image == NULL)
        return NULL;

    if (vdrive->image->device != DISK_IMAGE_DEVICE_FS)
        return NULL;

    return disk_image_fsimage_name_get(vdrive->image);
}
示例#7
0
void mon_drive_list(int drive_number)
{
    const char *name;
    image_contents_t *listing;
    vdrive_t *vdrive;

    if ((drive_number < 8) || (drive_number > 11)) {
        drive_number = 8;
    }

    vdrive = file_system_get_vdrive(drive_number);

    if (vdrive == NULL || vdrive->image == NULL) {
        mon_out("Drive %i not ready.\n", drive_number);
        return;
    }

    name = disk_image_name_get(vdrive->image);

    listing = diskcontents_read(name, drive_number);

    if (listing != NULL) {
        char *string = image_contents_to_string(listing, 1);
        image_contents_file_list_t *element = listing->file_list;

        mon_out("%s\n", string);
        lib_free(string);

        if (element == NULL) {
            mon_out("Empty image\n");
        } else {
            do {
                string = image_contents_file_to_string(element, 1);
                mon_out("%s\n", string);
                lib_free(string);
            }
            while ((element = element->next) != NULL);
        }

        if (listing->blocks_free >= 0) {
            string = lib_msprintf("%d blocks free.\n", listing->blocks_free);
            mon_out("%s", string);
            lib_free(string);
        }
    }
}
示例#8
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;
}
int parallel_trap_sendbyte(BYTE data)
{
    int st = 0;
    serial_t *p;
    void *vdrive;
    unsigned int dnr;

    for (dnr = 0; dnr < DRIVE_NUM; dnr++) {
        if ((unsigned int)(TrapDevice & 0x0f) == dnr + 8
            && drive_context[dnr]->drive->enable) {
            return 0x83;    /* device not present */
        }
    }

    p = serial_device_get(TrapDevice & 0x0f);
    vdrive = (void *)file_system_get_vdrive(TrapDevice & 0x0f);

    if (p->inuse) {
        if (p->isopen[TrapSecondary & 0x0f] == 1) {
            if (parallel_debug) {
                log_message(parallel_log,
                            "SerialSendByte[%2d] = %02x.", SerialPtr, data);
            }
            /* Store name here */
            if (SerialPtr < SERIAL_NAMELENGTH) {
                SerialBuffer[SerialPtr++] = data;
            }
        } else {
            /* Send to device */
            st = (*(p->putf))(vdrive, data, TrapSecondary & 0x0f);
        }
    } else {                    /* Not present */
        st = 0x83;
    }

    return st + (TrapDevice << 8);
}
示例#10
0
static int parallelcommand(void)
{
    serial_t *p;
    BYTE b;
    int channel;
    int i, st = 0;
    void *vdrive;
    unsigned int dnr;

    for (dnr = 0; dnr < DRIVE_NUM; dnr++) {
        if ((unsigned int)(TrapDevice & 0x0f) == dnr + 8
            && drive_context[dnr]->drive->enable) {
            return 0x83;    /* device not present */
        }
    }

    /* which device ? */
    p = serial_device_get(TrapDevice & 0x0f);
    vdrive = (void *)file_system_get_vdrive(TrapDevice & 0x0f);
    channel = TrapSecondary & 0x0f;

    /* if command on a channel, reset output buffer... */
    if ((TrapSecondary & 0xf0) != 0x60) {
        p->nextok[channel] = 0;
        p->lastok[channel] = 0;
    }
    switch (TrapSecondary & 0xf0) {
        case 0x60:
            /* Open Channel */
            if (!p->isopen[channel] == 1) {
                p->isopen[channel] = 2;
                st = (*(p->openf))(vdrive, NULL, 0, channel, NULL);
                for (i = 0; i < SerialPtr; i++) {
                    (*(p->putf))(vdrive, SerialBuffer[i], channel);
                }
                SerialPtr = 0;
            }
            if (p->flushf) {
                (*(p->flushf))(vdrive, channel);
            }

            if ((!st) && ((TrapDevice & 0xf0) == 0x40)) {
                /* any error, except eof */
                st = parallel_trap_receivebyte(&b, 1) & 0xbf;
            }
            break;
        case 0xE0:
            /* Close File */
            p->isopen[channel] = 0;
            st = (*(p->closef))(vdrive, channel);
            break;
        case 0xF0:
            /* Open File */
            if (p->isopen[channel]) {
#ifndef DELAYEDCLOSE
                if (p->isopen[channel] == 2) {
                    log_warning(parallel_log, "Bogus close?");
                    (*(p->closef))(vdrive, channel);
                }
                p->isopen[channel] = 2;
                SerialBuffer[SerialPtr] = 0;
                st = (*(p->openf))(vdrive, SerialBuffer, SerialPtr, channel, NULL);
                SerialPtr = 0;

                if (st) {
                    p->isopen[channel] = 0;
                    (*(p->closef))(vdrive, channel);
                    log_error(parallel_log, "Cannot open file. Status $%02x.", st);
                }
#else
                if (SerialPtr != 0 || channel == 0x0f) {
                    (*(p->closef))(vdrive, channel);
                    p->isopen[channel] = 2;

                    SerialBuffer[SerialPtr] = 0;
                    st = (*(p->openf))(vdrive, SerialBuffer, SerialPtr, channel, NULL);
                    SerialPtr = 0;

                    if (st) {
                        p->isopen[channel] = 0;
                        (*(p->closef))(vdrive, channel);
                        log_error(parallel_log, "Cannot open file. Status $%02x.", st);
                    }
                }
#endif
            }
            if (p->flushf) {
                (*(p->flushf))(vdrive, channel);
            }
            break;
        default:
            log_error(parallel_log, "Unknown command %02X.", TrapSecondary & 0xff);
    }
    return (st);
}
示例#11
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;
}
示例#12
0
int autostart_prg_with_disk_image(const char *file_name,
                                  fileio_info_t *fh,
                                  log_t log,
                                  const char *image_name)
{
    const int drive = 8;
    const int secondary = 1;
    autostart_prg_t *prg;
    vdrive_t *vdrive;
    int i;
    int old_tde_state;
    int file_name_size;
    BYTE data;
    unsigned int disk_image_type;
    int result, result2;

    /* identify disk image type */
    switch (drive_get_disk_drive_type(drive - 8)) {
    case DRIVE_TYPE_1540:
    case DRIVE_TYPE_1541:
    case DRIVE_TYPE_1541II:
    case DRIVE_TYPE_1551:
    case DRIVE_TYPE_1570:
    case DRIVE_TYPE_2031:
        disk_image_type = DISK_IMAGE_TYPE_D64;
        break;
    case DRIVE_TYPE_2040:
    case DRIVE_TYPE_3040:
    case DRIVE_TYPE_4040:
        disk_image_type = DISK_IMAGE_TYPE_D67;
        break;
    case DRIVE_TYPE_1571:
    case DRIVE_TYPE_1571CR:
        disk_image_type = DISK_IMAGE_TYPE_D71;
        break;
    case DRIVE_TYPE_1581:
    case DRIVE_TYPE_2000:
    case DRIVE_TYPE_4000:
        disk_image_type = DISK_IMAGE_TYPE_D81;
        break;
    case DRIVE_TYPE_8050:
        disk_image_type = DISK_IMAGE_TYPE_D80;
        break;
    case DRIVE_TYPE_8250:
    case DRIVE_TYPE_1001:
        disk_image_type = DISK_IMAGE_TYPE_D82;
        break;
    default:
        log_error(log, "No idea what disk image format to use.");
        return -1;
    }

    /* read prg file */
    prg = load_prg(file_name, fh, log);
    if (prg == NULL) {
        return -1;
    }

    /* disable TDE */
    resources_get_int("DriveTrueEmulation", &old_tde_state);
    if (old_tde_state != 0) {
        log_message(log, "Turning true drive emulation off.");
        resources_set_int("DriveTrueEmulation", 0);
    }

    do {
        result = -1;

        /* create empty image */
        if (vdrive_internal_create_format_disk_image(image_name, (char *)"AUTOSTART", disk_image_type) < 0) {
            log_error(log, "Error creating autostart disk image: %s", image_name);
            break;
        }

        /* attach disk image */
        if (file_system_attach_disk(drive, image_name) < 0) {
            log_error(log, "Could not attach disk image: %s", image_name);
            break;
        }

        /* get vdrive */
        vdrive = file_system_get_vdrive((unsigned int)drive);
        if (vdrive == NULL) {
            break;
        }

        /* get file name size */
        file_name_size = strlen((const char *)fh->name);
        if (file_name_size > 16) {
            file_name_size = 16;
        }

        /* open file on disk */
        if (vdrive_iec_open(vdrive, (const BYTE *)fh->name, file_name_size, secondary, NULL) != SERIAL_OK) {
            log_error(log, "Could not open file");
            break;
        }

        result2 = 0;
        /* write PRG data to file */
        for (i = -2; i < (int)prg->size; i++) {
            switch (i) {
            case -2:
                data = (BYTE)prg->start_addr;
                break;
            case -1:
                data = (BYTE)(prg->start_addr >> 8);
                break;
            default:
                data = prg->data[i];
                break;
            }
            if (vdrive_iec_write(vdrive, data, secondary) != SERIAL_OK) {
                log_error(log, "Could not write file");
                result2 = -1;
                break;
            }
        }

        /* close file */
        if (vdrive_iec_close(vdrive, secondary) != SERIAL_OK) {
            log_error(log, "Could not close file");
            break;
        }
        result = result2;
    } while (0);

    /* free prg file */
    free_prg(prg);

    /* re-enable TDE */
    if (old_tde_state != 0) {
        log_message(log, "Turning true drive emulation on.");
        resources_set_int("DriveTrueEmulation", old_tde_state);
    }

    /* ready */
    return result;
}
示例#13
0
/* Temporary hack.  */
int vdrive_bam_reread_bam(unsigned int unit)
{
    return vdrive_bam_read_bam(file_system_get_vdrive(unit));
}
示例#14
0
void mon_drive_block_cmd(int op, int track, int sector, MON_ADDR addr)
{
    vdrive_t *vdrive;

    mon_evaluate_default_addr(&addr);

    vdrive = file_system_get_vdrive(8);

    if (!vdrive || vdrive->image == NULL) {
        mon_out("No disk attached\n");
        return;
    }

    if (!op) {
        BYTE readdata[256];
        int i, j, dst;
        MEMSPACE dest_mem;

        /* We ignore disk error codes here.  */
        if (vdrive_read_sector(vdrive, readdata, track, sector)
            < 0) {
            mon_out("Error reading track %d sector %d\n", track, sector);
            return;
        }

        if (mon_is_valid_addr(addr)) {
            dst = addr_location(addr);
            dest_mem = addr_memspace(addr);

            for (i = 0; i < 256; i++) {
                mon_set_mem_val(dest_mem, ADDR_LIMIT(dst + i), readdata[i]);
            }

            mon_out("Read track %d sector %d into address $%04x\n", track, sector, dst);
        } else {
            for (i = 0; i < 16; i++) {
                mon_out(">%04x", i * 16);
                for (j = 0; j < 16; j++) {
                    if ((j & 3) == 0) {
                        mon_out(" ");
                    }
                    mon_out(" %02x", readdata[i * 16 + j]);
                }
                mon_out("\n");
            }
        }
    } else {
        BYTE writedata[256];
        int i, src;
        MEMSPACE src_mem;

        src = addr_location(addr);
        src_mem = addr_memspace(addr);

        for (i = 0; i < 256; i++) {
            writedata[i] = mon_get_mem_val(src_mem, ADDR_LIMIT(src + i));
        }

        if (vdrive_write_sector(vdrive, writedata, track, sector)) {
            mon_out("Error writing track %d sector %d\n", track, sector);
            return;
        }

        mon_out("Write data from address $%04x to track %d sector %d\n",
                src, track, sector);
    }
}
示例#15
0
int parallel_trap_attention(int b)
{
    int st = 0;
    serial_t *p;
    void *vdrive;

    if (parallel_debug) {
        log_message(parallel_log, "ParallelAttention(%02x).", b);
    }

    if (b == 0x3f
        && (((TrapSecondary & 0xf0) == 0xf0)
            || ((TrapSecondary & 0x0f) == 0x0f))) {
        st = parallelcommand();
    } else {
        switch (b & 0xf0) {
            case 0x20:
            case 0x40:
                TrapDevice = b;
                break;

            case 0x60:          /* secondary address */
            case 0xe0:          /* close a file */
                TrapSecondary = b;
                st |= parallelcommand();
                break;

            case 0xf0:          /* Open File needs the filename first */
                TrapSecondary = b;
                p = serial_device_get(TrapDevice & 0x0f);
#ifndef DELAYEDCLOSE
                vdrive = (void *)file_system_get_vdrive(TrapDevice & 0x0f);
                if (p->isopen[b & 0x0f] == 2) {
                    (*(p->closef))(vdrive, b & 0x0f);
                }
#endif
                p->isopen[b & 0x0f] = 1;
                break;
        }
    }

    p = serial_device_get(TrapDevice & 0x0f);
    if (!(p->inuse)) {
        st |= 0x80;
    }

    if (((b & 0xf0) == 0x20) || ((b & 0xf0) == 0x40) || ((b & 0xf0) == 0x60)
        || (b == 0x3f)) {
        if (p->listenf) {
            /* send talk/listen/unlisten to emulated devices for
               flushing of REL file write buffer. */
            if ((TrapDevice & 0x0f) >= 8) {
                vdrive = (void *)file_system_get_vdrive(TrapDevice & 0x0f);
                (*(p->listenf))(vdrive, TrapSecondary & 0x0f);
            }
        }
    }

    if ((b == 0x3f) || (b == 0x5f)) {
        TrapDevice = 0;
        TrapSecondary = 0;
    }

    st |= TrapDevice << 8;

    if (attention_callback_func) {
        attention_callback_func();
    }

    return st;
}
示例#16
0
int autostart_prg_with_disk_image(const char *file_name, fileio_info_t *fh, const char *image_name)
{
	const int drive = 8;
	const int secondary = 1;
	autostart_prg_t *prg;
	vdrive_t *vdrive;
	int i;
	int old_tde_state;
	int file_name_size;
	BYTE lo,hi;

	/* read prg file */ 
	prg = load_prg(file_name, fh);
	if (prg == NULL) {
		return -1;
	}

	/* disable TDE */
	resources_get_int("DriveTrueEmulation", &old_tde_state);
	if (old_tde_state != 0)
		resources_set_int("DriveTrueEmulation", 0);

	/* create empty image */
	if (vdrive_internal_create_format_disk_image(image_name, 
				(char *)"AUTOSTART", DISK_IMAGE_TYPE_D64) <0 ) {
		//log_error(log, "Error creating autostart disk image: %s", image_name);
		free_prg(prg);
		return -1;
	}

	/* attach disk image */
	if (file_system_attach_disk(drive, image_name) < 0) {
		//log_error(log, "Could not attach disk image: %s", image_name);
		free_prg(prg);
		return -1;
	}

	/* copy file to disk */
	vdrive = file_system_get_vdrive((unsigned int)drive);
	if (vdrive == NULL) {
		free_prg(prg);
		return -1;
	}

	/* get file name size */
	file_name_size = strlen((const char *)fh->name);
	if (file_name_size > 16) {
		file_name_size = 16;
	}

	/* open file on disk */
	if (vdrive_iec_open(vdrive, (const BYTE *)fh->name,
				file_name_size, secondary, NULL) != SERIAL_OK) {
		//log_error(log, "Could not open file");
		free_prg(prg);
		return -1;
	}

	/* write start address to file */
	lo = (BYTE)(prg->start_addr & 0xff);
	hi = (BYTE)((prg->start_addr >> 8) & 0xff);
	if ((vdrive_iec_write(vdrive, lo, secondary) != SERIAL_OK) ||
			(vdrive_iec_write(vdrive, hi, secondary) != SERIAL_OK)) {
		//log_error(log, "Could not write file");
		free_prg(prg);
		return -1;
	}

	/* write PRG data to file */
	for (i = 0; i < prg->size; i++) {
		if (vdrive_iec_write(vdrive, prg->data[i], secondary) != SERIAL_OK) {
			//log_error(log, "Could not write file");
			free_prg(prg);
			return -1;
		}
	}

	/* close file */
	if (vdrive_iec_close(vdrive, secondary) != SERIAL_OK) {
		//log_error(log, "Could not close file");
		free_prg(prg);
		return -1;
	}

	/* free prg file */
	free_prg(prg);

	/* re-enable TDE */
	if (old_tde_state != 0)
		resources_set_int("DriveTrueEmulation", old_tde_state);

	/* ready */
	return 0;
}
示例#17
0
文件: attach.c 项目: martinpiper/VICE
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;
}
示例#18
0
int parallel_trap_receivebyte(BYTE * data, int fake)
{
    int st = 0, secadr = TrapSecondary & 0x0f;
    serial_t *p;
    void *vdrive;
    unsigned int dnr;

    for (dnr = 0; dnr < DRIVE_NUM; dnr++) {
        if ((unsigned int)(TrapDevice & 0x0f) == dnr + 8
            && drive_context[dnr]->drive->enable) {
            return 0x83;    /* device not present */
        }
    }

    p = serial_device_get(TrapDevice & 0x0f);
    vdrive = (void *)file_system_get_vdrive(TrapDevice & 0x0f);

    /* first fill up buffers */
#if 0
    if (!p->lastok[secadr]) {
        p->lastok[secadr] = p->nextok[secadr];
        p->lastbyte[secadr] = p->nextbyte[secadr];
        p->lastst[secadr] = p->nextst[secadr];
        p->nextok[secadr] = 0;
#endif
    if (!p->lastok[secadr]) {
        p->lastst[secadr] =
            (*(p->getf))(vdrive, &(p->lastbyte[secadr]), secadr);
        p->lastok[secadr] = 1;
    }
#if 0
}
if ((!p->nextok[secadr]) && (!p->lastst[secadr])) {
    p->nextst[secadr] =
        (*(p->getf))(vdrive, &(p->nextbyte[secadr]), secadr);
    p->nextok[secadr] = 1;
}
#endif
    *data = p->lastbyte[secadr];
    if (!fake) {
        p->lastok[secadr] = 0;
    }
#if 0
    st = p->nextok[secadr] ? p->nextst[secadr] :
         (p->lastok[secadr] ? p->lastst[secadr] : 2);
#endif
    st = p->lastst[secadr]; /* added */
    st += TrapDevice << 8;

    if (parallel_debug) {
        log_message(parallel_log,
                    "receive: sa=%02x lastb = %02x (data=%02x), "
                    "ok=%s, st=%04x, nextb = %02x, "
                    "ok=%s, st=%04x.", secadr,
                    p->lastbyte[secadr], (int)*data,
                    p->lastok[secadr] ? "ok" : "no",
                    p->lastst[secadr],
                    p->nextbyte[secadr], p->nextok[secadr] ? "ok" : "no",
                    p->nextst[secadr]);
    }
#if 0
    if ((!fake) && p->nextok[secadr] && p->nextst[secadr]) {
        p->nextok[secadr] = 0;
    }
#endif
    if ((st & 0x40) && eof_callback_func != NULL) {
        eof_callback_func();
    }
    return st;
}