hc
2023-03-13 2ec15ae1cb4be1b4fcb56c6d621123d7ebdaad6c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/**************************************************************************/ /*!
@File
@Title          Temporary Device Memory 2 stuff
@Copyright      Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@Description    Device memory management
@License        Dual MIT/GPLv2
 
The contents of this file are subject to the MIT license as set out below.
 
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
 
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
 
Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.
 
If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.
 
This License is also included in this distribution in the file called
"MIT-COPYING".
 
EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ /***************************************************************************/
 
#ifndef __DEVICEMEMHEAPCFG_H__
#define __DEVICEMEMHEAPCFG_H__
 
#include <powervr/mem_types.h>
 
#include "img_types.h"
#include "pvrsrv_error.h"
#include "connection_data.h"
 
 
 
/* FIXME: Find a better way of defining _PVRSRV_DEVICE_NODE_ */
struct _PVRSRV_DEVICE_NODE_;
 
 
/*
  A "heap config" is a blueprint to be used for initial setting up of
  heaps when a device memory context is created.
 
  We define a data structure to define this, but it's really down to
  the caller to populate it.  This is all expected to be in-kernel.
  We provide an API that client code can use to enquire about the
  blueprint, such that it may do the heap setup during the context
  creation call on behalf of the user */
 
/* blueprint for a single heap */
typedef struct _DEVMEM_HEAP_BLUEPRINT_
{
   /* Name of this heap - for debug purposes, and perhaps for lookup
   by name? */
   const IMG_CHAR *pszName;
 
   /* Virtual address of the beginning of the heap.  This _must_ be a
   multiple of the data page size for the heap.  It is
   _recommended_ that it be coarser than that - especially, it
   should begin on a boundary appropriate to the MMU for the
   device.  For Rogue, this is a Page Directory boundary, or 1GB
   (virtual address a multiple of 0x0040000000). */
   IMG_DEV_VIRTADDR sHeapBaseAddr;
 
   /* Length of the heap.  Given that the END address of the heap has
   a similar restriction to that of the _beginning_ of the heap.
   That is the heap length _must_ be a whole number of data pages.
   Again, the recommendation is that it ends on a 1GB boundary.
   Again, this is not essential, but we do know that (at the time
   of writing) the current implementation of mmu_common.c is such
   that no two heaps may share a page directory, thus the
   remaining virtual space would be wasted if the length were not
   a multiple of 1GB */
   IMG_DEVMEM_SIZE_T uiHeapLength;
 
   /* Data page size.  This is the page size that is going to get
   programmed into the MMU, so it needs to be a valid one for the
   device.  Importantly, the start address and length _must_ be
   multiples of this page size.  Note that the page size is
   specified as the log 2 relative to 1 byte (e.g. 12 indicates
   4kB) */
   IMG_UINT32 uiLog2DataPageSize;
 
   /* Import alignment.  Force imports to this heap to be
   aligned to at least this value */
   IMG_UINT32 uiLog2ImportAlignment;
 
   /* Tiled heaps have an optimum byte-stride, this can be derived from
   the heap alignment and tiling mode. This is abstracted here such that
   Log2ByteStride = Log2Alignment - Log2TilingStrideFactor */
   IMG_UINT32 uiLog2TilingStrideFactor;
} DEVMEM_HEAP_BLUEPRINT;
 
/* entire named heap config */
typedef struct _DEVMEM_HEAP_CONFIG_
{
    /* Name of this heap config - for debug and maybe lookup */
    const IMG_CHAR *pszName;
 
    /* Number of heaps in this config */
    IMG_UINT32 uiNumHeaps;
 
    /* Array of individual heap blueprints as defined above */
    DEVMEM_HEAP_BLUEPRINT *psHeapBlueprintArray;
} DEVMEM_HEAP_CONFIG;
 
 
extern PVRSRV_ERROR
HeapCfgHeapConfigCount(struct _CONNECTION_DATA_ * psConnection,
    const struct _PVRSRV_DEVICE_NODE_ *psDeviceNode,
    IMG_UINT32 *puiNumHeapConfigsOut
);
 
extern PVRSRV_ERROR
HeapCfgHeapCount(struct _CONNECTION_DATA_ * psConnection,
    const struct _PVRSRV_DEVICE_NODE_ *psDeviceNode,
    IMG_UINT32 uiHeapConfigIndex,
    IMG_UINT32 *puiNumHeapsOut
);
 
extern PVRSRV_ERROR
HeapCfgHeapConfigName(struct _CONNECTION_DATA_ * psConnection,
    const struct _PVRSRV_DEVICE_NODE_ *psDeviceNode,
    IMG_UINT32 uiHeapConfigIndex,
    IMG_UINT32 uiHeapConfigNameBufSz,
    IMG_CHAR *pszHeapConfigNameOut
);
 
extern PVRSRV_ERROR
HeapCfgHeapDetails(struct _CONNECTION_DATA_ * psConnection,
    const struct _PVRSRV_DEVICE_NODE_ *psDeviceNode,
    IMG_UINT32 uiHeapConfigIndex,
    IMG_UINT32 uiHeapIndex,
    IMG_UINT32 uiHeapNameBufSz,
    IMG_CHAR *pszHeapNameOut,
    IMG_DEV_VIRTADDR *psDevVAddrBaseOut,
    IMG_DEVMEM_SIZE_T *puiHeapLengthOut,
    IMG_UINT32 *puiLog2DataPageSizeOut,
    IMG_UINT32 *puiLog2ImportAlignmentOut
);
 
#endif