Core: Correct rebase.
This commit is contained in:
parent
1c672128c4
commit
a33fbaddec
@ -8,6 +8,7 @@
|
|||||||
#include <dynarmic/A32/config.h>
|
#include <dynarmic/A32/config.h>
|
||||||
#include <dynarmic/A32/context.h>
|
#include <dynarmic/A32/context.h>
|
||||||
#include "common/microprofile.h"
|
#include "common/microprofile.h"
|
||||||
|
#include "core/arm/cpu_interrupt_handler.h"
|
||||||
#include "core/arm/dynarmic/arm_dynarmic_32.h"
|
#include "core/arm/dynarmic/arm_dynarmic_32.h"
|
||||||
#include "core/arm/dynarmic/arm_dynarmic_64.h"
|
#include "core/arm/dynarmic/arm_dynarmic_64.h"
|
||||||
#include "core/arm/dynarmic/arm_dynarmic_cp15.h"
|
#include "core/arm/dynarmic/arm_dynarmic_cp15.h"
|
||||||
@ -72,20 +73,13 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AddTicks(u64 ticks) override {
|
void AddTicks(u64 ticks) override {
|
||||||
// Divide the number of ticks by the amount of CPU cores. TODO(Subv): This yields only a
|
/// We are using host timing, NOP
|
||||||
// rough approximation of the amount of executed ticks in the system, it may be thrown off
|
|
||||||
// if not all cores are doing a similar amount of work. Instead of doing this, we should
|
|
||||||
// device a way so that timing is consistent across all cores without increasing the ticks 4
|
|
||||||
// times.
|
|
||||||
u64 amortized_ticks = (ticks - num_interpreted_instructions) / Core::NUM_CPU_CORES;
|
|
||||||
// Always execute at least one tick.
|
|
||||||
amortized_ticks = std::max<u64>(amortized_ticks, 1);
|
|
||||||
|
|
||||||
parent.system.CoreTiming().AddTicks(amortized_ticks);
|
|
||||||
num_interpreted_instructions = 0;
|
|
||||||
}
|
}
|
||||||
u64 GetTicksRemaining() override {
|
u64 GetTicksRemaining() override {
|
||||||
return std::max(parent.system.CoreTiming().GetDowncount(), {});
|
if (!parent.interrupt_handler.IsInterrupted()) {
|
||||||
|
return 1000ULL;
|
||||||
|
}
|
||||||
|
return 0ULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ARM_Dynarmic_32& parent;
|
ARM_Dynarmic_32& parent;
|
||||||
|
@ -552,8 +552,7 @@ void GlobalScheduler::Unlock() {
|
|||||||
EnableInterruptAndSchedule(cores_pending_reschedule, leaving_thread);
|
EnableInterruptAndSchedule(cores_pending_reschedule, leaving_thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
Scheduler::Scheduler(Core::System& system, std::size_t core_id)
|
Scheduler::Scheduler(Core::System& system, std::size_t core_id) : system(system), core_id(core_id) {
|
||||||
: system(system), core_id(core_id) {
|
|
||||||
switch_fiber = std::make_shared<Common::Fiber>(std::function<void(void*)>(OnSwitch), this);
|
switch_fiber = std::make_shared<Common::Fiber>(std::function<void(void*)>(OnSwitch), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -601,9 +600,10 @@ void Scheduler::SwitchContextStep2() {
|
|||||||
|
|
||||||
// Load context of new thread
|
// Load context of new thread
|
||||||
Process* const previous_process =
|
Process* const previous_process =
|
||||||
previous_thread != nullptr ? previous_thread->GetOwnerProcess() : nullptr;
|
previous_thread != nullptr ? previous_thread->GetOwnerProcess() : nullptr;
|
||||||
|
|
||||||
if (new_thread) {
|
if (new_thread) {
|
||||||
|
auto& cpu_core = system.ArmInterface(core_id);
|
||||||
new_thread->context_guard.lock();
|
new_thread->context_guard.lock();
|
||||||
cpu_core.Lock();
|
cpu_core.Lock();
|
||||||
ASSERT_MSG(new_thread->GetProcessorID() == s32(this->core_id),
|
ASSERT_MSG(new_thread->GetProcessorID() == s32(this->core_id),
|
||||||
@ -619,7 +619,6 @@ void Scheduler::SwitchContextStep2() {
|
|||||||
system.Kernel().MakeCurrentProcess(thread_owner_process);
|
system.Kernel().MakeCurrentProcess(thread_owner_process);
|
||||||
}
|
}
|
||||||
if (!new_thread->IsHLEThread()) {
|
if (!new_thread->IsHLEThread()) {
|
||||||
auto& cpu_core = system.ArmInterface(core_id);
|
|
||||||
cpu_core.LoadContext(new_thread->GetContext32());
|
cpu_core.LoadContext(new_thread->GetContext32());
|
||||||
cpu_core.LoadContext(new_thread->GetContext64());
|
cpu_core.LoadContext(new_thread->GetContext64());
|
||||||
cpu_core.SetTlsAddress(new_thread->GetTLSAddress());
|
cpu_core.SetTlsAddress(new_thread->GetTLSAddress());
|
||||||
@ -651,12 +650,12 @@ void Scheduler::SwitchContext() {
|
|||||||
|
|
||||||
// Save context for previous thread
|
// Save context for previous thread
|
||||||
if (previous_thread) {
|
if (previous_thread) {
|
||||||
|
auto& cpu_core = system.ArmInterface(core_id);
|
||||||
if (!previous_thread->IsHLEThread()) {
|
if (!previous_thread->IsHLEThread()) {
|
||||||
auto& cpu_core = system.ArmInterface(core_id);
|
|
||||||
cpu_core.SaveContext(previous_thread->GetContext32());
|
cpu_core.SaveContext(previous_thread->GetContext32());
|
||||||
cpu_core.SaveContext(previous_thread->GetContext64());
|
cpu_core.SaveContext(previous_thread->GetContext64());
|
||||||
// Save the TPIDR_EL0 system register in case it was modified.
|
// Save the TPIDR_EL0 system register in case it was modified.
|
||||||
previous_thread->SetTPIDR_EL0(cpu_core.GetTPIDR_EL0());
|
previous_thread->SetTPIDR_EL0(cpu_core.GetTPIDR_EL0());
|
||||||
cpu_core.ClearExclusiveState();
|
cpu_core.ClearExclusiveState();
|
||||||
}
|
}
|
||||||
if (previous_thread->GetStatus() == ThreadStatus::Running) {
|
if (previous_thread->GetStatus() == ThreadStatus::Running) {
|
||||||
|
Loading…
Reference in New Issue
Block a user