2018-09-07 16:00:13 +01:00
|
|
|
/*
|
2019-04-08 03:00:49 +01:00
|
|
|
* Copyright (c) 2018-2019 Atmosphère-NX
|
2018-09-07 16:00:13 +01:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms and conditions of the GNU General Public License,
|
|
|
|
* version 2, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2019-06-18 00:29:09 +01:00
|
|
|
|
2018-04-19 06:15:17 +01:00
|
|
|
#pragma once
|
|
|
|
#include <switch.h>
|
2018-10-30 05:33:56 +00:00
|
|
|
#include <stratosphere.hpp>
|
2018-04-19 06:15:17 +01:00
|
|
|
|
|
|
|
#include "ldr_registration.hpp"
|
2018-04-22 02:52:49 +01:00
|
|
|
#include "ldr_process_creation.hpp"
|
2018-04-19 06:15:17 +01:00
|
|
|
|
|
|
|
enum ProcessManagerServiceCmd {
|
|
|
|
Pm_Cmd_CreateProcess = 0,
|
|
|
|
Pm_Cmd_GetProgramInfo = 1,
|
|
|
|
Pm_Cmd_RegisterTitle = 2,
|
|
|
|
Pm_Cmd_UnregisterTitle = 3
|
|
|
|
};
|
|
|
|
|
2018-06-12 23:00:09 +01:00
|
|
|
class ProcessManagerService final : public IServiceObject {
|
2018-04-21 04:38:51 +01:00
|
|
|
struct ProgramInfo {
|
|
|
|
u8 main_thread_priority;
|
|
|
|
u8 default_cpu_id;
|
|
|
|
u16 application_type;
|
|
|
|
u32 main_thread_stack_size;
|
2018-05-01 23:49:20 +01:00
|
|
|
u64 title_id;
|
2018-04-21 04:38:51 +01:00
|
|
|
u32 acid_sac_size;
|
|
|
|
u32 aci0_sac_size;
|
|
|
|
u32 acid_fac_size;
|
2018-04-21 06:58:42 +01:00
|
|
|
u32 aci0_fah_size;
|
2018-04-21 04:38:51 +01:00
|
|
|
u8 ac_buffer[0x3E0];
|
|
|
|
};
|
2019-06-18 00:29:09 +01:00
|
|
|
|
|
|
|
static_assert(sizeof(ProcessManagerService::ProgramInfo) == 0x400, "Incorrect ProgramInfo definition.");
|
2018-04-19 06:15:17 +01:00
|
|
|
private:
|
|
|
|
/* Actual commands. */
|
2018-10-30 13:29:30 +00:00
|
|
|
Result CreateProcess(Out<MovedHandle> proc_h, u64 index, u32 flags, CopiedHandle reslimit_h);
|
|
|
|
Result GetProgramInfo(OutPointerWithServerSize<ProcessManagerService::ProgramInfo, 0x1> out_program_info, Registration::TidSid tid_sid);
|
2018-10-30 05:33:56 +00:00
|
|
|
Result RegisterTitle(Out<u64> index, Registration::TidSid tid_sid);
|
|
|
|
Result UnregisterTitle(u64 index);
|
2019-06-18 00:29:09 +01:00
|
|
|
|
2018-04-21 06:58:42 +01:00
|
|
|
/* Utilities */
|
2018-10-30 05:33:56 +00:00
|
|
|
Result PopulateProgramInfoBuffer(ProcessManagerService::ProgramInfo *out, Registration::TidSid *tid_sid);
|
|
|
|
public:
|
|
|
|
DEFINE_SERVICE_DISPATCH_TABLE {
|
|
|
|
MakeServiceCommandMeta<Pm_Cmd_CreateProcess, &ProcessManagerService::CreateProcess>(),
|
|
|
|
MakeServiceCommandMeta<Pm_Cmd_GetProgramInfo, &ProcessManagerService::GetProgramInfo>(),
|
|
|
|
MakeServiceCommandMeta<Pm_Cmd_RegisterTitle, &ProcessManagerService::RegisterTitle>(),
|
|
|
|
MakeServiceCommandMeta<Pm_Cmd_UnregisterTitle, &ProcessManagerService::UnregisterTitle>(),
|
|
|
|
};
|
2018-06-03 06:46:27 +01:00
|
|
|
};
|