diff options
| author | 2018-09-24 10:29:56 -0400 | |
|---|---|---|
| committer | 2018-09-24 22:15:53 -0400 | |
| commit | 7fd598636e819d4e86874b20081945936a05c5f1 (patch) | |
| tree | 046da702e80db7f8f5d75521b7864a1b7eb822a3 /src/core/hle/kernel | |
| parent | process/vm_manager: Amend API to allow reading parameters from NPDM metadata (diff) | |
| download | yuzu-7fd598636e819d4e86874b20081945936a05c5f1.tar.gz yuzu-7fd598636e819d4e86874b20081945936a05c5f1.tar.xz yuzu-7fd598636e819d4e86874b20081945936a05c5f1.zip | |
memory: Dehardcode the use of a 36-bit address space
Given games can also request a 32-bit or 39-bit address space, we
shouldn't be hardcoding the address space range as 36-bit.
Diffstat (limited to 'src/core/hle/kernel')
| -rw-r--r-- | src/core/hle/kernel/vm_manager.cpp | 18 | ||||
| -rw-r--r-- | src/core/hle/kernel/vm_manager.h | 3 |
2 files changed, 16 insertions, 5 deletions
diff --git a/src/core/hle/kernel/vm_manager.cpp b/src/core/hle/kernel/vm_manager.cpp index 337f17b7b..20d06f000 100644 --- a/src/core/hle/kernel/vm_manager.cpp +++ b/src/core/hle/kernel/vm_manager.cpp | |||
| @@ -66,18 +66,21 @@ VMManager::~VMManager() { | |||
| 66 | 66 | ||
| 67 | void VMManager::Reset(FileSys::ProgramAddressSpaceType type) { | 67 | void VMManager::Reset(FileSys::ProgramAddressSpaceType type) { |
| 68 | Clear(); | 68 | Clear(); |
| 69 | |||
| 69 | InitializeMemoryRegionRanges(type); | 70 | InitializeMemoryRegionRanges(type); |
| 70 | 71 | ||
| 72 | page_table.Resize(address_space_width); | ||
| 73 | |||
| 71 | // Initialize the map with a single free region covering the entire managed space. | 74 | // Initialize the map with a single free region covering the entire managed space. |
| 72 | VirtualMemoryArea initial_vma; | 75 | VirtualMemoryArea initial_vma; |
| 73 | initial_vma.size = MAX_ADDRESS; | 76 | initial_vma.size = address_space_end; |
| 74 | vma_map.emplace(initial_vma.base, initial_vma); | 77 | vma_map.emplace(initial_vma.base, initial_vma); |
| 75 | 78 | ||
| 76 | UpdatePageTableForVMA(initial_vma); | 79 | UpdatePageTableForVMA(initial_vma); |
| 77 | } | 80 | } |
| 78 | 81 | ||
| 79 | VMManager::VMAHandle VMManager::FindVMA(VAddr target) const { | 82 | VMManager::VMAHandle VMManager::FindVMA(VAddr target) const { |
| 80 | if (target >= MAX_ADDRESS) { | 83 | if (target >= address_space_end) { |
| 81 | return vma_map.end(); | 84 | return vma_map.end(); |
| 82 | } else { | 85 | } else { |
| 83 | return std::prev(vma_map.upper_bound(target)); | 86 | return std::prev(vma_map.upper_bound(target)); |
| @@ -291,7 +294,7 @@ ResultVal<VMManager::VMAIter> VMManager::CarveVMARange(VAddr target, u64 size) { | |||
| 291 | 294 | ||
| 292 | const VAddr target_end = target + size; | 295 | const VAddr target_end = target + size; |
| 293 | ASSERT(target_end >= target); | 296 | ASSERT(target_end >= target); |
| 294 | ASSERT(target_end <= MAX_ADDRESS); | 297 | ASSERT(target_end <= address_space_end); |
| 295 | ASSERT(size > 0); | 298 | ASSERT(size > 0); |
| 296 | 299 | ||
| 297 | VMAIter begin_vma = StripIterConstness(FindVMA(target)); | 300 | VMAIter begin_vma = StripIterConstness(FindVMA(target)); |
| @@ -455,9 +458,10 @@ void VMManager::ClearVMAMap() { | |||
| 455 | } | 458 | } |
| 456 | 459 | ||
| 457 | void VMManager::ClearPageTable() { | 460 | void VMManager::ClearPageTable() { |
| 458 | page_table.pointers.fill(nullptr); | 461 | std::fill(page_table.pointers.begin(), page_table.pointers.end(), nullptr); |
| 459 | page_table.special_regions.clear(); | 462 | page_table.special_regions.clear(); |
| 460 | page_table.attributes.fill(Memory::PageType::Unmapped); | 463 | std::fill(page_table.attributes.begin(), page_table.attributes.end(), |
| 464 | Memory::PageType::Unmapped); | ||
| 461 | } | 465 | } |
| 462 | 466 | ||
| 463 | u64 VMManager::GetTotalMemoryUsage() const { | 467 | u64 VMManager::GetTotalMemoryUsage() const { |
| @@ -480,6 +484,10 @@ u64 VMManager::GetAddressSpaceSize() const { | |||
| 480 | return MAX_ADDRESS; | 484 | return MAX_ADDRESS; |
| 481 | } | 485 | } |
| 482 | 486 | ||
| 487 | u64 VMManager::GetAddressSpaceWidth() const { | ||
| 488 | return address_space_width; | ||
| 489 | } | ||
| 490 | |||
| 483 | VAddr VMManager::GetCodeRegionBaseAddress() const { | 491 | VAddr VMManager::GetCodeRegionBaseAddress() const { |
| 484 | return code_region_base; | 492 | return code_region_base; |
| 485 | } | 493 | } |
diff --git a/src/core/hle/kernel/vm_manager.h b/src/core/hle/kernel/vm_manager.h index 0ce240126..581bf3d00 100644 --- a/src/core/hle/kernel/vm_manager.h +++ b/src/core/hle/kernel/vm_manager.h | |||
| @@ -205,6 +205,9 @@ public: | |||
| 205 | /// Gets the total address space address size, used by svcGetInfo | 205 | /// Gets the total address space address size, used by svcGetInfo |
| 206 | u64 GetAddressSpaceSize() const; | 206 | u64 GetAddressSpaceSize() const; |
| 207 | 207 | ||
| 208 | /// Gets the address space width in bits. | ||
| 209 | u64 GetAddressSpaceWidth() const; | ||
| 210 | |||
| 208 | /// Gets the base address of the code region. | 211 | /// Gets the base address of the code region. |
| 209 | VAddr GetCodeRegionBaseAddress() const; | 212 | VAddr GetCodeRegionBaseAddress() const; |
| 210 | 213 | ||