Package org.jnode.system.resource

Examples of org.jnode.system.resource.DMAResource


     * @throws DriverException
     */
    public DefaultFDC(ResourceOwner owner, boolean primary)
        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) {
                io1.release();
            }
            if (dma != null) {
                dma.release();
            }
            if (irq != null) {
                irq.release();
            }
            throw ex;
View Full Code Here

TOP

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

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.