Examples of Word


Examples of org.vmmagic.unboxed.Word

                break;
            default:
                return false;
        }

        final Word alignedStart = pageAlign(region, start.toWord(), false);
        if (!alignedStart.EQ(start.toWord())) {
            // Make adjustments on size & physAddr
            final Word diff = start.sub(alignedStart).toWord();
            start = alignedStart.toAddress();
            size = size.add(diff);
        }
        size = pageAlign(region, size.toWord(), true).toExtent();
        final Extent pageSize = getPageSize(region);
View Full Code Here

Examples of org.vmmagic.unboxed.Word

     *
     * @param vmAddress
     */
    private final void mapPage(Address vmAddress, Address physAddr, Extent pageSize, boolean debug) {
        // Setup the pdir structures
        final Word pdirIdx = vmAddress.toWord().rshl(22);
        final Address pdirEntryPtr = UnsafeX86.getCR3().add(pdirIdx.lsh(2));
        Word entry = pdirEntryPtr.loadWord();
        if (entry.and(Word.fromIntZeroExtend(PF_PRESENT)).isZero()) {
            final Word pagePtr;
            if (physAddr.isMax()) {
                // Get a free page
                pagePtr = pageCursor;
                pageCursor = pageCursor.add(pageSize);
            } else {
                pagePtr = physAddr.toWord();
            }

            // There is currently no present page, so do the mapping
            entry = pagePtr.or(Word.fromIntZeroExtend(PF_DEFAULT));
            pdirEntryPtr.store(entry);

            if (debug) {
                Unsafe.debug("mapPage ");
                Unsafe.debug(entry);
View Full Code Here

Examples of org.vmmagic.unboxed.Word

        dumpMultibootMMap();
        pageCursor = getFirstAvailableHeapPage();

        if (emptyMMap) {
            // Remove all page mappings between AVAILABLE_START-END
            final Word start = Word.fromIntZeroExtend(AVAILABLE_START);
            final Word end = Word.fromIntZeroExtend(AVAILABLE_END);
            final Extent pageSize = Extent.fromIntZeroExtend(AVAILABLE_PAGE_SIZE);
            removeVirtualMMap(start, end, pageSize);
        }
    }
View Full Code Here

Examples of org.vmmagic.unboxed.Word

     */
    private final void removeVirtualMMap(Word start, Word end, Extent pageSize) {
        final Address pdir = UnsafeX86.getCR3();

        for (Word ptr = start; ptr.LT(end); ptr = ptr.add(pageSize)) {
            final Word pdirIdx = ptr.rshl(22);
            pdir.add(pdirIdx.lsh(2)).store(Word.zero());
        }
    }
View Full Code Here

Examples of org.vmmagic.unboxed.Word

            data[index++] = regs[3];
        }

        // Load extended functions (0x80000000)
        String brand = "?";
        final Word extendedBase = Word.fromIntZeroExtend(0x80000000);
        UnsafeX86.getCPUID(extendedBase, regs);
        Word max = Word.fromIntZeroExtend(regs[0]);
        if (max.GE(extendedBase.add(4))) {
            // Load brand 0x80000002..0x80000004
            final StringBuilder buf = new StringBuilder();
            for (int i = 0; i < 3; i++) {
                UnsafeX86.getCPUID(extendedBase.add(2 + i), regs);
                intToString(buf, regs[0]);
View Full Code Here

Examples of org.vmmagic.unboxed.Word

          getCurrentProcessor().getArchitecture().getStackReader()
                    .debugStackTrace();
        }

        final int align = ObjectLayout.OBJECT_ALIGN;
        final Word headerSize = Word.fromIntZeroExtend(this.headerSize);
        final Offset tibOffset = Offset.fromIntSignExtend(this.tibOffset);
        final Offset flagsOffset = Offset.fromIntSignExtend(this.flagsOffset);
        int allocator = BasePlan.ALLOC_DEFAULT;

        final int refSize = VmUtils.getVm().getArch().getReferenceSize();
View Full Code Here

Examples of org.vmmagic.unboxed.Word

        }

        enter();
        try {
            // Calculate the number of blocks needed
            final Word reqBlockCount = blockAlign(blockSize.toWord(), true).rshl(BLOCK_SIZE_SHIFT);
            // Find a large enough series of blocks
            final Word nr = findFreeBlocks(reqBlockCount);
            if (nr.isMax()) {
                Unsafe.debug("ret null.");
                Unsafe.debug(blockSize.toInt());
                // Unsafe.debug("allocated blocks");
                // Unsafe.debug(allocatedBlocks);
                // Unsafe.debug("total blocks"); Unsafe.debug(blockCount);
                VmProcessor.current().getArchitecture().getStackReader().debugStackTrace();
                // Unsafe.die("allocateBlock");
                return null;
            }
            // Mark all blocks as in use
            for (Word i = Word.zero(); i.LT(reqBlockCount); i = i.add(1)) {
                setInUse(nr.add(i), true);
            }
            // Return the address of block "nr".
            allocatedBlocks = allocatedBlocks.add(reqBlockCount);
            nextBlockNr = nr.add(reqBlockCount);
            return startPtr.add(nr.lsh(BLOCK_SIZE_SHIFT));
        } finally {
            exit();
        }
    }
View Full Code Here

Examples of org.vmmagic.unboxed.Word

     */
    static final void freeBlock(Address ptr, Extent blockSize) {
        enter();
        try {
            // Calculate the block number
            final Word nr = ptr.toWord().sub(startPtr.toWord()).rshl(BLOCK_SIZE_SHIFT);
            // Calculate the number of blocks
            final Word reqBlockCount = blockAlign(blockSize.toWord(), true).rshl(BLOCK_SIZE_SHIFT);
            // Mark all blocks as free
            for (Word i = Word.zero(); i.LT(reqBlockCount); i = i.add(1)) {
                setInUse(nr.add(i), false);
            }
            allocatedBlocks = allocatedBlocks.sub(reqBlockCount);
View Full Code Here

Examples of org.vmmagic.unboxed.Word

     *
     * @param freeBlockCount
     * @return The block number of the first block, or Word.max() if not found.
     */
    private static Word findFreeBlocks(Word freeBlockCount) {
        final Word max = blockCount.sub(freeBlockCount);
        Word nr = nextBlockNr;
        while (nr.LT(max)) {
            boolean inUse = false;
            Word i;
            for (i = Word.zero(); i.LT(freeBlockCount) && (!inUse); i = i.add(1)) {
                inUse |= isInUse(nr.add(i));
            }
            if (!inUse) {
                // We found it
                return nr;
View Full Code Here

Examples of org.vmmagic.unboxed.Word

     *
     * @param blockNr
     * @return boolean
     */
    private static final boolean isInUse(Word blockNr) {
        final Word offset = blockNr.rshl(3); // we still need a byte offset
        final int mask = (1 << blockNr.and(Word.fromIntZeroExtend(7)).toInt());
        final Address ptr = bitmapPtr.add(offset);
        final int v = ptr.loadByte() & 0xFF;
        return ((v & mask) == mask);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.