diff options
| author | comex <comexk@gmail.com> | 2023-07-01 15:01:11 -0700 | 
|---|---|---|
| committer | comex <comexk@gmail.com> | 2023-07-01 15:01:11 -0700 | 
| commit | 98685d48e3cb9f25f6919f004ec62cadf33afad2 (patch) | |
| tree | 9df2ce7f57370641589bfae7196c77b090bcbe0f /src/core/hle/kernel | |
| parent | d885dd5b642807d0587acad43668cfccfdf06d1e (diff) | |
| parent | 8857911216f16a098231c25e0d2992ab67e33f83 (diff) | |
Merge remote-tracking branch 'origin/master' into ssl
Diffstat (limited to 'src/core/hle/kernel')
| -rw-r--r-- | src/core/hle/kernel/k_scheduler.cpp | 5 | ||||
| -rw-r--r-- | src/core/hle/kernel/k_synchronization_object.cpp | 3 | ||||
| -rw-r--r-- | src/core/hle/kernel/k_thread.cpp | 8 | ||||
| -rw-r--r-- | src/core/hle/kernel/k_thread.h | 3 | ||||
| -rw-r--r-- | src/core/hle/kernel/svc/svc_info.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/kernel/svc/svc_ipc.cpp | 7 | ||||
| -rw-r--r-- | src/core/hle/kernel/svc/svc_synchronization.cpp | 10 | ||||
| -rw-r--r-- | src/core/hle/kernel/svc/svc_thread.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/kernel/svc/svc_tick.cpp | 10 | 
9 files changed, 23 insertions, 29 deletions
diff --git a/src/core/hle/kernel/k_scheduler.cpp b/src/core/hle/kernel/k_scheduler.cpp index faa12b4f0..75ce5a23c 100644 --- a/src/core/hle/kernel/k_scheduler.cpp +++ b/src/core/hle/kernel/k_scheduler.cpp @@ -184,7 +184,8 @@ u64 KScheduler::UpdateHighestPriorityThread(KThread* highest_thread) {          prev_highest_thread != highest_thread) [[likely]] {          if (prev_highest_thread != nullptr) [[likely]] {              IncrementScheduledCount(prev_highest_thread); -            prev_highest_thread->SetLastScheduledTick(m_kernel.System().CoreTiming().GetCPUTicks()); +            prev_highest_thread->SetLastScheduledTick( +                m_kernel.System().CoreTiming().GetClockTicks());          }          if (m_state.should_count_idle) {              if (highest_thread != nullptr) [[likely]] { @@ -351,7 +352,7 @@ void KScheduler::SwitchThread(KThread* next_thread) {      // Update the CPU time tracking variables.      const s64 prev_tick = m_last_context_switch_time; -    const s64 cur_tick = m_kernel.System().CoreTiming().GetCPUTicks(); +    const s64 cur_tick = m_kernel.System().CoreTiming().GetClockTicks();      const s64 tick_diff = cur_tick - prev_tick;      cur_thread->AddCpuTime(m_core_id, tick_diff);      if (cur_process != nullptr) { diff --git a/src/core/hle/kernel/k_synchronization_object.cpp b/src/core/hle/kernel/k_synchronization_object.cpp index b7da3eee7..3e5b735b1 100644 --- a/src/core/hle/kernel/k_synchronization_object.cpp +++ b/src/core/hle/kernel/k_synchronization_object.cpp @@ -3,6 +3,7 @@  #include "common/assert.h"  #include "common/common_types.h" +#include "common/scratch_buffer.h"  #include "core/hle/kernel/k_scheduler.h"  #include "core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h"  #include "core/hle/kernel/k_synchronization_object.h" @@ -75,7 +76,7 @@ Result KSynchronizationObject::Wait(KernelCore& kernel, s32* out_index,                                      KSynchronizationObject** objects, const s32 num_objects,                                      s64 timeout) {      // Allocate space on stack for thread nodes. -    std::vector<ThreadListNode> thread_nodes(num_objects); +    std::array<ThreadListNode, Svc::ArgumentHandleCountMax> thread_nodes;      // Prepare for wait.      KThread* thread = GetCurrentThreadPointer(kernel); diff --git a/src/core/hle/kernel/k_thread.cpp b/src/core/hle/kernel/k_thread.cpp index 908811e2c..adb6ec581 100644 --- a/src/core/hle/kernel/k_thread.cpp +++ b/src/core/hle/kernel/k_thread.cpp @@ -909,7 +909,7 @@ Result KThread::SetActivity(Svc::ThreadActivity activity) {      R_SUCCEED();  } -Result KThread::GetThreadContext3(std::vector<u8>& out) { +Result KThread::GetThreadContext3(Common::ScratchBuffer<u8>& out) {      // Lock ourselves.      KScopedLightLock lk{m_activity_pause_lock}; @@ -927,15 +927,13 @@ Result KThread::GetThreadContext3(std::vector<u8>& out) {                  // Mask away mode bits, interrupt bits, IL bit, and other reserved bits.                  auto context = GetContext64();                  context.pstate &= 0xFF0FFE20; - -                out.resize(sizeof(context)); +                out.resize_destructive(sizeof(context));                  std::memcpy(out.data(), std::addressof(context), sizeof(context));              } else {                  // Mask away mode bits, interrupt bits, IL bit, and other reserved bits.                  auto context = GetContext32();                  context.cpsr &= 0xFF0FFE20; - -                out.resize(sizeof(context)); +                out.resize_destructive(sizeof(context));                  std::memcpy(out.data(), std::addressof(context), sizeof(context));              }          } diff --git a/src/core/hle/kernel/k_thread.h b/src/core/hle/kernel/k_thread.h index 37fe5db77..dd662b3f8 100644 --- a/src/core/hle/kernel/k_thread.h +++ b/src/core/hle/kernel/k_thread.h @@ -15,6 +15,7 @@  #include "common/intrusive_list.h"  #include "common/intrusive_red_black_tree.h" +#include "common/scratch_buffer.h"  #include "common/spin_lock.h"  #include "core/arm/arm_interface.h"  #include "core/hle/kernel/k_affinity_mask.h" @@ -567,7 +568,7 @@ public:      void RemoveWaiter(KThread* thread); -    Result GetThreadContext3(std::vector<u8>& out); +    Result GetThreadContext3(Common::ScratchBuffer<u8>& out);      KThread* RemoveUserWaiterByKey(bool* out_has_waiters, KProcessAddress key) {          return this->RemoveWaiterByKey(out_has_waiters, key, false); diff --git a/src/core/hle/kernel/svc/svc_info.cpp b/src/core/hle/kernel/svc/svc_info.cpp index 2b2c878b5..445cdd87b 100644 --- a/src/core/hle/kernel/svc/svc_info.cpp +++ b/src/core/hle/kernel/svc/svc_info.cpp @@ -199,9 +199,9 @@ Result GetInfo(Core::System& system, u64* result, InfoType info_id_type, Handle          if (same_thread && info_sub_id == 0xFFFFFFFFFFFFFFFF) {              const u64 thread_ticks = current_thread->GetCpuTime(); -            out_ticks = thread_ticks + (core_timing.GetCPUTicks() - prev_ctx_ticks); +            out_ticks = thread_ticks + (core_timing.GetClockTicks() - prev_ctx_ticks);          } else if (same_thread && info_sub_id == system.Kernel().CurrentPhysicalCoreIndex()) { -            out_ticks = core_timing.GetCPUTicks() - prev_ctx_ticks; +            out_ticks = core_timing.GetClockTicks() - prev_ctx_ticks;          }          *result = out_ticks; diff --git a/src/core/hle/kernel/svc/svc_ipc.cpp b/src/core/hle/kernel/svc/svc_ipc.cpp index ea03068aa..60247df2e 100644 --- a/src/core/hle/kernel/svc/svc_ipc.cpp +++ b/src/core/hle/kernel/svc/svc_ipc.cpp @@ -2,6 +2,7 @@  // SPDX-License-Identifier: GPL-2.0-or-later  #include "common/scope_exit.h" +#include "common/scratch_buffer.h"  #include "core/core.h"  #include "core/hle/kernel/k_client_session.h"  #include "core/hle/kernel/k_process.h" @@ -45,11 +46,11 @@ Result ReplyAndReceive(Core::System& system, s32* out_index, uint64_t handles_ad                   handles_addr, static_cast<u64>(sizeof(Handle) * num_handles)),               ResultInvalidPointer); -    std::vector<Handle> handles(num_handles); +    std::array<Handle, Svc::ArgumentHandleCountMax> handles;      GetCurrentMemory(kernel).ReadBlock(handles_addr, handles.data(), sizeof(Handle) * num_handles);      // Convert handle list to object table. -    std::vector<KSynchronizationObject*> objs(num_handles); +    std::array<KSynchronizationObject*, Svc::ArgumentHandleCountMax> objs;      R_UNLESS(handle_table.GetMultipleObjects<KSynchronizationObject>(objs.data(), handles.data(),                                                                       num_handles),               ResultInvalidHandle); @@ -80,7 +81,7 @@ Result ReplyAndReceive(Core::System& system, s32* out_index, uint64_t handles_ad          // Wait for an object.          s32 index;          Result result = KSynchronizationObject::Wait(kernel, std::addressof(index), objs.data(), -                                                     static_cast<s32>(objs.size()), timeout_ns); +                                                     num_handles, timeout_ns);          if (result == ResultTimedOut) {              R_RETURN(result);          } diff --git a/src/core/hle/kernel/svc/svc_synchronization.cpp b/src/core/hle/kernel/svc/svc_synchronization.cpp index 04d65f0bd..53df5bcd8 100644 --- a/src/core/hle/kernel/svc/svc_synchronization.cpp +++ b/src/core/hle/kernel/svc/svc_synchronization.cpp @@ -2,6 +2,7 @@  // SPDX-License-Identifier: GPL-2.0-or-later  #include "common/scope_exit.h" +#include "common/scratch_buffer.h"  #include "core/core.h"  #include "core/hle/kernel/k_process.h"  #include "core/hle/kernel/k_readable_event.h" @@ -54,7 +55,7 @@ static Result WaitSynchronization(Core::System& system, int32_t* out_index, cons      // Get the synchronization context.      auto& kernel = system.Kernel();      auto& handle_table = GetCurrentProcess(kernel).GetHandleTable(); -    std::vector<KSynchronizationObject*> objs(num_handles); +    std::array<KSynchronizationObject*, Svc::ArgumentHandleCountMax> objs;      // Copy user handles.      if (num_handles > 0) { @@ -72,8 +73,8 @@ static Result WaitSynchronization(Core::System& system, int32_t* out_index, cons      });      // Wait on the objects. -    Result res = KSynchronizationObject::Wait(kernel, out_index, objs.data(), -                                              static_cast<s32>(objs.size()), timeout_ns); +    Result res = +        KSynchronizationObject::Wait(kernel, out_index, objs.data(), num_handles, timeout_ns);      R_SUCCEED_IF(res == ResultSessionClosed);      R_RETURN(res); @@ -87,8 +88,7 @@ Result WaitSynchronization(Core::System& system, int32_t* out_index, u64 user_ha      // Ensure number of handles is valid.      R_UNLESS(0 <= num_handles && num_handles <= Svc::ArgumentHandleCountMax, ResultOutOfRange); - -    std::vector<Handle> handles(num_handles); +    std::array<Handle, Svc::ArgumentHandleCountMax> handles;      if (num_handles > 0) {          GetCurrentMemory(system.Kernel())              .ReadBlock(user_handles, handles.data(), num_handles * sizeof(Handle)); diff --git a/src/core/hle/kernel/svc/svc_thread.cpp b/src/core/hle/kernel/svc/svc_thread.cpp index 37b54079c..36b94e6bf 100644 --- a/src/core/hle/kernel/svc/svc_thread.cpp +++ b/src/core/hle/kernel/svc/svc_thread.cpp @@ -174,7 +174,7 @@ Result GetThreadContext3(Core::System& system, u64 out_context, Handle thread_ha          }          // Get the thread context. -        std::vector<u8> context; +        static thread_local Common::ScratchBuffer<u8> context;          R_TRY(thread->GetThreadContext3(context));          // Copy the thread context to user space. diff --git a/src/core/hle/kernel/svc/svc_tick.cpp b/src/core/hle/kernel/svc/svc_tick.cpp index 561336482..7dd7c6e51 100644 --- a/src/core/hle/kernel/svc/svc_tick.cpp +++ b/src/core/hle/kernel/svc/svc_tick.cpp @@ -12,16 +12,8 @@ namespace Kernel::Svc {  int64_t GetSystemTick(Core::System& system) {      LOG_TRACE(Kernel_SVC, "called"); -    auto& core_timing = system.CoreTiming(); -      // Returns the value of cntpct_el0 (https://switchbrew.org/wiki/SVC#svcGetSystemTick) -    const u64 result{core_timing.GetClockTicks()}; - -    if (!system.Kernel().IsMulticore()) { -        core_timing.AddTicks(400U); -    } - -    return static_cast<int64_t>(result); +    return static_cast<int64_t>(system.CoreTiming().GetClockTicks());  }  int64_t GetSystemTick64(Core::System& system) {  | 
