ENGR00156850 gpu-viv: add gpu-viv driver source
[wandboard.git] / drivers / mxc / gpu-viv / arch / GC350 / hal / kernel / gc_hal_kernel_hardware_command_vg.h
bloba3738fe47b6065705b26d4b020179ddd379c7098
1 /****************************************************************************
3 * Copyright (C) 2005 - 2011 by Vivante Corp.
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.
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.
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.
19 *****************************************************************************/
26 #ifndef __gc_hal_kernel_hardware_command_vg_h_
27 #define __gc_hal_kernel_hardware_command_vg_h_
29 /******************************************************************************\
30 ******************* Task and Interrupt Management Structures. ******************
31 \******************************************************************************/
33 /* Task storage header. */
34 typedef struct _gcsTASK_STORAGE * gcsTASK_STORAGE_PTR;
35 typedef struct _gcsTASK_STORAGE
37 /* Next allocated storage buffer. */
38 gcsTASK_STORAGE_PTR next;
40 gcsTASK_STORAGE;
42 /* Task container header. */
43 typedef struct _gcsTASK_CONTAINER * gcsTASK_CONTAINER_PTR;
44 typedef struct _gcsTASK_CONTAINER
46 /* The number of tasks left to be processed in the container. */
47 gctINT referenceCount;
49 /* Size of the buffer. */
50 gctUINT size;
52 /* Link to the previous and the next allocated containers. */
53 gcsTASK_CONTAINER_PTR allocPrev;
54 gcsTASK_CONTAINER_PTR allocNext;
56 /* Link to the previous and the next containers in the free list. */
57 gcsTASK_CONTAINER_PTR freePrev;
58 gcsTASK_CONTAINER_PTR freeNext;
60 gcsTASK_CONTAINER;
62 /* Kernel space task master table entry. */
63 typedef struct _gcsBLOCK_TASK_ENTRY * gcsBLOCK_TASK_ENTRY_PTR;
64 typedef struct _gcsBLOCK_TASK_ENTRY
66 /* Pointer to the current task container for the block. */
67 gcsTASK_CONTAINER_PTR container;
69 /* Pointer to the current task data within the container. */
70 gcsTASK_HEADER_PTR task;
72 /* Pointer to the last link task within the container. */
73 gcsTASK_LINK_PTR link;
75 /* Number of interrupts allocated for this block. */
76 gctUINT interruptCount;
78 /* The index of the current interrupt. */
79 gctUINT interruptIndex;
81 /* Interrupt semaphore. */
82 gctSEMAPHORE interruptSemaphore;
84 /* Interrupt value array. */
85 gctINT32 interruptArray[32];
87 gcsBLOCK_TASK_ENTRY;
90 /******************************************************************************\
91 ********************* Command Queue Management Structures. *********************
92 \******************************************************************************/
94 /* Command queue kernel element pointer. */
95 typedef struct _gcsKERNEL_CMDQUEUE * gcsKERNEL_CMDQUEUE_PTR;
97 /* Command queue object handler function type. */
98 typedef gceSTATUS (* gctOBJECT_HANDLER) (
99 gckVGKERNEL Kernel,
100 gcsKERNEL_CMDQUEUE_PTR Entry
103 /* Command queue kernel element. */
104 typedef struct _gcsKERNEL_CMDQUEUE
106 /* The number of buffers in the queue. */
107 gcsCMDBUFFER_PTR commandBuffer;
109 /* Pointer to the object handler function. */
110 gctOBJECT_HANDLER handler;
112 gcsKERNEL_CMDQUEUE;
114 /* Command queue header. */
115 typedef struct _gcsKERNEL_QUEUE_HEADER * gcsKERNEL_QUEUE_HEADER_PTR;
116 typedef struct _gcsKERNEL_QUEUE_HEADER
118 /* The size of the buffer in bytes. */
119 gctUINT size;
121 /* The number of pending entries to be processed. */
122 volatile gctUINT pending;
124 /* The current command queue entry. */
125 gcsKERNEL_CMDQUEUE_PTR currentEntry;
127 /* Next buffer. */
128 gcsKERNEL_QUEUE_HEADER_PTR next;
130 gcsKERNEL_QUEUE_HEADER;
133 /******************************************************************************\
134 ******************************* gckVGCOMMAND Object *******************************
135 \******************************************************************************/
137 /* gckVGCOMMAND object. */
138 struct _gckVGCOMMAND
140 /***************************************************************************
141 ** Object data and pointers.
144 gcsOBJECT object;
145 gckVGKERNEL kernel;
146 gckOS os;
147 gckVGHARDWARE hardware;
149 /* Features. */
150 gctBOOL fe20;
151 gctBOOL vg20;
152 gctBOOL vg21;
155 /***************************************************************************
156 ** Enable command queue dumping.
159 gctBOOL enableDumping;
162 /***************************************************************************
163 ** Bus Error interrupt.
166 gctINT32 busErrorInt;
169 /***************************************************************************
170 ** Command buffer information.
173 gcsCOMMAND_BUFFER_INFO info;
176 /***************************************************************************
177 ** Synchronization objects.
180 gctPOINTER queueMutex;
181 gctPOINTER taskMutex;
182 gctPOINTER commitMutex;
185 /***************************************************************************
186 ** Task management.
189 /* The head of the storage buffer linked list. */
190 gcsTASK_STORAGE_PTR taskStorage;
192 /* Allocation size. */
193 gctUINT taskStorageGranularity;
194 gctUINT taskStorageUsable;
196 /* The free container list. */
197 gcsTASK_CONTAINER_PTR taskFreeHead;
198 gcsTASK_CONTAINER_PTR taskFreeTail;
200 /* Task table */
201 gcsBLOCK_TASK_ENTRY taskTable[gcvBLOCK_COUNT];
204 /***************************************************************************
205 ** Command queue.
208 /* Pointer to the allocated queue memory. */
209 gcsKERNEL_QUEUE_HEADER_PTR queue;
211 /* Pointer to the current available queue from which new queue entries
212 will be allocated. */
213 gcsKERNEL_QUEUE_HEADER_PTR queueHead;
215 /* If different from queueHead, points to the command queue which is
216 currently being executed by the hardware. */
217 gcsKERNEL_QUEUE_HEADER_PTR queueTail;
219 /* Points to the queue to merge the tail with when the tail is processed. */
220 gcsKERNEL_QUEUE_HEADER_PTR mergeQueue;
222 /* Queue overflow counter. */
223 gctUINT queueOverflow;
226 /***************************************************************************
227 ** Context.
230 /* Context counter used for unique ID. */
231 gctUINT64 contextCounter;
233 /* Current context ID. */
234 gctUINT64 currentContext;
237 /******************************************************************************\
238 ************************ gckVGCOMMAND Object Internal API. ***********************
239 \******************************************************************************/
241 /* Initialize architecture dependent command buffer information. */
242 gceSTATUS
243 gckVGCOMMAND_InitializeInfo(
244 IN gckVGCOMMAND Command
247 /* Form a STATE command at the specified location in the command buffer. */
248 gceSTATUS
249 gckVGCOMMAND_StateCommand(
250 IN gckVGCOMMAND Command,
251 IN gctUINT32 Pipe,
252 IN gctPOINTER Logical,
253 IN gctUINT32 Address,
254 IN gctSIZE_T Count,
255 IN OUT gctSIZE_T * Bytes
258 /* Form a RESTART command at the specified location in the command buffer. */
259 gceSTATUS
260 gckVGCOMMAND_RestartCommand(
261 IN gckVGCOMMAND Command,
262 IN gctPOINTER Logical,
263 IN gctUINT32 FetchAddress,
264 IN gctUINT FetchCount,
265 IN OUT gctSIZE_T * Bytes
268 /* Form a FETCH command at the specified location in the command buffer. */
269 gceSTATUS
270 gckVGCOMMAND_FetchCommand(
271 IN gckVGCOMMAND Command,
272 IN gctPOINTER Logical,
273 IN gctUINT32 FetchAddress,
274 IN gctUINT FetchCount,
275 IN OUT gctSIZE_T * Bytes
278 /* Form a CALL command at the specified location in the command buffer. */
279 gceSTATUS
280 gckVGCOMMAND_CallCommand(
281 IN gckVGCOMMAND Command,
282 IN gctPOINTER Logical,
283 IN gctUINT32 FetchAddress,
284 IN gctUINT FetchCount,
285 IN OUT gctSIZE_T * Bytes
288 /* Form a RETURN command at the specified location in the command buffer. */
289 gceSTATUS
290 gckVGCOMMAND_ReturnCommand(
291 IN gckVGCOMMAND Command,
292 IN gctPOINTER Logical,
293 IN OUT gctSIZE_T * Bytes
296 /* Form an EVENT command at the specified location in the command buffer. */
297 gceSTATUS
298 gckVGCOMMAND_EventCommand(
299 IN gckVGCOMMAND Command,
300 IN gctPOINTER Logical,
301 IN gceBLOCK Block,
302 IN gctINT32 InterruptId,
303 IN OUT gctSIZE_T * Bytes
306 /* Form an END command at the specified location in the command buffer. */
307 gceSTATUS
308 gckVGCOMMAND_EndCommand(
309 IN gckVGCOMMAND Command,
310 IN gctPOINTER Logical,
311 IN gctINT32 InterruptId,
312 IN OUT gctSIZE_T * Bytes
315 #endif /* __gc_hal_kernel_hardware_command_h_ */