|
ReXGlue SDK
|
Public Member Functions | |
| virtual | ~BaseHeap () |
| u32 | GetHeapBase () const |
| u32 | GetHeapSize () const |
| u32 | GetPageSize () const |
| HeapType | GetHeapType () const |
| u32 | GetHostAddressOffset () const |
| template<typename T = u8*> | |
| T | TranslateRelative (size_t relative_address) const |
| virtual void | Dispose () |
| u32 | GetTotalPageCount () const |
| u32 | GetUnreservedPageCount () const |
| u32 | GetReservedPageCount () const |
| u32 | GetCommittedPages () const |
| void | PlotProfile () const |
| virtual bool | Alloc (u32 size, u32 alignment, u32 allocation_type, u32 protect, bool top_down, u32 *out_address) |
| virtual bool | AllocFixed (u32 base_address, u32 size, u32 alignment, u32 allocation_type, u32 protect) |
| virtual bool | AllocRange (u32 low_address, u32 high_address, u32 size, u32 alignment, u32 allocation_type, u32 protect, bool top_down, u32 *out_address) |
| virtual bool | AllocSystemHeap (u32 size, u32 alignment, u32 allocation_type, u32 protect, bool top_down, u32 *out_address) |
| virtual bool | Decommit (u32 address, u32 size) |
| virtual bool | Release (u32 address, u32 *out_region_size=nullptr) |
| bool | ReleaseRange (u32 address, u32 size, u32 *out_address, u32 *out_size) |
| virtual bool | Protect (u32 address, u32 size, u32 protect, u32 *old_protect=nullptr) |
| bool | QueryRegionInfo (u32 base_address, HeapAllocation *out_info) |
| bool | QuerySize (u32 address, u32 *out_size) |
| bool | QueryProtect (u32 address, u32 *out_protect) |
| rex::memory::PageAccess | QueryRangeAccess (u32 low_address, u32 high_address) |
| rex::memory::PageAccess | GetHostPageAccess (u32 host_page_number) const |
| bool | ReapplyHostPageAccess (void *host_address, bool is_write) |
Protected Member Functions | |
| rex::memory::PageAccess | GetHostPageGuestAccess (u32 host_page_number) const |
| bool | SyncHostPageAccess (u32 start_page_number, u32 end_page_number) |
| virtual std::unique_lock< rex::platform::RankedMutex > | AcquireHostPageReconcileLock () const |
| u32 | GetSystemRangeBase () const |
| bool | AllocFixedLocked (u32 base_address, u32 size, u32 alignment, u32 allocation_type, u32 protect) |
| bool | AllocRangeLocked (u32 low_address, u32 high_address, u32 size, u32 alignment, u32 allocation_type, u32 protect, bool top_down, u32 *out_address) |
| bool | DecommitLocked (u32 address, u32 size) |
| bool | ReleaseLocked (u32 address, u32 *out_region_size) |
| bool | ReleaseRangeLocked (u32 address, u32 size, u32 *out_address, u32 *out_size) |
| bool | ProtectLocked (u32 address, u32 size, u32 protect, u32 *old_protect) |
| bool | CheckProtectRangeLocked (u32 address, u32 size, u32 *out_start_page, u32 *out_end_page) |
| virtual bool | IsHostPageWriteWatched (u32 host_page_number) const |
| void | OnPageCommitted (u32 page_number) |
| void | OnPageDecommitted (u32 page_number) |
| void | Initialize (kernel::GuestAddressSpace *memory, u8 *membase, HeapType heap_type, u32 heap_base, u32 heap_size, u32 page_size, u32 host_address_offset=0) |
Protected Attributes | |
| kernel::GuestAddressSpace * | memory_ |
| u8 * | membase_ |
| HeapType | heap_type_ |
| u32 | heap_base_ |
| u32 | heap_size_ |
| u32 | page_size_ |
| u32 | page_size_shift_ = 0 |
| u32 | host_address_offset_ |
| u32 | unreserved_page_count_ = 0 |
| std::atomic< u32 > | committed_pages_ {0} |
| const char * | profile_pool_ = nullptr |
| const char * | profile_plot_ = nullptr |
| std::recursive_mutex | heap_mutex_ |
| std::vector< PageEntry > | page_table_ |
Friends | |
| class | PhysicalHeap |
|
virtual |
Does not release committed pages, which Dispose does.
|
protectedvirtual |
Takes the memory watch lock for operations that reconcile host page access.
Reimplemented in rex::kernel::PhysicalHeap.
|
virtual |
Allocates pages anywhere in the heap. Fails when not enough contiguous pages are found.
| allocation_type | MemoryAllocationFlag bits. |
| protect | MemoryProtectFlag bits. |
| top_down | True to allocate from the top of the heap. |
| out_address | Receives the allocated guest address. |
Reimplemented in rex::kernel::PhysicalHeap.
|
virtual |
Allocates pages at an address. Fails when the pages are allocated.
| base_address | Guest address to allocate at. |
| allocation_type | MemoryAllocationFlag bits. |
| protect | MemoryProtectFlag bits. |
Reimplemented in rex::kernel::PhysicalHeap.
|
virtual |
Allocates pages within an address range. Fails when not enough contiguous pages are found.
| allocation_type | MemoryAllocationFlag bits. |
| protect | MemoryProtectFlag bits. |
| top_down | True to allocate from the top of the range. |
| out_address | Receives the allocated guest address. |
Reimplemented in rex::kernel::PhysicalHeap.
|
virtual |
Allocates from the system portion, the top of a virtual heap. A physical heap uses Alloc.
| allocation_type | MemoryAllocationFlag bits. |
| protect | MemoryProtectFlag bits. |
| top_down | True to allocate from the top of the heap. |
| out_address | Receives the allocated guest address. |
Reimplemented in rex::kernel::PhysicalHeap.
|
protected |
Checks that a range can be protected: it is not empty, lies inside the heap, stays in one region and is committed. The caller holds heap_mutex_.
| address | The first address of the range. |
| size | The size of the range in bytes. |
| out_start_page | The page number holding the first byte. |
| out_end_page | The page number holding the last byte. |
|
virtual |
Decommits pages in the given range. Partially overlapped pages are decommitted.
Reimplemented in rex::kernel::PhysicalHeap.
|
virtual |
Disposes and decommits all memory and clears the page table.
|
inline |
Returns the heap offset relative to membase, without the host_address_offset adjustment.
|
inline |
Returns the offset added to guest addresses to get host addresses, excluding membase.
| rex::memory::PageAccess rex::kernel::BaseHeap::GetHostPageAccess | ( | u32 | host_page_number | ) | const |
Returns the host access for a host page, the union of the committed title protection of its guest pages. A write watched page stays read only. The caller holds the heap mutex and, when guest pages are smaller than host pages, the memory watch lock.
| host_page_number | Host page number from the heap host base, with GetHostAddressOffset(). |
|
protected |
Returns the union of the committed guest protection of the guest pages in a host page, ignoring write watches. The caller holds the same locks as for GetHostPageAccess.
| host_page_number | Host page number from the heap host base, with GetHostAddressOffset(). |
|
protected |
Returns the first address of the range reserved for system allocations, the end of the heap for a heap without a reserved range. Title allocations end one byte below it.
|
protected |
Initializes the heap properties and allocates the page table.
| heap_base | The heap offset relative to membase. |
| host_address_offset | The offset added to guest addresses to give host addresses. |
|
inlineprotectedvirtual |
Reports whether a host page is write watched, so SyncHostPageAccess must not restore write access to it. Only PhysicalHeap tracks this.
Reimplemented in rex::kernel::PhysicalHeap.
|
protected |
Counts a page as committed and reports it to the profiler memory pool of the heap.
|
protected |
Counts a page as decommitted and reports it to the profiler memory pool of the heap.
| void rex::kernel::BaseHeap::PlotProfile | ( | ) | const |
Plots the committed bytes on the profiler graph. Does nothing for a heap that views another.
|
virtual |
Modifies the protection mode of pages within the given range.
| protect | MemoryProtectFlag bits. |
| old_protect | Receives the previous protection. |
Reimplemented in rex::kernel::PhysicalHeap.
| bool rex::kernel::BaseHeap::QueryProtect | ( | u32 | address, |
| u32 * | out_protect ) |
Returns the current protection mode of the region containing the given address.
| out_protect | Receives the MemoryProtectFlag bits. |
| rex::memory::PageAccess rex::kernel::BaseHeap::QueryRangeAccess | ( | u32 | low_address, |
| u32 | high_address ) |
Returns the strictest readability and writability for the range.
| bool rex::kernel::BaseHeap::QueryRegionInfo | ( | u32 | base_address, |
| HeapAllocation * | out_info ) |
Returns information about the given region of pages.
| out_info | Receives the region information. |
| bool rex::kernel::BaseHeap::QuerySize | ( | u32 | address, |
| u32 * | out_size ) |
Returns the size of the region containing the given address.
| out_size | Receives the size in bytes. |
| bool rex::kernel::BaseHeap::ReapplyHostPageAccess | ( | void * | host_address, |
| bool | is_write ) |
Reapplies the host access the heap grants to a faulting host page, under the heap mutex. The caller holds the memory watch lock.
| is_write | True for a write, false for a read. |
|
virtual |
Decommits and releases pages in the given range. Partially overlapped pages are released.
| out_region_size | Receives the size of the released region. |
Reimplemented in rex::kernel::PhysicalHeap.
| bool rex::kernel::BaseHeap::ReleaseRange | ( | u32 | address, |
| u32 | size, | ||
| u32 * | out_address, | ||
| u32 * | out_size ) |
Releases the pages of a range inside one region, trimming or splitting it. Partially overlapped pages are released. Only for a heap whose regions need no parent heap.
| size | Size of the range in bytes, not 0. |
| out_address | Receives the guest address of the first released page. |
| out_size | Receives the size of the released pages in bytes. |
|
protected |
Reconciles host page access with guest page protection. The caller holds the memory watch lock when guest pages are smaller than host pages.
| start_page_number | First guest page of the range. |
| end_page_number | Last guest page of the range. |
|
inline |
Translates an offset from the heap base to a host pointer.
|
protected |
Number of committed pages, changed with the heap mutex held.
|
protected |
Guards the page table and the counters of the heap.
|
protected |
Offset added to guest addresses to give host addresses, given to Initialize.
|
protected |
Guest address space that owns the heap, source of the host page size.
|
protected |
Base 2 logarithm of page_size_, shifts a heap offset into a page number.
|
protected |
Profiler memory pool of the heap, null for a heap that views the memory of another heap.