8 #include "sys/list_head.h"
13 #define MAX_BUDDYSYSTEM_GFP_ORDER 14
16 #define BBSTRUCT_OFFSET(page, element) \
17 ((uint32_t) & (((page *)NULL)->element))
21 #define PG_FROM_BBSTRUCT(bbstruct, page, element) \
22 ((page *)(((uint32_t)(bbstruct)) - BBSTRUCT_OFFSET(page, element)))
unsigned long buddy_system_get_free_space(bb_instance_t *instance)
Returns the free space for the given instance.
Definition: buddysystem.c:369
struct bb_free_area_t bb_free_area_t
Buddy system descriptor: collection of free page blocks. Each block represents 2^k free contiguous pa...
unsigned long buddy_system_get_cached_space(bb_instance_t *instance)
Returns the cached space for the given instance.
Definition: buddysystem.c:377
void buddy_system_dump(bb_instance_t *instance)
Print the size of free_list of each free_area.
Definition: buddysystem.c:353
void bb_free_pages(bb_instance_t *instance, bb_page_t *page)
Free a block of page frames of size 2^order.
Definition: buddysystem.c:210
bb_page_t * bb_alloc_page_cached(bb_instance_t *instance)
Alloc a page using bb cache.
Definition: buddysystem.c:439
bb_page_t * bb_alloc_pages(bb_instance_t *instance, unsigned int order)
Allocate a block of page frames of size 2^order.
Definition: buddysystem.c:121
void bb_free_page_cached(bb_instance_t *instance, bb_page_t *page)
Free a page allocated with bb_alloc_page_cached.
Definition: buddysystem.c:444
struct bb_instance_t bb_instance_t
Buddy system instance, that represents a memory area managed by the buddy system.
unsigned long buddy_system_get_total_space(bb_instance_t *instance)
Returns the total space for the given instance.
Definition: buddysystem.c:364
struct bb_page_t bb_page_t
The base structure representing a bb page.
#define MAX_BUDDYSYSTEM_GFP_ORDER
Max gfp pages order of buddysystem blocks.
Definition: buddysystem.h:13
void buddy_system_init(bb_instance_t *instance, const char *name, void *pages_start, uint32_t bbpage_offset, uint32_t pages_stride, uint32_t pages_count)
Initialize Buddy System.
Definition: buddysystem.c:288
Standard integer data-types.
unsigned int uint32_t
Define the unsigned 32-bit integer.
Definition: stdint.h:18
Buddy system descriptor: collection of free page blocks. Each block represents 2^k free contiguous pa...
Definition: buddysystem.h:41
list_head free_list
free_list collectes the first page descriptors of a blocks of 2^k frames
Definition: buddysystem.h:43
int nr_free
nr_free specifies the number of blocks of free pages.
Definition: buddysystem.h:45
Buddy system instance, that represents a memory area managed by the buddy system.
Definition: buddysystem.h:50
list_head free_pages_cache_list
Pointer to start of free pages cache.
Definition: buddysystem.h:56
bb_page_t * base_page
Address of the first managed page.
Definition: buddysystem.h:62
unsigned long free_pages_cache_size
Size of the current cache.
Definition: buddysystem.h:58
bb_free_area_t free_area[MAX_BUDDYSYSTEM_GFP_ORDER]
List of buddy system pages grouped by level.
Definition: buddysystem.h:54
const char * name
Name of this bb instance.
Definition: buddysystem.h:52
unsigned long bbpg_offset
Offset of the bb_page_t struct from the start of the whole structure.
Definition: buddysystem.h:66
unsigned long pgs_size
Size of the (padded) wrapper page structure.
Definition: buddysystem.h:64
unsigned long size
Buddysystem instance size in number of pages.
Definition: buddysystem.h:60
The base structure representing a bb page.
Definition: buddysystem.h:25
volatile unsigned long flags
The flags of the page.
Definition: buddysystem.h:27
list_head siblings
The page siblings when not allocated.
Definition: buddysystem.h:33
list_head cache
The cache list pointer when allocated but on cache.
Definition: buddysystem.h:35
uint32_t order
The current page order.
Definition: buddysystem.h:29
union bb_page_t::@5 location
Keep track of where the page is located.