From: <ep...@us...> - 2013-11-12 08:49:31
|
Revision: 5994 http://sourceforge.net/p/jnode/svn/5994 Author: epr Date: 2013-11-12 08:49:28 +0000 (Tue, 12 Nov 2013) Log Message: ----------- Added logging. Added extra read of bootsector to work around an IDE transfer bug. Modified Paths: -------------- trunk/fs/src/driver/org/jnode/driver/block/ide/disk/IDEDiskDriver.java trunk/fs/src/driver/org/jnode/driver/bus/ide/command/IDEReadSectorsCommand.java trunk/fs/src/fs/org/jnode/partitions/ibm/IBMPartitionTable.java Modified: trunk/fs/src/driver/org/jnode/driver/block/ide/disk/IDEDiskDriver.java =================================================================== --- trunk/fs/src/driver/org/jnode/driver/block/ide/disk/IDEDiskDriver.java 2013-11-12 08:47:18 UTC (rev 5993) +++ trunk/fs/src/driver/org/jnode/driver/block/ide/disk/IDEDiskDriver.java 2013-11-12 08:49:28 UTC (rev 5994) @@ -105,6 +105,11 @@ // 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)); @@ -114,14 +119,18 @@ } 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; for (IBMPartitionTableEntry pte : pt) { + log.debug("Processing partition " + i); if (pte == null) { BootLogInstance.get().warn("PartitionTableEntry #" + i + " is null"); } else if (pte.isValid()) { + log.debug("Partition " + i + " is valid"); registerPartition(devMan, dev, pte, partIndex); } partIndex++; @@ -133,11 +142,17 @@ partIndex = registerExtendedPartition(devMan, dev, partIndex); } } catch (DeviceAlreadyRegisteredException ex) { + log.error("Partition device is already known"); throw new DriverException("Partition device is already known???? Probably a bug", ex); } catch (IOException ex) { + log.error("Cannot read partition table", ex); throw new DriverException("Cannot read partition table", ex); } catch (NameNotFoundException ex) { + log.error("Cannot find DeviceManager", ex); throw new DriverException("Cannot find DeviceManager", ex); + } catch (Throwable ex) { + log.error("Unknown error", ex); + throw new DriverException("Unknown error", ex); } } @@ -210,20 +225,11 @@ final int partSectors = Math.min(length / SECTOR_SIZE, maxSectorCount); final int partLength = partSectors * SECTOR_SIZE; - final IDERWSectorsCommand cmd = isWrite ? new IDEWriteSectorsCommand( - dev.isPrimary(), - dev.isMaster(), - is48bit, - partLbaStart, - partSectors, - buf) : new IDEReadSectorsCommand( - dev.isPrimary(), - dev.isMaster(), - is48bit, - partLbaStart, - partSectors, - buf); + final IDERWSectorsCommand cmd = isWrite ? + new IDEWriteSectorsCommand(dev.isPrimary(), dev.isMaster(), is48bit, partLbaStart, partSectors, buf) : + new IDEReadSectorsCommand(dev.isPrimary(), dev.isMaster(), is48bit, partLbaStart, partSectors, buf); try { + log.debug("bus.executeAndWait dev=" + dev.getId() + " start=" + partLbaStart + " sectors=" + partSectors + " len=" + partLength); bus.executeAndWait(cmd, IDE_DATA_XFER_TIMEOUT); } catch (InterruptedException ex) { throw new IOException("IDE " + errorSource + " interrupted", ex); Modified: trunk/fs/src/driver/org/jnode/driver/bus/ide/command/IDEReadSectorsCommand.java =================================================================== --- trunk/fs/src/driver/org/jnode/driver/bus/ide/command/IDEReadSectorsCommand.java 2013-11-12 08:47:18 UTC (rev 5993) +++ trunk/fs/src/driver/org/jnode/driver/bus/ide/command/IDEReadSectorsCommand.java 2013-11-12 08:49:28 UTC (rev 5994) @@ -21,6 +21,9 @@ package org.jnode.driver.bus.ide.command; import java.nio.ByteBuffer; + +import org.apache.log4j.Logger; +import org.jnode.driver.block.ide.disk.IDEDiskDriver; import org.jnode.driver.bus.ide.IDEBus; import org.jnode.driver.bus.ide.IDEIO; import org.jnode.util.TimeoutException; Modified: trunk/fs/src/fs/org/jnode/partitions/ibm/IBMPartitionTable.java =================================================================== --- trunk/fs/src/fs/org/jnode/partitions/ibm/IBMPartitionTable.java 2013-11-12 08:47:18 UTC (rev 5993) +++ trunk/fs/src/fs/org/jnode/partitions/ibm/IBMPartitionTable.java 2013-11-12 08:49:28 UTC (rev 5994) @@ -133,30 +133,36 @@ */ public static boolean containsPartitionTable(byte[] bootSector) { if (LittleEndian.getUInt16(bootSector, 510) != 0xaa55) { + log.debug("No aa55 magic"); return false; } if (LittleEndian.getUInt16(bootSector, 428) == 0x5678) { // Matches the AAP MBR extra signature, probably an valid partition table + log.debug("Has AAP MBR extra signature"); return true; } if (LittleEndian.getUInt16(bootSector, 380) == 0xa55a) { // Matches the AST/NEC MBR extra signature, probably an valid partition table + log.debug("Has AST/NEC MBR extra signature"); return true; } if (LittleEndian.getUInt16(bootSector, 252) == 0x55aa) { // Matches the Disk Manager MBR extra signature, probably an valid partition table + log.debug("Has Dis Manager MBR extra signature"); return true; } if (LittleEndian.getUInt32(bootSector, 2) == 0x4c57454e) { // Matches the NEWLDR MBR extra signature, probably an valid partition table + log.debug("Has NEWLDR MBR extra signature"); return true; } // Nothing matched, fall back to validating any specified partition entries + log.debug("Checking partitions"); IBMPartitionTableEntry lastValid = null; boolean foundValidEntry = false; for (int partitionNumber = 0; partitionNumber < TABLE_SIZE; partitionNumber++) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |