From c4db563261a6557f98dca88a62ae532ce348f7b6 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Wed, 18 Apr 2018 03:30:34 -0600 Subject: [PATCH] Stratosphere: Skeleton ldr:dmnt --- stratosphere/loader/source/iserviceobject.hpp | 7 +++++++ .../loader/source/ldr_debug_monitor.cpp | 21 +++++++++++++++++++ .../loader/source/ldr_debug_monitor.hpp | 15 +++++++++++++ .../loader/source/ldr_launch_queue.cpp | 21 +++++++++++++++++-- .../loader/source/ldr_launch_queue.hpp | 5 +++-- 5 files changed, 65 insertions(+), 4 deletions(-) create mode 100644 stratosphere/loader/source/iserviceobject.hpp create mode 100644 stratosphere/loader/source/ldr_debug_monitor.cpp create mode 100644 stratosphere/loader/source/ldr_debug_monitor.hpp diff --git a/stratosphere/loader/source/iserviceobject.hpp b/stratosphere/loader/source/iserviceobject.hpp new file mode 100644 index 000000000..5817c2aec --- /dev/null +++ b/stratosphere/loader/source/iserviceobject.hpp @@ -0,0 +1,7 @@ +#pragma once +#include + +class IServiceObject { + public: + virtual void dispatch(IpcParsedCommand *r, u32 *cmd_buf, u32 cmd_id, u32 *in_rawdata, u32 in_rawdata_size, u32 *out_rawdata, u32 *out_raw_data_count); +}; \ No newline at end of file diff --git a/stratosphere/loader/source/ldr_debug_monitor.cpp b/stratosphere/loader/source/ldr_debug_monitor.cpp new file mode 100644 index 000000000..379af82c2 --- /dev/null +++ b/stratosphere/loader/source/ldr_debug_monitor.cpp @@ -0,0 +1,21 @@ +#include +#include "ldr_debug_monitor.hpp" +#include "ldr_launch_queue.hpp" + +void DebugMonitorService::dispatch(IpcParsedCommand *r, u32 *cmd_buf, u32 cmd_id, u32 *in_rawdata, u32 in_rawdata_size, u32 *out_rawdata, u32 *out_raw_data_count) { + /* TODO */ +} + +Result DebugMonitorService::add_title_to_launch_queue(u64 tid, const char *args, size_t args_size) { + return LaunchQueue::add(tid, args, args_size); +} + +Result DebugMonitorService::clear_launch_queue() { + LaunchQueue::clear(); + return 0; +} + +Result DebugMonitorService::get_nso_info(u64 pid, void *out, size_t out_size, u32 *out_num_nsos) { + /* TODO, once I've defined struct NsoInfo elsewhere (in ldr_RegisteredProcesses.hpp) */ + return 0; +} \ No newline at end of file diff --git a/stratosphere/loader/source/ldr_debug_monitor.hpp b/stratosphere/loader/source/ldr_debug_monitor.hpp new file mode 100644 index 000000000..3e278f2f9 --- /dev/null +++ b/stratosphere/loader/source/ldr_debug_monitor.hpp @@ -0,0 +1,15 @@ +#pragma once +#include + +#include "iserviceobject.hpp" + +class DebugMonitorService : IServiceObject { + public: + void dispatch(IpcParsedCommand *r, u32 *cmd_buf, u32 cmd_id, u32 *in_rawdata, u32 in_rawdata_size, u32 *out_rawdata, u32 *out_raw_data_count); + + private: + /* Actual commands. */ + Result add_title_to_launch_queue(u64 tid, const char *args, size_t args_size); + Result clear_launch_queue(); + Result get_nso_info(u64 pid, void *out, size_t out_size, u32 *out_num_nsos); +}; \ No newline at end of file diff --git a/stratosphere/loader/source/ldr_launch_queue.cpp b/stratosphere/loader/source/ldr_launch_queue.cpp index a747edd5d..49736d10b 100644 --- a/stratosphere/loader/source/ldr_launch_queue.cpp +++ b/stratosphere/loader/source/ldr_launch_queue.cpp @@ -1,11 +1,28 @@ +#include +#include + #include "ldr_launch_queue.hpp" -#include namespace LaunchQueue { static LaunchItem g_launch_queue[LAUNCH_QUEUE_SIZE]; - Result add(LaunchItem *item) { + Result add(u64 tid, const char *args, u64 arg_size) { + if(arg_size > LAUNCH_QUEUE_ARG_SIZE_MAX) { + return 0x209; + } + + int idx = get_free_index(tid); + if(idx == LAUNCH_QUEUE_FULL) + return 0x409; + + g_launch_queue[idx].tid = tid; + g_launch_queue[idx].arg_size = arg_size; + std::copy(args, args + arg_size, g_launch_queue[idx].args); + return 0x0; + } + + Result add_item(const LaunchItem *item) { if(item->arg_size > LAUNCH_QUEUE_ARG_SIZE_MAX) { return 0x209; } diff --git a/stratosphere/loader/source/ldr_launch_queue.hpp b/stratosphere/loader/source/ldr_launch_queue.hpp index af4dcfc93..720a76c25 100644 --- a/stratosphere/loader/source/ldr_launch_queue.hpp +++ b/stratosphere/loader/source/ldr_launch_queue.hpp @@ -12,8 +12,9 @@ namespace LaunchQueue { u64 arg_size; char args[LAUNCH_QUEUE_ARG_SIZE_MAX]; }; - - Result add(LaunchItem *item); + + Result add(u64 tid, const char *args, u64 arg_size); + Result add_item(const LaunchItem *item); int get_index(u64 tid); int get_free_index(u64 tid); bool contains(u64 tid);