Package org.vmmagic.unboxed

Examples of org.vmmagic.unboxed.Address


    }

    public static ByteBuffer getBiosMemory() throws NameNotFoundException, ResourceNotFreeException {
        // steps 1 & 2 : allocate new buffer and copy the bios image to it
        manager = InitialNaming.lookup(ResourceManager.NAME);
        Address start = Address.fromInt(0xC0000);
        // int size = 0x8000; // 32 Kb
        int size = 0x10000; // 64 Kb
        int mode = ResourceManager.MEMMODE_NORMAL;
        MemoryResource resource = manager.claimMemoryResource(owner, start, size, mode);
        ByteBuffer buffer = null;
View Full Code Here


        final PCIDeviceConfig cfg = pciDev.getConfig();
        if ((cfg.getBaseClass() & 0xFFFFFF) != DISPLAY_CONTROLLER_PCI_DEVICE_CLASS)
            return null;

        //checking the VESA mode set up by GRUB
        Address vbeControlInfo = UnsafeX86.getVbeControlInfos();
        VbeInfoBlock vbeInfoBlock = new VbeInfoBlock(vbeControlInfo);
        if (vbeInfoBlock.isEmpty())
            return null;

        Address vbeModeInfo = UnsafeX86.getVbeModeInfos();
        ModeInfoBlock modeInfoBlock = new ModeInfoBlock(vbeModeInfo);
        if (modeInfoBlock.isEmpty())
            return null;

        //OK
View Full Code Here

        return address.isZero() || VesaUtils.isEmpty(address, 8);
    }

    public List<Short> getVideoModeList() {
        List<Short> modes = new ArrayList<Short>();
        Address addr = address.add(14).loadAddress();
        Unsafe.debug("\nvideo mode list at address " + Integer.toHexString(addr.toInt()) + "\n");
        if (!addr.isZero()) {
            short mode = addr.loadShort();
            int counter = 0;
            while ((mode != 0xFFFF) && (counter++ < 100)) {
                modes.add(mode);

                addr = addr.add(2);
                mode = addr.loadShort();
            }
        }

        return modes;
    }
View Full Code Here

        for (short mode : getVideoModeList()) {
            sb.append(Integer.toHexString(mode)).append(", ");
        }

        Unsafe.debug("\nsearching video mode 0x140 (800x600x32)...");
        Address addr = address.add(0); // clone
        int offset = -1;
        for (int i = 0; i < 4096; i++) {
            byte b1 = addr.loadByte();
            addr = addr.add(1);

            byte b2 = addr.loadByte();
            addr = addr.add(1);

            if ((b1 == 0x01) && (b2 == 0x40)) {
                offset = i * 2;
                break;
            }
View Full Code Here

    public VESACore(VESADriver driver, VbeInfoBlock vbeInfoBlock, ModeInfoBlock modeInfoBlock,
            PCIDevice device) throws ResourceNotFreeException, DriverException {
        super(modeInfoBlock.getXResolution(), modeInfoBlock.getYResolution());

        this.driver = driver;
        Address address = Address.fromIntZeroExtend(modeInfoBlock.getRamBase());

        try {
            final ResourceManager rm = InitialNaming.lookup(ResourceManager.NAME);
            this.capabilities = vbeInfoBlock.getCapabilities();
            this.maxWidth = modeInfoBlock.getXResolution();
View Full Code Here

                    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;
View Full Code Here

     * @param sf
     * @return The address of the static field data
     */
    private static final Address getStaticFieldAddress(VmStaticField sf) {
        final VmProcessor proc = VmProcessor.current();
        final Address tablePtr;
        final int offset;
        if (sf.isShared()) {
            offset = sf.getSharedStaticsIndex() << 2;
            tablePtr = VmMagic.getArrayData(proc.getSharedStaticsTable());
        } else {
            offset = sf.getIsolatedStaticsIndex() << 2;
            tablePtr = VmMagic.getArrayData(proc.getIsolatedStaticsTable());
        }
        return tablePtr.add(offset);
    }
View Full Code Here

     *
     * @param f
     * @return The address of the instance field data in the given object.
     */
    private static final Address getInstanceFieldAddress(Object object, VmInstanceField f) {
        final Address objectPtr = ObjectReference.fromObject(object).toAddress();
        return objectPtr.add(f.getOffset());
    }
View Full Code Here

    @Inline
    private final void verifyObject(Object object, VmNormalClass<?> vmClass) {
        final int[] referenceOffsets = vmClass.getReferenceOffsets();
        final int cnt = referenceOffsets.length;
        final int size = vmClass.getObjectSize();
        final Address ptr = ObjectReference.fromObject(object).toAddress();
        for (int i = 0; i < cnt; i++) {
            int offset = referenceOffsets[i];
            if ((offset < 0) || (offset >= size)) {
                Unsafe.debug("reference offset out of range!");
                Unsafe.debug(vmClass.getName());
                helper.die("Class internal error");
            } else {
                final Object child = ptr.loadObjectReference(Offset.fromIntZeroExtend(offset)).toObject();
                if (child != null) {
                    verifyChild(child, object, "object child");
                }
            }
        }
View Full Code Here

        final int offset = addr.toWord().sub(start.toWord()).toInt();
        int bit = offset / ObjectLayout.OBJECT_ALIGN;
        final Offset idx = Offset.fromIntZeroExtend(bit / 8);
        final int mask = 1 << (bit & 7);
        final Address bitmapPtr = this.allocationBitmapPtr;
        final int value = bitmapPtr.loadByte(idx);
        return ((value & mask) == mask);
    }
View Full Code Here

TOP

Related Classes of org.vmmagic.unboxed.Address

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.