pcidevice.java
来自「纯java操作系统jnode,安装简单和操作简单的个人使用的Java操作系统」· Java 代码 · 共 174 行
JAVA
174 行
/*
* $Id: PCIDevice.java,v 1.1 2003/11/25 11:41:21 epr Exp $
*/
package org.jnode.driver.pci;
import org.jnode.driver.Device;
/**
* @author epr
*/
public class PCIDevice extends Device {
/** The PCI system */
private final PCIDriver pci;
/** The bus this device is on */
private final int bus;
/** The unit number of this this */
private final int unit;
/** The function number of this device */
private final int function;
/** PCIConfig of this device */
private final PCIDeviceConfig config;
/**
* Create a new instance
*
* @param bus
* @param unit
* @param function
*/
public PCIDevice(PCIBus bus, int unit, int function) {
super(bus, "pci(" + bus.getBus() + "," + unit + "," + function + ")");
this.pci = bus.getPCI();
this.bus = bus.getBus();
this.unit = unit;
this.function = function;
this.config = new PCIDeviceConfig(this);
}
/**
* Gets the bus this device is on
*/
public int getPCIBus() {
return bus;
}
/**
* Gets the function number of this device
*/
public int getFunction() {
return function;
}
/**
* Gets the unit number of this device
*/
public int getUnit() {
return unit;
}
/**
* Gets the PCI configuration for this device
*/
public PCIDeviceConfig getConfig() {
return config;
}
/**
* Is this a bridge device.
*/
public final boolean isBridge() {
return (config.getBaseClass() == PCIConstants.CLASS_BRIDGE);
}
/**
* Read a configuration dword for this device.
*
* @param register
* @param type
*/
protected int readConfigDword(int register, int type) {
return pci.readConfigDword(bus, unit, function, register, type);
}
/**
* Read a configuration dword for this device at a given offset
* @param offset
*/
public final int readConfigDword(int offset) {
return pci.readConfigDword(bus, unit, function, offset);
}
/**
* Read a configuration word for this device at a given offset
* @param offset
*/
public final int readConfigWord(int offset) {
return pci.readConfigWord(bus, unit, function, offset);
}
/**
* Read a configuration byte for this device at a given offset
* @param offset
*/
public final int readConfigByte(int offset) {
return pci.readConfigByte(bus, unit, function, offset);
}
/**
* Write a configuration dword for this device.
*
* @param register
* @param type
* @param value
*/
protected final void writeConfigDword(int register, int type, int value) {
pci.writeConfigDword(bus, unit, function, register, type, value);
}
/**
* Write a configuration dword for this device at a given offset
*
* @param offset
* @param value
*/
public final void writeConfigDword(int offset, int value) {
pci.writeConfigDword(bus, unit, function, offset, value);
}
/**
* Write a configuration word for this device at a given offset
*
* @param offset
* @param value
*/
public final void writeConfigWord(int offset, int value) {
pci.writeConfigWord(bus, unit, function, offset, value);
}
/**
* Write a configuration byte for this device at a given offset
*
* @param offset
* @param value
*/
public final void writeConfigByte(int offset, int value) {
pci.writeConfigByte(bus, unit, function, offset, value);
}
/**
* Gets the name containing bus,unit,function.
*/
public final String getPCIName() {
return "" + bus + "," + unit + "," + function;
}
/**
* Gets the PCI bus API.
*/
public final PCIBusAPI getPCIBusAPI() {
return pci;
}
/**
* Convert to a String representation
* @see java.lang.Object#toString()
*/
public String toString() {
String cname = getClass().getName();
cname = cname.substring(cname.lastIndexOf('.') + 1);
return cname + "[" + getId() + ": " + getConfig().toString() + "]";
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?