Package org.jnode.system.resource

Examples of org.jnode.system.resource.MemoryResource


    private final boolean initConfigTable(ResourceManager rm,
                                          ResourceOwner owner) {
        final Address tablePtr = getMPConfigTablePtr();
        int size = 0x2C; // Base table length
        try {
            MemoryResource mem = rm.claimMemoryResource(owner, tablePtr, size,
                ResourceManager.MEMMODE_NORMAL);
            // Read the table length
            int baseTableLen = mem.getChar(4);
            mem.release();
            // Claim the full table.
            // BootLogInstance.get().info("baseTableLength " + baseTableLen);
            size = baseTableLen;
            mem = rm.claimMemoryResource(owner, tablePtr, size,
                ResourceManager.MEMMODE_NORMAL);
View Full Code Here


        final int stepSize = 16;
        while (size > 0) {
            Address res = ms.findInt32(ptr, size, MAGIC, stepSize);
            if (res != null) {
                try {
                    final MemoryResource mem;
                    mem = rm.claimMemoryResource(owner, ptr, 16,
                        ResourceManager.MEMMODE_NORMAL);
                    final MPFloatingPointerStructure mp = new MPFloatingPointerStructure(
                        mem);
                    if (mp.isValid()) {
View Full Code Here

        final int size = mem.getSize().toInt();
        try {
            while (offset < size) {
                final int type = mem.getByte(offset);
                final int len = ENTRY_LENGTH[type];
                final MemoryResource mem = this.mem.claimChildResource(offset,
                    len, false);
                final MPEntry entry;
                switch (type) {
                    case 0:
                        entry = new MPProcessorEntry(mem);
View Full Code Here

            ptr = drv.physToVirtual(ptr);

            // Load the length of the entire table.
            final int length = ptr.loadInt(Offset.fromIntZeroExtend(4));
            // Claim the full table memory region.
            final MemoryResource table;
            table = rm.claimMemoryResource(owner, ptr, length,
                ResourceManager.MEMMODE_NORMAL);
            // Load the signature
            final char[] signatureArr = new char[4];
            for (int i = 0; i < 4; i++) {
                signatureArr[i] = (char) (table.getByte(i) & 0xff);
            }
            final String signature = String.valueOf(signatureArr);

            if (signature.equals("RSDT")) {
                return new RootSystemDescriptionTable(drv, rm, table);
            } else if (signature.equals("DSDT")) {
                return new DifferentiatedSystemDescriptionTable(drv, rm, table);
            } else if (signature.equals("FACS")) {
                return new FirmwareAcpiControlStructure(drv, rm, table);
            } else if (signature.equals("FACP")) {
                return new FixedAcpiDescriptionTable(drv, rm, table);
            } else {
                table.release();
                return null;
            }
        } catch (ResourceNotFreeException ex1) {
            throw new ResourceNotFreeException(
                "Could not get table header begining memory range: "
View Full Code Here

        throws ResourceNotFreeException, DriverException {
        IRQResource irq = null;
        DMAResource dma = null;
        IOResource io1 = null;
        IOResource io2 = null;
        MemoryResource dmaMem = null;

        if (primary) {
            startPort = PRIMARY_START_PORT;
        } else {
            startPort = SECONDARY_START_PORT;
        }

        // Try to read the floppy parameters in CMOS
        try {
            final CMOSService cmos = InitialNaming.lookup(CMOSService.NAME);
            final int fd = cmos.getRegister(CMOSConstants.CMOS_FLOPPY_DRIVES);
            driveParams = new FloppyDriveParameters[NR_DRIVES];
            diskChanged = new boolean[NR_DRIVES];
            for (int i = 0; i < NR_DRIVES; i++) {
                final int cmosType;
                if (i == 0) {
                    cmosType = (fd >> 4) & 0xf;
                } else if (i == 1) {
                    cmosType = (fd & 0xf);
                } else {
                    cmosType = 0;
                }
                driveParams[i] = getDriveParam(cmosType);
                diskChanged[i] = true;
            }
        } catch (NameNotFoundException ex) {
            throw new ResourceNotFreeException("Cannot find CMOSService", ex);
        }

        try {
            final ResourceManager rm = InitialNaming.lookup(ResourceManager.NAME);
            final DMAManager dmaService = InitialNaming.lookup(DMAManager.NAME);
            // PRESERVE THIS CLAIMING ORDER!
            irq = rm.claimIRQ(owner, FLOPPY_IRQ, this, false);
            dma = dmaService.claimDMAChannel(owner, FLOPPY_DMA);
            io1 = claimPorts(rm, owner, startPort + OFFSET_RANGE1, NR_PORTS_RANGE1);
            io2 = claimPorts(rm, owner, startPort + OFFSET_RANGE2, NR_PORTS_RANGE2);
            dmaMem = rm.claimMemoryResource(owner, null, 64 * 1024, ResourceManager.MEMMODE_ALLOC_DMA);
        } catch (NameNotFoundException ex) {
            throw new ResourceNotFreeException("Cannot find ResourceManager or DMAService", ex);
        } catch (ResourceNotFreeException ex) {
            if (dmaMem != null) {
                dmaMem.release();
            }
            if (io2 != null) {
                io2.release();
            }
            if (io1 != null) {
View Full Code Here

        // Claim the memory mapped I/O region
        final Address regsAddrPtr = Address.fromLong(regsAddr.getMemoryBase());
        final Extent regsSize = Extent.fromIntZeroExtend(regsAddr.getSize());
        try {
            final MemoryResource regs;
            regs = rm.claimMemoryResource(device, regsAddrPtr, regsSize,
                ResourceManager.MEMMODE_NORMAL);
            this.io = new Prism2IO(regs);
        } catch (ResourceNotFreeException ex) {
            throw new DriverException("Cannot claim memory mapped I/O", ex);
View Full Code Here

            return null;
        }
    }

    private static int getRSDTVersion(ResourceManager rm, Address start) {
        final MemoryResource res;
        try {
            res = rm.claimMemoryResource(ResourceOwner.SYSTEM, start, 20, ResourceManager.MEMMODE_NORMAL);
        } catch (ResourceNotFreeException e) {
            // Cannot claim memory
            return 1;
        }
        try {
            return res.getByte(15);
        } finally {
            res.release();
        }
    }
View Full Code Here

        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;
        try {
            buffer = ByteBuffer.allocate(size);
            for (int i = 0; i < size; i++) {
                buffer.put(resource.getByte(i));
            }
            buffer.rewind();
        } finally {
            resource.release();
        }
       
        return buffer;
    }
View Full Code Here

            println("step5");
            // step 5
            int size = 0x7FFF; // 32 Kb
            int mode = ResourceManager.MEMMODE_NORMAL;
            int address = 0xA0000;
            @SuppressWarnings("unused")
            MemoryResource resource =
                    manager.claimMemoryResource(owner, Address.fromInt(address), size, mode);

            println("....");
            println("....");
View Full Code Here

                            ResourceManager.MEMMODE_NORMAL);

            // Map MMIO block 0, first test for 8Mb framebuffers.
            Offset block0Ofs = Offset.fromIntZeroExtend(0x7ffc00);
            Extent mmioSize = Extent.fromIntZeroExtend(1024); // 1K
            MemoryResource mmio0 = deviceRam.claimChildResource(block0Ofs, mmioSize, false);
            Mach64VgaIO io = new Mach64VgaIO(deviceRam, mmio0);
            if ((io.getReg32(CONFIG_CHIP_ID) & CFG_CHIP_TYPE) != pciCfg.getDeviceID()) {
                // Try for 4Mb framebuffers.
                mmio0.release();
                block0Ofs = Offset.fromIntZeroExtend(0x3ffc00);
                mmio0 = deviceRam.claimChildResource(block0Ofs, mmioSize, false);
                io = new Mach64VgaIO(deviceRam, mmio0);
                if ((io.getReg32(CONFIG_CHIP_ID) & CFG_CHIP_TYPE) != pciCfg.getDeviceID()) {
                    throw new DriverException("Cannot find block0 registers.");
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.