From 1c08912a59225a0b85e67e3a18df233b7aeb0332 Mon Sep 17 00:00:00 2001 From: wheremyfoodat <44909372+wheremyfoodat@users.noreply.github.com> Date: Sat, 8 Jul 2023 19:35:59 +0300 Subject: [PATCH] [IR:USER] Add empty service --- CMakeLists.txt | 3 ++- include/kernel/handles.hpp | 2 ++ include/logger.hpp | 1 + include/services/ir_user.hpp | 19 +++++++++++++++++++ include/services/service_manager.hpp | 2 ++ src/core/services/ir_user.cpp | 15 +++++++++++++++ src/core/services/service_manager.cpp | 7 ++++++- 7 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 include/services/ir_user.hpp create mode 100644 src/core/services/ir_user.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d446ba7..016b2a59 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -104,6 +104,7 @@ set(SERVICE_SOURCE_FILES src/core/services/service_manager.cpp src/core/services src/core/services/frd.cpp src/core/services/nim.cpp src/core/services/shared_font.cpp src/core/services/y2r.cpp src/core/services/cam.cpp src/core/services/ldr_ro.cpp src/core/services/act.cpp src/core/services/nfc.cpp src/core/services/dlp_srvr.cpp + src/core/services/ir_user.cpp ) set(PICA_SOURCE_FILES src/core/PICA/gpu.cpp src/core/PICA/regs.cpp src/core/PICA/shader_unit.cpp src/core/PICA/shader_interpreter.cpp src/core/PICA/dynapica/shader_rec.cpp @@ -141,7 +142,7 @@ set(HEADER_FILES include/emulator.hpp include/helpers.hpp include/opengl.hpp inc include/result/result_common.hpp include/result/result_fs.hpp include/result/result_fnd.hpp include/result/result_gsp.hpp include/result/result_kernel.hpp include/result/result_os.hpp include/crypto/aes_engine.hpp include/metaprogramming.hpp include/PICA/pica_vertex.hpp include/gl_state.hpp - include/config.hpp + include/config.hpp include/services/ir_user.hpp ) set(THIRD_PARTY_SOURCE_FILES third_party/imgui/imgui.cpp diff --git a/include/kernel/handles.hpp b/include/kernel/handles.hpp index 589b64f5..3656beeb 100644 --- a/include/kernel/handles.hpp +++ b/include/kernel/handles.hpp @@ -21,6 +21,7 @@ namespace KernelHandles { DLP_SRVR, // Download Play: Server. Used for network play. DSP, // DSP service (Used for audio decoding and output) HID, // HID service (Handles everything input-related including gyro) + IR_USER, // One of 3 infrared communication services FRD, // Friend service (Miiverse friend service) FS, // Filesystem service GPU, // GPU service @@ -68,6 +69,7 @@ namespace KernelHandles { case DSP: return "DSP"; case DLP_SRVR: return "DLP::SRVR"; case HID: return "HID"; + case IR_USER: return "IR:USER"; case FRD: return "FRD"; case FS: return "FS"; case GPU: return "GSP::GPU"; diff --git a/include/logger.hpp b/include/logger.hpp index 62129707..e1b425b9 100644 --- a/include/logger.hpp +++ b/include/logger.hpp @@ -42,6 +42,7 @@ namespace Log { static Logger frdLogger; static Logger fsLogger; static Logger hidLogger; + static Logger irUserLogger; static Logger gspGPULogger; static Logger gspLCDLogger; static Logger ldrLogger; diff --git a/include/services/ir_user.hpp b/include/services/ir_user.hpp new file mode 100644 index 00000000..734bec44 --- /dev/null +++ b/include/services/ir_user.hpp @@ -0,0 +1,19 @@ +#pragma once +#include "helpers.hpp" +#include "kernel_types.hpp" +#include "logger.hpp" +#include "memory.hpp" +#include "result/result.hpp" + +class IRUserService { + Handle handle = KernelHandles::IR_USER; + Memory& mem; + MAKE_LOG_FUNCTION(log, irUserLogger) + + // Service commands + + public: + IRUserService(Memory& mem) : mem(mem) {} + void reset(); + void handleSyncRequest(u32 messagePointer); +}; \ No newline at end of file diff --git a/include/services/service_manager.hpp b/include/services/service_manager.hpp index ee2677ad..3136408f 100644 --- a/include/services/service_manager.hpp +++ b/include/services/service_manager.hpp @@ -21,6 +21,7 @@ #include "services/gsp_gpu.hpp" #include "services/gsp_lcd.hpp" #include "services/hid.hpp" +#include "services/ir_user.hpp" #include "services/ldr_ro.hpp" #include "services/mic.hpp" #include "services/ndm.hpp" @@ -52,6 +53,7 @@ class ServiceManager { DlpSrvrService dlp_srvr; DSPService dsp; HIDService hid; + IRUserService ir_user; FRDService frd; FSService fs; GPUService gsp_gpu; diff --git a/src/core/services/ir_user.cpp b/src/core/services/ir_user.cpp new file mode 100644 index 00000000..6a1a9c11 --- /dev/null +++ b/src/core/services/ir_user.cpp @@ -0,0 +1,15 @@ +#include "ipc.hpp" +#include "services/ir_user.hpp" + +namespace IRUserCommands { + enum : u32 {}; +} + +void IRUserService::reset() {} + +void IRUserService::handleSyncRequest(u32 messagePointer) { + const u32 command = mem.read32(messagePointer); + switch (command) { + default: Helpers::panic("ir:USER service requested. Command: %08X\n", command); + } +} \ No newline at end of file diff --git a/src/core/services/service_manager.cpp b/src/core/services/service_manager.cpp index 5f2918de..6ac2478b 100644 --- a/src/core/services/service_manager.cpp +++ b/src/core/services/service_manager.cpp @@ -7,7 +7,7 @@ ServiceManager::ServiceManager(std::span regs, Memory& mem, GPU& gpu, u32& currentPID, Kernel& kernel) : regs(regs), mem(mem), kernel(kernel), ac(mem), am(mem), boss(mem), act(mem), apt(mem, kernel), cam(mem), - cecd(mem, kernel), cfg(mem), dlp_srvr(mem), dsp(mem, kernel), hid(mem, kernel), frd(mem), fs(mem, kernel), + cecd(mem, kernel), cfg(mem), dlp_srvr(mem), dsp(mem, kernel), hid(mem, kernel), ir_user(mem), frd(mem), fs(mem, kernel), gsp_gpu(mem, gpu, kernel, currentPID), gsp_lcd(mem), ldr(mem), mic(mem), nfc(mem, kernel), nim(mem), ndm(mem), ptm(mem), y2r(mem, kernel) {} @@ -26,6 +26,7 @@ void ServiceManager::reset() { dlp_srvr.reset(); dsp.reset(); hid.reset(); + ir_user.reset(); frd.reset(); fs.reset(); gsp_gpu.reset(); @@ -83,6 +84,7 @@ void ServiceManager::registerClient(u32 messagePointer) { mem.write32(messagePointer + 4, Result::Success); } +// clang-format off static std::map serviceMap = { { "ac:u", KernelHandles::AC }, { "act:u", KernelHandles::ACT }, @@ -97,6 +99,7 @@ static std::map serviceMap = { { "dlp:SRVR", KernelHandles::DLP_SRVR }, { "dsp::DSP", KernelHandles::DSP }, { "hid:USER", KernelHandles::HID }, + { "ir:USER", KernelHandles::IR_USER }, { "frd:u", KernelHandles::FRD }, { "fs:USER", KernelHandles::FS }, { "gsp::Gpu", KernelHandles::GPU }, @@ -110,6 +113,7 @@ static std::map serviceMap = { { "ptm:sysm", KernelHandles::PTM }, { "y2r:u", KernelHandles::Y2R } }; +// clang-format on // https://www.3dbrew.org/wiki/SRV:GetServiceHandle void ServiceManager::getServiceHandle(u32 messagePointer) { @@ -179,6 +183,7 @@ void ServiceManager::sendCommandToService(u32 messagePointer, Handle handle) { case KernelHandles::CFG: cfg.handleSyncRequest(messagePointer); break; case KernelHandles::DLP_SRVR: dlp_srvr.handleSyncRequest(messagePointer); break; case KernelHandles::HID: hid.handleSyncRequest(messagePointer); break; + case KernelHandles::IR_USER: ir_user.handleSyncRequest(messagePointer); break; case KernelHandles::FRD: frd.handleSyncRequest(messagePointer); break; case KernelHandles::LCD: gsp_lcd.handleSyncRequest(messagePointer); break; case KernelHandles::LDR_RO: ldr.handleSyncRequest(messagePointer); break;