RK3368 GPU: Rogue N Init.
[firefly-linux-kernel-4.4.55.git] / drivers / staging / imgtec / rogue / osmmap.h
1 /*************************************************************************/ /*!
2 @File
3 @Title          OS Interface for mapping PMRs into CPU space.
4 @Copyright      Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @Description    OS abstraction for the mmap2 interface for mapping PMRs into
6                 User Mode memory
7 @License        Dual MIT/GPLv2
8
9 The contents of this file are subject to the MIT license as set out below.
10
11 Permission is hereby granted, free of charge, to any person obtaining a copy
12 of this software and associated documentation files (the "Software"), to deal
13 in the Software without restriction, including without limitation the rights
14 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 copies of the Software, and to permit persons to whom the Software is
16 furnished to do so, subject to the following conditions:
17
18 The above copyright notice and this permission notice shall be included in
19 all copies or substantial portions of the Software.
20
21 Alternatively, the contents of this file may be used under the terms of
22 the GNU General Public License Version 2 ("GPL") in which case the provisions
23 of GPL are applicable instead of those above.
24
25 If you wish to allow use of your version of this file only under the terms of
26 GPL, and not to allow others to use your version of this file under the terms
27 of the MIT license, indicate your decision by deleting the provisions above
28 and replace them with the notice and other provisions required by GPL as set
29 out in the file called "GPL-COPYING" included in this distribution. If you do
30 not delete the provisions above, a recipient may use your version of this file
31 under the terms of either the MIT license or GPL.
32
33 This License is also included in this distribution in the file called
34 "MIT-COPYING".
35
36 EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
37 PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
38 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
39 PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
40 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
41 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
42 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
43 */ /**************************************************************************/
44
45 #ifndef _OSMMAP_H_
46 #define _OSMMAP_H_
47
48 #include <powervr/mem_types.h>
49
50 #include "img_types.h"
51 #include "pvrsrv_error.h"
52
53 /**************************************************************************/ /*!
54 @Function       OSMMapPMR
55 @Description    Maps the specified PMR into CPU memory so that it may be
56                 accessed by the user process.
57                 Whether the memory is mapped read only, read/write, or not at
58                 all, is dependent on the PMR itself.
59                 The PMR handle is opaque to the user, and lower levels of this
60                 stack ensure that the handle is private to this process, such that
61                 this API cannot be abused to gain access to other people's PMRs.
62                 The OS implementation of this function should return the virtual
63                 address and length for the User to use. The "PrivData" is to be
64                 stored opaquely by the caller (N.B. he should make no assumptions,
65                 in particular, NULL is a valid handle) and given back to the
66                 call to OSMUnmapPMR.
67                 The OS implementation is free to use the PrivData handle for any
68                 purpose it sees fit.
69 @Input          hBridge              The bridge handle.
70 @Input          hPMR                 The handle of the PMR to be mapped.
71 @Input          uiPMRLength          The size of the PMR.
72 @Input          uiFlags              Flags indicating how the mapping should
73                                      be done (read-only, etc). These may not
74                                      be honoured if the PMR does not permit
75                                      them.
76 @Input          uiPMRLength          The size of the PMR.
77 @Output         phOSMMapPrivDataOut  Returned private data.
78 @Output         ppvMappingAddressOut The returned mapping.
79 @Output         puiMappingLengthOut  The size of the returned mapping.
80 @Return         PVRSRV_OK on success, failure code otherwise.
81  */ /**************************************************************************/
82 extern PVRSRV_ERROR
83 OSMMapPMR(IMG_HANDLE hBridge,
84           IMG_HANDLE hPMR,
85           IMG_DEVMEM_SIZE_T uiPMRLength,
86           IMG_UINT32 uiFlags,
87           IMG_HANDLE *phOSMMapPrivDataOut,
88           void **ppvMappingAddressOut,
89           size_t *puiMappingLengthOut);
90
91 /**************************************************************************/ /*!
92 @Function       OSMUnmapPMR
93 @Description    Unmaps the specified PMR from CPU memory.
94                 This function is the counterpart to OSMMapPMR.
95                 The caller is required to pass the PMR handle back in along
96                 with the same 3-tuple of information that was returned by the
97                 call to OSMMapPMR in phOSMMapPrivDataOut.
98                 It is possible to unmap only part of the original mapping
99                 with this call, by specifying only the address range to be
100                 unmapped in pvMappingAddress and uiMappingLength.
101 @Input          hBridge              The bridge handle.
102 @Input          hPMR                 The handle of the PMR to be unmapped.
103 @Input          hOSMMapPrivData      The OS private data of the mapping.
104 @Input          pvMappingAddress     The address to be unmapped.
105 @Input          uiMappingLength      The size to be unmapped.
106 @Return         PVRSRV_OK on success, failure code otherwise.
107  */ /**************************************************************************/
108 /*
109    FIXME:
110    perhaps this function should take _only_ the hOSMMapPrivData arg,
111    and the implementation is required to store any of the other data
112    items that it requires to do the unmap?
113 */
114 extern void
115 OSMUnmapPMR(IMG_HANDLE hBridge,
116             IMG_HANDLE hPMR,
117             IMG_HANDLE hOSMMapPrivData,
118             void *pvMappingAddress,
119             size_t uiMappingLength);
120
121
122 #endif /* _OSMMAP_H_ */
123