mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-11-14 17:10:06 +00:00
pm: Migrate to cmif serialization
This commit is contained in:
parent
a05c0eac2f
commit
1e0010e8aa
@ -1,33 +1,33 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "core/hle/service/cmif_serialization.h"
|
||||
#include "core/hle/service/pm/boot_mode_service.h"
|
||||
|
||||
namespace Service::PM {
|
||||
|
||||
BootModeService::BootModeService(Core::System& system_) : ServiceFramework{system_, "pm:bm"} {
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, &BootModeService::GetBootMode, "GetBootMode"},
|
||||
{1, &BootModeService::SetMaintenanceBoot, "SetMaintenanceBoot"},
|
||||
{0, C<&BootModeService::GetBootMode>, "GetBootMode"},
|
||||
{1, C<&BootModeService::SetMaintenanceBoot>, "SetMaintenanceBoot"},
|
||||
};
|
||||
RegisterHandlers(functions);
|
||||
}
|
||||
|
||||
void BootModeService::GetBootMode(HLERequestContext& ctx) {
|
||||
Result BootModeService::GetBootMode(Out<u32> out_boot_mode) {
|
||||
LOG_DEBUG(Service_PM, "called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.PushEnum(boot_mode);
|
||||
*out_boot_mode = static_cast<u32>(boot_mode);
|
||||
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
void BootModeService::SetMaintenanceBoot(HLERequestContext& ctx) {
|
||||
Result BootModeService::SetMaintenanceBoot() {
|
||||
LOG_DEBUG(Service_PM, "called");
|
||||
|
||||
boot_mode = BootMode::Maintenance;
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
} // namespace Service::PM
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "core/hle/service/ipc_helpers.h"
|
||||
#include "core/hle/service/cmif_types.h"
|
||||
#include "core/hle/service/pm/pm_types.h"
|
||||
#include "core/hle/service/service.h"
|
||||
|
||||
@ -14,8 +14,8 @@ public:
|
||||
explicit BootModeService(Core::System& system_);
|
||||
|
||||
private:
|
||||
void GetBootMode(HLERequestContext& ctx);
|
||||
void SetMaintenanceBoot(HLERequestContext& ctx);
|
||||
Result GetBootMode(Out<u32> out_boot_mode);
|
||||
Result SetMaintenanceBoot();
|
||||
|
||||
BootMode boot_mode = BootMode::Normal;
|
||||
};
|
||||
|
@ -1,8 +1,8 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "core/hle/service/cmif_serialization.h"
|
||||
#include "core/hle/service/pm/debug_monitor_service.h"
|
||||
#include "core/hle/service/pm/pm_types.h"
|
||||
|
||||
namespace Service::PM {
|
||||
|
||||
@ -10,14 +10,14 @@ DebugMonitorService::DebugMonitorService(Core::System& system_)
|
||||
: ServiceFramework{system_, "pm:dmnt"} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, nullptr, "GetJitDebugProcessIdList"},
|
||||
{0, nullptr, "GetExceptionProcessIdList"},
|
||||
{1, nullptr, "StartProcess"},
|
||||
{2, &DebugMonitorService::GetProcessId, "GetProcessId"},
|
||||
{2, C<&DebugMonitorService::GetProcessId>, "GetProcessId"},
|
||||
{3, nullptr, "HookToCreateProcess"},
|
||||
{4, &DebugMonitorService::GetApplicationProcessId, "GetApplicationProcessId"},
|
||||
{4, C<&DebugMonitorService::GetApplicationProcessId>, "GetApplicationProcessId"},
|
||||
{5, nullptr, "HookToCreateApplicationProgress"},
|
||||
{6, nullptr, "ClearHook"},
|
||||
{65000, &DebugMonitorService::AtmosphereGetProcessInfo, "AtmosphereGetProcessInfo"},
|
||||
{65000, C<&DebugMonitorService::AtmosphereGetProcessInfo>, "AtmosphereGetProcessInfo"},
|
||||
{65001, nullptr, "AtmosphereGetCurrentLimitInfo"},
|
||||
};
|
||||
// clang-format on
|
||||
@ -25,61 +25,38 @@ DebugMonitorService::DebugMonitorService(Core::System& system_)
|
||||
RegisterHandlers(functions);
|
||||
}
|
||||
|
||||
void DebugMonitorService::GetProcessId(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto program_id = rp.PopRaw<u64>();
|
||||
|
||||
Result DebugMonitorService::GetProcessId(Out<ProcessId> out_process_id, u64 program_id) {
|
||||
LOG_DEBUG(Service_PM, "called, program_id={:016X}", program_id);
|
||||
|
||||
auto list = kernel.GetProcessList();
|
||||
auto process =
|
||||
SearchProcessList(list, [program_id](auto& p) { return p->GetProgramId() == program_id; });
|
||||
|
||||
if (process.IsNull()) {
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultProcessNotFound);
|
||||
return;
|
||||
}
|
||||
R_UNLESS(!process.IsNull(), ResultProcessNotFound);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 4};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.Push(process->GetProcessId());
|
||||
*out_process_id = ProcessId(process->GetProcessId());
|
||||
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
void DebugMonitorService::GetApplicationProcessId(HLERequestContext& ctx) {
|
||||
Result DebugMonitorService::GetApplicationProcessId(Out<ProcessId> out_process_id) {
|
||||
LOG_DEBUG(Service_PM, "called");
|
||||
auto list = kernel.GetProcessList();
|
||||
GetApplicationPidGeneric(ctx, list);
|
||||
R_RETURN(GetApplicationPidGeneric(out_process_id, list));
|
||||
}
|
||||
|
||||
void DebugMonitorService::AtmosphereGetProcessInfo(HLERequestContext& ctx) {
|
||||
Result DebugMonitorService::AtmosphereGetProcessInfo(
|
||||
OutCopyHandle<Kernel::KProcess> out_process_handle, Out<ProgramLocation> out_location,
|
||||
Out<OverrideStatus> out_status, ProcessId process_id) {
|
||||
// https://github.com/Atmosphere-NX/Atmosphere/blob/master/stratosphere/pm/source/impl/pm_process_manager.cpp#L614
|
||||
// This implementation is incomplete; only a handle to the process is returned.
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto pid = rp.PopRaw<u64>();
|
||||
const auto pid = process_id.pid;
|
||||
|
||||
LOG_WARNING(Service_PM, "(Partial Implementation) called, pid={:016X}", pid);
|
||||
|
||||
auto list = kernel.GetProcessList();
|
||||
auto process = SearchProcessList(list, [pid](auto& p) { return p->GetProcessId() == pid; });
|
||||
|
||||
if (process.IsNull()) {
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultProcessNotFound);
|
||||
return;
|
||||
}
|
||||
|
||||
struct ProgramLocation {
|
||||
u64 program_id;
|
||||
u8 storage_id;
|
||||
};
|
||||
static_assert(sizeof(ProgramLocation) == 0x10, "ProgramLocation has an invalid size");
|
||||
|
||||
struct OverrideStatus {
|
||||
u64 keys_held;
|
||||
u64 flags;
|
||||
};
|
||||
static_assert(sizeof(OverrideStatus) == 0x10, "OverrideStatus has an invalid size");
|
||||
R_UNLESS(!process.IsNull(), ResultProcessNotFound);
|
||||
|
||||
OverrideStatus override_status{};
|
||||
ProgramLocation program_location{
|
||||
@ -87,11 +64,11 @@ void DebugMonitorService::AtmosphereGetProcessInfo(HLERequestContext& ctx) {
|
||||
.storage_id = 0,
|
||||
};
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 10, 1};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.PushCopyObjects(*process);
|
||||
rb.PushRaw(program_location);
|
||||
rb.PushRaw(override_status);
|
||||
*out_process_handle = process.GetPointerUnsafe();
|
||||
*out_location = program_location;
|
||||
*out_status = override_status;
|
||||
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
} // namespace Service::PM
|
||||
|
@ -3,7 +3,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "core/hle/service/ipc_helpers.h"
|
||||
#include "core/hle/service/cmif_types.h"
|
||||
#include "core/hle/service/pm/pm_types.h"
|
||||
#include "core/hle/service/service.h"
|
||||
|
||||
namespace Service::PM {
|
||||
@ -13,8 +14,10 @@ public:
|
||||
explicit DebugMonitorService(Core::System& system_);
|
||||
|
||||
private:
|
||||
void GetProcessId(HLERequestContext& ctx);
|
||||
void GetApplicationProcessId(HLERequestContext& ctx);
|
||||
void AtmosphereGetProcessInfo(HLERequestContext& ctx);
|
||||
Result GetProcessId(Out<ProcessId> out_process_id, u64 program_id);
|
||||
Result GetApplicationProcessId(Out<ProcessId> out_process_id);
|
||||
Result AtmosphereGetProcessInfo(OutCopyHandle<Kernel::KProcess> out_process_handle,
|
||||
Out<ProgramLocation> out_location,
|
||||
Out<OverrideStatus> out_status, ProcessId process_id);
|
||||
};
|
||||
} // namespace Service::PM
|
||||
|
@ -1,6 +1,7 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "core/hle/service/cmif_serialization.h"
|
||||
#include "core/hle/service/pm/information_service.h"
|
||||
#include "core/hle/service/pm/pm_types.h"
|
||||
|
||||
@ -9,54 +10,40 @@ namespace Service::PM {
|
||||
InformationService::InformationService(Core::System& system_)
|
||||
: ServiceFramework{system_, "pm:info"} {
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, &InformationService::GetProgramId, "GetProgramId"},
|
||||
{65000, &InformationService::AtmosphereGetProcessId, "AtmosphereGetProcessId"},
|
||||
{0, C<&InformationService::GetProgramId>, "GetProgramId"},
|
||||
{65000, C<&InformationService::AtmosphereGetProcessId>, "AtmosphereGetProcessId"},
|
||||
{65001, nullptr, "AtmosphereHasLaunchedProgram"},
|
||||
{65002, nullptr, "AtmosphereGetProcessInfo"},
|
||||
};
|
||||
RegisterHandlers(functions);
|
||||
}
|
||||
|
||||
void InformationService::GetProgramId(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto process_id = rp.PopRaw<u64>();
|
||||
|
||||
Result InformationService::GetProgramId(Out<u64> out_program_id, u64 process_id) {
|
||||
LOG_DEBUG(Service_PM, "called, process_id={:016X}", process_id);
|
||||
|
||||
auto list = kernel.GetProcessList();
|
||||
auto process =
|
||||
SearchProcessList(list, [process_id](auto& p) { return p->GetProcessId() == process_id; });
|
||||
|
||||
if (process.IsNull()) {
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultProcessNotFound);
|
||||
return;
|
||||
}
|
||||
R_UNLESS(!process.IsNull(), ResultProcessNotFound);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 4};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.Push(process->GetProgramId());
|
||||
*out_program_id = process->GetProgramId();
|
||||
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
void InformationService::AtmosphereGetProcessId(HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto program_id = rp.PopRaw<u64>();
|
||||
|
||||
Result InformationService::AtmosphereGetProcessId(Out<ProcessId> out_process_id, u64 program_id) {
|
||||
LOG_DEBUG(Service_PM, "called, program_id={:016X}", program_id);
|
||||
|
||||
auto list = system.Kernel().GetProcessList();
|
||||
auto process =
|
||||
SearchProcessList(list, [program_id](auto& p) { return p->GetProgramId() == program_id; });
|
||||
|
||||
if (process.IsNull()) {
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultProcessNotFound);
|
||||
return;
|
||||
}
|
||||
R_UNLESS(!process.IsNull(), ResultProcessNotFound);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 4};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.Push(process->GetProcessId());
|
||||
*out_process_id = ProcessId(process->GetProcessId());
|
||||
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
} // namespace Service::PM
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "core/hle/service/ipc_helpers.h"
|
||||
#include "core/hle/service/cmif_types.h"
|
||||
#include "core/hle/service/service.h"
|
||||
|
||||
namespace Service::PM {
|
||||
@ -13,8 +13,8 @@ public:
|
||||
explicit InformationService(Core::System& system_);
|
||||
|
||||
private:
|
||||
void GetProgramId(HLERequestContext& ctx);
|
||||
void AtmosphereGetProcessId(HLERequestContext& ctx);
|
||||
Result GetProgramId(Out<u64> out_program_id, u64 process_id);
|
||||
Result AtmosphereGetProcessId(Out<ProcessId> out_process_id, u64 program_id);
|
||||
};
|
||||
|
||||
} // namespace Service::PM
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include "core/hle/kernel/k_process.h"
|
||||
#include "core/hle/kernel/kernel.h"
|
||||
#include "core/hle/result.h"
|
||||
#include "core/hle/service/ipc_helpers.h"
|
||||
#include "core/hle/service/cmif_types.h"
|
||||
|
||||
namespace Service::PM {
|
||||
|
||||
@ -26,6 +26,18 @@ enum class BootMode {
|
||||
SafeMode = 2,
|
||||
};
|
||||
|
||||
struct ProgramLocation {
|
||||
u64 program_id;
|
||||
u8 storage_id;
|
||||
};
|
||||
static_assert(sizeof(ProgramLocation) == 0x10, "ProgramLocation has an invalid size");
|
||||
|
||||
struct OverrideStatus {
|
||||
u64 keys_held;
|
||||
u64 flags;
|
||||
};
|
||||
static_assert(sizeof(OverrideStatus) == 0x10, "OverrideStatus has an invalid size");
|
||||
|
||||
using ProcessList = std::list<Kernel::KScopedAutoObject<Kernel::KProcess>>;
|
||||
|
||||
template <typename F>
|
||||
@ -40,12 +52,14 @@ static inline Kernel::KScopedAutoObject<Kernel::KProcess> SearchProcessList(
|
||||
return iter->GetPointerUnsafe();
|
||||
}
|
||||
|
||||
static inline void GetApplicationPidGeneric(HLERequestContext& ctx, ProcessList& process_list) {
|
||||
static inline Result GetApplicationPidGeneric(Out<ProcessId> out_process_id,
|
||||
ProcessList& process_list) {
|
||||
auto process = SearchProcessList(process_list, [](auto& p) { return p->IsApplication(); });
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 4};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.Push(process.IsNull() ? NO_PROCESS_FOUND_PID : process->GetProcessId());
|
||||
*out_process_id =
|
||||
process.IsNull() ? ProcessId(NO_PROCESS_FOUND_PID) : ProcessId(process->GetProcessId());
|
||||
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
} // namespace Service::PM
|
||||
|
@ -1,6 +1,7 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "core/hle/service/cmif_serialization.h"
|
||||
#include "core/hle/service/pm/pm_types.h"
|
||||
#include "core/hle/service/pm/shell_service.h"
|
||||
|
||||
@ -15,7 +16,7 @@ ShellService::ShellService(Core::System& system_) : ServiceFramework{system_, "p
|
||||
{3, nullptr, "GetProcessEventHandle"},
|
||||
{4, nullptr, "GetProcessEventInfo"},
|
||||
{5, nullptr, "NotifyBootFinished"},
|
||||
{6, &ShellService::GetApplicationProcessIdForShell, "GetApplicationProcessIdForShell"},
|
||||
{6, C<&ShellService::GetApplicationProcessIdForShell>, "GetApplicationProcessIdForShell"},
|
||||
{7, nullptr, "BoostSystemMemoryResourceLimit"},
|
||||
{8, nullptr, "BoostApplicationThreadResourceLimit"},
|
||||
{9, nullptr, "GetBootFinishedEventHandle"},
|
||||
@ -25,10 +26,12 @@ ShellService::ShellService(Core::System& system_) : ServiceFramework{system_, "p
|
||||
RegisterHandlers(functions);
|
||||
}
|
||||
|
||||
void ShellService::GetApplicationProcessIdForShell(HLERequestContext& ctx) {
|
||||
Result ShellService::GetApplicationProcessIdForShell(Out<ProcessId> out_process_id) {
|
||||
LOG_DEBUG(Service_PM, "called");
|
||||
|
||||
auto list = kernel.GetProcessList();
|
||||
GetApplicationPidGeneric(ctx, list);
|
||||
|
||||
R_RETURN(GetApplicationPidGeneric(out_process_id, list));
|
||||
}
|
||||
|
||||
} // namespace Service::PM
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "core/hle/service/cmif_types.h"
|
||||
#include "core/hle/service/ipc_helpers.h"
|
||||
#include "core/hle/service/service.h"
|
||||
|
||||
@ -13,7 +14,7 @@ public:
|
||||
explicit ShellService(Core::System& system_);
|
||||
|
||||
private:
|
||||
void GetApplicationProcessIdForShell(HLERequestContext& ctx);
|
||||
Result GetApplicationProcessIdForShell(Out<ProcessId> out_process_id);
|
||||
};
|
||||
|
||||
} // namespace Service::PM
|
||||
|
Loading…
Reference in New Issue
Block a user