]> Git Repo - qemu.git/blame - hw/scsi.h
scsi: move SCSIRequest management to common code.
[qemu.git] / hw / scsi.h
CommitLineData
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 */
8enum scsi_reason {
9 SCSI_REASON_DONE, /* Command complete. */
10 SCSI_REASON_DATA /* Transfer complete, more data required. */
11};
12
13typedef struct SCSIBus SCSIBus;
14typedef struct SCSIDevice SCSIDevice;
15typedef struct SCSIDeviceInfo SCSIDeviceInfo;
16typedef void (*scsi_completionfn)(SCSIBus *bus, int reason, uint32_t tag,
17 uint32_t arg);
18
4c41d2ef
GH
19typedef 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
28struct 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 */
37int cdrom_read_toc(int nb_sectors, uint8_t *buf, int msf, int start_track);
38int cdrom_read_toc_raw(int nb_sectors, uint8_t *buf, int msf, int session_num);
39
40/* scsi-bus.c */
41typedef int (*scsi_qdev_initfn)(SCSIDevice *dev);
42struct 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
54typedef void (*SCSIAttachFn)(DeviceState *host, BlockDriverState *bdrv,
55 int unit);
56struct SCSIBus {
57 BusState qbus;
58 int busnr;
59
60 int tcq, ndev;
61 scsi_completionfn complete;
62
63 SCSIDevice *devs[8];
64};
65
66void scsi_bus_new(SCSIBus *bus, DeviceState *host, int tcq, int ndev,
67 scsi_completionfn complete);
68void scsi_qdev_register(SCSIDeviceInfo *info);
69
70static inline SCSIBus *scsi_bus_from_device(SCSIDevice *d)
71{
72 return DO_UPCAST(SCSIBus, qbus, d->qdev.parent_bus);
73}
74
75SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, DriveInfo *dinfo, int unit);
76void scsi_bus_legacy_handle_cmdline(SCSIBus *bus);
77
89b08ae1
GH
78SCSIRequest *scsi_req_alloc(size_t size, SCSIDevice *d, uint32_t tag, uint32_t lun);
79SCSIRequest *scsi_req_find(SCSIDevice *d, uint32_t tag);
80void scsi_req_free(SCSIRequest *req);
81
43b443b6 82#endif
This page took 0.043802 seconds and 4 git commands to generate.