From d3d426985a38d2d006af0171a24386aa60de81e1 Mon Sep 17 00:00:00 2001 From: wheremyfoodat <44909372+wheremyfoodat@users.noreply.github.com> Date: Mon, 21 Aug 2023 16:45:35 +0300 Subject: [PATCH] Add news:u --- CMakeLists.txt | 4 ++-- include/kernel/handles.hpp | 2 ++ include/logger.hpp | 1 + include/services/news_u.hpp | 18 ++++++++++++++++++ include/services/service_manager.hpp | 4 +++- src/core/services/news_u.cpp | 15 +++++++++++++++ src/core/services/service_manager.cpp | 8 ++++++-- 7 files changed, 47 insertions(+), 5 deletions(-) create mode 100644 include/services/news_u.hpp create mode 100644 src/core/services/news_u.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c730daa..f68617c9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -137,7 +137,7 @@ set(SERVICE_SOURCE_FILES src/core/services/service_manager.cpp src/core/services 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 src/core/services/http.cpp src/core/services/soc.cpp - src/core/services/ssl.cpp + src/core/services/ssl.cpp src/core/services/news_u.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 @@ -178,7 +178,7 @@ set(HEADER_FILES include/emulator.hpp include/helpers.hpp include/termcolor.hpp include/config.hpp include/services/ir_user.hpp include/http_server.hpp include/cheats.hpp include/action_replay.hpp include/renderer_sw/renderer_sw.hpp include/compiler_builtins.hpp include/fs/romfs.hpp include/fs/ivfc.hpp include/discord_rpc.hpp include/services/http.hpp include/result/result_cfg.hpp - include/math_util.hpp include/services/soc.hpp + include/math_util.hpp include/services/soc.hpp include/services/news_u.hpp ) cmrc_add_resource_library( diff --git a/include/kernel/handles.hpp b/include/kernel/handles.hpp index 3e222260..746f51c6 100644 --- a/include/kernel/handles.hpp +++ b/include/kernel/handles.hpp @@ -34,6 +34,7 @@ namespace KernelHandles { NFC, // NFC (Duh), used for Amiibo NIM, // Updates, DLC, etc NDM, // ????? + NEWS_U, // This service literally has 1 command (AddNotification) and I don't even understand what it does PTM, // PTM service (Used for accessing various console info, such as battery, shell and pedometer state) SOC, // Socket service SSL, // SSL service (Totally didn't expect that) @@ -85,6 +86,7 @@ namespace KernelHandles { case MCU_HWC: return "MCU::HWC"; case MIC: return "MIC"; case NDM: return "NDM"; + case NEWS_U: return "NEWS_U"; case NFC: return "NFC"; case NIM: return "NIM"; case PTM: return "PTM"; diff --git a/include/logger.hpp b/include/logger.hpp index 09e8266b..c5a62ea9 100644 --- a/include/logger.hpp +++ b/include/logger.hpp @@ -50,6 +50,7 @@ namespace Log { static Logger ldrLogger; static Logger mcuLogger; static Logger micLogger; + static Logger newsLogger; static Logger nfcLogger; static Logger nimLogger; static Logger ndmLogger; diff --git a/include/services/news_u.hpp b/include/services/news_u.hpp new file mode 100644 index 00000000..61266e9a --- /dev/null +++ b/include/services/news_u.hpp @@ -0,0 +1,18 @@ +#pragma once +#include "helpers.hpp" +#include "kernel_types.hpp" +#include "logger.hpp" +#include "memory.hpp" + +class NewsUService { + Handle handle = KernelHandles::NEWS_U; + Memory& mem; + MAKE_LOG_FUNCTION(log, newsLogger) + + // Service commands + + public: + NewsUService(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 e7030956..437a5ea4 100644 --- a/include/services/service_manager.hpp +++ b/include/services/service_manager.hpp @@ -27,6 +27,7 @@ #include "services/mcu/mcu_hwc.hpp" #include "services/mic.hpp" #include "services/ndm.hpp" +#include "services/news_u.hpp" #include "services/nfc.hpp" #include "services/nim.hpp" #include "services/ptm.hpp" @@ -66,9 +67,10 @@ class ServiceManager { LCDService gsp_lcd; LDRService ldr; MICService mic; + NDMService ndm; + NewsUService news_u; NFCService nfc; NIMService nim; - NDMService ndm; PTMService ptm; SOCService soc; SSLService ssl; diff --git a/src/core/services/news_u.cpp b/src/core/services/news_u.cpp new file mode 100644 index 00000000..ad5df595 --- /dev/null +++ b/src/core/services/news_u.cpp @@ -0,0 +1,15 @@ +#include "ipc.hpp" +#include "services/news_u.hpp" + +namespace NewsCommands { + enum : u32 {}; +} + +void NewsUService::reset() {} + +void NewsUService::handleSyncRequest(u32 messagePointer) { + const u32 command = mem.read32(messagePointer); + switch (command) { + default: Helpers::panic("news:u 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 591d424a..2f196362 100644 --- a/src/core/services/service_manager.cpp +++ b/src/core/services/service_manager.cpp @@ -9,7 +9,7 @@ ServiceManager::ServiceManager(std::span regs, Memory& mem, GPU& gpu, u : regs(regs), mem(mem), kernel(kernel), ac(mem), am(mem), boss(mem), act(mem), apt(mem, kernel), cam(mem, kernel), cecd(mem, kernel), cfg(mem), dlp_srvr(mem), dsp(mem, kernel), hid(mem, kernel), http(mem), ir_user(mem, kernel), frd(mem), fs(mem, kernel), gsp_gpu(mem, gpu, kernel, currentPID), gsp_lcd(mem), ldr(mem), mcu_hwc(mem, config), mic(mem), nfc(mem, kernel), nim(mem), ndm(mem), - ptm(mem, config), soc(mem), ssl(mem), y2r(mem, kernel) {} + news_u(mem), ptm(mem, config), soc(mem), ssl(mem), y2r(mem, kernel) {} static constexpr int MAX_NOTIFICATION_COUNT = 16; @@ -35,8 +35,10 @@ void ServiceManager::reset() { ldr.reset(); mcu_hwc.reset(); mic.reset(); - nim.reset(); ndm.reset(); + news_u.reset(); + nfc.reset(); + nim.reset(); ptm.reset(); soc.reset(); ssl.reset(); @@ -114,6 +116,7 @@ static std::map serviceMap = { { "mcu::HWC", KernelHandles::MCU_HWC }, { "mic:u", KernelHandles::MIC }, { "ndm:u", KernelHandles::NDM }, + { "news:u", KernelHandles::NEWS_U }, { "nfc:u", KernelHandles::NFC }, { "nim:aoc", KernelHandles::NIM }, { "ptm:u", KernelHandles::PTM }, // TODO: ptm:u and ptm:sysm have very different command sets @@ -202,6 +205,7 @@ void ServiceManager::sendCommandToService(u32 messagePointer, Handle handle) { case KernelHandles::NFC: nfc.handleSyncRequest(messagePointer); break; case KernelHandles::NIM: nim.handleSyncRequest(messagePointer); break; case KernelHandles::NDM: ndm.handleSyncRequest(messagePointer); break; + case KernelHandles::NEWS_U: news_u.handleSyncRequest(messagePointer); break; case KernelHandles::PTM: ptm.handleSyncRequest(messagePointer); break; case KernelHandles::SOC: soc.handleSyncRequest(messagePointer); break; case KernelHandles::SSL: ssl.handleSyncRequest(messagePointer); break;