summaryrefslogtreecommitdiff
path: root/bmm_lib.h
blob: 09348ef3b7a531670d94e19ef6972cfe1e90a227 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
 *  bmm_lib.h
 *
 *  Buffer Management Module
 *
 *  User level BMM Defines/Globals/Functions
 *
 *  Li Li (lea.li@marvell.com)

 *(C) Copyright 2007 Marvell International Ltd.
 * All Rights Reserved
 */

#if !defined (__BMM_LIB_H__)
#define __BMM_LIB_H__

/* ioctl arguments: memory attributes */
#define BMM_ATTR_DEFAULT	(0)		/* cacheable bufferable */
#define BMM_ATTR_WRITECOMBINE	(1 << 0)	/* non-cacheable & bufferable */
#define BMM_ATTR_NONCACHED	(1 << 1)	/* non-cacheable & non-bufferable */

/* Note: extra attributes below are not supported yet! */
#define BMM_ATTR_HUGE_PAGE	(1 << 2)	/* 64KB page size */
#define BMM_ATTR_WRITETHROUGH	(1 << 3)	/* implies L1 Cacheable */
#define BMM_ATTR_L2_CACHEABLE	(1 << 4)	/* implies L1 Cacheable */

/* obsolete */
#define BMM_ATTR_NONBUFFERABLE	(1 << 5)	/* non-bufferable */
#define BMM_ATTR_NONCACHEABLE	(1 << 6)	/* non-cacheable */

/* ioctl arguments: cache flush direction */
#define BMM_DMA_BIDIRECTIONAL	(0)		/* DMA_BIDIRECTIONAL */
#define BMM_DMA_TO_DEVICE	(1)		/* DMA_TO_DEVICE */
#define BMM_DMA_FROM_DEVICE	(2)		/* DMA_FROM_DEVICE */
#define BMM_DMA_NONE		(3)		/* DMA_NONE */

#if defined (__cplusplus)
extern "C" {
#endif

int bmm_init(void);
void bmm_exit(void);
void *bmm_malloc(unsigned long size, int attr);
void *bmm_malloc_aligned(unsigned long size, int attr, unsigned align);
void *bmm_malloc_aligned_phys(unsigned long size, int attr, unsigned align,
			      unsigned long *paddr);
void bmm_free(void *vaddr);
void *bmm_attach(unsigned long paddr, unsigned long len);
void bmm_detach(void *vaddr, unsigned long len);
void *bmm_get_vaddr(unsigned long paddr);
unsigned long bmm_get_paddr(void *vaddr);
int bmm_get_dmabuf_fd(void *vaddr);
int bmm_get_phys_dmabuf_fd(unsigned long paddr);
int bmm_get_mem_attr(void *vaddr);
int bmm_set_mem_attr(void *vaddr, int attr);	/* Not supported yet */
unsigned long bmm_get_mem_size(void *vaddr);
unsigned long bmm_get_total_space(void);
unsigned long bmm_get_free_space(void);
unsigned long bmm_get_allocated_space(void);
void bmm_flush_cache(void *vaddr, int dir);
void bmm_flush_cache_range(void *start, size_t size, int direction);
void bmm_flush_user(void *start, long size, int direction);
void bmm_dump(void);	/* for debugging */

#if defined (__cplusplus)
}
#endif

#endif /* __BMM_LIB_H__ */