scsicmd.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. /*
  2. * GRUB -- GRand Unified Bootloader
  3. * Copyright (C) 2008 Free Software Foundation, Inc.
  4. *
  5. * GRUB is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * GRUB is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #ifndef GRUB_SCSICMD_H
  19. #define GRUB_SCSICMD_H 1
  20. #include <grub/types.h>
  21. #define GRUB_SCSI_DEVTYPE_MASK 31
  22. #define GRUB_SCSI_REMOVABLE_BIT 7
  23. #define GRUB_SCSI_LUN_SHIFT 5
  24. struct grub_scsi_test_unit_ready
  25. {
  26. grub_uint8_t opcode;
  27. grub_uint8_t lun; /* 7-5 LUN, 4-0 reserved */
  28. grub_uint8_t reserved1;
  29. grub_uint8_t reserved2;
  30. grub_uint8_t reserved3;
  31. grub_uint8_t control;
  32. grub_uint8_t pad[6]; /* To be ATAPI compatible */
  33. } GRUB_PACKED;
  34. struct grub_scsi_inquiry
  35. {
  36. grub_uint8_t opcode;
  37. grub_uint8_t lun; /* 7-5 LUN, 4-1 reserved, 0 EVPD */
  38. grub_uint8_t page; /* page code if EVPD=1 */
  39. grub_uint8_t reserved;
  40. grub_uint8_t alloc_length;
  41. grub_uint8_t control;
  42. grub_uint8_t pad[6]; /* To be ATAPI compatible */
  43. } GRUB_PACKED;
  44. struct grub_scsi_inquiry_data
  45. {
  46. grub_uint8_t devtype;
  47. grub_uint8_t rmb;
  48. grub_uint16_t reserved;
  49. grub_uint8_t length;
  50. grub_uint8_t reserved2[3];
  51. char vendor[8];
  52. char prodid[16];
  53. char prodrev[4];
  54. } GRUB_PACKED;
  55. struct grub_scsi_request_sense
  56. {
  57. grub_uint8_t opcode;
  58. grub_uint8_t lun; /* 7-5 LUN, 4-0 reserved */
  59. grub_uint8_t reserved1;
  60. grub_uint8_t reserved2;
  61. grub_uint8_t alloc_length;
  62. grub_uint8_t control;
  63. grub_uint8_t pad[6]; /* To be ATAPI compatible */
  64. } GRUB_PACKED;
  65. struct grub_scsi_request_sense_data
  66. {
  67. grub_uint8_t error_code; /* 7 Valid, 6-0 Err. code */
  68. grub_uint8_t segment_number;
  69. grub_uint8_t sense_key; /*7 FileMark, 6 EndOfMedia, 5 ILI, 4-0 sense key */
  70. grub_uint32_t information;
  71. grub_uint8_t additional_sense_length;
  72. grub_uint32_t cmd_specific_info;
  73. grub_uint8_t additional_sense_code;
  74. grub_uint8_t additional_sense_code_qualifier;
  75. grub_uint8_t field_replaceable_unit_code;
  76. grub_uint8_t sense_key_specific[3];
  77. /* there can be additional sense field */
  78. } GRUB_PACKED;
  79. struct grub_scsi_read_capacity10
  80. {
  81. grub_uint8_t opcode;
  82. grub_uint8_t lun; /* 7-5 LUN, 4-1 reserved, 0 reserved */
  83. grub_uint32_t logical_block_addr; /* only if PMI=1 */
  84. grub_uint8_t reserved1;
  85. grub_uint8_t reserved2;
  86. grub_uint8_t PMI;
  87. grub_uint8_t control;
  88. grub_uint16_t pad; /* To be ATAPI compatible */
  89. } GRUB_PACKED;
  90. struct grub_scsi_read_capacity10_data
  91. {
  92. grub_uint32_t last_block;
  93. grub_uint32_t blocksize;
  94. } GRUB_PACKED;
  95. struct grub_scsi_read_capacity16
  96. {
  97. grub_uint8_t opcode;
  98. grub_uint8_t lun; /* 7-5 LUN, 4-0 0x10 */
  99. grub_uint64_t logical_block_addr; /* only if PMI=1 */
  100. grub_uint32_t alloc_len;
  101. grub_uint8_t PMI;
  102. grub_uint8_t control;
  103. } GRUB_PACKED;
  104. struct grub_scsi_read_capacity16_data
  105. {
  106. grub_uint64_t last_block;
  107. grub_uint32_t blocksize;
  108. grub_uint8_t pad[20];
  109. } GRUB_PACKED;
  110. struct grub_scsi_read10
  111. {
  112. grub_uint8_t opcode;
  113. grub_uint8_t lun;
  114. grub_uint32_t lba;
  115. grub_uint8_t reserved;
  116. grub_uint16_t size;
  117. grub_uint8_t reserved2;
  118. grub_uint16_t pad;
  119. } GRUB_PACKED;
  120. struct grub_scsi_read12
  121. {
  122. grub_uint8_t opcode;
  123. grub_uint8_t lun;
  124. grub_uint32_t lba;
  125. grub_uint32_t size;
  126. grub_uint8_t reserved;
  127. grub_uint8_t control;
  128. } GRUB_PACKED;
  129. struct grub_scsi_read16
  130. {
  131. grub_uint8_t opcode;
  132. grub_uint8_t lun;
  133. grub_uint64_t lba;
  134. grub_uint32_t size;
  135. grub_uint8_t reserved;
  136. grub_uint8_t control;
  137. } GRUB_PACKED;
  138. struct grub_scsi_write10
  139. {
  140. grub_uint8_t opcode;
  141. grub_uint8_t lun;
  142. grub_uint32_t lba;
  143. grub_uint8_t reserved;
  144. grub_uint16_t size;
  145. grub_uint8_t reserved2;
  146. grub_uint16_t pad;
  147. } GRUB_PACKED;
  148. struct grub_scsi_write12
  149. {
  150. grub_uint8_t opcode;
  151. grub_uint8_t lun;
  152. grub_uint32_t lba;
  153. grub_uint32_t size;
  154. grub_uint8_t reserved;
  155. grub_uint8_t control;
  156. } GRUB_PACKED;
  157. struct grub_scsi_write16
  158. {
  159. grub_uint8_t opcode;
  160. grub_uint8_t lun;
  161. grub_uint64_t lba;
  162. grub_uint32_t size;
  163. grub_uint8_t reserved;
  164. grub_uint8_t control;
  165. } GRUB_PACKED;
  166. typedef enum
  167. {
  168. grub_scsi_cmd_test_unit_ready = 0x00,
  169. grub_scsi_cmd_request_sense = 0x03,
  170. grub_scsi_cmd_inquiry = 0x12,
  171. grub_scsi_cmd_read_capacity10 = 0x25,
  172. grub_scsi_cmd_read10 = 0x28,
  173. grub_scsi_cmd_write10 = 0x2a,
  174. grub_scsi_cmd_read16 = 0x88,
  175. grub_scsi_cmd_write16 = 0x8a,
  176. grub_scsi_cmd_read_capacity16 = 0x9e,
  177. grub_scsi_cmd_read12 = 0xa8,
  178. grub_scsi_cmd_write12 = 0xaa,
  179. } grub_scsi_cmd_t;
  180. typedef enum
  181. {
  182. grub_scsi_devtype_direct = 0x00,
  183. grub_scsi_devtype_cdrom = 0x05
  184. } grub_scsi_devtype_t;
  185. #endif /* GRUB_SCSICMD_H */