Rev 3425 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3425 | Rev 4377 | ||
---|---|---|---|
Line 127... | Line 127... | ||
127 | * their caches do not require further allocation |
127 | * their caches do not require further allocation |
128 | */ |
128 | */ |
129 | static slab_cache_t *slab_extern_cache; |
129 | static slab_cache_t *slab_extern_cache; |
130 | /** Caches for malloc */ |
130 | /** Caches for malloc */ |
131 | static slab_cache_t *malloc_caches[SLAB_MAX_MALLOC_W - SLAB_MIN_MALLOC_W + 1]; |
131 | static slab_cache_t *malloc_caches[SLAB_MAX_MALLOC_W - SLAB_MIN_MALLOC_W + 1]; |
132 | char *malloc_names[] = { |
132 | static char *malloc_names[] = { |
133 | "malloc-16", |
133 | "malloc-16", |
134 | "malloc-32", |
134 | "malloc-32", |
135 | "malloc-64", |
135 | "malloc-64", |
136 | "malloc-128", |
136 | "malloc-128", |
137 | "malloc-256", |
137 | "malloc-256", |
Line 142... | Line 142... | ||
142 | "malloc-8K", |
142 | "malloc-8K", |
143 | "malloc-16K", |
143 | "malloc-16K", |
144 | "malloc-32K", |
144 | "malloc-32K", |
145 | "malloc-64K", |
145 | "malloc-64K", |
146 | "malloc-128K", |
146 | "malloc-128K", |
147 | "malloc-256K" |
147 | "malloc-256K", |
- | 148 | "malloc-512K", |
|
- | 149 | "malloc-1M", |
|
- | 150 | "malloc-2M", |
|
- | 151 | "malloc-4M" |
|
148 | }; |
152 | }; |
149 | 153 | ||
150 | /** Slab descriptor */ |
154 | /** Slab descriptor */ |
151 | typedef struct { |
155 | typedef struct { |
152 | slab_cache_t *cache; /**< Pointer to parent cache. */ |
156 | slab_cache_t *cache; /**< Pointer to parent cache. */ |
Line 171... | Line 175... | ||
171 | { |
175 | { |
172 | void *data; |
176 | void *data; |
173 | slab_t *slab; |
177 | slab_t *slab; |
174 | size_t fsize; |
178 | size_t fsize; |
175 | unsigned int i; |
179 | unsigned int i; |
176 | unsigned int zone = 0; |
180 | count_t zone = 0; |
177 | 181 | ||
178 | data = frame_alloc_generic(cache->order, FRAME_KA | flags, &zone); |
182 | data = frame_alloc_generic(cache->order, FRAME_KA | flags, &zone); |
179 | if (!data) { |
183 | if (!data) { |
180 | return NULL; |
184 | return NULL; |
181 | } |
185 | } |
Line 930... | Line 934... | ||
930 | /**************************************/ |
934 | /**************************************/ |
931 | /* kalloc/kfree functions */ |
935 | /* kalloc/kfree functions */ |
932 | void *malloc(unsigned int size, int flags) |
936 | void *malloc(unsigned int size, int flags) |
933 | { |
937 | { |
934 | ASSERT(_slab_initialized); |
938 | ASSERT(_slab_initialized); |
935 | ASSERT(size && size <= (1 << SLAB_MAX_MALLOC_W)); |
939 | ASSERT(size <= (1 << SLAB_MAX_MALLOC_W)); |
936 | 940 | ||
937 | if (size < (1 << SLAB_MIN_MALLOC_W)) |
941 | if (size < (1 << SLAB_MIN_MALLOC_W)) |
938 | size = (1 << SLAB_MIN_MALLOC_W); |
942 | size = (1 << SLAB_MIN_MALLOC_W); |
939 | 943 | ||
940 | int idx = fnzb(size - 1) - SLAB_MIN_MALLOC_W + 1; |
944 | int idx = fnzb(size - 1) - SLAB_MIN_MALLOC_W + 1; |