コード例 #1
0
/* This function calibrates the datarate (i.e. determines the maximal
 * usable data rate) and sets the global variable ft_qic_std to qic_std
 *
 */
int ftape_calibrate_data_rate(unsigned int qic_std)
{
	int rate = ft_fdc_rate_limit;
	int result;
	TRACE_FUN(ft_t_flow);

	ft_qic_std = qic_std;

	if (ft_qic_std == -1) {
		TRACE_ABORT(-EIO, ft_t_err,
		"Unable to determine data rate if QIC standard is unknown");
	}

	/*  Select highest rate supported by both fdc and drive.
	 *  Start with highest rate supported by the fdc.
	 */
	while (fdc_set_data_rate(rate) < 0 && rate > 250) {
		rate /= 2;
	}
	TRACE(ft_t_info,
	      "Highest FDC supported data rate: %d Kbps", rate);
	ft_fdc_max_rate = rate;
	do {
		result = ftape_set_data_rate(rate, ft_qic_std);
	} while (result == -EINVAL && (rate /= 2) > 250);
	if (result < 0) {
		TRACE_ABORT(-EIO, ft_t_err, "set datarate failed");
	}
	ft_data_rate = rate;
	TRACE_EXIT 0;
}
コード例 #2
0
ファイル: ftape-ctl.c プロジェクト: robacklin/uclinux-linux
int ftape_init_drive(int *formatted)
{
	TRACE_FUN(5, "ftape_init_drive");
	int result = 0;
	int status;

	result = ftape_report_raw_drive_status(&status);
	if (result >= 0 && (status & QIC_STATUS_CARTRIDGE_PRESENT)) {
		if (!(status & QIC_STATUS_AT_BOT)) {
			/*  Antique drives will get here after a soft reset,
			 *  modern ones only if the driver is loaded when the
			 *  tape wasn't rewound properly.
			 */
			ftape_seek_to_bot();
		}
		if (!(status & QIC_STATUS_REFERENCED)) {
			TRACE(5, "starting seek_load_point");
			result = ftape_command_wait(QIC_SEEK_LOAD_POINT,
						 timeout.reset, &status);
			if (result < 0) {
				TRACE(1, "seek_load_point failed (command)");
			}
		}
	}
	if (result >= 0) {
		int rate;

		*formatted = (status & QIC_STATUS_REFERENCED);
		if (!*formatted) {
			TRACE(1, "Warning: tape is not formatted !");
		}
		/*  Select highest rate supported by both fdc and drive.
		 *  Start with highest rate supported by the fdc.
		 */
		if (fdc.type >= i82078_1)
			rate = 0;
		else if (fdc.type >= i82077)
			rate = 1;
		else
			rate = 2;
		do {
			result = ftape_set_data_rate(rate);
			if (result >= 0) {
				ftape_calc_timeouts();
				break;
			}
			++rate;
		} while (rate < 4);
		if (result < 0) {
			result = -EIO;
		}
	}
	if (result >= 0) {
		/* Tape should be at bot if new cartridge ! */
		ftape_new_cartridge();
	}
	init_drive_needed = 0;
	TRACE_EXIT;
	return result;
}
コード例 #3
0
int ftape_half_data_rate(void)
{
	if (ft_data_rate < 500) {
		return -1;
	}
	if (ftape_set_data_rate(ft_data_rate / 2, ft_qic_std) < 0) {
		return -EIO;
	}
	ftape_calc_timeouts(ft_qic_std, ft_data_rate, ftape_tape_len);
	return 0;
}