From 5345d7c20611ecf58b0411a30183924e31f4d83c Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Wed, 18 Apr 2018 03:57:18 -0600 Subject: [PATCH] Stratosphere: Skeleton ldr:shel --- stratosphere/loader/source/ldr_shell.cpp | 45 ++++++++++++++++++++++++ stratosphere/loader/source/ldr_shell.hpp | 19 ++++++++++ 2 files changed, 64 insertions(+) create mode 100644 stratosphere/loader/source/ldr_shell.cpp create mode 100644 stratosphere/loader/source/ldr_shell.hpp diff --git a/stratosphere/loader/source/ldr_shell.cpp b/stratosphere/loader/source/ldr_shell.cpp new file mode 100644 index 000000000..4ff84acb5 --- /dev/null +++ b/stratosphere/loader/source/ldr_shell.cpp @@ -0,0 +1,45 @@ +#include +#include "ldr_shell.hpp" +#include "ldr_launch_queue.hpp" + +Result ShellService::dispatch(IpcParsedCommand *r, u32 *cmd_buf, u32 cmd_id, u32 *in_rawdata, u32 in_rawdata_size, u32 *out_rawdata, u32 *out_raw_data_count) { + + Result rc = 0xF601; + + /* TODO: Prepare SFCO. */ + + switch ((ShellServiceCmd)cmd_id) { + case Cmd_AddTitleToLaunchQueue: + /* Validate arguments. */ + if (in_rawdata_size < 0x10 || r->HasPid || r->NumHandles != 0 || r->NumBuffers != 0 || r->NumStatics != 1) { + break; + } + + rc = add_title_to_launch_queue(((u64 *)in_rawdata)[0], (const char *)r->Statics[0], r->StaticSizes[0]); + + *out_raw_data_count = 0; + + break; + case Cmd_ClearLaunchQueue: + if (r->HasPid || r->NumHandles != 0 || r->NumBuffers != 0 || r->NumStatics != 0) { + break; + } + + rc = clear_launch_queue(); + *out_raw_data_count = 0; + + break; + default: + break; + } + return rc; +} + +Result ShellService::add_title_to_launch_queue(u64 tid, const char *args, size_t args_size) { + return LaunchQueue::add(tid, args, args_size); +} + +Result ShellService::clear_launch_queue() { + LaunchQueue::clear(); + return 0; +} \ No newline at end of file diff --git a/stratosphere/loader/source/ldr_shell.hpp b/stratosphere/loader/source/ldr_shell.hpp new file mode 100644 index 000000000..295517912 --- /dev/null +++ b/stratosphere/loader/source/ldr_shell.hpp @@ -0,0 +1,19 @@ +#pragma once +#include + +#include "iserviceobject.hpp" + +enum ShellServiceCmd { + Cmd_AddTitleToLaunchQueue = 0, + Cmd_ClearLaunchQueue = 1 +}; + +class ShellService : IServiceObject { + public: + Result 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(); +}; \ No newline at end of file