View Javadoc

1   package org.jscsi.target.scsi.modeSense;
2   
3   
4   import org.jscsi.target.scsi.ISerializable;
5   
6   
7   /**
8    * Instances {@link ModeParameterHeader} are part of {@link ModeParameterList} objects and specify the layout and length
9    * of the following non-header fields.
10   * 
11   * @author Andreas Ergenzinger
12   */
13  public abstract class ModeParameterHeader implements ISerializable {
14  
15      /**
16       * When using the MODE SENSE command, the MODE DATA LENGTH field indicates the length in bytes of the following data
17       * that is available to be transferred. The mode data length does not include the number of bytes in the MODE DATA
18       * LENGTH field.
19       * <p>
20       * When using the MODE SELECT command, this field is reserved.
21       * <p>
22       * Logical units that support more than 256 bytes of block descriptors and mode pages may need to implement ten-byte
23       * mode commands. The mode data length field in the six-byte CDB header limits the returned data to 256 bytes.
24       */
25      protected final int modeDataLength;
26  
27      /**
28       * The contents of the MEDIUM TYPE field are unique for each device type. For direct-access block devices, the value
29       * must be 0x00.
30       */
31      protected final byte mediumType = (byte) 0x00;
32  
33      /**
34       * The DEVICE-SPECIFIC PARAMETER field is unique for each device type. For direct-access block devices the byte
35       * looks like this:
36       * <p>
37       * <code>
38       * +---+---+---+---+---+---+---+---+---+<br/>
39       * |bit| 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |<br/>
40       * +---+---+---+---+---+---+---+---+---+<br/>
41       * |___|WP_|RESERV-|DPO|___RESERVED____|<br/>
42       * |___|___|__ED___|FUA|_______________|<br/>
43       * +---+---+---+---+---+---+---+---+---+
44       * </code>
45       * <p>
46       * When used with the MODE SELECT command, the write protect (WP) bit is not defined. When used with the MODE SENSE
47       * command, a WP bit set to one indicates that the medium is write-protected. A WP bit set to zero indicates that
48       * the medium is not write-protected. When the software write protect (SWP) bit in the Control mode page (see SPC-4)
49       * is set to one, the WP bit shall be set to one.
50       * <p>
51       * When the SWP bit in the Control mode page is set to zero, the WP bit shall be set to one if the medium is
52       * write-protected (e.g., due to mechanisms outside the scope of this standard) or zero if the medium is not
53       * write-protected.
54       * <p>
55       * When used with the MODE SELECT command, the DPOFUA bit is reserved. When used with the MODE SENSE command, a
56       * DPOFUA bit set to zero indicates that the device server does not support the DPO and FUA bits. When used with the
57       * MODE SENSE command, a DPOFUA bit set to one indicates that the device server supports the DPO and FUA bits.
58       * <p>
59       * So, the simulated logical unit of the jSCSI Target must always use a value of 0x00.
60       */
61      protected final byte deviceSpecificParameter = (byte) 0x00;
62  
63      /**
64       * The BLOCK DESCRIPTOR LENGTH field contains the length in bytes of all the block descriptors. It is equal to the
65       * number of block descriptors times eight if the LONGLBA bit is set to zero or times sixteen if the LONGLBA bit is
66       * set to one, and does not include mode pages or vendor specific parameters (e.g., page code set to zero), if any,
67       * that may follow the last block descriptor. A block descriptor length of zero indicates that no block descriptors
68       * are included in the mode parameter list. This condition shall not be considered an error.
69       */
70      protected final int blockDescriptorLength;
71  
72      /**
73       * The abstract constructor.
74       * 
75       * @param modeDataLength the length in bytes of all MODE DATA list elements
76       * @param blockDescriptorLength the length in bytes of all BLOCK DESCRIPTOR list elements
77       */
78      public ModeParameterHeader (final int modeDataLength, final int blockDescriptorLength) {
79          this.modeDataLength = modeDataLength;
80          this.blockDescriptorLength = blockDescriptorLength;
81      }
82  }