2020-01-24 20:38:20 +01:00
|
|
|
// Copyright 2020 yuzu Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2020-01-25 23:55:32 +01:00
|
|
|
#include "common/logging/log.h"
|
|
|
|
#include "core/arm/arm_interface.h"
|
|
|
|
#ifdef ARCHITECTURE_x86_64
|
2020-03-02 05:46:10 +01:00
|
|
|
#include "core/arm/dynarmic/arm_dynarmic_32.h"
|
|
|
|
#include "core/arm/dynarmic/arm_dynarmic_64.h"
|
2020-01-25 23:55:32 +01:00
|
|
|
#endif
|
|
|
|
#include "core/arm/exclusive_monitor.h"
|
|
|
|
#include "core/arm/unicorn/arm_unicorn.h"
|
|
|
|
#include "core/core.h"
|
|
|
|
#include "core/hle/kernel/physical_core.h"
|
|
|
|
#include "core/hle/kernel/scheduler.h"
|
|
|
|
#include "core/hle/kernel/thread.h"
|
|
|
|
|
2020-01-24 20:38:20 +01:00
|
|
|
namespace Kernel {
|
|
|
|
|
2020-01-31 00:19:21 +01:00
|
|
|
PhysicalCore::PhysicalCore(Core::System& system, std::size_t id,
|
2020-01-26 21:14:18 +01:00
|
|
|
Core::ExclusiveMonitor& exclusive_monitor)
|
2020-01-31 00:19:21 +01:00
|
|
|
: core_index{id} {
|
2020-01-24 20:38:20 +01:00
|
|
|
#ifdef ARCHITECTURE_x86_64
|
2020-03-02 05:46:10 +01:00
|
|
|
arm_interface_32 =
|
|
|
|
std::make_unique<Core::ARM_Dynarmic_32>(system, exclusive_monitor, core_index);
|
|
|
|
arm_interface_64 =
|
|
|
|
std::make_unique<Core::ARM_Dynarmic_64>(system, exclusive_monitor, core_index);
|
|
|
|
|
2020-01-24 20:38:20 +01:00
|
|
|
#else
|
2020-04-24 06:07:38 +02:00
|
|
|
using Core::ARM_Unicorn;
|
|
|
|
arm_interface_32 = std::make_unique<ARM_Unicorn>(system, ARM_Unicorn::Arch::AArch32);
|
|
|
|
arm_interface_64 = std::make_unique<ARM_Unicorn>(system, ARM_Unicorn::Arch::AArch64);
|
2020-01-24 20:38:20 +01:00
|
|
|
LOG_WARNING(Core, "CPU JIT requested, but Dynarmic not available");
|
|
|
|
#endif
|
|
|
|
|
2020-03-02 05:46:10 +01:00
|
|
|
scheduler = std::make_unique<Kernel::Scheduler>(system, core_index);
|
2020-01-24 20:38:20 +01:00
|
|
|
}
|
|
|
|
|
2020-01-26 21:14:18 +01:00
|
|
|
PhysicalCore::~PhysicalCore() = default;
|
|
|
|
|
2020-01-25 23:55:32 +01:00
|
|
|
void PhysicalCore::Run() {
|
|
|
|
arm_interface->Run();
|
|
|
|
arm_interface->ClearExclusiveState();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PhysicalCore::Step() {
|
|
|
|
arm_interface->Step();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PhysicalCore::Stop() {
|
|
|
|
arm_interface->PrepareReschedule();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PhysicalCore::Shutdown() {
|
|
|
|
scheduler->Shutdown();
|
|
|
|
}
|
|
|
|
|
2020-03-02 05:46:10 +01:00
|
|
|
void PhysicalCore::SetIs64Bit(bool is_64_bit) {
|
|
|
|
if (is_64_bit) {
|
|
|
|
arm_interface = arm_interface_64.get();
|
|
|
|
} else {
|
|
|
|
arm_interface = arm_interface_32.get();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-24 20:38:20 +01:00
|
|
|
} // namespace Kernel
|