Coverage Report - org.jscsi.target.scsi.cdb.Read6Cdb
 
Classes in this File Line Coverage Branch Coverage Complexity
Read6Cdb
0%
0/10
0%
0/4
1.6
 
 1  
 package org.jscsi.target.scsi.cdb;
 2  
 
 3  
 
 4  
 import java.nio.ByteBuffer;
 5  
 
 6  
 import org.jscsi.target.util.ReadWrite;
 7  
 
 8  
 
 9  
 /**
 10  
  * This class represents Command Descriptor Blocks for the <code>READ (6)
 11  
  * </code> SCSI command.
 12  
  * <p>
 13  
  * The READ (6) command requests that the device server read the specified logical block(s) and transfer them to the
 14  
  * data-in buffer. Each logical block read includes user data and, if the medium is formatted with protection
 15  
  * information enabled, protection information. Each logical block transferred includes user data but does not include
 16  
  * protection information.
 17  
  * <p>
 18  
  * Although the READ (6) command is limited to addressing up to 2,097,151 logical blocks, this command has been
 19  
  * maintained as mandatory since some system initialization routines require that the READ (6) command be used. System
 20  
  * initialization routines should migrate from the READ (6) command to the READ (10) command, which is capable of
 21  
  * addressing 4,294,947,295 logical blocks, or the READ (16) command, which is capable of addressing
 22  
  * 18,446,744,073,709,551,615 logical blocks.
 23  
  * 
 24  
  * @author Andreas Ergenzinger
 25  
  */
 26  
 public class Read6Cdb extends ReadCdb {
 27  
 
 28  
     public Read6Cdb (ByteBuffer buffer) {
 29  0
         super(buffer);
 30  0
     }
 31  
 
 32  
     @Override
 33  
     protected long deserializeLogicalBlockAddress (ByteBuffer buffer) {
 34  
         // the first three bits of byte 1 are reserved i.e. must be 0
 35  
         // check that
 36  0
         final byte b = buffer.get(1);
 37  0
         if (((b >> 5) & 7) != 0) addIllegalFieldPointer(1);
 38  
 
 39  
         // read the field's value
 40  0
         return ((b & 31) << 16) | ReadWrite.readTwoByteInt(buffer, 2);
 41  
     }
 42  
 
 43  
     @Override
 44  
     protected int deserializeTransferLength (ByteBuffer buffer) {
 45  
         /*
 46  
          * A TRANSFER LENGTH field set to zero specifies that 256 logical blocks shall be read. Any other value
 47  
          * specifies the number of logical blocks that shall be read.
 48  
          */
 49  0
         final int value = ReadWrite.readOneByteInt(buffer, 4);
 50  0
         if (value == 0) return 256;
 51  0
         return value;
 52  
     }
 53  
 
 54  
     @Override
 55  
     protected int getLogicalBlockAddressFieldIndex () {
 56  0
         return 1;
 57  
     }
 58  
 
 59  
     @Override
 60  
     protected int getTransferLengthFieldIndex () {
 61  0
         return 4;
 62  
     }
 63  
 
 64  
 }