osdep: include glib-compat.h before other QEMU headers
[qemu/ar7.git] / include / hw / usb / msd.h
blob7538c54569bf16e710f29c7df934c7d79f317f11
1 /*
2 * USB Mass Storage Device emulation
4 * Copyright (c) 2006 CodeSourcery.
5 * Written by Paul Brook
7 * This code is licensed under the LGPL.
8 */
10 #include "hw/usb.h"
11 #include "hw/scsi/scsi.h"
13 enum USBMSDMode {
14 USB_MSDM_CBW, /* Command Block. */
15 USB_MSDM_DATAOUT, /* Transfer data to device. */
16 USB_MSDM_DATAIN, /* Transfer data from device. */
17 USB_MSDM_CSW /* Command Status. */
20 struct usb_msd_csw {
21 uint32_t sig;
22 uint32_t tag;
23 uint32_t residue;
24 uint8_t status;
27 struct MSDState {
28 USBDevice dev;
29 enum USBMSDMode mode;
30 uint32_t scsi_off;
31 uint32_t scsi_len;
32 uint32_t data_len;
33 struct usb_msd_csw csw;
34 SCSIRequest *req;
35 SCSIBus bus;
36 /* For async completion. */
37 USBPacket *packet;
38 /* usb-storage only */
39 BlockConf conf;
40 bool removable;
41 bool commandlog;
42 SCSIDevice *scsi_dev;
45 typedef struct MSDState MSDState;
46 #define TYPE_USB_STORAGE "usb-storage-dev"
47 DECLARE_INSTANCE_CHECKER(MSDState, USB_STORAGE_DEV,
48 TYPE_USB_STORAGE)
50 void usb_msd_transfer_data(SCSIRequest *req, uint32_t len);
51 void usb_msd_command_complete(SCSIRequest *req, size_t resid);
52 void usb_msd_request_cancelled(SCSIRequest *req);
53 void *usb_msd_load_request(QEMUFile *f, SCSIRequest *req);
54 void usb_msd_handle_reset(USBDevice *dev);