mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-31 05:40:04 +00:00 
			
		
		
		
	Merge branch 'master' into feature/savestates-2
This commit is contained in:
		
						commit
						da3ab3d56e
					
				
					 80 changed files with 7297 additions and 2608 deletions
				
			
		|  | @ -15,9 +15,9 @@ static std::shared_ptr<Memory::PageTable> page_table = nullptr; | |||
| TestEnvironment::TestEnvironment(bool mutable_memory_) | ||||
|     : mutable_memory(mutable_memory_), test_memory(std::make_shared<TestMemory>(this)) { | ||||
| 
 | ||||
|     timing = std::make_unique<Core::Timing>(); | ||||
|     timing = std::make_unique<Core::Timing>(1); | ||||
|     memory = std::make_unique<Memory::MemorySystem>(); | ||||
|     kernel = std::make_unique<Kernel::KernelSystem>(*memory, *timing, [] {}, 0); | ||||
|     kernel = std::make_unique<Kernel::KernelSystem>(*memory, *timing, [] {}, 0, 1, 0); | ||||
| 
 | ||||
|     kernel->SetCurrentProcess(kernel->CreateProcess(kernel->CreateCodeSet("", 0))); | ||||
|     page_table = kernel->GetCurrentProcess()->vm_manager.page_table; | ||||
|  |  | |||
|  | @ -23,7 +23,7 @@ TEST_CASE("ARM_DynCom (vfp): vadd", "[arm_dyncom]") { | |||
|     test_env.SetMemory32(0, 0xEE321A03); // vadd.f32 s2, s4, s6
 | ||||
|     test_env.SetMemory32(4, 0xEAFFFFFE); // b +#0
 | ||||
| 
 | ||||
|     ARM_DynCom dyncom(nullptr, test_env.GetMemory(), USER32MODE); | ||||
|     ARM_DynCom dyncom(nullptr, test_env.GetMemory(), USER32MODE, 0, nullptr); | ||||
| 
 | ||||
|     std::vector<VfpTestCase> test_cases{{ | ||||
| #include "vfp_vadd_f32.inc" | ||||
|  |  | |||
|  | @ -34,16 +34,16 @@ static void AdvanceAndCheck(Core::Timing& timing, u32 idx, int downcount, int ex | |||
|     expected_callback = CB_IDS[idx]; | ||||
|     lateness = expected_lateness; | ||||
| 
 | ||||
|     timing.AddTicks(timing.GetDowncount() - | ||||
|                     cpu_downcount); // Pretend we executed X cycles of instructions.
 | ||||
|     timing.Advance(); | ||||
|     timing.GetTimer(0)->AddTicks(timing.GetTimer(0)->GetDowncount() - | ||||
|                                  cpu_downcount); // Pretend we executed X cycles of instructions.
 | ||||
|     timing.GetTimer(0)->Advance(); | ||||
| 
 | ||||
|     REQUIRE(decltype(callbacks_ran_flags)().set(idx) == callbacks_ran_flags); | ||||
|     REQUIRE(downcount == timing.GetDowncount()); | ||||
|     REQUIRE(downcount == timing.GetTimer(0)->GetDowncount()); | ||||
| } | ||||
| 
 | ||||
| TEST_CASE("CoreTiming[BasicOrder]", "[core]") { | ||||
|     Core::Timing timing; | ||||
|     Core::Timing timing(1); | ||||
| 
 | ||||
|     Core::TimingEventType* cb_a = timing.RegisterEvent("callbackA", CallbackTemplate<0>); | ||||
|     Core::TimingEventType* cb_b = timing.RegisterEvent("callbackB", CallbackTemplate<1>); | ||||
|  | @ -52,60 +52,19 @@ TEST_CASE("CoreTiming[BasicOrder]", "[core]") { | |||
|     Core::TimingEventType* cb_e = timing.RegisterEvent("callbackE", CallbackTemplate<4>); | ||||
| 
 | ||||
|     // Enter slice 0
 | ||||
|     timing.Advance(); | ||||
|     timing.GetTimer(0)->Advance(); | ||||
| 
 | ||||
|     // D -> B -> C -> A -> E
 | ||||
|     timing.ScheduleEvent(1000, cb_a, CB_IDS[0]); | ||||
|     REQUIRE(1000 == timing.GetDowncount()); | ||||
|     timing.ScheduleEvent(500, cb_b, CB_IDS[1]); | ||||
|     REQUIRE(500 == timing.GetDowncount()); | ||||
|     timing.ScheduleEvent(800, cb_c, CB_IDS[2]); | ||||
|     REQUIRE(500 == timing.GetDowncount()); | ||||
|     timing.ScheduleEvent(100, cb_d, CB_IDS[3]); | ||||
|     REQUIRE(100 == timing.GetDowncount()); | ||||
|     timing.ScheduleEvent(1200, cb_e, CB_IDS[4]); | ||||
|     REQUIRE(100 == timing.GetDowncount()); | ||||
| 
 | ||||
|     AdvanceAndCheck(timing, 3, 400); | ||||
|     AdvanceAndCheck(timing, 1, 300); | ||||
|     AdvanceAndCheck(timing, 2, 200); | ||||
|     AdvanceAndCheck(timing, 0, 200); | ||||
|     AdvanceAndCheck(timing, 4, MAX_SLICE_LENGTH); | ||||
| } | ||||
| 
 | ||||
| TEST_CASE("CoreTiming[Threadsave]", "[core]") { | ||||
|     Core::Timing timing; | ||||
| 
 | ||||
|     Core::TimingEventType* cb_a = timing.RegisterEvent("callbackA", CallbackTemplate<0>); | ||||
|     Core::TimingEventType* cb_b = timing.RegisterEvent("callbackB", CallbackTemplate<1>); | ||||
|     Core::TimingEventType* cb_c = timing.RegisterEvent("callbackC", CallbackTemplate<2>); | ||||
|     Core::TimingEventType* cb_d = timing.RegisterEvent("callbackD", CallbackTemplate<3>); | ||||
|     Core::TimingEventType* cb_e = timing.RegisterEvent("callbackE", CallbackTemplate<4>); | ||||
| 
 | ||||
|     // Enter slice 0
 | ||||
|     timing.Advance(); | ||||
| 
 | ||||
|     // D -> B -> C -> A -> E
 | ||||
|     timing.ScheduleEventThreadsafe(1000, cb_a, CB_IDS[0]); | ||||
|     // Manually force since ScheduleEventThreadsafe doesn't call it
 | ||||
|     timing.ForceExceptionCheck(1000); | ||||
|     REQUIRE(1000 == timing.GetDowncount()); | ||||
|     timing.ScheduleEventThreadsafe(500, cb_b, CB_IDS[1]); | ||||
|     // Manually force since ScheduleEventThreadsafe doesn't call it
 | ||||
|     timing.ForceExceptionCheck(500); | ||||
|     REQUIRE(500 == timing.GetDowncount()); | ||||
|     timing.ScheduleEventThreadsafe(800, cb_c, CB_IDS[2]); | ||||
|     // Manually force since ScheduleEventThreadsafe doesn't call it
 | ||||
|     timing.ForceExceptionCheck(800); | ||||
|     REQUIRE(500 == timing.GetDowncount()); | ||||
|     timing.ScheduleEventThreadsafe(100, cb_d, CB_IDS[3]); | ||||
|     // Manually force since ScheduleEventThreadsafe doesn't call it
 | ||||
|     timing.ForceExceptionCheck(100); | ||||
|     REQUIRE(100 == timing.GetDowncount()); | ||||
|     timing.ScheduleEventThreadsafe(1200, cb_e, CB_IDS[4]); | ||||
|     // Manually force since ScheduleEventThreadsafe doesn't call it
 | ||||
|     timing.ForceExceptionCheck(1200); | ||||
|     REQUIRE(100 == timing.GetDowncount()); | ||||
|     timing.ScheduleEvent(1000, cb_a, CB_IDS[0], 0); | ||||
|     REQUIRE(1000 == timing.GetTimer(0)->GetDowncount()); | ||||
|     timing.ScheduleEvent(500, cb_b, CB_IDS[1], 0); | ||||
|     REQUIRE(500 == timing.GetTimer(0)->GetDowncount()); | ||||
|     timing.ScheduleEvent(800, cb_c, CB_IDS[2], 0); | ||||
|     REQUIRE(500 == timing.GetTimer(0)->GetDowncount()); | ||||
|     timing.ScheduleEvent(100, cb_d, CB_IDS[3], 0); | ||||
|     REQUIRE(100 == timing.GetTimer(0)->GetDowncount()); | ||||
|     timing.ScheduleEvent(1200, cb_e, CB_IDS[4], 0); | ||||
|     REQUIRE(100 == timing.GetTimer(0)->GetDowncount()); | ||||
| 
 | ||||
|     AdvanceAndCheck(timing, 3, 400); | ||||
|     AdvanceAndCheck(timing, 1, 300); | ||||
|  | @ -131,7 +90,7 @@ void FifoCallback(u64 userdata, s64 cycles_late) { | |||
| TEST_CASE("CoreTiming[SharedSlot]", "[core]") { | ||||
|     using namespace SharedSlotTest; | ||||
| 
 | ||||
|     Core::Timing timing; | ||||
|     Core::Timing timing(1); | ||||
| 
 | ||||
|     Core::TimingEventType* cb_a = timing.RegisterEvent("callbackA", FifoCallback<0>); | ||||
|     Core::TimingEventType* cb_b = timing.RegisterEvent("callbackB", FifoCallback<1>); | ||||
|  | @ -139,36 +98,36 @@ TEST_CASE("CoreTiming[SharedSlot]", "[core]") { | |||
|     Core::TimingEventType* cb_d = timing.RegisterEvent("callbackD", FifoCallback<3>); | ||||
|     Core::TimingEventType* cb_e = timing.RegisterEvent("callbackE", FifoCallback<4>); | ||||
| 
 | ||||
|     timing.ScheduleEvent(1000, cb_a, CB_IDS[0]); | ||||
|     timing.ScheduleEvent(1000, cb_b, CB_IDS[1]); | ||||
|     timing.ScheduleEvent(1000, cb_c, CB_IDS[2]); | ||||
|     timing.ScheduleEvent(1000, cb_d, CB_IDS[3]); | ||||
|     timing.ScheduleEvent(1000, cb_e, CB_IDS[4]); | ||||
|     timing.ScheduleEvent(1000, cb_a, CB_IDS[0], 0); | ||||
|     timing.ScheduleEvent(1000, cb_b, CB_IDS[1], 0); | ||||
|     timing.ScheduleEvent(1000, cb_c, CB_IDS[2], 0); | ||||
|     timing.ScheduleEvent(1000, cb_d, CB_IDS[3], 0); | ||||
|     timing.ScheduleEvent(1000, cb_e, CB_IDS[4], 0); | ||||
| 
 | ||||
|     // Enter slice 0
 | ||||
|     timing.Advance(); | ||||
|     REQUIRE(1000 == timing.GetDowncount()); | ||||
|     timing.GetTimer(0)->Advance(); | ||||
|     REQUIRE(1000 == timing.GetTimer(0)->GetDowncount()); | ||||
| 
 | ||||
|     callbacks_ran_flags = 0; | ||||
|     counter = 0; | ||||
|     lateness = 0; | ||||
|     timing.AddTicks(timing.GetDowncount()); | ||||
|     timing.Advance(); | ||||
|     REQUIRE(MAX_SLICE_LENGTH == timing.GetDowncount()); | ||||
|     timing.GetTimer(0)->AddTicks(timing.GetTimer(0)->GetDowncount()); | ||||
|     timing.GetTimer(0)->Advance(); | ||||
|     REQUIRE(MAX_SLICE_LENGTH == timing.GetTimer(0)->GetDowncount()); | ||||
|     REQUIRE(0x1FULL == callbacks_ran_flags.to_ullong()); | ||||
| } | ||||
| 
 | ||||
| TEST_CASE("CoreTiming[PredictableLateness]", "[core]") { | ||||
|     Core::Timing timing; | ||||
|     Core::Timing timing(1); | ||||
| 
 | ||||
|     Core::TimingEventType* cb_a = timing.RegisterEvent("callbackA", CallbackTemplate<0>); | ||||
|     Core::TimingEventType* cb_b = timing.RegisterEvent("callbackB", CallbackTemplate<1>); | ||||
| 
 | ||||
|     // Enter slice 0
 | ||||
|     timing.Advance(); | ||||
|     timing.GetTimer(0)->Advance(); | ||||
| 
 | ||||
|     timing.ScheduleEvent(100, cb_a, CB_IDS[0]); | ||||
|     timing.ScheduleEvent(200, cb_b, CB_IDS[1]); | ||||
|     timing.ScheduleEvent(100, cb_a, CB_IDS[0], 0); | ||||
|     timing.ScheduleEvent(200, cb_b, CB_IDS[1], 0); | ||||
| 
 | ||||
|     AdvanceAndCheck(timing, 0, 90, 10, -10); // (100 - 10)
 | ||||
|     AdvanceAndCheck(timing, 1, MAX_SLICE_LENGTH, 50, -50); | ||||
|  | @ -190,7 +149,7 @@ static void RescheduleCallback(Core::Timing& timing, u64 userdata, s64 cycles_la | |||
| TEST_CASE("CoreTiming[ChainScheduling]", "[core]") { | ||||
|     using namespace ChainSchedulingTest; | ||||
| 
 | ||||
|     Core::Timing timing; | ||||
|     Core::Timing timing(1); | ||||
| 
 | ||||
|     Core::TimingEventType* cb_a = timing.RegisterEvent("callbackA", CallbackTemplate<0>); | ||||
|     Core::TimingEventType* cb_b = timing.RegisterEvent("callbackB", CallbackTemplate<1>); | ||||
|  | @ -201,28 +160,30 @@ TEST_CASE("CoreTiming[ChainScheduling]", "[core]") { | |||
|         }); | ||||
| 
 | ||||
|     // Enter slice 0
 | ||||
|     timing.Advance(); | ||||
|     timing.GetTimer(0)->Advance(); | ||||
| 
 | ||||
|     timing.ScheduleEvent(800, cb_a, CB_IDS[0]); | ||||
|     timing.ScheduleEvent(1000, cb_b, CB_IDS[1]); | ||||
|     timing.ScheduleEvent(2200, cb_c, CB_IDS[2]); | ||||
|     timing.ScheduleEvent(1000, cb_rs, reinterpret_cast<u64>(cb_rs)); | ||||
|     REQUIRE(800 == timing.GetDowncount()); | ||||
|     timing.ScheduleEvent(800, cb_a, CB_IDS[0], 0); | ||||
|     timing.ScheduleEvent(1000, cb_b, CB_IDS[1], 0); | ||||
|     timing.ScheduleEvent(2200, cb_c, CB_IDS[2], 0); | ||||
|     timing.ScheduleEvent(1000, cb_rs, reinterpret_cast<u64>(cb_rs), 0); | ||||
|     REQUIRE(800 == timing.GetTimer(0)->GetDowncount()); | ||||
| 
 | ||||
|     reschedules = 3; | ||||
|     AdvanceAndCheck(timing, 0, 200);  // cb_a
 | ||||
|     AdvanceAndCheck(timing, 1, 1000); // cb_b, cb_rs
 | ||||
|     REQUIRE(2 == reschedules); | ||||
| 
 | ||||
|     timing.AddTicks(timing.GetDowncount()); | ||||
|     timing.Advance(); // cb_rs
 | ||||
|     timing.GetTimer(0)->AddTicks(timing.GetTimer(0)->GetDowncount()); | ||||
|     timing.GetTimer(0)->Advance(); // cb_rs
 | ||||
|     REQUIRE(1 == reschedules); | ||||
|     REQUIRE(200 == timing.GetDowncount()); | ||||
|     REQUIRE(200 == timing.GetTimer(0)->GetDowncount()); | ||||
| 
 | ||||
|     AdvanceAndCheck(timing, 2, 800); // cb_c
 | ||||
| 
 | ||||
|     timing.AddTicks(timing.GetDowncount()); | ||||
|     timing.Advance(); // cb_rs
 | ||||
|     timing.GetTimer(0)->AddTicks(timing.GetTimer(0)->GetDowncount()); | ||||
|     timing.GetTimer(0)->Advance(); // cb_rs
 | ||||
|     REQUIRE(0 == reschedules); | ||||
|     REQUIRE(MAX_SLICE_LENGTH == timing.GetDowncount()); | ||||
|     REQUIRE(MAX_SLICE_LENGTH == timing.GetTimer(0)->GetDowncount()); | ||||
| } | ||||
| 
 | ||||
| // TODO: Add tests for multiple timers
 | ||||
|  |  | |||
|  | @ -24,9 +24,9 @@ static std::shared_ptr<Object> MakeObject(Kernel::KernelSystem& kernel) { | |||
| } | ||||
| 
 | ||||
| TEST_CASE("HLERequestContext::PopulateFromIncomingCommandBuffer", "[core][kernel]") { | ||||
|     Core::Timing timing; | ||||
|     Core::Timing timing(1); | ||||
|     Memory::MemorySystem memory; | ||||
|     Kernel::KernelSystem kernel(memory, timing, [] {}, 0); | ||||
|     Kernel::KernelSystem kernel(memory, timing, [] {}, 0, 1, 0); | ||||
|     auto [server, client] = kernel.CreateSessionPair(); | ||||
|     HLERequestContext context(kernel, std::move(server), nullptr); | ||||
| 
 | ||||
|  | @ -239,9 +239,9 @@ TEST_CASE("HLERequestContext::PopulateFromIncomingCommandBuffer", "[core][kernel | |||
| } | ||||
| 
 | ||||
| TEST_CASE("HLERequestContext::WriteToOutgoingCommandBuffer", "[core][kernel]") { | ||||
|     Core::Timing timing; | ||||
|     Core::Timing timing(1); | ||||
|     Memory::MemorySystem memory; | ||||
|     Kernel::KernelSystem kernel(memory, timing, [] {}, 0); | ||||
|     Kernel::KernelSystem kernel(memory, timing, [] {}, 0, 1, 0); | ||||
|     auto [server, client] = kernel.CreateSessionPair(); | ||||
|     HLERequestContext context(kernel, std::move(server), nullptr); | ||||
| 
 | ||||
|  |  | |||
|  | @ -11,9 +11,9 @@ | |||
| #include "core/memory.h" | ||||
| 
 | ||||
| TEST_CASE("Memory::IsValidVirtualAddress", "[core][memory]") { | ||||
|     Core::Timing timing; | ||||
|     Core::Timing timing(1); | ||||
|     Memory::MemorySystem memory; | ||||
|     Kernel::KernelSystem kernel(memory, timing, [] {}, 0); | ||||
|     Kernel::KernelSystem kernel(memory, timing, [] {}, 0, 1, 0); | ||||
|     SECTION("these regions should not be mapped on an empty process") { | ||||
|         auto process = kernel.CreateProcess(kernel.CreateCodeSet("", 0)); | ||||
|         CHECK(Memory::IsValidVirtualAddress(*process, Memory::PROCESS_IMAGE_VADDR) == false); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue