Ejemplo n.º 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;
  }
Ejemplo n.º 2
0
 /**
  * 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();
 }