RK3368 GPU: Rogue N Init.
[firefly-linux-kernel-4.4.55.git] / drivers / staging / imgtec / rogue / physmem_osmem.h
1 /**************************************************************************/ /*!
2 @File
3 @Title          PMR implementation of OS derived physical memory
4 @Copyright      Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @Description    Part of the memory management.  This module is
6                 responsible for the an implementation of the "PMR"
7                 abstraction.  This interface is for the
8                 PhysmemNewOSRamBackedPMR() "PMR Factory" which is
9                 responsible for claiming chunks of memory (in
10                 particular physically contiguous quanta) from the
11                 Operating System.
12
13                 As such, this interface will be implemented on a
14                 Per-OS basis, in the "env" directory for that system.
15                 A dummy implementation is available in
16                 physmem_osmem_dummy.c for operating systems that
17                 cannot, or do not wish to, offer this functionality.
18 @License        Dual MIT/GPLv2
19
20 The contents of this file are subject to the MIT license as set out below.
21
22 Permission is hereby granted, free of charge, to any person obtaining a copy
23 of this software and associated documentation files (the "Software"), to deal
24 in the Software without restriction, including without limitation the rights
25 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
26 copies of the Software, and to permit persons to whom the Software is
27 furnished to do so, subject to the following conditions:
28
29 The above copyright notice and this permission notice shall be included in
30 all copies or substantial portions of the Software.
31
32 Alternatively, the contents of this file may be used under the terms of
33 the GNU General Public License Version 2 ("GPL") in which case the provisions
34 of GPL are applicable instead of those above.
35
36 If you wish to allow use of your version of this file only under the terms of
37 GPL, and not to allow others to use your version of this file under the terms
38 of the MIT license, indicate your decision by deleting the provisions above
39 and replace them with the notice and other provisions required by GPL as set
40 out in the file called "GPL-COPYING" included in this distribution. If you do
41 not delete the provisions above, a recipient may use your version of this file
42 under the terms of either the MIT license or GPL.
43
44 This License is also included in this distribution in the file called
45 "MIT-COPYING".
46
47 EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
48 PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
49 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
50 PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
51 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
52 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
53 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
54 */ /***************************************************************************/
55 #ifndef _SRVSRV_PHYSMEM_OSMEM_H_
56 #define _SRVSRV_PHYSMEM_OSMEM_H_
57
58 /* include/ */
59 #include "img_types.h"
60 #include "pvrsrv_error.h"
61 #include "pvrsrv_memallocflags.h"
62
63 /* services/server/include/ */
64 #include "pmr.h"
65 #include "pmr_impl.h"
66
67 /*************************************************************************/ /*!
68 @Function       PhysmemNewOSRamBackedPMR
69 @Description    Rogue Services will call this function to allocate GPU device 
70                 memory from the PMR factory supported by the OS DDK port. This 
71                 factory typically obtains physical memory from the kernel/OS 
72                 API that allocates memory from the default heap of shared system 
73                 memory available on the platform. The allocated memory must be 
74                 page-aligned and be a whole number of pages. 
75                 After allocating the required memory, the implementation must 
76                 then call PMRCreatePMR() to obtain the PMR structure that 
77                 describes this allocation to the upper layers of the Services.
78                 memory management sub-system. 
79                 NB. Implementation of this function is mandatory. If shared 
80                 system memory is not to be used in the OS port then the 
81                 implementation must return PVRSRV_ERROR_NOT_SUPPORTED.
82
83 @Input          psDevNode        the device node
84 @Input          uiSize           the size of the allocation
85                                  (must be a multiple of page size)
86 @Input          uiChunkSize      when sparse allocations are requested,
87                                  this is the allocated chunk size.
88                                  For regular allocations, this will be
89                                  the same as uiSize.
90                                  (must be a multiple of page size)
91 @Input          ui32NumPhysChunks  when sparse allocations are requested,
92                                    this is the number of physical chunks
93                                    to be allocated.
94                                    For regular allocations, this will be 1.
95 @Input          ui32NumVirtChunks  when sparse allocations are requested,
96                                    this is the number of virtual chunks
97                                    covering the sparse allocation.
98                                    For regular allocations, this will be 1.
99 @Input          pui32MappingTable  when sparse allocations are requested,
100                                    this is the list of the indices of
101                                    each physically-backed virtual chunk
102                                    For regular allocations, this will
103                                    be NULL.
104 @Input          uiLog2PageSize   the physical pagesize in log2(bytes).
105 @Input          uiFlags          the allocation flags.
106 @Input          pszAnnotation    string describing the PMR (for debug).
107                                  This should be passed into the function
108                                  PMRCreatePMR().
109 @Output         ppsPMROut        pointer to the PMR created for the
110                                  new allocation
111 @Return         PVRSRV_OK on success, a failure code otherwise.
112 */ /**************************************************************************/
113 extern PVRSRV_ERROR
114 PhysmemNewOSRamBackedPMR(PVRSRV_DEVICE_NODE *psDevNode,
115                          IMG_DEVMEM_SIZE_T uiSize,
116                                                  IMG_DEVMEM_SIZE_T uiChunkSize,
117                                                  IMG_UINT32 ui32NumPhysChunks,
118                                                  IMG_UINT32 ui32NumVirtChunks,
119                                                  IMG_UINT32 *pui32MappingTable,
120                          IMG_UINT32 uiLog2PageSize,
121                          PVRSRV_MEMALLOCFLAGS_T uiFlags,
122                          const IMG_CHAR *pszAnnotation,
123                          PMR **ppsPMROut);
124
125 #endif /* #ifndef _SRVSRV_PHYSMEM_OSMEM_H_ */