Example #1
0
 /**
  * Test whether a memory range is set to a given integer value
  *
  * @param start The address to start checking at
  * @param bytes The size of the region to check, in bytes
  * @param verbose If true, produce verbose output
  * @param value The value to which the memory should be set
  */
 private static boolean isSet(Address start, int bytes, boolean verbose, int value)
     /* Inlining this loop into the uninterruptible code can
      *  cause/encourage the GCP into moving a get_obj_tib into the
      * interruptible region where the tib is being installed via an
      * int_store
      */
     throws NoInlinePragma {
   if (Assert.VERIFY_ASSERTIONS) assertAligned(bytes);
   for (int i = 0; i < bytes; i += BYTES_IN_INT)
     if (start.loadInt(Offset.fromInt(i)) != value) {
       if (verbose) {
         Log.prependThreadId();
         Log.write("Memory range does not contain only value ");
         Log.writeln(value);
         Log.write("Non-zero range: ");
         Log.write(start);
         Log.write(" .. ");
         Log.writeln(start.add(bytes));
         Log.write("First bad value at ");
         Log.writeln(start.add(i));
         dumpMemory(start, 0, bytes);
       }
       return false;
     }
   return true;
 }
Example #2
0
 /**
  * Set a region of memory
  *
  * @param start The start of the region to be zeroed (must be 4-byte aligned)
  * @param bytes The number of bytes to be zeroed (must be 4-byte aligned)
  * @param value The value to which the integers in the region should be set
  */
 public static void set(Address start, int bytes, int value) throws InlinePragma {
   if (Assert.VERIFY_ASSERTIONS) {
     assertAligned(start);
     assertAligned(bytes);
   }
   Address end = start.add(bytes);
   for (Address addr = start; addr.LT(end); addr = addr.add(BYTES_IN_INT)) addr.store(value);
 }
Example #3
0
 /**
  * Zero a small region of memory
  *
  * @param start The start of the region to be zeroed (must be 4-byte aligned)
  * @param bytes The number of bytes to be zeroed (must be 4-byte aligned)
  */
 public static void zeroSmall(Address start, Extent bytes) throws InlinePragma {
   if (Assert.VERIFY_ASSERTIONS) {
     assertAligned(start);
     assertAligned(bytes);
   }
   Address end = start.add(bytes);
   for (Address addr = start; addr.LT(end); addr = addr.add(BYTES_IN_INT)) addr.store(0);
 }
Example #4
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 #5
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);
  }