fixup! core: hle: kernel: KPageTable: Improve Un/MapPhysicalMemory.
This commit is contained in:
parent
1a16d055df
commit
92b2e92620
@ -10,12 +10,12 @@ PageTable::PageTable() = default;
|
|||||||
|
|
||||||
PageTable::~PageTable() noexcept = default;
|
PageTable::~PageTable() noexcept = default;
|
||||||
|
|
||||||
bool PageTable::BeginTraversal(TraversalEntry* out_entry, TraversalContext* out_context,
|
bool PageTable::BeginTraversal(TraversalEntry& out_entry, TraversalContext& out_context,
|
||||||
u64 address) const {
|
u64 address) const {
|
||||||
// Setup invalid defaults.
|
// Setup invalid defaults.
|
||||||
out_entry->phys_addr = 0;
|
out_entry.phys_addr = 0;
|
||||||
out_entry->block_size = page_size;
|
out_entry.block_size = page_size;
|
||||||
out_context->next_page = 0;
|
out_context.next_page = 0;
|
||||||
|
|
||||||
// Validate that we can read the actual entry.
|
// Validate that we can read the actual entry.
|
||||||
const auto page = address / page_size;
|
const auto page = address / page_size;
|
||||||
@ -30,20 +30,20 @@ bool PageTable::BeginTraversal(TraversalEntry* out_entry, TraversalContext* out_
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Populate the results.
|
// Populate the results.
|
||||||
out_entry->phys_addr = phys_addr + address;
|
out_entry.phys_addr = phys_addr + address;
|
||||||
out_context->next_page = page + 1;
|
out_context.next_page = page + 1;
|
||||||
out_context->next_offset = address + page_size;
|
out_context.next_offset = address + page_size;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PageTable::ContinueTraversal(TraversalEntry* out_entry, TraversalContext* context) const {
|
bool PageTable::ContinueTraversal(TraversalEntry& out_entry, TraversalContext& context) const {
|
||||||
// Setup invalid defaults.
|
// Setup invalid defaults.
|
||||||
out_entry->phys_addr = 0;
|
out_entry.phys_addr = 0;
|
||||||
out_entry->block_size = page_size;
|
out_entry.block_size = page_size;
|
||||||
|
|
||||||
// Validate that we can read the actual entry.
|
// Validate that we can read the actual entry.
|
||||||
const auto page = context->next_page;
|
const auto page = context.next_page;
|
||||||
if (page >= backing_addr.size()) {
|
if (page >= backing_addr.size()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -55,9 +55,9 @@ bool PageTable::ContinueTraversal(TraversalEntry* out_entry, TraversalContext* c
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Populate the results.
|
// Populate the results.
|
||||||
out_entry->phys_addr = phys_addr + context->next_offset;
|
out_entry.phys_addr = phys_addr + context.next_offset;
|
||||||
context->next_page = page + 1;
|
context.next_page = page + 1;
|
||||||
context->next_offset += page_size;
|
context.next_offset += page_size;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -99,9 +99,9 @@ struct PageTable {
|
|||||||
PageTable(PageTable&&) noexcept = default;
|
PageTable(PageTable&&) noexcept = default;
|
||||||
PageTable& operator=(PageTable&&) noexcept = default;
|
PageTable& operator=(PageTable&&) noexcept = default;
|
||||||
|
|
||||||
bool BeginTraversal(TraversalEntry* out_entry, TraversalContext* out_context,
|
bool BeginTraversal(TraversalEntry& out_entry, TraversalContext& out_context,
|
||||||
u64 address) const;
|
u64 address) const;
|
||||||
bool ContinueTraversal(TraversalEntry* out_entry, TraversalContext* context) const;
|
bool ContinueTraversal(TraversalEntry& out_entry, TraversalContext& context) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resizes the page table to be able to accommodate enough pages within
|
* Resizes the page table to be able to accommodate enough pages within
|
||||||
|
@ -41,24 +41,6 @@ constexpr std::size_t GetAddressSpaceWidthFromType(FileSys::ProgramAddressSpaceT
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr u64 GetAddressInRange(const KMemoryInfo& info, VAddr addr) {
|
|
||||||
if (info.GetAddress() < addr) {
|
|
||||||
return addr;
|
|
||||||
}
|
|
||||||
return info.GetAddress();
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr std::size_t GetSizeInRange(const KMemoryInfo& info, VAddr start, VAddr end) {
|
|
||||||
std::size_t size{info.GetSize()};
|
|
||||||
if (info.GetAddress() < start) {
|
|
||||||
size -= start - info.GetAddress();
|
|
||||||
}
|
|
||||||
if (info.GetEndAddress() > end) {
|
|
||||||
size -= info.GetEndAddress() - end;
|
|
||||||
}
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
KPageTable::KPageTable(Core::System& system_)
|
KPageTable::KPageTable(Core::System& system_)
|
||||||
@ -724,8 +706,7 @@ ResultCode KPageTable::UnmapPhysicalMemory(VAddr address, std::size_t size) {
|
|||||||
size_t tot_size = 0;
|
size_t tot_size = 0;
|
||||||
|
|
||||||
cur_address = address;
|
cur_address = address;
|
||||||
next_valid =
|
next_valid = impl.BeginTraversal(next_entry, context, cur_address);
|
||||||
impl.BeginTraversal(std::addressof(next_entry), std::addressof(context), cur_address);
|
|
||||||
next_entry.block_size =
|
next_entry.block_size =
|
||||||
(next_entry.block_size - (next_entry.phys_addr & (next_entry.block_size - 1)));
|
(next_entry.block_size - (next_entry.phys_addr & (next_entry.block_size - 1)));
|
||||||
|
|
||||||
@ -751,8 +732,7 @@ ResultCode KPageTable::UnmapPhysicalMemory(VAddr address, std::size_t size) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
next_valid =
|
next_valid = impl.ContinueTraversal(next_entry, context);
|
||||||
impl.ContinueTraversal(std::addressof(next_entry), std::addressof(context));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the last block.
|
// Add the last block.
|
||||||
|
Loading…
Reference in New Issue
Block a user