Duy Truong | 790f06d | 2013-02-13 16:38:12 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2010, The Linux Foundation. All rights reserved. |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 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 | |
| 14 | #ifndef VCM_ALLOC_H |
| 15 | #define VCM_ALLOC_H |
| 16 | |
| 17 | #include <linux/list.h> |
| 18 | #include <linux/vcm.h> |
| 19 | #include <linux/vcm_types.h> |
| 20 | |
| 21 | #define MAX_NUM_PRIO_POOLS 8 |
| 22 | |
| 23 | /* Data structure to inform VCM about the memory it manages */ |
| 24 | struct physmem_region { |
| 25 | size_t addr; |
| 26 | size_t size; |
| 27 | int chunk_size; |
| 28 | }; |
| 29 | |
| 30 | /* Mapping between memtypes and physmem_regions based on chunk size */ |
| 31 | struct vcm_memtype_map { |
| 32 | int pool_id[MAX_NUM_PRIO_POOLS]; |
| 33 | int num_pools; |
| 34 | }; |
| 35 | |
| 36 | int vcm_alloc_pool_idx_to_size(int pool_idx); |
| 37 | int vcm_alloc_idx_to_size(int idx); |
| 38 | int vcm_alloc_get_mem_size(void); |
| 39 | int vcm_alloc_blocks_avail(enum memtype_t memtype, int idx); |
| 40 | int vcm_alloc_get_num_chunks(enum memtype_t memtype); |
| 41 | int vcm_alloc_all_blocks_avail(enum memtarget_t memtype); |
| 42 | int vcm_alloc_count_allocated(enum memtype_t memtype); |
| 43 | void vcm_alloc_print_list(enum memtype_t memtype, int just_allocated); |
| 44 | int vcm_alloc_idx_to_size(int idx); |
| 45 | int vcm_alloc_destroy(void); |
| 46 | int vcm_alloc_init(struct physmem_region *mem, int n_regions, |
| 47 | struct vcm_memtype_map *mt_map, int n_mt); |
| 48 | int vcm_alloc_free_blocks(enum memtype_t memtype, |
| 49 | struct phys_chunk *alloc_head); |
| 50 | int vcm_alloc_num_blocks(int num, enum memtype_t memtype, |
| 51 | int idx, /* chunk size */ |
| 52 | struct phys_chunk *alloc_head); |
| 53 | int vcm_alloc_max_munch(int len, enum memtype_t memtype, |
| 54 | struct phys_chunk *alloc_head); |
| 55 | |
| 56 | /* bring-up init, destroy */ |
| 57 | int vcm_sys_init(struct physmem_region *mem, int n_regions, |
| 58 | struct vcm_memtype_map *mt_map, int n_mt, |
| 59 | void *cont_pa, unsigned int cont_sz); |
| 60 | |
| 61 | int vcm_sys_destroy(void); |
| 62 | |
| 63 | #endif /* VCM_ALLOC_H */ |