2 * xvmalloc memory allocator
4 * Copyright (C) 2008, 2009 Nitin Gupta
6 * This code is released using a dual license strategy: BSD/GPL
7 * You can choose the licence that better fits your requirements.
9 * Released under the terms of 3-clause BSD License
10 * Released under the terms of GNU General Public License Version 2.0
13 #ifndef _XV_MALLOC_INT_H_
14 #define _XV_MALLOC_INT_H_
16 #include <linux/kernel.h>
17 #include <linux/types.h>
19 /* User configurable params */
21 /* Must be power of two */
22 #define XV_ALIGN_SHIFT 2
23 #define XV_ALIGN (1 << XV_ALIGN_SHIFT)
24 #define XV_ALIGN_MASK (XV_ALIGN - 1)
26 /* This must be greater than sizeof(link_free) */
27 #define XV_MIN_ALLOC_SIZE 32
28 #define XV_MAX_ALLOC_SIZE (PAGE_SIZE - XV_ALIGN)
30 /* Free lists are separated by FL_DELTA bytes */
31 #define FL_DELTA_SHIFT 3
32 #define FL_DELTA (1 << FL_DELTA_SHIFT)
33 #define FL_DELTA_MASK (FL_DELTA - 1)
34 #define NUM_FREE_LISTS ((XV_MAX_ALLOC_SIZE - XV_MIN_ALLOC_SIZE) \
37 #define MAX_FLI DIV_ROUND_UP(NUM_FREE_LISTS, BITS_PER_LONG)
39 /* End of user params */
47 #define FLAGS_MASK XV_ALIGN_MASK
48 #define PREV_MASK (~FLAGS_MASK)
50 struct freelist_entry
{
57 struct page
*prev_page
;
58 struct page
*next_page
;
65 /* This common header must be ALIGN bytes */
72 struct link_free link
;
77 ulong slbitmap
[MAX_FLI
];
80 struct freelist_entry freelist
[NUM_FREE_LISTS
];