diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/hle/kernel/k_code_memory.cpp | 6 | ||||
-rw-r--r-- | src/core/hle/kernel/svc.cpp | 2 | ||||
-rw-r--r-- | src/core/hle/service/pm/pm.cpp | 45 |
3 files changed, 49 insertions, 4 deletions
diff --git a/src/core/hle/kernel/k_code_memory.cpp b/src/core/hle/kernel/k_code_memory.cpp index d69f7ffb7..0b225e8e0 100644 --- a/src/core/hle/kernel/k_code_memory.cpp +++ b/src/core/hle/kernel/k_code_memory.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include "common/alignment.h" #include "common/common_types.h" #include "core/device_memory.h" #include "core/hle/kernel/k_auto_object.h" @@ -28,8 +29,7 @@ ResultCode KCodeMemory::Initialize(Core::DeviceMemory& device_memory, VAddr addr auto& page_table = m_owner->PageTable(); // Construct the page group. - KMemoryInfo kBlockInfo = page_table.QueryInfo(addr); - m_page_group = KPageLinkedList(kBlockInfo.GetAddress(), kBlockInfo.GetNumPages()); + m_page_group = KPageLinkedList(addr, Common::DivideUp(size, PageSize)); // Lock the memory. R_TRY(page_table.LockForCodeMemory(addr, size)) @@ -143,4 +143,4 @@ ResultCode KCodeMemory::UnmapFromOwner(VAddr address, size_t size) { return ResultSuccess; } -} // namespace Kernel
\ No newline at end of file +} // namespace Kernel diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 4f7aebf3f..9387373c1 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -396,7 +396,7 @@ static ResultCode GetProcessId(Core::System& system, u64* out_process_id, Handle // Get the process id. *out_process_id = process->GetId(); - return ResultInvalidHandle; + return ResultSuccess; } static ResultCode GetProcessId32(Core::System& system, u32* out_process_id_low, diff --git a/src/core/hle/service/pm/pm.cpp b/src/core/hle/service/pm/pm.cpp index 277abc17a..057666021 100644 --- a/src/core/hle/service/pm/pm.cpp +++ b/src/core/hle/service/pm/pm.cpp @@ -91,6 +91,8 @@ public: {4, &DebugMonitor::GetApplicationProcessId, "GetApplicationProcessId"}, {5, nullptr, "HookToCreateApplicationProgress"}, {6, nullptr, "ClearHook"}, + {65000, &DebugMonitor::AtmosphereGetProcessInfo, "AtmosphereGetProcessInfo"}, + {65001, nullptr, "AtmosphereGetCurrentLimitInfo"}, }; // clang-format on @@ -125,6 +127,49 @@ private: GetApplicationPidGeneric(ctx, kernel.GetProcessList()); } + void AtmosphereGetProcessInfo(Kernel::HLERequestContext& ctx) { + // 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>(); + + LOG_WARNING(Service_PM, "(Partial Implementation) called, pid={:016X}", pid); + + const auto process = SearchProcessList(kernel.GetProcessList(), [pid](const auto& proc) { + return proc->GetProcessID() == pid; + }); + + if (!process.has_value()) { + 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"); + + OverrideStatus override_status{}; + ProgramLocation program_location{ + .program_id = (*process)->GetProgramID(), + .storage_id = 0, + }; + + IPC::ResponseBuilder rb{ctx, 10, 1}; + rb.Push(ResultSuccess); + rb.PushCopyObjects(*process); + rb.PushRaw(program_location); + rb.PushRaw(override_status); + } + const Kernel::KernelCore& kernel; }; |