summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/svc.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2021-12-29 21:40:38 -0800
committerGravatar bunnei2021-12-30 15:50:45 -0800
commit3a89723d97b8e646cde569030057777813f4371c (patch)
treec08f00b1ebb21c3652f0e23ab28fe06c4678aa42 /src/core/hle/kernel/svc.cpp
parentMerge pull request #7635 from bunnei/set-heap-size (diff)
downloadyuzu-3a89723d97b8e646cde569030057777813f4371c.tar.gz
yuzu-3a89723d97b8e646cde569030057777813f4371c.tar.xz
yuzu-3a89723d97b8e646cde569030057777813f4371c.zip
core: hle: kernel: Implement thread pinning.
- We largely had the mechanics in place for thread pinning, this change hooks these up. - Validated with tests https://github.com/Atmosphere-NX/Atmosphere/blob/master/tests/TestSvc/source/test_thread_pinning.cpp.
Diffstat (limited to 'src/core/hle/kernel/svc.cpp')
-rw-r--r--src/core/hle/kernel/svc.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index 63e2dff19..250ef9042 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -2027,6 +2027,25 @@ static ResultCode SignalToAddress(Core::System& system, VAddr address, Svc::Sign
2027 count); 2027 count);
2028} 2028}
2029 2029
2030static void SynchronizePreemptionState(Core::System& system) {
2031 auto& kernel = system.Kernel();
2032
2033 // Lock the scheduler.
2034 KScopedSchedulerLock sl{kernel};
2035
2036 // If the current thread is pinned, unpin it.
2037 KProcess* cur_process = system.Kernel().CurrentProcess();
2038 const auto core_id = GetCurrentCoreId(kernel);
2039
2040 if (cur_process->GetPinnedThread(core_id) == GetCurrentThreadPointer(kernel)) {
2041 // Clear the current thread's interrupt flag.
2042 GetCurrentThread(kernel).ClearInterruptFlag();
2043
2044 // Unpin the current thread.
2045 cur_process->UnpinCurrentThread(core_id);
2046 }
2047}
2048
2030static ResultCode SignalToAddress32(Core::System& system, u32 address, Svc::SignalType signal_type, 2049static ResultCode SignalToAddress32(Core::System& system, u32 address, Svc::SignalType signal_type,
2031 s32 value, s32 count) { 2050 s32 value, s32 count) {
2032 return SignalToAddress(system, address, signal_type, value, count); 2051 return SignalToAddress(system, address, signal_type, value, count);
@@ -2797,7 +2816,7 @@ static const FunctionDef SVC_Table_64[] = {
2797 {0x33, SvcWrap64<GetThreadContext>, "GetThreadContext"}, 2816 {0x33, SvcWrap64<GetThreadContext>, "GetThreadContext"},
2798 {0x34, SvcWrap64<WaitForAddress>, "WaitForAddress"}, 2817 {0x34, SvcWrap64<WaitForAddress>, "WaitForAddress"},
2799 {0x35, SvcWrap64<SignalToAddress>, "SignalToAddress"}, 2818 {0x35, SvcWrap64<SignalToAddress>, "SignalToAddress"},
2800 {0x36, nullptr, "SynchronizePreemptionState"}, 2819 {0x36, SvcWrap64<SynchronizePreemptionState>, "SynchronizePreemptionState"},
2801 {0x37, nullptr, "Unknown"}, 2820 {0x37, nullptr, "Unknown"},
2802 {0x38, nullptr, "Unknown"}, 2821 {0x38, nullptr, "Unknown"},
2803 {0x39, nullptr, "Unknown"}, 2822 {0x39, nullptr, "Unknown"},