mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-12-22 20:31:14 +00:00
Process Manager: Add stub for pm:shell
This commit is contained in:
parent
5d215ef299
commit
ae830fea95
2 changed files with 182 additions and 0 deletions
132
stratosphere/pm/source/pm_shell.cpp
Normal file
132
stratosphere/pm/source/pm_shell.cpp
Normal file
|
@ -0,0 +1,132 @@
|
|||
#include <switch.h>
|
||||
#include "pm_registration.hpp"
|
||||
#include "pm_shell.hpp"
|
||||
|
||||
static bool g_has_boot_finished = false;
|
||||
|
||||
Result ShellService::dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size) {
|
||||
Result rc = 0xF601;
|
||||
if (kernelAbove500()) {
|
||||
switch ((ShellCmd_5X)cmd_id) {
|
||||
case Shell_Cmd_5X_LaunchProcess:
|
||||
rc = WrapIpcCommandImpl<&ShellService::launch_process>(this, r, out_c, pointer_buffer, pointer_buffer_size);
|
||||
break;
|
||||
case Shell_Cmd_5X_TerminateProcessId:
|
||||
rc = WrapIpcCommandImpl<&ShellService::terminate_process_id>(this, r, out_c, pointer_buffer, pointer_buffer_size);
|
||||
break;
|
||||
case Shell_Cmd_5X_TerminateTitleId:
|
||||
rc = WrapIpcCommandImpl<&ShellService::terminate_title_id>(this, r, out_c, pointer_buffer, pointer_buffer_size);
|
||||
break;
|
||||
case Shell_Cmd_5X_GetProcessWaitEvent:
|
||||
rc = WrapIpcCommandImpl<&ShellService::get_process_wait_event>(this, r, out_c, pointer_buffer, pointer_buffer_size);
|
||||
break;
|
||||
case Shell_Cmd_5X_GetProcessEventType:
|
||||
rc = WrapIpcCommandImpl<&ShellService::get_process_event_type>(this, r, out_c, pointer_buffer, pointer_buffer_size);
|
||||
break;
|
||||
case Shell_Cmd_5X_NotifyBootFinished:
|
||||
rc = WrapIpcCommandImpl<&ShellService::notify_boot_finished>(this, r, out_c, pointer_buffer, pointer_buffer_size);
|
||||
break;
|
||||
case Shell_Cmd_5X_GetApplicationProcessId:
|
||||
rc = WrapIpcCommandImpl<&ShellService::get_application_process_id>(this, r, out_c, pointer_buffer, pointer_buffer_size);
|
||||
break;
|
||||
case Shell_Cmd_5X_BoostSystemMemoryResourceLimit:
|
||||
rc = WrapIpcCommandImpl<&ShellService::boost_system_memory_resource_limit>(this, r, out_c, pointer_buffer, pointer_buffer_size);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch ((ShellCmd)cmd_id) {
|
||||
case Shell_Cmd_LaunchProcess:
|
||||
rc = WrapIpcCommandImpl<&ShellService::launch_process>(this, r, out_c, pointer_buffer, pointer_buffer_size);
|
||||
break;
|
||||
case Shell_Cmd_TerminateProcessId:
|
||||
rc = WrapIpcCommandImpl<&ShellService::terminate_process_id>(this, r, out_c, pointer_buffer, pointer_buffer_size);
|
||||
break;
|
||||
case Shell_Cmd_TerminateTitleId:
|
||||
rc = WrapIpcCommandImpl<&ShellService::terminate_title_id>(this, r, out_c, pointer_buffer, pointer_buffer_size);
|
||||
break;
|
||||
case Shell_Cmd_GetProcessWaitEvent:
|
||||
rc = WrapIpcCommandImpl<&ShellService::get_process_wait_event>(this, r, out_c, pointer_buffer, pointer_buffer_size);
|
||||
break;
|
||||
case Shell_Cmd_GetProcessEventType:
|
||||
rc = WrapIpcCommandImpl<&ShellService::get_process_event_type>(this, r, out_c, pointer_buffer, pointer_buffer_size);
|
||||
break;
|
||||
case Shell_Cmd_FinalizeDeadProcess:
|
||||
rc = WrapIpcCommandImpl<&ShellService::finalize_dead_process>(this, r, out_c, pointer_buffer, pointer_buffer_size);
|
||||
break;
|
||||
case Shell_Cmd_ClearProcessNotificationFlag:
|
||||
rc = WrapIpcCommandImpl<&ShellService::clear_process_notification_flag>(this, r, out_c, pointer_buffer, pointer_buffer_size);
|
||||
break;
|
||||
case Shell_Cmd_NotifyBootFinished:
|
||||
rc = WrapIpcCommandImpl<&ShellService::notify_boot_finished>(this, r, out_c, pointer_buffer, pointer_buffer_size);
|
||||
break;
|
||||
case Shell_Cmd_GetApplicationProcessId:
|
||||
rc = WrapIpcCommandImpl<&ShellService::get_application_process_id>(this, r, out_c, pointer_buffer, pointer_buffer_size);
|
||||
break;
|
||||
case Shell_Cmd_BoostSystemMemoryResourceLimit:
|
||||
rc = WrapIpcCommandImpl<&ShellService::boost_system_memory_resource_limit>(this, r, out_c, pointer_buffer, pointer_buffer_size);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
Result ShellService::handle_deferred() {
|
||||
/* This service is never deferrable. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::tuple<Result, u64> launch_process(u64 launch_flags, Registration::TidSid tid_sid) {
|
||||
/* TODO */
|
||||
return {0xF601, 0};
|
||||
}
|
||||
|
||||
std::tuple<Result> terminate_process_id(u64 pid) {
|
||||
/* TODO */
|
||||
return {0xF601};
|
||||
}
|
||||
|
||||
std::tuple<Result> terminate_title_id(u64 tid) {
|
||||
/* TODO */
|
||||
return {0xF601};
|
||||
}
|
||||
|
||||
std::tuple<Result, CopiedHandle> get_process_wait_event() {
|
||||
/* TODO */
|
||||
return {0xF601, 0};
|
||||
}
|
||||
|
||||
std::tuple<Result, u64, u64> get_process_event_type() {
|
||||
/* TODO */
|
||||
return {0xF601, 0, 0};
|
||||
}
|
||||
|
||||
std::tuple<Result> finalize_dead_process(u64 pid) {
|
||||
/* TODO */
|
||||
return {0xF601};
|
||||
}
|
||||
|
||||
std::tuple<Result> clear_process_notification_flag(u64 pid) {
|
||||
/* TODO */
|
||||
return {0xF601};
|
||||
}
|
||||
|
||||
std::tuple<Result> notify_boot_finished() {
|
||||
u64 boot_pid;
|
||||
if (!g_has_boot_finished) {
|
||||
Registration::LaunchProcess(BOOT2_TITLE_ID, FsStorageId_NandSystem, 0, &boot_pid);
|
||||
g_has_boot_finished = true;
|
||||
}
|
||||
return {0};
|
||||
}
|
||||
|
||||
std::tuple<Result, u64> get_application_process_id() {
|
||||
/* TODO */
|
||||
return {0xF601, 0};
|
||||
}
|
||||
|
||||
std::tuple<Result> boost_system_memory_resource_limit() {
|
||||
/* TODO */
|
||||
return {0xF601};
|
||||
}
|
50
stratosphere/pm/source/pm_shell.hpp
Normal file
50
stratosphere/pm/source/pm_shell.hpp
Normal file
|
@ -0,0 +1,50 @@
|
|||
#pragma once
|
||||
#include <switch.h>
|
||||
#include <stratosphere/iserviceobject.hpp>
|
||||
|
||||
#include "pm_registration.hpp"
|
||||
|
||||
#define BOOT2_TITLE_ID (0x0100000000000008ULL)
|
||||
|
||||
enum ShellCmd {
|
||||
Shell_Cmd_LaunchProcess = 0,
|
||||
Shell_Cmd_TerminateProcessId = 1,
|
||||
Shell_Cmd_TerminateTitleId = 2,
|
||||
Shell_Cmd_GetProcessWaitEvent = 3,
|
||||
Shell_Cmd_GetProcessEventType = 4,
|
||||
Shell_Cmd_FinalizeDeadProcess = 5,
|
||||
Shell_Cmd_ClearProcessNotificationFlag = 6,
|
||||
Shell_Cmd_NotifyBootFinished = 7,
|
||||
Shell_Cmd_GetApplicationProcessId = 8,
|
||||
Shell_Cmd_BoostSystemMemoryResourceLimit = 9
|
||||
};
|
||||
|
||||
enum ShellCmd_5X {
|
||||
Shell_Cmd_5X_LaunchProcess = 0,
|
||||
Shell_Cmd_5X_TerminateProcessId = 1,
|
||||
Shell_Cmd_5X_TerminateTitleId = 2,
|
||||
Shell_Cmd_5X_GetProcessWaitEvent = 3,
|
||||
Shell_Cmd_5X_GetProcessEventType = 4,
|
||||
Shell_Cmd_5X_NotifyBootFinished = 5,
|
||||
Shell_Cmd_5X_GetApplicationProcessId = 6,
|
||||
Shell_Cmd_5X_BoostSystemMemoryResourceLimit = 7
|
||||
};
|
||||
|
||||
class ShellService : IServiceObject {
|
||||
public:
|
||||
virtual Result dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size);
|
||||
virtual Result handle_deferred();
|
||||
|
||||
private:
|
||||
/* Actual commands. */
|
||||
std::tuple<Result, u64> launch_process(u64 launch_flags, Registration::TidSid tid_sid);
|
||||
std::tuple<Result> terminate_process_id(u64 pid);
|
||||
std::tuple<Result> terminate_title_id(u64 tid);
|
||||
std::tuple<Result, CopiedHandle> get_process_wait_event();
|
||||
std::tuple<Result, u64, u64> get_process_event_type();
|
||||
std::tuple<Result> finalize_dead_process(u64 pid);
|
||||
std::tuple<Result> clear_process_notification_flag(u64 pid);
|
||||
std::tuple<Result> notify_boot_finished();
|
||||
std::tuple<Result, u64> get_application_process_id();
|
||||
std::tuple<Result> boost_system_memory_resource_limit();
|
||||
};
|
Loading…
Reference in a new issue