]>
Commit | Line | Data |
---|---|---|
1e37607b GH |
1 | #ifndef QEMU_HW_SCSI_H |
2 | #define QEMU_HW_SCSI_H | |
43b443b6 GH |
3 | |
4 | #include "qdev.h" | |
4c41d2ef | 5 | #include "block.h" |
43b443b6 GH |
6 | |
7 | /* scsi-disk.c */ | |
8 | enum scsi_reason { | |
9 | SCSI_REASON_DONE, /* Command complete. */ | |
10 | SCSI_REASON_DATA /* Transfer complete, more data required. */ | |
11 | }; | |
12 | ||
13 | typedef struct SCSIBus SCSIBus; | |
14 | typedef struct SCSIDevice SCSIDevice; | |
15 | typedef struct SCSIDeviceInfo SCSIDeviceInfo; | |
16 | typedef void (*scsi_completionfn)(SCSIBus *bus, int reason, uint32_t tag, | |
17 | uint32_t arg); | |
18 | ||
4c41d2ef GH |
19 | typedef struct SCSIRequest { |
20 | SCSIBus *bus; | |
21 | SCSIDevice *dev; | |
22 | uint32_t tag; | |
89b08ae1 | 23 | uint32_t lun; |
4c41d2ef | 24 | BlockDriverAIOCB *aiocb; |
9af99d98 | 25 | QTAILQ_ENTRY(SCSIRequest) next; |
4c41d2ef GH |
26 | } SCSIRequest; |
27 | ||
43b443b6 GH |
28 | struct SCSIDevice |
29 | { | |
30 | DeviceState qdev; | |
31 | uint32_t id; | |
32 | SCSIDeviceInfo *info; | |
9af99d98 | 33 | QTAILQ_HEAD(, SCSIRequest) requests; |
43b443b6 GH |
34 | }; |
35 | ||
36 | /* cdrom.c */ | |
37 | int cdrom_read_toc(int nb_sectors, uint8_t *buf, int msf, int start_track); | |
38 | int cdrom_read_toc_raw(int nb_sectors, uint8_t *buf, int msf, int session_num); | |
39 | ||
40 | /* scsi-bus.c */ | |
41 | typedef int (*scsi_qdev_initfn)(SCSIDevice *dev); | |
42 | struct SCSIDeviceInfo { | |
43 | DeviceInfo qdev; | |
44 | scsi_qdev_initfn init; | |
45 | void (*destroy)(SCSIDevice *s); | |
46 | int32_t (*send_command)(SCSIDevice *s, uint32_t tag, uint8_t *buf, | |
47 | int lun); | |
48 | void (*read_data)(SCSIDevice *s, uint32_t tag); | |
49 | int (*write_data)(SCSIDevice *s, uint32_t tag); | |
50 | void (*cancel_io)(SCSIDevice *s, uint32_t tag); | |
51 | uint8_t *(*get_buf)(SCSIDevice *s, uint32_t tag); | |
52 | }; | |
53 | ||
54 | typedef void (*SCSIAttachFn)(DeviceState *host, BlockDriverState *bdrv, | |
55 | int unit); | |
56 | struct SCSIBus { | |
57 | BusState qbus; | |
58 | int busnr; | |
59 | ||
60 | int tcq, ndev; | |
61 | scsi_completionfn complete; | |
62 | ||
63 | SCSIDevice *devs[8]; | |
64 | }; | |
65 | ||
66 | void scsi_bus_new(SCSIBus *bus, DeviceState *host, int tcq, int ndev, | |
67 | scsi_completionfn complete); | |
68 | void scsi_qdev_register(SCSIDeviceInfo *info); | |
69 | ||
70 | static inline SCSIBus *scsi_bus_from_device(SCSIDevice *d) | |
71 | { | |
72 | return DO_UPCAST(SCSIBus, qbus, d->qdev.parent_bus); | |
73 | } | |
74 | ||
75 | SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, DriveInfo *dinfo, int unit); | |
76 | void scsi_bus_legacy_handle_cmdline(SCSIBus *bus); | |
77 | ||
89b08ae1 GH |
78 | SCSIRequest *scsi_req_alloc(size_t size, SCSIDevice *d, uint32_t tag, uint32_t lun); |
79 | SCSIRequest *scsi_req_find(SCSIDevice *d, uint32_t tag); | |
80 | void scsi_req_free(SCSIRequest *req); | |
81 | ||
43b443b6 | 82 | #endif |