Package org.jnode.driver.bus.ide

Examples of org.jnode.driver.bus.ide.IDEDevice


        helper.modifyPartition(id, false, start, size, sizeUnit, type);
    }

    private void printPartitionTable(PartitionHelper helper, PrintWriter out)
        throws DeviceNotFoundException, ApiNotFoundException, IOException {
        IDEDevice ideDev = helper.getDevice();
        IDEDriveDescriptor descriptor = ideDev.getDescriptor();
        int sectorSize = IDEConstants.SECTOR_SIZE;
        if (ideDev != null) {
            out.println("IDE Disk : " + ideDev.getId() + ": " +
                descriptor.getSectorsAddressable() * 512 + " bytes");
        }
        out.println("Device Boot    Start       End    Blocks   System");
        IBMPartitionTable partitionTable = helper.getPartitionTable();
        int i = 0;
View Full Code Here


    private void listAvailableDevices(DeviceManager dm, PrintWriter out) {
        final Collection<Device> allDevices = dm.getDevicesByAPI(BlockDeviceAPI.class);
        for (Device dev : allDevices) {
            //out.println("Found device : " + dev.getId() + "[" + dev.getClass() + "]");
            if (dev instanceof IDEDevice) {
                IDEDevice ideDevice = (IDEDevice) dev;
                IDEDriveDescriptor desc = ideDevice.getDescriptor();
                if (desc.isDisk()) {
                    out.println("IDE Disk: " + ideDevice.getId() + "('" + desc.getModel() + "' " +
                        desc.getSectorsAddressable() * IDEConstants.SECTOR_SIZE + " bytes)");
                }
            }
        }
    }
View Full Code Here

        MockObjectFactory.createResourceManager(testCase);

        // create stub IDE device
        Device parent = MockObjectFactory.createParentDevice();
        BlockDeviceAPITestConfig cfg = (BlockDeviceAPITestConfig) config;
        IDEDevice device = MockObjectFactory.createIDEDevice(parent, testCase, true, cfg.getDeviceSize());

        init(null, driver, device);
    }
