mirror of
https://github.com/PabloMK7/citra.git
synced 2024-11-20 06:24:17 +00:00
Memory: move PageTable functions into class
This commit is contained in:
parent
b199b7ada9
commit
8c618c3fc3
8 changed files with 19 additions and 16 deletions
|
@ -172,7 +172,7 @@ ARM_Dynarmic::~ARM_Dynarmic() = default;
|
|||
MICROPROFILE_DEFINE(ARM_Jit, "ARM JIT", "ARM JIT", MP_RGB(255, 64, 64));
|
||||
|
||||
void ARM_Dynarmic::Run() {
|
||||
ASSERT(Memory::GetCurrentPageTable() == current_page_table);
|
||||
ASSERT(system.Memory().GetCurrentPageTable() == current_page_table);
|
||||
MICROPROFILE_SCOPE(ARM_Jit);
|
||||
|
||||
jit->Run();
|
||||
|
@ -279,7 +279,7 @@ void ARM_Dynarmic::InvalidateCacheRange(u32 start_address, std::size_t length) {
|
|||
}
|
||||
|
||||
void ARM_Dynarmic::PageTableChanged() {
|
||||
current_page_table = Memory::GetCurrentPageTable();
|
||||
current_page_table = system.Memory().GetCurrentPageTable();
|
||||
|
||||
auto iter = jits.find(current_page_table);
|
||||
if (iter != jits.end()) {
|
||||
|
|
|
@ -143,7 +143,7 @@ System::ResultStatus System::Load(EmuWindow& emu_window, const std::string& file
|
|||
return ResultStatus::ErrorLoader;
|
||||
}
|
||||
}
|
||||
Memory::SetCurrentPageTable(&kernel->GetCurrentProcess()->vm_manager.page_table);
|
||||
memory->SetCurrentPageTable(&kernel->GetCurrentProcess()->vm_manager.page_table);
|
||||
cheat_engine = std::make_unique<Cheats::CheatEngine>(*this);
|
||||
status = ResultStatus::Success;
|
||||
m_emu_window = &emu_window;
|
||||
|
|
|
@ -20,7 +20,7 @@ KernelSystem::KernelSystem(Memory::MemorySystem& memory, u32 system_mode) : memo
|
|||
MemoryInit(system_mode);
|
||||
|
||||
resource_limits = std::make_unique<ResourceLimitList>(*this);
|
||||
thread_manager = std::make_unique<ThreadManager>();
|
||||
thread_manager = std::make_unique<ThreadManager>(*this);
|
||||
timer_manager = std::make_unique<TimerManager>();
|
||||
}
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ void ThreadManager::SwitchContext(Thread* new_thread) {
|
|||
// Cancel any outstanding wakeup events for this thread
|
||||
timing.UnscheduleEvent(ThreadWakeupEventType, new_thread->thread_id);
|
||||
|
||||
auto previous_process = Core::System::GetInstance().Kernel().GetCurrentProcess();
|
||||
auto previous_process = kernel.GetCurrentProcess();
|
||||
|
||||
current_thread = new_thread;
|
||||
|
||||
|
@ -112,8 +112,9 @@ void ThreadManager::SwitchContext(Thread* new_thread) {
|
|||
new_thread->status = ThreadStatus::Running;
|
||||
|
||||
if (previous_process != current_thread->owner_process) {
|
||||
Core::System::GetInstance().Kernel().SetCurrentProcess(current_thread->owner_process);
|
||||
SetCurrentPageTable(¤t_thread->owner_process->vm_manager.page_table);
|
||||
kernel.SetCurrentProcess(current_thread->owner_process);
|
||||
kernel.memory.SetCurrentPageTable(
|
||||
¤t_thread->owner_process->vm_manager.page_table);
|
||||
}
|
||||
|
||||
Core::CPU().LoadContext(new_thread->context);
|
||||
|
@ -460,7 +461,7 @@ VAddr Thread::GetCommandBufferAddress() const {
|
|||
return GetTLSAddress() + CommandHeaderOffset;
|
||||
}
|
||||
|
||||
ThreadManager::ThreadManager() {
|
||||
ThreadManager::ThreadManager(Kernel::KernelSystem& kernel) : kernel(kernel) {
|
||||
ThreadWakeupEventType = Core::System::GetInstance().CoreTiming().RegisterEvent(
|
||||
"ThreadWakeupCallback",
|
||||
[this](u64 thread_id, s64 cycle_late) { ThreadWakeupCallback(thread_id, cycle_late); });
|
||||
|
|
|
@ -57,7 +57,7 @@ enum class ThreadWakeupReason {
|
|||
|
||||
class ThreadManager {
|
||||
public:
|
||||
ThreadManager();
|
||||
explicit ThreadManager(Kernel::KernelSystem& kernel);
|
||||
~ThreadManager();
|
||||
|
||||
/**
|
||||
|
@ -121,6 +121,8 @@ private:
|
|||
*/
|
||||
void ThreadWakeupCallback(u64 thread_id, s64 cycles_late);
|
||||
|
||||
Kernel::KernelSystem& kernel;
|
||||
|
||||
u32 next_thread_id = 1;
|
||||
SharedPtr<Thread> current_thread;
|
||||
Common::ThreadQueueList<Thread*, ThreadPrioLowest + 1> ready_queue;
|
||||
|
|
|
@ -27,14 +27,14 @@ std::array<u8, Memory::FCRAM_N3DS_SIZE> fcram;
|
|||
|
||||
static PageTable* current_page_table = nullptr;
|
||||
|
||||
void SetCurrentPageTable(PageTable* page_table) {
|
||||
void MemorySystem::SetCurrentPageTable(PageTable* page_table) {
|
||||
current_page_table = page_table;
|
||||
if (Core::System::GetInstance().IsPoweredOn()) {
|
||||
Core::CPU().PageTableChanged();
|
||||
}
|
||||
}
|
||||
|
||||
PageTable* GetCurrentPageTable() {
|
||||
PageTable* MemorySystem::GetCurrentPageTable() {
|
||||
return current_page_table;
|
||||
}
|
||||
|
||||
|
|
|
@ -180,10 +180,6 @@ enum : VAddr {
|
|||
|
||||
extern std::array<u8, Memory::FCRAM_N3DS_SIZE> fcram;
|
||||
|
||||
/// Currently active page table
|
||||
void SetCurrentPageTable(PageTable* page_table);
|
||||
PageTable* GetCurrentPageTable();
|
||||
|
||||
/// Determines if the given VAddr is valid for the specified process.
|
||||
bool IsValidVirtualAddress(const Kernel::Process& process, VAddr vaddr);
|
||||
|
||||
|
@ -253,6 +249,10 @@ void RasterizerFlushVirtualRegion(VAddr start, u32 size, FlushMode mode);
|
|||
|
||||
class MemorySystem {
|
||||
public:
|
||||
/// Currently active page table
|
||||
void SetCurrentPageTable(PageTable* page_table);
|
||||
PageTable* GetCurrentPageTable();
|
||||
|
||||
/// Gets offset in FCRAM from a pointer inside FCRAM range
|
||||
u32 GetFCRAMOffset(u8* pointer);
|
||||
};
|
||||
|
|
|
@ -33,7 +33,7 @@ TestEnvironment::TestEnvironment(bool mutable_memory_)
|
|||
Memory::MapIoRegion(*page_table, 0x00000000, 0x80000000, test_memory);
|
||||
Memory::MapIoRegion(*page_table, 0x80000000, 0x80000000, test_memory);
|
||||
|
||||
Memory::SetCurrentPageTable(page_table);
|
||||
memory.SetCurrentPageTable(page_table);
|
||||
}
|
||||
|
||||
TestEnvironment::~TestEnvironment() {
|
||||
|
|
Loading…
Reference in a new issue