20#ifndef KERNEL_PROCESSOR_X86_COMMON_PHYSICALMEMORYMANAGER_H
21#define KERNEL_PROCESSOR_X86_COMMON_PHYSICALMEMORYMANAGER_H
22#include "pedigree/kernel/Atomic.h"
23#include "pedigree/kernel/Spinlock.h"
24#include "pedigree/kernel/compiler.h"
25#include "pedigree/kernel/processor/PhysicalMemoryManager.h"
26#include "pedigree/kernel/processor/types.h"
27#include "pedigree/kernel/utilities/HashTable.h"
28#include "pedigree/kernel/utilities/RangeList.h"
29#include "pedigree/kernel/utilities/utility.h"
39extern size_t g_AllocedPages;
62 virtual physical_uintptr_t
allocatePage(
size_t pageConstraints = 0)
override;
63 physical_uintptr_t tryAllocatePage()
override;
64 bool copyPhysicalPageToBuffer(physical_uintptr_t page,
void* buffer)
override;
65 bool copyPhysicalPageFromBuffer(physical_uintptr_t page,
const void* buffer)
override;
66 MemorySnapshot memorySnapshot()
const override;
67 virtual void freePage(physical_uintptr_t page)
override;
69 size_t Flags, physical_uintptr_t start = -1)
override;
71 virtual void pin(physical_uintptr_t page)
override;
131 physical_uintptr_t allocate(
size_t constraints,
bool waitForReady =
true);
134 void free(uint64_t
physicalAddress,
size_t length,
bool newMemory =
false);
138 inline size_t freePages()
const {
142 size_t totalPages()
const {
148 void markAbove4GReady();
151 void markBelow4GReady();
178 static const size_t StackCount = 3;
182 void* m_Stack[StackCount];
184 size_t m_StackMax[StackCount];
186 size_t m_StackSize[StackCount];
191 size_t m_DesiredCapacity[StackCount];
234 size_t hash()
const {
239 return p.m_Page == m_Page;
244 physical_uintptr_t m_Page;
249 page() : active(
false), refcount(0) {}
266 physical_uintptr_t m_BootstrapPinnedPage;
267 size_t m_BootstrapPinnedPageRefcount;
Implementation of the PhysicalMemoryManager for common x86.
Special memory entity in the kernel's virtual address space.
static constexpr size_t getPageSize() PURE
The Stack of pages (below4GB, below64GB, no constraint).
PageStack & operator=(const PageStack &)
PageStack(const PageStack &)
Implementation of the PhysicalMemoryManager for common x86.
static X86CommonPhysicalMemoryManager & instance()
RangeList< uint32_t > m_RangeBelow1MB
void initialise64(const BootstrapStruct_t &Info) INITIALISATION_ONLY
static X86CommonPhysicalMemoryManager m_Instance
RangeList< uintptr_t > m_MemoryRegions
RangeList< uint64_t > m_PhysicalRanges
void initialise(const BootstrapStruct_t &Info) INITIALISATION_ONLY
X86CommonPhysicalMemoryManager() INITIALISATION_ONLY
void initialisationDone()
virtual size_t freePageCount() const override
RangeList< uint64_t > m_AcpiRanges
virtual void freePageUnlocked(physical_uintptr_t page) override
void unmapRegion(MemoryRegion *pRegion) override
virtual void pin(physical_uintptr_t page) override
virtual void freePage(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
HashTable< PageHashable, struct page > m_PageMetadata
RangeList< uint32_t > m_RangeBelow16MB
virtual physical_uintptr_t allocatePage(size_t pageConstraints=0) override
#define INITIALISATION_ONLY
uintptr_t physicalAddress(physical_uintptr_t address) PURE