Пример #1
0
UINT8 omti8621_device::check_disk_address(const UINT8 *cdb)
{
	UINT8 sense_code = OMTI_SENSE_CODE_NO_ERROR;
	UINT8 lun = get_lun(cdb);
	UINT16 head = cdb[1] & 0x1f;
	UINT16 sector = cdb[2] & 0x3f;
	UINT32 cylinder = cdb[3] + ((cdb[2] & 0xc0) << 2) + ((cdb[1] & 0x80) << 3);
	UINT8 block_count = cdb[4];
	omti_disk_image_device *disk = our_disks[lun];

	UINT32 disk_track = cylinder * disk->m_heads + head;
	UINT32 disk_addr = (disk_track * disk->m_sectors) + sector;

	if (block_count > OMTI_MAX_BLOCK_COUNT) {
		LOG(("########### check_disk_address: unexpected block count %x", block_count));
		sense_code = OMTI_SENSE_CODE_ILLEGAL_ADDRESS | OMTI_SENSE_CODE_ADDRESS_VALID;
	}

	if (lun > OMTI_MAX_LUN) {
		sense_code = OMTI_SENSE_CODE_DRIVE_NOT_READY;
	} else  if (!disk->m_image->exists()) {
		sense_code = OMTI_SENSE_CODE_DRIVE_NOT_READY;
	} else  if (sector >= OMTI_MAX_BLOCK_COUNT) {
		sense_code = OMTI_SENSE_CODE_ILLEGAL_ADDRESS | OMTI_SENSE_CODE_ADDRESS_VALID;
	} else if (head >= disk->m_heads) {
		sense_code = OMTI_SENSE_CODE_ILLEGAL_ADDRESS | OMTI_SENSE_CODE_ADDRESS_VALID;
	} else if (cylinder >= disk->m_cylinders) {
		sense_code = OMTI_SENSE_CODE_ILLEGAL_ADDRESS | OMTI_SENSE_CODE_ADDRESS_VALID;
	} else if ( disk_track == diskaddr_format_bad_track && disk_track != 0) {
		sense_code = OMTI_SENSE_CODE_BAD_TRACK;
	} else if (disk_addr == diskaddr_ecc_error && disk_addr != 0) {
		sense_code = OMTI_SENSE_CODE_ECC_ERROR;
	} else if (disk_track == alternate_track_address[1] && disk_track != 0) {
		sense_code = OMTI_SENSE_CODE_ALTERNATE_TRACK;
	}

	if (sense_code == OMTI_SENSE_CODE_NO_ERROR) {
		clear_sense_data();
	} else {
		command_status |= OMTI_COMMAND_STATUS_ERROR;
		set_sense_data(sense_code, cdb);
	}
	return sense_code == OMTI_SENSE_CODE_NO_ERROR;
}
Пример #2
0
static void omti_reset(omti8621_state *state) {
	LOG2(("omti_reset"));

	// should go from reset to idle after 100 us
	// state->omti_state = OMTI_STATE_RESET;
	state->omti_state = OMTI_STATE_IDLE;

	state->status_port =  OMTI_STATUS_NU6 | OMTI_STATUS_NU7;
	state->config_port = ~state->jumper;
	state->mask_port = 0;

	// default the sector data buffer with model and status information
	// (i.e. set sector data buffer for cmd=0x0e READ SECTOR BUFFER)

	memset(state->sector_buffer, 0, OMTI_DISK_SECTOR_SIZE);
	memcpy(state->sector_buffer, "8621VB.4060487xx", 0x10);
	state->sector_buffer[0x10] = 0; // ROM Checksum error
	state->sector_buffer[0x11] = 0; // Processor Register error
	state->sector_buffer[0x12] = 0; // Buffer RAM error
	state->sector_buffer[0x13] = 0; // Sequencer Register File error
	state->sector_buffer[0x14] = 0xc0; // 32K buffer size
	// TODO: add missing Default values for LUN 0, 1 and 3

	state->command_length = 0;
	state->command_index = 0;
	state->command_status = 0;

	state->data_index = 0;
	state->data_length = 0;

	clear_sense_data(state) ;

	state->diskaddr_ecc_error = 0;
	state->diskaddr_format_bad_track = 0;
	state->alternate_track_address[0] = 0;
	state->alternate_track_address[1] = 0;
}
Пример #3
0
void omti8621_device::device_reset()
{
	static const int io_bases[8] = { 0x320, 0x324, 0x328, 0x32c, 0x1a0, 0x1a4, 0x1a8, 0x1ac };

	LOG2(("device_reset"));

	// you can't read I/O ports in device_start() even if they're required_ioport<> in your class!
	if (!m_installed)
	{
		int esdi_base = io_bases[m_iobase->read() & 7];

		// install the ESDI ports
		m_isa->install16_device(esdi_base, esdi_base + 7, 0, 0, read16_delegate(FUNC(omti8621_device::read), this), write16_delegate(FUNC(omti8621_device::write), this));

		// and the onboard AT FDC ports
		if (m_iobase->read() & 8)
		{
			m_isa->install_device(0x0370, 0x0377, *m_fdc, &pc_fdc_interface::map);
		}
		else
		{
			m_isa->install_device(0x03f0, 0x03f7, *m_fdc, &pc_fdc_interface::map);
		}

		m_isa->set_dma_channel(2, this, TRUE);

		m_installed = true;
	}

	set_jumper(our_disks[0]->m_type);

	// should go from reset to idle after 100 us
	// state->omti_state = OMTI_STATE_RESET;
	omti_state = OMTI_STATE_IDLE;

	status_port =  OMTI_STATUS_NU6 | OMTI_STATUS_NU7;
	config_port = ~jumper;
	mask_port = 0;

	// default the sector data buffer with model and status information
	// (i.e. set sector data buffer for cmd=0x0e READ SECTOR BUFFER)

	memset(&sector_buffer[0], 0, OMTI_DISK_SECTOR_SIZE);
	memcpy(&sector_buffer[0], "8621VB.4060487xx", 0x10);
	sector_buffer[0x10] = 0; // ROM Checksum error
	sector_buffer[0x11] = 0; // Processor Register error
	sector_buffer[0x12] = 0; // Buffer RAM error
	sector_buffer[0x13] = 0; // Sequencer Register File error
	sector_buffer[0x14] = 0xc0; // 32K buffer size
	// TODO: add missing Default values for LUN 0, 1 and 3

	command_length = 0;
	command_index = 0;
	command_status = 0;

	data_index = 0;
	data_length = 0;

	clear_sense_data();

	diskaddr_ecc_error = 0;
	diskaddr_format_bad_track = 0;
	alternate_track_address[0] = 0;
	alternate_track_address[1] = 0;
}