View Full Code Here

         * @see org.jnode.driver.bus.scsi.SCSIDevice#executeCommand(org.jnode.driver.bus.scsi.CDB, byte[], int, long)
         */
        public final int executeCommand(CDB cdb, byte[] data,
                                        int dataOffset, long timeout) throws SCSIException,
            TimeoutException, InterruptedException {
            final IDEDevice dev = (IDEDevice) getDevice();
            final IDEBus bus = (IDEBus) dev.getBus();

            final IDEPacketCommand cmd = new IDEPacketCommand(
                dev.isPrimary(), dev.isMaster(), cdb.toByteArray(), data,
                dataOffset);
            bus.executeAndWait(cmd, timeout);

            if (!cmd.isFinished()) {
                throw new TimeoutException("Timeout in SCSI command");
View Full Code Here

    /**
     * @see org.jnode.driver.DeviceToDriverMapper#findDriver(org.jnode.driver.Device)
     */
    public Driver findDriver(Device device) {
        if (device instanceof IDEDevice) {
            final IDEDevice ideDev = (IDEDevice) device;
            if (ideDev.getDescriptor().isAtapi()) {
                return new ATAPIDriver();
            }
        }
        return null;
    }
View Full Code Here

        IDEDriveDescriptor desc = (IDEDriveDescriptor)
            MockUtils.createMockObject(IDEDriveDescriptor.class,
                initializer, clsArgs, args);

        DefaultIDEControllerDriver ctrlDriver = new DefaultIDEControllerDriver();
        IDEDevice device = new IDEDevice(ideBus, primary, master, "hdTest", desc, ctrlDriver);

        return device;
    }
View Full Code Here

    public static void main(String[] args) {
        DeviceManager dm;
        try {
            dm = InitialNaming.lookup(DeviceManager.NAME);

            IDEDevice current = (IDEDevice) dm.getDevice(args[0]);
            BlockDeviceAPI api = current.getAPI(BlockDeviceAPI.class);

            int size = (int) (Math.random() * 5 /*256*/) * 512;
            int offset = (int) (Math.random() * 10000) * 512;
            System.out.println("Create Random Buffer");
            System.out.println("Size = " + size);
View Full Code Here

        throws NamingException, ApiNotFoundException, IOException, DeviceNotFoundException {

        final DeviceManager dm = InitialNaming.lookup(DeviceManager.NAME);
        final String name = (args.length > 0) ? args[0] : "hda";

        IDEDevice dev = (IDEDevice) dm.getDevice(name);
        IDEDeviceAPI<?> api = dev.getAPI(IDEDeviceAPI.class);
        IDEDriveDescriptor descr = dev.getDescriptor();

        System.out.println("LBA support   : " + descr.supportsLBA());
        System.out.println("DMA support   : " + descr.supportsDMA());
        System.out.println("48-bit support: " + descr.supports48bitAddressing());
        System.out.println("Length        : " + api.getLength());
View Full Code Here

    private boolean is48bit;
    private IDEDiskBus diskBus;
    private IBMPartitionTable pt;

    protected void startDevice() throws DriverException {
        final IDEDevice dev = (IDEDevice) getDevice();
        diskBus = new IDEDiskBus(dev);
        /* Register the IDEDevice API */
        dev.registerAPI(IDEDeviceAPI.class,
            new IDEDeviceBlockAlignmentSupport<IBMPartitionTableEntry>(this, SECTOR_SIZE));

        /* Get basic configuration */
        final IDEDriveDescriptor descr = dev.getDescriptor();
        //lba = descr.supportsLBA();
        //dma = descr.supportsDMA();
        is48bit = descr.supports48bitAddressing();
        maxSector = descr.getSectorsAddressable();

        // Look for partitions
        try {
            // Find the devicemanager
            DeviceManager devMan = InitialNaming.lookup(DeviceManager.NAME);
            // Read the bootsector
            final byte[] bs1 = new byte[SECTOR_SIZE];
            read(0, ByteBuffer.wrap(bs1));

            // Read the bootsector twice, since the first read seems to fail.
            // todo: THIS IS A WORKAROUND
            final byte[] bs = new byte[SECTOR_SIZE];
            read(0, ByteBuffer.wrap(bs));

            IDEDeviceFactory factory;
            try {
                factory = IDEDriverUtils.getIDEDeviceFactory();
            } catch (NamingException ex) {
                throw new DriverException(ex);
            }
            log.debug("Creating partition table object on " + dev.getId());
            this.pt = factory.createIBMPartitionTable(bs, dev);
            log.debug("Created partition table object");

            int partIndex = 0;
            int i = 0;
View Full Code Here

            throw new DriverException("Unknown error", ex);
        }
    }

    protected void stopDevice() throws DriverException {
        final IDEDevice dev = (IDEDevice) getDevice();
        // find mounted partitions on this device and unregister them !
        try {
            DeviceManager devMan = InitialNaming.lookup(DeviceManager.NAME);
            Collection<Device> devices = devMan.getDevices();
            final ArrayList<IDEDiskPartitionDevice> toStop = new ArrayList<IDEDiskPartitionDevice>();

            for (Device device : devices) {
                if (device instanceof IDEDiskPartitionDevice) {
                    IDEDiskPartitionDevice partition = (IDEDiskPartitionDevice) device;
                    if (partition.getParent() == dev) {
                        toStop.add(partition);
                    }
                }

            }

            for (IDEDiskPartitionDevice partition : toStop) {
                devMan.unregister(partition);
            }
        } catch (NameNotFoundException e) {
            throw new DriverException("Problem while stopping this IDE device", e);
        }

        dev.unregisterAPI(BlockDeviceAPI.class);
        this.pt = null;
    }
View Full Code Here

TOP

Related Classes of org.jnode.driver.bus.ide.IDEDevice

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.