- implementation of save/restore for the SCSI emulation started

- SCSI buffer length fixes ported from the Qemu project
This commit is contained in:
Volker Ruppert 2007-05-05 12:30:23 +00:00
parent 65a99eb736
commit e88a8b48a1
4 changed files with 35 additions and 16 deletions

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: scsi_device.cc,v 1.3 2007-03-18 15:18:02 vruppert Exp $
// $Id: scsi_device.cc,v 1.4 2007-05-05 12:30:23 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2007 Volker Ruppert
@ -75,6 +75,15 @@ scsi_device_t::~scsi_device_t(void)
{
}
#if BX_SUPPORT_SAVE_RESTORE
void scsi_device_t::register_state(bx_list_c *parent, const char *name)
{
bx_list_c *list = new bx_list_c(parent, name, "", 1);
new bx_shadow_num_c(list, "sense", &sense);
// TODO: save/restore for SCSI requests
}
#endif
SCSIRequest* scsi_device_t::scsi_new_request(Bit32u tag)
{
SCSIRequest *r;
@ -344,7 +353,7 @@ Bit32s scsi_device_t::scsi_send_command(Bit32u tag, Bit8u *buf, int lun)
BX_DEBUG(("request Sense (len %d)", len));
if (len < 4)
goto fail;
memset(buf, 0, 4);
memset(outbuf, 0, 4);
outbuf[0] = 0xf0;
outbuf[1] = 0;
outbuf[2] = sense;
@ -368,7 +377,7 @@ Bit32s scsi_device_t::scsi_send_command(Bit32u tag, Bit8u *buf, int lun)
memcpy(&outbuf[32], "1.0", 4);
outbuf[2] = 3;
outbuf[3] = 2;
outbuf[4] = 32;
outbuf[4] = 31;
outbuf[7] = 0x10 | (tcq ? 0x02 : 0);
r->buf_len = 36;
break;
@ -400,10 +409,11 @@ Bit32s scsi_device_t::scsi_send_command(Bit32u tag, Bit8u *buf, int lun)
p += 4;
if ((page == 8 || page == 0x3f)) {
/* Caching page. */
memset(p, 0, 20);
p[0] = 8;
p[1] = 0x12;
p[2] = 4; /* WCE */
p += 19;
p += 20;
}
if ((page == 0x3f || page == 0x2a)
&& (type == SCSIDEV_TYPE_CDROM)) {
@ -432,7 +442,7 @@ Bit32s scsi_device_t::scsi_send_command(Bit32u tag, Bit8u *buf, int lun)
p[19] = (16 * 176) & 0xff;
p[20] = (16 * 176) >> 8; // 16x write speed current
p[21] = (16 * 176) & 0xff;
p += 21;
p += 22;
}
r->buf_len = p - outbuf;
outbuf[0] = r->buf_len - 4;

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: scsi_device.h,v 1.3 2007-03-18 15:18:02 vruppert Exp $
// $Id: scsi_device.h,v 1.4 2007-05-05 12:30:23 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2007 Volker Ruppert
@ -64,6 +64,9 @@ public:
scsi_completionfn _completion, void *_dev);
virtual ~scsi_device_t(void);
#if BX_SUPPORT_SAVE_RESTORE
void register_state(bx_list_c *parent, const char *name);
#endif
Bit32s scsi_send_command(Bit32u tag, Bit8u *buf, int lun);
void scsi_command_complete(SCSIRequest *r, int sense);
void scsi_cancel_io(Bit32u tag);

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: usb_msd.cc,v 1.4 2007-04-09 09:04:54 vruppert Exp $
// $Id: usb_msd.cc,v 1.5 2007-05-05 12:30:23 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2007 Volker Ruppert
@ -155,6 +155,9 @@ bx_bool usb_msd_device_t::init(const char *filename)
return 0;
} else {
s.scsi_dev = new scsi_device_t(s.hdimage, 0, usb_msd_command_complete, (void*)this);
#if BX_SUPPORT_SAVE_RESTORE
s.scsi_dev->register_state(s.sr_list, "scsidev");
#endif
s.mode = USB_MSDM_CBW;
d.connected = 1;
return 1;
@ -164,14 +167,14 @@ bx_bool usb_msd_device_t::init(const char *filename)
#if BX_SUPPORT_SAVE_RESTORE
void usb_msd_device_t::register_state_specific(bx_list_c *parent)
{
bx_list_c *list = new bx_list_c(parent, "s", "USB MSD Device State", 7);
new bx_shadow_num_c(list, "mode", &s.mode);
new bx_shadow_num_c(list, "scsi_len", &s.scsi_len);
new bx_shadow_num_c(list, "usb_len", &s.usb_len);
new bx_shadow_num_c(list, "data_len", &s.data_len);
new bx_shadow_num_c(list, "residue", &s.residue);
new bx_shadow_num_c(list, "tag", &s.tag);
new bx_shadow_num_c(list, "result", &s.result);
s.sr_list = new bx_list_c(parent, "s", "USB MSD Device State", 8);
new bx_shadow_num_c(s.sr_list, "mode", &s.mode);
new bx_shadow_num_c(s.sr_list, "scsi_len", &s.scsi_len);
new bx_shadow_num_c(s.sr_list, "usb_len", &s.usb_len);
new bx_shadow_num_c(s.sr_list, "data_len", &s.data_len);
new bx_shadow_num_c(s.sr_list, "residue", &s.residue);
new bx_shadow_num_c(s.sr_list, "tag", &s.tag);
new bx_shadow_num_c(s.sr_list, "result", &s.result);
}
#endif

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: usb_msd.h,v 1.3 2007-04-09 09:04:54 vruppert Exp $
// $Id: usb_msd.h,v 1.4 2007-05-05 12:30:23 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2007 Volker Ruppert
@ -58,6 +58,9 @@ private:
device_image_t *hdimage;
scsi_device_t *scsi_dev;
USBPacket *packet;
#if BX_SUPPORT_SAVE_RESTORE
bx_list_c *sr_list;
#endif
} s;
};