* @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;
}