2018-05-02 02:21:38 +00:00
|
|
|
// Copyright 2018 yuzu emulator team
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2018-05-03 04:16:12 +00:00
|
|
|
#include <atomic>
|
2018-05-03 01:26:14 +00:00
|
|
|
#include <condition_variable>
|
2018-09-17 22:15:09 +00:00
|
|
|
#include <cstddef>
|
2018-05-02 02:21:38 +00:00
|
|
|
#include <memory>
|
2018-05-03 01:26:14 +00:00
|
|
|
#include <mutex>
|
2018-05-02 02:21:38 +00:00
|
|
|
#include "common/common_types.h"
|
|
|
|
|
|
|
|
namespace Kernel {
|
2019-03-29 21:09:10 +00:00
|
|
|
class GlobalScheduler;
|
2020-01-25 22:55:32 +00:00
|
|
|
class PhysicalCore;
|
2019-04-02 13:22:53 +00:00
|
|
|
} // namespace Kernel
|
2018-05-02 02:21:38 +00:00
|
|
|
|
2019-03-04 21:02:59 +00:00
|
|
|
namespace Core {
|
|
|
|
class System;
|
|
|
|
}
|
|
|
|
|
2019-02-14 17:42:58 +00:00
|
|
|
namespace Core::Timing {
|
|
|
|
class CoreTiming;
|
|
|
|
}
|
|
|
|
|
2019-11-26 22:39:57 +00:00
|
|
|
namespace Memory {
|
|
|
|
class Memory;
|
|
|
|
}
|
|
|
|
|
2018-05-02 02:21:38 +00:00
|
|
|
namespace Core {
|
|
|
|
|
2018-05-03 01:26:14 +00:00
|
|
|
constexpr unsigned NUM_CPU_CORES{4};
|
|
|
|
|
2020-01-26 18:07:22 +00:00
|
|
|
class CoreManager {
|
2018-05-02 02:21:38 +00:00
|
|
|
public:
|
2020-01-26 18:07:22 +00:00
|
|
|
CoreManager(System& system, std::size_t core_index);
|
|
|
|
~CoreManager();
|
2018-05-02 02:21:38 +00:00
|
|
|
|
|
|
|
void RunLoop(bool tight_loop = true);
|
|
|
|
|
|
|
|
void SingleStep();
|
|
|
|
|
|
|
|
void PrepareReschedule();
|
|
|
|
|
2018-05-03 01:26:14 +00:00
|
|
|
bool IsMainCore() const {
|
|
|
|
return core_index == 0;
|
|
|
|
}
|
|
|
|
|
2018-09-15 13:21:06 +00:00
|
|
|
std::size_t CoreIndex() const {
|
2018-07-03 13:28:46 +00:00
|
|
|
return core_index;
|
|
|
|
}
|
|
|
|
|
2018-05-02 02:21:38 +00:00
|
|
|
private:
|
|
|
|
void Reschedule();
|
|
|
|
|
2019-03-29 21:09:10 +00:00
|
|
|
Kernel::GlobalScheduler& global_scheduler;
|
2020-01-25 22:55:32 +00:00
|
|
|
Kernel::PhysicalCore& physical_core;
|
2019-02-14 17:42:58 +00:00
|
|
|
Timing::CoreTiming& core_timing;
|
2018-05-02 02:21:38 +00:00
|
|
|
|
2018-08-12 22:51:47 +00:00
|
|
|
std::atomic<bool> reschedule_pending = false;
|
2018-09-15 13:21:06 +00:00
|
|
|
std::size_t core_index;
|
2018-05-02 02:21:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Core
|