]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android-sdk/device-ti-proprietary-open.git/blob - omap5/sgx_src/eurasia_km/services4/srvkm/include/refcount.h
jacinto6: sgx: add memtrack library
[android-sdk/device-ti-proprietary-open.git] / omap5 / sgx_src / eurasia_km / services4 / srvkm / include / refcount.h
1 /*************************************************************************/ /*!
2 @Title          Services reference count debugging
3 @Copyright      Copyright (c) Imagination Technologies Ltd. All Rights Reserved
4 @License        Dual MIT/GPLv2
6 The contents of this file are subject to the MIT license as set out below.
8 Permission is hereby granted, free of charge, to any person obtaining a copy
9 of this software and associated documentation files (the "Software"), to deal
10 in the Software without restriction, including without limitation the rights
11 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 copies of the Software, and to permit persons to whom the Software is
13 furnished to do so, subject to the following conditions:
15 The above copyright notice and this permission notice shall be included in
16 all copies or substantial portions of the Software.
18 Alternatively, the contents of this file may be used under the terms of
19 the GNU General Public License Version 2 ("GPL") in which case the provisions
20 of GPL are applicable instead of those above.
22 If you wish to allow use of your version of this file only under the terms of
23 GPL, and not to allow others to use your version of this file under the terms
24 of the MIT license, indicate your decision by deleting the provisions above
25 and replace them with the notice and other provisions required by GPL as set
26 out in the file called "GPL-COPYING" included in this distribution. If you do
27 not delete the provisions above, a recipient may use your version of this file
28 under the terms of either the MIT license or GPL.
30 This License is also included in this distribution in the file called
31 "MIT-COPYING".
33 EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
34 PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
35 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
36 PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
37 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
38 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
39 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
40 */ /**************************************************************************/
42 #ifndef __REFCOUNT_H__
43 #define __REFCOUNT_H__
45 #include "pvr_bridge_km.h"
47 #if defined(PVRSRV_REFCOUNT_DEBUG)
49 void PVRSRVDumpRefCountCCB(void);
51 #define PVRSRVKernelSyncInfoIncRef(x...) \
52         PVRSRVKernelSyncInfoIncRef2(__FILE__, __LINE__, x)
53 #define PVRSRVKernelSyncInfoDecRef(x...) \
54         PVRSRVKernelSyncInfoDecRef2(__FILE__, __LINE__, x)
55 #define PVRSRVKernelMemInfoIncRef(x...) \
56         PVRSRVKernelMemInfoIncRef2(__FILE__, __LINE__, x)
57 #define PVRSRVKernelMemInfoDecRef(x...) \
58         PVRSRVKernelMemInfoDecRef2(__FILE__, __LINE__, x)
59 #define PVRSRVBMBufIncRef(x...) \
60         PVRSRVBMBufIncRef2(__FILE__, __LINE__, x)
61 #define PVRSRVBMBufDecRef(x...) \
62         PVRSRVBMBufDecRef2(__FILE__, __LINE__, x)
63 #define PVRSRVBMBufIncExport(x...) \
64         PVRSRVBMBufIncExport2(__FILE__, __LINE__, x)
65 #define PVRSRVBMBufDecExport(x...) \
66         PVRSRVBMBufDecExport2(__FILE__, __LINE__, x)
68 void PVRSRVKernelSyncInfoIncRef2(const IMG_CHAR *pszFile, IMG_INT iLine,
69                                                                  PVRSRV_KERNEL_SYNC_INFO *psKernelSyncInfo,
70                                                                  PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo);
71 void PVRSRVKernelSyncInfoDecRef2(const IMG_CHAR *pszFile, IMG_INT iLine,
72                                                                  PVRSRV_KERNEL_SYNC_INFO *psKernelSyncInfo,
73                                                                  PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo);
74 void PVRSRVKernelMemInfoIncRef2(const IMG_CHAR *pszFile, IMG_INT iLine,
75                                                                 PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo);
76 void PVRSRVKernelMemInfoDecRef2(const IMG_CHAR *pszFile, IMG_INT iLine,
77                                                                 PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo);
78 void PVRSRVBMBufIncRef2(const IMG_CHAR *pszFile,
79                                                 IMG_INT iLine, BM_BUF *pBuf);
80 void PVRSRVBMBufDecRef2(const IMG_CHAR *pszFile,
81                                                 IMG_INT iLine, BM_BUF *pBuf);
82 void PVRSRVBMBufIncExport2(const IMG_CHAR *pszFile,
83                                                    IMG_INT iLine, BM_BUF *pBuf);
84 void PVRSRVBMBufDecExport2(const IMG_CHAR *pszFile,
85                                                    IMG_INT iLine, BM_BUF *pBuf);
86 void PVRSRVBMXProcIncRef2(const IMG_CHAR *pszFile, IMG_INT iLine,
87                                                   IMG_UINT32 ui32Index);
88 void PVRSRVBMXProcDecRef2(const IMG_CHAR *pszFile, IMG_INT iLine,
89                                                   IMG_UINT32 ui32Index);
91 #if defined(__linux__)
93 /* mmap refcounting is Linux specific */
94 #include "mmap.h"
96 #define PVRSRVOffsetStructIncRef(x...) \
97         PVRSRVOffsetStructIncRef2(__FILE__, __LINE__, x)
98 #define PVRSRVOffsetStructDecRef(x...) \
99         PVRSRVOffsetStructDecRef2(__FILE__, __LINE__, x)
100 #define PVRSRVOffsetStructIncMapped(x...) \
101         PVRSRVOffsetStructIncMapped2(__FILE__, __LINE__, x)
102 #define PVRSRVOffsetStructDecMapped(x...) \
103         PVRSRVOffsetStructDecMapped2(__FILE__, __LINE__, x)
105 void PVRSRVOffsetStructIncRef2(const IMG_CHAR *pszFile, IMG_INT iLine,
106                                                            PKV_OFFSET_STRUCT psOffsetStruct);
107 void PVRSRVOffsetStructDecRef2(const IMG_CHAR *pszFile, IMG_INT iLine,
108                                                            PKV_OFFSET_STRUCT psOffsetStruct);
109 void PVRSRVOffsetStructIncMapped2(const IMG_CHAR *pszFile, IMG_INT iLine,
110                                                                   PKV_OFFSET_STRUCT psOffsetStruct);
111 void PVRSRVOffsetStructDecMapped2(const IMG_CHAR *pszFile, IMG_INT iLine,
112                                                                   PKV_OFFSET_STRUCT psOffsetStruct);
114 #endif /* defined(__linux__) */
116 #else /* defined(PVRSRV_REFCOUNT_DEBUG) */
118 static INLINE void PVRSRVDumpRefCountCCB(void) { }
120 static INLINE void PVRSRVKernelSyncInfoIncRef(PVRSRV_KERNEL_SYNC_INFO *psKernelSyncInfo,
121                                                                 PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo)
123         PVR_UNREFERENCED_PARAMETER(psKernelMemInfo);
124         PVRSRVAcquireSyncInfoKM(psKernelSyncInfo);
127 static INLINE void PVRSRVKernelSyncInfoDecRef(PVRSRV_KERNEL_SYNC_INFO *psKernelSyncInfo,
128                                                                 PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo)
130         PVR_UNREFERENCED_PARAMETER(psKernelMemInfo);
131         PVRSRVReleaseSyncInfoKM(psKernelSyncInfo);
134 static INLINE void PVRSRVKernelMemInfoIncRef(PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo)
136         psKernelMemInfo->ui32RefCount++;
139 static INLINE void PVRSRVKernelMemInfoDecRef(PVRSRV_KERNEL_MEM_INFO *psKernelMemInfo)
141         psKernelMemInfo->ui32RefCount--;
144 static INLINE void PVRSRVBMBufIncRef(BM_BUF *pBuf)
146         pBuf->ui32RefCount++;
149 static INLINE void PVRSRVBMBufDecRef(BM_BUF *pBuf)
151         pBuf->ui32RefCount--;
154 static INLINE void PVRSRVBMBufIncExport(BM_BUF *pBuf)
156         pBuf->ui32ExportCount++;
159 static INLINE void PVRSRVBMBufDecExport(BM_BUF *pBuf)
161         pBuf->ui32ExportCount--;
164 static INLINE void PVRSRVBMXProcIncRef(IMG_UINT32 ui32Index)
166         gXProcWorkaroundShareData[ui32Index].ui32RefCount++;
169 static INLINE void PVRSRVBMXProcDecRef(IMG_UINT32 ui32Index)
171         gXProcWorkaroundShareData[ui32Index].ui32RefCount--;
174 #if defined(__linux__)
176 /* mmap refcounting is Linux specific */
177 #include "mmap.h"
179 static INLINE void PVRSRVOffsetStructIncRef(PKV_OFFSET_STRUCT psOffsetStruct)
181         psOffsetStruct->ui32RefCount++;
184 static INLINE void PVRSRVOffsetStructDecRef(PKV_OFFSET_STRUCT psOffsetStruct)
186         psOffsetStruct->ui32RefCount--;
189 static INLINE void PVRSRVOffsetStructIncMapped(PKV_OFFSET_STRUCT psOffsetStruct)
191         psOffsetStruct->ui32Mapped++;
194 static INLINE void PVRSRVOffsetStructDecMapped(PKV_OFFSET_STRUCT psOffsetStruct)
196         psOffsetStruct->ui32Mapped--;
199 #endif /* defined(__linux__) */
201 #endif /* defined(PVRSRV_REFCOUNT_DEBUG) */
203 #endif /* __REFCOUNT_H__ */