2 * USB Mass Storage Device emulation
4 * Copyright (c) 2006 CodeSourcery.
5 * Written by Paul Brook
7 * This code is licensed under the LGPL.
10 #include "qemu/osdep.h"
11 #include "qemu/typedefs.h"
12 #include "qapi/error.h"
14 #include "hw/usb/desc.h"
15 #include "hw/usb/msd.h"
17 static const struct SCSIBusInfo usb_msd_scsi_info_bot
= {
22 .transfer_data
= usb_msd_transfer_data
,
23 .complete
= usb_msd_command_complete
,
24 .cancel
= usb_msd_request_cancelled
,
25 .load_request
= usb_msd_load_request
,
28 static void usb_msd_bot_realize(USBDevice
*dev
, Error
**errp
)
30 MSDState
*s
= USB_STORAGE_DEV(dev
);
31 DeviceState
*d
= DEVICE(dev
);
33 usb_desc_create_serial(dev
);
35 dev
->flags
|= (1 << USB_DEV_FLAG_IS_SCSI_STORAGE
);
37 s
->dev
.auto_attach
= 0;
40 scsi_bus_new(&s
->bus
, sizeof(s
->bus
), DEVICE(dev
),
41 &usb_msd_scsi_info_bot
, NULL
);
42 usb_msd_handle_reset(dev
);
45 static void usb_msd_class_bot_initfn(ObjectClass
*klass
, void *data
)
47 USBDeviceClass
*uc
= USB_DEVICE_CLASS(klass
);
49 uc
->realize
= usb_msd_bot_realize
;
50 uc
->attached_settable
= true;
53 static const TypeInfo bot_info
= {
55 .parent
= TYPE_USB_STORAGE
,
56 .class_init
= usb_msd_class_bot_initfn
,
59 static void register_types(void)
61 type_register_static(&bot_info
);
64 type_init(register_types
)