Kernel: pass in MemorySystem
This commit is contained in:
parent
6992f76acf
commit
8118be6615
|
@ -176,7 +176,7 @@ System::ResultStatus System::Init(EmuWindow& emu_window, u32 system_mode) {
|
||||||
|
|
||||||
timing = std::make_unique<Timing>();
|
timing = std::make_unique<Timing>();
|
||||||
|
|
||||||
kernel = std::make_unique<Kernel::KernelSystem>(system_mode);
|
kernel = std::make_unique<Kernel::KernelSystem>(*memory, system_mode);
|
||||||
|
|
||||||
if (Settings::values.use_cpu_jit) {
|
if (Settings::values.use_cpu_jit) {
|
||||||
#ifdef ARCHITECTURE_x86_64
|
#ifdef ARCHITECTURE_x86_64
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
|
||||||
/// Initialize the kernel
|
/// Initialize the kernel
|
||||||
KernelSystem::KernelSystem(u32 system_mode) {
|
KernelSystem::KernelSystem(Memory::MemorySystem& memory, u32 system_mode) : memory(memory) {
|
||||||
MemoryInit(system_mode);
|
MemoryInit(system_mode);
|
||||||
|
|
||||||
resource_limits = std::make_unique<ResourceLimitList>(*this);
|
resource_limits = std::make_unique<ResourceLimitList>(*this);
|
||||||
|
|
|
@ -23,6 +23,10 @@ namespace SharedPage {
|
||||||
class Handler;
|
class Handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace Memory {
|
||||||
|
class MemorySystem;
|
||||||
|
}
|
||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
|
||||||
class AddressArbiter;
|
class AddressArbiter;
|
||||||
|
@ -73,7 +77,7 @@ using SharedPtr = boost::intrusive_ptr<T>;
|
||||||
|
|
||||||
class KernelSystem {
|
class KernelSystem {
|
||||||
public:
|
public:
|
||||||
explicit KernelSystem(u32 system_mode);
|
explicit KernelSystem(Memory::MemorySystem& memory, u32 system_mode);
|
||||||
~KernelSystem();
|
~KernelSystem();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -220,6 +224,8 @@ public:
|
||||||
/// Map of named ports managed by the kernel, which can be retrieved using the ConnectToPort
|
/// Map of named ports managed by the kernel, which can be retrieved using the ConnectToPort
|
||||||
std::unordered_map<std::string, SharedPtr<ClientPort>> named_ports;
|
std::unordered_map<std::string, SharedPtr<ClientPort>> named_ports;
|
||||||
|
|
||||||
|
Memory::MemorySystem& memory;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void MemoryInit(u32 mem_type);
|
void MemoryInit(u32 mem_type);
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,8 @@ TestEnvironment::TestEnvironment(bool mutable_memory_)
|
||||||
// so we need to create the kernel object there.
|
// so we need to create the kernel object there.
|
||||||
// Change this when all global states are eliminated.
|
// Change this when all global states are eliminated.
|
||||||
Core::System::GetInstance().timing = std::make_unique<Core::Timing>();
|
Core::System::GetInstance().timing = std::make_unique<Core::Timing>();
|
||||||
Core::System::GetInstance().kernel = std::make_unique<Kernel::KernelSystem>(0);
|
Memory::MemorySystem memory;
|
||||||
|
Core::System::GetInstance().kernel = std::make_unique<Kernel::KernelSystem>(memory, 0);
|
||||||
kernel = Core::System::GetInstance().kernel.get();
|
kernel = Core::System::GetInstance().kernel.get();
|
||||||
|
|
||||||
kernel->SetCurrentProcess(kernel->CreateProcess(kernel->CreateCodeSet("", 0)));
|
kernel->SetCurrentProcess(kernel->CreateProcess(kernel->CreateCodeSet("", 0)));
|
||||||
|
|
|
@ -23,7 +23,8 @@ static SharedPtr<Object> MakeObject(Kernel::KernelSystem& kernel) {
|
||||||
TEST_CASE("HLERequestContext::PopulateFromIncomingCommandBuffer", "[core][kernel]") {
|
TEST_CASE("HLERequestContext::PopulateFromIncomingCommandBuffer", "[core][kernel]") {
|
||||||
// HACK: see comments of member timing
|
// HACK: see comments of member timing
|
||||||
Core::System::GetInstance().timing = std::make_unique<Core::Timing>();
|
Core::System::GetInstance().timing = std::make_unique<Core::Timing>();
|
||||||
Kernel::KernelSystem kernel(0);
|
Memory::MemorySystem memory;
|
||||||
|
Kernel::KernelSystem kernel(memory, 0);
|
||||||
auto session = std::get<SharedPtr<ServerSession>>(kernel.CreateSessionPair());
|
auto session = std::get<SharedPtr<ServerSession>>(kernel.CreateSessionPair());
|
||||||
HLERequestContext context(std::move(session));
|
HLERequestContext context(std::move(session));
|
||||||
|
|
||||||
|
@ -235,7 +236,8 @@ TEST_CASE("HLERequestContext::PopulateFromIncomingCommandBuffer", "[core][kernel
|
||||||
TEST_CASE("HLERequestContext::WriteToOutgoingCommandBuffer", "[core][kernel]") {
|
TEST_CASE("HLERequestContext::WriteToOutgoingCommandBuffer", "[core][kernel]") {
|
||||||
// HACK: see comments of member timing
|
// HACK: see comments of member timing
|
||||||
Core::System::GetInstance().timing = std::make_unique<Core::Timing>();
|
Core::System::GetInstance().timing = std::make_unique<Core::Timing>();
|
||||||
Kernel::KernelSystem kernel(0);
|
Memory::MemorySystem memory;
|
||||||
|
Kernel::KernelSystem kernel(memory, 0);
|
||||||
auto session = std::get<SharedPtr<ServerSession>>(kernel.CreateSessionPair());
|
auto session = std::get<SharedPtr<ServerSession>>(kernel.CreateSessionPair());
|
||||||
HLERequestContext context(std::move(session));
|
HLERequestContext context(std::move(session));
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,8 @@
|
||||||
TEST_CASE("Memory::IsValidVirtualAddress", "[core][memory]") {
|
TEST_CASE("Memory::IsValidVirtualAddress", "[core][memory]") {
|
||||||
// HACK: see comments of member timing
|
// HACK: see comments of member timing
|
||||||
Core::System::GetInstance().timing = std::make_unique<Core::Timing>();
|
Core::System::GetInstance().timing = std::make_unique<Core::Timing>();
|
||||||
Kernel::KernelSystem kernel(0);
|
Memory::MemorySystem memory;
|
||||||
|
Kernel::KernelSystem kernel(memory, 0);
|
||||||
SECTION("these regions should not be mapped on an empty process") {
|
SECTION("these regions should not be mapped on an empty process") {
|
||||||
auto process = kernel.CreateProcess(kernel.CreateCodeSet("", 0));
|
auto process = kernel.CreateProcess(kernel.CreateCodeSet("", 0));
|
||||||
CHECK(Memory::IsValidVirtualAddress(*process, Memory::PROCESS_IMAGE_VADDR) == false);
|
CHECK(Memory::IsValidVirtualAddress(*process, Memory::PROCESS_IMAGE_VADDR) == false);
|
||||||
|
|
Reference in New Issue