1 /* 2 * Copyright 2009, Haiku Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _SCSI_H 6 #define _SCSI_H 7 8 9 #include <Drivers.h> 10 #include <OS.h> 11 #include <SupportDefs.h> 12 13 14 /* SCSI device types */ 15 #define B_SCSI_DISK 0x00 16 #define B_SCSI_TAPE 0x01 17 #define B_SCSI_PRINTER 0x02 18 #define B_SCSI_CPU 0x03 19 #define B_SCSI_WORM 0x04 20 #define B_SCSI_CD 0x05 21 #define B_SCSI_SCANNER 0x06 22 #define B_SCSI_OPTICAL 0x07 23 #define B_SCSI_JUKEBOX 0x08 24 #define B_SCSI_NETWORK 0x09 25 26 27 /* SCSI device masks */ 28 #define B_SCSI_ALL_DEVICES_MASK 0xffffffff 29 #define B_SCSI_DISK_MASK (1 << (B_SCSI_DISK)) 30 #define B_SCSI_TAPE_MASK (1 << (B_SCSI_TAPE)) 31 #define B_SCSI_PRINTER_MASK (1 << (B_SCSI_PRINTER)) 32 #define B_SCSI_CPU_MASK (1 << (B_SCSI_CPU)) 33 #define B_SCSI_WORM_MASK (1 << (B_SCSI_WORM)) 34 #define B_SCSI_CD_MASK (1 << (B_SCSI_CD)) 35 #define B_SCSI_SCANNER_MASK (1 << (B_SCSI_SCANNER)) 36 #define B_SCSI_OPTICAL_MASK (1 << (B_SCSI_OPTICAL)) 37 #define B_SCSI_JUKEBOX_MASK (1 << (B_SCSI_JUKEBOX)) 38 #define B_SCSI_NETWORK_MASK (1 << (B_SCSI_NETWORK)) 39 40 41 enum { 42 B_SCSI_SCAN_FOR_DEVICES = B_DEVICE_OP_CODES_END + 1, 43 B_SCSI_ENABLE_PROFILING 44 }; 45 46 47 enum { 48 B_SCSI_INQUIRY = B_DEVICE_OP_CODES_END + 100, 49 B_SCSI_EJECT, 50 B_SCSI_PREVENT_ALLOW, 51 B_RAW_DEVICE_COMMAND 52 }; 53 54 55 typedef struct { 56 uchar inquiry_data[36]; 57 } scsi_inquiry; 58 59 60 enum { 61 B_SCSI_GET_TOC = B_DEVICE_OP_CODES_END + 200, 62 B_SCSI_PLAY_TRACK, 63 B_SCSI_PLAY_POSITION, 64 B_SCSI_STOP_AUDIO, 65 B_SCSI_PAUSE_AUDIO, 66 B_SCSI_RESUME_AUDIO, 67 B_SCSI_GET_POSITION, 68 B_SCSI_SET_VOLUME, 69 B_SCSI_GET_VOLUME, 70 B_SCSI_READ_CD, 71 B_SCSI_SCAN, 72 B_SCSI_DATA_MODE 73 }; 74 75 76 typedef struct { 77 uchar toc_data[804]; 78 } scsi_toc; 79 80 81 typedef struct { 82 uchar start_track; 83 uchar start_index; 84 uchar end_track; 85 uchar end_index; 86 } scsi_play_track; 87 88 89 typedef struct { 90 uchar start_m; 91 uchar start_s; 92 uchar start_f; 93 uchar end_m; 94 uchar end_s; 95 uchar end_f; 96 } scsi_play_position; 97 98 99 typedef struct { 100 uchar position[16]; 101 } scsi_position; 102 103 104 typedef struct { 105 uchar flags; 106 uchar port0_channel; 107 uchar port0_volume; 108 uchar port1_channel; 109 uchar port1_volume; 110 uchar port2_channel; 111 uchar port2_volume; 112 uchar port3_channel; 113 uchar port3_volume; 114 } scsi_volume; 115 116 117 #define B_SCSI_PORT0_CHANNEL 0x01 118 #define B_SCSI_PORT0_VOLUME 0x02 119 #define B_SCSI_PORT1_CHANNEL 0x04 120 #define B_SCSI_PORT1_VOLUME 0x08 121 #define B_SCSI_PORT2_CHANNEL 0x10 122 #define B_SCSI_PORT2_VOLUME 0x20 123 #define B_SCSI_PORT3_CHANNEL 0x40 124 #define B_SCSI_PORT3_VOLUME 0x80 125 126 127 typedef struct { 128 uchar start_m; 129 uchar start_s; 130 uchar start_f; 131 uchar length_m; 132 uchar length_s; 133 uchar length_f; 134 long buffer_length; 135 char* buffer; 136 bool play; 137 } scsi_read_cd; 138 139 140 typedef struct { 141 char speed; 142 char direction; 143 } scsi_scan; 144 145 146 typedef struct { 147 off_t block; 148 int32 mode; 149 } scsi_data_mode; 150 151 152 typedef struct { 153 uint8 command[16]; 154 uint8 command_length; 155 uint8 flags; 156 uint8 scsi_status; 157 uint8 cam_status; 158 void* data; 159 size_t data_length; 160 void* sense_data; 161 size_t sense_data_length; 162 bigtime_t timeout; 163 } raw_device_command; 164 165 166 enum { 167 B_RAW_DEVICE_DATA_IN = 0x01, 168 B_RAW_DEVICE_REPORT_RESIDUAL = 0x02, 169 B_RAW_DEVICE_SHORT_READ_VALID = 0x04 170 }; 171 172 #endif /* _SCSI_H */ 173