- applied parts of the new USB patch by Ben Lunt

- removed max_packet_size member from USB device structure
- usb_uhci: improved speed info
- updated USB-related documentation
- TODO: review and test the main part of the xHCI changes by Ben
This commit is contained in:
Volker Ruppert 2014-09-22 19:49:39 +00:00
parent 86bb2f97cc
commit 50e96fa1cd
12 changed files with 280 additions and 70 deletions

View File

@ -1028,9 +1028,11 @@ speaker: enabled=1, mode=sound
# 'hub' and 'printer').
#
# The optionsX parameter can be used to assign specific options to the device
# connected to the corresponding USB port. Currently this feature is only used
# to set the speed reported by device and by the 'disk' device to specify
# an alternative redolog file of some image modes.
# connected to the corresponding USB port. Currently this feature is used to
# set the speed reported by device ('low', 'full', 'high' or 'super'). The
# availabe speed choices depend on both HC and device. For the USB 'disk' device
# the optionsX parameter can be used to specify an alternative redolog file
# (journal) of some image modes.
#
# If you connect the mouse or tablet to one of the ports, Bochs forwards the
# mouse movement data to the USB device instead of the selected mouse type.
@ -1058,14 +1060,16 @@ speaker: enabled=1, mode=sound
#usb_uhci: enabled=1
#usb_uhci: enabled=1, port1=mouse, port2=disk:usbstick.img
#usb_uhci: enabled=1, port1=hub:7, port2=disk:growing:usbdisk.img
#usb_uhci: enabled=1, port2=disk:undoable:usbdisk.img, options1=journal:redo.log
#usb_uhci: enabled=1, port2=disk:undoable:usbdisk.img, options2=journal:redo.log
#usb_uhci: enabled=1, port2=disk:vvfat:vvfat, options2=speed:full
#usb_uhci: enabled=1, port1=printer:printdata.bin, port2=cdrom:image.iso
#=======================================================================
# USB_OHCI:
# This option controls the presence of the USB OHCI host controller with a
# 2-port hub. The portX option accepts the same device types with the same
# syntax as the UHCI controller (see above).
# 2-port hub. The portX parameter accepts the same device types with the same
# syntax as the UHCI controller (see above). The optionsX parameter is also
# available on OHCI.
#=======================================================================
#usb_ohci: enabled=1
#usb_ohci: enabled=1, port1=printer:usbprinter.bin
@ -1073,8 +1077,9 @@ speaker: enabled=1, mode=sound
#=======================================================================
# USB_XHCI:
# This option controls the presence of the experimental USB xHCI host controller
# with a 4-port hub. The portX option accepts the same device types with the
# same syntax as the UHCI controller (see above).
# with a 4-port hub. The portX paramter accepts the same device types with the
# same syntax as the UHCI controller (see above). The optionsX parameter is
# also available on xHCI.
#=======================================================================
#usb_xhci: enabled=1

View File

