citra-emu
/
citra-canary
Archived
1
0
Fork 0

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);
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<std::vector<u8>>(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<std::vector<u8>>(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[]{

View File

@ -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<Kernel::VMManager>();
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<Kernel::VMManager>();
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<Kernel::VMManager>();
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<Kernel::VMManager>();
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(),