⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bios.java

📁 纯java操作系统jnode,安装简单和操作简单的个人使用的Java操作系统
💻 JAVA
字号:
/*
 * $Id: BIOS.java,v 1.1 2003/11/25 11:41:54 epr Exp $
 */
package org.jnode.driver.firmware.bios;

import org.jnode.driver.Driver;
import org.jnode.driver.DriverException;
import org.jnode.driver.firmware.AcpiRSDPInfo;
import org.jnode.driver.firmware.FirmwareAPI;
import org.jnode.system.MemoryResource;
import org.jnode.system.ResourceManager;
import org.jnode.system.ResourceNotFreeException;
import org.jnode.system.ResourceOwner;
import org.jnode.system.SimpleResourceOwner;
import org.jnode.vm.Address;

/**
 * BIOS firmware implementation.
 * 
 * <p>
 * Title:
 * </p>
 * <p>
 * Description:
 * </p>
 * <p>
 * Licence: GNU LGPL
 * </p>
 * <p>
 * </p>
 * 
 * @author Francois-Frederic Ozog
 * @version 1.0
 */

public class BIOS extends Driver implements FirmwareAPI {

	private final AcpiRSDPInfo info;

	public BIOS(AcpiRSDPInfo info) {
		this.info = info;
	}
	
	/**
	 * Start the device
	 * @throws DriverException
	 */
	protected void startDevice() throws DriverException {
		getDevice().registerAPI(FirmwareAPI.class, this);
	}

	/**
	 * Stop the device
	 * @throws DriverException
	 */
	protected void stopDevice() throws DriverException {
		getDevice().unregisterAPI(FirmwareAPI.class);
	}

	/**
	 * Gets the ACPI root descriptor table.
	 * @return The found root table, or null if not found.
	 */
	public AcpiRSDPInfo getAcpiRSDPInfo() {
		return info;
	}

	static AcpiRSDPInfo findAcpiRSDTPTR(ResourceManager rm) throws ResourceNotFreeException {
		// TODO This should be replaced by: owner = biosDevice; when the bios is a device.
		final ResourceOwner owner = new SimpleResourceOwner("BIOS");
		final byte[] match = { 'R', 'S', 'D', ' ', 'P', 'T', 'R', ' ' };

		final MemoryResource acpiSearchRegion;
		try {
			final Address ptr = Address.valueOf(0xe0000);
			acpiSearchRegion = rm.claimMemoryResource(owner, ptr, 0x1ffff, ResourceManager.MEMMODE_NORMAL);
		} catch (ResourceNotFreeException ex) {
			throw new ResourceNotFreeException("Could not get 0xE0000:FFFFF memory range");
		}
		try {
			final int max = 0x1ffff - match.length;
			for (int i = 0x0; i < max; i++) {
				if (startsWith(acpiSearchRegion, i, match)) {
					final byte version = acpiSearchRegion.getByte(i + 15);
					final Address ptr = Address.valueOf(0xe0000 + i);
					return new AcpiRSDPInfo(ptr, version);
				}

			}
			// Not an ACPI system
			return null;
		} finally {
			acpiSearchRegion.release();
		}
	}

	private static boolean startsWith(MemoryResource res, int index, byte[] src) {
		final int len = src.length;
		for (int i = 0; i < len; i++) {
			if (res.getByte(index + i) != src[i]) {
				return false;
			}
		}
		return true;
	}
}

⌨️ 快捷键说明

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