ModeSense6CommandDescriptorBlock.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /* Copyright (C) 2012-2016 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved.
  2. *
  3. * You can redistribute this program and/or modify it under the terms of
  4. * the GNU Lesser Public License as published by the Free Software Foundation,
  5. * either version 3 of the License, or (at your option) any later version.
  6. */
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Text;
  10. using Utilities;
  11. namespace SCSI
  12. {
  13. public class ModeSense6CommandDescriptorBlock : SCSICommandDescriptorBlock
  14. {
  15. public bool DBD; // Disable block descriptors
  16. public byte PC; // Page Control
  17. public ModePageCodeName PageCode;
  18. public byte SubpageCode;
  19. public ModeSense6CommandDescriptorBlock() : base()
  20. {
  21. OpCode = SCSIOpCodeName.ModeSense6;
  22. }
  23. public ModeSense6CommandDescriptorBlock(byte[] buffer, int offset) : base()
  24. {
  25. OpCode = (SCSIOpCodeName)buffer[offset + 0];
  26. DBD = (buffer[offset + 1] & 0x08) != 0;
  27. PC = (byte)(buffer[offset + 2] >> 6);
  28. PageCode = (ModePageCodeName)(buffer[offset + 2] & 0x3F);
  29. SubpageCode = buffer[offset + 3];
  30. AllocationLength = buffer[offset + 4];
  31. Control = buffer[offset + 5];
  32. }
  33. public override byte[] GetBytes()
  34. {
  35. byte[] buffer = new byte[6];
  36. buffer[0] = (byte)OpCode;
  37. if (DBD)
  38. {
  39. buffer[1] |= 0x08;
  40. }
  41. buffer[2] |= (byte)(PC << 6);
  42. buffer[2] |= (byte)((byte)PageCode & 0x3F);
  43. buffer[3] = SubpageCode;
  44. buffer[4] = AllocationLength;
  45. buffer[5] = Control;
  46. return buffer;
  47. }
  48. public byte AllocationLength
  49. {
  50. get
  51. {
  52. return (byte)TransferLength;
  53. }
  54. set
  55. {
  56. TransferLength = value;
  57. }
  58. }
  59. }
  60. }