diff --git a/stratosphere/tma/client/UsbConnection.py b/stratosphere/tma/client/UsbConnection.py index a7b009ad6..a0ec84e38 100644 --- a/stratosphere/tma/client/UsbConnection.py +++ b/stratosphere/tma/client/UsbConnection.py @@ -80,6 +80,7 @@ class UsbConnection(UsbInterface): 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 f7c04a475..423b7cb90 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_Pcie = 0x13; 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 0012944d8..2d2b18cec 100644 --- a/stratosphere/tma/source/tma_service_manager.cpp +++ b/stratosphere/tma/source/tma_service_manager.cpp @@ -93,6 +93,7 @@ void TmaServiceManager::AddWork(TmaWorkType type, TmaTask *task, TmaPacket *pack 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 @@ void TmaServiceManager::HandleSleepWork() { 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 234345da1..227975c70 100644 --- a/stratosphere/tma/source/tma_target.cpp +++ b/stratosphere/tma/source/tma_target.cpp @@ -34,6 +34,7 @@ static TmaConnection *g_active_connection = nullptr; 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 @@ static void Wake() { 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 Wake() { 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 @@ static void OnPowerManagementEvent(PscPmState state, u32 flags) { { 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 @@ static void OnPowerManagementEvent(PscPmState state, u32 flags) { svcSleepThread(1000000ULL); } } + if (!connected) { /* TODO: Signal disconnected */ }