diff --git a/src/core/hle/service/sockets/bsd.cpp b/src/core/hle/service/sockets/bsd.cpp index dd652ca42..ef803e33f 100644 --- a/src/core/hle/service/sockets/bsd.cpp +++ b/src/core/hle/service/sockets/bsd.cpp @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project +// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #include @@ -309,7 +310,7 @@ void BSD::Listen(HLERequestContext& ctx) { void BSD::Fcntl(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const s32 fd = rp.Pop(); - const s32 cmd = rp.Pop(); + const u32 cmd = rp.Pop(); const s32 arg = rp.Pop(); LOG_DEBUG(Service, "called. fd={} cmd={} arg={}", fd, cmd, arg); @@ -479,6 +480,14 @@ void BSD::EventFd(HLERequestContext& ctx) { BuildErrnoResponse(ctx, Errno::SUCCESS); } +void BSD::RegisterClientShared(HLERequestContext& ctx) { + LOG_WARNING(Service, "(STUBBED) called RegisterClientShared"); + IPC::ResponseBuilder rb{ctx, 4}; // Match RegisterClient response style + rb.Push(ResultSuccess); + rb.Push(0); // ret (0 for success) + rb.Push(0); // BSD errno (0 for success, consistent with RegisterClient stub) +} + template void BSD::ExecuteWork(HLERequestContext& ctx, Work work) { work.Execute(this); @@ -976,11 +985,11 @@ BSD::BSD(Core::System& system_, const char* name) {0, &BSD::RegisterClient, "RegisterClient"}, {1, &BSD::StartMonitoring, "StartMonitoring"}, {2, &BSD::Socket, "Socket"}, - {3, nullptr, "SocketExempt"}, - {4, nullptr, "Open"}, + {3, &BSD::SocketExempt, "SocketExempt"}, + {4, &BSD::Open, "Open"}, {5, &BSD::Select, "Select"}, {6, &BSD::Poll, "Poll"}, - {7, nullptr, "Sysctl"}, + {7, &BSD::Sysctl, "Sysctl"}, {8, &BSD::Recv, "Recv"}, {9, &BSD::RecvFrom, "RecvFrom"}, {10, &BSD::Send, "Send"}, @@ -992,21 +1001,25 @@ BSD::BSD(Core::System& system_, const char* name) {16, &BSD::GetSockName, "GetSockName"}, {17, &BSD::GetSockOpt, "GetSockOpt"}, {18, &BSD::Listen, "Listen"}, - {19, nullptr, "Ioctl"}, + {19, &BSD::Ioctl, "Ioctl"}, {20, &BSD::Fcntl, "Fcntl"}, {21, &BSD::SetSockOpt, "SetSockOpt"}, {22, &BSD::Shutdown, "Shutdown"}, - {23, nullptr, "ShutdownAllSockets"}, + {23, &BSD::ShutdownAllSockets, "ShutdownAllSockets"}, {24, &BSD::Write, "Write"}, {25, &BSD::Read, "Read"}, {26, &BSD::Close, "Close"}, {27, &BSD::DuplicateSocket, "DuplicateSocket"}, - {28, nullptr, "GetResourceStatistics"}, - {29, nullptr, "RecvMMsg"}, - {30, nullptr, "SendMMsg"}, + {28, &BSD::GetResourceStatistics, "GetResourceStatistics"}, + {29, &BSD::RecvMMsg, "RecvMMsg"}, + {30, &BSD::SendMMsg, "SendMMsg"}, {31, &BSD::EventFd, "EventFd"}, - {32, nullptr, "RegisterResourceStatisticsName"}, - {33, nullptr, "Initialize2"}, + {32, &BSD::RegisterResourceStatisticsName, "RegisterResourceStatisticsName"}, + {33, &BSD::RegisterClientShared, "RegisterClientShared"}, + {34, &BSD::GetSocketStatistics, "GetSocketStatistics"}, + {35, &BSD::NifIoctl, "NifIoctl"}, + {200, &BSD::SetThreadCoreMask, "SetThreadCoreMask"}, + {201, &BSD::GetThreadCoreMask, "GetThreadCoreMask"}, }; // clang-format on @@ -1058,4 +1071,109 @@ BSDCFG::BSDCFG(Core::System& system_) : ServiceFramework{system_, "bsdcfg"} { BSDCFG::~BSDCFG() = default; +void BSD::GetResourceStatistics(HLERequestContext& ctx) { + LOG_WARNING(Service, "(STUBBED) called GetResourceStatistics"); + IPC::ResponseBuilder rb{ctx, 4}; + rb.Push(ResultSuccess); + rb.Push(-1); + rb.PushEnum(static_cast(EOPNOTSUPP)); +} + +void BSD::GetSocketStatistics(HLERequestContext& ctx) { + LOG_WARNING(Service, "(STUBBED) called GetSocketStatistics"); + IPC::ResponseBuilder rb{ctx, 4}; + rb.Push(ResultSuccess); + rb.Push(-1); + rb.PushEnum(static_cast(EOPNOTSUPP)); +} + +void BSD::GetThreadCoreMask(HLERequestContext& ctx) { + LOG_WARNING(Service, "(STUBBED) called GetThreadCoreMask"); + IPC::ResponseBuilder rb{ctx, 5}; + rb.Push(ResultSuccess); + rb.Push(0); + rb.Push(-1); + rb.PushEnum(static_cast(EOPNOTSUPP)); +} + +void BSD::Ioctl(HLERequestContext& ctx) { + LOG_WARNING(Service, "(STUBBED) called Ioctl"); + IPC::ResponseBuilder rb{ctx, 4}; + rb.Push(ResultSuccess); + rb.Push(-1); + rb.PushEnum(static_cast(ENOTTY)); +} + +void BSD::NifIoctl(HLERequestContext& ctx) { + LOG_WARNING(Service, "(STUBBED) called NifIoctl"); + IPC::ResponseBuilder rb{ctx, 4}; + rb.Push(ResultSuccess); + rb.Push(-1); + rb.PushEnum(static_cast(ENOTTY)); +} + +void BSD::Open(HLERequestContext& ctx) { + LOG_WARNING(Service, "(STUBBED) called Open"); + IPC::ResponseBuilder rb{ctx, 4}; + rb.Push(ResultSuccess); + rb.Push(-1); + rb.PushEnum(static_cast(EACCES)); +} + +void BSD::RecvMMsg(HLERequestContext& ctx) { + LOG_WARNING(Service, "(STUBBED) called RecvMMsg"); + IPC::ResponseBuilder rb{ctx, 4}; + rb.Push(ResultSuccess); + rb.Push(0); // num_msgs processed + rb.PushEnum(static_cast(EOPNOTSUPP)); +} + +void BSD::RegisterResourceStatisticsName(HLERequestContext& ctx) { + LOG_WARNING(Service, "(STUBBED) called RegisterResourceStatisticsName"); + IPC::ResponseBuilder rb{ctx, 4}; + rb.Push(ResultSuccess); + rb.Push(-1); + rb.PushEnum(static_cast(EOPNOTSUPP)); +} + +void BSD::SendMMsg(HLERequestContext& ctx) { + LOG_WARNING(Service, "(STUBBED) called SendMMsg"); + IPC::ResponseBuilder rb{ctx, 4}; + rb.Push(ResultSuccess); + rb.Push(0); // num_msgs processed + rb.PushEnum(static_cast(EOPNOTSUPP)); +} + +void BSD::SetThreadCoreMask(HLERequestContext& ctx) { + LOG_WARNING(Service, "(STUBBED) called SetThreadCoreMask"); + IPC::ResponseBuilder rb{ctx, 4}; + rb.Push(ResultSuccess); + rb.Push(-1); + rb.PushEnum(static_cast(EOPNOTSUPP)); +} + +void BSD::ShutdownAllSockets(HLERequestContext& ctx) { + LOG_WARNING(Service, "(STUBBED) called ShutdownAllSockets"); + IPC::ResponseBuilder rb{ctx, 4}; + rb.Push(ResultSuccess); + rb.Push(-1); + rb.PushEnum(static_cast(EOPNOTSUPP)); +} + +void BSD::SocketExempt(HLERequestContext& ctx) { + LOG_WARNING(Service, "(STUBBED) called SocketExempt"); + IPC::ResponseBuilder rb{ctx, 4}; + rb.Push(ResultSuccess); + rb.Push(-1); // fd + rb.PushEnum(static_cast(EOPNOTSUPP)); +} + +void BSD::Sysctl(HLERequestContext& ctx) { + LOG_WARNING(Service, "(STUBBED) called Sysctl"); + IPC::ResponseBuilder rb{ctx, 4}; + rb.Push(ResultSuccess); + rb.Push(-1); + rb.PushEnum(static_cast(EOPNOTSUPP)); +} + } // namespace Service::Sockets diff --git a/src/core/hle/service/sockets/bsd.h b/src/core/hle/service/sockets/bsd.h index 4f69d382c..b2fd39cc5 100644 --- a/src/core/hle/service/sockets/bsd.h +++ b/src/core/hle/service/sockets/bsd.h @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project +// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #pragma once @@ -149,6 +150,22 @@ private: void DuplicateSocket(HLERequestContext& ctx); void EventFd(HLERequestContext& ctx); + // [Zephyron] Added declarations based on Switchbrew documentation + void SocketExempt(HLERequestContext& ctx); + void Open(HLERequestContext& ctx); + void Sysctl(HLERequestContext& ctx); + void Ioctl(HLERequestContext& ctx); + void ShutdownAllSockets(HLERequestContext& ctx); + void GetResourceStatistics(HLERequestContext& ctx); + void RecvMMsg(HLERequestContext& ctx); + void SendMMsg(HLERequestContext& ctx); + void RegisterResourceStatisticsName(HLERequestContext& ctx); + void RegisterClientShared(HLERequestContext& ctx); + void GetSocketStatistics(HLERequestContext& ctx); + void NifIoctl(HLERequestContext& ctx); + void SetThreadCoreMask(HLERequestContext& ctx); + void GetThreadCoreMask(HLERequestContext& ctx); + template void ExecuteWork(HLERequestContext& ctx, Work work);