@ -4665,7 +4665,8 @@ Examples:
<screen>
usb_uhci: enabled=1, port1=mouse, port2=disk:usbstick.img
usb_uhci: enabled=1, port1=hub:7, port2=disk:growing:usbdisk.img
usb_uhci: enabled=1, port2=disk:undoable:usbdisk.img, options1=journal:redo.log
usb_uhci: enabled=1, port2=disk:undoable:usbdisk.img, options2=journal:redo.log
usb_uhci: enabled=1, port2=disk:vvfat:vvfat, options2=speed:full
usb_uhci: enabled=1, port1=printer:printdata.bin, port2=cdrom:image.iso
</screen>
This option controls the presence of the USB root hub which is a part of the
@ -4679,8 +4680,10 @@ to the hub (currently supported: 'mouse', 'tablet', 'keypad', 'disk', 'cdrom',
<para>
The options<replaceable>X</replaceable> parameter can be used to assign specific
options to the device connected to the corresponding USB port. Currently this
feature is only used to set the speed reported by device and by the 'disk'
device to specify an alternative redolog file of some image modes.
feature is used to set the speed reported by device ('low', 'full', 'high' or
'super'). The availabe speed choices depend on both HC and device. For the USB
'disk' device the optionsX parameter can be used to specify an alternative
redolog file (journal) of some image modes.
</para>
<para>
If you connect the mouse or tablet to one of the ports, Bochs forwards the
@ -4722,9 +4725,9 @@ Example:
usb_ohci: enabled=1, port1=printer:printdata.bin
</screen>
This option controls the presence of the USB OHCI host controller with a
2-port hub. The portX option accepts the same device types with the same
2-port hub. The portX parameter accepts the same device types with the same
syntax as the UHCI controller (see the <link linkend="bochsopt-usb-uhci">usb_uhci option</link>).
</para>
The optionsX parameter is also available on OHCI.</para>
</section>
<section id="bochsopt-usb-xhci"><title>usb_xhci</title>
@ -4734,9 +4737,9 @@ Example:
usb_xhci: enabled=1
</screen>
This option controls the presence of the experimental USB xHCI host controller
with a 4-port hub. The portX option accepts the same device types with the same
with a 4-port hub. The portX parameter accepts the same device types with the same
syntax as the UHCI controller (see the <link linkend="bochsopt-usb-uhci">usb_uhci option</link>).
</para>
The optionsX parameter is also available on xHCI.</para>
</section>
<section><title>pcidev</title>

View File

@ -1,5 +1,5 @@
.\"Document Author: Timothy R. Butler - tbutler@uninetsolutions.com"
.TH bochsrc 5 "7 Jul 2014" "bochsrc" "The Bochs Project"
.TH bochsrc 5 "22 Sep 2014" "bochsrc" "The Bochs Project"
.\"SKIP_SECTION"
.SH NAME
bochsrc \- Configuration file for Bochs.
@ -1147,9 +1147,11 @@ to the hub (currently supported: 'mouse', 'tablet', 'keypad', 'disk', 'cdrom',
'hub' and 'printer').
The optionsX parameter can be used to assign specific options to the device
connected to the corresponding USB port. Currently this feature is only used
to set the speed reported by device and by the 'disk' device to specify
an alternative redolog file of some image modes.
connected to the corresponding USB port. Currently this feature is used to
set the speed reported by device ('low', 'full', 'high' or 'super'). The
availabe speed choices depend on both HC and device. For the USB 'disk' device
the optionsX parameter can be used to specify an alternative redolog file
(journal) of some image modes.
If you connect the mouse or tablet to one of the ports, Bochs forwards the
mouse movement data to the USB device instead of the selected mouse type.
@ -1172,13 +1174,15 @@ overwrite the file instead, asking user first.
Example:
usb_uhci: enabled=1, port1=mouse, port2=disk:usbstick.img
usb_uhci: enabled=1, port1=hub:7, port2=disk:growing:usbdisk.img
usb_uhci: enabled=1, port2=disk:vvfat:vvfat, options2=speed:full
usb_uhci: enabled=1, port1=printer:printdata.bin, port2=cdrom:image.iso
.TP
.I "usb_ohci:"
This option controls the presence of the USB OHCI host controller with a
2-port hub. The portX option accepts the same device types with the same
syntax as the UHCI controller (see above).
2-port hub. The portX parameter accepts the same device types with the same
syntax as the UHCI controller (see above). The optionsX parameter is also
available on OHCI.
Example:
usb_ohci: enabled=1
@ -1186,8 +1190,9 @@ Example:
.TP
.I "usb_xhci:"
This option controls the presence of the experimental USB xHCI host controller
with a 4-port hub. The portX option accepts the same device types with the same
syntax as the UHCI controller (see above).
with a 4-port hub. The portX parameter accepts the same device types with the
same syntax as the UHCI controller (see above). The optionsX parameter is also
available on xHCI.
Example:
usb_xhci: enabled=1

View File

@ -144,7 +144,7 @@ void bx_usb_devctl_c::parse_port_options(usb_device_c *device, bx_list_c *portco
const char *raw_options;
char *options;
unsigned i, string_i;
int optc, speed = USB_SPEED_LOW;
int optc, speed = USB_SPEED_LOW; // assume LOW speed device if parameter not given.
char *opts[16];
char *ptr;
char string[512];

View File

@ -6,7 +6,7 @@
//
// Copyright (c) 2005 Fabrice Bellard
// Copyright (C) 2009 Benjamin D Lunt (fys at frontiernet net)
// 2009-2013 The Bochs Project
// 2009-2014 The Bochs Project
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@ -86,20 +86,23 @@
#define EndpointOutRequest \
((USB_DIR_OUT|USB_TYPE_STANDARD|USB_RECIP_ENDPOINT)<<8)
#define USB_REQ_GET_STATUS 0x00
#define USB_REQ_CLEAR_FEATURE 0x01
#define USB_REQ_SET_FEATURE 0x03
#define USB_REQ_SET_ADDRESS 0x05
#define USB_REQ_GET_DESCRIPTOR 0x06
#define USB_REQ_SET_DESCRIPTOR 0x07
#define USB_REQ_GET_CONFIGURATION 0x08
#define USB_REQ_SET_CONFIGURATION 0x09
#define USB_REQ_GET_INTERFACE 0x0A
#define USB_REQ_SET_INTERFACE 0x0B
#define USB_REQ_SYNCH_FRAME 0x0C
#define USB_REQ_GET_STATUS 0x00
#define USB_REQ_CLEAR_FEATURE 0x01
#define USB_REQ_SET_FEATURE 0x03
#define USB_REQ_SET_ADDRESS 0x05
#define USB_REQ_GET_DESCRIPTOR 0x06
#define USB_REQ_SET_DESCRIPTOR 0x07
#define USB_REQ_GET_CONFIGURATION 0x08
#define USB_REQ_SET_CONFIGURATION 0x09
#define USB_REQ_GET_INTERFACE 0x0A
#define USB_REQ_SET_INTERFACE 0x0B
#define USB_REQ_SYNCH_FRAME 0x0C
#define USB_REQ_SET_SEL 0x30
#define USB_DEVICE_SELF_POWERED 0
#define USB_DEVICE_REMOTE_WAKEUP 1
#define USB_DEVICE_SELF_POWERED 0
#define USB_DEVICE_REMOTE_WAKEUP 1
#define USB_DEVICE_U1_ENABLE 48
#define USB_DEVICE_U2_ENABLE 49
// USB 1.1
#define USB_DT_DEVICE 0x01
@ -111,6 +114,8 @@
#define USB_DT_DEVICE_QUALIFIER 0x06
#define USB_DT_OTHER_SPEED_CONFIG 0x07
#define USB_DT_INTERFACE_POWER 0x08
// USB 3.0
#define USB_DT_BIN_DEV_OBJ_STORE 0x0F
class usb_device_c;
@ -169,7 +174,6 @@ public:
int get_speed() {return d.speed;}
void set_speed(int speed) {d.speed = speed;}
Bit8u get_address() {return d.addr;}
int get_max_packet_size() {return d.max_packet_size;}
void usb_send_msg(int msg);
@ -190,7 +194,6 @@ protected:
int setup_state;
int setup_len;
int setup_index;
int max_packet_size;
bx_bool stall;
} d;

View File

@ -7,7 +7,7 @@
//
// Copyright (c) 2005 Fabrice Bellard
// Copyright (c) 2007 OpenMoko, Inc. (andrew@openedhand.com)
// Copyright (C) 2009-2012 The Bochs Project
// Copyright (C) 2009-2014 The Bochs Project
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@ -414,7 +414,6 @@ usb_hid_device_c::usb_hid_device_c(usbdev_type type)
d.type = type;
d.maxspeed = USB_SPEED_LOW;
d.speed = d.maxspeed;
// TODO: d.max_packet_size = ???
if (d.type == USB_DEV_TYPE_MOUSE) {
strcpy(d.devname, "USB Mouse");
DEV_register_removable_mouse((void*)this, mouse_enq_static, mouse_enabled_changed);

View File

@ -5,7 +5,7 @@
// USB hub emulation support (ported from QEMU)
//
// Copyright (C) 2005 Fabrice Bellard
// Copyright (C) 2009-2013 The Bochs Project
// Copyright (C) 2009-2014 The Bochs Project
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@ -177,7 +177,6 @@ usb_hub_device_c::usb_hub_device_c(Bit8u ports)
d.type = USB_DEV_TYPE_HUB;
d.maxspeed = USB_SPEED_FULL;
d.speed = d.maxspeed;
// TODO: d.max_packet_size = ???
strcpy(d.devname, "Bochs USB HUB");
d.connected = 1;
memset((void*)&hub, 0, sizeof(hub));

View File

@ -67,6 +67,7 @@ struct usb_msd_csw {
#define MassStorageReset 0xff
#define GetMaxLun 0xfe
// Low-, Full-, and High-speed
static const Bit8u bx_msd_dev_descriptor[] = {
0x12, /* u8 bLength; */
0x01, /* u8 bDescriptorType; Device */
@ -88,6 +89,7 @@ static const Bit8u bx_msd_dev_descriptor[] = {
0x01 /* u8 bNumConfigurations; */
};
// Low-, Full-, and High-speed
static const Bit8u bx_msd_config_descriptor[] = {
/* one configuration */
@ -132,8 +134,112 @@ static const Bit8u bx_msd_config_descriptor[] = {
0x00 /* u8 ep_bInterval; */
};
static int usb_cdrom_count = 0;
// Super-speed
static const Bit8u bx_msd_dev_descriptor3[] = {
0x12, /* u8 bLength; */
0x01, /* u8 bDescriptorType; Device */
0x00, 0x03, /* u16 bcdUSB; v3.0 */
0x00, /* u8 bDeviceClass; */
0x00, /* u8 bDeviceSubClass; */
0x00, /* u8 bDeviceProtocol; */
0x09, /* u8 bMaxPacketSize0; 2^^9 = 512 Bytes */
/* Vendor and product id are arbitrary. */
0x00, 0x00, /* u16 idVendor; */
0x00, 0x00, /* u16 idProduct; */
0x00, 0x01, /* u16 bcdDevice */
0x01, /* u8 iManufacturer; */
0x02, /* u8 iProduct; */
0x03, /* u8 iSerialNumber; */
0x01 /* u8 bNumConfigurations; */
};
static const Bit8u bx_msd_config_descriptor3[] = {
/* one configuration */
0x09, /* u8 bLength; */
0x02, /* u8 bDescriptorType; Configuration */
0x2C, 0x00, /* u16 wTotalLength; */
0x01, /* u8 bNumInterfaces; (1) */
0x01, /* u8 bConfigurationValue; */
0x00, /* u8 iConfiguration; */
0x80, /* u8 bmAttributes;
Bit 7: must be set,
6: Self-powered,
5: Remote wakeup,
4..0: resvd */
0x3F, /* u8 MaxPower; */
/* one interface */
0x09, /* u8 if_bLength; */
0x04, /* u8 if_bDescriptorType; Interface */
0x00, /* u8 if_bInterfaceNumber; */
0x00, /* u8 if_bAlternateSetting; */
0x02, /* u8 if_bNumEndpoints; */
0x08, /* u8 if_bInterfaceClass; MASS STORAGE */
0x06, /* u8 if_bInterfaceSubClass; SCSI */
0x50, /* u8 if_bInterfaceProtocol; Bulk Only */
0x00, /* u8 if_iInterface; */
/* Bulk-In endpoint */
0x07, /* u8 ep_bLength; */
0x05, /* u8 ep_bDescriptorType; Endpoint */
0x81, /* u8 ep_bEndpointAddress; IN Endpoint 1 */
0x02, /* u8 ep_bmAttributes; Bulk */
0x00, 0x04, /* u16 ep_wMaxPacketSize; */
0x00, /* u8 ep_bInterval; */
/* Bulk-In companion descriptor */
0x06, /* u8 epc_bLength; */
0x30, /* u8 epc_bDescriptorType; Endpoint Companion */
0x0F, /* u8 epc_bMaxPerBurst; */
0x00, /* u8 epc_bmAttributes; */
0x00, 0x00, /* u16 epc_reserved; */
/* Bulk-Out endpoint */
0x07, /* u8 ep_bLength; */
0x05, /* u8 ep_bDescriptorType; Endpoint */
0x02, /* u8 ep_bEndpointAddress; OUT Endpoint 2 */
0x02, /* u8 ep_bmAttributes; Bulk */
0x00, 0x04, /* u16 ep_wMaxPacketSize; */
0x00, /* u8 ep_bInterval; */
/* Bulk-Out companion descriptor */
0x06, /* u8 epc_bLength; */
0x30, /* u8 epc_bDescriptorType; Endpoint Companion */
0x0F, /* u8 epc_bMaxPerBurst; */
0x00, /* u8 epc_bmAttributes; */
0x00, 0x00 /* u16 epc_reserved; */
};
// BOS Descriptor
static const Bit8u bx_msd_bos_descriptor3[] = {
/* stub */
0x05, /* u8 bos_bLength; */
0x0F, /* u8 bos_bDescriptorType; BOS */
0x16, 0x00, /* u16 bos_wTotalLength; */
0x02, /* u8 bos_bNumCapEntries; BOS */
/* USB 2.0 Extention */
0x07, /* u8 bss_bLength; */
0x10, /* u8 bss_bType; Device Cap */
0x02, /* u8 bss_bCapType; USB 2.0 Ext */
0x02, 0x00, /* u32 bss_bmAttributes; */
0x00, 0x00,
/* USB 3.0 */
0x0A, /* u8 bss_bLength; */
0x10, /* u8 bss_bType; Device Cap */
0x03, /* u8 bss_bCapType; USB 3.0 */
0x00, /* u8 bss_bmAttributes; */
0x0E, 0x00, /* u16 bss_bmSupSpeeds; */
0x01, /* u8 bss_bSupFunct; */
0x0A, /* u8 bss_bU1DevExitLat; */
0x20, 0x00 /* u16 bss_wU2DevExitLat; */
};
static int usb_cdrom_count = 0;
usb_msd_device_c::usb_msd_device_c(usbdev_type type, const char *filename)
{
@ -145,9 +251,7 @@ usb_msd_device_c::usb_msd_device_c(usbdev_type type, const char *filename)
bx_param_enum_c *status;
d.type = type;
d.maxspeed = USB_SPEED_FULL;
d.speed = d.maxspeed;
// TODO: d.max_packet_size = ???
d.maxspeed = USB_SPEED_SUPER;
memset((void*)&s, 0, sizeof(s));
if (d.type == USB_DEV_TYPE_DISK) {
strcpy(d.devname, "BOCHS USB HARDDRIVE");
@ -278,42 +382,66 @@ int usb_msd_device_c::handle_control(int request, int value, int index, int leng
switch (request) {
case DeviceRequest | USB_REQ_GET_STATUS:
case EndpointRequest | USB_REQ_GET_STATUS:
BX_DEBUG(("USB_REQ_GET_STATUS:"));
data[0] = (1 << USB_DEVICE_SELF_POWERED) |
(d.remote_wakeup << USB_DEVICE_REMOTE_WAKEUP);
data[1] = 0x00;
ret = 2;
break;
case DeviceOutRequest | USB_REQ_CLEAR_FEATURE:
BX_DEBUG(("USB_REQ_CLEAR_FEATURE:"));
if (value == USB_DEVICE_REMOTE_WAKEUP) {
d.remote_wakeup = 0;
} else {
BX_DEBUG(("USB_REQ_CLEAR_FEATURE: Not handled: %i %i %i %i", request, value, index, length ));
goto fail;
}
ret = 0;
break;
case DeviceOutRequest | USB_REQ_SET_FEATURE:
if (value == USB_DEVICE_REMOTE_WAKEUP) {
d.remote_wakeup = 1;
} else {
BX_DEBUG(("USB_REQ_SET_FEATURE:"));
switch (value) {
case USB_DEVICE_REMOTE_WAKEUP:
d.remote_wakeup = 1;
break;
case USB_DEVICE_U1_ENABLE:
case USB_DEVICE_U2_ENABLE:
break;
default:
BX_DEBUG(("USB_REQ_SET_FEATURE: Not handled: %i %i %i %i", request, value, index, length ));
goto fail;
}
ret = 0;
break;
case DeviceOutRequest | USB_REQ_SET_ADDRESS:
BX_DEBUG(("USB_REQ_SET_ADDRESS:"));
d.addr = value;
ret = 0;
break;
case DeviceRequest | USB_REQ_GET_DESCRIPTOR:
switch(value >> 8) {
switch (value >> 8) {
case USB_DT_DEVICE:
memcpy(data, bx_msd_dev_descriptor, sizeof(bx_msd_dev_descriptor));
ret = sizeof(bx_msd_dev_descriptor);
BX_DEBUG(("USB_REQ_GET_DESCRIPTOR: Device"));
if (get_speed() == USB_SPEED_SUPER) {
memcpy(data, bx_msd_dev_descriptor3, sizeof(bx_msd_dev_descriptor3));
ret = sizeof(bx_msd_dev_descriptor3);
} else {
memcpy(data, bx_msd_dev_descriptor, sizeof(bx_msd_dev_descriptor));
ret = sizeof(bx_msd_dev_descriptor);
}
break;
case USB_DT_CONFIG:
memcpy(data, bx_msd_config_descriptor, sizeof(bx_msd_config_descriptor));
ret = sizeof(bx_msd_config_descriptor);
BX_DEBUG(("USB_REQ_GET_DESCRIPTOR: Config"));
if (get_speed() == USB_SPEED_SUPER) {
memcpy(data, bx_msd_config_descriptor3, sizeof(bx_msd_config_descriptor3));
ret = sizeof(bx_msd_config_descriptor3);
} else {
memcpy(data, bx_msd_config_descriptor, sizeof(bx_msd_config_descriptor));
ret = sizeof(bx_msd_config_descriptor);
}
break;
case USB_DT_STRING:
BX_DEBUG(("USB_REQ_GET_DESCRIPTOR: String"));
switch(value & 0xff) {
case 0:
// language IDs
@ -339,12 +467,17 @@ int usb_msd_device_c::handle_control(int request, int value, int index, int leng
// serial number
ret = set_usb_string(data, s.scsi_dev->get_serial_number());
break;
case 0xEE:
// Microsoft OS Descriptor check
// We don't support this check, so fail
goto fail;
default:
BX_ERROR(("USB MSD handle_control: unknown string descriptor 0x%02x", value & 0xff));
goto fail;
}
break;
case USB_DT_DEVICE_QUALIFIER:
BX_DEBUG(("USB_REQ_GET_DESCRIPTOR: Device Qualifier"));
// device qualifier
data[0] = 10;
data[1] = USB_DT_DEVICE_QUALIFIER;
@ -353,40 +486,60 @@ int usb_msd_device_c::handle_control(int request, int value, int index, int leng
data[9] = 0;
ret = 10;
break;
case USB_DT_BIN_DEV_OBJ_STORE:
BX_DEBUG(("USB_REQ_GET_DESCRIPTOR: BOS"));
if (get_speed() == USB_SPEED_SUPER) {
memcpy(data, bx_msd_bos_descriptor3, sizeof(bx_msd_bos_descriptor3));
ret = sizeof(bx_msd_bos_descriptor3);
} else
goto fail;
break;
default:
BX_ERROR(("USB MSD handle_control: unknown descriptor type 0x%02x", value >> 8));
goto fail;
}
break;
case DeviceRequest | USB_REQ_GET_CONFIGURATION:
BX_DEBUG(("USB_REQ_GET_CONFIGURATION:"));
data[0] = 1;
ret = 1;
break;
case DeviceOutRequest | USB_REQ_SET_CONFIGURATION:
BX_DEBUG(("USB_REQ_SET_CONFIGURATION:"));
ret = 0;
break;
case DeviceRequest | USB_REQ_GET_INTERFACE:
BX_DEBUG(("USB_REQ_GET_INFTERFACE:"));
data[0] = 0;
ret = 1;
break;
case DeviceOutRequest | USB_REQ_SET_INTERFACE:
case InterfaceOutRequest | USB_REQ_SET_INTERFACE:
BX_DEBUG(("USB_REQ_SET_INFTERFACE:"));
ret = 0;
break;
case EndpointOutRequest | USB_REQ_CLEAR_FEATURE:
BX_DEBUG(("USB_REQ_CLEAR_FEATURE:"));
if (value == 0 && index != 0x81) { /* clear ep halt */
goto fail;
}
ret = 0;
break;
// Class specific requests
case DeviceOutRequest | USB_REQ_SET_SEL:
// Set U1 and U2 System Exit Latency
BX_DEBUG(("SET_SEL (U1 and U2):"));
ret = 0;
break;
// Class specific requests
case InterfaceOutClassRequest | MassStorageReset:
case MassStorageReset:
BX_DEBUG(("MASS STORAGE RESET:"));
s.mode = USB_MSDM_CBW;
ret = 0;
break;
case InterfaceInClassRequest | GetMaxLun:
case GetMaxLun:
BX_DEBUG(("MASS STORAGE: GET MAX LUN"));
data[0] = 0;
ret = 1;
break;
@ -422,7 +575,7 @@ int usb_msd_device_c::handle_data(USBPacket *p)
}
memcpy(&cbw, data, 31);
if (dtoh32(cbw.sig) != 0x43425355) {
BX_ERROR(("bad signature %08x", dtoh32(cbw.sig)));
BX_ERROR(("bad signature %08X", dtoh32(cbw.sig)));
goto fail;
}
BX_DEBUG(("command on LUN %d", cbw.lun));
@ -435,7 +588,7 @@ int usb_msd_device_c::handle_data(USBPacket *p)
} else {
s.mode = USB_MSDM_DATAOUT;
}
BX_DEBUG(("command tag 0x%x flags %08x len %d data %d",
BX_DEBUG(("command tag 0x%X flags %08X len %d data %d",
s.tag, cbw.flags, cbw.cmd_len, s.data_len));
s.residue = 0;
s.scsi_dev->scsi_send_command(s.tag, cbw.cmd, cbw.lun);
@ -476,7 +629,7 @@ int usb_msd_device_c::handle_data(USBPacket *p)
break;
default:
BX_ERROR(("USB MSD handle_data: unexpected mode at USB_TOKEN_OUT"));
BX_ERROR(("USB MSD handle_data: unexpected mode at USB_TOKEN_OUT: (0x%02X)", s.mode));
goto fail;
}
break;
@ -541,7 +694,7 @@ int usb_msd_device_c::handle_data(USBPacket *p)
break;
default:
BX_ERROR(("USB MSD handle_data: unexpected mode at USB_TOKEN_IN"));
BX_ERROR(("USB MSD handle_data: unexpected mode at USB_TOKEN_IN: (0x%02X)", s.mode));
goto fail;
}
if (ret > 0) usb_dump_packet(data, ret);

View File

@ -1480,8 +1480,21 @@ void bx_usb_ohci_c::usb_set_connect_status(Bit8u port, int type, bx_bool connect
if (device != NULL) {
if (device->get_type() == type) {
if (connected) {
BX_OHCI_THIS hub.usb_port[port].HcRhPortStatus.lsda =
(device->get_speed() == USB_SPEED_LOW);
switch (device->get_speed()) {
case USB_SPEED_LOW:
BX_OHCI_THIS hub.usb_port[port].HcRhPortStatus.lsda = 1;
break;
case USB_SPEED_FULL:
BX_OHCI_THIS hub.usb_port[port].HcRhPortStatus.lsda = 0;
break;
case USB_SPEED_HIGH:
case USB_SPEED_SUPER:
BX_PANIC(("HC supports 'low' or 'full' speed devices only."));
device->set_speed(USB_SPEED_FULL);
break;
default:
BX_ERROR(("device->get_speed() returned invalid speed value"));
}
BX_OHCI_THIS hub.usb_port[port].HcRhPortStatus.ccs = 1;
if (!device->get_connected()) {
if (!device->init()) {

View File

@ -3,7 +3,7 @@
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2009 Benjamin D Lunt (fys at frontiernet net)
// 2009-2012 The Bochs Project
// 2009-2014 The Bochs Project
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@ -115,7 +115,6 @@ usb_printer_device_c::usb_printer_device_c(usbdev_type type, const char *filenam
d.type = type;
d.maxspeed = USB_SPEED_FULL;
d.speed = d.maxspeed;
// TODO: d.max_packet_size = ???
memset((void*)&s, 0, sizeof(s));
strcpy(d.devname, "USB Printer");
s.fname = filename;

View File

@ -28,7 +28,7 @@
It has been a challenge, but I have learned a lot.
- 31 July 2006:
I now have a Beagle USB Protocol Analyzer from Total Phase for my research.
(http://www.totalphase.com/products/beagle/usb/)
(http://www.totalphase.com/products/beagle-usb12/)
With this device, I plan on doing a lot of research and development to get this
code to a state where it is actually very useful. I plan on adding support
of many "plug-in" type modules so that you can simply add a plug-in for your
@ -1099,14 +1099,35 @@ void bx_usb_uhci_c::pci_write_handler(Bit8u address, Bit32u value, unsigned io_l
BX_DEBUG(("write PCI register 0x%02x value 0x%08x", address, value));
}
const char *usb_speed[4] = {
"low",
"full",
"high",
"super"
};
void bx_usb_uhci_c::usb_set_connect_status(Bit8u port, int type, bx_bool connected)
{
usb_device_c *device = BX_UHCI_THIS hub.usb_port[port].device;
if (device != NULL) {
if (device->get_type() == type) {
if (connected) {
BX_UHCI_THIS hub.usb_port[port].low_speed =
(device->get_speed() == USB_SPEED_LOW);
BX_INFO(("port #%d: speed = %s", port+1, usb_speed[device->get_speed()]));
switch (device->get_speed()) {
case USB_SPEED_LOW:
BX_UHCI_THIS hub.usb_port[port].low_speed = 1;
break;
case USB_SPEED_FULL:
BX_UHCI_THIS hub.usb_port[port].low_speed = 0;
break;
case USB_SPEED_HIGH:
case USB_SPEED_SUPER:
BX_PANIC(("HC supports 'low' or 'full' speed devices only."));
device->set_speed(USB_SPEED_FULL);
break;
default:
BX_ERROR(("device->get_speed() returned invalid speed value"));
}
if (BX_UHCI_THIS hub.usb_port[port].low_speed) {
BX_UHCI_THIS hub.usb_port[port].line_dminus = 1; // dminus=1 & dplus=0 = low speed (at idle time)
BX_UHCI_THIS hub.usb_port[port].line_dplus = 0; // dminus=0 & dplus=1 = high speed (at idle time)

View File

@ -2003,8 +2003,18 @@ void bx_usb_xhci_c::process_command_ring(void)
// it should remain the mps for the device attached.
if (i == 1) {
int port_num = BX_XHCI_THIS hub.slots[slot].slot_context.rh_port_num - 1;
BX_XHCI_THIS hub.slots[slot].ep_context[i].ep_context.max_packet_size =
BX_XHCI_THIS hub.usb_port[port_num].device->get_max_packet_size();
switch (BX_XHCI_THIS hub.usb_port[port_num].device->get_speed()) {
case USB_SPEED_LOW:
BX_XHCI_THIS hub.slots[slot].ep_context[i].ep_context.max_packet_size = 8;
break;
case USB_SPEED_FULL:
case USB_SPEED_HIGH:
BX_XHCI_THIS hub.slots[slot].ep_context[i].ep_context.max_packet_size = 64;
break;
case USB_SPEED_SUPER:
BX_XHCI_THIS hub.slots[slot].ep_context[i].ep_context.max_packet_size = 512;
break;
}
} else
BX_XHCI_THIS hub.slots[slot].ep_context[i].ep_context.max_packet_size = ep_context.max_packet_size;