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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
|
/**********************************************************************
*
* Copyright (C) Imagination Technologies Ltd. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful but, except
* as otherwise stated in writing, without any warranty; without even the
* implied warranty of merchantability or fitness for a particular purpose.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
*
* The full GNU General Public License is included in this distribution in
* the file called "COPYING".
*
* Contact Information:
* Imagination Technologies Ltd. <gpl-support@imgtec.com>
* Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK
*
******************************************************************************/
#ifndef _BUFFER_MANAGER_H_
#define _BUFFER_MANAGER_H_
#include "img_types.h"
#include "ra.h"
#include "perproc.h"
#if defined(__cplusplus)
extern "C"{
#endif
typedef struct _BM_HEAP_ BM_HEAP;
struct _BM_MAPPING_
{
enum
{
hm_wrapped = 1,
hm_wrapped_scatter,
hm_wrapped_virtaddr,
hm_wrapped_scatter_virtaddr,
hm_env,
hm_contiguous
} eCpuMemoryOrigin;
BM_HEAP *pBMHeap;
RA_ARENA *pArena;
IMG_CPU_VIRTADDR CpuVAddr;
IMG_CPU_PHYADDR CpuPAddr;
IMG_DEV_VIRTADDR DevVAddr;
IMG_SYS_PHYADDR *psSysAddr;
IMG_SIZE_T uSize;
IMG_HANDLE hOSMemHandle;
IMG_UINT32 ui32Flags;
};
typedef struct _BM_BUF_
{
IMG_CPU_VIRTADDR *CpuVAddr;
IMG_VOID *hOSMemHandle;
IMG_CPU_PHYADDR CpuPAddr;
IMG_DEV_VIRTADDR DevVAddr;
BM_MAPPING *pMapping;
IMG_UINT32 ui32RefCount;
IMG_UINT32 ui32ExportCount;
} BM_BUF;
struct _BM_HEAP_
{
IMG_UINT32 ui32Attribs;
BM_CONTEXT *pBMContext;
RA_ARENA *pImportArena;
RA_ARENA *pLocalDevMemArena;
RA_ARENA *pVMArena;
DEV_ARENA_DESCRIPTOR sDevArena;
MMU_HEAP *pMMUHeap;
PDUMP_MMU_ATTRIB *psMMUAttrib;
struct _BM_HEAP_ *psNext;
struct _BM_HEAP_ **ppsThis;
IMG_UINT32 ui32XTileStride;
};
struct _BM_CONTEXT_
{
MMU_CONTEXT *psMMUContext;
BM_HEAP *psBMHeap;
BM_HEAP *psBMSharedHeap;
PVRSRV_DEVICE_NODE *psDeviceNode;
HASH_TABLE *pBufferHash;
IMG_HANDLE hResItem;
IMG_UINT32 ui32RefCount;
struct _BM_CONTEXT_ *psNext;
struct _BM_CONTEXT_ **ppsThis;
};
typedef struct _XPROC_DATA_{
IMG_UINT32 ui32RefCount;
IMG_UINT32 ui32AllocFlags;
IMG_UINT32 ui32Size;
IMG_UINT32 ui32PageSize;
RA_ARENA *psArena;
IMG_SYS_PHYADDR sSysPAddr;
IMG_VOID *pvCpuVAddr;
IMG_HANDLE hOSMemHandle;
} XPROC_DATA;
extern XPROC_DATA gXProcWorkaroundShareData[];
typedef IMG_VOID *BM_HANDLE;
#define BP_POOL_MASK 0x7
#define BP_CONTIGUOUS (1 << 3)
#define BP_PARAMBUFFER (1 << 4)
#define BM_MAX_DEVMEM_ARENAS 2
IMG_HANDLE
BM_CreateContext(PVRSRV_DEVICE_NODE *psDeviceNode,
IMG_DEV_PHYADDR *psPDDevPAddr,
PVRSRV_PER_PROCESS_DATA *psPerProc,
IMG_BOOL *pbCreated);
PVRSRV_ERROR
BM_DestroyContext (IMG_HANDLE hBMContext,
IMG_BOOL *pbCreated);
IMG_HANDLE
BM_CreateHeap (IMG_HANDLE hBMContext,
DEVICE_MEMORY_HEAP_INFO *psDevMemHeapInfo);
IMG_VOID
BM_DestroyHeap (IMG_HANDLE hDevMemHeap);
IMG_BOOL
BM_Reinitialise (PVRSRV_DEVICE_NODE *psDeviceNode);
IMG_BOOL
BM_Alloc (IMG_HANDLE hDevMemHeap,
IMG_DEV_VIRTADDR *psDevVAddr,
IMG_SIZE_T uSize,
IMG_UINT32 *pui32Flags,
IMG_UINT32 uDevVAddrAlignment,
IMG_PVOID pvPrivData,
IMG_UINT32 ui32PrivDataLength,
BM_HANDLE *phBuf);
IMG_BOOL
BM_Wrap ( IMG_HANDLE hDevMemHeap,
IMG_SIZE_T ui32Size,
IMG_SIZE_T ui32Offset,
IMG_BOOL bPhysContig,
IMG_SYS_PHYADDR *psSysAddr,
IMG_VOID *pvCPUVAddr,
IMG_UINT32 *pui32Flags,
BM_HANDLE *phBuf);
IMG_VOID
BM_Free (BM_HANDLE hBuf,
IMG_UINT32 ui32Flags);
IMG_CPU_VIRTADDR
BM_HandleToCpuVaddr (BM_HANDLE hBuf);
IMG_DEV_VIRTADDR
BM_HandleToDevVaddr (BM_HANDLE hBuf);
IMG_SYS_PHYADDR
BM_HandleToSysPaddr (BM_HANDLE hBuf);
IMG_HANDLE
BM_HandleToOSMemHandle (BM_HANDLE hBuf);
IMG_VOID BM_GetPhysPageAddr(PVRSRV_KERNEL_MEM_INFO *psMemInfo,
IMG_DEV_VIRTADDR sDevVPageAddr,
IMG_DEV_PHYADDR *psDevPAddr);
MMU_CONTEXT* BM_GetMMUContext(IMG_HANDLE hDevMemHeap);
MMU_CONTEXT* BM_GetMMUContextFromMemContext(IMG_HANDLE hDevMemContext);
IMG_HANDLE BM_GetMMUHeap(IMG_HANDLE hDevMemHeap);
PVRSRV_DEVICE_NODE* BM_GetDeviceNode(IMG_HANDLE hDevMemContext);
IMG_HANDLE BM_GetMappingHandle(PVRSRV_KERNEL_MEM_INFO *psMemInfo);
IMG_VOID BM_Export(BM_HANDLE hBuf);
IMG_VOID BM_FreeExport(BM_HANDLE hBuf, IMG_UINT32 ui32Flags);
PVRSRV_ERROR BM_XProcWorkaroundSetShareIndex(IMG_UINT32 ui32Index);
PVRSRV_ERROR BM_XProcWorkaroundUnsetShareIndex(IMG_UINT32 ui32Index);
PVRSRV_ERROR BM_XProcWorkaroundFindNewBufferAndSetShareIndex(IMG_UINT32 *pui32Index);
#if defined(PVRSRV_REFCOUNT_DEBUG)
IMG_VOID _BM_XProcIndexAcquireDebug(const IMG_CHAR *pszFile, IMG_INT iLine, IMG_UINT32 ui32Index);
IMG_VOID _BM_XProcIndexReleaseDebug(const IMG_CHAR *pszFile, IMG_INT iLine, IMG_UINT32 ui32Index);
#define BM_XProcIndexAcquire(x...) \
_BM_XProcIndexAcquireDebug(__FILE__, __LINE__, x)
#define BM_XProcIndexRelease(x...) \
_BM_XProcIndexReleaseDebug(__FILE__, __LINE__, x)
#else
IMG_VOID _BM_XProcIndexAcquire(IMG_UINT32 ui32Index);
IMG_VOID _BM_XProcIndexRelease(IMG_UINT32 ui32Index);
#define BM_XProcIndexAcquire(x...) \
_BM_XProcIndexAcquire( x)
#define BM_XProcIndexRelease(x...) \
_BM_XProcIndexRelease( x)
#endif
#if defined(__cplusplus)
}
#endif
#endif
|