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

📄 ethernetcard.java

📁 JPC: x86 PC Hardware Emulator. 牛津大学开发的一个纯JAVA的x86系统结构硬件模拟器。
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
	public int[] ioPortsRequested()	{	    int addr = this.getAddress();	    int[] temp = new int[32];	    for (int i = 0; i < 32; i++)		temp[i] = addr + i;	    return temp;	}        public void timerCallback() {}    }        private void ioPortWrite(int address, byte data)    {	address &= 0xf;	if(address == E8390_CMD) {	    /* control register */	    this.setCommand(data);	    if (0 != (data & E8390_START)) {		this.andISR((byte)~ENISR_RESET);		/* test specific case: zero length transfer */		if((0 != (data & (E8390_RREAD | E8390_RWRITE)))		   && (this.getRCNT() == 0)) { // check operators		    this.orISR(ENISR_RDC);		    this.updateIRQ();		}		if (0 != (data & E8390_TRANS)) {		    this.getEthernetOutput().sendPacket(null, 0, 0);		    /* signal end of transfer */		    this.setTSR(ENTSR_PTX);		    this.orISR(ENISR_TX);		    this.updateIRQ();		}	    }	} else {	    int page = this.getCommand() >> 6;	    int offset = address | (page << 4);	    switch(offset) {	    case EN0_STARTPG:		this.setStart(data << 8);		break;	    case EN0_STOPPG:		this.setStop(data << 8);		break;	    case EN0_BOUNDARY:		this.setBoundary(data);		break;	    case EN0_IMR:		this.setIMR(data);		this.updateIRQ();		break;	    case EN0_TPSR:		this.setTPSR(data);		break;	    case EN0_TCNTLO:		this.setTCNT((short)((this.getTCNT() & 0xff00) | data));		break;	    case EN0_TCNTHI:		this.setTCNT((short)((this.getTCNT() & 0x00ff) | (data << 8)));		break;	    case EN0_RSARLO:		this.setRSAR((this.getRSAR() & 0xff00) | data);		break;	    case EN0_RSARHI:		this.setRSAR((this.getRSAR() & 0x00ff) | (data << 8));		break;	    case EN0_RCNTLO:		this.setRCNT((short)((this.getRCNT() & 0xff00) | data));		break;	    case EN0_RCNTHI:		this.setRCNT((short)((this.getRCNT() & 0x00ff) | (data << 8)));		break;	    case EN0_DCFG:		this.setDCfg(data);		break;	    case EN0_ISR:		this.andISR((byte)~(data & 0x7f));		this.updateIRQ();		break;	    case EN1_PHYS:	    case EN1_PHYS + 1:	    case EN1_PHYS + 2:	    case EN1_PHYS + 3:	    case EN1_PHYS + 4:	    case EN1_PHYS + 5:		this.setPhysical(offset - EN1_PHYS, data);		break;	    case EN1_CURPAG:		this.setCurrentPage(data);		break;	    case EN1_MULT:	    case EN1_MULT + 1:	    case EN1_MULT + 2:	    case EN1_MULT + 3:	    case EN1_MULT + 4:	    case EN1_MULT + 5:	    case EN1_MULT + 6:	    case EN1_MULT + 7:		this.setMulticast(offset - EN1_MULT, data);		break;	    }	}    }    private void asicIOPortWriteByte(int address, short data)    {	if (this.getRCNT() == 0)	    return;	if (0 != (this.getDCfg() & 0x01)) {	    /* 16 bit access */	    this.memoryWriteWord(this.getRSAR(), data);	    this.dmaUpdate(2);	} else {	    /* 8 bit access */	    this.memoryWriteByte(this.getRSAR(), (byte)data);	    this.dmaUpdate(1);	}    }    private void asicIOPortWriteWord(int address, short data)    {	if (this.getRCNT() == 0)	    return;	if (0 != (this.getDCfg() & 0x01)) {	    /* 16 bit access */	    this.memoryWriteWord(this.getRSAR(), data);	    this.dmaUpdate(2);	} else {	    /* 8 bit access */	    this.memoryWriteByte(this.getRSAR(), (byte)data);	    this.dmaUpdate(1);	}    }    private void asicIOPortWriteLong(int address, int data)    {	if (this.getRCNT() == 0)	    return;	this.memoryWriteLong(this.getRSAR(), data);	this.dmaUpdate(4);    }    private byte ioPortRead(int address)    {	address &= 0xf;	if (address == E8390_CMD) {	    return this.getCommand();	}	int page = this.getCommand() >> 6;	int offset = address | (page << 4);	switch (offset) {	case EN0_TSR:	    return this.getTSR();	case EN0_BOUNDARY:	    return this.getBoundary();        case EN0_ISR:	    return this.getISR();	case EN0_RSARLO:	    return (byte)(this.getRSAR() & 0x00ff);	case EN0_RSARHI:	    return (byte)(this.getRSAR() >> 8);        case EN1_PHYS:	case EN1_PHYS + 1:	case EN1_PHYS + 2:	case EN1_PHYS + 3:	case EN1_PHYS + 4:	case EN1_PHYS + 5:	    return this.getPhysical(offset - EN1_PHYS);        case EN1_CURPAG:	    return this.getCurrentPage();        case EN1_MULT:	case EN1_MULT + 1:	case EN1_MULT + 2:	case EN1_MULT + 3:	case EN1_MULT + 4:	case EN1_MULT + 5:	case EN1_MULT + 6:	case EN1_MULT + 7:	    return this.getMulticast(offset - EN1_MULT);        case EN0_RSR:	    return this.getRSR();	default:	    return 0x00;	}    }    private short asicIOPortReadByte(int address)    {	short ret;	if (0 != (this.getDCfg() & 0x01)) {	    /* 16 bit access */	    ret = this.memoryReadWord(this.getRSAR());	    this.dmaUpdate(2);	} else {	    /* 8 bit access */	    ret = (short)this.memoryReadByte(this.getRSAR());	    ret &= 0xff;	    this.dmaUpdate(1);	}	return ret;    }    private short asicIOPortReadWord(int address)    {	short ret;	if (0 != (this.getDCfg() & 0x01)) {	    /* 16 bit access */	    ret = this.memoryReadWord(this.getRSAR());	    this.dmaUpdate(2);	} else {	    /* 8 bit access */	    ret = (short)this.memoryReadByte(this.getRSAR());	    ret &= 0xff;	    this.dmaUpdate(1);	}	return ret;    }    private int asicIOPortReadLong(int address)    {	int ret = this.memoryReadLong(this.getRSAR());	this.dmaUpdate(4);	return ret;    }    private byte resetIOPortRead(int address)    {	this.internalReset();	return 0x00;    }    private void dmaUpdate(int length)    {	this.setRSAR(this.getRSAR() + length);	if (this.getRSAR() == this.getStop())	    this.setRSAR(this.getStart());	if (this.getRCNT() <= length) {	    this.setRCNT((short)0);	    /* signal end of transfer */	    this.orISR(ENISR_RDC);	    this.updateIRQ();	} else {	    this.setRCNT((short)(this.getRCNT() - length));	}    }    private void memoryWriteByte(int address, byte data)    {	if (address < 32 ||	    (address >= NE2000_PMEM_START && address < NE2000_MEM_SIZE)) {	    mem.set(address, data);	}    }    private void memoryWriteWord(int address, short data)    {	address &= ~1;	if (address < 32 ||	    (address >= NE2000_PMEM_START && address < NE2000_MEM_SIZE)) {	    mem.setShort(address, data);	}    }    private void memoryWriteLong(int address, int data)    {	address &= ~1;	if (address < 32 ||	    (address >= NE2000_PMEM_START && address < NE2000_MEM_SIZE)) {	    mem.setInt(address, data);	}    }    private byte memoryReadByte(int address)    {	if (address < 32 ||	    (address >= NE2000_PMEM_START && address < NE2000_MEM_SIZE)) {	    return mem.get(address);	} else {	    return (byte)0xff;	}    }    private short memoryReadWord(int address)    {	address &= ~1;	if (address < 32 ||	    (address >= NE2000_PMEM_START && address < NE2000_MEM_SIZE)) {	    return mem.getShort(address);	} else {	    return (short)0xffff;	}    }    private int memoryReadLong(int address)    {	address &= ~1;	if (address < 32 ||	    (address >= NE2000_PMEM_START && address < NE2000_MEM_SIZE)) {	    return mem.getInt(address);	} else {	    return (int)0xffffffff;	}    }    private byte getCommand()    {	return command;    }    private void setCommand(byte command)    {	this.command = command;    }    private int getStart()    {	return start;    }    private void setStart(int start)    {	this.start = start;    }    private int getStop()    {	return stop;    }    private void setStop(int stop)    {	this.stop = stop;    }    private byte getBoundary()    {	return boundary;    }    private void setBoundary(byte boundary)    {	this.boundary = boundary;    }    private byte getTSR()    {	return tsr;    }    private void setTSR(byte tsr)    {	this.tsr = tsr;    }    private byte getTPSR()    {	return tpsr;    }    private void setTPSR(byte tpsr)    {	this.tpsr = tpsr;    }    private short getTCNT()    {	return tcnt;    }    private void setTCNT(short tcnt)    {	this.tcnt = tcnt;    }    private short getRCNT()    {	return rcnt;    }    private void setRCNT(short rcnt)    {	this.rcnt = rcnt;    }    private int getRSAR()    {	return rsar;    }    private void setRSAR(int rsar)    {	this.rsar = rsar;    }    private byte getRSR()    {	return rsr;    }    private void setRSR(byte rsr)    {	this.rsr = rsr;    }    private byte getISR()    {	return isr;    }    private void setISR(byte isr)    {	this.isr = isr;    }    private void andISR(byte mask)    {	this.setISR((byte)(this.getISR() & mask));    }    private void orISR(byte mask)    {	this.setISR((byte)(this.getISR() | mask));    }    private byte getDCfg()    {	return dcfg;    }    private void setDCfg(byte dcfg)    {	this.dcfg = dcfg;    }    private byte getIMR()    {	return imr;    }    private void setIMR(byte imr)    {	this.imr = imr;    }    private byte getPhysical(int address)    {	return phys[address];    }    private void setPhysical(int address, byte data)    {	phys[address] = data;    }    private byte getCurrentPage()    {	return curpag;    }    private void setCurrentPage(byte currentPage)    {	this.curpag = currentPage;    }    private byte getMulticast(int address)    {	return mult[address];    }    private void setMulticast(int address, byte data)    {	mult[address] = data;    }    private EthernetOutput getEthernetOutput()    {	return this.outputDevice;    }    public void testPacket()    {	this.setIMR((byte)0xff);	this.orISR(ENISR_RX);	this.updateIRQ();    }}    

⌨️ 快捷键说明

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