blob: 88e64ce574041bc181932d7f8b10543b5c959d98 [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/* Copyright (c) 2011, Code Aurora Forum. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#ifndef _LINUX_MEMALLOC_H
14#define _LINUX_MEMALLOC_H
15
16#include <linux/mutex.h>
17#include <linux/genalloc.h>
18#include <linux/rbtree.h>
19
20struct mem_pool {
21 struct mutex pool_mutex;
22 struct gen_pool *gpool;
23 unsigned long paddr;
24 unsigned long size;
25 unsigned long free;
26};
27
28struct alloc {
29 struct rb_node rb_node;
30 void *vaddr;
31 unsigned long paddr;
32 struct mem_pool *mpool;
33 unsigned long len;
34};
35
36struct mem_pool *initialize_memory_pool(unsigned long start,
37 unsigned long size, int mem_type);
38
39void *allocate_contiguous_memory(unsigned long size,
40 int mem_type, unsigned long align, int cached);
41
42unsigned long allocate_contiguous_memory_nomap(unsigned long size,
43 int mem_type, unsigned long align);
44
45void free_contiguous_memory(void *addr);
46void free_contiguous_memory_by_paddr(unsigned long paddr);
47
48unsigned long memory_pool_node_paddr(void *vaddr);
49
50unsigned long memory_pool_node_len(void *vaddr);
51
52int memory_pool_init(void);
53#endif /* _LINUX_MEMALLOC_H */