2018-04-19 05:15:17 +00:00
|
|
|
#pragma once
|
|
|
|
#include <switch.h>
|
2018-04-22 02:31:06 +00:00
|
|
|
#include <stratosphere/iserviceobject.hpp>
|
2018-04-19 05:15:17 +00:00
|
|
|
|
|
|
|
#include "ldr_registration.hpp"
|
2018-04-22 01:52:49 +00:00
|
|
|
#include "ldr_process_creation.hpp"
|
2018-04-19 05:15:17 +00:00
|
|
|
|
|
|
|
enum ProcessManagerServiceCmd {
|
|
|
|
Pm_Cmd_CreateProcess = 0,
|
|
|
|
Pm_Cmd_GetProgramInfo = 1,
|
|
|
|
Pm_Cmd_RegisterTitle = 2,
|
|
|
|
Pm_Cmd_UnregisterTitle = 3
|
|
|
|
};
|
|
|
|
|
2018-06-12 22:00:09 +00:00
|
|
|
class ProcessManagerService final : public IServiceObject {
|
2018-04-21 03:38:51 +00:00
|
|
|
struct ProgramInfo {
|
|
|
|
u8 main_thread_priority;
|
|
|
|
u8 default_cpu_id;
|
|
|
|
u16 application_type;
|
|
|
|
u32 main_thread_stack_size;
|
2018-05-01 22:49:20 +00:00
|
|
|
u64 title_id;
|
2018-04-21 03:38:51 +00:00
|
|
|
u32 acid_sac_size;
|
|
|
|
u32 aci0_sac_size;
|
|
|
|
u32 acid_fac_size;
|
2018-04-21 05:58:42 +00:00
|
|
|
u32 aci0_fah_size;
|
2018-04-21 03:38:51 +00:00
|
|
|
u8 ac_buffer[0x3E0];
|
|
|
|
};
|
|
|
|
|
|
|
|
static_assert(sizeof(ProcessManagerService::ProgramInfo) == 0x400, "Incorrect ProgramInfo definition.");
|
|
|
|
|
2018-04-19 05:15:17 +00:00
|
|
|
public:
|
2018-06-03 05:46:27 +00:00
|
|
|
Result dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size) override;
|
|
|
|
Result handle_deferred() override {
|
2018-04-22 09:02:08 +00:00
|
|
|
/* This service will never defer. */
|
|
|
|
return 0;
|
|
|
|
}
|
2018-04-19 05:15:17 +00:00
|
|
|
|
2018-06-14 23:50:01 +00:00
|
|
|
ProcessManagerService *clone() override {
|
|
|
|
return new ProcessManagerService();
|
|
|
|
}
|
|
|
|
|
2018-04-19 05:15:17 +00:00
|
|
|
private:
|
|
|
|
/* Actual commands. */
|
2018-04-22 01:52:49 +00:00
|
|
|
std::tuple<Result, MovedHandle> create_process(u64 flags, u64 index, CopiedHandle reslimit_h);
|
2018-04-21 03:38:51 +00:00
|
|
|
std::tuple<Result> get_program_info(Registration::TidSid tid_sid, OutPointerWithServerSize<ProcessManagerService::ProgramInfo, 0x1> out_program_info);
|
2018-04-21 01:34:29 +00:00
|
|
|
std::tuple<Result, u64> register_title(Registration::TidSid tid_sid);
|
|
|
|
std::tuple<Result> unregister_title(u64 index);
|
2018-04-21 05:58:42 +00:00
|
|
|
|
|
|
|
/* Utilities */
|
|
|
|
Result populate_program_info_buffer(ProcessManagerService::ProgramInfo *out, Registration::TidSid *tid_sid);
|
2018-06-03 05:46:27 +00:00
|
|
|
};
|