22 pr_dinfo2(pmm,
"setting up physical memory manager...");
29 pfn_t phyframes_pfn = 0;
42 if (r->
nframes < phyframes_npages)
68 if (r == phyframes_region)
80 MOS_ASSERT_X(
phyframes[0].state == PHYFRAME_RESERVED,
"phyframe 0 isn't reserved, things have gone horribly wrong");
86 pr_info(
"Physical Memory Manager dump:");
101 for (
size_t i = 0; i < n_frames; i++)
111 pr_dinfo2(pmm,
"freeing " PFN_RANGE ", %zu pages", start, start + n_pages - 1, n_pages);
112 for (
pfn_t pfn = start; pfn < start + n_pages; pfn++)
125 pr_dinfo2(pmm,
"reserving " PFN_RANGE ", %zu pages", pfn_start, pfn_start + npages - 1, npages);
155 pr_dinfo2(pmm,
"ref range: " PFN_RANGE ", %zu pages", start, start + n_pages, n_pages);
157 for (
size_t i = start; i < start + n_pages; i++)
166 pr_dinfo2(pmm,
"unref range: " PFN_RANGE ", %zu pages", start, start + n_pages, n_pages);
168 for (
pfn_t pfn = start; pfn < start + n_pages; pfn++)
#define MOS_ASSERT_X(cond, msg,...)
#define MOS_ASSERT_ONCE(...)
#define mos_warn_once(...)
phyframe_t * buddy_alloc_n_exact(size_t nframes)
Allocate nframes of contiguous physical memory.
void buddy_dump_all()
Dump the state of the buddy allocator.
void buddy_free_n(pfn_t pfn, size_t nframes)
Free nframes of contiguous physical memory.
void buddy_init(size_t max_nframes)
Initialize the buddy allocator with the given maximum number of frames.
void buddy_reserve_n(pfn_t pfn, size_t nframes)
Reserve several frames at the given physical frame number.
MOSAPI void linked_list_init(list_node_t *head_node)
Initialise a circular double linked list.
#define list_node(element)
Get the ‘list_node’ of a list element. This is exactly the reverse of ‘list_entry’ above.
#define pfn_phyframe(pfn)
void _pmm_unref_phyframes(phyframe_t *frame, size_t n_pages)
phyframe_t * _pmm_ref_phyframes(phyframe_t *frame, size_t n_pages)
#define phyframe_pfn(frame)
pfn_t pmm_reserve_frames(pfn_t pfn_start, size_t npages)
Mark a range of physical memory as reserved.
void pmm_free_frames(phyframe_t *start_frame, size_t n_pages)
phyframe_t * pmm_allocate_frames(size_t n_frames, pmm_allocation_flags_t flags)
Allocate n_frames of contiguous physical memory.
pmm_region_t * pmm_find_reserved_region(ptr_t needle)
Find a region in the physical memory manager.
void pmm_dump_lists(void)
Dump the physical memory manager's state, (i.e. the free list and the allocated list).
@ PMM_ALLOC_NORMAL
allocate normal pages
#define ALIGN_UP_TO_PAGE(addr)
#define MOS_PANIC_HOOK_FEAT(_feat, _f, _n)
size_t pmm_reserved_frames
size_t pmm_allocated_frames
#define pr_dinfo2(feat, fmt,...)
#define memzero(ptr, size)
atomic_t allocated_refcount
#define PFNADDR(pfn, end)