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;
90 struct BM_CONTEXT *psNext;
93 #define BP_POOL_MASK 0x7
95 #define BP_CONTIGUOUS (1 << 3)
96 #define BP_PARAMBUFFER (1 << 4)
98 #define BM_MAX_DEVMEM_ARENAS 2
100 void *BM_CreateContext(struct PVRSRV_DEVICE_NODE *psDeviceNode,
101 struct IMG_DEV_PHYADDR *psPDDevPAddr,
102 struct PVRSRV_PER_PROCESS_DATA *psPerProc,
103 IMG_BOOL *pbCreated);
105 void BM_DestroyContext(void *hBMContext);
107 static inline void pvr_get_ctx(struct BM_CONTEXT *ctx)
109 WARN_ON(!ctx->ui32RefCount);
113 static inline bool pvr_put_ctx(struct BM_CONTEXT *ctx)
115 BUG_ON(!ctx->ui32RefCount);
117 if (!ctx->ui32RefCount) {
118 BM_DestroyContext(ctx);
126 void *BM_CreateHeap(void *hBMContext,
127 struct DEVICE_MEMORY_HEAP_INFO *psDevMemHeapInfo);
128 void BM_DestroyHeap(void *hDevMemHeap);
129 IMG_BOOL BM_Reinitialise(struct PVRSRV_DEVICE_NODE *psDeviceNode);
131 IMG_BOOL BM_Alloc(void *hDevMemHeap,
132 struct IMG_DEV_VIRTADDR *psDevVAddr,
133 size_t uSize, u32 *pui32Flags, u32 uDevVAddrAlignment, void **phBuf);
135 IMG_BOOL BM_Wrap(void *hDevMemHeap,
138 IMG_BOOL bPhysContig,
139 struct IMG_SYS_PHYADDR *psSysAddr,
140 void *pvCPUVAddr, u32 *pui32Flags, void **phBuf);
142 void BM_Free(void *hBuf, u32 ui32Flags);
143 void *BM_HandleToCpuVaddr(void *hBuf);
144 struct IMG_DEV_VIRTADDR BM_HandleToDevVaddr(void *hBuf);
146 struct IMG_SYS_PHYADDR BM_HandleToSysPaddr(void *hBuf);
148 void *BM_HandleToOSMemHandle(void *hBuf);
150 IMG_BOOL BM_ContiguousStatistics(u32 uFlags, u32 *pTotalBytes,
151 u32 *pAvailableBytes);
153 enum PVRSRV_ERROR BM_GetPhysPageAddr(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo,
154 struct IMG_DEV_VIRTADDR sDevVPageAddr,
155 struct IMG_DEV_PHYADDR *psDevPAddr);
157 enum PVRSRV_ERROR BM_GetHeapInfo(void *hDevMemHeap,
158 struct PVRSRV_HEAP_INFO *psHeapInfo);
160 struct MMU_CONTEXT *BM_GetMMUContext(void *hDevMemHeap);
162 struct MMU_CONTEXT *BM_GetMMUContextFromMemContext(void *hDevMemContext);
164 void *BM_GetMMUHeap(void *hDevMemHeap);
166 struct PVRSRV_DEVICE_NODE *BM_GetDeviceNode(void *hDevMemContext);
168 void *BM_GetMappingHandle(struct PVRSRV_KERNEL_MEM_INFO *psMemInfo);
170 struct BM_CONTEXT *bm_find_context(struct BM_CONTEXT *head_context,