MentOS
0.8.0
The Mentoring Operating System
|
Implementation of the Zone Allocator. More...
Go to the source code of this file.
Classes | |
struct | page_t |
Page descriptor. Use as a bitmap to understand the order of the block and if it is free or allocated. More... | |
struct | zone_t |
Data structure to differentiate memory zone. More... | |
struct | pg_data_t |
Data structure to rapresent a memory node. In Uniform memory access (UMA) architectures there is only one node called contig_page_data. More... | |
Macros | |
#define | page_count(p) atomic_read(&(p)->count) |
Reads the page count. | |
#define | set_page_count(p, v) atomic_set(&(p)->count, v) |
Sets the page count. | |
#define | page_inc(p) atomic_inc(&(p)->count) |
Increments the counter for the given page. | |
#define | page_dec(p) atomic_dec(&(p)->count) |
Decrements the counter for the given page. | |
Typedefs | |
typedef struct page_t | page_t |
Page descriptor. Use as a bitmap to understand the order of the block and if it is free or allocated. | |
typedef struct zone_t | zone_t |
Data structure to differentiate memory zone. | |
typedef struct pg_data_t | pg_data_t |
Data structure to rapresent a memory node. In Uniform memory access (UMA) architectures there is only one node called contig_page_data. | |
Enumerations | |
enum | zone_type { ZONE_NORMAL , ZONE_HIGHMEM , __MAX_NR_ZONES } |
Enumeration for zone_t. More... | |
Functions | |
uint32_t | find_nearest_order_greater (uint32_t base_addr, uint32_t amount) |
Finds the nearest order of memory allocation that can accommodate a given amount of memory. More... | |
int | pmmngr_init (boot_info_t *boot_info) |
Physical memory manager initialization. More... | |
page_t * | alloc_page_cached (gfp_t gfp_mask) |
Allocates a cached page based on the given GFP mask. More... | |
int | free_page_cached (page_t *page) |
Free a page allocated with alloc_page_cached. More... | |
uint32_t | __alloc_page_lowmem (gfp_t gfp_mask) |
Find the first free page frame, set it allocated and return the memory address of the page frame. More... | |
int | free_page_lowmem (uint32_t addr) |
Frees the given page frame address. More... | |
uint32_t | __alloc_pages_lowmem (gfp_t gfp_mask, uint32_t order) |
Find the first free 2^order amount of page frames, set it allocated and return the memory address of the first page frame allocated. More... | |
page_t * | _alloc_pages (gfp_t gfp_mask, uint32_t order) |
Find the first free 2^order amount of page frames, set it allocated and return the memory address of the first page frame allocated. More... | |
uint32_t | get_virtual_address_from_page (page_t *page) |
Converts a page structure to its corresponding low memory virtual address. More... | |
uint32_t | get_physical_address_from_page (page_t *page) |
Converts a page structure to its corresponding physical address. More... | |
page_t * | get_page_from_physical_address (uint32_t paddr) |
Retrieves the page structure corresponding to a given physical address. More... | |
page_t * | get_page_from_virtual_address (uint32_t vaddr) |
Retrieves the low memory page corresponding to the given virtual address. More... | |
int | free_pages_lowmem (uint32_t addr) |
Frees from the given page frame address up to 2^order amount of page frames. More... | |
int | __free_pages (page_t *page) |
Frees from the given page frame address up to 2^order amount of page frames. More... | |
unsigned long | get_zone_total_space (gfp_t gfp_mask) |
Retrieves the total space of the zone corresponding to the given GFP mask. More... | |
unsigned long | get_zone_free_space (gfp_t gfp_mask) |
Retrieves the free space of the zone corresponding to the given GFP mask. More... | |
unsigned long | get_zone_cached_space (gfp_t gfp_mask) |
Retrieves the cached space of the zone corresponding to the given GFP mask. More... | |
static int | is_lowmem_page_struct (void *addr) |
Checks if the specified address points to a page_t (or field) that belongs to lowmem. More... | |
Variables | |
page_t * | mem_map |
Array of all physical memory blocks (pages). More... | |
pg_data_t * | contig_page_data |
Memory node descriptor for contiguous memory. More... | |
Implementation of the Zone Allocator.
enum zone_type |
Enumeration for zone_t.
Find the first free page frame, set it allocated and return the memory address of the page frame.
gfp_mask | GFP_FLAGS to decide the zone allocation. |
Find the first free 2^order amount of page frames, set it allocated and return the memory address of the first page frame allocated.
gfp_mask | GFP_FLAGS to decide the zone allocation. |
order | The logarithm of the size of the page frame. |
int __free_pages | ( | page_t * | page | ) |
Frees from the given page frame address up to 2^order amount of page frames.
page | The page. |
Find the first free 2^order amount of page frames, set it allocated and return the memory address of the first page frame allocated.
gfp_mask | GFP_FLAGS to decide the zone allocation. |
order | The logarithm of the size of the page frame. |
Allocates a cached page based on the given GFP mask.
gfp_mask | The GFP mask specifying the allocation constraints. |
Finds the nearest order of memory allocation that can accommodate a given amount of memory.
base_addr | the base address from which to calculate the number of pages. |
amount | the amount of memory (in bytes) to allocate. |
int free_page_cached | ( | page_t * | page | ) |
Free a page allocated with alloc_page_cached.
page | Pointer to the page to free. |
int free_page_lowmem | ( | uint32_t | addr | ) |
Frees the given page frame address.
addr | The block address. |
int free_pages_lowmem | ( | uint32_t | addr | ) |
Frees from the given page frame address up to 2^order amount of page frames.
addr | The page frame address. |
Retrieves the page structure corresponding to a given physical address.
paddr | The physical address for which the page structure is requested. |
Retrieves the low memory page corresponding to the given virtual address.
vaddr | the virtual address to convert. |
Converts a page structure to its corresponding physical address.
page | Pointer to the page structure. |
Converts a page structure to its corresponding low memory virtual address.
page | Pointer to the page structure. |
unsigned long get_zone_cached_space | ( | gfp_t | gfp_mask | ) |
Retrieves the cached space of the zone corresponding to the given GFP mask.
gfp_mask | The GFP mask specifying the allocation constraints. |
unsigned long get_zone_free_space | ( | gfp_t | gfp_mask | ) |
Retrieves the free space of the zone corresponding to the given GFP mask.
gfp_mask | The GFP mask specifying the allocation constraints. |
unsigned long get_zone_total_space | ( | gfp_t | gfp_mask | ) |
Retrieves the total space of the zone corresponding to the given GFP mask.
gfp_mask | The GFP mask specifying the allocation constraints. |
|
inlinestatic |
Checks if the specified address points to a page_t (or field) that belongs to lowmem.
addr | The address to check. |
int pmmngr_init | ( | boot_info_t * | boot_info | ) |
Physical memory manager initialization.
boot_info | Information coming from the booloader. |
|
extern |
Memory node descriptor for contiguous memory.
This variable points to the pg_data_t
structure, which represents a memory node (usually for NUMA systems). It typically describes the memory properties and zones for a contiguous block of physical memory.