GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / linux / linux-2.6.36 / drivers / staging / zram / xvmalloc_int.h
blobe23ed5c8b8e4e57593d182544aedfe15bb6a333d
1 /*
2 * xvmalloc memory allocator
4 * Copyright (C) 2008, 2009, 2010 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) \
35 / FL_DELTA + 1)
37 #define MAX_FLI DIV_ROUND_UP(NUM_FREE_LISTS, BITS_PER_LONG)
39 /* End of user params */
41 enum blockflags {
42 BLOCK_FREE,
43 PREV_FREE,
44 __NR_BLOCKFLAGS,
47 #define FLAGS_MASK XV_ALIGN_MASK
48 #define PREV_MASK (~FLAGS_MASK)
50 struct freelist_entry {
51 struct page *page;
52 u16 offset;
53 u16 pad;
56 struct link_free {
57 struct page *prev_page;
58 struct page *next_page;
59 u16 prev_offset;
60 u16 next_offset;
63 struct block_header {
64 union {
65 /* This common header must be XV_ALIGN bytes */
66 u8 common[XV_ALIGN];
67 struct {
68 u16 size;
69 u16 prev;
72 struct link_free link;
75 struct xv_pool {
76 ulong flbitmap;
77 ulong slbitmap[MAX_FLI];
78 spinlock_t lock;
80 struct freelist_entry freelist[NUM_FREE_LISTS];
82 /* stats */
83 u64 total_pages;
86 #endif