From de993dcfbdcda1632752004d2840107c7ff5b45d Mon Sep 17 00:00:00 2001 From: GPUCode <47210458+GPUCode@users.noreply.github.com> Date: Sat, 10 Feb 2024 00:09:05 +0200 Subject: [PATCH] service: Stub mcu::HWC (#7428) --- src/core/CMakeLists.txt | 4 ++++ src/core/hle/service/mcu/mcu.cpp | 16 +++++++++++++ src/core/hle/service/mcu/mcu.h | 15 ++++++++++++ src/core/hle/service/mcu/mcu_hwc.cpp | 36 ++++++++++++++++++++++++++++ src/core/hle/service/mcu/mcu_hwc.h | 21 ++++++++++++++++ src/core/hle/service/service.cpp | 3 ++- 6 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 src/core/hle/service/mcu/mcu.cpp create mode 100644 src/core/hle/service/mcu/mcu.h create mode 100644 src/core/hle/service/mcu/mcu_hwc.cpp create mode 100644 src/core/hle/service/mcu/mcu_hwc.h diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index dc45e1eb8..cf29c05a8 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -327,6 +327,10 @@ add_library(citra_core STATIC hle/service/ldr_ro/cro_helper.h hle/service/ldr_ro/ldr_ro.cpp hle/service/ldr_ro/ldr_ro.h + hle/service/mcu/mcu_hwc.cpp + hle/service/mcu/mcu_hwc.h + hle/service/mcu/mcu.cpp + hle/service/mcu/mcu.h hle/service/mic/mic_u.cpp hle/service/mic/mic_u.h hle/service/mvd/mvd.cpp diff --git a/src/core/hle/service/mcu/mcu.cpp b/src/core/hle/service/mcu/mcu.cpp new file mode 100644 index 000000000..dff4ee3e9 --- /dev/null +++ b/src/core/hle/service/mcu/mcu.cpp @@ -0,0 +1,16 @@ +// Copyright 2024 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include "core/core.h" +#include "core/hle/service/mcu/mcu.h" +#include "core/hle/service/mcu/mcu_hwc.h" + +namespace Service::MCU { + +void InstallInterfaces(Core::System& system) { + auto& service_manager = system.ServiceManager(); + std::make_shared()->InstallAsService(service_manager); +} + +} // namespace Service::MCU diff --git a/src/core/hle/service/mcu/mcu.h b/src/core/hle/service/mcu/mcu.h new file mode 100644 index 000000000..95431243f --- /dev/null +++ b/src/core/hle/service/mcu/mcu.h @@ -0,0 +1,15 @@ +// Copyright 2024 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +namespace Core { +class System; +} + +namespace Service::MCU { + +void InstallInterfaces(Core::System& system); + +} // namespace Service::MCU diff --git a/src/core/hle/service/mcu/mcu_hwc.cpp b/src/core/hle/service/mcu/mcu_hwc.cpp new file mode 100644 index 000000000..c2a5d7514 --- /dev/null +++ b/src/core/hle/service/mcu/mcu_hwc.cpp @@ -0,0 +1,36 @@ +// Copyright 2024 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include "common/archives.h" +#include "core/hle/service/mcu/mcu_hwc.h" + +SERIALIZE_EXPORT_IMPL(Service::MCU::HWC) + +namespace Service::MCU { + +HWC::HWC() : ServiceFramework("mcu::HWC", 1) { + static const FunctionInfo functions[] = { + // clang-format off + {0x0001, nullptr, "ReadRegister"}, + {0x0002, nullptr, "WriteRegister"}, + {0x0003, nullptr, "GetInfoRegisters"}, + {0x0004, nullptr, "GetBatteryVoltage"}, + {0x0005, nullptr, "GetBatteryLevel"}, + {0x0006, nullptr, "SetPowerLEDPattern"}, + {0x0007, nullptr, "SetWifiLEDState"}, + {0x0008, nullptr, "SetCameraLEDPattern"}, + {0x0009, nullptr, "Set3DLEDState"}, + {0x000A, nullptr, "SetInfoLEDPattern"}, + {0x000B, nullptr, "GetSoundVolume"}, + {0x000C, nullptr, "SetTopScreenFlicker"}, + {0x000D, nullptr, "SetBottomScreenFlicker"}, + {0x000F, nullptr, "GetRtcTime"}, + {0x0010, nullptr, "GetMcuFwVerHigh"}, + {0x0011, nullptr, "GetMcuFwVerLow"}, + // clang-format on + }; + RegisterHandlers(functions); +} + +} // namespace Service::MCU diff --git a/src/core/hle/service/mcu/mcu_hwc.h b/src/core/hle/service/mcu/mcu_hwc.h new file mode 100644 index 000000000..fdcd7bf2f --- /dev/null +++ b/src/core/hle/service/mcu/mcu_hwc.h @@ -0,0 +1,21 @@ +// Copyright 2024 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include "core/hle/service/service.h" + +namespace Service::MCU { + +class HWC final : public ServiceFramework { +public: + explicit HWC(); + +private: + SERVICE_SERIALIZATION_SIMPLE +}; + +} // namespace Service::MCU + +BOOST_CLASS_EXPORT_KEY(Service::MCU::HWC) diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index 133bfce20..49b394bcd 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp @@ -35,6 +35,7 @@ #include "core/hle/service/http/http_c.h" #include "core/hle/service/ir/ir.h" #include "core/hle/service/ldr_ro/ldr_ro.h" +#include "core/hle/service/mcu/mcu.h" #include "core/hle/service/mic/mic_u.h" #include "core/hle/service/mvd/mvd.h" #include "core/hle/service/ndm/ndm_u.h" @@ -101,7 +102,7 @@ const std::array service_module_map{ {"CDC", 0x00040130'00001802, nullptr}, {"GPIO", 0x00040130'00001B02, nullptr}, {"I2C", 0x00040130'00001E02, nullptr}, - {"MCU", 0x00040130'00001F02, nullptr}, + {"MCU", 0x00040130'00001F02, MCU::InstallInterfaces}, {"MP", 0x00040130'00002A02, nullptr}, {"PDN", 0x00040130'00002102, nullptr}, {"SPI", 0x00040130'00002302, nullptr}}};