diff options
Diffstat (limited to 'drivers/gpu/pvr/osperproc.c')
-rw-r--r-- | drivers/gpu/pvr/osperproc.c | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/drivers/gpu/pvr/osperproc.c b/drivers/gpu/pvr/osperproc.c new file mode 100644 index 00000000000..882234f5df5 --- /dev/null +++ b/drivers/gpu/pvr/osperproc.c | |||
@@ -0,0 +1,113 @@ | |||
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 | #include "services_headers.h" | ||
28 | #include "osperproc.h" | ||
29 | |||
30 | #include "env_perproc.h" | ||
31 | #include "proc.h" | ||
32 | |||
33 | extern IMG_UINT32 gui32ReleasePID; | ||
34 | |||
35 | PVRSRV_ERROR OSPerProcessPrivateDataInit(IMG_HANDLE *phOsPrivateData) | ||
36 | { | ||
37 | PVRSRV_ERROR eError; | ||
38 | IMG_HANDLE hBlockAlloc; | ||
39 | PVRSRV_ENV_PER_PROCESS_DATA *psEnvPerProc; | ||
40 | |||
41 | eError = OSAllocMem(PVRSRV_OS_NON_PAGEABLE_HEAP, | ||
42 | sizeof(PVRSRV_ENV_PER_PROCESS_DATA), | ||
43 | phOsPrivateData, | ||
44 | &hBlockAlloc, | ||
45 | "Environment per Process Data"); | ||
46 | |||
47 | if (eError != PVRSRV_OK) | ||
48 | { | ||
49 | *phOsPrivateData = IMG_NULL; | ||
50 | |||
51 | PVR_DPF((PVR_DBG_ERROR, "%s: OSAllocMem failed (%d)", __FUNCTION__, eError)); | ||
52 | return eError; | ||
53 | } | ||
54 | |||
55 | psEnvPerProc = (PVRSRV_ENV_PER_PROCESS_DATA *)*phOsPrivateData; | ||
56 | OSMemSet(psEnvPerProc, 0, sizeof(*psEnvPerProc)); | ||
57 | |||
58 | psEnvPerProc->hBlockAlloc = hBlockAlloc; | ||
59 | |||
60 | |||
61 | LinuxMMapPerProcessConnect(psEnvPerProc); | ||
62 | |||
63 | #if defined(SUPPORT_DRI_DRM) && defined(PVR_SECURE_DRM_AUTH_EXPORT) | ||
64 | |||
65 | INIT_LIST_HEAD(&psEnvPerProc->sDRMAuthListHead); | ||
66 | #endif | ||
67 | |||
68 | return PVRSRV_OK; | ||
69 | } | ||
70 | |||
71 | PVRSRV_ERROR OSPerProcessPrivateDataDeInit(IMG_HANDLE hOsPrivateData) | ||
72 | { | ||
73 | PVRSRV_ERROR eError; | ||
74 | PVRSRV_ENV_PER_PROCESS_DATA *psEnvPerProc; | ||
75 | |||
76 | if (hOsPrivateData == IMG_NULL) | ||
77 | { | ||
78 | return PVRSRV_OK; | ||
79 | } | ||
80 | |||
81 | psEnvPerProc = (PVRSRV_ENV_PER_PROCESS_DATA *)hOsPrivateData; | ||
82 | |||
83 | |||
84 | LinuxMMapPerProcessDisconnect(psEnvPerProc); | ||
85 | |||
86 | |||
87 | RemovePerProcessProcDir(psEnvPerProc); | ||
88 | |||
89 | eError = OSFreeMem(PVRSRV_OS_NON_PAGEABLE_HEAP, | ||
90 | sizeof(PVRSRV_ENV_PER_PROCESS_DATA), | ||
91 | hOsPrivateData, | ||
92 | psEnvPerProc->hBlockAlloc); | ||
93 | |||
94 | |||
95 | if (eError != PVRSRV_OK) | ||
96 | { | ||
97 | PVR_DPF((PVR_DBG_ERROR, "%s: OSFreeMem failed (%d)", __FUNCTION__, eError)); | ||
98 | } | ||
99 | |||
100 | return PVRSRV_OK; | ||
101 | } | ||
102 | |||
103 | PVRSRV_ERROR OSPerProcessSetHandleOptions(PVRSRV_HANDLE_BASE *psHandleBase) | ||
104 | { | ||
105 | return LinuxMMapPerProcessHandleOptions(psHandleBase); | ||
106 | } | ||
107 | |||
108 | IMG_HANDLE LinuxTerminatingProcessPrivateData(IMG_VOID) | ||
109 | { | ||
110 | if(!gui32ReleasePID) | ||
111 | return NULL; | ||
112 | return PVRSRVPerProcessPrivateData(gui32ReleasePID); | ||
113 | } | ||