Browse Source
core/memory: Get rid of 3DS leftovers
core/memory: Get rid of 3DS leftovers
Removes leftover code from citra that isn't needed.pull/15/merge
16 changed files with 29 additions and 559 deletions
-
2src/core/CMakeLists.txt
-
6src/core/core.cpp
-
3src/core/core.h
-
6src/core/hle/kernel/kernel.cpp
-
2src/core/hle/kernel/kernel.h
-
90src/core/hle/kernel/memory.cpp
-
34src/core/hle/kernel/memory.h
-
76src/core/hle/kernel/process.cpp
-
17src/core/hle/kernel/process.h
-
39src/core/hle/kernel/shared_memory.cpp
-
3src/core/hle/kernel/shared_memory.h
-
33src/core/hle/kernel/thread.cpp
-
106src/core/memory.cpp
-
88src/core/memory.h
-
1src/tests/CMakeLists.txt
-
56src/tests/core/memory/memory.cpp
@ -1,90 +0,0 @@ |
|||
// Copyright 2014 Citra Emulator Project
|
|||
// Licensed under GPLv2 or any later version
|
|||
// Refer to the license.txt file included.
|
|||
|
|||
#include <algorithm>
|
|||
#include <cinttypes>
|
|||
#include <memory>
|
|||
#include <utility>
|
|||
#include <vector>
|
|||
#include "common/assert.h"
|
|||
#include "common/common_types.h"
|
|||
#include "common/logging/log.h"
|
|||
#include "core/hle/kernel/memory.h"
|
|||
#include "core/hle/kernel/process.h"
|
|||
#include "core/hle/kernel/vm_manager.h"
|
|||
#include "core/memory.h"
|
|||
|
|||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|||
|
|||
namespace Kernel { |
|||
|
|||
MemoryRegionInfo memory_regions[3]; |
|||
|
|||
/// Size of the APPLICATION, SYSTEM and BASE memory regions (respectively) for each system
|
|||
/// memory configuration type.
|
|||
static const u32 memory_region_sizes[8][3] = { |
|||
// Old 3DS layouts
|
|||
{0x04000000, 0x02C00000, 0x01400000}, // 0
|
|||
{/* This appears to be unused. */}, // 1
|
|||
{0x06000000, 0x00C00000, 0x01400000}, // 2
|
|||
{0x05000000, 0x01C00000, 0x01400000}, // 3
|
|||
{0x04800000, 0x02400000, 0x01400000}, // 4
|
|||
{0x02000000, 0x04C00000, 0x01400000}, // 5
|
|||
|
|||
// New 3DS layouts
|
|||
{0x07C00000, 0x06400000, 0x02000000}, // 6
|
|||
{0x0B200000, 0x02E00000, 0x02000000}, // 7
|
|||
}; |
|||
|
|||
void MemoryInit(u32 mem_type) { |
|||
// TODO(yuriks): On the n3DS, all o3DS configurations (<=5) are forced to 6 instead.
|
|||
ASSERT_MSG(mem_type <= 5, "New 3DS memory configuration aren't supported yet!"); |
|||
ASSERT(mem_type != 1); |
|||
|
|||
// The kernel allocation regions (APPLICATION, SYSTEM and BASE) are laid out in sequence, with
|
|||
// the sizes specified in the memory_region_sizes table.
|
|||
VAddr base = 0; |
|||
for (int i = 0; i < 3; ++i) { |
|||
memory_regions[i].base = base; |
|||
memory_regions[i].size = memory_region_sizes[mem_type][i]; |
|||
memory_regions[i].used = 0; |
|||
memory_regions[i].linear_heap_memory = std::make_shared<std::vector<u8>>(); |
|||
// Reserve enough space for this region of FCRAM.
|
|||
// We do not want this block of memory to be relocated when allocating from it.
|
|||
memory_regions[i].linear_heap_memory->reserve(memory_regions[i].size); |
|||
|
|||
base += memory_regions[i].size; |
|||
} |
|||
|
|||
// We must've allocated the entire FCRAM by the end
|
|||
ASSERT(base == Memory::FCRAM_SIZE); |
|||
} |
|||
|
|||
void MemoryShutdown() { |
|||
for (auto& region : memory_regions) { |
|||
region.base = 0; |
|||
region.size = 0; |
|||
region.used = 0; |
|||
region.linear_heap_memory = nullptr; |
|||
} |
|||
} |
|||
|
|||
MemoryRegionInfo* GetMemoryRegion(MemoryRegion region) { |
|||
switch (region) { |
|||
case MemoryRegion::APPLICATION: |
|||
return &memory_regions[0]; |
|||
case MemoryRegion::SYSTEM: |
|||
return &memory_regions[1]; |
|||
case MemoryRegion::BASE: |
|||
return &memory_regions[2]; |
|||
default: |
|||
UNREACHABLE(); |
|||
} |
|||
} |
|||
|
|||
void HandleSpecialMapping(VMManager& address_space, const AddressMapping& mapping) {} |
|||
|
|||
void MapSharedPages(VMManager& address_space) {} |
|||
|
|||
} // namespace Kernel
|
|||
@ -1,34 +0,0 @@ |
|||
// Copyright 2014 Citra Emulator Project |
|||
// Licensed under GPLv2 or any later version |
|||
// Refer to the license.txt file included. |
|||
|
|||
#pragma once |
|||
|
|||
#include <memory> |
|||
#include <vector> |
|||
|
|||
#include "common/common_types.h" |
|||
|
|||
namespace Kernel { |
|||
|
|||
class VMManager; |
|||
enum class MemoryRegion : u16; |
|||
struct AddressMapping; |
|||
|
|||
struct MemoryRegionInfo { |
|||
u64 base; // Not an address, but offset from start of FCRAM |
|||
u64 size; |
|||
u64 used; |
|||
|
|||
std::shared_ptr<std::vector<u8>> linear_heap_memory; |
|||
}; |
|||
|
|||
void MemoryInit(u32 mem_type); |
|||
void MemoryShutdown(); |
|||
MemoryRegionInfo* GetMemoryRegion(MemoryRegion region); |
|||
|
|||
void HandleSpecialMapping(VMManager& address_space, const AddressMapping& mapping); |
|||
void MapSharedPages(VMManager& address_space); |
|||
|
|||
extern MemoryRegionInfo memory_regions[3]; |
|||
} // namespace Kernel |
|||
@ -1,56 +0,0 @@ |
|||
// Copyright 2017 Citra Emulator Project
|
|||
// Licensed under GPLv2 or any later version
|
|||
// Refer to the license.txt file included.
|
|||
|
|||
#include <catch.hpp>
|
|||
#include "core/hle/kernel/memory.h"
|
|||
#include "core/hle/kernel/process.h"
|
|||
#include "core/memory.h"
|
|||
|
|||
TEST_CASE("Memory::IsValidVirtualAddress", "[core][memory][!hide]") { |
|||
SECTION("these regions should not be mapped on an empty process") { |
|||
auto process = Kernel::Process::Create(""); |
|||
CHECK(Memory::IsValidVirtualAddress(*process, Memory::PROCESS_IMAGE_VADDR) == false); |
|||
CHECK(Memory::IsValidVirtualAddress(*process, Memory::HEAP_VADDR) == false); |
|||
CHECK(Memory::IsValidVirtualAddress(*process, Memory::LINEAR_HEAP_VADDR) == false); |
|||
CHECK(Memory::IsValidVirtualAddress(*process, Memory::VRAM_VADDR) == false); |
|||
CHECK(Memory::IsValidVirtualAddress(*process, Memory::CONFIG_MEMORY_VADDR) == false); |
|||
CHECK(Memory::IsValidVirtualAddress(*process, Memory::SHARED_PAGE_VADDR) == false); |
|||
CHECK(Memory::IsValidVirtualAddress(*process, Memory::TLS_AREA_VADDR) == false); |
|||
} |
|||
|
|||
SECTION("CONFIG_MEMORY_VADDR and SHARED_PAGE_VADDR should be valid after mapping them") { |
|||
auto process = Kernel::Process::Create(""); |
|||
Kernel::MapSharedPages(process->vm_manager); |
|||
CHECK(Memory::IsValidVirtualAddress(*process, Memory::CONFIG_MEMORY_VADDR) == true); |
|||
CHECK(Memory::IsValidVirtualAddress(*process, Memory::SHARED_PAGE_VADDR) == true); |
|||
} |
|||
|
|||
SECTION("special regions should be valid after mapping them") { |
|||
auto process = Kernel::Process::Create(""); |
|||
SECTION("VRAM") { |
|||
Kernel::HandleSpecialMapping(process->vm_manager, |
|||
{Memory::VRAM_VADDR, Memory::VRAM_SIZE, false, false}); |
|||
CHECK(Memory::IsValidVirtualAddress(*process, Memory::VRAM_VADDR) == true); |
|||
} |
|||
|
|||
SECTION("IO (Not yet implemented)") { |
|||
Kernel::HandleSpecialMapping( |
|||
process->vm_manager, {Memory::IO_AREA_VADDR, Memory::IO_AREA_SIZE, false, false}); |
|||
CHECK_FALSE(Memory::IsValidVirtualAddress(*process, Memory::IO_AREA_VADDR) == true); |
|||
} |
|||
|
|||
SECTION("DSP") { |
|||
Kernel::HandleSpecialMapping( |
|||
process->vm_manager, {Memory::DSP_RAM_VADDR, Memory::DSP_RAM_SIZE, false, false}); |
|||
CHECK(Memory::IsValidVirtualAddress(*process, Memory::DSP_RAM_VADDR) == true); |
|||
} |
|||
} |
|||
|
|||
SECTION("Unmapping a VAddr should make it invalid") { |
|||
auto process = Kernel::Process::Create(""); |
|||
Kernel::MapSharedPages(process->vm_manager); |
|||
process->vm_manager.UnmapRange(Memory::CONFIG_MEMORY_VADDR, Memory::CONFIG_MEMORY_SIZE); |
|||
CHECK(Memory::IsValidVirtualAddress(*process, Memory::CONFIG_MEMORY_VADDR) == false); |
|||
} |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue