36 #ifndef CONFIG_BUDDY_HOUSE_KEEPING_PERCENT
37 #define CONFIG_BUDDY_HOUSE_KEEPING_PERCENT 25
40 #ifndef CONFIG_BUDDY_MIN_BLOCK_SIZE_SHIFT
41 #define CONFIG_BUDDY_MIN_BLOCK_SIZE_SHIFT 2
44 #ifndef CONFIG_BUDDY_MAX_BLOCK_SIZE_SHIFT
45 #define CONFIG_BUDDY_MAX_BLOCK_SIZE_SHIFT 12
49 #define HOUSE_KEEPING_PERCENT (CONFIG_BUDDY_HOUSE_KEEPING_PERCENT)
51 #define MIN_BLOCK_SIZE (0x01UL << CONFIG_BUDDY_MIN_BLOCK_SIZE_SHIFT)
53 #define MAX_BLOCK_SIZE (0x01UL << CONFIG_BUDDY_MAX_BLOCK_SIZE_SHIFT)
54 #define BINS_MAX_ORDER (CONFIG_BUDDY_MAX_BLOCK_SIZE_SHIFT - \
55 CONFIG_BUDDY_MIN_BLOCK_SIZE_SHIFT + 1)
57 #define NUM_OF_HEAPS 8
58 #define HEAP_SIZE (1 << 16)
59 #define COMMON_HEAP_ID 0
unsigned int heap_size
Definition: sw_buddy.h:96
unsigned int blk_sz
Definition: sw_buddy.h:77
#define BINS_MAX_ORDER
Definition: sw_buddy.h:54
struct list head
Definition: sw_buddy.h:65
unsigned int bin_num
Definition: sw_buddy.h:78
int alloc_private_heap(int heap_id)
Allocates heap memory initially during task creation for a particular heap_id Checks for already allo...
Definition: sw_buddy.c:819
struct list head
Definition: sw_buddy.h:75
int buddy_init(int index, void *heap_start, unsigned int heap_size)
Buddy allocator initialization.
Definition: sw_buddy.c:119
int free_private_heap(int heap_id)
Frees the private heap already allocated corresponding to the heap_id.
Definition: sw_buddy.c:848
Definition: sw_buddy.h:86
Definition: sw_buddy.h:64
void * sw_malloc(u32 size)
Gets the task id and allocates memory in the heap memory corresponding to the task.
Definition: sw_buddy.c:690
unsigned int count
Definition: sw_buddy.h:79
void sw_malloc_init(void)
Initial Memory Allocation Heap also initialized.
Definition: sw_heap.c:55
int sw_heap_init(int index, void *heap_start, unsigned int heap_size)
Heap memory initialization.
Definition: sw_buddy.c:802
void * heap_start
Definition: sw_buddy.h:39
void buddy_print_hk_state(int index)
Prints the status of house keeping region of heap memory No. of free and allocated nodes in the heap...
Definition: sw_buddy.c:622
struct sw_alloced_area * hk_an_array
Definition: sw_buddy.h:88
unsigned int mem_size
Definition: sw_buddy.h:95
unsigned int get_ptr_size(void *ptr)
function to get the size of a pointer. This is needed during realloc
Definition: sw_buddy.c:881
struct sw_free_area * hk_fn_array
Definition: sw_buddy.h:87
void * mem_start
Definition: sw_buddy.h:89
Definition: sw_buddy.h:74
unsigned int res0
Definition: sw_buddy.h:68
unsigned int res0
Definition: sw_buddy.h:80
void * buddy_zalloc(unsigned int size)
Allocates memory at the requested heap index for size bytes and initalizes it to zero.
Definition: sw_buddy.c:523
void sw_free_private(int heap_id, void *pointer)
Frees the privately allocated memory pointing to the heap_id and the address pointer.
Definition: sw_buddy.c:735
struct sw_alloced_area current
Definition: sw_buddy.h:91
void * sw_buddy_malloc(int index, unsigned int size)
allocates memory at the requested heap index for size bytes
Definition: sw_buddy.c:452
void * sw_malloc_private(int heap_id, u32 size)
Allocates memory privately for size bytes at the memory related to heap_id passed.
Definition: sw_buddy.c:657
void sw_free(void *pointer)
Gets the task_id and frees the heap memory corresponding to the task_id.
Definition: sw_buddy.c:763
struct sw_free_area __attribute__((packed))
void * map
Definition: sw_buddy.h:76
void sw_malloc_free(void *ptr)
Frees the memory allocated by passing the address ptr.
Definition: sw_heap.c:37
void * map
Definition: sw_buddy.h:66
void sw_dump_mallocs(void)
Prints the heap memory allocation related address and sizes.
Definition: sw_heap.c:46
unsigned int hk_fn_count
Definition: sw_buddy.h:93
void sw_buddy_print_state(void)
Prints the state of the heap allocations Whether heap is found for this task Heap size...
Definition: sw_buddy.c:578
unsigned int hk_an_count
Definition: sw_buddy.h:94
void * heap_start
Definition: sw_buddy.h:90
unsigned int count
Definition: sw_buddy.h:67
struct sw_free_area free_area[BINS_MAX_ORDER]
Definition: sw_buddy.h:92
void buddy_free(int index, void *ptr)
Frees the allocated memory block at the given heap index and address ptr.
Definition: sw_buddy.c:555
unsigned int heap_size
Definition: sw_buddy.h:45