Skip to content

Commit

Permalink
Merge branch 'master' into vpc
Browse files Browse the repository at this point in the history
  • Loading branch information
fysnet authored Sep 18, 2023
2 parents 0696f2e + b46fc68 commit 66095eb
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 3 deletions.
4 changes: 4 additions & 0 deletions bochs/iodev/usb/uhci_core.cc
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,10 @@ int bx_uhci_core_c::event_handler(int event, void *ptr, int port)
break;

// host controller events start here
case USB_EVENT_DEFAULT_SPEED:
// return default speed for specified port number
return USB_SPEED_FULL;

case USB_EVENT_CHECK_SPEED:
if (ptr != NULL) {
usb_device_c *usb_device = (usb_device_c *) ptr;
Expand Down
7 changes: 6 additions & 1 deletion bochs/iodev/usb/usb_common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,12 @@ static const char *usb_speed[4] = {

void bx_usbdev_ctl_c::parse_port_options(usb_device_c *device, bx_list_c *portconf)
{
int speed = device->get_default_speed(USB_SPEED_FULL); // try to default to FULL speed if parameter not given.
// if the speed option parameter is not given:
// first try to default to speed of controller
// then adjust to default max speed of device
// if the speed option parameter is given, this will be overwritten anyway
int speed = device->hc_event(USB_EVENT_DEFAULT_SPEED, device);
speed = device->get_default_speed(speed);
char *opts[16];

memset(opts, 0, sizeof(opts));
Expand Down
5 changes: 3 additions & 2 deletions bochs/iodev/usb/usb_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ typedef struct USBPacket USBPacket;
#define USB_EVENT_WAKEUP 0
#define USB_EVENT_ASYNC 1
// controller events
#define USB_EVENT_CHECK_SPEED 10
#define USB_EVENT_DEFAULT_SPEED 10
#define USB_EVENT_CHECK_SPEED 11

// set this to 1 to monitor the TD's toggle bit
// setting to 0 will speed up the emualtion slightly
Expand Down Expand Up @@ -240,7 +241,7 @@ class BOCHSAPI usb_device_c : public logfunctions {
int get_default_speed(int speed) {
if ((speed >= d.minspeed) && (speed <= d.maxspeed))
return speed;
return d.minspeed; // will be no more than full-speed
return BX_MIN(speed, d.maxspeed);
}

// return information for the specified ep of the current device
Expand Down
4 changes: 4 additions & 0 deletions bochs/iodev/usb/usb_ehci.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1324,6 +1324,10 @@ int bx_usb_ehci_c::event_handler(int event, void *ptr, int port)
break;

// host controller events start here
case USB_EVENT_DEFAULT_SPEED:
// return default speed for specified port number
return USB_SPEED_HIGH;

case USB_EVENT_CHECK_SPEED:
if (ptr != NULL) {
usb_device_c *usb_device = (usb_device_c *) ptr;
Expand Down
4 changes: 4 additions & 0 deletions bochs/iodev/usb/usb_ohci.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1233,6 +1233,10 @@ int bx_usb_ohci_c::event_handler(int event, void *ptr, int port)
break;

// host controller events start here
case USB_EVENT_DEFAULT_SPEED:
// return default speed for specified port number
return USB_SPEED_FULL;

case USB_EVENT_CHECK_SPEED:
if (ptr != NULL) {
usb_device_c *usb_device = (usb_device_c *) ptr;
Expand Down
9 changes: 9 additions & 0 deletions bochs/iodev/usb/usb_xhci.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2149,6 +2149,15 @@ int bx_usb_xhci_c::event_handler(int event, void *ptr, int port)
break;

// host controller events start here
case USB_EVENT_DEFAULT_SPEED:
// return default speed for specified port number
if (BX_XHCI_THIS hub.usb_port[port].is_usb3 == 1) {
// return super-speed
return USB_SPEED_SUPER;
}
// else return high-speed
return USB_SPEED_HIGH;

case USB_EVENT_CHECK_SPEED:
// all super-speed device must be on the first half port register sets,
// while all non-super-speed device must be on the second half.
Expand Down

0 comments on commit 66095eb

Please sign in to comment.