From 7a564b904bcd97f220d3c38a2723d22b50f9b4e3 Mon Sep 17 00:00:00 2001 From: Weiyi Wang Date: Thu, 8 Nov 2018 12:14:14 -0500 Subject: [PATCH] tests: use VMManager::MapBackingMemory --- src/tests/core/hle/kernel/hle_ipc.cpp | 25 +++++++++++++------------ src/tests/core/memory/vm_manager.cpp | 20 ++++++++++---------- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/src/tests/core/hle/kernel/hle_ipc.cpp b/src/tests/core/hle/kernel/hle_ipc.cpp index 2e404a32d4..86de36db48 100644 --- a/src/tests/core/hle/kernel/hle_ipc.cpp +++ b/src/tests/core/hle/kernel/hle_ipc.cpp @@ -139,8 +139,8 @@ TEST_CASE("HLERequestContext::PopulateFromIncomingCommandBuffer", "[core][kernel std::fill(buffer->begin(), buffer->end(), 0xAB); VAddr target_address = 0x10000000; - auto result = process->vm_manager.MapMemoryBlock(target_address, buffer, 0, buffer->size(), - MemoryState::Private); + auto result = process->vm_manager.MapBackingMemory(target_address, buffer->data(), + buffer->size(), MemoryState::Private); REQUIRE(result.Code() == RESULT_SUCCESS); const u32_le input[]{ @@ -161,8 +161,8 @@ TEST_CASE("HLERequestContext::PopulateFromIncomingCommandBuffer", "[core][kernel std::fill(buffer->begin(), buffer->end(), 0xCD); VAddr target_address = 0x10000000; - auto result = process->vm_manager.MapMemoryBlock(target_address, buffer, 0, buffer->size(), - MemoryState::Private); + auto result = process->vm_manager.MapBackingMemory(target_address, buffer->data(), + buffer->size(), MemoryState::Private); const u32_le input[]{ IPC::MakeHeader(0, 0, 2), @@ -188,13 +188,14 @@ TEST_CASE("HLERequestContext::PopulateFromIncomingCommandBuffer", "[core][kernel std::fill(buffer_mapped->begin(), buffer_mapped->end(), 0xDF); VAddr target_address_static = 0x10000000; - auto result = process->vm_manager.MapMemoryBlock( - target_address_static, buffer_static, 0, buffer_static->size(), MemoryState::Private); + auto result = + process->vm_manager.MapBackingMemory(target_address_static, buffer_static->data(), + buffer_static->size(), MemoryState::Private); REQUIRE(result.Code() == RESULT_SUCCESS); VAddr target_address_mapped = 0x20000000; - result = process->vm_manager.MapMemoryBlock(target_address_mapped, buffer_mapped, 0, - buffer_mapped->size(), MemoryState::Private); + result = process->vm_manager.MapBackingMemory(target_address_mapped, buffer_mapped->data(), + buffer_mapped->size(), MemoryState::Private); REQUIRE(result.Code() == RESULT_SUCCESS); auto a = MakeObject(kernel); @@ -315,8 +316,8 @@ TEST_CASE("HLERequestContext::WriteToOutgoingCommandBuffer", "[core][kernel]") { auto output_buffer = std::make_shared>(Memory::PAGE_SIZE); VAddr target_address = 0x10000000; - auto result = process->vm_manager.MapMemoryBlock( - target_address, output_buffer, 0, output_buffer->size(), MemoryState::Private); + auto result = process->vm_manager.MapBackingMemory( + target_address, output_buffer->data(), output_buffer->size(), MemoryState::Private); REQUIRE(result.Code() == RESULT_SUCCESS); input[0] = IPC::MakeHeader(0, 0, 2); @@ -344,8 +345,8 @@ TEST_CASE("HLERequestContext::WriteToOutgoingCommandBuffer", "[core][kernel]") { auto output_buffer = std::make_shared>(Memory::PAGE_SIZE); VAddr target_address = 0x10000000; - auto result = process->vm_manager.MapMemoryBlock( - target_address, output_buffer, 0, output_buffer->size(), MemoryState::Private); + auto result = process->vm_manager.MapBackingMemory( + target_address, output_buffer->data(), output_buffer->size(), MemoryState::Private); REQUIRE(result.Code() == RESULT_SUCCESS); const u32_le input_cmdbuff[]{ diff --git a/src/tests/core/memory/vm_manager.cpp b/src/tests/core/memory/vm_manager.cpp index 00d03dbc3e..9fb365df2a 100644 --- a/src/tests/core/memory/vm_manager.cpp +++ b/src/tests/core/memory/vm_manager.cpp @@ -14,23 +14,23 @@ TEST_CASE("Memory Basics", "[kernel][memory]") { SECTION("mapping memory") { // Because of the PageTable, Kernel::VMManager is too big to be created on the stack. auto manager = std::make_unique(); - auto result = manager->MapMemoryBlock(Memory::HEAP_VADDR, block, 0, block->size(), - Kernel::MemoryState::Private); + auto result = manager->MapBackingMemory(Memory::HEAP_VADDR, block->data(), block->size(), + Kernel::MemoryState::Private); REQUIRE(result.Code() == RESULT_SUCCESS); auto vma = manager->FindVMA(Memory::HEAP_VADDR); CHECK(vma != manager->vma_map.end()); CHECK(vma->second.size == block->size()); - CHECK(vma->second.type == Kernel::VMAType::AllocatedMemoryBlock); - CHECK(vma->second.backing_block == block); + CHECK(vma->second.type == Kernel::VMAType::BackingMemory); + CHECK(vma->second.backing_memory == block->data()); CHECK(vma->second.meminfo_state == Kernel::MemoryState::Private); } SECTION("unmapping memory") { // Because of the PageTable, Kernel::VMManager is too big to be created on the stack. auto manager = std::make_unique(); - auto result = manager->MapMemoryBlock(Memory::HEAP_VADDR, block, 0, block->size(), - Kernel::MemoryState::Private); + auto result = manager->MapBackingMemory(Memory::HEAP_VADDR, block->data(), block->size(), + Kernel::MemoryState::Private); REQUIRE(result.Code() == RESULT_SUCCESS); ResultCode code = manager->UnmapRange(Memory::HEAP_VADDR, block->size()); @@ -45,8 +45,8 @@ TEST_CASE("Memory Basics", "[kernel][memory]") { SECTION("changing memory permissions") { // Because of the PageTable, Kernel::VMManager is too big to be created on the stack. auto manager = std::make_unique(); - auto result = manager->MapMemoryBlock(Memory::HEAP_VADDR, block, 0, block->size(), - Kernel::MemoryState::Private); + auto result = manager->MapBackingMemory(Memory::HEAP_VADDR, block->data(), block->size(), + Kernel::MemoryState::Private); REQUIRE(result.Code() == RESULT_SUCCESS); ResultCode code = manager->ReprotectRange(Memory::HEAP_VADDR, block->size(), @@ -64,8 +64,8 @@ TEST_CASE("Memory Basics", "[kernel][memory]") { SECTION("changing memory state") { // Because of the PageTable, Kernel::VMManager is too big to be created on the stack. auto manager = std::make_unique(); - auto result = manager->MapMemoryBlock(Memory::HEAP_VADDR, block, 0, block->size(), - Kernel::MemoryState::Private); + auto result = manager->MapBackingMemory(Memory::HEAP_VADDR, block->data(), block->size(), + Kernel::MemoryState::Private); REQUIRE(result.Code() == RESULT_SUCCESS); ResultCode code = manager->ReprotectRange(Memory::HEAP_VADDR, block->size(),