]>
Commit | Line | Data |
---|---|---|
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 */ |
7 | enum scsi_reason { | |
8 | SCSI_REASON_DONE, /* Command complete. */ | |
9 | SCSI_REASON_DATA /* Transfer complete, more data required. */ | |
10 | }; | |
11 | ||
d52affa7 | 12 | typedef struct SCSIBus SCSIBus; |
87ecb68b | 13 | typedef struct SCSIDevice SCSIDevice; |
d52affa7 GH |
14 | typedef struct SCSIDeviceInfo SCSIDeviceInfo; |
15 | typedef void (*scsi_completionfn)(SCSIBus *bus, int reason, uint32_t tag, | |
87ecb68b PB |
16 | uint32_t arg); |
17 | ||
8ccc2ace TS |
18 | struct SCSIDevice |
19 | { | |
d52affa7 GH |
20 | DeviceState qdev; |
21 | uint32_t id; | |
22 | SCSIDeviceInfo *info; | |
23 | }; | |
24 | ||
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); | |
28 | ||
29 | /* scsi-bus.c */ | |
30 | typedef int (*scsi_qdev_initfn)(SCSIDevice *dev); | |
31 | struct 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 |
43 | typedef void (*SCSIAttachFn)(DeviceState *host, BlockDriverState *bdrv, |
44 | int unit); | |
45 | struct 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 | ||
55 | SCSIBus *scsi_bus_new(DeviceState *host, int tcq, int ndev, | |
56 | scsi_completionfn complete); | |
57 | void scsi_qdev_register(SCSIDeviceInfo *info); | |
58 | ||
59 | static inline SCSIBus *scsi_bus_from_device(SCSIDevice *d) | |
60 | { | |
61 | return DO_UPCAST(SCSIBus, qbus, d->qdev.parent_bus); | |
62 | } | |
63 | ||
64 | SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, DriveInfo *dinfo, int unit); | |
65 | void scsi_bus_legacy_handle_cmdline(SCSIBus *bus); | |
87ecb68b PB |
66 | |
67 | #endif |