diff options
| author | 2023-10-21 16:47:43 -0400 | |
|---|---|---|
| committer | 2023-10-21 20:03:41 -0400 | |
| commit | 8c59543ee32c8bff575bab7ec1e70f76f8eda437 (patch) | |
| tree | afeee77ba66daf7ec6bff18515c8fbf1bb8468e0 /src/core/hle/kernel/svc | |
| parent | Merge pull request #11831 from liamwhite/hosversionbetween (diff) | |
| download | yuzu-8c59543ee32c8bff575bab7ec1e70f76f8eda437.tar.gz yuzu-8c59543ee32c8bff575bab7ec1e70f76f8eda437.tar.xz yuzu-8c59543ee32c8bff575bab7ec1e70f76f8eda437.zip | |
kernel: update KProcess
Diffstat (limited to 'src/core/hle/kernel/svc')
| -rw-r--r-- | src/core/hle/kernel/svc/svc_info.cpp | 28 | ||||
| -rw-r--r-- | src/core/hle/kernel/svc/svc_lock.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/kernel/svc/svc_physical_memory.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/kernel/svc/svc_synchronization.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/kernel/svc/svc_thread.cpp | 7 |
5 files changed, 24 insertions, 21 deletions
diff --git a/src/core/hle/kernel/svc/svc_info.cpp b/src/core/hle/kernel/svc/svc_info.cpp index f99964028..ada998772 100644 --- a/src/core/hle/kernel/svc/svc_info.cpp +++ b/src/core/hle/kernel/svc/svc_info.cpp | |||
| @@ -86,20 +86,19 @@ Result GetInfo(Core::System& system, u64* result, InfoType info_id_type, Handle | |||
| 86 | R_SUCCEED(); | 86 | R_SUCCEED(); |
| 87 | 87 | ||
| 88 | case InfoType::TotalMemorySize: | 88 | case InfoType::TotalMemorySize: |
| 89 | *result = process->GetTotalPhysicalMemoryAvailable(); | 89 | *result = process->GetTotalUserPhysicalMemorySize(); |
| 90 | R_SUCCEED(); | 90 | R_SUCCEED(); |
| 91 | 91 | ||
| 92 | case InfoType::UsedMemorySize: | 92 | case InfoType::UsedMemorySize: |
| 93 | *result = process->GetTotalPhysicalMemoryUsed(); | 93 | *result = process->GetUsedUserPhysicalMemorySize(); |
| 94 | R_SUCCEED(); | 94 | R_SUCCEED(); |
| 95 | 95 | ||
| 96 | case InfoType::SystemResourceSizeTotal: | 96 | case InfoType::SystemResourceSizeTotal: |
| 97 | *result = process->GetSystemResourceSize(); | 97 | *result = process->GetTotalSystemResourceSize(); |
| 98 | R_SUCCEED(); | 98 | R_SUCCEED(); |
| 99 | 99 | ||
| 100 | case InfoType::SystemResourceSizeUsed: | 100 | case InfoType::SystemResourceSizeUsed: |
| 101 | LOG_WARNING(Kernel_SVC, "(STUBBED) Attempted to query system resource usage"); | 101 | *result = process->GetUsedSystemResourceSize(); |
| 102 | *result = process->GetSystemResourceUsage(); | ||
| 103 | R_SUCCEED(); | 102 | R_SUCCEED(); |
| 104 | 103 | ||
| 105 | case InfoType::ProgramId: | 104 | case InfoType::ProgramId: |
| @@ -111,20 +110,29 @@ Result GetInfo(Core::System& system, u64* result, InfoType info_id_type, Handle | |||
| 111 | R_SUCCEED(); | 110 | R_SUCCEED(); |
| 112 | 111 | ||
| 113 | case InfoType::TotalNonSystemMemorySize: | 112 | case InfoType::TotalNonSystemMemorySize: |
| 114 | *result = process->GetTotalPhysicalMemoryAvailableWithoutSystemResource(); | 113 | *result = process->GetTotalNonSystemUserPhysicalMemorySize(); |
| 115 | R_SUCCEED(); | 114 | R_SUCCEED(); |
| 116 | 115 | ||
| 117 | case InfoType::UsedNonSystemMemorySize: | 116 | case InfoType::UsedNonSystemMemorySize: |
| 118 | *result = process->GetTotalPhysicalMemoryUsedWithoutSystemResource(); | 117 | *result = process->GetUsedNonSystemUserPhysicalMemorySize(); |
| 119 | R_SUCCEED(); | 118 | R_SUCCEED(); |
| 120 | 119 | ||
| 121 | case InfoType::IsApplication: | 120 | case InfoType::IsApplication: |
| 122 | LOG_WARNING(Kernel_SVC, "(STUBBED) Assuming process is application"); | 121 | LOG_WARNING(Kernel_SVC, "(STUBBED) Assuming process is application"); |
| 123 | *result = true; | 122 | *result = process->IsApplication(); |
| 124 | R_SUCCEED(); | 123 | R_SUCCEED(); |
| 125 | 124 | ||
| 126 | case InfoType::FreeThreadCount: | 125 | case InfoType::FreeThreadCount: |
| 127 | *result = process->GetFreeThreadCount(); | 126 | if (KResourceLimit* resource_limit = process->GetResourceLimit(); |
| 127 | resource_limit != nullptr) { | ||
| 128 | const auto current_value = | ||
| 129 | resource_limit->GetCurrentValue(Svc::LimitableResource::ThreadCountMax); | ||
| 130 | const auto limit_value = | ||
| 131 | resource_limit->GetLimitValue(Svc::LimitableResource::ThreadCountMax); | ||
| 132 | *result = limit_value - current_value; | ||
| 133 | } else { | ||
| 134 | *result = 0; | ||
| 135 | } | ||
| 128 | R_SUCCEED(); | 136 | R_SUCCEED(); |
| 129 | 137 | ||
| 130 | default: | 138 | default: |
| @@ -161,7 +169,7 @@ Result GetInfo(Core::System& system, u64* result, InfoType info_id_type, Handle | |||
| 161 | 169 | ||
| 162 | case InfoType::RandomEntropy: | 170 | case InfoType::RandomEntropy: |
| 163 | R_UNLESS(handle == 0, ResultInvalidHandle); | 171 | R_UNLESS(handle == 0, ResultInvalidHandle); |
| 164 | R_UNLESS(info_sub_id < KProcess::RANDOM_ENTROPY_SIZE, ResultInvalidCombination); | 172 | R_UNLESS(info_sub_id < 4, ResultInvalidCombination); |
| 165 | 173 | ||
| 166 | *result = GetCurrentProcess(system.Kernel()).GetRandomEntropy(info_sub_id); | 174 | *result = GetCurrentProcess(system.Kernel()).GetRandomEntropy(info_sub_id); |
| 167 | R_SUCCEED(); | 175 | R_SUCCEED(); |
diff --git a/src/core/hle/kernel/svc/svc_lock.cpp b/src/core/hle/kernel/svc/svc_lock.cpp index 1d7bc4246..5f0833fcb 100644 --- a/src/core/hle/kernel/svc/svc_lock.cpp +++ b/src/core/hle/kernel/svc/svc_lock.cpp | |||
| @@ -17,7 +17,7 @@ Result ArbitrateLock(Core::System& system, Handle thread_handle, u64 address, u3 | |||
| 17 | R_UNLESS(!IsKernelAddress(address), ResultInvalidCurrentMemory); | 17 | R_UNLESS(!IsKernelAddress(address), ResultInvalidCurrentMemory); |
| 18 | R_UNLESS(Common::IsAligned(address, sizeof(u32)), ResultInvalidAddress); | 18 | R_UNLESS(Common::IsAligned(address, sizeof(u32)), ResultInvalidAddress); |
| 19 | 19 | ||
| 20 | R_RETURN(GetCurrentProcess(system.Kernel()).WaitForAddress(thread_handle, address, tag)); | 20 | R_RETURN(KConditionVariable::WaitForAddress(system.Kernel(), thread_handle, address, tag)); |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | /// Unlock a mutex | 23 | /// Unlock a mutex |
| @@ -28,7 +28,7 @@ Result ArbitrateUnlock(Core::System& system, u64 address) { | |||
| 28 | R_UNLESS(!IsKernelAddress(address), ResultInvalidCurrentMemory); | 28 | R_UNLESS(!IsKernelAddress(address), ResultInvalidCurrentMemory); |
| 29 | R_UNLESS(Common::IsAligned(address, sizeof(u32)), ResultInvalidAddress); | 29 | R_UNLESS(Common::IsAligned(address, sizeof(u32)), ResultInvalidAddress); |
| 30 | 30 | ||
| 31 | R_RETURN(GetCurrentProcess(system.Kernel()).SignalToAddress(address)); | 31 | R_RETURN(KConditionVariable::SignalToAddress(system.Kernel(), address)); |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | Result ArbitrateLock64(Core::System& system, Handle thread_handle, uint64_t address, uint32_t tag) { | 34 | Result ArbitrateLock64(Core::System& system, Handle thread_handle, uint64_t address, uint32_t tag) { |
diff --git a/src/core/hle/kernel/svc/svc_physical_memory.cpp b/src/core/hle/kernel/svc/svc_physical_memory.cpp index d3545f232..99330d02a 100644 --- a/src/core/hle/kernel/svc/svc_physical_memory.cpp +++ b/src/core/hle/kernel/svc/svc_physical_memory.cpp | |||
| @@ -46,7 +46,7 @@ Result MapPhysicalMemory(Core::System& system, u64 addr, u64 size) { | |||
| 46 | KProcess* const current_process{GetCurrentProcessPointer(system.Kernel())}; | 46 | KProcess* const current_process{GetCurrentProcessPointer(system.Kernel())}; |
| 47 | auto& page_table{current_process->GetPageTable()}; | 47 | auto& page_table{current_process->GetPageTable()}; |
| 48 | 48 | ||
| 49 | if (current_process->GetSystemResourceSize() == 0) { | 49 | if (current_process->GetTotalSystemResourceSize() == 0) { |
| 50 | LOG_ERROR(Kernel_SVC, "System Resource Size is zero"); | 50 | LOG_ERROR(Kernel_SVC, "System Resource Size is zero"); |
| 51 | R_THROW(ResultInvalidState); | 51 | R_THROW(ResultInvalidState); |
| 52 | } | 52 | } |
| @@ -95,7 +95,7 @@ Result UnmapPhysicalMemory(Core::System& system, u64 addr, u64 size) { | |||
| 95 | KProcess* const current_process{GetCurrentProcessPointer(system.Kernel())}; | 95 | KProcess* const current_process{GetCurrentProcessPointer(system.Kernel())}; |
| 96 | auto& page_table{current_process->GetPageTable()}; | 96 | auto& page_table{current_process->GetPageTable()}; |
| 97 | 97 | ||
| 98 | if (current_process->GetSystemResourceSize() == 0) { | 98 | if (current_process->GetTotalSystemResourceSize() == 0) { |
| 99 | LOG_ERROR(Kernel_SVC, "System Resource Size is zero"); | 99 | LOG_ERROR(Kernel_SVC, "System Resource Size is zero"); |
| 100 | R_THROW(ResultInvalidState); | 100 | R_THROW(ResultInvalidState); |
| 101 | } | 101 | } |
diff --git a/src/core/hle/kernel/svc/svc_synchronization.cpp b/src/core/hle/kernel/svc/svc_synchronization.cpp index 8ebc1bd1c..6c79cfd8d 100644 --- a/src/core/hle/kernel/svc/svc_synchronization.cpp +++ b/src/core/hle/kernel/svc/svc_synchronization.cpp | |||
| @@ -132,7 +132,7 @@ void SynchronizePreemptionState(Core::System& system) { | |||
| 132 | GetCurrentThread(kernel).ClearInterruptFlag(); | 132 | GetCurrentThread(kernel).ClearInterruptFlag(); |
| 133 | 133 | ||
| 134 | // Unpin the current thread. | 134 | // Unpin the current thread. |
| 135 | cur_process->UnpinCurrentThread(core_id); | 135 | cur_process->UnpinCurrentThread(); |
| 136 | } | 136 | } |
| 137 | } | 137 | } |
| 138 | 138 | ||
diff --git a/src/core/hle/kernel/svc/svc_thread.cpp b/src/core/hle/kernel/svc/svc_thread.cpp index 933b82e30..755fd62b5 100644 --- a/src/core/hle/kernel/svc/svc_thread.cpp +++ b/src/core/hle/kernel/svc/svc_thread.cpp | |||
| @@ -85,10 +85,6 @@ Result StartThread(Core::System& system, Handle thread_handle) { | |||
| 85 | // Try to start the thread. | 85 | // Try to start the thread. |
| 86 | R_TRY(thread->Run()); | 86 | R_TRY(thread->Run()); |
| 87 | 87 | ||
| 88 | // If we succeeded, persist a reference to the thread. | ||
| 89 | thread->Open(); | ||
| 90 | system.Kernel().RegisterInUseObject(thread.GetPointerUnsafe()); | ||
| 91 | |||
| 92 | R_SUCCEED(); | 88 | R_SUCCEED(); |
| 93 | } | 89 | } |
| 94 | 90 | ||
| @@ -99,7 +95,6 @@ void ExitThread(Core::System& system) { | |||
| 99 | auto* const current_thread = GetCurrentThreadPointer(system.Kernel()); | 95 | auto* const current_thread = GetCurrentThreadPointer(system.Kernel()); |
| 100 | system.GlobalSchedulerContext().RemoveThread(current_thread); | 96 | system.GlobalSchedulerContext().RemoveThread(current_thread); |
| 101 | current_thread->Exit(); | 97 | current_thread->Exit(); |
| 102 | system.Kernel().UnregisterInUseObject(current_thread); | ||
| 103 | } | 98 | } |
| 104 | 99 | ||
| 105 | /// Sleep the current thread | 100 | /// Sleep the current thread |
| @@ -260,7 +255,7 @@ Result GetThreadList(Core::System& system, s32* out_num_threads, u64 out_thread_ | |||
| 260 | 255 | ||
| 261 | auto list_iter = thread_list.cbegin(); | 256 | auto list_iter = thread_list.cbegin(); |
| 262 | for (std::size_t i = 0; i < copy_amount; ++i, ++list_iter) { | 257 | for (std::size_t i = 0; i < copy_amount; ++i, ++list_iter) { |
| 263 | memory.Write64(out_thread_ids, (*list_iter)->GetThreadId()); | 258 | memory.Write64(out_thread_ids, list_iter->GetThreadId()); |
| 264 | out_thread_ids += sizeof(u64); | 259 | out_thread_ids += sizeof(u64); |
| 265 | } | 260 | } |
| 266 | 261 | ||