diff options
| author | 2024-01-16 00:09:00 +0000 | |
|---|---|---|
| committer | 2024-01-16 00:09:00 +0000 | |
| commit | 90ab89a0b0174f8df559b79dc06a03479d959f93 (patch) | |
| tree | 3d11a790e44945e309f0e68f5332b33b42e72bbb /src/common/page_table.cpp | |
| parent | Fix typos in arrays.xml (diff) | |
| parent | Merge pull request #12681 from t895/stick-toggles (diff) | |
| download | yuzu-90ab89a0b0174f8df559b79dc06a03479d959f93.tar.gz yuzu-90ab89a0b0174f8df559b79dc06a03479d959f93.tar.xz yuzu-90ab89a0b0174f8df559b79dc06a03479d959f93.zip | |
Merge remote-tracking branch 'origin/master' into typos3
Diffstat (limited to 'src/common/page_table.cpp')
| -rw-r--r-- | src/common/page_table.cpp | 34 |
1 files changed, 10 insertions, 24 deletions
diff --git a/src/common/page_table.cpp b/src/common/page_table.cpp index 166dc3dce..85dc18c11 100644 --- a/src/common/page_table.cpp +++ b/src/common/page_table.cpp | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include "common/page_table.h" | 4 | #include "common/page_table.h" |
| 5 | #include "common/scope_exit.h" | ||
| 5 | 6 | ||
| 6 | namespace Common { | 7 | namespace Common { |
| 7 | 8 | ||
| @@ -11,29 +12,10 @@ PageTable::~PageTable() noexcept = default; | |||
| 11 | 12 | ||
| 12 | bool PageTable::BeginTraversal(TraversalEntry* out_entry, TraversalContext* out_context, | 13 | bool PageTable::BeginTraversal(TraversalEntry* out_entry, TraversalContext* out_context, |
| 13 | Common::ProcessAddress address) const { | 14 | Common::ProcessAddress address) const { |
| 14 | // Setup invalid defaults. | 15 | out_context->next_offset = GetInteger(address); |
| 15 | out_entry->phys_addr = 0; | 16 | out_context->next_page = address / page_size; |
| 16 | out_entry->block_size = page_size; | ||
| 17 | out_context->next_page = 0; | ||
| 18 | |||
| 19 | // Validate that we can read the actual entry. | ||
| 20 | const auto page = address / page_size; | ||
| 21 | if (page >= backing_addr.size()) { | ||
| 22 | return false; | ||
| 23 | } | ||
| 24 | |||
| 25 | // Validate that the entry is mapped. | ||
| 26 | const auto phys_addr = backing_addr[page]; | ||
| 27 | if (phys_addr == 0) { | ||
| 28 | return false; | ||
| 29 | } | ||
| 30 | 17 | ||
| 31 | // Populate the results. | 18 | return this->ContinueTraversal(out_entry, out_context); |
| 32 | out_entry->phys_addr = phys_addr + GetInteger(address); | ||
| 33 | out_context->next_page = page + 1; | ||
| 34 | out_context->next_offset = GetInteger(address) + page_size; | ||
| 35 | |||
| 36 | return true; | ||
| 37 | } | 19 | } |
| 38 | 20 | ||
| 39 | bool PageTable::ContinueTraversal(TraversalEntry* out_entry, TraversalContext* context) const { | 21 | bool PageTable::ContinueTraversal(TraversalEntry* out_entry, TraversalContext* context) const { |
| @@ -41,6 +23,12 @@ bool PageTable::ContinueTraversal(TraversalEntry* out_entry, TraversalContext* c | |||
| 41 | out_entry->phys_addr = 0; | 23 | out_entry->phys_addr = 0; |
| 42 | out_entry->block_size = page_size; | 24 | out_entry->block_size = page_size; |
| 43 | 25 | ||
| 26 | // Regardless of whether the page was mapped, advance on exit. | ||
| 27 | SCOPE_EXIT({ | ||
| 28 | context->next_page += 1; | ||
| 29 | context->next_offset += page_size; | ||
| 30 | }); | ||
| 31 | |||
| 44 | // Validate that we can read the actual entry. | 32 | // Validate that we can read the actual entry. |
| 45 | const auto page = context->next_page; | 33 | const auto page = context->next_page; |
| 46 | if (page >= backing_addr.size()) { | 34 | if (page >= backing_addr.size()) { |
| @@ -55,8 +43,6 @@ bool PageTable::ContinueTraversal(TraversalEntry* out_entry, TraversalContext* c | |||
| 55 | 43 | ||
| 56 | // Populate the results. | 44 | // Populate the results. |
| 57 | out_entry->phys_addr = phys_addr + context->next_offset; | 45 | out_entry->phys_addr = phys_addr + context->next_offset; |
| 58 | context->next_page = page + 1; | ||
| 59 | context->next_offset += page_size; | ||
| 60 | 46 | ||
| 61 | return true; | 47 | return true; |
| 62 | } | 48 | } |