Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Merge branch 'devel'
[palacios.git] / kitten / include / lwk / buddy.h
1 /* Copyright (c) 2007, Sandia National Laboratories */
2
3 #ifndef _LWK_BUDDY_H
4 #define _LWK_BUDDY_H
5
6 #include <lwk/list.h>
7
8 /**
9  * This structure stores the state of a buddy system memory allocator object.
10  */
11 struct buddy_mempool {
12         unsigned long    base_addr;    /* base address of the memory pool */
13         unsigned long    pool_order;   /* size of memory pool = 2^pool_order */
14         unsigned long    min_order;    /* minimum allocatable block size */
15
16         unsigned long    num_blocks;   /* number of bits in tag_bits */
17         unsigned long    *tag_bits;    /* one bit for each 2^min_order block
18                                         *   0 = block is allocated
19                                         *   1 = block is available
20                                         */
21
22         struct list_head *avail;       /* one free list for each block size,
23                                         * indexed by block order:
24                                         *   avail[i] = free list of 2^i blocks
25                                         */
26 };
27
28 struct buddy_mempool *
29 buddy_init(
30         unsigned long base_addr,
31         unsigned long pool_order,
32         unsigned long min_order
33 );
34
35 void *buddy_alloc(struct buddy_mempool *mp, unsigned long order);
36 void buddy_free(struct buddy_mempool *mp, void *addr, unsigned long order);
37
38 void buddy_dump_mempool(struct buddy_mempool *mp);
39
40 #endif