RK3368 GPU version Rogue M 1.28
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / rogue_m / services / include / physheap.h
1 /*************************************************************************/ /*!
2 @File
3 @Title          Physcial heap management header
4 @Copyright      Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @Description    Defines the interface for the physical heap management
6 @License        Dual MIT/GPLv2
7
8 The contents of this file are subject to the MIT license as set out below.
9
10 Permission is hereby granted, free of charge, to any person obtaining a copy
11 of this software and associated documentation files (the "Software"), to deal
12 in the Software without restriction, including without limitation the rights
13 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 copies of the Software, and to permit persons to whom the Software is
15 furnished to do so, subject to the following conditions:
16
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19
20 Alternatively, the contents of this file may be used under the terms of
21 the GNU General Public License Version 2 ("GPL") in which case the provisions
22 of GPL are applicable instead of those above.
23
24 If you wish to allow use of your version of this file only under the terms of
25 GPL, and not to allow others to use your version of this file under the terms
26 of the MIT license, indicate your decision by deleting the provisions above
27 and replace them with the notice and other provisions required by GPL as set
28 out in the file called "GPL-COPYING" included in this distribution. If you do
29 not delete the provisions above, a recipient may use your version of this file
30 under the terms of either the MIT license or GPL.
31
32 This License is also included in this distribution in the file called
33 "MIT-COPYING".
34
35 EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
36 PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
37 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
38 PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
39 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
40 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
41 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
42 */ /**************************************************************************/
43
44 #include "img_types.h"
45 #include "pvrsrv_error.h"
46
47 #ifndef _PHYSHEAP_H_
48 #define _PHYSHEAP_H_
49
50 typedef struct _PHYS_HEAP_ PHYS_HEAP;
51
52 typedef IMG_VOID (*CpuPAddrToDevPAddr)(IMG_HANDLE hPrivData,
53                                                                            IMG_UINT32 ui32NumOfAddr,
54                                                                            IMG_DEV_PHYADDR *psDevPAddr,
55                                                                            IMG_CPU_PHYADDR *psCpuPAddr);
56
57 typedef IMG_VOID (*DevPAddrToCpuPAddr)(IMG_HANDLE hPrivData,
58                                                                            IMG_UINT32 ui32NumOfAddr,
59                                                                            IMG_CPU_PHYADDR *psCpuPAddr,
60                                                                            IMG_DEV_PHYADDR *psDevPAddr);
61
62 typedef struct _PHYS_HEAP_FUNCTIONS_
63 {
64         /*! Translate CPU physical address to device physical address */
65         CpuPAddrToDevPAddr      pfnCpuPAddrToDevPAddr;
66         /*! Translate device physical address to CPU physical address */
67         DevPAddrToCpuPAddr      pfnDevPAddrToCpuPAddr;
68 } PHYS_HEAP_FUNCTIONS;
69
70 typedef enum _PHYS_HEAP_TYPE_
71 {
72         PHYS_HEAP_TYPE_UNKNOWN = 0,
73         PHYS_HEAP_TYPE_UMA,
74         PHYS_HEAP_TYPE_LMA,
75 } PHYS_HEAP_TYPE;
76
77 typedef struct _PHYS_HEAP_CONFIG_
78 {
79         IMG_UINT32                              ui32PhysHeapID;
80         PHYS_HEAP_TYPE                  eType;
81         /*
82                 Note:
83                 sStartAddr and uiSize are only required for LMA heaps
84         */
85         IMG_CPU_PHYADDR                 sStartAddr;
86         IMG_UINT64                              uiSize;
87         IMG_CHAR                                *pszPDumpMemspaceName;
88         PHYS_HEAP_FUNCTIONS             *psMemFuncs;
89         IMG_HANDLE                              hPrivData;
90 } PHYS_HEAP_CONFIG;
91
92 PVRSRV_ERROR PhysHeapRegister(PHYS_HEAP_CONFIG *psConfig,
93                                                           PHYS_HEAP **ppsPhysHeap);
94
95 IMG_VOID PhysHeapUnregister(PHYS_HEAP *psPhysHeap);
96
97 PVRSRV_ERROR PhysHeapAcquire(IMG_UINT32 ui32PhysHeapID,
98                                                          PHYS_HEAP **ppsPhysHeap);
99
100 IMG_VOID PhysHeapRelease(PHYS_HEAP *psPhysHeap);
101
102 PHYS_HEAP_TYPE PhysHeapGetType(PHYS_HEAP *psPhysHeap);
103
104 PVRSRV_ERROR PhysHeapGetAddress(PHYS_HEAP *psPhysHeap,
105                                                                 IMG_CPU_PHYADDR *psCpuPAddr);
106
107 PVRSRV_ERROR PhysHeapGetSize(PHYS_HEAP *psPhysHeap,
108                                                      IMG_UINT64 *puiSize);
109
110 IMG_VOID PhysHeapCpuPAddrToDevPAddr(PHYS_HEAP *psPhysHeap,
111                                                                         IMG_UINT32 ui32NumOfAddr,
112                                                                         IMG_DEV_PHYADDR *psDevPAddr,
113                                                                         IMG_CPU_PHYADDR *psCpuPAddr);
114 IMG_VOID PhysHeapDevPAddrToCpuPAddr(PHYS_HEAP *psPhysHeap,
115                                                                         IMG_UINT32 ui32NumOfAddr,
116                                                                         IMG_CPU_PHYADDR *psCpuPAddr,
117                                                                         IMG_DEV_PHYADDR *psDevPAddr);
118
119 IMG_CHAR *PhysHeapPDumpMemspaceName(PHYS_HEAP *psPhysHeap);
120
121 PVRSRV_ERROR PhysHeapInit(IMG_VOID);
122 PVRSRV_ERROR PhysHeapDeinit(IMG_VOID);
123
124 #endif /* _PHYSHEAP_H_ */