msd.h (1335B)
1/* 2 * USB Mass Storage Device emulation 3 * 4 * Copyright (c) 2006 CodeSourcery. 5 * Written by Paul Brook 6 * 7 * This code is licensed under the LGPL. 8 */ 9 10#include "hw/usb.h" 11#include "hw/scsi/scsi.h" 12 13enum 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. */ 18}; 19 20struct usb_msd_csw { 21 uint32_t sig; 22 uint32_t tag; 23 uint32_t residue; 24 uint8_t status; 25}; 26 27struct 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; 43}; 44 45typedef struct MSDState MSDState; 46#define TYPE_USB_STORAGE "usb-storage-dev" 47DECLARE_INSTANCE_CHECKER(MSDState, USB_STORAGE_DEV, 48 TYPE_USB_STORAGE) 49 50void usb_msd_transfer_data(SCSIRequest *req, uint32_t len); 51void usb_msd_command_complete(SCSIRequest *req, size_t resid); 52void usb_msd_request_cancelled(SCSIRequest *req); 53void *usb_msd_load_request(QEMUFile *f, SCSIRequest *req); 54void usb_msd_handle_reset(USBDevice *dev);