Exemplo n.º 1
0
 /** @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);
 }
Exemplo n.º 2
0
 /** @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);
 }
Exemplo n.º 3
0
 /** 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);
 }
Exemplo n.º 4
0
 /** 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);
 }
Exemplo n.º 5
0
  /** 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;
  }
Exemplo n.º 6
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);
 }
Exemplo n.º 7
0
 /**
  * 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);
 }
Exemplo n.º 8
0
 /**
  * Sets the select register
  *
  * @param select
  */
 public final void setSelectReg(int select) {
   cmdBlock.outPortByte(cmdBlockStart + RW8_SELECT_OFFSET, select);
 }
Exemplo n.º 9
0
 /** 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);
 }
Exemplo n.º 10
0
 /**
  * Sets the sector register
  *
  * @param sector
  */
 protected final void setSectorReg(int sector) {
   cmdBlock.outPortByte(cmdBlockStart + RW8_SECTOR_OFFSET, sector);
 }
Exemplo n.º 11
0
 /**
  * Sets the contents of the LBA mid register
  *
  * @param value
  */
 public final void setLbaMidReg(int value) {
   cmdBlock.outPortByte(cmdBlockStart + RW8_LBA_MID_OFFSET, value);
 }
Exemplo n.º 12
0
 /**
  * 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);
 }
Exemplo n.º 13
0
 /** Stop this processor. */
 public void release() {
   cmdBlock.release();
   ctrlBlock.release();
 }
Exemplo n.º 14
0
 /** Gets the frame number register */
 protected final int getFrameNumber() {
   return io.inPortWord(base + USBFRNUM);
 }
Exemplo n.º 15
0
 /** Sets the interrupt enable register */
 protected final void setInterruptEnable(int mask) {
   io.outPortWord(base + USBINTR, mask);
 }
Exemplo n.º 16
0
 /**
  * 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);
 }
Exemplo n.º 17
0
 /**
  * Sets the contents of the LBA low register
  *
  * @param value
  */
 public final void setLbaLowReg(int value) {
   cmdBlock.outPortByte(cmdBlockStart + RW8_LBA_LOW_OFFSET, value);
 }
Exemplo n.º 18
0
 /**
  * Writes a word to the data register
  *
  * @param dataWord
  */
 public final void setDataReg(int dataWord) {
   cmdBlock.outPortWord(cmdBlockStart + RW16_DATA_OFFSET, dataWord);
 }
Exemplo n.º 19
0
 /**
  * Sets the contents of the LBA high register
  *
  * @param value
  */
 public final void setLbaHighReg(int value) {
   cmdBlock.outPortByte(cmdBlockStart + RW8_LBA_HIGH_OFFSET, value);
 }
Exemplo n.º 20
0
 /**
  * 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);
 }
Exemplo n.º 21
0
 /** 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);
 }
Exemplo n.º 22
0
 /**
  * Sets the contents of the featureregister
  *
  * @param features
  */
 public final void setFeatureReg(int features) {
   cmdBlock.outPortByte(cmdBlockStart + W8_FEATURE_OFFSET, features);
 }
Exemplo n.º 23
0
 /**
  * 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);
 }
Exemplo n.º 24
0
 /**
  * Sets the sector count register
  *
  * @param sectorCount
  */
 public final void setSectorCountReg(int sectorCount) {
   cmdBlock.outPortByte(cmdBlockStart + RW8_SECTOR_COUNT_OFFSET, sectorCount);
 }
Exemplo n.º 25
0
 /**
  * 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);
 }
Exemplo n.º 26
0
 /**
  * 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);
 }
Exemplo n.º 27
0
 /**
  * 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);
 }
Exemplo n.º 28
0
 /**
  * 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);
 }
Exemplo n.º 29
0
  /** 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;
  }
Exemplo n.º 30
0
 /**
  * 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);
 }