idecommand.java

来自「纯java操作系统jnode,安装简单和操作简单的个人使用的Java操作系统」· Java 代码 · 共 85 行

JAVA
85
字号
/*
 * $Id: IDECommand.java,v 1.1 2003/11/25 11:50:41 epr Exp $
 */
package org.jnode.driver.ide;

import org.apache.log4j.Logger;
import org.jnode.util.Command;


/**
 * @author epr
 */
public abstract class IDECommand extends Command implements IDEConstants {

	protected final Logger log = Logger.getLogger(getClass());
	/** ID From master (true) or slave (false) */
	protected final boolean master;
	/** The taskfile for which this command is intended */
	private final int taskfile;
	/** Error that occurred during this command. -1 means no error */
	private int error = -1;

	/**
	 * Create a new instance
	 * @param taskfile The taskfile to use. 0 for IDE0, 1 for IDE1
	 * @param master Command intended for master (true) or slave (false)
	 * @throws IllegalArgumentException Invalid argument
	 */
	protected IDECommand(int taskfile, boolean master) 
	throws IllegalArgumentException {
		if ((taskfile < 0) || (taskfile >= IDE_NR_TASKFILES)) {
			throw new IllegalArgumentException("Invalid taskfile " + taskfile);
		}
		this.taskfile = taskfile;
		this.master = master;
	}

	/**
	 * Setup the IDE controller for this command
	 */
	protected abstract void setup(IDEBus ide);

	/** 
	 * Handle an IDE IRQ.
	 */
	protected abstract void handleIRQ(IDEBus ide);

	/**
	 * Is this command for the master (true) or slave (false).
	 */
	public boolean isMaster() {
		return master;
	}
	
	/**
	 * Gets the taskfile for which this command is intended.
	 * @return The taskfile [0..1] for which this command is intended.
	 */
	public int getTaskFile() {
		return taskfile;
	}
	
	/**
	 * Has this command got an error?
	 */
	public boolean hasError() {
		return (error != -1);
	}
	
	/**
	 * Gets the error code that occurred during this command
	 */
	public int getError() {
		return error;
	}
	
	/**
	 * Set the error code.
	 * @param error
	 */
	protected void setError(int error) {
		this.error = error;
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?