18 #ifndef NDBD_MALLOC_IMPL_H
19 #define NDBD_MALLOC_IMPL_H
21 #include <kernel_types.h>
22 #include <Bitmask.hpp>
32 #define BITMAP_WORDS (1 << BMW_2LOG)
34 #define BPP_2LOG (BMW_2LOG + 5)
35 #define SPACE_PER_BMP_2LOG ((2 + BMW_2LOG) + BPP_2LOG)
41 Uint32 m_data[BITMAP_WORDS];
69 bool init(Uint32 *watchCounter,
bool allow_alloc_less_than_requested =
true);
70 void map(Uint32 * watchCounter,
bool memlock =
false, Uint32 resources[] = 0);
71 void* get_memroot()
const;
81 void* alloc_page(Uint32
type, Uint32*
i,
enum AllocZone);
82 void release_page(Uint32 type, Uint32 i);
84 void alloc_pages(Uint32 type, Uint32* i, Uint32 *cnt, Uint32 min = 1);
85 void release_pages(Uint32 type, Uint32 i, Uint32 cnt);
95 void grow(Uint32 start, Uint32 cnt);
104 Uint32 m_buddy_lists[2][16];
108 void release_impl(Uint32 zone, Uint32 start, Uint32 cnt);
109 void insert_free_list(Uint32 zone, Uint32 start, Uint32 cnt);
110 Uint32 remove_free_list(Uint32 zone, Uint32 start, Uint32 list);
112 void set(Uint32 first, Uint32 last);
113 void clear(Uint32 first, Uint32 last);
114 void clear_and_set(Uint32 first, Uint32 last);
115 Uint32 check(Uint32 first, Uint32 last);
117 void alloc(AllocZone, Uint32*
ret, Uint32 *pages, Uint32 min_requested);
118 void alloc_impl(Uint32 zone, Uint32* ret, Uint32 *pages, Uint32 min);
119 void release(Uint32 start, Uint32 cnt);
130 Ndbd_mem_manager::get_free_page_data(
Alloc_page* ptr, Uint32 idx)
132 assert(idx & ((1 << BPP_2LOG) - 1));
133 assert((idx & ((1 << BPP_2LOG) - 1)) != ((1 << BPP_2LOG) - 1));
136 (ptr->m_data + ((idx & ((BITMAP_WORDS >> FPD_2LOG) - 1)) << FPD_2LOG));
141 Ndbd_mem_manager::set(Uint32 first, Uint32 last)
144 #if ((SPACE_PER_BMP_2LOG < 32) && (SIZEOF_CHARP == 4)) || (SIZEOF_CHARP == 8)
145 Uint32 bmp = first & ~((1 << BPP_2LOG) - 1);
146 assert((first >> BPP_2LOG) == (last >> BPP_2LOG));
147 assert(bmp < m_resource_limit[0].m_resource_id);
159 Ndbd_mem_manager::clear(Uint32 first, Uint32 last)
162 #if ((SPACE_PER_BMP_2LOG < 32) && (SIZEOF_CHARP == 4)) || (SIZEOF_CHARP == 8)
163 Uint32 bmp = first & ~((1 << BPP_2LOG) - 1);
164 assert((first >> BPP_2LOG) == (last >> BPP_2LOG));
165 assert(bmp < m_resource_limit[0].m_resource_id);
177 Ndbd_mem_manager::clear_and_set(Uint32 first, Uint32 last)
180 #if ((SPACE_PER_BMP_2LOG < 32) && (SIZEOF_CHARP == 4)) || (SIZEOF_CHARP == 8)
181 Uint32 bmp = first & ~((1 << BPP_2LOG) - 1);
182 assert((first >> BPP_2LOG) == (last >> BPP_2LOG));
183 assert(bmp < m_resource_limit[0].m_resource_id);
196 Ndbd_mem_manager::check(Uint32 first, Uint32 last)
200 #if ((SPACE_PER_BMP_2LOG < 32) && (SIZEOF_CHARP == 4)) || (SIZEOF_CHARP == 8)
201 Uint32 bmp = first & ~((1 << BPP_2LOG) - 1);
202 assert((first >> BPP_2LOG) == (last >> BPP_2LOG));
203 assert(bmp < m_resource_limit[0].m_resource_id);