scsi.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. //
  2. // Copyright 2026 Aarav Ravindra Kharade
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. //
  16. /* Copyright (C) 1998-2026 Free Software Foundation, Inc.
  17. This file is part of the GNU C Library.
  18. The GNU C Library is free software; you can redistribute it and/or
  19. modify it under the terms of the GNU Lesser General Public
  20. License as published by the Free Software Foundation; either
  21. version 2.1 of the License, or (at your option) any later version.
  22. The GNU C Library is distributed in the hope that it will be useful,
  23. but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  25. Lesser General Public License for more details.
  26. You should have received a copy of the GNU Lesser General Public
  27. License along with the GNU C Library; if not, see
  28. <https://www.gnu.org/licenses/>. */
  29. /*
  30. * This header file contains public constants and structures used by
  31. * the scsi code for linux.
  32. */
  33. #ifndef _SCSI_SCSI_H
  34. #define _SCSI_SCSI_H 1
  35. #include <features.h>
  36. /*
  37. * SCSI opcodes
  38. */
  39. #define TEST_UNIT_READY 0x00
  40. #define REZERO_UNIT 0x01
  41. #define REQUEST_SENSE 0x03
  42. #define FORMAT_UNIT 0x04
  43. #define READ_BLOCK_LIMITS 0x05
  44. #define REASSIGN_BLOCKS 0x07
  45. #define READ_6 0x08
  46. #define WRITE_6 0x0a
  47. #define SEEK_6 0x0b
  48. #define READ_REVERSE 0x0f
  49. #define WRITE_FILEMARKS 0x10
  50. #define SPACE 0x11
  51. #define INQUIRY 0x12
  52. #define RECOVER_BUFFERED_DATA 0x14
  53. #define MODE_SELECT 0x15
  54. #define RESERVE 0x16
  55. #define RELEASE 0x17
  56. #define COPY 0x18
  57. #define ERASE 0x19
  58. #define MODE_SENSE 0x1a
  59. #define START_STOP 0x1b
  60. #define RECEIVE_DIAGNOSTIC 0x1c
  61. #define SEND_DIAGNOSTIC 0x1d
  62. #define ALLOW_MEDIUM_REMOVAL 0x1e
  63. #define SET_WINDOW 0x24
  64. #define READ_CAPACITY 0x25
  65. #define READ_10 0x28
  66. #define WRITE_10 0x2a
  67. #define SEEK_10 0x2b
  68. #define WRITE_VERIFY 0x2e
  69. #define VERIFY 0x2f
  70. #define SEARCH_HIGH 0x30
  71. #define SEARCH_EQUAL 0x31
  72. #define SEARCH_LOW 0x32
  73. #define SET_LIMITS 0x33
  74. #define PRE_FETCH 0x34
  75. #define READ_POSITION 0x34
  76. #define SYNCHRONIZE_CACHE 0x35
  77. #define LOCK_UNLOCK_CACHE 0x36
  78. #define READ_DEFECT_DATA 0x37
  79. #define MEDIUM_SCAN 0x38
  80. #define COMPARE 0x39
  81. #define COPY_VERIFY 0x3a
  82. #define WRITE_BUFFER 0x3b
  83. #define READ_BUFFER 0x3c
  84. #define UPDATE_BLOCK 0x3d
  85. #define READ_LONG 0x3e
  86. #define WRITE_LONG 0x3f
  87. #define CHANGE_DEFINITION 0x40
  88. #define WRITE_SAME 0x41
  89. #define READ_TOC 0x43
  90. #define LOG_SELECT 0x4c
  91. #define LOG_SENSE 0x4d
  92. #define MODE_SELECT_10 0x55
  93. #define RESERVE_10 0x56
  94. #define RELEASE_10 0x57
  95. #define MODE_SENSE_10 0x5a
  96. #define PERSISTENT_RESERVE_IN 0x5e
  97. #define PERSISTENT_RESERVE_OUT 0x5f
  98. #define MOVE_MEDIUM 0xa5
  99. #define READ_12 0xa8
  100. #define WRITE_12 0xaa
  101. #define WRITE_VERIFY_12 0xae
  102. #define SEARCH_HIGH_12 0xb0
  103. #define SEARCH_EQUAL_12 0xb1
  104. #define SEARCH_LOW_12 0xb2
  105. #define READ_ELEMENT_STATUS 0xb8
  106. #define SEND_VOLUME_TAG 0xb6
  107. #define WRITE_LONG_2 0xea
  108. /*
  109. * Status codes
  110. */
  111. #define GOOD 0x00
  112. #define CHECK_CONDITION 0x01
  113. #define CONDITION_GOOD 0x02
  114. #define BUSY 0x04
  115. #define INTERMEDIATE_GOOD 0x08
  116. #define INTERMEDIATE_C_GOOD 0x0a
  117. #define RESERVATION_CONFLICT 0x0c
  118. #define COMMAND_TERMINATED 0x11
  119. #define QUEUE_FULL 0x14
  120. #define STATUS_MASK 0x3e
  121. /*
  122. * SENSE KEYS
  123. */
  124. #define NO_SENSE 0x00
  125. #define RECOVERED_ERROR 0x01
  126. #define NOT_READY 0x02
  127. #define MEDIUM_ERROR 0x03
  128. #define HARDWARE_ERROR 0x04
  129. #define ILLEGAL_REQUEST 0x05
  130. #define UNIT_ATTENTION 0x06
  131. #define DATA_PROTECT 0x07
  132. #define BLANK_CHECK 0x08
  133. #define COPY_ABORTED 0x0a
  134. #define ABORTED_COMMAND 0x0b
  135. #define VOLUME_OVERFLOW 0x0d
  136. #define MISCOMPARE 0x0e
  137. /*
  138. * DEVICE TYPES
  139. */
  140. #define TYPE_DISK 0x00
  141. #define TYPE_TAPE 0x01
  142. #define TYPE_PROCESSOR 0x03 /* HP scanners use this */
  143. #define TYPE_WORM 0x04 /* Treated as ROM by our system */
  144. #define TYPE_ROM 0x05
  145. #define TYPE_SCANNER 0x06
  146. #define TYPE_MOD 0x07 /* Magneto-optical disk -
  147. * - treated as TYPE_DISK */
  148. #define TYPE_MEDIUM_CHANGER 0x08
  149. #define TYPE_ENCLOSURE 0x0d /* Enclosure Services Device */
  150. #define TYPE_NO_LUN 0x7f
  151. /*
  152. * standard mode-select header prepended to all mode-select commands
  153. *
  154. * moved here from cdrom.h -- kraxel
  155. */
  156. struct ccs_modesel_head
  157. {
  158. unsigned char _r1; /* reserved. */
  159. unsigned char medium; /* device-specific medium type. */
  160. unsigned char _r2; /* reserved. */
  161. unsigned char block_desc_length; /* block descriptor length. */
  162. unsigned char density; /* device-specific density code. */
  163. unsigned char number_blocks_hi; /* number of blocks in this block
  164. desc. */
  165. unsigned char number_blocks_med;
  166. unsigned char number_blocks_lo;
  167. unsigned char _r3;
  168. unsigned char block_length_hi; /* block length for blocks in this
  169. desc. */
  170. unsigned char block_length_med;
  171. unsigned char block_length_lo;
  172. };
  173. /*
  174. * MESSAGE CODES
  175. */
  176. #define COMMAND_COMPLETE 0x00
  177. #define EXTENDED_MESSAGE 0x01
  178. #define EXTENDED_MODIFY_DATA_POINTER 0x00
  179. #define EXTENDED_SDTR 0x01
  180. #define EXTENDED_EXTENDED_IDENTIFY 0x02 /* SCSI-I only */
  181. #define EXTENDED_WDTR 0x03
  182. #define SAVE_POINTERS 0x02
  183. #define RESTORE_POINTERS 0x03
  184. #define DISCONNECT 0x04
  185. #define INITIATOR_ERROR 0x05
  186. #define ABORT 0x06
  187. #define MESSAGE_REJECT 0x07
  188. #define NOP 0x08
  189. #define MSG_PARITY_ERROR 0x09
  190. #define LINKED_CMD_COMPLETE 0x0a
  191. #define LINKED_FLG_CMD_COMPLETE 0x0b
  192. #define BUS_DEVICE_RESET 0x0c
  193. #define INITIATE_RECOVERY 0x0f /* SCSI-II only */
  194. #define RELEASE_RECOVERY 0x10 /* SCSI-II only */
  195. #define SIMPLE_QUEUE_TAG 0x20
  196. #define HEAD_OF_QUEUE_TAG 0x21
  197. #define ORDERED_QUEUE_TAG 0x22
  198. /*
  199. * Here are some scsi specific ioctl commands which are sometimes useful.
  200. */
  201. /* These are a few other constants only used by scsi devices. */
  202. #define SCSI_IOCTL_GET_IDLUN 0x5382
  203. /* Used to turn on and off tagged queuing for scsi devices. */
  204. #define SCSI_IOCTL_TAGGED_ENABLE 0x5383
  205. #define SCSI_IOCTL_TAGGED_DISABLE 0x5384
  206. /* Used to obtain the host number of a device. */
  207. #define SCSI_IOCTL_PROBE_HOST 0x5385
  208. /* Used to get the bus number for a device. */
  209. #define SCSI_IOCTL_GET_BUS_NUMBER 0x5386
  210. #endif /* scsi/scsi.h */