1 /*************************************************************************/ /*!
2 @File devicemem_heapcfg.c
3 @Title Temporary Device Memory 2 stuff
4 @Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @Description Device memory management
6 @License Dual MIT/GPLv2
8 The contents of this file are subject to the MIT license as set out below.
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:
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
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.
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.
32 This License is also included in this distribution in the file called
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 */ /***************************************************************************/
44 /* our exported API */
45 #include "devicemem_heapcfg.h"
48 #include "img_types.h"
49 #include "pvr_debug.h"
50 #include "pvrsrv_error.h"
53 #include "connection_server.h"
56 HeapCfgHeapConfigCount(CONNECTION_DATA * psConnection,
57 const PVRSRV_DEVICE_NODE *psDeviceNode,
58 IMG_UINT32 *puiNumHeapConfigsOut
62 PVR_UNREFERENCED_PARAMETER(psConnection);
64 *puiNumHeapConfigsOut = psDeviceNode->sDevMemoryInfo.uiNumHeapConfigs;
70 HeapCfgHeapCount(CONNECTION_DATA * psConnection,
71 const PVRSRV_DEVICE_NODE *psDeviceNode,
72 IMG_UINT32 uiHeapConfigIndex,
73 IMG_UINT32 *puiNumHeapsOut
76 if (uiHeapConfigIndex >= psDeviceNode->sDevMemoryInfo.uiNumHeapConfigs)
78 return PVRSRV_ERROR_DEVICEMEM_INVALID_HEAP_CONFIG_INDEX;
81 *puiNumHeapsOut = psDeviceNode->sDevMemoryInfo.psDeviceMemoryHeapConfigArray[uiHeapConfigIndex].uiNumHeaps;
87 HeapCfgHeapConfigName(CONNECTION_DATA * psConnection,
88 const PVRSRV_DEVICE_NODE *psDeviceNode,
89 IMG_UINT32 uiHeapConfigIndex,
90 IMG_UINT32 uiHeapConfigNameBufSz,
91 IMG_CHAR *pszHeapConfigNameOut
94 if (uiHeapConfigIndex >= psDeviceNode->sDevMemoryInfo.uiNumHeapConfigs)
96 return PVRSRV_ERROR_DEVICEMEM_INVALID_HEAP_CONFIG_INDEX;
99 OSSNPrintf(pszHeapConfigNameOut, uiHeapConfigNameBufSz, "%s", psDeviceNode->sDevMemoryInfo.psDeviceMemoryHeapConfigArray[uiHeapConfigIndex].pszName);
105 HeapCfgHeapDetails(CONNECTION_DATA * psConnection,
106 const PVRSRV_DEVICE_NODE *psDeviceNode,
107 IMG_UINT32 uiHeapConfigIndex,
108 IMG_UINT32 uiHeapIndex,
109 IMG_UINT32 uiHeapNameBufSz,
110 IMG_CHAR *pszHeapNameOut,
111 IMG_DEV_VIRTADDR *psDevVAddrBaseOut,
112 IMG_DEVMEM_SIZE_T *puiHeapLengthOut,
113 IMG_UINT32 *puiLog2DataPageSizeOut,
114 IMG_UINT32 *puiLog2ImportAlignmentOut
117 DEVMEM_HEAP_BLUEPRINT *psHeapBlueprint;
119 if (uiHeapConfigIndex >= psDeviceNode->sDevMemoryInfo.uiNumHeapConfigs)
121 return PVRSRV_ERROR_DEVICEMEM_INVALID_HEAP_CONFIG_INDEX;
124 if (uiHeapIndex >= psDeviceNode->sDevMemoryInfo.psDeviceMemoryHeapConfigArray[uiHeapConfigIndex].uiNumHeaps)
126 return PVRSRV_ERROR_DEVICEMEM_INVALID_HEAP_INDEX;
129 psHeapBlueprint = &psDeviceNode->sDevMemoryInfo.psDeviceMemoryHeapConfigArray[uiHeapConfigIndex].psHeapBlueprintArray[uiHeapIndex];
131 OSSNPrintf(pszHeapNameOut, uiHeapNameBufSz, "%s", psHeapBlueprint->pszName);
132 *psDevVAddrBaseOut = psHeapBlueprint->sHeapBaseAddr;
133 *puiHeapLengthOut = psHeapBlueprint->uiHeapLength;
134 *puiLog2DataPageSizeOut = psHeapBlueprint->uiLog2DataPageSize;
135 *puiLog2ImportAlignmentOut = psHeapBlueprint->uiLog2ImportAlignment;
137 /* REL/1.8 maintain bridge compatibility
138 * 4:0 - uiLog2ImportAlignment (13--20)
139 * 18:16 - uiLog2TilingStrideFactor (3--4)
141 *puiLog2ImportAlignmentOut |= (psHeapBlueprint->uiLog2TilingStrideFactor << 16);