[Base] Specify heap type on initialization

This commit is contained in:
Gliniak
2020-09-16 20:09:32 +02:00
committed by Rick Gibbed
parent 2cb7d26d62
commit c071500ff4
2 changed files with 48 additions and 32 deletions

View File

@@ -36,6 +36,13 @@ enum SystemHeapFlag : uint32_t {
kSystemHeapDefault = kSystemHeapVirtual,
};
enum class HeapType : uint8_t {
kGuestVirtual,
kGuestXex,
kGuestPhysical,
kHostPhysical,
};
enum MemoryAllocationFlag : uint32_t {
kMemoryAllocationReserve = 1 << 0,
kMemoryAllocationCommit = 1 << 1,
@@ -106,6 +113,9 @@ class BaseHeap {
// Size of each page within the heap range in bytes.
uint32_t page_size() const { return page_size_; }
// Type of specified heap
HeapType heap_type() const { return heap_type_; }
// Offset added to the virtual addresses to convert them to host addresses
// (not including membase).
uint32_t host_address_offset() const { return host_address_offset_; }
@@ -188,12 +198,13 @@ class BaseHeap {
protected:
BaseHeap();
void Initialize(Memory* memory, uint8_t* membase, uint32_t heap_base,
uint32_t heap_size, uint32_t page_size,
void Initialize(Memory* memory, uint8_t* membase, HeapType heap_type,
uint32_t heap_base, uint32_t heap_size, uint32_t page_size,
uint32_t host_address_offset = 0);
Memory* memory_;
uint8_t* membase_;
HeapType heap_type_;
uint32_t heap_base_;
uint32_t heap_size_;
uint32_t page_size_;
@@ -209,8 +220,8 @@ class VirtualHeap : public BaseHeap {
~VirtualHeap() override;
// Initializes the heap properties and allocates the page table.
void Initialize(Memory* memory, uint8_t* membase, uint32_t heap_base,
uint32_t heap_size, uint32_t page_size);
void Initialize(Memory* memory, uint8_t* membase, HeapType heap_type,
uint32_t heap_base, uint32_t heap_size, uint32_t page_size);
};
// A heap for ranges of memory that are mapped to physical ranges.
@@ -226,8 +237,8 @@ class PhysicalHeap : public BaseHeap {
~PhysicalHeap() override;
// Initializes the heap properties and allocates the page table.
void Initialize(Memory* memory, uint8_t* membase, uint32_t heap_base,
uint32_t heap_size, uint32_t page_size,
void Initialize(Memory* memory, uint8_t* membase, HeapType heap_type,
uint32_t heap_base, uint32_t heap_size, uint32_t page_size,
VirtualHeap* parent_heap);
bool Alloc(uint32_t size, uint32_t alignment, uint32_t allocation_type,