]> Git Repo - qemu.git/blame - hw/scsi-disk.h
qdev/scsi: add scsi bus support to qdev, convert drivers.
[qemu.git] / hw / scsi-disk.h
CommitLineData
87ecb68b
PB
1#ifndef SCSI_DISK_H
2#define SCSI_DISK_H
3
d52affa7
GH
4#include "qdev.h"
5
87ecb68b
PB
6/* scsi-disk.c */
7enum scsi_reason {
8 SCSI_REASON_DONE, /* Command complete. */
9 SCSI_REASON_DATA /* Transfer complete, more data required. */
10};
11
d52affa7 12typedef struct SCSIBus SCSIBus;
87ecb68b 13typedef struct SCSIDevice SCSIDevice;
d52affa7
GH
14typedef struct SCSIDeviceInfo SCSIDeviceInfo;
15typedef void (*scsi_completionfn)(SCSIBus *bus, int reason, uint32_t tag,
87ecb68b
PB
16 uint32_t arg);
17
8ccc2ace
TS
18struct SCSIDevice
19{
d52affa7
GH
20 DeviceState qdev;
21 uint32_t id;
22 SCSIDeviceInfo *info;
23};
24
25/* cdrom.c */
26int cdrom_read_toc(int nb_sectors, uint8_t *buf, int msf, int start_track);
27int cdrom_read_toc_raw(int nb_sectors, uint8_t *buf, int msf, int session_num);
28
29/* scsi-bus.c */
30typedef int (*scsi_qdev_initfn)(SCSIDevice *dev);
31struct SCSIDeviceInfo {
32 DeviceInfo qdev;
33 scsi_qdev_initfn init;
8ccc2ace
TS
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);
41};
87ecb68b 42
d52affa7
GH
43typedef void (*SCSIAttachFn)(DeviceState *host, BlockDriverState *bdrv,
44 int unit);
45struct SCSIBus {
46 BusState qbus;
47 int busnr;
87ecb68b 48
d52affa7
GH
49 int tcq, ndev;
50 scsi_completionfn complete;
51
52 SCSIDevice *devs[8];
53};
54
55SCSIBus *scsi_bus_new(DeviceState *host, int tcq, int ndev,
56 scsi_completionfn complete);
57void scsi_qdev_register(SCSIDeviceInfo *info);
58
59static inline SCSIBus *scsi_bus_from_device(SCSIDevice *d)
60{
61 return DO_UPCAST(SCSIBus, qbus, d->qdev.parent_bus);
62}
63
64SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, DriveInfo *dinfo, int unit);
65void scsi_bus_legacy_handle_cmdline(SCSIBus *bus);
87ecb68b
PB
66
67#endif
This page took 0.257407 seconds and 4 git commands to generate.