- added instructions how to update the online documentation
[bochs-mirror.git] / iodev / scsi_device.h
blobef183dcd28fe8c071e77156a5e08b61de7c5b60a
1 /////////////////////////////////////////////////////////////////////////
2 // $Id: scsi_device.h,v 1.5 2007/09/28 19:52:05 sshwarts Exp $
3 /////////////////////////////////////////////////////////////////////////
4 //
5 // Copyright (C) 2007 Volker Ruppert
6 //
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,
27 Bit32u arg);
28 class scsi_device_t;
29 class LOWLEVEL_CDROM;
31 enum scsidev_type {
32 SCSIDEV_TYPE_DISK,
33 SCSIDEV_TYPE_CDROM
36 enum scsi_reason {
37 SCSI_REASON_DONE,
38 SCSI_REASON_DATA
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 {
49 scsi_device_t *dev;
50 Bit32u tag;
51 int sector;
52 int sector_count;
53 int buf_len;
54 Bit8u dma_buf[SCSI_DMA_BUF_SIZE];
55 struct SCSIRequest *next;
56 } SCSIRequest;
59 class scsi_device_t : public logfunctions {
60 public:
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);
76 protected:
77 SCSIRequest* scsi_new_request(Bit32u tag);
78 void scsi_remove_request(SCSIRequest *r);
79 SCSIRequest *scsi_find_request(Bit32u tag);
81 private:
82 enum scsidev_type type;
83 device_image_t *hdimage;
84 LOWLEVEL_CDROM *cdrom;
85 SCSIRequest *requests;
86 int cluster_size;
87 int sense;
88 int tcq;
89 scsi_completionfn completion;
90 void *dev;
93 #endif