1 /****************************************************************************** 2 / 3 / File: scsi.h 4 / 5 / Description: Data structures and control calls for using the scsi driver. 6 / 7 / Copyright 1992-98, Be Incorporated 8 / 9 *******************************************************************************/ 10 11 12 #ifndef _SCSI_H 13 #define _SCSI_H 14 15 #include <SupportDefs.h> 16 #include <OS.h> 17 #include <Drivers.h> 18 19 20 /* scsi device types */ 21 /*------------------------*/ 22 #define B_SCSI_DISK 0x00 23 #define B_SCSI_TAPE 0x01 24 #define B_SCSI_PRINTER 0x02 25 #define B_SCSI_CPU 0x03 26 #define B_SCSI_WORM 0x04 27 #define B_SCSI_CD 0x05 28 #define B_SCSI_SCANNER 0x06 29 #define B_SCSI_OPTICAL 0x07 30 #define B_SCSI_JUKEBOX 0x08 31 #define B_SCSI_NETWORK 0x09 32 33 34 /* scsi device masks */ 35 /*----------------------------------*/ 36 #define B_SCSI_ALL_DEVICES_MASK 0xffffffff 37 #define B_SCSI_DISK_MASK (1 << (B_SCSI_DISK)) 38 #define B_SCSI_TAPE_MASK (1 << (B_SCSI_TAPE)) 39 #define B_SCSI_PRINTER_MASK (1 << (B_SCSI_PRINTER)) 40 #define B_SCSI_CPU_MASK (1 << (B_SCSI_CPU)) 41 #define B_SCSI_WORM_MASK (1 << (B_SCSI_WORM)) 42 #define B_SCSI_CD_MASK (1 << (B_SCSI_CD)) 43 #define B_SCSI_SCANNER_MASK (1 << (B_SCSI_SCANNER)) 44 #define B_SCSI_OPTICAL_MASK (1 << (B_SCSI_OPTICAL)) 45 #define B_SCSI_JUKEBOX_MASK (1 << (B_SCSI_JUKEBOX)) 46 #define B_SCSI_NETWORK_MASK (1 << (B_SCSI_NETWORK)) 47 48 /* control call codes for rescan scsi driver (/dev/scsi/rescan) */ 49 /*-----------------------------------------------------*/ 50 enum { 51 B_SCSI_SCAN_FOR_DEVICES = B_DEVICE_OP_CODES_END + 1, 52 B_SCSI_ENABLE_PROFILING 53 }; 54 55 56 /* control calls for all individual scsi device drivers */ 57 /*------------------------------------------------------*/ 58 enum { 59 B_SCSI_INQUIRY = B_DEVICE_OP_CODES_END + 100, 60 B_SCSI_EJECT, 61 B_SCSI_PREVENT_ALLOW, 62 B_RAW_DEVICE_COMMAND 63 }; 64 65 typedef struct { 66 uchar inquiry_data[36]; /* inquiry data (see SCSI standard) */ 67 } scsi_inquiry; 68 69 70 /* control calls for scsi cd-rom driver */ 71 /*--------------------------------------*/ 72 enum { 73 B_SCSI_GET_TOC = B_DEVICE_OP_CODES_END + 200, 74 B_SCSI_PLAY_TRACK, 75 B_SCSI_PLAY_POSITION, 76 B_SCSI_STOP_AUDIO, 77 B_SCSI_PAUSE_AUDIO, 78 B_SCSI_RESUME_AUDIO, 79 B_SCSI_GET_POSITION, 80 B_SCSI_SET_VOLUME, 81 B_SCSI_GET_VOLUME, 82 B_SCSI_READ_CD, 83 B_SCSI_SCAN, 84 B_SCSI_DATA_MODE 85 }; 86 87 typedef struct { 88 uchar toc_data[804]; /* table of contents data (see SCSI standard) */ 89 } scsi_toc; 90 91 typedef struct { 92 uchar start_track; /* starting track */ 93 uchar start_index; /* starting index */ 94 uchar end_track; /* ending track */ 95 uchar end_index; /* ending index */ 96 } scsi_play_track; 97 98 typedef struct { 99 uchar start_m; /* starting minute */ 100 uchar start_s; /* starting second */ 101 uchar start_f; /* starting frame */ 102 uchar end_m; /* ending minute */ 103 uchar end_s; /* ending second */ 104 uchar end_f; /* ending frame */ 105 } scsi_play_position; 106 107 typedef struct { 108 uchar position[16]; /* position data (see SCSI standard) */ 109 } scsi_position; 110 111 typedef struct { 112 uchar flags; /* A 1 in any position means change that field */ 113 /* with port0_channel as bit 0 and port3_volume */ 114 /* as bit 7. */ 115 uchar port0_channel; 116 uchar port0_volume; 117 uchar port1_channel; 118 uchar port1_volume; 119 uchar port2_channel; 120 uchar port2_volume; 121 uchar port3_channel; 122 uchar port3_volume; 123 } scsi_volume; 124 125 #define B_SCSI_PORT0_CHANNEL 0x01 126 #define B_SCSI_PORT0_VOLUME 0x02 127 #define B_SCSI_PORT1_CHANNEL 0x04 128 #define B_SCSI_PORT1_VOLUME 0x08 129 #define B_SCSI_PORT2_CHANNEL 0x10 130 #define B_SCSI_PORT2_VOLUME 0x20 131 #define B_SCSI_PORT3_CHANNEL 0x40 132 #define B_SCSI_PORT3_VOLUME 0x80 133 134 typedef struct { 135 uchar start_m; /* starting minute */ 136 uchar start_s; /* starting second */ 137 uchar start_f; /* starting frame */ 138 uchar length_m; /* transfer length minute */ 139 uchar length_s; /* transfer length second */ 140 uchar length_f; /* transfer length frame */ 141 long buffer_length; /* size of read buffer */ 142 char* buffer; /* buffer to hold requested data */ 143 bool play; /* FALSE = don't play, TRUE = play */ 144 } scsi_read_cd; 145 146 typedef struct { 147 char speed; /* 0 = slow - 5x, 1 = fast - 12x */ 148 char direction; /* 1 = forward, 0 = stop scan, -1 = backward */ 149 } scsi_scan; 150 151 typedef struct { 152 off_t block; 153 int32 mode; 154 } scsi_data_mode; 155 156 /* raw device commands */ 157 158 typedef struct { 159 uint8 command[16]; 160 uint8 command_length; 161 uint8 flags; 162 uint8 scsi_status; /* SCSI Status Byte */ 163 /* (0 = success, 2 = check cond, ... */ 164 uint8 cam_status; /* CAM_* status conditions from CAM.h */ 165 void *data; 166 size_t data_length; 167 void *sense_data; /* buffer to return mode sense data in */ 168 size_t sense_data_length; /* size of optional buffer for mode sense */ 169 bigtime_t timeout; 170 } raw_device_command; 171 172 enum { 173 B_RAW_DEVICE_DATA_IN = 0x01, 174 B_RAW_DEVICE_REPORT_RESIDUAL = 0x02, 175 B_RAW_DEVICE_SHORT_READ_VALID = 0x04 176 }; 177 178 #endif 179