VERY experimental Nintendo Switch 2 emulator
C++
Set client SDK version to Service APIs
mailwl662aee1e1dff
diff --git a/src/common/logging/log.h b/src/common/logging/log.hindex 8011534b81..96d0dfb8c3 100644--- a/src/common/logging/log.h+++ b/src/common/logging/log.h@@ -60,7 +60,7 @@ enum class Class : ClassType {Service_AM, ///< The AM (Application manager) serviceService_PTM, ///< The PTM (Power status & misc.) serviceService_LDR, ///< The LDR (3ds dll loader) service- Service_MIC, ///< The MIC (microphone) service+ Service_MIC, ///< The MIC (Microphone) serviceService_NDM, ///< The NDM (Network daemon manager) serviceService_NIM, ///< The NIM (Network interface manager) serviceService_NWM, ///< The NWM (Network wlan manager) service@@ -85,8 +85,7 @@ enum class Class : ClassType {Audio_DSP, ///< The HLE implementation of the DSPAudio_Sink, ///< Emulator audio output backendLoader, ///< ROM loader-- Count ///< Total number of logging classes+ Count ///< Total number of logging classes};/// Logs a message to the global logger.diff --git a/src/core/hle/service/ac_u.cpp b/src/core/hle/service/ac_u.cppindex 18026975f1..fe367aca50 100644--- a/src/core/hle/service/ac_u.cpp+++ b/src/core/hle/service/ac_u.cpp@@ -230,6 +230,24 @@ static void IsConnected(Service::Interface* self) {LOG_WARNING(Service_AC, "(STUBBED) called");}+/**+ * AC_U::SetClientVersion service function+ * Inputs:+ * 1 : Used SDK Version+ * Outputs:+ * 1 : Result of function, 0 on success, otherwise error code+ */+static void SetClientVersion(Service::Interface* self) {+ u32* cmd_buff = Kernel::GetCommandBuffer();++ const u32 version = cmd_buff[1];+ self->SetVersion(version);++ LOG_WARNING(Service_AC, "(STUBBED) called, version: 0x%08X", version);++ cmd_buff[1] = RESULT_SUCCESS.raw; // No error+}+const Interface::FunctionInfo FunctionTable[] = {{0x00010000, CreateDefaultConfig, "CreateDefaultConfig"},{0x00040006, ConnectAsync, "ConnectAsync"},@@ -250,7 +268,7 @@ const Interface::FunctionInfo FunctionTable[] = {{0x00300004, RegisterDisconnectEvent, "RegisterDisconnectEvent"},{0x003C0042, nullptr, "GetAPSSIDList"},{0x003E0042, IsConnected, "IsConnected"},- {0x00400042, nullptr, "SetClientVersion"},+ {0x00400042, SetClientVersion, "SetClientVersion"},};////////////////////////////////////////////////////////////////////////////////////////////////////diff --git a/src/core/hle/service/frd/frd.cpp b/src/core/hle/service/frd/frd.cppindex 1d16f8732a..34fdf7f535 100644--- a/src/core/hle/service/frd/frd.cpp+++ b/src/core/hle/service/frd/frd.cpp@@ -100,6 +100,18 @@ void GetMyScreenName(Service::Interface* self) {LOG_WARNING(Service_FRD, "(STUBBED) called");}+void SetClientSdkVersion(Service::Interface* self) {+ u32* cmd_buff = Kernel::GetCommandBuffer();++ const u32 version = cmd_buff[1];++ self->SetVersion(version);++ LOG_WARNING(Service_FRD, "(STUBBED) called, version: 0x%08X", version);++ cmd_buff[1] = RESULT_SUCCESS.raw; // No error+}+void Init() {using namespace Kernel;diff --git a/src/core/hle/service/frd/frd.h b/src/core/hle/service/frd/frd.hindex c8283a7f32..e61940ea07 100644--- a/src/core/hle/service/frd/frd.h+++ b/src/core/hle/service/frd/frd.h@@ -95,6 +95,15 @@ void GetMyFriendKey(Service::Interface* self);*/void GetMyScreenName(Service::Interface* self);+/**+ * FRD::SetClientSdkVersion service function+ * Inputs:+ * 1 : Used SDK Version+ * Outputs:+ * 1 : Result of function, 0 on success, otherwise error code+ */+void SetClientSdkVersion(Service::Interface* self);+/// Initialize FRD service(s)void Init();diff --git a/src/core/hle/service/frd/frd_u.cpp b/src/core/hle/service/frd/frd_u.cppindex bd1c9c16b0..496f29ca93 100644--- a/src/core/hle/service/frd/frd_u.cpp+++ b/src/core/hle/service/frd/frd_u.cpp@@ -58,7 +58,7 @@ const Interface::FunctionInfo FunctionTable[] = {{0x002F0040, nullptr, "AllowHalfAwake"},{0x00300000, nullptr, "GetServerTypes"},{0x00310082, nullptr, "GetFriendComment"},- {0x00320042, nullptr, "SetClientSdkVersion"},+ {0x00320042, SetClientSdkVersion, "SetClientSdkVersion"},{0x00330000, nullptr, "GetMyApproachContext"},{0x00340046, nullptr, "AddFriendWithApproach"},{0x00350082, nullptr, "DecryptApproachContext"},diff --git a/src/core/hle/service/fs/fs_user.cpp b/src/core/hle/service/fs/fs_user.cppindex 00edc7622f..9ec17b395b 100644--- a/src/core/hle/service/fs/fs_user.cpp+++ b/src/core/hle/service/fs/fs_user.cpp@@ -763,23 +763,27 @@ static void CreateLegacySystemSaveData(Service::Interface* self) {* FS_User::InitializeWithSdkVersion service function.* Inputs:* 0 : 0x08610042- * 1 : Unknown- * 2 : Unknown- * 3 : Unknown+ * 1 : Used SDK Version+ * 2 : ProcessId Header+ * 3 : placeholder for ProcessId* Outputs:* 1 : Result of function, 0 on success, otherwise error code*/static void InitializeWithSdkVersion(Service::Interface* self) {u32* cmd_buff = Kernel::GetCommandBuffer();- u32 unk1 = cmd_buff[1];- u32 unk2 = cmd_buff[2];- u32 unk3 = cmd_buff[3];+ const u32 version = cmd_buff[1];+ self->SetVersion(version);- cmd_buff[1] = RESULT_SUCCESS.raw;-- LOG_WARNING(Service_FS, "(STUBBED) called unk1=0x%08X, unk2=0x%08X, unk3=0x%08X", unk1, unk2,- unk3);+ if (cmd_buff[2] == IPC::CallingPidDesc()) {+ LOG_WARNING(Service_FS, "(STUBBED) called, version: 0x%08X", version);+ cmd_buff[1] = RESULT_SUCCESS.raw;+ } else {+ LOG_ERROR(Service_FS, "ProcessId Header must be 0x20");+ cmd_buff[1] = ResultCode(ErrorDescription::OS_InvalidBufferDescriptor, ErrorModule::OS,+ ErrorSummary::WrongArgument, ErrorLevel::Permanent)+ .raw;+ }}/**diff --git a/src/core/hle/service/mic_u.cpp b/src/core/hle/service/mic_u.cppindex 5633415048..1f851d3286 100644--- a/src/core/hle/service/mic_u.cpp+++ b/src/core/hle/service/mic_u.cpp@@ -287,6 +287,24 @@ static void SetAllowShellClosed(Service::Interface* self) {LOG_WARNING(Service_MIC, "(STUBBED) called, allow_shell_closed=%u", allow_shell_closed);}+/**+ * MIC_U::SetClientVersion service function+ * Inputs:+ * 1 : Used SDK Version+ * Outputs:+ * 1 : Result of function, 0 on success, otherwise error code+ */+static void SetClientVersion(Service::Interface* self) {+ u32* cmd_buff = Kernel::GetCommandBuffer();++ const u32 version = cmd_buff[1];+ self->SetVersion(version);++ LOG_WARNING(Service_MIC, "(STUBBED) called, version: 0x%08X", version);++ cmd_buff[1] = RESULT_SUCCESS.raw; // No error+}+const Interface::FunctionInfo FunctionTable[] = {{0x00010042, MapSharedMem, "MapSharedMem"},{0x00020000, UnmapSharedMem, "UnmapSharedMem"},@@ -303,7 +321,7 @@ const Interface::FunctionInfo FunctionTable[] = {{0x000D0040, SetClamp, "SetClamp"},{0x000E0000, GetClamp, "GetClamp"},{0x000F0040, SetAllowShellClosed, "SetAllowShellClosed"},- {0x00100040, nullptr, "SetClientSDKVersion"},+ {0x00100040, SetClientVersion, "SetClientVersion"},};////////////////////////////////////////////////////////////////////////////////////////////////////diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.hindex 39b5ffaaec..29daacfc46 100644--- a/src/core/hle/service/service.h+++ b/src/core/hle/service/service.h@@ -29,6 +29,10 @@ public:return GetPortName();}+ virtual void SetVersion(u32 raw_version) {+ version.raw = raw_version;+ }+typedef void (*Function)(Interface*);struct FunctionInfo {@@ -58,6 +62,14 @@ protected:void Register(const FunctionInfo* functions, size_t n);+ union {+ u32 raw;+ BitField<0, 8, u32> major;+ BitField<8, 8, u32> minor;+ BitField<16, 8, u32> build;+ BitField<24, 8, u32> revision;+ } version = {};+private:boost::container::flat_map<u32, FunctionInfo> m_functions;};