cmosplugin.java

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

JAVA
72
字号
/*
 * $Id: CMOSPlugin.java,v 1.2 2004/01/02 08:41:59 epr Exp $
 */
package org.jnode.driver.cmos.def;

import javax.naming.NamingException;

import org.jnode.driver.cmos.CMOSService;
import org.jnode.naming.InitialNaming;
import org.jnode.plugin.Plugin;
import org.jnode.plugin.PluginDescriptor;
import org.jnode.plugin.PluginException;
import org.jnode.system.ResourceNotFreeException;
import org.jnode.system.ResourceOwner;
import org.jnode.system.SimpleResourceOwner;
import org.jnode.vm.VmSystem;

/**
 * @author epr
 */
public class CMOSPlugin extends Plugin implements CMOSService {

	/** The CMOS accesser */
	private CMOS cmos;
	private final RTC rtc = new RTC(this);

	/**
	 * Initialize a new instance
	 * @param descriptor
	 */
	public CMOSPlugin(PluginDescriptor descriptor) {
		super(descriptor);
	}

	/**
	 * Gets the value of a CMOS register with a given nr. 
	 * @param regnr
	 * @return The register value
	 */
	public int getRegister(int regnr) {
		return cmos.getRegister(regnr);
	}

	/**
	 * Start this plugin
	 * @throws PluginException
	 */
	protected void startPlugin() throws PluginException {
		try {
			final ResourceOwner owner = new SimpleResourceOwner("CMOS");
			cmos = new CMOS(owner);
			InitialNaming.bind(NAME, this);
			VmSystem.setRtcService(rtc);
		} catch (ResourceNotFreeException ex) {
			throw new PluginException("Cannot claim IO ports", ex);
		} catch (NamingException ex) {
			throw new PluginException("Cannot register service", ex);
		}
	}

	/**
	 * Stop this plugin
	 * @throws PluginException
	 */
	protected void stopPlugin() throws PluginException {
		InitialNaming.unbind(NAME);
		VmSystem.resetRtcService(rtc);
		cmos.release();
		cmos = null;
	}
}

⌨️ 快捷键说明

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