diff options
Diffstat (limited to 'sgx_km/eurasia_km/services4/srvkm/bridged/bridged_support.c')
-rw-r--r-- | sgx_km/eurasia_km/services4/srvkm/bridged/bridged_support.c | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/sgx_km/eurasia_km/services4/srvkm/bridged/bridged_support.c b/sgx_km/eurasia_km/services4/srvkm/bridged/bridged_support.c new file mode 100644 index 0000000..2ccdc66 --- /dev/null +++ b/sgx_km/eurasia_km/services4/srvkm/bridged/bridged_support.c | |||
@@ -0,0 +1,113 @@ | |||
1 | /*************************************************************************/ /*! | ||
2 | @Title PVR Bridge Support Functions | ||
3 | @Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved | ||
4 | @Description User/kernel mode bridge support. The functions in here | ||
5 | may be used beyond the bridge code proper (e.g. Linux | ||
6 | mmap interface). | ||
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 | #include "img_defs.h" | ||
46 | #include "servicesint.h" | ||
47 | #include "bridged_support.h" | ||
48 | |||
49 | |||
50 | /* | ||
51 | * Derive the internal OS specific memory handle from a secure | ||
52 | * handle. | ||
53 | */ | ||
54 | PVRSRV_ERROR | ||
55 | PVRSRVLookupOSMemHandle(PVRSRV_HANDLE_BASE *psHandleBase, IMG_HANDLE *phOSMemHandle, IMG_HANDLE hMHandle) | ||
56 | { | ||
57 | IMG_HANDLE hMHandleInt; | ||
58 | PVRSRV_HANDLE_TYPE eHandleType; | ||
59 | PVRSRV_ERROR eError; | ||
60 | |||
61 | /* | ||
62 | * We don't know the type of the handle at this point, so we use | ||
63 | * PVRSRVLookupHandleAnyType to look it up. | ||
64 | */ | ||
65 | eError = PVRSRVLookupHandleAnyType(psHandleBase, &hMHandleInt, | ||
66 | &eHandleType, | ||
67 | hMHandle); | ||
68 | if(eError != PVRSRV_OK) | ||
69 | { | ||
70 | return eError; | ||
71 | } | ||
72 | |||
73 | switch(eHandleType) | ||
74 | { | ||
75 | #if defined(PVR_SECURE_HANDLES) | ||
76 | case PVRSRV_HANDLE_TYPE_MEM_INFO: | ||
77 | case PVRSRV_HANDLE_TYPE_MEM_INFO_REF: | ||
78 | case PVRSRV_HANDLE_TYPE_SHARED_SYS_MEM_INFO: | ||
79 | { | ||
80 | PVRSRV_KERNEL_MEM_INFO *psMemInfo = (PVRSRV_KERNEL_MEM_INFO *)hMHandleInt; | ||
81 | |||
82 | *phOSMemHandle = psMemInfo->sMemBlk.hOSMemHandle; | ||
83 | |||
84 | break; | ||
85 | } | ||
86 | case PVRSRV_HANDLE_TYPE_SYNC_INFO: | ||
87 | { | ||
88 | PVRSRV_KERNEL_SYNC_INFO *psSyncInfo = (PVRSRV_KERNEL_SYNC_INFO *)hMHandleInt; | ||
89 | PVRSRV_KERNEL_MEM_INFO *psMemInfo = psSyncInfo->psSyncDataMemInfoKM; | ||
90 | |||
91 | *phOSMemHandle = psMemInfo->sMemBlk.hOSMemHandle; | ||
92 | |||
93 | break; | ||
94 | } | ||
95 | case PVRSRV_HANDLE_TYPE_SOC_TIMER: | ||
96 | { | ||
97 | *phOSMemHandle = (IMG_VOID *)hMHandleInt; | ||
98 | break; | ||
99 | } | ||
100 | #else | ||
101 | case PVRSRV_HANDLE_TYPE_NONE: | ||
102 | *phOSMemHandle = (IMG_VOID *)hMHandleInt; | ||
103 | break; | ||
104 | #endif | ||
105 | default: | ||
106 | return PVRSRV_ERROR_BAD_MAPPING; | ||
107 | } | ||
108 | |||
109 | return PVRSRV_OK; | ||
110 | } | ||
111 | /****************************************************************************** | ||
112 | End of file (bridged_support.c) | ||
113 | ******************************************************************************/ | ||