From ce64a9fab9e6f015a4d2b332abcb7043914549d4 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Sun, 7 Jul 2019 12:55:30 -0700 Subject: physmem: add helpers, cleanup logic. --- src/core/hle/kernel/vm_manager.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/core/hle/kernel/vm_manager.h') diff --git a/src/core/hle/kernel/vm_manager.h b/src/core/hle/kernel/vm_manager.h index 8be03a6e4..5b27548aa 100644 --- a/src/core/hle/kernel/vm_manager.h +++ b/src/core/hle/kernel/vm_manager.h @@ -303,6 +303,15 @@ struct VirtualMemoryArea { PAddr paddr = 0; Common::MemoryHookPointer mmio_handler = nullptr; + /// If the address lies within this VMA, returns the size left before the + /// end of this VMA. If the given address doesn't lie within the VMA, then + /// an empty optional value is returned. + /// + /// For example, given a VMA 100 bytes long. If '10' was given as the + /// start address, then this would return 90. + /// + std::optional SizeRemainingFromAddress(VAddr address) const; + /// Tests if this area can be merged to the right with `next`. bool CanBeMergedWith(const VirtualMemoryArea& next) const; }; @@ -735,6 +744,13 @@ private: MemoryAttribute attribute_mask, MemoryAttribute attribute, MemoryAttribute ignore_mask) const; + /// Gets the amount of memory currently mapped (state != Unmapped) in a range. + ResultVal SizeOfAllocatedVMAsInRange(VAddr address, std::size_t size) const; + + /// Gets the amount of memory unmappable by UnmapPhysicalMemory in a range. + ResultVal SizeOfUnmappablePhysicalMemoryInRange(VAddr address, + std::size_t size) const; + /** * A map covering the entirety of the managed address space, keyed by the `base` field of each * VMA. It must always be modified by splitting or merging VMAs, so that the invariant -- cgit v1.2.3