2018-04-19 05:15:17 +00:00
|
|
|
#include <switch.h>
|
|
|
|
#include "ldr_process_manager.hpp"
|
|
|
|
#include "ldr_registration.hpp"
|
|
|
|
#include "ldr_launch_queue.hpp"
|
|
|
|
|
2018-04-21 01:34:29 +00:00
|
|
|
Result ProcessManagerService::dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size) {
|
2018-04-19 05:15:17 +00:00
|
|
|
|
|
|
|
Result rc = 0xF601;
|
|
|
|
|
|
|
|
switch ((ProcessManagerServiceCmd)cmd_id) {
|
|
|
|
case Pm_Cmd_CreateProcess:
|
2018-04-21 01:34:29 +00:00
|
|
|
rc = WrapIpcCommandImpl<&ProcessManagerService::create_process>(this, r, out_c, pointer_buffer, pointer_buffer_size);
|
2018-04-19 05:15:17 +00:00
|
|
|
break;
|
|
|
|
case Pm_Cmd_GetProgramInfo:
|
2018-04-21 01:34:29 +00:00
|
|
|
rc = WrapIpcCommandImpl<&ProcessManagerService::get_program_info>(this, r, out_c, pointer_buffer, pointer_buffer_size);
|
2018-04-19 05:15:17 +00:00
|
|
|
break;
|
2018-04-21 01:34:29 +00:00
|
|
|
case Pm_Cmd_RegisterTitle:
|
|
|
|
rc = WrapIpcCommandImpl<&ProcessManagerService::register_title>(this, r, out_c, pointer_buffer, pointer_buffer_size);
|
2018-04-19 05:15:17 +00:00
|
|
|
break;
|
|
|
|
case Pm_Cmd_UnregisterTitle:
|
2018-04-21 01:34:29 +00:00
|
|
|
rc = WrapIpcCommandImpl<&ProcessManagerService::unregister_title>(this, r, out_c, pointer_buffer, pointer_buffer_size);
|
2018-04-19 05:15:17 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2018-04-21 01:34:29 +00:00
|
|
|
std::tuple<Result> ProcessManagerService::create_process() {
|
2018-04-19 05:15:17 +00:00
|
|
|
/* TODO */
|
2018-04-21 01:34:29 +00:00
|
|
|
return std::make_tuple(0xF601);
|
2018-04-19 05:15:17 +00:00
|
|
|
}
|
|
|
|
|
2018-04-21 01:34:29 +00:00
|
|
|
std::tuple<Result> ProcessManagerService::get_program_info() {
|
2018-04-19 05:15:17 +00:00
|
|
|
/* TODO */
|
2018-04-21 01:34:29 +00:00
|
|
|
return std::make_tuple(0xF601);
|
2018-04-19 05:15:17 +00:00
|
|
|
}
|
|
|
|
|
2018-04-21 01:34:29 +00:00
|
|
|
std::tuple<Result, u64> ProcessManagerService::register_title(Registration::TidSid tid_sid) {
|
|
|
|
u64 out_index = 0;
|
|
|
|
if (Registration::register_tid_sid(&tid_sid, &out_index)) {
|
|
|
|
return std::make_tuple(0, out_index);
|
2018-04-19 05:15:17 +00:00
|
|
|
} else {
|
2018-04-21 01:34:29 +00:00
|
|
|
return std::make_tuple(0xE09, out_index);
|
2018-04-19 05:15:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-21 01:34:29 +00:00
|
|
|
std::tuple<Result> ProcessManagerService::unregister_title(u64 index) {
|
2018-04-19 05:15:17 +00:00
|
|
|
if (Registration::unregister_index(index)) {
|
2018-04-21 01:34:29 +00:00
|
|
|
return std::make_tuple(0);
|
2018-04-19 05:15:17 +00:00
|
|
|
} else {
|
2018-04-21 01:34:29 +00:00
|
|
|
return std::make_tuple(0x1009);
|
2018-04-19 05:15:17 +00:00
|
|
|
}
|
|
|
|
}
|