tests: use VMManager::MapBackingMemory

This commit is contained in:
Weiyi Wang 2018-11-08 12:14:14 -05:00
parent 560df843b1
commit 7a564b904b
2 changed files with 23 additions and 22 deletions

View file

@ -139,8 +139,8 @@ TEST_CASE("HLERequestContext::PopulateFromIncomingCommandBuffer", "[core][kernel
std::fill(buffer->begin(), buffer->end(), 0xAB); std::fill(buffer->begin(), buffer->end(), 0xAB);
VAddr target_address = 0x10000000; VAddr target_address = 0x10000000;
auto result = process->vm_manager.MapMemoryBlock(target_address, buffer, 0, buffer->size(), auto result = process->vm_manager.MapBackingMemory(target_address, buffer->data(),
MemoryState::Private); buffer->size(), MemoryState::Private);
REQUIRE(result.Code() == RESULT_SUCCESS); REQUIRE(result.Code() == RESULT_SUCCESS);
const u32_le input[]{ const u32_le input[]{
@ -161,8 +161,8 @@ TEST_CASE("HLERequestContext::PopulateFromIncomingCommandBuffer", "[core][kernel
std::fill(buffer->begin(), buffer->end(), 0xCD); std::fill(buffer->begin(), buffer->end(), 0xCD);
VAddr target_address = 0x10000000; VAddr target_address = 0x10000000;
auto result = process->vm_manager.MapMemoryBlock(target_address, buffer, 0, buffer->size(), auto result = process->vm_manager.MapBackingMemory(target_address, buffer->data(),
MemoryState::Private); buffer->size(), MemoryState::Private);
const u32_le input[]{ const u32_le input[]{
IPC::MakeHeader(0, 0, 2), IPC::MakeHeader(0, 0, 2),
@ -188,12 +188,13 @@ TEST_CASE("HLERequestContext::PopulateFromIncomingCommandBuffer", "[core][kernel
std::fill(buffer_mapped->begin(), buffer_mapped->end(), 0xDF); std::fill(buffer_mapped->begin(), buffer_mapped->end(), 0xDF);
VAddr target_address_static = 0x10000000; VAddr target_address_static = 0x10000000;
auto result = process->vm_manager.MapMemoryBlock( auto result =
target_address_static, buffer_static, 0, buffer_static->size(), MemoryState::Private); process->vm_manager.MapBackingMemory(target_address_static, buffer_static->data(),
buffer_static->size(), MemoryState::Private);
REQUIRE(result.Code() == RESULT_SUCCESS); REQUIRE(result.Code() == RESULT_SUCCESS);
VAddr target_address_mapped = 0x20000000; VAddr target_address_mapped = 0x20000000;
result = process->vm_manager.MapMemoryBlock(target_address_mapped, buffer_mapped, 0, result = process->vm_manager.MapBackingMemory(target_address_mapped, buffer_mapped->data(),
buffer_mapped->size(), MemoryState::Private); buffer_mapped->size(), MemoryState::Private);
REQUIRE(result.Code() == RESULT_SUCCESS); REQUIRE(result.Code() == RESULT_SUCCESS);
@ -315,8 +316,8 @@ TEST_CASE("HLERequestContext::WriteToOutgoingCommandBuffer", "[core][kernel]") {
auto output_buffer = std::make_shared<std::vector<u8>>(Memory::PAGE_SIZE); auto output_buffer = std::make_shared<std::vector<u8>>(Memory::PAGE_SIZE);
VAddr target_address = 0x10000000; VAddr target_address = 0x10000000;
auto result = process->vm_manager.MapMemoryBlock( auto result = process->vm_manager.MapBackingMemory(
target_address, output_buffer, 0, output_buffer->size(), MemoryState::Private); target_address, output_buffer->data(), output_buffer->size(), MemoryState::Private);
REQUIRE(result.Code() == RESULT_SUCCESS); REQUIRE(result.Code() == RESULT_SUCCESS);
input[0] = IPC::MakeHeader(0, 0, 2); input[0] = IPC::MakeHeader(0, 0, 2);
@ -344,8 +345,8 @@ TEST_CASE("HLERequestContext::WriteToOutgoingCommandBuffer", "[core][kernel]") {
auto output_buffer = std::make_shared<std::vector<u8>>(Memory::PAGE_SIZE); auto output_buffer = std::make_shared<std::vector<u8>>(Memory::PAGE_SIZE);
VAddr target_address = 0x10000000; VAddr target_address = 0x10000000;
auto result = process->vm_manager.MapMemoryBlock( auto result = process->vm_manager.MapBackingMemory(
target_address, output_buffer, 0, output_buffer->size(), MemoryState::Private); target_address, output_buffer->data(), output_buffer->size(), MemoryState::Private);
REQUIRE(result.Code() == RESULT_SUCCESS); REQUIRE(result.Code() == RESULT_SUCCESS);
const u32_le input_cmdbuff[]{ const u32_le input_cmdbuff[]{

View file

@ -14,22 +14,22 @@ TEST_CASE("Memory Basics", "[kernel][memory]") {
SECTION("mapping memory") { SECTION("mapping memory") {
// Because of the PageTable, Kernel::VMManager is too big to be created on the stack. // Because of the PageTable, Kernel::VMManager is too big to be created on the stack.
auto manager = std::make_unique<Kernel::VMManager>(); auto manager = std::make_unique<Kernel::VMManager>();
auto result = manager->MapMemoryBlock(Memory::HEAP_VADDR, block, 0, block->size(), auto result = manager->MapBackingMemory(Memory::HEAP_VADDR, block->data(), block->size(),
Kernel::MemoryState::Private); Kernel::MemoryState::Private);
REQUIRE(result.Code() == RESULT_SUCCESS); REQUIRE(result.Code() == RESULT_SUCCESS);
auto vma = manager->FindVMA(Memory::HEAP_VADDR); auto vma = manager->FindVMA(Memory::HEAP_VADDR);
CHECK(vma != manager->vma_map.end()); CHECK(vma != manager->vma_map.end());
CHECK(vma->second.size == block->size()); CHECK(vma->second.size == block->size());
CHECK(vma->second.type == Kernel::VMAType::AllocatedMemoryBlock); CHECK(vma->second.type == Kernel::VMAType::BackingMemory);
CHECK(vma->second.backing_block == block); CHECK(vma->second.backing_memory == block->data());
CHECK(vma->second.meminfo_state == Kernel::MemoryState::Private); CHECK(vma->second.meminfo_state == Kernel::MemoryState::Private);
} }
SECTION("unmapping memory") { SECTION("unmapping memory") {
// Because of the PageTable, Kernel::VMManager is too big to be created on the stack. // Because of the PageTable, Kernel::VMManager is too big to be created on the stack.
auto manager = std::make_unique<Kernel::VMManager>(); auto manager = std::make_unique<Kernel::VMManager>();
auto result = manager->MapMemoryBlock(Memory::HEAP_VADDR, block, 0, block->size(), auto result = manager->MapBackingMemory(Memory::HEAP_VADDR, block->data(), block->size(),
Kernel::MemoryState::Private); Kernel::MemoryState::Private);
REQUIRE(result.Code() == RESULT_SUCCESS); REQUIRE(result.Code() == RESULT_SUCCESS);
@ -45,7 +45,7 @@ TEST_CASE("Memory Basics", "[kernel][memory]") {
SECTION("changing memory permissions") { SECTION("changing memory permissions") {
// Because of the PageTable, Kernel::VMManager is too big to be created on the stack. // Because of the PageTable, Kernel::VMManager is too big to be created on the stack.
auto manager = std::make_unique<Kernel::VMManager>(); auto manager = std::make_unique<Kernel::VMManager>();
auto result = manager->MapMemoryBlock(Memory::HEAP_VADDR, block, 0, block->size(), auto result = manager->MapBackingMemory(Memory::HEAP_VADDR, block->data(), block->size(),
Kernel::MemoryState::Private); Kernel::MemoryState::Private);
REQUIRE(result.Code() == RESULT_SUCCESS); REQUIRE(result.Code() == RESULT_SUCCESS);
@ -64,7 +64,7 @@ TEST_CASE("Memory Basics", "[kernel][memory]") {
SECTION("changing memory state") { SECTION("changing memory state") {
// Because of the PageTable, Kernel::VMManager is too big to be created on the stack. // Because of the PageTable, Kernel::VMManager is too big to be created on the stack.
auto manager = std::make_unique<Kernel::VMManager>(); auto manager = std::make_unique<Kernel::VMManager>();
auto result = manager->MapMemoryBlock(Memory::HEAP_VADDR, block, 0, block->size(), auto result = manager->MapBackingMemory(Memory::HEAP_VADDR, block->data(), block->size(),
Kernel::MemoryState::Private); Kernel::MemoryState::Private);
REQUIRE(result.Code() == RESULT_SUCCESS); REQUIRE(result.Code() == RESULT_SUCCESS);