blob: 06d7ee1dd0b6006466f8aed03c07a76278a61f9d [file] [log] [blame]
Duy Truong790f06d2013-02-13 16:38:12 -08001/* Copyright (c) 2010, The Linux Foundation. All rights reserved.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002 *
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 */
24struct 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 */
31struct vcm_memtype_map {
32 int pool_id[MAX_NUM_PRIO_POOLS];
33 int num_pools;
34};
35
36int vcm_alloc_pool_idx_to_size(int pool_idx);
37int vcm_alloc_idx_to_size(int idx);
38int vcm_alloc_get_mem_size(void);
39int vcm_alloc_blocks_avail(enum memtype_t memtype, int idx);
40int vcm_alloc_get_num_chunks(enum memtype_t memtype);
41int vcm_alloc_all_blocks_avail(enum memtarget_t memtype);
42int vcm_alloc_count_allocated(enum memtype_t memtype);
43void vcm_alloc_print_list(enum memtype_t memtype, int just_allocated);
44int vcm_alloc_idx_to_size(int idx);
45int vcm_alloc_destroy(void);
46int vcm_alloc_init(struct physmem_region *mem, int n_regions,
47 struct vcm_memtype_map *mt_map, int n_mt);
48int vcm_alloc_free_blocks(enum memtype_t memtype,
49 struct phys_chunk *alloc_head);
50int vcm_alloc_num_blocks(int num, enum memtype_t memtype,
51 int idx, /* chunk size */
52 struct phys_chunk *alloc_head);
53int vcm_alloc_max_munch(int len, enum memtype_t memtype,
54 struct phys_chunk *alloc_head);
55
56/* bring-up init, destroy */
57int 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
61int vcm_sys_destroy(void);
62
63#endif /* VCM_ALLOC_H */