| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| ModeParameterHeader10 |
|
| 1.0;1 |
| 1 | package org.jscsi.target.scsi.modeSense; | |
| 2 | ||
| 3 | ||
| 4 | import java.nio.ByteBuffer; | |
| 5 | ||
| 6 | import org.jscsi.target.util.BitManip; | |
| 7 | import org.jscsi.target.util.ReadWrite; | |
| 8 | ||
| 9 | ||
| 10 | /** | |
| 11 | * A {@link ModeParameterHeader} sub-class. Instances of this class are sent in response to <code>MODE SENSE (10)</code> | |
| 12 | * SCSI commands and have a serialized length of 8 bytes. | |
| 13 | * | |
| 14 | * @see LongLogicalBlockDescriptor | |
| 15 | * @author Andreas Ergenzinger | |
| 16 | */ | |
| 17 | public final class ModeParameterHeader10 extends ModeParameterHeader { | |
| 18 | ||
| 19 | /** | |
| 20 | * The length of this object when serialized. | |
| 21 | */ | |
| 22 | static final int SIZE = 8; | |
| 23 | ||
| 24 | /** | |
| 25 | * The length in bytes of the MODE DATA LENGTH field. | |
| 26 | */ | |
| 27 | static final int MODE_DATA_LENGTH_FIELD_SIZE = 2; | |
| 28 | ||
| 29 | /** | |
| 30 | * If the Long LBA (LONGLBA) bit is set to zero, the MODE PARAMETER BLOCK DESCRIPTOR(s), if any, are each eight | |
| 31 | * bytes long and have the format described in SPC-3. If the LONGLBA bit is set to one, the mode parameter block | |
| 32 | * descriptor(s), if any, are each sixteen bytes long and have a format described in a non-general command standard. | |
| 33 | */ | |
| 34 | private final boolean longLba; | |
| 35 | ||
| 36 | /** | |
| 37 | * The constructor. | |
| 38 | * | |
| 39 | * @param modeDataLength the total length in bytes of all MODE DATA list elements | |
| 40 | * @param blockDescriptorLength the total length in bytes of all BLOCK DESCRIPTOR list elements | |
| 41 | * @param longLba if <code>true</code> then the LONG LBA MODE PAREMETER LOGICAL BLOCK DESCRIPTOR format will be used | |
| 42 | * @see LongLogicalBlockDescriptor | |
| 43 | * @see ShortLogicalBlockDescriptor | |
| 44 | */ | |
| 45 | public ModeParameterHeader10 (final int modeDataLength, final int blockDescriptorLength, final boolean longLba) { | |
| 46 | 0 | super(modeDataLength, blockDescriptorLength); |
| 47 | 0 | this.longLba = longLba; |
| 48 | 0 | } |
| 49 | ||
| 50 | public void serialize (final ByteBuffer byteBuffer, final int index) { | |
| 51 | 0 | ReadWrite.writeTwoByteInt(byteBuffer,// buffer |
| 52 | modeDataLength,// value | |
| 53 | index);// index | |
| 54 | 0 | byteBuffer.position(index + 2); |
| 55 | 0 | byteBuffer.put(mediumType); |
| 56 | 0 | byteBuffer.put(deviceSpecificParameter); |
| 57 | 0 | final byte zeroByte = 0; |
| 58 | 0 | byteBuffer.put(BitManip.getByteWithBitSet(zeroByte, 0, longLba)); |
| 59 | 0 | byteBuffer.put(zeroByte); |
| 60 | 0 | ReadWrite.writeTwoByteInt(byteBuffer,// buffer |
| 61 | blockDescriptorLength,// value | |
| 62 | index + 6);// index | |
| 63 | 0 | } |
| 64 | ||
| 65 | public int size () { | |
| 66 | 0 | return SIZE; |
| 67 | } | |
| 68 | ||
| 69 | } |