Package org.vmmagic.unboxed

Examples of org.vmmagic.unboxed.Address


    }


    public static void main(String[] args) {
        final Address a1 = Address.fromIntZeroExtend(0x1234);
        final Address a2 = a1.add(5);

        final int i1 = a1.toInt();
        final int i2 = a2.toInt();

        System.out.println("a1 LE a2 " + a1.LE(a2) + " " + (i1 <= i2));
        System.out.println("a1 LT a2 " + a1.LT(a2) + " " + (i1 < i2));
        System.out.println("a1 EQ a2 " + a1.EQ(a2) + " " + (i1 == i2));
        System.out.println("a1 NE a2 " + a1.NE(a2) + " " + (i1 != i2));
        System.out.println("a1 GT a2 " + a1.GT(a2) + " " + (i1 > i2));
        System.out.println("a1 GE a2 " + a1.GE(a2) + " " + (i1 >= i2));

        System.out.println("a2 LE a1 " + a2.LE(a1) + " " + (i2 <= i1));
        System.out.println("a2 LT a1 " + a2.LT(a1) + " " + (i2 < i1));
        System.out.println("a2 EQ a1 " + a2.EQ(a1) + " " + (i2 == i1));
        System.out.println("a2 NE a1 " + a2.NE(a1) + " " + (i2 != i1));
        System.out.println("a2 GT a1 " + a2.GT(a1) + " " + (i2 > i1));
        System.out.println("a2 GE a1 " + a2.GE(a1) + " " + (i2 >= i1));
    }
View Full Code Here


     * @return True if the color was changed, false if the current color of the
     *         object was not equal to oldColor.
     */
    public boolean atomicChangeObjectColor(Object dst, int oldColor,
                                           int newColor) {
        final Address addr = ObjectReference.fromObject(dst).toAddress().add(
            flagsOffset);
        for (;;) {
            Word oldValue = addr.prepareWord();
            if (oldValue
                .and(Word.fromIntZeroExtend(ObjectFlags.GC_COLOUR_MASK))
                .NE(Word.fromIntZeroExtend(oldColor))) {
                return false;
            }
            Word newValue = oldValue.and(
                Word.fromIntZeroExtend(ObjectFlags.GC_COLOUR_MASK).not())
                .or(Word.fromIntZeroExtend(newColor));
            if (addr.attempt(oldValue, newValue)) {
                return true;
            }
        }
    }
View Full Code Here

     * Mark the given object as finalized.
     *
     * @param dst
     */
    public final void setFinalized(Object dst) {
        final Address addr = ObjectReference.fromObject(dst).toAddress().add(
            flagsOffset);
        int oldValue;
        int newValue;
        do {
            oldValue = addr.prepareInt();
            if ((oldValue & ObjectFlags.STATUS_FINALIZED) != 0) {
                return;
            }
            newValue = oldValue | ObjectFlags.STATUS_FINALIZED;
        } while (!addr.attempt(oldValue, newValue));
        // } while (!Unsafe.atomicCompareAndSwap(addr, oldValue, newValue));
    }
