mirror of
https://github.com/izzy2lost/dolphin.git
synced 2026-06-19 01:16:48 -07:00
UnitTests: Add PageTableHostMappingTest
This commit is contained in:
@@ -127,6 +127,22 @@ inline u64 swap64(const u8* data)
|
||||
return swap64(value);
|
||||
}
|
||||
|
||||
inline void WriteSwap16(u8* data, u16 value)
|
||||
{
|
||||
value = swap16(value);
|
||||
std::memcpy(data, &value, sizeof(u16));
|
||||
}
|
||||
inline void WriteSwap32(u8* data, u32 value)
|
||||
{
|
||||
value = swap32(value);
|
||||
std::memcpy(data, &value, sizeof(u32));
|
||||
}
|
||||
inline void WriteSwap64(u8* data, u64 value)
|
||||
{
|
||||
value = swap64(value);
|
||||
std::memcpy(data, &value, sizeof(u64));
|
||||
}
|
||||
|
||||
template <int count>
|
||||
void swap(u8*);
|
||||
|
||||
|
||||
@@ -85,6 +85,8 @@ public:
|
||||
u8* GetPhysicalPageMappingsBase() const { return m_physical_page_mappings_base; }
|
||||
u8* GetLogicalPageMappingsBase() const { return m_logical_page_mappings_base; }
|
||||
|
||||
u32 GetHostPageSize() const { return m_page_size; }
|
||||
|
||||
// FIXME: these should not return their address, but AddressSpace wants that
|
||||
u8*& GetRAM() { return m_ram; }
|
||||
u8*& GetEXRAM() { return m_exram; }
|
||||
|
||||
@@ -21,6 +21,7 @@ add_dolphin_test(SkylandersTest IOS/USB/SkylandersTest.cpp)
|
||||
if(_M_X86_64)
|
||||
add_dolphin_test(PowerPCTest
|
||||
PowerPC/DivUtilsTest.cpp
|
||||
PowerPC/PageTableHostMappingTest.cpp
|
||||
PowerPC/Jit64Common/ConvertDoubleToSingle.cpp
|
||||
PowerPC/Jit64Common/Fres.cpp
|
||||
PowerPC/Jit64Common/Frsqrte.cpp
|
||||
@@ -28,6 +29,7 @@ if(_M_X86_64)
|
||||
elseif(_M_ARM_64)
|
||||
add_dolphin_test(PowerPCTest
|
||||
PowerPC/DivUtilsTest.cpp
|
||||
PowerPC/PageTableHostMappingTest.cpp
|
||||
PowerPC/JitArm64/ConvertSingleDouble.cpp
|
||||
PowerPC/JitArm64/FPRF.cpp
|
||||
PowerPC/JitArm64/Fres.cpp
|
||||
@@ -37,9 +39,11 @@ elseif(_M_ARM_64)
|
||||
else()
|
||||
add_dolphin_test(PowerPCTest
|
||||
PowerPC/DivUtilsTest.cpp
|
||||
PowerPC/PageTableHostMappingTest.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
target_sources(PowerPCTest PRIVATE
|
||||
PowerPC/TestValues.h
|
||||
StubJit.h
|
||||
)
|
||||
|
||||
@@ -7,10 +7,11 @@
|
||||
#include "Common/ScopeGuard.h"
|
||||
#include "Core/Core.h"
|
||||
#include "Core/MemTools.h"
|
||||
#include "Core/PowerPC/JitCommon/JitBase.h"
|
||||
#include "Core/PowerPC/JitInterface.h"
|
||||
#include "Core/System.h"
|
||||
|
||||
#include "StubJit.h"
|
||||
|
||||
// include order is important
|
||||
#include <gtest/gtest.h> // NOLINT
|
||||
|
||||
@@ -23,26 +24,11 @@ enum
|
||||
#endif
|
||||
};
|
||||
|
||||
class PageFaultFakeJit : public JitBase
|
||||
class PageFaultFakeJit : public StubJit
|
||||
{
|
||||
public:
|
||||
explicit PageFaultFakeJit(Core::System& system) : JitBase(system) {}
|
||||
explicit PageFaultFakeJit(Core::System& system) : StubJit(system) {}
|
||||
|
||||
// CPUCoreBase methods
|
||||
void Init() override {}
|
||||
void Shutdown() override {}
|
||||
void ClearCache() override {}
|
||||
void Run() override {}
|
||||
void SingleStep() override {}
|
||||
const char* GetName() const override { return nullptr; }
|
||||
// JitBase methods
|
||||
JitBaseBlockCache* GetBlockCache() override { return nullptr; }
|
||||
void Jit(u32 em_address) override {}
|
||||
void EraseSingleBlock(const JitBlock&) override {}
|
||||
std::vector<MemoryStats> GetMemoryStats() const override { return {}; }
|
||||
std::size_t DisassembleNearCode(const JitBlock&, std::ostream&) const override { return 0; }
|
||||
std::size_t DisassembleFarCode(const JitBlock&, std::ostream&) const override { return 0; }
|
||||
const CommonAsmRoutinesBase* GetAsmRoutines() override { return nullptr; }
|
||||
bool HandleFault(uintptr_t access_address, SContext* ctx) override
|
||||
{
|
||||
m_pre_unprotect_time = std::chrono::high_resolution_clock::now();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,38 @@
|
||||
// Copyright 2026 Dolphin Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Core/PowerPC/JitCommon/JitBase.h"
|
||||
#include "Core/PowerPC/JitCommon/JitCache.h"
|
||||
|
||||
class StubJit : public JitBase
|
||||
{
|
||||
public:
|
||||
explicit StubJit(Core::System& system) : JitBase(system) {}
|
||||
|
||||
// CPUCoreBase methods
|
||||
void Init() override {}
|
||||
void Shutdown() override {}
|
||||
void ClearCache() override {}
|
||||
void Run() override {}
|
||||
void SingleStep() override {}
|
||||
const char* GetName() const override { return nullptr; }
|
||||
// JitBase methods
|
||||
JitBaseBlockCache* GetBlockCache() override { return nullptr; }
|
||||
void Jit(u32) override {}
|
||||
void EraseSingleBlock(const JitBlock&) override {}
|
||||
std::vector<MemoryStats> GetMemoryStats() const override { return {}; }
|
||||
std::size_t DisassembleNearCode(const JitBlock&, std::ostream&) const override { return 0; }
|
||||
std::size_t DisassembleFarCode(const JitBlock&, std::ostream&) const override { return 0; }
|
||||
const CommonAsmRoutinesBase* GetAsmRoutines() override { return nullptr; }
|
||||
bool HandleFault(uintptr_t, SContext*) override { return false; }
|
||||
};
|
||||
|
||||
class StubBlockCache : public JitBaseBlockCache
|
||||
{
|
||||
public:
|
||||
explicit StubBlockCache(JitBase& jit) : JitBaseBlockCache(jit) {}
|
||||
|
||||
void WriteLinkBlock(const JitBlock::LinkData&, const JitBlock*) override {}
|
||||
};
|
||||
@@ -32,6 +32,7 @@
|
||||
<ClInclude Include="Core\DSP\HermesText.h" />
|
||||
<ClInclude Include="Core\IOS\ES\TestBinaryData.h" />
|
||||
<ClInclude Include="Core\PowerPC\TestValues.h" />
|
||||
<ClInclude Include="Core\StubJit.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<!--gtest is rather small, so just include it into the build here-->
|
||||
@@ -74,6 +75,7 @@
|
||||
<ClCompile Include="Core\PageFaultTest.cpp" />
|
||||
<ClCompile Include="Core\PatchAllowlistTest.cpp" />
|
||||
<ClCompile Include="Core\PowerPC\DivUtilsTest.cpp" />
|
||||
<ClCompile Include="Core\PowerPC\PageTableHostMappingTest.cpp" />
|
||||
<ClCompile Include="VideoCommon\VertexLoaderTest.cpp" />
|
||||
<ClCompile Include="StubHost.cpp" />
|
||||
</ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user