1 /****************************************************************************
3 * Copyright (C) 2005 - 2014 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 *****************************************************************************/
22 #ifndef __gc_hal_kernel_hardware_command_vg_h_
23 #define __gc_hal_kernel_hardware_command_vg_h_
25 /******************************************************************************\
26 ******************* Task and Interrupt Management Structures. ******************
27 \******************************************************************************/
29 /* Task storage header. */
30 typedef struct _gcsTASK_STORAGE * gcsTASK_STORAGE_PTR;
31 typedef struct _gcsTASK_STORAGE
33 /* Next allocated storage buffer. */
34 gcsTASK_STORAGE_PTR next;
38 /* Task container header. */
39 typedef struct _gcsTASK_CONTAINER * gcsTASK_CONTAINER_PTR;
40 typedef struct _gcsTASK_CONTAINER
42 /* The number of tasks left to be processed in the container. */
43 gctINT referenceCount;
45 /* Size of the buffer. */
48 /* Link to the previous and the next allocated containers. */
49 gcsTASK_CONTAINER_PTR allocPrev;
50 gcsTASK_CONTAINER_PTR allocNext;
52 /* Link to the previous and the next containers in the free list. */
53 gcsTASK_CONTAINER_PTR freePrev;
54 gcsTASK_CONTAINER_PTR freeNext;
58 /* Kernel space task master table entry. */
59 typedef struct _gcsBLOCK_TASK_ENTRY * gcsBLOCK_TASK_ENTRY_PTR;
60 typedef struct _gcsBLOCK_TASK_ENTRY
62 /* Pointer to the current task container for the block. */
63 gcsTASK_CONTAINER_PTR container;
65 /* Pointer to the current task data within the container. */
66 gcsTASK_HEADER_PTR task;
68 /* Pointer to the last link task within the container. */
69 gcsTASK_LINK_PTR link;
71 /* Number of interrupts allocated for this block. */
72 gctUINT interruptCount;
74 /* The index of the current interrupt. */
75 gctUINT interruptIndex;
77 /* Interrupt semaphore. */
78 gctSEMAPHORE interruptSemaphore;
80 /* Interrupt value array. */
81 gctINT32 interruptArray[32];
86 /******************************************************************************\
87 ********************* Command Queue Management Structures. *********************
88 \******************************************************************************/
90 /* Command queue kernel element pointer. */
91 typedef struct _gcsKERNEL_CMDQUEUE * gcsKERNEL_CMDQUEUE_PTR;
93 /* Command queue object handler function type. */
94 typedef gceSTATUS (* gctOBJECT_HANDLER) (
96 gcsKERNEL_CMDQUEUE_PTR Entry
99 /* Command queue kernel element. */
100 typedef struct _gcsKERNEL_CMDQUEUE
102 /* The number of buffers in the queue. */
103 gcsCMDBUFFER_PTR commandBuffer;
105 /* Pointer to the object handler function. */
106 gctOBJECT_HANDLER handler;
110 /* Command queue header. */
111 typedef struct _gcsKERNEL_QUEUE_HEADER * gcsKERNEL_QUEUE_HEADER_PTR;
112 typedef struct _gcsKERNEL_QUEUE_HEADER
114 /* The size of the buffer in bytes. */
117 /* The number of pending entries to be processed. */
118 volatile gctUINT pending;
120 /* The current command queue entry. */
121 gcsKERNEL_CMDQUEUE_PTR currentEntry;
124 gcsKERNEL_QUEUE_HEADER_PTR next;
126 gcsKERNEL_QUEUE_HEADER;
129 /******************************************************************************\
130 ******************************* gckVGCOMMAND Object *******************************
131 \******************************************************************************/
133 /* gckVGCOMMAND object. */
136 /***************************************************************************
137 ** Object data and pointers.
143 gckVGHARDWARE hardware;
151 /***************************************************************************
152 ** Enable command queue dumping.
155 gctBOOL enableDumping;
158 /***************************************************************************
159 ** Bus Error interrupt.
162 gctINT32 busErrorInt;
165 /***************************************************************************
166 ** Command buffer information.
169 gcsCOMMAND_BUFFER_INFO info;
172 /***************************************************************************
173 ** Synchronization objects.
176 gctPOINTER queueMutex;
177 gctPOINTER taskMutex;
178 gctPOINTER commitMutex;
181 /***************************************************************************
185 /* The head of the storage buffer linked list. */
186 gcsTASK_STORAGE_PTR taskStorage;
188 /* Allocation size. */
189 gctUINT taskStorageGranularity;
190 gctUINT taskStorageUsable;
192 /* The free container list. */
193 gcsTASK_CONTAINER_PTR taskFreeHead;
194 gcsTASK_CONTAINER_PTR taskFreeTail;
197 gcsBLOCK_TASK_ENTRY taskTable[gcvBLOCK_COUNT];
200 /***************************************************************************
204 /* Pointer to the allocated queue memory. */
205 gcsKERNEL_QUEUE_HEADER_PTR queue;
207 /* Pointer to the current available queue from which new queue entries
208 will be allocated. */
209 gcsKERNEL_QUEUE_HEADER_PTR queueHead;
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;
215 /* Points to the queue to merge the tail with when the tail is processed. */
216 gcsKERNEL_QUEUE_HEADER_PTR mergeQueue;
218 /* Queue overflow counter. */
219 gctUINT queueOverflow;
222 /***************************************************************************
226 /* Context counter used for unique ID. */
227 gctUINT64 contextCounter;
229 /* Current context ID. */
230 gctUINT64 currentContext;
232 /* Command queue power semaphore. */
233 gctPOINTER powerSemaphore;
234 gctINT32 powerStallInt;
235 gcsCMDBUFFER_PTR powerStallBuffer;
236 gctSIGNAL powerStallSignal;
240 /******************************************************************************\
241 ************************ gckVGCOMMAND Object Internal API. ***********************
242 \******************************************************************************/
244 /* Initialize architecture dependent command buffer information. */
246 gckVGCOMMAND_InitializeInfo(
247 IN gckVGCOMMAND Command
250 /* Form a STATE command at the specified location in the command buffer. */
252 gckVGCOMMAND_StateCommand(
253 IN gckVGCOMMAND Command,
255 IN gctPOINTER Logical,
256 IN gctUINT32 Address,
258 IN OUT gctUINT32 * Bytes
261 /* Form a RESTART command at the specified location in the command buffer. */
263 gckVGCOMMAND_RestartCommand(
264 IN gckVGCOMMAND Command,
265 IN gctPOINTER Logical,
266 IN gctUINT32 FetchAddress,
267 IN gctUINT FetchCount,
268 IN OUT gctUINT32 * Bytes
271 /* Form a FETCH command at the specified location in the command buffer. */
273 gckVGCOMMAND_FetchCommand(
274 IN gckVGCOMMAND Command,
275 IN gctPOINTER Logical,
276 IN gctUINT32 FetchAddress,
277 IN gctUINT FetchCount,
278 IN OUT gctUINT32 * Bytes
281 /* Form a CALL command at the specified location in the command buffer. */
283 gckVGCOMMAND_CallCommand(
284 IN gckVGCOMMAND Command,
285 IN gctPOINTER Logical,
286 IN gctUINT32 FetchAddress,
287 IN gctUINT FetchCount,
288 IN OUT gctUINT32 * Bytes
291 /* Form a RETURN command at the specified location in the command buffer. */
293 gckVGCOMMAND_ReturnCommand(
294 IN gckVGCOMMAND Command,
295 IN gctPOINTER Logical,
296 IN OUT gctUINT32 * Bytes
299 /* Form an EVENT command at the specified location in the command buffer. */
301 gckVGCOMMAND_EventCommand(
302 IN gckVGCOMMAND Command,
303 IN gctPOINTER Logical,
305 IN gctINT32 InterruptId,
306 IN OUT gctUINT32 * Bytes
309 /* Form an END command at the specified location in the command buffer. */
311 gckVGCOMMAND_EndCommand(
312 IN gckVGCOMMAND Command,
313 IN gctPOINTER Logical,
314 IN gctINT32 InterruptId,
315 IN OUT gctUINT32 * Bytes
318 #endif /* __gc_hal_kernel_hardware_command_h_ */