diff --git a/CMakeLists.txt b/CMakeLists.txt index b78871c3..6fc6fe2a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,7 +82,7 @@ set(SERVICE_SOURCE_FILES src/core/services/service_manager.cpp src/core/services src/core/services/ac.cpp src/core/services/am.cpp src/core/services/boss.cpp 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/act.cpp src/core/services/nfc.cpp src/core/services/dlp_srvr.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 @@ -112,7 +112,7 @@ set(HEADER_FILES include/emulator.hpp include/helpers.hpp include/opengl.hpp inc include/fs/archive_ext_save_data.hpp include/services/shared_font.hpp include/fs/archive_ncch.hpp include/renderer_gl/textures.hpp include/colour.hpp include/services/y2r.hpp include/services/cam.hpp include/services/ldr_ro.hpp include/ipc.hpp include/services/act.hpp include/services/nfc.hpp - include/system_models.hpp + include/system_models.hpp include/services/dlp_srvr.hpp ) set(THIRD_PARTY_SOURCE_FILES third_party/imgui/imgui.cpp diff --git a/include/kernel/handles.hpp b/include/kernel/handles.hpp index 9b13460a..589b64f5 100644 --- a/include/kernel/handles.hpp +++ b/include/kernel/handles.hpp @@ -18,11 +18,12 @@ namespace KernelHandles { CAM, // Camera service CECD, // More Streetpass stuff? CFG, // CFG service (Console & region info) + 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) FRD, // Friend service (Miiverse friend service) FS, // Filesystem service GPU, // GPU service - DSP, // DSP service (Used for audio decoding and output) LCD, // LCD service (Used for configuring the displays) LDR_RO, // Loader service. Used for loading CROs. MIC, // MIC service (Controls the microphone) @@ -64,10 +65,11 @@ namespace KernelHandles { case CAM: return "CAM"; case CECD: return "CECD"; case CFG: return "CFG"; + case DSP: return "DSP"; + case DLP_SRVR: return "DLP::SRVR"; case HID: return "HID"; case FRD: return "FRD"; case FS: return "FS"; - case DSP: return "DSP"; case GPU: return "GSP::GPU"; case LCD: return "GSP::LCD"; case LDR_RO: return "LDR:RO"; diff --git a/include/logger.hpp b/include/logger.hpp index 5ffd707b..eec3b400 100644 --- a/include/logger.hpp +++ b/include/logger.hpp @@ -38,6 +38,7 @@ namespace Log { static Logger cecdLogger; static Logger cfgLogger; static Logger dspServiceLogger; + static Logger dlpSrvrLogger; static Logger frdLogger; static Logger fsLogger; static Logger hidLogger; diff --git a/include/services/dlp_srvr.hpp b/include/services/dlp_srvr.hpp new file mode 100644 index 00000000..c4be004f --- /dev/null +++ b/include/services/dlp_srvr.hpp @@ -0,0 +1,21 @@ +#pragma once +#include "helpers.hpp" +#include "kernel_types.hpp" +#include "logger.hpp" +#include "memory.hpp" + +// Please forgive me for how everything in this file is named +// "dlp:SRVR" is not a nice name to work with +class DlpSrvrService { + Handle handle = KernelHandles::DLP_SRVR; + Memory& mem; + MAKE_LOG_FUNCTION(log, dlpSrvrLogger) + + // Service commands + void isChild(u32 messagePointer); + +public: + DlpSrvrService(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 25e4d8f0..2a50ffaf 100644 --- a/include/services/service_manager.hpp +++ b/include/services/service_manager.hpp @@ -12,6 +12,7 @@ #include "services/cam.hpp" #include "services/cecd.hpp" #include "services/cfg.hpp" +#include "services/dlp_srvr.hpp" #include "services/dsp.hpp" #include "services/hid.hpp" #include "services/frd.hpp" @@ -46,6 +47,7 @@ class ServiceManager { CAMService cam; CECDService cecd; CFGService cfg; + DlpSrvrService dlp_srvr; DSPService dsp; HIDService hid; FRDService frd; diff --git a/src/core/services/dlp_srvr.cpp b/src/core/services/dlp_srvr.cpp new file mode 100644 index 00000000..3e465e21 --- /dev/null +++ b/src/core/services/dlp_srvr.cpp @@ -0,0 +1,32 @@ +#include "services/dlp_srvr.hpp" +#include "ipc.hpp" + +namespace DlpSrvrCommands { + enum : u32 { + IsChild = 0x000E0040 + }; +} + +namespace Result { + enum : u32 { + Success = 0, + }; +} + +void DlpSrvrService::reset() {} + +void DlpSrvrService::handleSyncRequest(u32 messagePointer) { + const u32 command = mem.read32(messagePointer); + switch (command) { + case DlpSrvrCommands::IsChild: isChild(messagePointer); break; + default: Helpers::panic("DLP::SRVR service requested. Command: %08X\n", command); + } +} + +void DlpSrvrService::isChild(u32 messagePointer) { + log("DLP::SRVR: IsChild\n"); + + mem.write32(messagePointer, IPC::responseHeader(0x0E, 2, 0)); + mem.write32(messagePointer + 4, Result::Success); + mem.write32(messagePointer + 8, 0); // We are responsible adults +} \ No newline at end of file diff --git a/src/core/services/service_manager.cpp b/src/core/services/service_manager.cpp index 8b14e5e1..27b39af9 100644 --- a/src/core/services/service_manager.cpp +++ b/src/core/services/service_manager.cpp @@ -5,7 +5,7 @@ ServiceManager::ServiceManager(std::array& 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), 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), 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) {} @@ -21,6 +21,7 @@ void ServiceManager::reset() { cam.reset(); cecd.reset(); cfg.reset(); + dlp_srvr.reset(); dsp.reset(); hid.reset(); frd.reset(); @@ -97,6 +98,7 @@ static std::map serviceMap = { { "cam:u", KernelHandles::CAM }, { "cecd:u", KernelHandles::CECD }, { "cfg:u", KernelHandles::CFG }, + { "dlp:SRVR", KernelHandles::DLP_SRVR }, { "dsp::DSP", KernelHandles::DSP }, { "hid:USER", KernelHandles::HID }, { "frd:u", KernelHandles::FRD }, @@ -170,6 +172,7 @@ void ServiceManager::sendCommandToService(u32 messagePointer, Handle handle) { case KernelHandles::GPU: [[likely]] gsp_gpu.handleSyncRequest(messagePointer); break; case KernelHandles::FS: [[likely]] fs.handleSyncRequest(messagePointer); break; case KernelHandles::APT: [[likely]] apt.handleSyncRequest(messagePointer); break; + case KernelHandles::DSP: [[likely]] dsp.handleSyncRequest(messagePointer); break; case KernelHandles::AC: ac.handleSyncRequest(messagePointer); break; case KernelHandles::ACT: act.handleSyncRequest(messagePointer); break; @@ -178,7 +181,7 @@ void ServiceManager::sendCommandToService(u32 messagePointer, Handle handle) { case KernelHandles::CAM: cam.handleSyncRequest(messagePointer); break; case KernelHandles::CECD: cecd.handleSyncRequest(messagePointer); break; case KernelHandles::CFG: cfg.handleSyncRequest(messagePointer); break; - case KernelHandles::DSP: dsp.handleSyncRequest(messagePointer); break; + case KernelHandles::DLP_SRVR: dlp_srvr.handleSyncRequest(messagePointer); break; case KernelHandles::HID: hid.handleSyncRequest(messagePointer); break; case KernelHandles::FRD: frd.handleSyncRequest(messagePointer); break; case KernelHandles::LCD: gsp_lcd.handleSyncRequest(messagePointer); break;