Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Typedefs | Functions
genalloc.h File Reference

Go to the source code of this file.

Data Structures

struct  gen_pool
 
struct  gen_pool_chunk
 

Typedefs

typedef unsigned long(* genpool_algo_t )(unsigned long *map, unsigned long size, unsigned long start, unsigned int nr, void *data)
 

Functions

struct gen_poolgen_pool_create (int, int)
 
phys_addr_t gen_pool_virt_to_phys (struct gen_pool *pool, unsigned long)
 
int gen_pool_add_virt (struct gen_pool *, unsigned long, phys_addr_t, size_t, int)
 
void gen_pool_destroy (struct gen_pool *)
 
unsigned long gen_pool_alloc (struct gen_pool *, size_t)
 
void gen_pool_free (struct gen_pool *, unsigned long, size_t)
 
void gen_pool_for_each_chunk (struct gen_pool *, void(*)(struct gen_pool *, struct gen_pool_chunk *, void *), void *)
 
size_t gen_pool_avail (struct gen_pool *)
 
size_t gen_pool_size (struct gen_pool *)
 
void gen_pool_set_algo (struct gen_pool *pool, genpool_algo_t algo, void *data)
 
unsigned long gen_pool_first_fit (unsigned long *map, unsigned long size, unsigned long start, unsigned int nr, void *data)
 
unsigned long gen_pool_best_fit (unsigned long *map, unsigned long size, unsigned long start, unsigned int nr, void *data)
 

Typedef Documentation

typedef unsigned long(* genpool_algo_t)(unsigned long *map, unsigned long size, unsigned long start, unsigned int nr, void *data)

Allocation callback function type definition : Pointer to bitmap : The bitmap size in bits : The bitnumber to start searching at : The number of zeroed bits we're looking for : optional additional data used by

Definition at line 40 of file genalloc.h.

Function Documentation

int gen_pool_add_virt ( struct gen_pool pool,
unsigned long  virt,
phys_addr_t  phys,
size_t  size,
int  nid 
)

gen_pool_add_virt - add a new chunk of special memory to the pool : pool to add new memory chunk to : virtual starting address of memory chunk to add to pool : physical starting address of memory chunk to add to pool : size in bytes of the memory chunk to add to pool : node id of the node the chunk structure and bitmap should be allocated on, or -1

Add a new chunk of special memory to the specified pool.

Returns 0 on success or a -ve errno on failure.

Definition at line 175 of file genalloc.c.

unsigned long gen_pool_alloc ( struct gen_pool pool,
size_t  size 
)

gen_pool_alloc - allocate special memory from the pool : pool to allocate from : number of bytes to allocate from the pool

Allocate the requested number of bytes from the specified pool. Uses the pool allocation function (with first-fit algorithm by default). Can not be used in NMI handler on architectures without NMI-safe cmpxchg implementation.

Definition at line 264 of file genalloc.c.

size_t gen_pool_avail ( struct gen_pool pool)

gen_pool_avail - get available free space of the pool : pool to get available free space

Return available free space of the specified pool.

Definition at line 375 of file genalloc.c.

unsigned long gen_pool_best_fit ( unsigned long map,
unsigned long  size,
unsigned long  start,
unsigned int  nr,
void data 
)

gen_pool_best_fit - find the best fitting region of memory macthing the size requirement (no alignment constraint) : The address to base the search on : The bitmap size in bits : The bitnumber to start searching at : The number of zeroed bits we're looking for : additional data - unused

Iterate over the bitmap to find the smallest free region which we can allocate the memory.

Definition at line 459 of file genalloc.c.

struct gen_pool* gen_pool_create ( int  min_alloc_order,
int  nid 
)
read

gen_pool_create - create a new special memory pool : log base 2 of number of bytes each bitmap bit represents : node id of the node the pool structure should be allocated on, or -1

Create a new special memory pool that can be used to manage special purpose memory not managed by the regular kmalloc/kfree interface.

Definition at line 146 of file genalloc.c.

void gen_pool_destroy ( struct gen_pool pool)

gen_pool_destroy - destroy a special memory pool : pool to destroy

Destroy the specified special memory pool. Verifies that there are no outstanding allocations.

Definition at line 232 of file genalloc.c.

unsigned long gen_pool_first_fit ( unsigned long map,
unsigned long  size,
unsigned long  start,
unsigned int  nr,
void data 
)

gen_pool_first_fit - find the first available region of memory matching the size requirement (no alignment constraint) : The address to base the search on : The bitmap size in bits : The bitnumber to start searching at : The number of zeroed bits we're looking for : additional data - unused

Definition at line 440 of file genalloc.c.

void gen_pool_for_each_chunk ( struct gen_pool ,
void(*)(struct gen_pool *, struct gen_pool_chunk *, void *)  ,
void  
)
void gen_pool_free ( struct gen_pool pool,
unsigned long  addr,
size_t  size 
)

gen_pool_free - free allocated special memory back to the pool : pool to free to : starting address of memory to free back to pool : size in bytes of memory to free

Free previously allocated special memory back to the specified pool. Can not be used in NMI handler on architectures without NMI-safe cmpxchg implementation.

Definition at line 318 of file genalloc.c.

void gen_pool_set_algo ( struct gen_pool pool,
genpool_algo_t  algo,
void data 
)

gen_pool_set_algo - set the allocation algorithm : pool to change allocation algorithm : custom algorithm function : additional data used by

Call for each memory allocation in the pool. If is NULL use gen_pool_first_fit as default memory allocation function.

Definition at line 417 of file genalloc.c.

size_t gen_pool_size ( struct gen_pool pool)

gen_pool_size - get size in bytes of memory managed by the pool : pool to get size

Return size in bytes of memory managed by the pool.

Definition at line 394 of file genalloc.c.

phys_addr_t gen_pool_virt_to_phys ( struct gen_pool pool,
unsigned long  addr 
)

gen_pool_virt_to_phys - return the physical address of memory : pool to allocate from : starting address of memory

Returns the physical address on success, or -1 on error.

Definition at line 207 of file genalloc.c.