Package org.jnode.system.resource

Examples of org.jnode.system.resource.MemoryResource


        final int bytesPerLine = config.getBytesPerLine();
        final int bytesPerScreen = bytesPerLine * height;
        currentState.calcForConfiguration(config, vgaIO);

        // Allocate the screen memory
        final MemoryResource screen = claimDeviceMemory(bytesPerScreen, 4 * 1024);

        // Block all interrupts.
        vgaIO.disableIRQ();

        // Save the current state
        oldVgaState.saveFromVGA(vgaIO);

        // Turn off the screen
        final DpmsState dpmsState = getDpms();
        setDpms(DpmsState.OFF);

        try {
            // Set new configuration

            // Create the graphics helper & clear the screen
            final BitmapGraphics bitmapGraphics;
            switch (config.getBitsPerPixel()) {
                case 8:
                    bitmapGraphics =
                            BitmapGraphics.create8bppInstance(screen, width, height, bytesPerLine,
                                    0);
                    screen.setByte(0, (byte) 0, pixels);
                    break;
                case 16:
                    bitmapGraphics =
                            BitmapGraphics.create16bppInstance(screen, width, height, bytesPerLine,
                                    0);
                    screen.setShort(0, (byte) 0, pixels);
                    break;
                case 24:
                    bitmapGraphics =
                            BitmapGraphics.create24bppInstance(screen, width, height, bytesPerLine,
                                    0);
                    screen.setInt24(0, 0, pixels);
                    break;
                case 32:
                    bitmapGraphics =
                            BitmapGraphics.create32bppInstance(screen, width, height, bytesPerLine,
                                    0);
                    screen.setInt(0, 0, pixels);
                    break;
                default:
                    throw new IllegalArgumentException("Invalid bits per pixel " + bitsPerPixel);
            }
            return new Mach64Surface(this, config, bitmapGraphics, screen);
View Full Code Here


            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);
        res.setInt(SVGA_FIFO_NEXT_CMD * 4, fifoMin);
        res.setInt(SVGA_FIFO_STOP * 4, fifoMin);
        setReg32(SVGA_REG_CONFIG_DONE, 1);

        return res;
    }
