20#ifndef KERNEL_PROCESSOR_HOSTED_PHYSICALMEMORYMANAGER_H
21#define KERNEL_PROCESSOR_HOSTED_PHYSICALMEMORYMANAGER_H
22#include "pedigree/kernel/BootstrapInfo.h"
23#include "pedigree/kernel/Spinlock.h"
24#include "pedigree/kernel/compiler.h"
25#include "pedigree/kernel/processor/PhysicalMemoryManager.h"
26#include "pedigree/kernel/utilities/HashTable.h"
27#include "pedigree/kernel/utilities/RangeList.h"
31#include "../x86_common/PhysicalMemoryManager.h"
36#define HOSTED_PHYSICAL_MEMORY_SIZE (1UL << 31)
55 virtual physical_uintptr_t
allocatePage(
size_t pageConstraints = 0)
override;
56 physical_uintptr_t tryAllocatePage()
override;
57 bool copyPhysicalPageToBuffer(physical_uintptr_t
page,
void* buffer)
override;
58 bool copyPhysicalPageFromBuffer(physical_uintptr_t
page,
const void* buffer)
override;
62 size_t Flags, physical_uintptr_t start = -1)
override;
64 virtual void pin(physical_uintptr_t
page)
override;
91 inline
int getBackingFile()
const {
95#if PEDIGREE_HOSTED_SMOKE_TESTS
96 size_t pageReferenceCountForTestImpl(physical_uintptr_t page);
135 size_t hash()
const {
140 return p.m_Page == m_Page;
145 physical_uintptr_t m_Page;
150 page() : active(
false), refcount(0) {}
Implementation of the PhysicalMemoryManager for common x86.
RangeList< uint64_t > m_PhysicalRanges
virtual physical_uintptr_t allocatePage(size_t pageConstraints=0) override
RangeList< uintptr_t > m_MemoryRegions
HashTable< PageHashable, struct page > m_PageMetadata
virtual void freePage(physical_uintptr_t page) override
void unmapRegion(MemoryRegion *pRegion) override
HostedPhysicalMemoryManager() INITIALISATION_ONLY
void initialisationDone()
static HostedPhysicalMemoryManager * m_Instance
static HostedPhysicalMemoryManager & instance()
virtual void pin(physical_uintptr_t page) override
virtual bool allocateRegion(MemoryRegion &Region, size_t cPages, size_t pageConstraints, size_t Flags, physical_uintptr_t start=-1) override
void initialise(const BootstrapStruct_t &Info) INITIALISATION_ONLY
virtual void freePageUnlocked(physical_uintptr_t page) override
Special memory entity in the kernel's virtual address space.
static constexpr size_t getPageSize() PURE
The Stack of pages (below4GB, below64GB, no constraint).
#define INITIALISATION_ONLY