Пример #1
0
void fdc_reset(unsigned int fnum, unsigned int drive_type)
{
    fdc_t *thefdc = &fdc[fnum];
    int drive1 = mk_drive1(fnum);
    disk_image_t *saved_image0,
                 *saved_image1;

#ifdef FDC_DEBUG
    log_message(fdc_log, "fdc_reset: drive %d type=%d\n",fnum, drive_type);
#endif

    saved_image0 = fdc[fnum].realimage;
    saved_image1 = NULL;

    /* detach disk images */
    if (thefdc->image) {
        thefdc->wps_change = 0;
        fdc_detach_image(thefdc->image, fnum + 8);
    }
    if (thefdc->num_drives == 2) {
        saved_image1 = fdc[drive1].realimage;
        if (fdc[drive1].image) {
            fdc[drive1].wps_change = 0;
            fdc_detach_image(fdc[drive1].image, drive1 + 8);
        }
    }

    if (drive_check_old(drive_type)) {
        thefdc->drive_type = drive_type;
        thefdc->num_drives = is_drive1(fnum) ? 1 :
                             drive_check_dual(drive_type) ? 2 : 1;
        thefdc->fdc_state = FDC_RESET0;
        alarm_set(thefdc->fdc_alarm, drive_clk[fnum] + 20);
    } else {
        thefdc->drive_type = DRIVE_TYPE_NONE;
        alarm_unset(thefdc->fdc_alarm);
        thefdc->fdc_state = FDC_UNUSED;
        thefdc->num_drives = 0;
    }

    /* re-attach disk images */
    if (saved_image0) {
#ifdef FDC_DEBUG
        printf("ieee/fdc.c:fdc_reset dev %d type %d drive 0 re-attach image %p (drive: %p)\n", fnum+8, drive_type, saved_image0, drive_context[fnum]->drive->image);
#endif
        fdc_attach_image(saved_image0, fnum + 8);
    }
    if (saved_image1) {
#ifdef FDC_DEBUG
        printf("ieee/fdc.c:fdc_reset dev %d type %d drive 1 re-attach image %p (drive: %p)\n", fnum+8, drive_type, saved_image0, drive_context[drive1]->drive->image);
#endif
        fdc_attach_image(saved_image1, drive1 + 8);
    }
}
Пример #2
0
int ieee_drive_image_detach(struct disk_image_s *image, unsigned int unit)
{
    return fdc_detach_image(image, unit);
}