Example #1
0
  /**
   * Look for the ROM in the ISA region.
   *
   * @param rm
   * @return The claimed ROM region, or null if not found.
   */
  private final MemoryResource findRom(final ResourceOwner owner, final ResourceManager rm)
      throws ResourceNotFreeException {
    final MemoryScanner scanner =
        AccessController.doPrivileged(
            new PrivilegedAction<MemoryScanner>() {

              public MemoryScanner run() {
                return rm.getMemoryScanner();
              }
            });

    final Address start = Address.fromIntZeroExtend(0xC0000);
    final Address end = Address.fromIntZeroExtend(0xF0000);
    final int size = end.toWord().sub(start.toWord()).toInt();
    final int stepSize = 0x1000;
    int offset = 0;
    while (offset < size) {
      final Address romAddr;
      // Search for BIOS expansion
      romAddr =
          scanner.findInt8Array(
              start.add(offset),
              size - offset,
              BIOS_ROM_SIGNATURE,
              0,
              BIOS_ROM_SIGNATURE.length,
              stepSize);
      if (romAddr == null) {
        return null;
      } else {
        offset = romAddr.toWord().sub(start.toWord()).toInt() + stepSize;
      }
      // Search for ATI signature
      final Address atiSigAddr;
      atiSigAddr =
          scanner.findInt8Array(romAddr, 128, ATI_ROM_SIGNATURE, 0, ATI_ROM_SIGNATURE.length, 1);
      if (atiSigAddr == null) {
        continue;
      }

      // We found it
      // Claim a small region, so we can read the size.
      MemoryResource mem;
      mem = rm.claimMemoryResource(owner, romAddr, 4, ResourceManager.MEMMODE_NORMAL);
      final int blocks = mem.getByte(2) & 0xFF;
      final int romSize = blocks * 512;
      mem.release();

      log.info(
          "Found ATI ROM at 0x"
              + NumberUtils.hex(romAddr.toInt())
              + " size="
              + NumberUtils.toBinaryByte(romSize));
      return rm.claimMemoryResource(owner, romAddr, romSize, ResourceManager.MEMMODE_NORMAL);
    }

    return null;
  }
Example #2
0
  public EEPRO100TxFD(ResourceManager rm) {
    // Create a large enough buffer
    final int size = (TxFDSize + DataBufferSize) + 16 /* alignment */;
    this.data = new byte[size];
    this.mem = rm.asMemoryResource(data);

    final Address memAddr = mem.getAddress();

    this.firstDPDOffset = 0;
    this.firstDPDAddress = memAddr.add(firstDPDOffset);
  }
Example #3
0
 private static int getRSDTVersion(ResourceManager rm, Address start) {
   final MemoryResource res;
   try {
     res = rm.claimMemoryResource(ResourceOwner.SYSTEM, start, 20, ResourceManager.MEMMODE_NORMAL);
   } catch (ResourceNotFreeException e) {
     // Cannot claim memory
     return 1;
   }
   try {
     return res.getByte(15);
   } finally {
     res.release();
   }
 }
Example #4
0
  /**
   * @param driver
   * @param architecture
   * @param model
   * @param device
   */
  public RadeonCore(RadeonDriver driver, int architecture, String model, PCIDevice device)
      throws ResourceNotFreeException, DriverException {
    this.driver = driver;
    this.fbinfo = new FBInfo(architecture);

    final PCIHeaderType0 pciCfg = device.getConfig().asHeaderType0();
    final PCIBaseAddress ioAddr = pciCfg.getBaseAddresses()[2];
    final PCIBaseAddress fbAddr = pciCfg.getBaseAddresses()[0];
    final PCIRomAddress romAddr = pciCfg.getRomAddress();
    log.info("Found ATI " + model + ", chipset 0x" + NumberUtils.hex(pciCfg.getRevision()));
    try {
      final ResourceManager rm = InitialNaming.lookup(ResourceManager.NAME);
      final int ioBase = (int) ioAddr.getMemoryBase();
      final int ioSize = ioAddr.getSize();
      final int fbBase = (int) fbAddr.getMemoryBase() /* & 0xFF800000 */;

      // Map Memory Mapped IO
      this.mmio =
          rm.claimMemoryResource(
              device, Address.fromIntZeroExtend(ioBase), ioSize, ResourceManager.MEMMODE_NORMAL);
      this.vgaIO = new RadeonVgaIO(mmio);
      final int memSize = readMemorySize();
      log.info("Memory size " + NumberUtils.toBinaryByte(memSize));
      this.accel = new RadeonAcceleration(vgaIO);

      // Map Device RAM
      this.deviceRam =
          rm.claimMemoryResource(
              device, Address.fromIntZeroExtend(fbBase), memSize, ResourceManager.MEMMODE_NORMAL);
      vgaIO.setVideoRam(deviceRam);

      // Find ROM
      MemoryResource rom = null;
      if (romAddr != null) {
        romAddr.setEnabled(true);
        if (romAddr.isEnabled()) {
          rom =
              rm.claimMemoryResource(
                  device,
                  Address.fromIntZeroExtend(romAddr.getRomBase()),
                  romAddr.getSize(),
                  ResourceManager.MEMMODE_NORMAL);
          if (!verifyBiosSignature(rom)) {
            log.info("Signature mismatch");
            rom.release();
            rom = null;
          }
        } else {
          log.debug("Failed to enabled expansion ROM");
        }
      }
      if (rom == null) {
        // Use the ISA regions rom instead
        rom = findRom(device, rm);
      }
      this.rom = rom;

      log.debug(
          "Found ATI "
              + model
              + ", FB at 0x"
              + NumberUtils.hex(fbBase)
              + "s0x"
              + NumberUtils.hex(memSize)
              + ", MMIO at 0x"
              + NumberUtils.hex(ioBase)
              + ", ROM "
              + pciCfg.getRomAddress());

      fbinfo.readMonitorInfo(vgaIO);
      if (this.rom != null) {
        log.info("ROM[0-3] 0x" + NumberUtils.hex(rom.getInt(0)));
        // Read monitor information
        fbinfo.readFPIInfo(rom);
      }

    } catch (NameNotFoundException ex) {
      throw new ResourceNotFreeException(ex);
    }

    // Read the current state of the device
    this.oldVgaState = new RadeonVgaState(architecture, fbinfo.hasCRTC2, vgaIO);
    this.currentState = new RadeonVgaState(architecture, fbinfo.hasCRTC2, vgaIO);

    // Claim the first 128K for VGA only
    deviceRam.claimChildResource(0, 128 * 1024, false);

    // Allocate the hardware cursor
    this.hwCursor = new RadeonHardwareCursor(this, vgaIO);
  }