void sc499_device::device_reset() { LOG1(("reset sc499")); m_data = 0; m_command = SC499_CMD_NO_COMMAND; m_status = SC499_STAT_RDY; // | SC499_STAT_EXC; m_control = 0; m_first_block_hack = 1; m_nasty_readahead = 0; m_read_block_pending = 0; m_current_command = m_command; m_data_error_counter = 0; m_underrun_counter = 0; m_image_length = 0; check_tape(); m_data_index = 0; m_ctape_block_index = 0; m_tape_pos = 0; irq_state = CLEAR_LINE; dma_drq_state = CLEAR_LINE; }
void sc499_device::read_block() { if (m_tape_pos == 0) { // check if tape has been replaced or removed check_tape(); } m_image->fseek((UINT64) m_tape_pos * SC499_CTAPE_BLOCK_SIZE, SEEK_SET); if (m_image->image_feof()) { m_status &= ~SC499_STAT_EXC; m_status &= ~SC499_STAT_DIR; m_status &= ~SC499_STAT_DON; tape_status_clear(SC499_ST_CLEAR_ALL); tape_status_set(SC499_ST_READ_ERROR); } else { m_image->fread(m_ctape_block_buffer, SC499_CTAPE_BLOCK_SIZE); // if (verbose > 1 || m_tape_pos % 100 == 0) { log_block("read_block"); } m_ctape_block_index = 0; m_tape_pos++; if (m_first_block_hack) { // FIXME: we must read first block twice (in MD for 'di c' and 'ld' or 'ex ...') // why is this necessary??? m_tape_pos = 0; LOG(("read_block - duplicating block %d", m_tape_pos)); } m_first_block_hack = 0; // we are no longer at Beginning of media (BOM) tape_status_clear(SC499_ST1_BOM); if (block_is_filemark()) { m_status &= ~SC499_STAT_EXC; m_status &= ~SC499_STAT_DIR; tape_status_clear(SC499_ST_CLEAR_ALL); tape_status_set(SC499_ST0_FM); } else { tape_status_clear(SC499_ST0_FM); } } // if (m_tape_pos == 69400) verbose = 2; }
void sc499_device::write_block() { log_block("write_block"); if (m_tape_pos == 0) { // check if tape has been replaced or removed check_tape(); } m_image->fseek((UINT64) m_tape_pos * SC499_CTAPE_BLOCK_SIZE, SEEK_SET); m_image->fwrite(m_ctape_block_buffer, SC499_CTAPE_BLOCK_SIZE); m_ctape_block_count = m_tape_pos; m_ctape_block_index = 0; m_tape_pos++; // we are no longer at Beginning of media (BOM) tape_status_clear(SC499_ST1_BOM); }
void sc499_device::device_reset() { m_data = 0; m_command = SC499_CMD_NO_COMMAND; m_status = SC499_STAT_RDY; // | SC499_STAT_EXC; m_control = 0; m_first_block_hack = 1; m_nasty_readahead = 0; m_read_block_pending = 0; m_current_command = m_command; m_data_error_counter = 0; m_underrun_counter = 0; m_image_length = 0; check_tape(); m_data_index = 0; m_ctape_block_index = 0; m_tape_pos = 0; irq_state = CLEAR_LINE; dma_drq_state = CLEAR_LINE; if (!m_installed) { int base = m_iobase->read(); m_irq = m_irqdrq->read() & 7; m_drq = m_irqdrq->read()>>4; m_isa->install_device(base, base+7, read8_delegate(FUNC(sc499_device::read), this), write8_delegate(FUNC(sc499_device::write), this)); m_isa->set_dma_channel(m_drq, this, true); m_installed = true; }
static THREAD_FUNC TapeWatchThread(void *dummy) { int boot_flag; static struct mtget info; static char *fid = "TapeWatchThread"; boot_flag = 1; util_log(2, "TAPE_WATCH thread started, tid = %d", THREAD_SELF()); set_alarm(ISP_ALARM_OFFLINE); while (1) { MUTEX_LOCK(&mp); /* if we were offline, see if a tape is now present */ if (prev_state == MTIO_OFFLINE) { if ((tp = mtio_open(Params->odev, "w")) != null) { if (mtio_status(tp, &info) != -1) { crnt_state = MTIO_ONLINE; clear_alarm(ISP_ALARM_OFFLINE); if (ioerr) { clear_alarm(ISP_ALARM_IOERR); ioerr = 0; } check_tape(boot_flag); } else { mtio_close(tp); tp = (TAPE *) NULL; } } if (tp == null && shutting_down()) { util_log(1, "shutting down w/o final flush (no tape)"); complete_shutdown(); } /* if we were on-line, make sure we still are that way */ /* THIS CODE DOES NOT WORK AND I DON'T KNOW HOW TO MAKE IT WORK! */ } else if (mtio_nop(tp) < 0 || mtio_status(tp, &info) < 0) { mtio_close(tp); tp = (TAPE *) tp; set_alarm(ISP_ALARM_OFFLINE); crnt_state = MTIO_OFFLINE; } if (crnt_state != prev_state) { MUTEX_LOCK(&Status->lock); if (crnt_state == MTIO_ONLINE) { Status->output.state = ISP_OUTPUT_ONLINE; Status->output.err = 0; Status->output.file = info.mt_fileno + 1; Status->output.nrec = 0; } else { Status->output.state = ISP_OUTPUT_OFFLINE; } MUTEX_UNLOCK(&Status->lock); } prev_state = crnt_state; boot_flag = 0; if (pending && (crnt_state == MTIO_ONLINE)) { pending = 0; SEM_POST(&sp); } MUTEX_UNLOCK(&mp); sleep(10); } }