mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-11-09 22:56:35 +00:00
Stratosphere: Skeleton ldr:pm (RegisterTitle/UnregisterTitle are implemented)
This commit is contained in:
parent
30e401d125
commit
af11f9fdec
6 changed files with 106 additions and 6 deletions
|
@ -7,6 +7,7 @@
|
|||
|
||||
#include "waitablemanager.hpp"
|
||||
#include "serviceserver.hpp"
|
||||
#include "ldr_process_manager.hpp"
|
||||
#include "ldr_debug_monitor.hpp"
|
||||
#include "ldr_shell.hpp"
|
||||
|
||||
|
@ -39,6 +40,7 @@ int main(int argc, char **argv)
|
|||
WaitableManager *server_manager = new WaitableManager(U64_MAX);
|
||||
|
||||
/* Add services to manager. */
|
||||
server_manager->add_waitable(new ServiceServer<ProcessManagerService>("dbg:pm", 1));
|
||||
server_manager->add_waitable(new ServiceServer<ShellService>("dbg:shel", 3));
|
||||
server_manager->add_waitable(new ServiceServer<DebugMonitorService>("dbg:dmnt", 2));
|
||||
|
||||
|
|
74
stratosphere/loader/source/ldr_process_manager.cpp
Normal file
74
stratosphere/loader/source/ldr_process_manager.cpp
Normal file
|
@ -0,0 +1,74 @@
|
|||
#include <switch.h>
|
||||
#include "ldr_process_manager.hpp"
|
||||
#include "ldr_registration.hpp"
|
||||
#include "ldr_launch_queue.hpp"
|
||||
|
||||
Result ProcessManagerService::dispatch(IpcParsedCommand *r, IpcCommand *out_c, u32 *cmd_buf, u32 cmd_id, u32 *in_rawdata, u32 in_rawdata_size, u32 *out_rawdata, u32 *out_raw_data_count) {
|
||||
|
||||
Result rc = 0xF601;
|
||||
|
||||
switch ((ProcessManagerServiceCmd)cmd_id) {
|
||||
case Pm_Cmd_CreateProcess:
|
||||
/* TODO */
|
||||
break;
|
||||
case Pm_Cmd_GetProgramInfo:
|
||||
/* TODO */
|
||||
break;
|
||||
case Pm_Cmd_RegisterTitle:
|
||||
/* Validate arguments. */
|
||||
if (in_rawdata_size < 0x10 || r->HasPid || r->NumHandles != 0 || r->NumBuffers != 0 || r->NumStatics != 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
u64 out_index;
|
||||
rc = register_title((Registration::TidSid *)in_rawdata, &out_index);
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
((u64 *)out_rawdata)[0] = out_index;
|
||||
*out_raw_data_count = 8;
|
||||
} else {
|
||||
((u64 *)out_rawdata)[0] = 0;
|
||||
*out_raw_data_count = 0;
|
||||
}
|
||||
|
||||
break;
|
||||
case Pm_Cmd_UnregisterTitle:
|
||||
/* Validate arguments. */
|
||||
if (in_rawdata_size < 0x8 || r->HasPid || r->NumHandles != 0 || r->NumBuffers != 0 || r->NumStatics != 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
rc = unregister_title(((u64 *)in_rawdata)[0]);
|
||||
*out_raw_data_count = 0;
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
Result ProcessManagerService::create_process() {
|
||||
/* TODO */
|
||||
return 0xF601;
|
||||
}
|
||||
|
||||
Result ProcessManagerService::get_program_info() {
|
||||
/* TODO */
|
||||
return 0xF601;
|
||||
}
|
||||
|
||||
Result ProcessManagerService::register_title(const Registration::TidSid *tid_sid, u64 *out_index) {
|
||||
if (Registration::register_tid_sid(tid_sid, out_index)) {
|
||||
return 0;
|
||||
} else {
|
||||
return 0xE09;
|
||||
}
|
||||
}
|
||||
|
||||
Result ProcessManagerService::unregister_title(u64 index) {
|
||||
if (Registration::unregister_index(index)) {
|
||||
return 0;
|
||||
} else {
|
||||
return 0x1009;
|
||||
}
|
||||
}
|
24
stratosphere/loader/source/ldr_process_manager.hpp
Normal file
24
stratosphere/loader/source/ldr_process_manager.hpp
Normal file
|
@ -0,0 +1,24 @@
|
|||
#pragma once
|
||||
#include <switch.h>
|
||||
|
||||
#include "iserviceobject.hpp"
|
||||
#include "ldr_registration.hpp"
|
||||
|
||||
enum ProcessManagerServiceCmd {
|
||||
Pm_Cmd_CreateProcess = 0,
|
||||
Pm_Cmd_GetProgramInfo = 1,
|
||||
Pm_Cmd_RegisterTitle = 2,
|
||||
Pm_Cmd_UnregisterTitle = 3
|
||||
};
|
||||
|
||||
class ProcessManagerService : IServiceObject {
|
||||
public:
|
||||
Result dispatch(IpcParsedCommand *r, IpcCommand *out_c, 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 create_process();
|
||||
Result get_program_info();
|
||||
Result register_title(const Registration::TidSid *tid_sid, u64 *out_index);
|
||||
Result unregister_title(u64 index);
|
||||
};
|
|
@ -6,7 +6,7 @@
|
|||
static Registration::List g_registration_list = {0};
|
||||
static u64 g_num_registered = 1;
|
||||
|
||||
Registration::Process *get_free_process() {
|
||||
Registration::Process *Registration::get_free_process() {
|
||||
unsigned int i;
|
||||
for (i = 0; i < REGISTRATION_LIST_MAX; i++) {
|
||||
if (!g_registration_list.processes[i].in_use) {
|
||||
|
@ -16,7 +16,7 @@ Registration::Process *get_free_process() {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
Registration::Process *get_process(u64 index) {
|
||||
Registration::Process *Registration::get_process(u64 index) {
|
||||
unsigned int i;
|
||||
for (i = 0; !g_registration_list.processes[i].in_use || g_registration_list.processes[i].index != index; i++) {
|
||||
if (i >= REGISTRATION_LIST_MAX) {
|
||||
|
|
|
@ -7,7 +7,7 @@ Result ShellService::dispatch(IpcParsedCommand *r, IpcCommand *out_c, u32 *cmd_b
|
|||
Result rc = 0xF601;
|
||||
|
||||
switch ((ShellServiceCmd)cmd_id) {
|
||||
case Cmd_AddTitleToLaunchQueue:
|
||||
case Shell_Cmd_AddTitleToLaunchQueue:
|
||||
/* Validate arguments. */
|
||||
if (in_rawdata_size < 0x10 || r->HasPid || r->NumHandles != 0 || r->NumBuffers != 0 || r->NumStatics != 1) {
|
||||
break;
|
||||
|
@ -23,7 +23,7 @@ Result ShellService::dispatch(IpcParsedCommand *r, IpcCommand *out_c, u32 *cmd_b
|
|||
*out_raw_data_count = 0;
|
||||
|
||||
break;
|
||||
case Cmd_ClearLaunchQueue:
|
||||
case Shell_Cmd_ClearLaunchQueue:
|
||||
if (r->HasPid || r->NumHandles != 0 || r->NumBuffers != 0 || r->NumStatics != 0) {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
#include "iserviceobject.hpp"
|
||||
|
||||
enum ShellServiceCmd {
|
||||
Cmd_AddTitleToLaunchQueue = 0,
|
||||
Cmd_ClearLaunchQueue = 1
|
||||
Shell_Cmd_AddTitleToLaunchQueue = 0,
|
||||
Shell_Cmd_ClearLaunchQueue = 1
|
||||
};
|
||||
|
||||
class ShellService : IServiceObject {
|
||||
|
|
Loading…
Reference in a new issue