mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-11-03 23:28:48 +00:00 
			
		
		
		
	ARM: pass MemorySystem separately in the constructor and make System optional
So that unit test can test CPU without constructing the entire system. Also remove hacks in the System class
This commit is contained in:
		
							parent
							
								
									9573ee46bd
								
							
						
					
					
						commit
						64f6e5e597
					
				
					 14 changed files with 80 additions and 65 deletions
				
			
		| 
						 | 
				
			
			@ -73,7 +73,7 @@ class DynarmicUserCallbacks final : public Dynarmic::A32::UserCallbacks {
 | 
			
		|||
public:
 | 
			
		||||
    explicit DynarmicUserCallbacks(ARM_Dynarmic& parent)
 | 
			
		||||
        : parent(parent), timing(parent.system.CoreTiming()), svc_context(parent.system),
 | 
			
		||||
          memory(parent.system.Memory()) {}
 | 
			
		||||
          memory(parent.memory) {}
 | 
			
		||||
    ~DynarmicUserCallbacks() = default;
 | 
			
		||||
 | 
			
		||||
    std::uint8_t MemoryRead8(VAddr vaddr) override {
 | 
			
		||||
| 
						 | 
				
			
			@ -163,9 +163,10 @@ public:
 | 
			
		|||
    Memory::MemorySystem& memory;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
ARM_Dynarmic::ARM_Dynarmic(Core::System& system, PrivilegeMode initial_mode)
 | 
			
		||||
    : system(system), cb(std::make_unique<DynarmicUserCallbacks>(*this)) {
 | 
			
		||||
    interpreter_state = std::make_shared<ARMul_State>(system, initial_mode);
 | 
			
		||||
ARM_Dynarmic::ARM_Dynarmic(Core::System* system, Memory::MemorySystem& memory,
 | 
			
		||||
                           PrivilegeMode initial_mode)
 | 
			
		||||
    : system(*system), memory(memory), cb(std::make_unique<DynarmicUserCallbacks>(*this)) {
 | 
			
		||||
    interpreter_state = std::make_shared<ARMul_State>(system, memory, initial_mode);
 | 
			
		||||
    PageTableChanged();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -174,7 +175,7 @@ ARM_Dynarmic::~ARM_Dynarmic() = default;
 | 
			
		|||
MICROPROFILE_DEFINE(ARM_Jit, "ARM JIT", "ARM JIT", MP_RGB(255, 64, 64));
 | 
			
		||||
 | 
			
		||||
void ARM_Dynarmic::Run() {
 | 
			
		||||
    ASSERT(system.Memory().GetCurrentPageTable() == current_page_table);
 | 
			
		||||
    ASSERT(memory.GetCurrentPageTable() == current_page_table);
 | 
			
		||||
    MICROPROFILE_SCOPE(ARM_Jit);
 | 
			
		||||
 | 
			
		||||
    jit->Run();
 | 
			
		||||
| 
						 | 
				
			
			@ -281,7 +282,7 @@ void ARM_Dynarmic::InvalidateCacheRange(u32 start_address, std::size_t length) {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
void ARM_Dynarmic::PageTableChanged() {
 | 
			
		||||
    current_page_table = system.Memory().GetCurrentPageTable();
 | 
			
		||||
    current_page_table = memory.GetCurrentPageTable();
 | 
			
		||||
 | 
			
		||||
    auto iter = jits.find(current_page_table);
 | 
			
		||||
    if (iter != jits.end()) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,6 +13,7 @@
 | 
			
		|||
 | 
			
		||||
namespace Memory {
 | 
			
		||||
struct PageTable;
 | 
			
		||||
class MemorySystem;
 | 
			
		||||
} // namespace Memory
 | 
			
		||||
 | 
			
		||||
namespace Core {
 | 
			
		||||
| 
						 | 
				
			
			@ -23,7 +24,7 @@ class DynarmicUserCallbacks;
 | 
			
		|||
 | 
			
		||||
class ARM_Dynarmic final : public ARM_Interface {
 | 
			
		||||
public:
 | 
			
		||||
    ARM_Dynarmic(Core::System& system, PrivilegeMode initial_mode);
 | 
			
		||||
    ARM_Dynarmic(Core::System* system, Memory::MemorySystem& memory, PrivilegeMode initial_mode);
 | 
			
		||||
    ~ARM_Dynarmic();
 | 
			
		||||
 | 
			
		||||
    void Run() override;
 | 
			
		||||
| 
						 | 
				
			
			@ -55,6 +56,7 @@ public:
 | 
			
		|||
private:
 | 
			
		||||
    friend class DynarmicUserCallbacks;
 | 
			
		||||
    Core::System& system;
 | 
			
		||||
    Memory::MemorySystem& memory;
 | 
			
		||||
    std::unique_ptr<DynarmicUserCallbacks> cb;
 | 
			
		||||
    std::unique_ptr<Dynarmic::A32::Jit> MakeJit();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue