Merge branch 'upstream-merge'
[qemu-kvm/markmc.git] / hw / scsi-disk.h
blobb6b6c12666bf8ff46a43996ceae24c8a1837ca00
1 #ifndef SCSI_DISK_H
2 #define SCSI_DISK_H
4 #include "qdev.h"
6 /* scsi-disk.c */
7 enum scsi_reason {
8 SCSI_REASON_DONE, /* Command complete. */
9 SCSI_REASON_DATA /* Transfer complete, more data required. */
12 typedef struct SCSIBus SCSIBus;
13 typedef struct SCSIDevice SCSIDevice;
14 typedef struct SCSIDeviceInfo SCSIDeviceInfo;
15 typedef void (*scsi_completionfn)(SCSIBus *bus, int reason, uint32_t tag,
16 uint32_t arg);
18 struct SCSIDevice
20 DeviceState qdev;
21 uint32_t id;
22 SCSIDeviceInfo *info;
25 /* cdrom.c */
26 int cdrom_read_toc(int nb_sectors, uint8_t *buf, int msf, int start_track);
27 int cdrom_read_toc_raw(int nb_sectors, uint8_t *buf, int msf, int session_num);
29 /* scsi-bus.c */
30 typedef int (*scsi_qdev_initfn)(SCSIDevice *dev);
31 struct SCSIDeviceInfo {
32 DeviceInfo qdev;
33 scsi_qdev_initfn init;
34 void (*destroy)(SCSIDevice *s);
35 int32_t (*send_command)(SCSIDevice *s, uint32_t tag, uint8_t *buf,
36 int lun);
37 void (*read_data)(SCSIDevice *s, uint32_t tag);
38 int (*write_data)(SCSIDevice *s, uint32_t tag);
39 void (*cancel_io)(SCSIDevice *s, uint32_t tag);
40 uint8_t *(*get_buf)(SCSIDevice *s, uint32_t tag);
43 typedef void (*SCSIAttachFn)(DeviceState *host, BlockDriverState *bdrv,
44 int unit);
45 struct SCSIBus {
46 BusState qbus;
47 int busnr;
49 int tcq, ndev;
50 scsi_completionfn complete;
52 SCSIDevice *devs[8];
55 void scsi_bus_new(SCSIBus *bus, DeviceState *host, int tcq, int ndev,
56 scsi_completionfn complete);
57 void scsi_qdev_register(SCSIDeviceInfo *info);
59 static inline SCSIBus *scsi_bus_from_device(SCSIDevice *d)
61 return DO_UPCAST(SCSIBus, qbus, d->qdev.parent_bus);
64 SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, DriveInfo *dinfo, int unit);
65 void scsi_bus_legacy_handle_cmdline(SCSIBus *bus);
67 #endif