From b24e15a09cbde347f80ea9a71aac2bc6cca1e807 Mon Sep 17 00:00:00 2001 From: ergo720 Date: Mon, 9 Jul 2018 21:40:09 +0200 Subject: [PATCH] USB_DeviceDetach --- src/devices/usb/Hub.cpp | 2 +- src/devices/usb/USBDevice.cpp | 11 +++++++++++ src/devices/usb/USBDevice.h | 2 ++ src/devices/usb/UsbCommon.h | 1 - 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/devices/usb/Hub.cpp b/src/devices/usb/Hub.cpp index cff78ab43..844b9eaca 100644 --- a/src/devices/usb/Hub.cpp +++ b/src/devices/usb/Hub.cpp @@ -548,7 +548,7 @@ void Hub::UsbHub_HandleData(XboxDeviceState* dev, USBPacket* p) void Hub::UsbHub_HandleDestroy() { // Inform upstream that the hub is detached and gone - m_HubState->dev.Port->Operations->detach(m_HubState->dev.Port); + m_UsbDev->USB_DeviceDetach(&m_HubState->dev); m_UsbDev->m_FreePorts.push_back(m_HubState->dev.Port); for (int i = 0; i < NUM_PORTS; i++) { diff --git a/src/devices/usb/USBDevice.cpp b/src/devices/usb/USBDevice.cpp index d3e1d2ac2..d8e4b62d1 100644 --- a/src/devices/usb/USBDevice.cpp +++ b/src/devices/usb/USBDevice.cpp @@ -665,6 +665,17 @@ void USBDevice::USB_DeviceAttach(XboxDeviceState* dev) USB_Attach(port); } +void USBDevice::USB_DeviceDetach(XboxDeviceState* dev) +{ + USBPort* port = dev->Port; + + assert(port != nullptr); + assert(dev->Attached); + + USB_Detach(port); + dev->Attached--; +} + void USBDevice::USB_EpInit(XboxDeviceState* dev) { USB_EpReset(dev); diff --git a/src/devices/usb/USBDevice.h b/src/devices/usb/USBDevice.h index 56bd0b3e1..c4e567b41 100644 --- a/src/devices/usb/USBDevice.h +++ b/src/devices/usb/USBDevice.h @@ -79,6 +79,8 @@ class USBDevice : public PCIDevice { void USB_PortReset(USBPort* Port); // update device status during an attach void USB_DeviceAttach(XboxDeviceState* dev); + // update device status during an detach + void USB_DeviceDetach(XboxDeviceState* dev); // update port status when a device is attached void USB_Attach(USBPort* Port); // update port status when a device is detached diff --git a/src/devices/usb/UsbCommon.h b/src/devices/usb/UsbCommon.h index 421c6debf..5a61ab9f6 100644 --- a/src/devices/usb/UsbCommon.h +++ b/src/devices/usb/UsbCommon.h @@ -330,7 +330,6 @@ struct USBEndpoint { struct XboxDeviceState { USBPort* Port; // usb port struct of this device int PortPath; // port index to which this device is attached to - char* Serial; USBDeviceClass* klass; // usb class struct of this device int Speed; // actual speed of the connected device