From 021c77bc9f485fe871f4cced0bdb2ba568f3c1a2 Mon Sep 17 00:00:00 2001 From: Weiyi Wang Date: Tue, 12 Mar 2019 21:44:04 -0400 Subject: [PATCH] UDS: divide IPC and impl for InitializeWithVersion --- src/core/hle/service/nwm/nwm_uds.cpp | 32 +++++++++++++++++----------- src/core/hle/service/nwm/nwm_uds.h | 4 ++++ 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/core/hle/service/nwm/nwm_uds.cpp b/src/core/hle/service/nwm/nwm_uds.cpp index bc68a9dc6c..439764f225 100644 --- a/src/core/hle/service/nwm/nwm_uds.cpp +++ b/src/core/hle/service/nwm/nwm_uds.cpp @@ -615,20 +615,14 @@ void NWM_UDS::RecvBeaconBroadcastData(Kernel::HLERequestContext& ctx) { out_buffer_size, wlan_comm_id, id, unk1, unk2, cur_buffer_size); } -void NWM_UDS::InitializeWithVersion(Kernel::HLERequestContext& ctx) { - IPC::RequestParser rp(ctx, 0x1B, 12, 2); - - u32 sharedmem_size = rp.Pop(); - - // Update the node information with the data the game gave us. - rp.PopRaw(current_node); - - u16 version = rp.Pop(); - - recv_buffer_memory = rp.PopObject(); +ResultVal> NWM_UDS::Initialize( + u32 sharedmem_size, const NodeInfo& node, u16 version, + Kernel::SharedPtr sharedmem) { + current_node = node; initialized = true; + recv_buffer_memory = std::move(sharedmem); ASSERT_MSG(recv_buffer_memory->GetSize() == sharedmem_size, "Invalid shared memory size."); if (auto room_member = Network::GetRoomMember().lock()) { @@ -650,9 +644,21 @@ void NWM_UDS::InitializeWithVersion(Kernel::HLERequestContext& ctx) { channel_data.clear(); } + return MakeResult(connection_status_event); +} + +void NWM_UDS::InitializeWithVersion(Kernel::HLERequestContext& ctx) { + IPC::RequestParser rp(ctx, 0x1B, 12, 2); + u32 sharedmem_size = rp.Pop(); + auto node = rp.PopRaw(); + u16 version = rp.Pop(); + auto sharedmem = rp.PopObject(); + + auto result = Initialize(sharedmem_size, node, version, std::move(sharedmem)); + IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); - rb.Push(RESULT_SUCCESS); - rb.PushCopyObjects(connection_status_event); + rb.Push(result.Code()); + rb.PushCopyObjects(result.ValueOr(nullptr)); LOG_DEBUG(Service_NWM, "called sharedmem_size=0x{:08X}, version=0x{:08X}", sharedmem_size, version); diff --git a/src/core/hle/service/nwm/nwm_uds.h b/src/core/hle/service/nwm/nwm_uds.h index 3d7ef80d85..4008753551 100644 --- a/src/core/hle/service/nwm/nwm_uds.h +++ b/src/core/hle/service/nwm/nwm_uds.h @@ -369,6 +369,10 @@ private: */ void DecryptBeaconData(Kernel::HLERequestContext& ctx); + ResultVal> Initialize( + u32 sharedmem_size, const NodeInfo& node, u16 version, + Kernel::SharedPtr sharedmem); + void BeaconBroadcastCallback(u64 userdata, s64 cycles_late); /**