1 /**************************************************************************/ /*!
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 #ifndef __DEVICEMEMHEAPCFG_H__
45 #define __DEVICEMEMHEAPCFG_H__
47 #include "img_types.h"
48 #include "pvrsrv_error.h"
50 /* FIXME: Find a better way of defining _PVRSRV_DEVICE_NODE_ */
51 struct _PVRSRV_DEVICE_NODE_;
54 A "heap config" is a blueprint to be used for initial setting up of
55 heaps when a device memory context is created.
57 We define a data structure to define this, but it's really down to
58 the caller to populate it. This is all expected to be in-kernel.
59 We provide an API that client code can use to enquire about the
60 blueprint, such that it may do the heap setup during the context
61 creation call on behalf of the user */
63 /* blueprint for a single heap */
64 typedef struct _DEVMEM_HEAP_BLUEPRINT_
66 /* Name of this heap - for debug purposes, and perhaps for lookup
68 const IMG_CHAR *pszName;
70 /* Virtual address of the beginning of the heap. This _must_ be a
71 multiple of the data page size for the heap. It is
72 _recommended_ that it be coarser than that - especially, it
73 should begin on a boundary appropriate to the MMU for the
74 device. For Rogue, this is a Page Directory boundary, or 1GB
75 (virtual address a multiple of 0x0040000000). */
76 IMG_DEV_VIRTADDR sHeapBaseAddr;
78 /* Length of the heap. Given that the END address of the heap has
79 a similar restriction to that of the _beginning_ of the heap.
80 That is the heap length _must_ be a whole number of data pages.
81 Again, the recommendation is that it ends on a 1GB boundary.
82 Again, this is not essential, but we do know that (at the time
83 of writing) the current implementation of mmu_common.c is such
84 that no two heaps may share a page directory, thus the
85 remaining virtual space would be wasted if the length were not
87 IMG_DEVMEM_SIZE_T uiHeapLength;
89 /* Data page size. This is the page size that is going to get
90 programmed into the MMU, so it needs to be a valid one for the
91 device. Importantly, the start address and length _must_ be
92 multiples of this page size. Note that the page size is
93 specified as the log 2 relative to 1 byte (e.g. 12 indicates
95 IMG_UINT32 uiLog2DataPageSize;
97 /* Import alignment. Force imports to this heap to be
98 aligned to at least this value */
99 IMG_UINT32 uiLog2ImportAlignment;
100 } DEVMEM_HEAP_BLUEPRINT;
102 /* entire named heap config */
103 typedef struct _DEVMEM_HEAP_CONFIG_
105 /* Name of this heap config - for debug and maybe lookup */
106 const IMG_CHAR *pszName;
108 /* Number of heaps in this config */
109 IMG_UINT32 uiNumHeaps;
111 /* Array of individual heap blueprints as defined above */
112 DEVMEM_HEAP_BLUEPRINT *psHeapBlueprintArray;
113 } DEVMEM_HEAP_CONFIG;
117 HeapCfgHeapConfigCount(
118 const struct _PVRSRV_DEVICE_NODE_ *psDeviceNode,
119 IMG_UINT32 *puiNumHeapConfigsOut
124 const struct _PVRSRV_DEVICE_NODE_ *psDeviceNode,
125 IMG_UINT32 uiHeapConfigIndex,
126 IMG_UINT32 *puiNumHeapsOut
130 HeapCfgHeapConfigName(
131 const struct _PVRSRV_DEVICE_NODE_ *psDeviceNode,
132 IMG_UINT32 uiHeapConfigIndex,
133 IMG_UINT32 uiHeapConfigNameBufSz,
134 IMG_CHAR *pszHeapConfigNameOut
139 const struct _PVRSRV_DEVICE_NODE_ *psDeviceNode,
140 IMG_UINT32 uiHeapConfigIndex,
141 IMG_UINT32 uiHeapIndex,
142 IMG_UINT32 uiHeapNameBufSz,
143 IMG_CHAR *pszHeapNameOut,
144 IMG_DEV_VIRTADDR *psDevVAddrBaseOut,
145 IMG_DEVMEM_SIZE_T *puiHeapLengthOut,
146 IMG_UINT32 *puiLog2DataPageSizeOut,
147 IMG_UINT32 *puiLog2ImportAlignmentOut