try to make ABI compatible with TI 1.4.14.2616/4_00_00_01 release
[sgx.git] / pvr / ra.h
1 /**********************************************************************
2  *
3  * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved.
4  *
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.
8  *
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.
13  *
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.
17  *
18  * The full GNU General Public License is included in this distribution in
19  * the file called "COPYING".
20  *
21  * Contact Information:
22  * Imagination Technologies Ltd. <gpl-support@imgtec.com>
23  * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK
24  *
25  ******************************************************************************/
26
27 #ifndef _RA_H_
28 #define _RA_H_
29
30 #include "img_types.h"
31 #include "hash.h"
32 #include "osfunc.h"
33
34 struct RA_ARENA;
35 struct BM_MAPPING;
36
37 #define RA_STATS
38
39 struct RA_STATISTICS {
40         u32 uSpanCount;
41         u32 uLiveSegmentCount;
42         u32 uFreeSegmentCount;
43         u32 uTotalResourceCount;
44         u32 uFreeResourceCount;
45         u32 uCumulativeAllocs;
46         u32 uCumulativeFrees;
47         u32 uImportCount;
48         u32 uExportCount;
49 };
50 struct RA_STATISTICS;
51
52 struct RA_SEGMENT_DETAILS {
53         u32 uiSize;
54         struct IMG_CPU_PHYADDR sCpuPhyAddr;
55         void *hSegment;
56 };
57 struct RA_SEGMENT_DETAILS;
58
59 struct RA_ARENA *RA_Create(char *name, u32 base, size_t uSize,
60                            struct BM_MAPPING *psMapping, size_t uQuantum,
61                            IMG_BOOL(*imp_alloc)(void *_h, size_t uSize,
62                                                 size_t *pActualSize,
63                                                 struct BM_MAPPING **ppsMapping,
64                                                 u32 uFlags, u32 *pBase),
65                            void (*imp_free)(void *, u32, struct BM_MAPPING *),
66                            void (*backingstore_free)(void *, u32, u32, void *),
67                            void *import_handle);
68
69 void RA_Delete(struct RA_ARENA *pArena);
70
71 IMG_BOOL RA_TestDelete(struct RA_ARENA *pArena);
72
73 IMG_BOOL RA_Add(struct RA_ARENA *pArena, u32 base, size_t uSize);
74
75 IMG_BOOL RA_Alloc(struct RA_ARENA *pArena, size_t uSize,
76          struct BM_MAPPING **ppsMapping, u32 uFlags, u32 uAlignment,
77          u32 *pBase);
78
79 void RA_Free(struct RA_ARENA *pArena, u32 base, IMG_BOOL bFreeBackingStore);
80
81 #ifdef RA_STATS
82
83 #define CHECK_SPACE(total)                              \
84 {                                                       \
85         if (total < 100)                                \
86                 return PVRSRV_ERROR_INVALID_PARAMS;     \
87 }
88
89 #define UPDATE_SPACE(str, count, total)                 \
90 {                                                       \
91         if (count == -1)                                \
92                 return PVRSRV_ERROR_INVALID_PARAMS;     \
93         else {                                          \
94                 str += count;                           \
95                 total -= count;                         \
96         }                                               \
97 }
98
99 IMG_BOOL RA_GetNextLiveSegment(void *hArena,
100                                struct RA_SEGMENT_DETAILS *psSegDetails);
101
102 enum PVRSRV_ERROR RA_GetStats(struct RA_ARENA *pArena, char **ppszStr,
103                                 u32 *pui32StrLen);
104
105 #endif
106
107 #endif