2018-04-18 10:57:18 +01:00
|
|
|
#include <switch.h>
|
|
|
|
#include "ldr_shell.hpp"
|
|
|
|
#include "ldr_launch_queue.hpp"
|
|
|
|
|
2018-04-18 19:53:04 +01:00
|
|
|
Result ShellService::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) {
|
2018-04-18 10:57:18 +01:00
|
|
|
|
|
|
|
Result rc = 0xF601;
|
2018-04-19 06:00:10 +01:00
|
|
|
|
2018-04-18 10:57:18 +01:00
|
|
|
switch ((ShellServiceCmd)cmd_id) {
|
2018-04-19 06:15:17 +01:00
|
|
|
case Shell_Cmd_AddTitleToLaunchQueue:
|
2018-04-18 10:57:18 +01:00
|
|
|
/* Validate arguments. */
|
|
|
|
if (in_rawdata_size < 0x10 || r->HasPid || r->NumHandles != 0 || r->NumBuffers != 0 || r->NumStatics != 1) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2018-04-19 06:00:10 +01:00
|
|
|
if (r->Statics[0] == NULL) {
|
|
|
|
rc = 0xCE01;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2018-04-18 10:57:18 +01:00
|
|
|
rc = add_title_to_launch_queue(((u64 *)in_rawdata)[0], (const char *)r->Statics[0], r->StaticSizes[0]);
|
|
|
|
|
|
|
|
*out_raw_data_count = 0;
|
|
|
|
|
|
|
|
break;
|
2018-04-19 06:15:17 +01:00
|
|
|
case Shell_Cmd_ClearLaunchQueue:
|
2018-04-18 10:57:18 +01:00
|
|
|
if (r->HasPid || r->NumHandles != 0 || r->NumBuffers != 0 || r->NumStatics != 0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = clear_launch_queue();
|
|
|
|
*out_raw_data_count = 0;
|
|
|
|
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
Result ShellService::add_title_to_launch_queue(u64 tid, const char *args, size_t args_size) {
|
|
|
|
return LaunchQueue::add(tid, args, args_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
Result ShellService::clear_launch_queue() {
|
|
|
|
LaunchQueue::clear();
|
|
|
|
return 0;
|
|
|
|
}
|