|
From: <ga...@us...> - 2007-02-20 19:16:43
|
Revision: 3129
http://jnode.svn.sourceforge.net/jnode/?rev=3129&view=rev
Author: galatnm
Date: 2007-02-20 11:16:35 -0800 (Tue, 20 Feb 2007)
Log Message:
-----------
Correct scsi driver detection.
Modified Paths:
--------------
trunk/fs/src/driver/org/jnode/driver/block/usb/storage/USBStorageSCSIHostDriver.java
trunk/fs/src/driver/org/jnode/driver/block/usb/storage/scsi/USBStorageSCSIDeviceToDriverMapper.java
trunk/fs/src/driver/org/jnode/driver/block/usb/storage/scsi/USBStorageSCSIDriver.java
Modified: trunk/fs/src/driver/org/jnode/driver/block/usb/storage/USBStorageSCSIHostDriver.java
===================================================================
--- trunk/fs/src/driver/org/jnode/driver/block/usb/storage/USBStorageSCSIHostDriver.java 2007-02-17 17:30:42 UTC (rev 3128)
+++ trunk/fs/src/driver/org/jnode/driver/block/usb/storage/USBStorageSCSIHostDriver.java 2007-02-20 19:16:35 UTC (rev 3129)
@@ -9,16 +9,16 @@
* by the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
- * This library is distributed in the hope that it will be useful, but
+ * This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
- * along with this library; If not, write to the Free Software Foundation, Inc.,
+ * along with this library; If not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-
+
package org.jnode.driver.block.usb.storage;
import org.apache.log4j.Logger;
@@ -56,7 +56,7 @@
/** Storage specific device data */
private USBStorageDeviceData USBMassStorage;
-
+
/** The SCSI device that i'm host of */
private USBStorageSCSIDevice scsiDevice;
@@ -88,9 +88,9 @@
default:
throw new DriverException("Transport protocol not implemented.");
}
-
+
USBEndPoint ep;
-
+
for (int i = 0; i < conf.getInterface(0).getDescriptor().getNumEndPoints(); i++) {
ep = conf.getInterface(0).getEndPoint(i);
// Is it a bulk endpoint ?
@@ -162,7 +162,7 @@
public void requestFailed(USBRequest request) {
log.debug("USBStorageSCSIHostDriver failed with status:" + request.getStatus());
}
-
+
private final class USBStorageSCSIHostBus extends Bus {
/**
@@ -170,10 +170,13 @@
*/
public USBStorageSCSIHostBus(Device parent) {
super(parent);
- }
+ }
}
-
- private final class USBStorageSCSIDevice extends SCSIDevice {
+ /**
+ *
+ * @author Fabien Lesire
+ */
+ public final class USBStorageSCSIDevice extends SCSIDevice {
private InquiryData inquiryResult;
@@ -195,10 +198,10 @@
int res = this.executeCommand(new CDBTestUnitReady(),null,0,50000);
log.debug("*** result : 0x" + NumberUtils.hex(res) + " ***" );
}
-
+
/**
- * Execute an INQUUIRY command.
- *
+ * Execute an INQUIRY command.
+ *
* @throws SCSIException
* @throws TimeoutException
* @throws InterruptedException
@@ -211,12 +214,12 @@
inquiryResult = new InquiryData(inqData);
log.debug("INQUIRY Data : " + inquiryResult.toString());
}
-
+
protected final void capacity() throws SCSIException, TimeoutException, InterruptedException {
log.info("*** Read capacity ***");
CapacityData cd = MMCUtils.readCapacity(this);
log.debug("Capacity Data : " + cd.toString());
-
+
}
/**
Modified: trunk/fs/src/driver/org/jnode/driver/block/usb/storage/scsi/USBStorageSCSIDeviceToDriverMapper.java
===================================================================
--- trunk/fs/src/driver/org/jnode/driver/block/usb/storage/scsi/USBStorageSCSIDeviceToDriverMapper.java 2007-02-17 17:30:42 UTC (rev 3128)
+++ trunk/fs/src/driver/org/jnode/driver/block/usb/storage/scsi/USBStorageSCSIDeviceToDriverMapper.java 2007-02-20 19:16:35 UTC (rev 3129)
@@ -9,22 +9,23 @@
* by the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
- * This library is distributed in the hope that it will be useful, but
+ * This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
- * along with this library; If not, write to the Free Software Foundation, Inc.,
+ * along with this library; If not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-
+
package org.jnode.driver.block.usb.storage.scsi;
import org.apache.log4j.Logger;
import org.jnode.driver.Device;
import org.jnode.driver.DeviceToDriverMapper;
import org.jnode.driver.Driver;
+import org.jnode.driver.block.usb.storage.USBStorageSCSIHostDriver.USBStorageSCSIDevice;
import org.jnode.driver.bus.scsi.SCSIDevice;
import org.jnode.driver.bus.usb.USBDevice;
@@ -39,8 +40,7 @@
*/
public Driver findDriver(Device device) {
log.debug("*** USBStorageSCSIDeviceToDriverMapper::findDriver ***");
- if ((device instanceof USBDevice) && (device instanceof SCSIDevice)) {
- log.debug("*** find USBStorageSCSIDriver ***");
+ if (device instanceof USBStorageSCSIDevice) {
return new USBStorageSCSIDriver();
}
return null;
@@ -48,7 +48,7 @@
/**
* Gets the matching level of this mapper. The mappers are queried in order
* of match level. This will ensure the best available driver for a device.
- *
+ *
* @return One of the MATCH_xxx constants.
* @see #MATCH_DEVICE_REVISION
* @see #MATCH_DEVICE
Modified: trunk/fs/src/driver/org/jnode/driver/block/usb/storage/scsi/USBStorageSCSIDriver.java
===================================================================
--- trunk/fs/src/driver/org/jnode/driver/block/usb/storage/scsi/USBStorageSCSIDriver.java 2007-02-17 17:30:42 UTC (rev 3128)
+++ trunk/fs/src/driver/org/jnode/driver/block/usb/storage/scsi/USBStorageSCSIDriver.java 2007-02-20 19:16:35 UTC (rev 3129)
@@ -9,16 +9,16 @@
* by the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
- * This library is distributed in the hope that it will be useful, but
+ * This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
- * along with this library; If not, write to the Free Software Foundation, Inc.,
+ * along with this library; If not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-
+
package org.jnode.driver.block.usb.storage.scsi;
import java.io.IOException;
@@ -82,16 +82,16 @@
} catch (DeviceAlreadyRegisteredException ex) {
throw new DriverException(ex);
}
-
+
this.locked = false;
this.changed = true;
this.capacity = null;
this.blockAlignment.setAlignment(2048);
-
+
dev.registerAPI(RemovableDeviceAPI.class, this);
dev.registerAPI(FSBlockDeviceAPI.class, blockAlignment);
}
-
+
@Override
protected void stopDevice() throws DriverException {
try {
@@ -123,7 +123,8 @@
}
public void read(long devOffset, ByteBuffer dest) throws IOException {
- // TODO Auto-generated method stub
+ processChanged();
+ if (capacity == null) { throw new IOException("No medium"); }
}
@@ -149,7 +150,7 @@
/**
* Unlock the device.
- *
+ *
* @throws IOException
*/
public synchronized void unlock() throws IOException {
@@ -196,13 +197,13 @@
}
public boolean canLock() {
- // TODO Auto-generated method stub
- return false;
+ return true;
}
-
+ /**
+ * It's a removable device.
+ */
public boolean canEject() {
- // TODO Auto-generated method stub
- return false;
+ return true;
}
public void lock() throws IOException {
@@ -211,8 +212,7 @@
}
public boolean isLocked() {
- // TODO Auto-generated method stub
- return false;
+ return locked;
}
public void eject() throws IOException {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|