@@ -65,7 +65,9 @@ void ScsiCdrom::process_command()
6565 this ->read (lba, cmd[4 ], 6 );
6666 break ;
6767 case ScsiCommand::INQUIRY:
68- this ->inquiry ();
68+ this ->bytes_out = this ->inquiry (cmd, this ->data_buf );
69+ this ->msg_buf [0 ] = ScsiMessage::COMMAND_COMPLETE;
70+ this ->switch_phase (ScsiPhase::DATA_IN);
6971 break ;
7072 case ScsiCommand::MODE_SELECT_6:
7173 this ->mode_select_6 (cmd[4 ]);
@@ -151,55 +153,53 @@ int ScsiCdrom::test_unit_ready()
151153 return ScsiError::NO_ERROR;
152154}
153155
154- void ScsiCdrom::inquiry () {
155- int page_num = cmd_buf [2 ];
156- int alloc_len = cmd_buf [4 ];
156+ uint32_t ScsiCdrom::inquiry (uint8_t *cmd_ptr, uint8_t *data_ptr ) {
157+ int page_num = cmd_ptr [2 ];
158+ int alloc_len = cmd_ptr [4 ];
157159
158160 if (page_num) {
159161 ABORT_F (" %s: invalid page number in INQUIRY" , this ->name .c_str ());
160162 }
161163
162164 if (alloc_len > 36 ) {
163- LOG_F (ERROR , " %s: more than 36 bytes requested in INQUIRY" , this ->name .c_str ());
165+ LOG_F (WARNING , " %s: more than 36 bytes requested in INQUIRY" , this ->name .c_str ());
164166 }
165167
166168 int lun;
167169 if (this ->last_selection_has_atention ) {
168- LOG_F (9 , " %s: INQUIRY (%d bytes) with ATN LUN = %02x & 7" , this ->name .c_str (),
169- alloc_len, this ->last_selection_message );
170+ LOG_F (INFO , " %s: INQUIRY (%d bytes) with ATN LUN = %02x & 7" , this ->name .c_str (),
171+ alloc_len, this ->last_selection_message );
170172 lun = this ->last_selection_message & 7 ;
171173 }
172174 else {
173- LOG_F (9 , " %s: INQUIRY (%d bytes) with NO ATN LUN = %02x >> 5" , this ->name .c_str (),
174- alloc_len, cmd_buf [1 ]);
175- lun = cmd_buf [1 ] >> 5 ;
175+ LOG_F (INFO , " %s: INQUIRY (%d bytes) with NO ATN LUN = %02x >> 5" , this ->name .c_str (),
176+ alloc_len, cmd_ptr [1 ]);
177+ lun = cmd_ptr [1 ] >> 5 ;
176178 }
177179
178- this -> data_buf [0 ] = (lun == this ->lun ) ? 5 : 0x7f ; // device type: CD-ROM
179- this -> data_buf [1 ] = 0x80 ; // removable media
180- this -> data_buf [2 ] = 2 ; // ANSI version: SCSI-2
181- this -> data_buf [3 ] = 1 ; // response data format
182- this -> data_buf [4 ] = 0x1F ; // additional length
183- this -> data_buf [5 ] = 0 ;
184- this -> data_buf [6 ] = 0 ;
185- this -> data_buf [7 ] = 0x18 ; // supports synchronous xfers and linked commands
186- std::memcpy (&this -> data_buf [8 ], vendor_info, 8 );
187- std::memcpy (&this -> data_buf [16 ], prod_info, 16 );
188- std::memcpy (&this -> data_buf [32 ], rev_info, 4 );
189- // std::memcpy(&this->data_buf [36], serial_number, 8);
180+ data_ptr [0 ] = (lun == this ->lun ) ? 5 : 0x7f ; // device type: CD-ROM
181+ data_ptr [1 ] = 0x80 ; // removable media
182+ data_ptr [2 ] = 2 ; // ANSI version: SCSI-2
183+ data_ptr [3 ] = 1 ; // response data format
184+ data_ptr [4 ] = 0x1F ; // additional length
185+ data_ptr [5 ] = 0 ;
186+ data_ptr [6 ] = 0 ;
187+ data_ptr [7 ] = 0x18 ; // supports synchronous xfers and linked commands
188+ std::memcpy (&data_ptr [8 ], vendor_info, 8 );
189+ std::memcpy (&data_ptr [16 ], prod_info, 16 );
190+ std::memcpy (&data_ptr [32 ], rev_info, 4 );
191+ // std::memcpy(&data_ptr [36], serial_number, 8);
190192 // etc.
191193
192194 if (alloc_len < 36 ) {
193- LOG_F (ERROR, " Inappropriate Allocation Length: %d" , alloc_len);
195+ LOG_F (ERROR, " %s: allocation length too small: %d" , this ->name .c_str (),
196+ alloc_len);
194197 }
195198 else {
196- memset (&this -> data_buf [36 ], 0 , alloc_len - 36 );
199+ memset (&data_ptr [36 ], 0 , alloc_len - 36 );
197200 }
198201
199- this ->bytes_out = alloc_len;
200- this ->msg_buf [0 ] = ScsiMessage::COMMAND_COMPLETE;
201-
202- this ->switch_phase (ScsiPhase::DATA_IN);
202+ return alloc_len;
203203}
204204
205205static char Apple_Copyright_Page_Data[] = " APPLE COMPUTER, INC " ;
0 commit comments