1 /////////////////////////////////////////////////////////////////////////
2 // $Id: scsi_device.h,v 1.5 2007/09/28 19:52:05 sshwarts Exp $
3 /////////////////////////////////////////////////////////////////////////
5 // Copyright (C) 2007 Volker Ruppert
7 // This library is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU Lesser General Public
9 // License as published by the Free Software Foundation; either
10 // version 2 of the License, or (at your option) any later version.
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // Lesser General Public License for more details.
17 // You should have received a copy of the GNU Lesser General Public
18 // License along with this library; if not, write to the Free Software
19 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 // SCSI emulation layer ported from the Qemu project
23 #ifndef BX_IODEV_SCSI_DEVICE_H
24 #define BX_IODEV_SCSI_DEVICE_H
26 typedef void (*scsi_completionfn
)(void *opaque
, int reason
, Bit32u tag
,
41 #define SENSE_NO_SENSE 0
42 #define SENSE_NOT_READY 2
43 #define SENSE_HARDWARE_ERROR 4
44 #define SENSE_ILLEGAL_REQUEST 5
46 #define SCSI_DMA_BUF_SIZE 65536
48 typedef struct SCSIRequest
{
54 Bit8u dma_buf
[SCSI_DMA_BUF_SIZE
];
55 struct SCSIRequest
*next
;
59 class scsi_device_t
: public logfunctions
{
61 scsi_device_t(device_image_t
*_hdimage
, int _tcq
,
62 scsi_completionfn _completion
, void *_dev
);
63 scsi_device_t(LOWLEVEL_CDROM
*_cdrom
, int _tcq
,
64 scsi_completionfn _completion
, void *_dev
);
65 virtual ~scsi_device_t(void);
67 void register_state(bx_list_c
*parent
, const char *name
);
68 Bit32s
scsi_send_command(Bit32u tag
, Bit8u
*buf
, int lun
);
69 void scsi_command_complete(SCSIRequest
*r
, int sense
);
70 void scsi_cancel_io(Bit32u tag
);
71 void scsi_read_complete(void *req
, int ret
);
72 void scsi_read_data(Bit32u tag
);
73 void scsi_write_complete(void *req
, int ret
);
74 int scsi_write_data(Bit32u tag
);
75 Bit8u
* scsi_get_buf(Bit32u tag
);
77 SCSIRequest
* scsi_new_request(Bit32u tag
);
78 void scsi_remove_request(SCSIRequest
*r
);
79 SCSIRequest
*scsi_find_request(Bit32u tag
);
82 enum scsidev_type type
;
83 device_image_t
*hdimage
;
84 LOWLEVEL_CDROM
*cdrom
;
85 SCSIRequest
*requests
;
89 scsi_completionfn completion
;