Nitin Gupta | 61989a8 | 2012-01-09 16:51:56 -0600 | [diff] [blame] | 1 | /* |
| 2 | * zsmalloc memory allocator |
| 3 | * |
| 4 | * Copyright (C) 2011 Nitin Gupta |
| 5 | * |
| 6 | * This code is released using a dual license strategy: BSD/GPL |
| 7 | * You can choose the license that better fits your requirements. |
| 8 | * |
| 9 | * Released under the terms of 3-clause BSD License |
| 10 | * Released under the terms of GNU General Public License Version 2.0 |
| 11 | */ |
| 12 | |
| 13 | #ifndef _ZS_MALLOC_H_ |
| 14 | #define _ZS_MALLOC_H_ |
| 15 | |
| 16 | #include <linux/types.h> |
| 17 | |
Seth Jennings | b741851 | 2012-07-02 16:15:52 -0500 | [diff] [blame^] | 18 | /* |
| 19 | * zsmalloc mapping modes |
| 20 | * |
| 21 | * NOTE: These only make a difference when a mapped object spans pages |
| 22 | */ |
| 23 | enum zs_mapmode { |
| 24 | ZS_MM_RW, /* normal read-write mapping */ |
| 25 | ZS_MM_RO, /* read-only (no copy-out at unmap time) */ |
| 26 | ZS_MM_WO /* write-only (no copy-in at map time) */ |
| 27 | }; |
| 28 | |
Nitin Gupta | 61989a8 | 2012-01-09 16:51:56 -0600 | [diff] [blame] | 29 | struct zs_pool; |
| 30 | |
| 31 | struct zs_pool *zs_create_pool(const char *name, gfp_t flags); |
| 32 | void zs_destroy_pool(struct zs_pool *pool); |
| 33 | |
Minchan Kim | c234434 | 2012-06-08 15:39:25 +0900 | [diff] [blame] | 34 | unsigned long zs_malloc(struct zs_pool *pool, size_t size); |
| 35 | void zs_free(struct zs_pool *pool, unsigned long obj); |
Nitin Gupta | 61989a8 | 2012-01-09 16:51:56 -0600 | [diff] [blame] | 36 | |
Seth Jennings | b741851 | 2012-07-02 16:15:52 -0500 | [diff] [blame^] | 37 | void *zs_map_object(struct zs_pool *pool, unsigned long handle, |
| 38 | enum zs_mapmode mm); |
Minchan Kim | c234434 | 2012-06-08 15:39:25 +0900 | [diff] [blame] | 39 | void zs_unmap_object(struct zs_pool *pool, unsigned long handle); |
Nitin Gupta | 61989a8 | 2012-01-09 16:51:56 -0600 | [diff] [blame] | 40 | |
| 41 | u64 zs_get_total_size_bytes(struct zs_pool *pool); |
| 42 | |
| 43 | #endif |