1 /**********************************************************************
3 * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
9 * This program is distributed in the hope it will be useful but, except
10 * as otherwise stated in writing, without any warranty; without even the
11 * implied warranty of merchantability or fitness for a particular purpose.
12 * See the GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18 * The full GNU General Public License is included in this distribution in
19 * the file called "COPYING".
21 * Contact Information:
22 * Imagination Technologies Ltd. <gpl-support@imgtec.com>
23 * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK
25 ******************************************************************************/
27 #ifndef _BUFFER_MANAGER_H_
28 #define _BUFFER_MANAGER_H_
30 #include "img_types.h"
42 hm_wrapped_scatter_virtaddr,
47 struct BM_HEAP *pBMHeap;
48 struct RA_ARENA *pArena;
51 struct IMG_CPU_PHYADDR CpuPAddr;
52 struct IMG_DEV_VIRTADDR DevVAddr;
53 struct IMG_SYS_PHYADDR *psSysAddr;
62 struct IMG_CPU_PHYADDR CpuPAddr;
63 struct IMG_DEV_VIRTADDR DevVAddr;
65 struct BM_MAPPING *pMapping;
71 struct BM_CONTEXT *pBMContext;
72 struct RA_ARENA *pImportArena;
73 struct RA_ARENA *pLocalDevMemArena;
74 struct RA_ARENA *pVMArena;
75 struct DEV_ARENA_DESCRIPTOR sDevArena;
76 struct MMU_HEAP *pMMUHeap;
78 struct BM_HEAP *psNext;
82 struct MMU_CONTEXT *psMMUContext;
83 struct BM_HEAP *psBMHeap;
84 struct BM_HEAP *psBMSharedHeap;
85 struct PVRSRV_DEVICE_NODE *psDeviceNode;
86 struct HASH_TABLE *pBufferHash;
89 struct BM_CONTEXT *psNext;
92 #define BP_POOL_MASK 0x7
94 #define BP_CONTIGUOUS (1 << 3)
95 #define BP_PARAMBUFFER (1 << 4)
97 #define BM_MAX_DEVMEM_ARENAS 2
99 void *BM_CreateContext(struct PVRSRV_DEVICE_NODE *psDeviceNode,
100 struct IMG_DEV_PHYADDR *psPDDevPAddr,
101 struct PVRSRV_PER_PROCESS_DATA *psPerProc,
102 IMG_BOOL *pbCreated);
104 void BM_DestroyContext(void *hBMContext);
106 static inline void pvr_get_ctx(struct BM_CONTEXT *ctx)
108 WARN_ON(!ctx->ui32RefCount);
112 static inline bool pvr_put_ctx(struct BM_CONTEXT *ctx)
114 BUG_ON(!ctx->ui32RefCount);
116 if (!ctx->ui32RefCount) {
117 BM_DestroyContext(ctx);
125 void *BM_CreateHeap(void *hBMContext,
126 struct DEVICE_MEMORY_HEAP_INFO *psDevMemHeapInfo);
127 void BM_DestroyHeap(void *hDevMemHeap);
128 IMG_BOOL BM_Reinitialise(struct PVRSRV_DEVICE_NODE *psDeviceNode);
130 IMG_BOOL BM_Alloc(void *hDevMemHeap,
131 struct IMG_DEV_VIRTADDR *psDevVAddr,
132 size_t uSize, u32 *pui32Flags, u32 uDevVAddrAlignment, void **phBuf);
134 IMG_BOOL BM_Wrap(void *hDevMemHeap,
137 IMG_BOOL bPhysContig,
138 struct IMG_SYS_PHYADDR *psSysAddr,
139 void *pvCPUVAddr, u32 *pui32Flags, void **phBuf);
141 void BM_Free(void *hBuf, u32 ui32Flags);
142 void *BM_HandleToCpuVaddr(void *hBuf);
143 struct IMG_DEV_VIRTADDR BM_HandleToDevVaddr(void *hBuf);
145 struct IMG_SYS_PHYADDR BM_HandleToSysPaddr(void *hBuf);
147 void *BM_HandleToOSMemHandle(void *hBuf);
149 IMG_BOOL BM_ContiguousStatistics(u32 uFlags, u32 *pTotalBytes,
150 u32 *pAvailableBytes);
152 enum PVRSRV_ERROR BM_GetPhysPageAddr(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo,
153 struct IMG_DEV_VIRTADDR sDevVPageAddr,
154 struct IMG_DEV_PHYADDR *psDevPAddr);
156 enum PVRSRV_ERROR BM_GetHeapInfo(void *hDevMemHeap,
157 struct PVRSRV_HEAP_INFO *psHeapInfo);
159 struct MMU_CONTEXT *BM_GetMMUContext(void *hDevMemHeap);
161 struct MMU_CONTEXT *BM_GetMMUContextFromMemContext(void *hDevMemContext);
163 void *BM_GetMMUHeap(void *hDevMemHeap);
165 struct PVRSRV_DEVICE_NODE *BM_GetDeviceNode(void *hDevMemContext);
167 void *BM_GetMappingHandle(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo);
169 struct BM_CONTEXT *bm_find_context(struct BM_CONTEXT *head_context,