scsidisk.pas 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. {
  2. This file is part of the Free Pascal run time library.
  3. A file in Amiga system run time library.
  4. Copyright (c) 1998-2003 by Nils Sjoholm
  5. member of the Amiga RTL development team.
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. {
  13. History:
  14. Update for AmigaOS 3.9.
  15. Added const.
  16. 31 Jan 2003.
  17. [email protected]
  18. }
  19. {
  20. SCSI exec-level device command
  21. }
  22. unit scsidisk;
  23. INTERFACE
  24. uses exec;
  25. {--------------------------------------------------------------------
  26. *
  27. * SCSI Command
  28. * Several Amiga SCSI controller manufacturers are converging on
  29. * standard ways to talk to their controllers. This include
  30. * file describes an exec-device command (e.g. for hddisk.device)
  31. * that can be used to issue SCSI commands
  32. *
  33. * UNIT NUMBERS
  34. * Unit numbers to the OpenDevice call have encoded in them which
  35. * SCSI device is being referred to. The three decimal digits of
  36. * the unit number refer to the SCSI Target ID (bus address) in
  37. * the 1's digit, the SCSI logical unit (LUN) in the 10's digit,
  38. * and the controller board in the 100's digit.
  39. *
  40. * Examples:
  41. * 0 drive at address 0
  42. * 12 LUN 1 on multiple drive controller at address 2
  43. * 104 second controller board, address 4
  44. * 88 not valid: both logical units and addresses
  45. * range from 0..7.
  46. *
  47. * CAVEATS
  48. * Original 2090 code did not support this command.
  49. *
  50. * Commodore 2090/2090A unit numbers are different. The SCSI
  51. * logical unit is the 100's digit, and the SCSI Target ID
  52. * is a permuted 1's digit: Target ID 0..6 maps to unit 3..9
  53. * (7 is reserved for the controller).
  54. *
  55. * Examples:
  56. * 3 drive at address 0
  57. * 109 drive at address 6, logical unit 1
  58. * 1 not valid: this is not a SCSI unit. Perhaps
  59. * it's an ST506 unit.
  60. *
  61. * Some controller boards generate a unique name (e.g. 2090A's
  62. * iddisk.device) for the second controller board, instead of
  63. * implementing the 100's digit.
  64. *
  65. *
  66. * With the advent of wide SCSI the scheme above fails miserably.
  67. * A new scheme was adopted by Phase V, who appear to be the only
  68. * source of wide SCSI for the Amiga at this time. Thus their
  69. * numbering system kludge is adopted here. When the ID or LUN is
  70. * above 7 the new numbering scheme is used.
  71. *
  72. * Unit =
  73. * Board * 10 * 1000 * 1000 +
  74. * LUN * 10 * 1000 +
  75. * ID * 10 +
  76. * HD_WIDESCSI;
  77. *
  78. * There are optional restrictions on the alignment, bus
  79. * accessability, and size of the data for the data phase.
  80. * Be conservative to work with all manufacturer's controllers.
  81. *
  82. *------------------------------------------------------------------}
  83. Const
  84. HD_WIDESCSI = 8;
  85. HD_SCSICMD = 28; { issue a SCSI command to the unit }
  86. { io_Data points to a SCSICmd }
  87. { io_Length is sizeof(struct SCSICmd) }
  88. { io_Actual and io_Offset are not used }
  89. Type
  90. pSCSICmd = ^tSCSICmd;
  91. tSCSICmd = record
  92. scsi_Data : Pointer; { word aligned data for SCSI Data Phase }
  93. { (optional) data need not be byte aligned }
  94. { (optional) data need not be bus accessable }
  95. scsi_Length : ULONG; { even length of Data area }
  96. { (optional) data can have odd length }
  97. { (optional) data length can be > 2**24 }
  98. scsi_Actual : ULONG; { actual Data used }
  99. scsi_Command : Pointer; { SCSI Command (same options as scsi_Data) }
  100. scsi_CmdLength : Word; { length of Command }
  101. scsi_CmdActual : Word; { actual Command used }
  102. scsi_Flags : Byte; { includes intended data direction }
  103. scsi_Status : Byte; { SCSI status of command }
  104. scsi_SenseData : STRPTR; { sense data: filled IF SCSIF_[OLD]AUTOSENSE }
  105. { is set AND scsi_Status has CHECK CONDITION }
  106. { (bit 1) set }
  107. scsi_SenseLength : Word; { size of scsi_SenseData, also bytes to }
  108. { request w/ SCSIF_AUTOSENSE, must be 4..255 }
  109. scsi_SenseActual : Word; { amount actually fetched (0 means no sense) }
  110. end;
  111. Const
  112. {----- scsi_Flags -----}
  113. SCSIF_WRITE = 0; { intended data direction is out }
  114. SCSIF_READ = 1; { intended data direction is in }
  115. SCSIB_READ_WRITE = 0; { (the bit to test) }
  116. SCSIF_NOSENSE = 0; { no automatic request sense }
  117. SCSIF_AUTOSENSE = 2; { do standard extended request sense }
  118. { on check condition }
  119. SCSIF_OLDAUTOSENSE = 6; { do 4 byte non-extended request }
  120. { sense on check condition }
  121. SCSIB_AUTOSENSE = 1; { (the bit to test) }
  122. SCSIB_OLDAUTOSENSE = 2; { (the bit to test) }
  123. {----- SCSI io_Error values -----}
  124. HFERR_SelfUnit = 40; { cannot issue SCSI command to self }
  125. HFERR_DMA = 41; { DMA error }
  126. HFERR_Phase = 42; { illegal or unexpected SCSI phase }
  127. HFERR_Parity = 43; { SCSI parity error }
  128. HFERR_SelTimeout = 44; { Select timed out }
  129. HFERR_BadStatus = 45; { status and/or sense error }
  130. {----- OpenDevice io_Error values -----}
  131. HFERR_NoBoard = 50; { Open failed for non-existant board }
  132. IMPLEMENTATION
  133. end.