View Full Code Here

                    rm.claimMemoryResource(device, Address.fromIntZeroExtend(fbBase), memSize,
                            ResourceManager.MEMMODE_NORMAL);
            vgaIO.setVideoRam(deviceRam);

            // Find ROM
            MemoryResource rom = null;
            if (romAddr != null) {
                romAddr.setEnabled(true);
                if (romAddr.isEnabled()) {
                    rom =
                            rm.claimMemoryResource(device, Address.fromIntZeroExtend(romAddr
                                    .getRomBase()), romAddr.getSize(),
                                    ResourceManager.MEMMODE_NORMAL);
                    if (!verifyBiosSignature(rom)) {
                        log.info("Signature mismatch");
                        rom.release();
                        rom = null;
                    }
                } else {
                    log.debug("Failed to enabled expansion ROM");
                }
            }
            if (rom == null) {
                // Use the ISA regions rom instead
                rom = findRom(device, rm);
            }
            this.rom = rom;

            log.debug("Found ATI " + model + ", FB at 0x" + NumberUtils.hex(fbBase) + "s0x" +
                    NumberUtils.hex(memSize) + ", MMIO at 0x" + NumberUtils.hex(ioBase) + ", ROM " +
                    pciCfg.getRomAddress());

            fbinfo.readMonitorInfo(vgaIO);
            if (this.rom != null) {
                log.info("ROM[0-3] 0x" + NumberUtils.hex(rom.getInt(0)));
                // Read monitor information
                fbinfo.readFPIInfo(rom);
            }

        } catch (NameNotFoundException ex) {
View Full Code Here

        // Disable video interrupts
        vgaIO.disableIRQ();

        // Allocate the screen memory
        final MemoryResource screen = claimDeviceMemory(bytesPerScreen, 4 * 1024);
        // final MemoryResource screen = deviceRam;
        log.debug("Screen at 0x" + NumberUtils.hex(screen.getOffset().toInt()) + ", size 0x" +
                NumberUtils.hex(screen.getSize().toInt()));

        // if (true) { throw new ResourceNotFreeException("TEST"); }

        // Save the current state
        oldVgaState.saveFromVGA(vgaIO);
        log.debug("oldState:" + oldVgaState);

        // Turn off the screen
        final DpmsState dpmsState = getDpms();
        setDpms(DpmsState.OFF);

        try {
            // Set the new configuration
            currentState.restoreToVGA(vgaIO);
            log.debug("NewState: " + currentState);
            vgaIO.setReg32(CRTC_OFFSET, (int) screen.getOffset().toInt());
            if (fbinfo.hasCRTC2) {
                vgaIO.setReg32(CRTC2_OFFSET, (int) screen.getOffset().toInt());
            }

            // Set the 8-bit palette
            setPalette(1.0f);

            // Create the graphics helper & clear the screen
            final BitmapGraphics bitmapGraphics;
            switch (bitsPerPixel) {
                case 8:
                    bitmapGraphics =
                            BitmapGraphics.create8bppInstance(screen, width, height, bytesPerLine,
                                    0);
                    screen.setByte(0, (byte) 0, pixels);
                    break;
                case 16:
                    bitmapGraphics =
                            BitmapGraphics.create16bppInstance(screen, width, height, bytesPerLine,
                                    0);
                    screen.setShort(0, (byte) 0, pixels);
                    break;
                case 24:
                    bitmapGraphics =
                            BitmapGraphics.create24bppInstance(screen, width, height, bytesPerLine,
                                    0);
                    screen.setInt24(0, 0, pixels);
                    break;
                case 32:
                    bitmapGraphics =
                            BitmapGraphics.create32bppInstance(screen, width, height, bytesPerLine,
                                    0);
                    screen.setInt(0, 0, pixels);
                    break;
                default:
                    throw new IllegalArgumentException("Invalid bits per pixel " + bitsPerPixel);
            }
            return new RadeonSurface(this, config, bitmapGraphics, screen, accel);
View Full Code Here

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

    /* save the fonts */
    protected void saveFont(VgaIO io) {
        if (fonts == null) {
            fonts = new byte[FONT_STATE_SIZE * 4];
        }
        final MemoryResource vgaMem = io.getVideoMem();
        int ofs = 0;
        final int oldSeq2 = io.getSEQ(2);
        final int oldSeq4 = io.getSEQ(4);
        final int oldGra4 = io.getGRAF(4);
        final int oldGra5 = io.getGRAF(5);
        final int oldGra6 = io.getGRAF(6);
        io.setSEQ(4, 0x06);
        io.setGRAF(5, 0);
        io.setGRAF(6, 0x05);

        io.setSEQ(2, 1);
        io.setGRAF(4, 0);
        vgaMem.getBytes(0, fonts, ofs, FONT_STATE_SIZE);
        ofs += FONT_STATE_SIZE;

        io.setSEQ(2, 2);
        io.setGRAF(4, 1);
        vgaMem.getBytes(0, fonts, ofs, FONT_STATE_SIZE);
        ofs += FONT_STATE_SIZE;

        io.setSEQ(2, 4);
        io.setGRAF(4, 2);
        vgaMem.getBytes(0, fonts, ofs, FONT_STATE_SIZE);
        ofs += FONT_STATE_SIZE;

        io.setSEQ(2, 8);
        io.setGRAF(4, 3);
        vgaMem.getBytes(0, fonts, ofs, FONT_STATE_SIZE);

        // restore
        io.setSEQ(2, oldSeq2);
        io.setSEQ(4, oldSeq4);
        io.setGRAF(4, oldGra4);
View Full Code Here

        io.setGRAF(6, oldGra6);
    }

    private void restoreFont(VgaIO io) {
        if (fonts != null) {
            final MemoryResource vgaMem = io.getVideoMem();
            int ofs = 0;

            final int oldSeq2 = io.getSEQ(0x02);
            final int oldSeq4 = io.getSEQ(0x04);
            final int oldGra1 = io.getGRAF(0x01);
            final int oldGra3 = io.getGRAF(0x03);
            final int oldGra5 = io.getGRAF(0x05);
            final int oldGra8 = io.getGRAF(0x08);

            io.setSEQ(4, 0x06);
            io.setGRAF(1, 0);
            io.setGRAF(3, 0);
            io.setGRAF(5, 0);
            io.setGRAF(8, 0xFF);

            io.setSEQ(2, 1);
            io.setGRAF(4, 0);
            vgaMem.setBytes(fonts, ofs, 0, FONT_STATE_SIZE);
            ofs += FONT_STATE_SIZE;

            io.setSEQ(2, 2);
            io.setGRAF(4, 1);
            vgaMem.setBytes(fonts, ofs, 0, FONT_STATE_SIZE);
            ofs += FONT_STATE_SIZE;

            io.setSEQ(2, 4);
            io.setGRAF(4, 2);
            vgaMem.setBytes(fonts, ofs, 0, FONT_STATE_SIZE);
            ofs += FONT_STATE_SIZE;

            io.setSEQ(2, 8);
            io.setGRAF(4, 3);
            vgaMem.setBytes(fonts, ofs, 0, FONT_STATE_SIZE);

            // restore
            io.setSEQ(2, oldSeq2);
            io.setSEQ(4, oldSeq4);
            io.setGRAF(1, oldGra1);
View Full Code Here

    private void loadRootTable(ResourceManager rm, AcpiRSDPInfo acpiInfo)
        throws ResourceNotFreeException {
        if (acpiInfo != null) {
            final ResourceOwner owner = new SimpleResourceOwner("ACPI");
            final MemoryResource rsdtptrRes;
            rsdtptrRes = rm.claimMemoryResource(owner, acpiInfo.getRsdpStart(),
                acpiInfo.getLength(), ResourceManager.MEMMODE_NORMAL);
            this.rsdp = new RSDP(this, rsdtptrRes);
            this.root = NameSpace.getRoot();
            Address ptr = rsdp.getXsdtAddress();
View Full Code Here

    static void put(Pointer address, int index, byte[] src, int offset, int length) {
        ((MemoryRawData) address).resource.setBytes(src, offset, index, length);
    }

    static Pointer adjustAddress(Pointer address, int offset) {
        final MemoryResource res = ((MemoryRawData) address).resource;
        final Extent size = res.getSize().sub(offset);
        try {
            return new MemoryRawData(res.claimChildResource(Offset.fromIntZeroExtend(offset), size, true));
        } catch (ResourceNotFreeException ex) {
            throw new Error("Cannot adjustAddress", ex);
        }
    }
View Full Code Here

TOP

Related Classes of org.jnode.system.resource.MemoryResource

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.