]> git.karo-electronics.de Git - karo-tx-linux.git/blob - drivers/mxc/gpu-viv/arch/GC350/hal/kernel/gc_hal_kernel_hardware_command_vg.h
aa767ee173566e210729e1663371b20ab300d431
[karo-tx-linux.git] / drivers / mxc / gpu-viv / arch / GC350 / hal / kernel / gc_hal_kernel_hardware_command_vg.h
1 /****************************************************************************
2 *
3 *    Copyright (C) 2005 - 2013 by Vivante Corp.
4 *
5 *    This program is free software; you can redistribute it and/or modify
6 *    it under the terms of the GNU General Public License as published by
7 *    the Free Software Foundation; either version 2 of the license, or
8 *    (at your option) any later version.
9 *
10 *    This program is distributed in the hope that it will be useful,
11 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
12 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 *    GNU General Public License for more details.
14 *
15 *    You should have received a copy of the GNU General Public License
16 *    along with this program; if not write to the Free Software
17 *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 *
19 *****************************************************************************/
20
21
22 #ifndef __gc_hal_kernel_hardware_command_vg_h_
23 #define __gc_hal_kernel_hardware_command_vg_h_
24
25 /******************************************************************************\
26 ******************* Task and Interrupt Management Structures. ******************
27 \******************************************************************************/
28
29 /* Task storage header. */
30 typedef struct _gcsTASK_STORAGE * gcsTASK_STORAGE_PTR;
31 typedef struct _gcsTASK_STORAGE
32 {
33     /* Next allocated storage buffer. */
34     gcsTASK_STORAGE_PTR         next;
35 }
36 gcsTASK_STORAGE;
37
38 /* Task container header. */
39 typedef struct _gcsTASK_CONTAINER * gcsTASK_CONTAINER_PTR;
40 typedef struct _gcsTASK_CONTAINER
41 {
42     /* The number of tasks left to be processed in the container. */
43     gctINT                      referenceCount;
44
45     /* Size of the buffer. */
46     gctUINT                     size;
47
48     /* Link to the previous and the next allocated containers. */
49     gcsTASK_CONTAINER_PTR       allocPrev;
50     gcsTASK_CONTAINER_PTR       allocNext;
51
52     /* Link to the previous and the next containers in the free list. */
53     gcsTASK_CONTAINER_PTR       freePrev;
54     gcsTASK_CONTAINER_PTR       freeNext;
55 }
56 gcsTASK_CONTAINER;
57
58 /* Kernel space task master table entry. */
59 typedef struct _gcsBLOCK_TASK_ENTRY * gcsBLOCK_TASK_ENTRY_PTR;
60 typedef struct _gcsBLOCK_TASK_ENTRY
61 {
62     /* Pointer to the current task container for the block. */
63     gcsTASK_CONTAINER_PTR       container;
64
65     /* Pointer to the current task data within the container. */
66     gcsTASK_HEADER_PTR          task;
67
68     /* Pointer to the last link task within the container. */
69     gcsTASK_LINK_PTR            link;
70
71     /* Number of interrupts allocated for this block. */
72     gctUINT                     interruptCount;
73
74     /* The index of the current interrupt. */
75     gctUINT                     interruptIndex;
76
77     /* Interrupt semaphore. */
78     gctSEMAPHORE                interruptSemaphore;
79
80     /* Interrupt value array. */
81     gctINT32                    interruptArray[32];
82 }
83 gcsBLOCK_TASK_ENTRY;
84
85
86 /******************************************************************************\
87 ********************* Command Queue Management Structures. *********************
88 \******************************************************************************/
89
90 /* Command queue kernel element pointer. */
91 typedef struct _gcsKERNEL_CMDQUEUE * gcsKERNEL_CMDQUEUE_PTR;
92
93 /* Command queue object handler function type. */
94 typedef gceSTATUS (* gctOBJECT_HANDLER) (
95     gckVGKERNEL Kernel,
96     gcsKERNEL_CMDQUEUE_PTR Entry
97     );
98
99 /* Command queue kernel element. */
100 typedef struct _gcsKERNEL_CMDQUEUE
101 {
102     /* The number of buffers in the queue. */
103     gcsCMDBUFFER_PTR            commandBuffer;
104
105     /* Pointer to the object handler function. */
106     gctOBJECT_HANDLER           handler;
107 }
108 gcsKERNEL_CMDQUEUE;
109
110 /* Command queue header. */
111 typedef struct _gcsKERNEL_QUEUE_HEADER * gcsKERNEL_QUEUE_HEADER_PTR;
112 typedef struct _gcsKERNEL_QUEUE_HEADER
113 {
114     /* The size of the buffer in bytes. */
115     gctUINT                     size;
116
117     /* The number of pending entries to be processed. */
118     volatile gctUINT            pending;
119
120     /* The current command queue entry. */
121     gcsKERNEL_CMDQUEUE_PTR      currentEntry;
122
123     /* Next buffer. */
124     gcsKERNEL_QUEUE_HEADER_PTR  next;
125 }
126 gcsKERNEL_QUEUE_HEADER;
127
128
129 /******************************************************************************\
130 ******************************* gckVGCOMMAND Object *******************************
131 \******************************************************************************/
132
133 /* gckVGCOMMAND object. */
134 struct _gckVGCOMMAND
135 {
136     /***************************************************************************
137     ** Object data and pointers.
138     */
139
140     gcsOBJECT                   object;
141     gckVGKERNEL                 kernel;
142     gckOS                       os;
143     gckVGHARDWARE                   hardware;
144
145     /* Features. */
146     gctBOOL                     fe20;
147     gctBOOL                     vg20;
148     gctBOOL                     vg21;
149
150
151     /***************************************************************************
152     ** Enable command queue dumping.
153     */
154
155     gctBOOL                     enableDumping;
156
157
158     /***************************************************************************
159     ** Bus Error interrupt.
160     */
161
162     gctINT32                    busErrorInt;
163
164
165     /***************************************************************************
166     ** Command buffer information.
167     */
168
169     gcsCOMMAND_BUFFER_INFO      info;
170
171
172     /***************************************************************************
173     ** Synchronization objects.
174     */
175
176     gctPOINTER                  queueMutex;
177     gctPOINTER                  taskMutex;
178     gctPOINTER                  commitMutex;
179
180
181     /***************************************************************************
182     ** Task management.
183     */
184
185     /* The head of the storage buffer linked list. */
186     gcsTASK_STORAGE_PTR         taskStorage;
187
188     /* Allocation size. */
189     gctUINT                     taskStorageGranularity;
190     gctUINT                     taskStorageUsable;
191
192     /* The free container list. */
193     gcsTASK_CONTAINER_PTR       taskFreeHead;
194     gcsTASK_CONTAINER_PTR       taskFreeTail;
195
196     /* Task table */
197     gcsBLOCK_TASK_ENTRY         taskTable[gcvBLOCK_COUNT];
198
199
200     /***************************************************************************
201     ** Command queue.
202     */
203
204     /* Pointer to the allocated queue memory. */
205     gcsKERNEL_QUEUE_HEADER_PTR  queue;
206
207     /* Pointer to the current available queue from which new queue entries
208        will be allocated. */
209     gcsKERNEL_QUEUE_HEADER_PTR  queueHead;
210
211     /* If different from queueHead, points to the command queue which is
212        currently being executed by the hardware. */
213     gcsKERNEL_QUEUE_HEADER_PTR  queueTail;
214
215     /* Points to the queue to merge the tail with when the tail is processed. */
216     gcsKERNEL_QUEUE_HEADER_PTR  mergeQueue;
217
218     /* Queue overflow counter. */
219     gctUINT                     queueOverflow;
220
221
222     /***************************************************************************
223     ** Context.
224     */
225
226     /* Context counter used for unique ID. */
227     gctUINT64                   contextCounter;
228
229     /* Current context ID. */
230     gctUINT64                   currentContext;
231
232     /* Command queue power semaphore. */
233     gctPOINTER                  powerSemaphore;
234     gctINT32                    powerStallInt;
235     gcsCMDBUFFER_PTR            powerStallBuffer;
236     gctSIGNAL                   powerStallSignal;
237
238 };
239
240 /******************************************************************************\
241 ************************ gckVGCOMMAND Object Internal API. ***********************
242 \******************************************************************************/
243
244 /* Initialize architecture dependent command buffer information. */
245 gceSTATUS
246 gckVGCOMMAND_InitializeInfo(
247     IN gckVGCOMMAND Command
248     );
249
250 /* Form a STATE command at the specified location in the command buffer. */
251 gceSTATUS
252 gckVGCOMMAND_StateCommand(
253     IN gckVGCOMMAND Command,
254     IN gctUINT32 Pipe,
255     IN gctPOINTER Logical,
256     IN gctUINT32 Address,
257     IN gctSIZE_T Count,
258     IN OUT gctSIZE_T * Bytes
259     );
260
261 /* Form a RESTART command at the specified location in the command buffer. */
262 gceSTATUS
263 gckVGCOMMAND_RestartCommand(
264     IN gckVGCOMMAND Command,
265     IN gctPOINTER Logical,
266     IN gctUINT32 FetchAddress,
267     IN gctUINT FetchCount,
268     IN OUT gctSIZE_T * Bytes
269     );
270
271 /* Form a FETCH command at the specified location in the command buffer. */
272 gceSTATUS
273 gckVGCOMMAND_FetchCommand(
274     IN gckVGCOMMAND Command,
275     IN gctPOINTER Logical,
276     IN gctUINT32 FetchAddress,
277     IN gctUINT FetchCount,
278     IN OUT gctSIZE_T * Bytes
279     );
280
281 /* Form a CALL command at the specified location in the command buffer. */
282 gceSTATUS
283 gckVGCOMMAND_CallCommand(
284     IN gckVGCOMMAND Command,
285     IN gctPOINTER Logical,
286     IN gctUINT32 FetchAddress,
287     IN gctUINT FetchCount,
288     IN OUT gctSIZE_T * Bytes
289     );
290
291 /* Form a RETURN command at the specified location in the command buffer. */
292 gceSTATUS
293 gckVGCOMMAND_ReturnCommand(
294     IN gckVGCOMMAND Command,
295     IN gctPOINTER Logical,
296     IN OUT gctSIZE_T * Bytes
297     );
298
299 /* Form an EVENT command at the specified location in the command buffer. */
300 gceSTATUS
301 gckVGCOMMAND_EventCommand(
302     IN gckVGCOMMAND Command,
303     IN gctPOINTER Logical,
304     IN gceBLOCK Block,
305     IN gctINT32 InterruptId,
306     IN OUT gctSIZE_T * Bytes
307     );
308
309 /* Form an END command at the specified location in the command buffer. */
310 gceSTATUS
311 gckVGCOMMAND_EndCommand(
312     IN gckVGCOMMAND Command,
313     IN gctPOINTER Logical,
314     IN gctINT32 InterruptId,
315     IN OUT gctSIZE_T * Bytes
316     );
317
318 #endif  /* __gc_hal_kernel_hardware_command_h_ */
319