diff options
author | Zephyron <zephyron@citron-emu.org> | 2025-01-25 14:23:22 +1000 |
---|---|---|
committer | Zephyron <zephyron@citron-emu.org> | 2025-01-25 14:23:22 +1000 |
commit | 0adeac26af77c7fb0605b08ab858a7c8262ffc88 (patch) | |
tree | e568f6b0ca30bb8ff9bb57ce622b275b8147ca0f /src/core | |
parent | 37677052c186a3a0f6e6e0a1c6f842d4e7eeadeb (diff) |
service: mm: Implement proper parameter handling for MM service
Add proper type definitions and parameter handling for the Memory Management
(mm:u) service based on the Switch documentation:
- Add Module enum for hardware components (CPU, GPU, EMC, etc)
- Add Priority and Setting type definitions as u32
- Add EventClearMode enum for initialization
- Implement proper parameter handling for all IPC calls
- Add detailed logging with parameter values
The Module enum now properly reflects the documented hardware components:
CPU, GPU, EMC, System Bus, Memory Select, and NVIDIA modules (NVDEC,
NVENC, NVJPG).
This makes the implementation match the documented nn::mmnv::IRequest
interface.
Refs: switchbrew.org/wiki/Display_services#mm:u
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/hle/service/mm/mm_u.cpp | 28 | ||||
-rw-r--r-- | src/core/hle/service/mm/mm_u.h | 30 |
2 files changed, 52 insertions, 6 deletions
diff --git a/src/core/hle/service/mm/mm_u.cpp b/src/core/hle/service/mm/mm_u.cpp index 6f43b1968..64e3c3eea 100644 --- a/src/core/hle/service/mm/mm_u.cpp +++ b/src/core/hle/service/mm/mm_u.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 "common/logging/log.h" @@ -30,14 +31,23 @@ public: private: void InitializeOld(HLERequestContext& ctx) { - LOG_WARNING(Service_MM, "(STUBBED) called"); + IPC::RequestParser rp{ctx}; + const auto module = rp.PopEnum<Module>(); + const auto priority = rp.Pop<Priority>(); + const auto event_clear_mode = rp.PopEnum<EventClearMode>(); + + LOG_WARNING(Service_MM, "(STUBBED) called, module={:d}, priority={:d}, event_clear_mode={:d}", + static_cast<u32>(module), priority, static_cast<u32>(event_clear_mode)); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); } void FinalizeOld(HLERequestContext& ctx) { - LOG_WARNING(Service_MM, "(STUBBED) called"); + IPC::RequestParser rp{ctx}; + const auto module = rp.PopEnum<Module>(); + + LOG_WARNING(Service_MM, "(STUBBED) called, module={:d}", static_cast<u32>(module)); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(ResultSuccess); @@ -45,9 +55,12 @@ private: void SetAndWaitOld(HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; - min = rp.Pop<u32>(); - max = rp.Pop<u32>(); - LOG_DEBUG(Service_MM, "(STUBBED) called, min=0x{:X}, max=0x{:X}", min, max); + const auto module = rp.PopEnum<Module>(); + min = rp.Pop<Setting>(); + max = rp.Pop<Setting>(); + + LOG_DEBUG(Service_MM, "(STUBBED) called, module={:d}, min=0x{:X}, max=0x{:X}", + static_cast<u32>(module), min, max); current = min; IPC::ResponseBuilder rb{ctx, 2}; @@ -55,7 +68,10 @@ private: } void GetOld(HLERequestContext& ctx) { - LOG_DEBUG(Service_MM, "(STUBBED) called"); + IPC::RequestParser rp{ctx}; + const auto module = rp.PopEnum<Module>(); + + LOG_DEBUG(Service_MM, "(STUBBED) called, module={:d}", static_cast<u32>(module)); IPC::ResponseBuilder rb{ctx, 3}; rb.Push(ResultSuccess); diff --git a/src/core/hle/service/mm/mm_u.h b/src/core/hle/service/mm/mm_u.h index 43117c9b1..bae9eabf8 100644 --- a/src/core/hle/service/mm/mm_u.h +++ b/src/core/hle/service/mm/mm_u.h @@ -1,14 +1,44 @@ // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project +// SPDX-FileCopyrightText: Copyright 2025 citron Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #pragma once +#include "common/common_types.h" + namespace Core { class System; } namespace Service::MM { +enum class Module : u32 { + Cpu = 0, + Gpu = 1, + Emc = 2, + SysBus = 3, + Mselect = 4, + Nvdec = 5, + Nvenc = 6, + Nvjpg = 7, + Test = 8, +}; + +using Priority = u32; +using Setting = u32; + +enum class EventClearMode : u32 { + // TODO: Add specific clear mode values when documented +}; + +// Consolidate settings into a struct for better organization +struct Settings { + Setting min{0}; + Setting max{0}; + Setting current{0}; + u32 id{1}; // Used by newer API versions +}; + void LoopProcess(Core::System& system); } // namespace Service::MM |