diff --git a/stratosphere/tma/client/UsbConnection.py b/stratosphere/tma/client/UsbConnection.py index a7b009a..a0ec84e 100644 --- a/stratosphere/tma/client/UsbConnection.py +++ b/stratosphere/tma/client/UsbConnection.py @@ -80,6 +80,7 @@ try: # Perform Query + Connection handshake + print 'Performing handshake...' self.intf.send_packet(Packet().set_service(ServiceId.USB_QUERY_TARGET)) query_resp = self.intf.read_packet() print 'Found Switch, Protocol version 0x%x' % query_resp.read_u32() diff --git a/stratosphere/tma/source/tma_power_manager.cpp b/stratosphere/tma/source/tma_power_manager.cpp index f7c04a4..423b7cb 100644 --- a/stratosphere/tma/source/tma_power_manager.cpp +++ b/stratosphere/tma/source/tma_power_manager.cpp @@ -23,7 +23,6 @@ static constexpr u16 PscPmModuleId_Tma = 0x1E; static const u16 g_tma_pm_dependencies[] = { - PscPmModuleId_Pcie, PscPmModuleId_Usb, }; diff --git a/stratosphere/tma/source/tma_service_manager.cpp b/stratosphere/tma/source/tma_service_manager.cpp index 0012944..2d2b18c 100644 --- a/stratosphere/tma/source/tma_service_manager.cpp +++ b/stratosphere/tma/source/tma_service_manager.cpp @@ -93,6 +93,7 @@ work_item->task = task; work_item->packet = packet; work_item->work_type = type; + this->work_queue.Send(reinterpret_cast(work_item)); } /* Packet management. */ @@ -391,6 +392,7 @@ this->wake_signal.Wait(); /* We're awake now... */ + this->SetAsleep(false); /* Wake up services. */ for (auto srv : this->services) { diff --git a/stratosphere/tma/source/tma_target.cpp b/stratosphere/tma/source/tma_target.cpp index 234345d..227975c 100644 --- a/stratosphere/tma/source/tma_target.cpp +++ b/stratosphere/tma/source/tma_target.cpp @@ -34,6 +34,7 @@ static TmaServiceManager *g_service_manager = nullptr; static HosMutex g_connection_event_mutex; static bool g_has_woken_up = false; +static bool g_connected_before_sleep = false; static bool g_signal_on_disconnect = false; static TmaUsbConnection *g_usb_connection = nullptr; @@ -119,7 +120,7 @@ g_usb_connection = new TmaUsbConnection(); g_usb_connection->SetConnectionEventCallback(OnConnectionEvent, g_usb_connection); g_usb_connection->Initialize(); - SetActiveConnection(g_usb_connection); + g_active_connection = g_usb_connection; g_service_manager->Wake(g_active_connection); } @@ -128,7 +129,11 @@ static void Sleep() { if (!g_service_manager->GetAsleep()) { if (g_active_connection->IsConnected()) { + g_connected_before_sleep = true; + /* TODO: Send a packet saying we're going to sleep. */ + } else { + g_connected_before_sleep = false; } g_service_manager->Sleep(); @@ -157,6 +162,7 @@ { if (g_service_manager->GetAsleep()) { Wake(); + if (g_connected_before_sleep) { /* Try to restore a connection. */ bool connected = g_service_manager->GetConnected(); @@ -170,6 +176,7 @@ svcSleepThread(1000000ULL); } } + if (!connected) { /* TODO: Signal disconnected */ }