MOS Source Code
|
Allocate/free the physical memory, in the form of physical frames. More...
Classes | |
struct | phyframe_t |
struct | pmm_region_t |
Macros | |
#define | phyframe_pfn(frame) ((pfn_t) ((frame) -phyframes)) |
#define | pfn_phyframe(pfn) (&phyframes[(pfn)]) |
#define | pmm_reserve_address(paddr) pmm_reserve_frames(ALIGN_DOWN_TO_PAGE(paddr) / MOS_PAGE_SIZE, 1) |
#define | pmm_reserve_addresses(paddr, npages) pmm_reserve_frames(ALIGN_DOWN_TO_PAGE(paddr) / MOS_PAGE_SIZE, npages) |
#define | pmm_ref(thing, npages) _Generic((thing), phyframe_t *: _pmm_ref_phyframes, pfn_t: _pmm_ref_pfn_range)(thing, npages) |
#define | pmm_unref(thing, npages) _Generic((thing), phyframe_t *: _pmm_unref_phyframes, pfn_t: _pmm_unref_pfn_range)(thing, npages) |
#define | pmm_ref_one(thing) pmm_ref(thing, 1) |
#define | pmm_unref_one(thing) pmm_unref(thing, 1) |
Typedefs | |
typedef struct phyframe | phyframe_t |
Enumerations | |
enum | pmm_allocation_flags_t { PMM_ALLOC_NORMAL = 0 } |
Functions | |
MOS_STATIC_ASSERT (sizeof(phyframe_t)==32, "update phyframe_t struct size") | |
void | pmm_dump_lists (void) |
Dump the physical memory manager's state, (i.e. the free list and the allocated list). | |
void | pmm_init (size_t max_frames) |
Initialize the physical memory manager. | |
phyframe_t * | pmm_allocate_frames (size_t n_frames, pmm_allocation_flags_t flags) |
Allocate n_frames of contiguous physical memory. | |
void | pmm_free_frames (phyframe_t *start_frame, size_t n_pages) |
pfn_t | pmm_reserve_frames (pfn_t pfn, size_t npages) |
Mark a range of physical memory as reserved. | |
pmm_region_t * | pmm_find_reserved_region (ptr_t needle) |
Find a region in the physical memory manager. | |
phyframe_t * | _pmm_ref_phyframes (phyframe_t *frame, size_t npages) |
void | _pmm_unref_phyframes (phyframe_t *frame, size_t npages) |
should_inline pfn_t | _pmm_ref_pfn_range (pfn_t pfn_start, size_t npages) |
should_inline void | _pmm_unref_pfn_range (pfn_t pfn_start, size_t npages) |
Variables | |
phyframe_t * | phyframes |
size_t | pmm_total_frames |
size_t | pmm_allocated_frames |
size_t | pmm_reserved_frames |
Allocate/free the physical memory, in the form of physical frames.
The physical memory manager is responsible for allocating and freeing physical memory.
Definition at line 71 of file pmm.h.
Referenced by _pmm_ref_phyframes(), _pmm_unref_phyframes(), acpi_sysfs_mmap(), break_the_order(), buddy_alloc_n_exact(), dmabuf_do_allocate(), dump_list(), extract_exact_range(), mm_handle_fault(), mm_resolve_cow_fault(), pmm_allocate_frames(), and pmm_free_frames().
#define pfn_phyframe | ( | pfn | ) | (&phyframes[(pfn)]) |
Definition at line 72 of file pmm.h.
Referenced by _pmm_ref_pfn_range(), _pmm_ref_phyframes(), _pmm_unref_pfn_range(), _pmm_unref_phyframes(), break_the_order(), break_this_pfn(), buddy_alloc_n_exact(), buddy_free_n(), dmabuf_unshare(), extract_exact_range(), mm_handle_fault(), mmstat_sysfs_phyframe_stat_show(), pmm_allocate_frames(), pmm_free_frames(), populate_freelist(), and try_merge().
#define pmm_reserve_address | ( | paddr | ) | pmm_reserve_frames(ALIGN_DOWN_TO_PAGE(paddr) / MOS_PAGE_SIZE, 1) |
Definition at line 112 of file pmm.h.
Referenced by ioapic_init(), and lapic_memory_setup().
#define pmm_reserve_addresses | ( | paddr, | |
npages ) pmm_reserve_frames(ALIGN_DOWN_TO_PAGE(paddr) / MOS_PAGE_SIZE, npages) |
#define pmm_ref | ( | thing, | |
npages ) _Generic((thing), phyframe_t *: _pmm_ref_phyframes, pfn_t: _pmm_ref_pfn_range)(thing, npages) |
Definition at line 139 of file pmm.h.
Referenced by dmabuf_do_allocate(), mos_start_kernel(), and register_sysfs_acpi_node().
#define pmm_unref | ( | thing, | |
npages ) _Generic((thing), phyframe_t *: _pmm_unref_phyframes, pfn_t: _pmm_unref_pfn_range)(thing, npages) |
#define pmm_ref_one | ( | thing | ) | pmm_ref(thing, 1) |
Definition at line 142 of file pmm.h.
Referenced by cpio_fill_cache(), mm_replace_page_locked(), pml1e_do_copy_callback(), pml1e_do_map_callback(), tmpfs_fill_cache(), userfs_inode_cache_fill_cache(), and zero_page().
#define pmm_unref_one | ( | thing | ) | pmm_unref(thing, 1) |
Definition at line 143 of file pmm.h.
Referenced by mm_replace_page_locked(), pml1e_do_copy_callback(), and pml1e_do_unmap_callback().
MOS_STATIC_ASSERT | ( | sizeof(phyframe_t) | = =32, |
"update phyframe_t struct size" | ) |
Dump the physical memory manager's state, (i.e. the free list and the allocated list).
Definition at line 31 of file pmm.c.
Referenced by pmm_init().
Initialize the physical memory manager.
max_frames | Maximum number of frames that are addressable on the system. |
Definition at line 18 of file pmm.c.
Referenced by x86_initialise_phyframes_array().
phyframe_t * pmm_allocate_frames | ( | size_t | n_frames, |
pmm_allocation_flags_t | flags ) |
Allocate n_frames of contiguous physical memory.
n_frames | Number of frames to allocate. |
flags | Allocation flags. |
Definition at line 37 of file pmm.c.
Referenced by dmabuf_do_allocate(), mm_get_free_page_raw(), and mm_get_free_pages().
void pmm_free_frames | ( | phyframe_t * | start_frame, |
size_t | n_pages ) |
Definition at line 53 of file pmm.c.
Referenced by _pmm_unref_phyframes(), and dmabuf_unshare().
Mark a range of physical memory as reserved.
pfn | Physical frame number of the block to reserve. |
npages | Number of pages to reserve. |
PMM_REGION_RESERVED
and will be moved to the allocated list.Definition at line 67 of file pmm.c.
Referenced by platform_startup_mm(), and x86_initialise_phyframes_array().
pmm_region_t * pmm_find_reserved_region | ( | ptr_t | needle | ) |
Find a region in the physical memory manager.
needle | One address in the region to find. |
Definition at line 76 of file pmm.c.
Referenced by ioapic_init(), lapic_memory_setup(), and platform_startup_late().
phyframe_t * _pmm_ref_phyframes | ( | phyframe_t * | frame, |
size_t | npages ) |
Definition at line 96 of file pmm.c.
Referenced by _pmm_ref_pfn_range().
void _pmm_unref_phyframes | ( | phyframe_t * | frame, |
size_t | npages ) |
Definition at line 107 of file pmm.c.
Referenced by _pmm_unref_pfn_range().
should_inline pfn_t _pmm_ref_pfn_range | ( | pfn_t | pfn_start, |
size_t | npages ) |
should_inline void _pmm_unref_pfn_range | ( | pfn_t | pfn_start, |
size_t | npages ) |
|
extern |
Definition at line 13 of file pmm.c.
Referenced by x86_initialise_phyframes_array().
|
extern |
Definition at line 14 of file pmm.c.
Referenced by _pmm_ref_phyframes(), _pmm_unref_phyframes(), extract_exact_range(), mmstat_sysfs_phyframe_stat_show(), mmstat_sysfs_phyframe_stat_store(), mmstat_sysfs_stat(), pmm_init(), pmm_reserve_frames(), and try_merge().
size_t pmm_allocated_frames |
Definition at line 74 of file pmm.h.
Referenced by mmstat_sysfs_stat().
size_t pmm_reserved_frames |
Definition at line 74 of file pmm.h.
Referenced by mmstat_sysfs_stat().