/** @see org.jnode.driver.video.vgahw.VgaIO#getDACData() */ public int getDACData() { ports.inPortByte(HDR_HIDDEN_DAC_REGISTER); ports.inPortByte(HDR_HIDDEN_DAC_REGISTER); ports.inPortByte(HDR_HIDDEN_DAC_REGISTER); ports.inPortByte(HDR_HIDDEN_DAC_REGISTER); return ports.inPortByte(HDR_HIDDEN_DAC_REGISTER); }
/** @see org.jnode.driver.video.vgahw.VgaIO#setDACData(int) */ public void setDACData(int data) { ports.inPortByte(HDR_HIDDEN_DAC_REGISTER); ports.inPortByte(HDR_HIDDEN_DAC_REGISTER); ports.inPortByte(HDR_HIDDEN_DAC_REGISTER); ports.inPortByte(HDR_HIDDEN_DAC_REGISTER); ports.outPortByte(HDR_HIDDEN_DAC_REGISTER, data); }
/** Sets certain bits of the command register on/off */ protected final void setCommandBits(int mask, boolean on) { int cmd = io.inPortWord(base + USBCMD); if (on) { cmd |= mask; } else { cmd &= ~mask; } io.outPortWord(base + USBCMD, cmd); }
/** Sets certain bits of the port1 status and control register on/off */ protected final void setPortSCBits(int port, int mask, boolean on) { int sc = io.inPortWord(base + USBPORTSC1 + (port << 1)); sc &= 0xFFF5; if (on) { sc |= mask; } else { sc &= ~mask; } io.outPortWord(base + USBPORTSC1 + (port << 1), sc); }
/** Not implemented by kvm's cirrus emulation! */ public boolean getDDC1Bit() { ports.outPortByte(SRX_SEQUENCER_INDEX, SR8_DDC2B); int data = ports.inPortByte(SRX_SEQUENCER_DATA) & 0xFF; if ((data & 0x40) == 0) { log.error("DDC2B/I2C configured in EEPROM mode!"); return false; } // Anything else to check? return (data & (1 << 7)) != 0; }
/** * Sets the control register. * * @param control The new value for the control register */ public final void setControlReg(int control) { ctrlBlock.outPortByte(ctrlBlockStart + W8_CONTROL_OFFSET, control); }
/** * Gets the alternative status of the IDE controller. Any pending IRQ is NOT reset. * * @return the alternative status of the IDE controller */ public final int getAltStatusReg() { return ctrlBlock.inPortByte(altStatusPort); }
/** * Sets the select register * * @param select */ public final void setSelectReg(int select) { cmdBlock.outPortByte(cmdBlockStart + RW8_SELECT_OFFSET, select); }
/** Sets the cylinder registers value (both LSB and MSB) */ protected final void setCylinderRegs(int cylinder) { final int lsb = cylinder & 0xFF; final int msb = (cylinder >> 8) & 0xFF; cmdBlock.outPortByte(cmdBlockStart + RW8_CYLINDER_LSB_OFFSET, lsb); cmdBlock.outPortByte(cmdBlockStart + RW8_CYLINDER_MSB_OFFSET, msb); }
/** * Sets the sector register * * @param sector */ protected final void setSectorReg(int sector) { cmdBlock.outPortByte(cmdBlockStart + RW8_SECTOR_OFFSET, sector); }
/** * Sets the contents of the LBA mid register * * @param value */ public final void setLbaMidReg(int value) { cmdBlock.outPortByte(cmdBlockStart + RW8_LBA_MID_OFFSET, value); }
/** * Gets a word from the data register * * @return a word from the data register */ public final int getDataReg() { return cmdBlock.inPortWord(cmdBlockStart + RW16_DATA_OFFSET); }
/** Stop this processor. */ public void release() { cmdBlock.release(); ctrlBlock.release(); }
/** Gets the frame number register */ protected final int getFrameNumber() { return io.inPortWord(base + USBFRNUM); }
/** Sets the interrupt enable register */ protected final void setInterruptEnable(int mask) { io.outPortWord(base + USBINTR, mask); }
/** * Gets the contents of the LBA high register * * @return the contents of the LBA high register */ public final int getLbaHighReg() { return cmdBlock.inPortByte(cmdBlockStart + RW8_LBA_HIGH_OFFSET); }
/** * Sets the contents of the LBA low register * * @param value */ public final void setLbaLowReg(int value) { cmdBlock.outPortByte(cmdBlockStart + RW8_LBA_LOW_OFFSET, value); }
/** * Writes a word to the data register * * @param dataWord */ public final void setDataReg(int dataWord) { cmdBlock.outPortWord(cmdBlockStart + RW16_DATA_OFFSET, dataWord); }
/** * Sets the contents of the LBA high register * * @param value */ public final void setLbaHighReg(int value) { cmdBlock.outPortByte(cmdBlockStart + RW8_LBA_HIGH_OFFSET, value); }
/** * Gets the contents of the error register * * @return the contents of the error register */ public final int getErrorReg() { return cmdBlock.inPortByte(cmdBlockStart + R8_ERROR_OFFSET); }
/** Gets the combined cylinder value out the the cylinder LSB and MSB registers. */ protected final int getCylinderRegs() { final int lsb = cmdBlock.inPortByte(cmdBlockStart + RW8_CYLINDER_LSB_OFFSET); final int msb = cmdBlock.inPortByte(cmdBlockStart + RW8_CYLINDER_MSB_OFFSET); return ((msb & 0xFF) << 8) | (lsb & 0xFF); }
/** * Sets the contents of the featureregister * * @param features */ public final void setFeatureReg(int features) { cmdBlock.outPortByte(cmdBlockStart + W8_FEATURE_OFFSET, features); }
/** * Gets the contents of the select register * * @return the contents of the select register */ public final int getSelectReg() { return cmdBlock.inPortByte(cmdBlockStart + RW8_SELECT_OFFSET); }
/** * Sets the sector count register * * @param sectorCount */ public final void setSectorCountReg(int sectorCount) { cmdBlock.outPortByte(cmdBlockStart + RW8_SECTOR_COUNT_OFFSET, sectorCount); }
/** * Gets the status of the IDE controller. Any pending IRQ is reset. * * @return the status of the IDE controller. Any pending IRQ is reset. */ public final int getStatusReg() { return cmdBlock.inPortByte(cmdBlockStart + R8_STATUS_OFFSET); }
/** * Gets the contents of the sector register * * @return the contents of the sector register */ public final int getSectorReg() { return cmdBlock.inPortByte(cmdBlockStart + RW8_SECTOR_OFFSET); }
/** * Sets the command register. This also activates the IDE controller so always set other registers * first. * * @param command */ public final void setCommandReg(int command) { cmdBlock.outPortByte(cmdBlockStart + W8_COMMAND_OFFSET, command); }
/** * Gets the contents of the LBA low register * * @return the contents of the LBA low register */ public final int getLbaLowReg() { return cmdBlock.inPortByte(cmdBlockStart + RW8_LBA_LOW_OFFSET); }
/** Create a new instance */ protected DefaultIDEIO(Device device, boolean primary) throws IllegalArgumentException, DriverException, ResourceNotFreeException { int cmdBlockStart = (primary ? IDE0_START_PORT : IDE1_START_PORT); int ctrlBlockStart = cmdBlockStart + HIGH_OFFSET; int cmdBlockSize = IDE_NR_PORTS; int ctrlBlockSize = IDE_NR_HIGH_PORTS; int altStatusPort = ctrlBlockStart + R8_ALTSTATUS_OFFSET; int irq = (primary ? IDE0_IRQ : IDE1_IRQ); boolean nativeMode = false; // Detect PCI IDE Controller, look for enhanced mode if (device instanceof PCIDevice) { final PCIDevice pciDev = (PCIDevice) device; final PCIDeviceConfig pciCfg = pciDev.getConfig(); final int pIntf = pciCfg.getMinorClass(); final int progMask = 0x02 | 0x08; final int enhModeMask = 0x01 | 0x04; if ((pIntf & progMask) == progMask) { // Mode is programmable, set enhanced mode // pciCfg.setMinorClass(pIntf | enhModeMask); } if ((pciCfg.getMinorClass() & enhModeMask) == enhModeMask) { // Use enhanced mode final PCIBaseAddress[] baseAddrs = pciCfg.asHeaderType0().getBaseAddresses(); final int idx = (primary ? 0 : 2); cmdBlockStart = baseAddrs[idx].getIOBase(); cmdBlockSize = 8; ctrlBlockStart = baseAddrs[idx + 1].getIOBase(); ctrlBlockSize = 4; altStatusPort = ctrlBlockStart + 0x02; irq = pciCfg.asHeaderType0().getInterruptLine(); nativeMode = true; } } log.info( "Using PCI IDE " + (nativeMode ? "Native" : "Compatibility") + " mode [irq=" + irq + "]"); // Now claim the resources IOResource cmdBlock = null; IOResource ctrlBlock = null; final ResourceManager rm; try { rm = InitialNaming.lookup(ResourceManager.NAME); cmdBlock = claimPorts(rm, device, cmdBlockStart, cmdBlockSize); ctrlBlock = claimPorts(rm, device, ctrlBlockStart, ctrlBlockSize); } catch (NameNotFoundException ex) { throw new ResourceNotFreeException("Cannot find ResourceManager", ex); } catch (ResourceNotFreeException ex) { if (cmdBlock != null) { cmdBlock.release(); } if (ctrlBlock != null) { ctrlBlock.release(); } throw ex; } this.irq = irq; this.cmdBlockStart = cmdBlockStart; this.ctrlBlockStart = ctrlBlockStart; this.cmdBlock = cmdBlock; this.ctrlBlock = ctrlBlock; this.altStatusPort = altStatusPort; }
/** * Gets the contents of the LBA mid register * * @return the contents of the LBA mid register */ public final int getLbaMidReg() { return cmdBlock.inPortByte(cmdBlockStart + RW8_LBA_MID_OFFSET); }