Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1 | /* 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 | |
| 20 | struct 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 | |
| 28 | struct 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 | |
| 36 | struct mem_pool *initialize_memory_pool(unsigned long start, |
| 37 | unsigned long size, int mem_type); |
| 38 | |
| 39 | void *allocate_contiguous_memory(unsigned long size, |
| 40 | int mem_type, unsigned long align, int cached); |
| 41 | |
| 42 | unsigned long allocate_contiguous_memory_nomap(unsigned long size, |
| 43 | int mem_type, unsigned long align); |
| 44 | |
| 45 | void free_contiguous_memory(void *addr); |
| 46 | void free_contiguous_memory_by_paddr(unsigned long paddr); |
| 47 | |
| 48 | unsigned long memory_pool_node_paddr(void *vaddr); |
| 49 | |
| 50 | unsigned long memory_pool_node_len(void *vaddr); |
| 51 | |
| 52 | int memory_pool_init(void); |
| 53 | #endif /* _LINUX_MEMALLOC_H */ |