Beispiel #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;
  }
 /**
  * Demand zero mmaps an area of virtual memory.
  *
  * @param start the address of the start of the area to be mapped
  * @param size the size, in bytes, of the area to be mapped
  * @return 0 if successful, otherwise the system errno
  */
 public final int dzmmap(Address start, int size) {
   Address result = org.jikesrvm.runtime.Memory.dzmmap(start, Extent.fromIntZeroExtend(size));
   if (result.EQ(start)) return 0;
   if (result.GT(Address.fromIntZeroExtend(127))) {
     VM.sysWrite("demand zero mmap with MAP_FIXED on ", start);
     VM.sysWriteln(" returned some other address", result);
     VM.sysFail("mmap with MAP_FIXED has unexpected behavior");
   }
   return result.toInt();
 }
Beispiel #3
0
  /**
   * Find the ACPI root descriptor table.
   *
   * @param rm
   * @return
   * @throws ResourceNotFreeException
   */
  private static final AcpiRSDPInfo findAcpiRSDTPTR(final ResourceManager rm)
      throws ResourceNotFreeException {
    final byte[] match = {'R', 'S', 'D', ' ', 'P', 'T', 'R', ' '};

    final MemoryScanner scanner =
        (MemoryScanner)
            AccessController.doPrivileged(
                new PrivilegedAction() {
                  public Object run() {
                    return rm.getMemoryScanner();
                  }
                });
    final Address tablePtr =
        scanner.findInt8Array(
            Address.fromIntZeroExtend(0xe0000), 0x1ffff, match, 0, match.length, 1);
    if (tablePtr != null) {
      final int version = getRSDTVersion(rm, tablePtr);
      return new AcpiRSDPInfo(tablePtr, version);
    } else {
      // Not an ACPI system
      return null;
    }
  }
Beispiel #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);
  }