vmwaredriver.java

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

JAVA
101
字号
/*
 * $Id: VMWareDriver.java,v 1.2 2003/12/20 12:19:43 epr Exp $
 */
package org.jnode.driver.video.vmware;

import org.jnode.driver.Device;
import org.jnode.driver.DeviceException;
import org.jnode.driver.DriverException;
import org.jnode.driver.pci.PCIDevice;
import org.jnode.driver.video.AbstractFrameBufferDriver;
import org.jnode.driver.video.AlreadyOpenException;
import org.jnode.driver.video.FrameBufferConfiguration;
import org.jnode.driver.video.HardwareCursorAPI;
import org.jnode.driver.video.Surface;
import org.jnode.driver.video.UnknownConfigurationException;
import org.jnode.system.ResourceNotFreeException;

/**
 * @author epr
 */
public class VMWareDriver extends AbstractFrameBufferDriver implements VMWareConstants {

	private FrameBufferConfiguration currentConfig;
	private VMWareCore kernel;
	
	private FrameBufferConfiguration[] configs;

	/**
	 * Create a new instance
	 */
	public VMWareDriver() { 
	}

	/**
	 * @see org.jnode.driver.video.FrameBufferAPI#getConfigurations()
	 */
	public final FrameBufferConfiguration[] getConfigurations() {
		return configs;
	}

	/**
	 * @see org.jnode.driver.video.FrameBufferAPI#getCurrentConfiguration()
	 */
	public final FrameBufferConfiguration getCurrentConfiguration() {
		return currentConfig;
	}

	/**
	 * @see org.jnode.driver.video.FrameBufferAPI#open(org.jnode.driver.video.FrameBufferConfiguration)
	 */
	public synchronized Surface open(FrameBufferConfiguration config) throws UnknownConfigurationException, AlreadyOpenException, DeviceException {
		for (int i = 0; i < configs.length; i++) {
			if (config.equals(configs[i])) {
				kernel.open(config);
				this.currentConfig = config;
				return kernel;
			}
		}
		throw new UnknownConfigurationException();
	}
	
	/**
	 * Notify of a close of the graphics object
	 * @param graphics
	 */
	final synchronized void close(VMWareCore graphics) {
		this.currentConfig = null;
	}
	/**
	 * @see org.jnode.driver.Driver#startDevice()
	 */
	protected void startDevice() throws DriverException {
		try {
			kernel = new VMWareCore(this, (PCIDevice)getDevice());
			configs = kernel.getConfigs();
		} catch (ResourceNotFreeException ex) {
			throw new DriverException(ex);
		}
		final Device dev = getDevice();
		super.startDevice();
		dev.registerAPI(HardwareCursorAPI.class, kernel);
	}

	/**
	 * @see org.jnode.driver.Driver#stopDevice()
	 */
	protected void stopDevice() throws DriverException {
		final Device dev = getDevice();
		dev.unregisterAPI(HardwareCursorAPI.class);
		if (currentConfig != null) {
			kernel.close();
		}
		if (kernel != null) {
			kernel.release();
			kernel = null;
		}
		super.stopDevice();
	}

}

⌨️ 快捷键说明

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