int read_cmd, ee_size;
    public EEPRO100Core(EEPRO100Driver driver, ResourceOwner owner, PCIDevice device, Flags flags) throws ResourceNotFreeException, DriverException {        this.driver = driver;        this.flags = (EEPRO100Flags) flags;        final PCIDeviceConfig config = device.getConfig();        final int irq = config.getInterruptLine();        final PCIBaseAddress[] addrs = config.getBaseAddresses();        if (addrs.length < 1) { throw new DriverException("Cannot find iobase: not base addresses"); }        if (!addrs[1].isIOSpace()) { throw new DriverException("Cannot find iobase: first address is not I/O"); }        // Get the start of the IO address space        iobase = addrs[1].getIOBase();        final int iolength = addrs[1].getSize();        log.debug("Found Lance IOBase: 0x" + NumberUtils.hex(iobase) + ", length: " + iolength);        ResourceManager rm;        try {            rm = (ResourceManager) InitialNaming.lookup(ResourceManager.NAME);        } catch (NameNotFoundException ex) {            throw new DriverException("Cannot find ResourceManager");        }        this.irq = rm.claimIRQ(owner, irq, this, true);        try {            io = claimPorts(rm, owner, iobase, iolength);        } catch (ResourceNotFreeException ex) {            this.irq.release();            throw ex;        }        // Initialize registers.        regs = new EEPRO100Registers(iobase, io);        // Initialize statistical counters.        stats = new EEPRO100Stats(rm,regs);        // Initialize RX/TX Buffers.        RxTxBuffer = new EEPRO100Buffer(rm);        int i, option = 0;        int[] eeprom = new int[0x100];        short sum = 0;        int j;        int read_cmd, ee_size;        sizeEeprom();        final byte[] hwAddrArr = new byte[ETH_ALEN];        for (j = 0, i = 0; i < eeSize; i++) {            int value = doEepromCmd(i) & 0xffff;            eeprom[i] = value;            sum += value;            if (i < 3) {                hwAddrArr[j++] = (byte) value;                hwAddrArr[j++] = (byte) (value >> 8);            }        }        if (sum != 0xBABA) {            log.debug(this.flags.getName() + ": Invalid EEPROM checksum " + Integer.toHexString(sum) + ", check settings before activating this device!");        }        this.hwAddress = new EthernetAddress(hwAddrArr, 0);        /*         * Reset the chip: stop Tx and Rx processes and clear counters. This         * takes less than 10usec and will easily finish before the next action.         */        regs.setReg32(SCBPort, PortReset);        eepromDelay();        log.debug("Found " + flags.getName() + " IRQ=" + irq + ", IOBase=0x" + NumberUtils.hex(iobase) + ", MAC Address=" + hwAddress);        // We have a cyclone PMC52 card, IQ80310 board        /*         * if(((Integer)deviceIdTable[deviceId+2]).intValue() == 0x360113c ||         * ((Integer)deviceIdTable[deviceId+2]).intValue() == 0x700113c) { //         * set the phy address; for 82559 this defaults to 1; phy[0] = 1; //         * read and print out the id registers sb.append("phy id:         * ").append(Integer.toHexString(mdioRead(phy[0], 2))); sb.append('         * ').append(Integer.toHexString(mdioRead(phy[0], 3)));         * System.out.println(sb.toString()); sb.setLength(0); // assuming we         * are i82555 } else {         */        /*         * OK, this is pure kernel bloat. I don't like it when other drivers         * waste non-pageable kernel space to emit similar messages, but I need         * them for bug reports.         */        String connectors[] = { " RJ45", " BNC", " AUI", " MII"};        if ((eeprom[3] & 0x03) != 0) log.info("Receiver lock-up bug exists -- enabling work-around.");        log.debug("Board assembly " + Integer.toHexString(eeprom[8]) + " " + Integer.toHexString(eeprom[9] >> 8) + "  " + (eeprom[9] & 0xff) + " connectors present: ");        for (i = 0; i < 4; i++) {            if ((eeprom[5] & (1 << i)) != 0) log.debug(connectors[i]);            log.debug("Primary interface chip " + (phys[(eeprom[6] >> 8) & 15]));            log.debug(" PHY #" + (eeprom[6] & 0x1f));            if ((eeprom[7] & 0x0700) != 0) {                log.debug("Secondary interface chip " + (phys[(eeprom[7] >> 8) & 7]));            }            if (((eeprom[6] >> 8) & 0x3f) == DP83840 || ((eeprom[6] >> 8) & 0x3f) == DP83840A) {                int mdi_reg23 = mdioRead(eeprom[6] & 0x1f, 23) | 0x0422;                if (congenb) mdi_reg23 |= 0x0100;                log.debug("DP83840 specific setup, setting register 23 to " + Integer.toHexString(mdi_reg23));                mdioWrite(eeprom[6] & 0x1f, 23, mdi_reg23);            }            if ((option >= 0) && (option & 0x330) != 0) {                log.debug("  Forcing " + ((option & 0x300) != 0 ? 100 : 10) + "Mbs " + ((option & 0x220) != 0 ? "full" : "half") + "-duplex operation.");                mdioWrite(eeprom[6] & 0x1f, 0, ((option & 0x300) != 0 ? 0x2000 : 0) | /* 100mbps? */                ((option & 0x220) != 0 ? 0x0100 : 0)); /* Full duplex? */            } else {                int mii_bmcrctrl = mdioRead(eeprom[6] & 0x1f, 0);                /* Reset out of a transceiver left in 10baseT-fixed mode. */                if ((mii_bmcrctrl & 0x3100) == 0) mdioWrite(eeprom[6] & 0x1f, 0, 0x8000);            }        }        byte[] data = new byte[32];        MemoryResource selfTest = rm.asMemoryResource(data);        /* Perform a system self-test. */        log.debug("self test: " + Integer.toHexString(Address.as32bit(selfTest.getAddress())));        regs.setReg32(SCBPort, Address.as32bit(selfTest.getAddress()) | PortSelfTest);        selfTest.setInt(2, 0); // rom signature        selfTest.setInt(0, -1); //status        int boguscnt = 16000; // Timeout for set-test.        do {            systemDelay(10);            int i0 = 100;            while (i0-- > 0)                ;        } while (selfTest.getInt(0) == -1 && --boguscnt >= 0);        StringBuffer sb = new StringBuffer();        if (boguscnt < 0) {            /* Test optimized out. */            log.debug("Self test failed, status" + Long.toHexString(selfTest.getLong(4)) + "Failure to initialize the i82557.");            log.debug("Verify that the card is a bus-master capable slot.");        } else {            int results = selfTest.getInt(0);            log.debug("General self-test:" + ((results & 0x1000) == 0 ? "failed" : "passed"));            log.debug("Serial sub-system self-test: " + ((results & 0x0020) == 0 ? "failed" : "passed"));            log.debug("Internal registers self-test:" + ((results & 0x0008) == 0 ? "failed" : "passed"));            log.debug(" ROM checksum self-test:" + ((results & 0x0004) == 0 ? "failed" : "passed") + "(" + Integer.toHexString(selfTest.getInt(2)) + ")");            log.debug(sb.toString());            sb.setLength(0);        }        /* reset adapter to default state */        regs.setReg32(SCBPort, PortReset);        systemDelay(100);        // 	pci_dev = pdev;        // 	chip_id = chip_idx;        // 	drv_flags = pci_id_tbl[chip_idx].drv_flags;        // 	acpi_pwr = acpi_idle_state;        /*         * full_duplex = option >= 0 && (option & 0x220) ? 1 : 0; if (card_idx >=         * 0) { if (full_duplex[card_idx] >= 0) full_duplex =         * full_duplex[card_idx]; } if (full_duplex) medialock = 1;         */        // 		phy[0] = eeprom[6];        // 		phy[1] = eeprom[7];        // 		rxBug = (eeprom[3] & 0x03) == 3;        // 		if (rxBug)        // 			System.out.println("Receiver lock-up workaround activated.");    } /*