View Full Code Here

            this.maxHeight = getReg32(SVGA_REG_MAX_HEIGHT);
            final int bitsPerPixel = getReg32(SVGA_REG_BITS_PER_PIXEL);
            this.bytesPerLine = getReg32(SVGA_REG_BYTES_PER_LINE);

            // Allocate framebuffer memory
            final Address videoRamAddr;
            if (device.getConfig().getDeviceID() == PCI_DEVICE_ID_VMWARE_SVGA2) {
                videoRamAddr =
                    Address.fromLong(device.getConfig().asHeaderType0().getBaseAddresses()[1].getMemoryBase());
            } else {
                videoRamAddr = Address.fromIntZeroExtend(SVGA_REG_FB_START);
View Full Code Here

     * @return
     */
    private final MemoryResource initFifo(PCIDevice device, ResourceManager rm)
        throws ResourceNotFreeException {
        final int size = getReg32(SVGA_REG_MEM_SIZE);
        final Address address;

        if (device.getConfig().getDeviceID() == PCI_DEVICE_ID_VMWARE_SVGA2) {
            address = Address.fromLong(device.getConfig().asHeaderType0().getBaseAddresses()[2].getMemoryBase());
        } else {
            final int physBase = getReg32(SVGA_REG_MEM_START);
            address = Address.fromIntZeroExtend(physBase);
        }

        log.debug("Found FIFO at 0x" + NumberUtils.hex(address.toInt()) + ", size 0x" + NumberUtils.hex(size));

        final MemoryResource res = rm.claimMemoryResource(device, address, size, ResourceManager.MEMMODE_NORMAL);
        final int fifoMin = SVGA_FIFO_NUM_REGS * 4;
        res.setInt(SVGA_FIFO_MIN * 4, fifoMin);
        res.setInt(SVGA_FIFO_MAX * 4, size);
View Full Code Here

        final int size = TOTAL_RX_BUF_SIZE;
        this.data = new byte[size];
        this.nrFrames = nrFrames;
        this.mem = rm.asMemoryResource(data);

        final Address memAddr = mem.getAddress();
        int offset = 0;

        this.firstUPDOffset = offset;
        this.firstUPDAddress = memAddr.add(firstUPDOffset);
    }
View Full Code Here

     * @see org.jnode.driver.Driver#startDevice()
     */
    protected void startDevice() throws DriverException {
        ModeInfoBlock modeInfoBlock = null;
        try {
            Address vbeControlInfo = UnsafeX86.getVbeControlInfos();
            VbeInfoBlock vbeInfoBlock = new VbeInfoBlock(vbeControlInfo);
            if (vbeInfoBlock.isEmpty()) {
                throw new DriverException(
                        "can't start device (vbeInfoBlock is empty): grub haven't switched to graphic mode");
            }

            Address vbeModeInfo = UnsafeX86.getVbeModeInfos();
            modeInfoBlock = new ModeInfoBlock(vbeModeInfo);
            if (modeInfoBlock.isEmpty()) {
                throw new DriverException(
                        "can't start device (modeInfoBlock is empty): grub haven't switched to graphic mode");
            }
View Full Code Here

        // Create a large enough buffer
        final int size = (DPD_SIZE + FRAME_SIZE) + 16 /* alignment */;
        this.data = new byte[size];
        this.mem = rm.asMemoryResource(data);

        final Address memAddr = mem.getAddress();
        // int addr = Address.as32bit(memAddr);
        int offset = 0;

        this.firstDPDOffset = offset;
        this.firstDPDAddress = memAddr.add(firstDPDOffset);
    }
View Full Code Here

        // Create a large enough buffer
        final int size = (DPD_SIZE + FRAME_SIZE) + 16 /* alignment */;
        this.data = new byte[size];
        this.mem = rm.asMemoryResource(data);

        final Address memAddr = mem.getAddress();
        int addr = memAddr.toInt();
        int offset = 0;
        // Align on 16-byte boundary
        while ((addr & 15) != 0) {
            addr++;
            offset++;
        }

        this.firstDPDOffset = offset;
        this.firstDPDAddress = memAddr.add(firstDPDOffset);
        this.firstFrameOffset = firstDPDOffset + DPD_SIZE;
        this.firstFrameAddress = memAddr.add(firstFrameOffset);
    }
View Full Code Here

        final int size = (nrFrames * (UPD_SIZE + FRAME_SIZE)) + 16/* alignment */;
        this.data = new byte[size];
        this.nrFrames = nrFrames;
        this.mem = rm.asMemoryResource(data);

        final Address memAddr = mem.getAddress();
        int addr = memAddr.toInt();
        int offset = 0;
        // Align on 16-byte boundary
        while ((addr & 15) != 0) {
            addr++;
            offset++;
        }

        this.firstUPDOffset = offset;
        this.firstUPDAddress = memAddr.add(firstUPDOffset);
        this.firstFrameOffset = firstUPDOffset + (nrFrames * UPD_SIZE);
        this.firstFrameAddress = memAddr.add(firstFrameOffset);
    }
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.