예제 #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;
  }
예제 #2
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;
    }
  }