- prepared media change support in the SCSI cdrom code

This commit is contained in:
Volker Ruppert 2009-04-05 16:28:35 +00:00
parent fab6f61199
commit ccdd32c111
2 changed files with 9 additions and 2 deletions

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: scsi_device.cc,v 1.15 2009-04-03 16:42:56 vruppert Exp $
// $Id: scsi_device.cc,v 1.16 2009-04-05 16:28:35 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2007 Volker Ruppert
@ -53,6 +53,7 @@ scsi_device_t::scsi_device_t(device_image_t *_hdimage, int _tcq,
dev = _dev;
cluster_size = 1;
locked = 0;
inserted = 1;
max_lba = (hdimage->hd_size / 512) - 1;
sprintf(drive_serial_str, "%d", serial_number++);
@ -72,6 +73,7 @@ scsi_device_t::scsi_device_t(LOWLEVEL_CDROM *_cdrom, int _tcq,
dev = _dev;
cluster_size = 4;
locked = 0;
inserted = 1;
max_lba = cdrom->capacity() - 1;
sprintf(drive_serial_str, "%d", serial_number++);
@ -382,6 +384,8 @@ Bit32s scsi_device_t::scsi_send_command(Bit32u tag, Bit8u *buf, int lun)
switch (command) {
case 0x0:
BX_DEBUG(("Test Unit Ready"));
if (!inserted)
goto notready;
break;
case 0x03:
BX_DEBUG(("request Sense (len %d)", len));
@ -636,6 +640,7 @@ Bit32s scsi_device_t::scsi_send_command(Bit32u tag, Bit8u *buf, int lun)
outbuf[7] = 0;
r->buf_len = 8;
} else {
notready:
scsi_command_complete(r, STATUS_CHECK_CONDITION, SENSE_NOT_READY);
return 0;
}

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: scsi_device.h,v 1.10 2009-04-03 16:42:56 vruppert Exp $
// $Id: scsi_device.h,v 1.11 2009-04-05 16:28:35 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2007 Volker Ruppert
@ -79,6 +79,7 @@ public:
int scsi_write_data(Bit32u tag);
Bit8u* scsi_get_buf(Bit32u tag);
const char *get_serial_number() {return drive_serial_str;}
void set_inserted(bx_bool value) {inserted = value;}
protected:
SCSIRequest* scsi_new_request(Bit32u tag);
void scsi_remove_request(SCSIRequest *r);
@ -96,6 +97,7 @@ private:
scsi_completionfn completion;
void *dev;
bx_bool locked;
bx_bool inserted;
char drive_serial_str[21];
};