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:
Weiyi Wang
2019-02-01 14:50:25 -05:00
parent 9573ee46bd
commit 64f6e5e597
14 changed files with 80 additions and 65 deletions

View File

@@ -11,11 +11,9 @@
#include "core/memory.h"
TEST_CASE("Memory::IsValidVirtualAddress", "[core][memory]") {
// HACK: see comments of member timing
Core::System::GetInstance().timing = std::make_unique<Core::Timing>();
Core::System::GetInstance().memory = std::make_unique<Memory::MemorySystem>();
Kernel::KernelSystem kernel(*Core::System::GetInstance().memory,
*Core::System::GetInstance().timing, [] {}, 0);
Core::Timing timing;
Memory::MemorySystem memory;
Kernel::KernelSystem kernel(memory, timing, [] {}, 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);