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 *****************************************************************************/
24 #ifndef __gc_hal_base_h_
25 #define __gc_hal_base_h_
27 #include "gc_hal_enum.h"
28 #include "gc_hal_types.h"
30 #include "gc_hal_dump.h"
36 /******************************************************************************\
37 ****************************** Object Declarations *****************************
38 \******************************************************************************/
40 typedef struct _gckOS
* gckOS
;
41 typedef struct _gcoHAL
* gcoHAL
;
42 typedef struct _gcoOS
* gcoOS
;
43 typedef struct _gco2D
* gco2D
;
46 typedef struct _gco3D
* gco3D
;
49 typedef struct _gcoSURF
* gcoSURF
;
50 typedef struct _gcsSURF_INFO
* gcsSURF_INFO_PTR
;
51 typedef struct _gcsSURF_NODE
* gcsSURF_NODE_PTR
;
52 typedef struct _gcsSURF_FORMAT_INFO
* gcsSURF_FORMAT_INFO_PTR
;
53 typedef struct _gcsPOINT
* gcsPOINT_PTR
;
54 typedef struct _gcsSIZE
* gcsSIZE_PTR
;
55 typedef struct _gcsRECT
* gcsRECT_PTR
;
56 typedef struct _gcsBOUNDARY
* gcsBOUNDARY_PTR
;
57 typedef struct _gcoDUMP
* gcoDUMP
;
58 typedef struct _gcoHARDWARE
* gcoHARDWARE
;
59 typedef union _gcuVIDMEM_NODE
* gcuVIDMEM_NODE_PTR
;
62 typedef struct _gcoVG
* gcoVG
;
63 typedef struct _gcsCOMPLETION_SIGNAL
* gcsCOMPLETION_SIGNAL_PTR
;
64 typedef struct _gcsCONTEXT_MAP
* gcsCONTEXT_MAP_PTR
;
69 /******************************************************************************\
70 ******************************* Process local storage *************************
71 \******************************************************************************/
73 typedef struct _gcsPLS
* gcsPLS_PTR
;
74 typedef struct _gcsPLS
80 /* Internal memory pool. */
81 gctSIZE_T internalSize
;
82 gctPHYS_ADDR internalPhysical
;
83 gctPOINTER internalLogical
;
85 /* External memory pool. */
86 gctSIZE_T externalSize
;
87 gctPHYS_ADDR externalPhysical
;
88 gctPOINTER externalLogical
;
90 /* Contiguous memory pool. */
91 gctSIZE_T contiguousSize
;
92 gctPHYS_ADDR contiguousPhysical
;
93 gctPOINTER contiguousLogical
;
95 /* EGL-specific process-wide objects. */
96 gctPOINTER eglDisplayInfo
;
97 gctPOINTER eglSurfaceInfo
;
103 /******************************************************************************\
104 ******************************* Thread local storage *************************
105 \******************************************************************************/
107 typedef struct _gcsTLS
* gcsTLS_PTR
;
109 typedef void (* gctTLS_DESTRUCTOR
) (
113 typedef struct _gcsTLS
115 gceHARDWARE_TYPE currentType
;
116 gcoHARDWARE hardware
;
117 /* Only for separated 3D and 2D */
118 gcoHARDWARE hardware2D
;
121 #endif /* gcdENABLE_VG */
123 gctTLS_DESTRUCTOR destructor
;
124 gctBOOL ProcessExiting
;
128 /******************************************************************************\
129 ********************************* Enumerations *********************************
130 \******************************************************************************/
132 typedef enum _gcePLS_VALUE
134 gcePLS_VALUE_EGL_DISPLAY_INFO
,
135 gcePLS_VALUE_EGL_SURFACE_INFO
139 /* Video memory pool type. */
140 typedef enum _gcePOOL
145 gcvPOOL_LOCAL_INTERNAL
,
146 gcvPOOL_LOCAL_EXTERNAL
,
153 gcvPOOL_NUMBER_OF_POOLS
157 #ifndef VIVANTE_NO_3D
158 /* Blending functions. */
159 typedef enum _gceBLEND_FUNCTION
163 gcvBLEND_SOURCE_COLOR
,
164 gcvBLEND_INV_SOURCE_COLOR
,
165 gcvBLEND_SOURCE_ALPHA
,
166 gcvBLEND_INV_SOURCE_ALPHA
,
167 gcvBLEND_TARGET_COLOR
,
168 gcvBLEND_INV_TARGET_COLOR
,
169 gcvBLEND_TARGET_ALPHA
,
170 gcvBLEND_INV_TARGET_ALPHA
,
171 gcvBLEND_SOURCE_ALPHA_SATURATE
,
172 gcvBLEND_CONST_COLOR
,
173 gcvBLEND_INV_CONST_COLOR
,
174 gcvBLEND_CONST_ALPHA
,
175 gcvBLEND_INV_CONST_ALPHA
,
179 /* Blending modes. */
180 typedef enum _gceBLEND_MODE
184 gcvBLEND_REVERSE_SUBTRACT
,
201 typedef enum _gceDEPTH_MODE
208 #endif /* VIVANTE_NO_3D */
210 typedef enum _gceWHERE
220 gcvHOW_SEMAPHORE
= 0x1,
222 gcvHOW_SEMAPHORE_STALL
= 0x3,
228 typedef struct _gcsHAL_LIMITS
231 gceCHIPMODEL chipModel
;
232 gctUINT32 chipRevision
;
233 gctUINT32 featureCount
;
234 gctUINT32
*chipFeatures
;
239 gctUINT32 multiTargetCount
;
240 gctUINT32 maxSamples
;
245 /******************************************************************************\
246 ********************************* gcoHAL Object *********************************
247 \******************************************************************************/
249 /* Construct a new gcoHAL object. */
252 IN gctPOINTER Context
,
257 /* Destroy an gcoHAL object. */
263 /* Get pointer to gco2D object. */
270 #ifndef VIVANTE_NO_3D
271 /* Get pointer to gco3D object. */
277 #endif /* VIVANTE_NO_3D */
279 /* Verify whether the specified feature is available in hardware. */
281 gcoHAL_IsFeatureAvailable(
283 IN gceFEATURE Feature
286 /* Query the identity of the hardware. */
288 gcoHAL_QueryChipIdentity(
290 OUT gceCHIPMODEL
* ChipModel
,
291 OUT gctUINT32
* ChipRevision
,
292 OUT gctUINT32
* ChipFeatures
,
293 OUT gctUINT32
* ChipMinorFeatures
296 /* Query the minor features of the hardware. */
297 gceSTATUS
gcoHAL_QueryChipMinorFeatures(
299 OUT gctUINT32
* NumFeatures
,
300 OUT gctUINT32
* ChipMinorFeatures
303 /* Query the amount of video memory. */
305 gcoHAL_QueryVideoMemory(
307 OUT gctPHYS_ADDR
* InternalAddress
,
308 OUT gctSIZE_T
* InternalSize
,
309 OUT gctPHYS_ADDR
* ExternalAddress
,
310 OUT gctSIZE_T
* ExternalSize
,
311 OUT gctPHYS_ADDR
* ContiguousAddress
,
312 OUT gctSIZE_T
* ContiguousSize
315 /* Map video memory. */
319 IN gctPHYS_ADDR Physical
,
320 IN gctSIZE_T NumberOfBytes
,
321 OUT gctPOINTER
* Logical
324 /* Unmap video memory. */
328 IN gctPHYS_ADDR Physical
,
329 IN gctSIZE_T NumberOfBytes
,
330 IN gctPOINTER Logical
333 /* Schedule an unmap of a buffer mapped through its physical address. */
335 gcoHAL_ScheduleUnmapMemory(
337 IN gctPHYS_ADDR Physical
,
338 IN gctSIZE_T NumberOfBytes
,
339 IN gctPOINTER Logical
342 /* Schedule an unmap of a user buffer using event mechanism. */
344 gcoHAL_ScheduleUnmapUserMemory(
348 IN gctUINT32 Address
,
352 /* Commit the current command buffer. */
359 /* Query the tile capabilities. */
363 OUT gctINT32
* TileWidth2D
,
364 OUT gctINT32
* TileHeight2D
,
365 OUT gctINT32
* TileWidth3D
,
366 OUT gctINT32
* TileHeight3D
374 #if VIVANTE_PROFILER /*gcdENABLE_PROFILING*/
383 IN gctCONST_STRING Title
387 /* Power Management */
389 gcoHAL_SetPowerManagementState(
391 IN gceCHIPPOWERSTATE State
395 gcoHAL_QueryPowerManagementState(
397 OUT gceCHIPPOWERSTATE
*State
400 /* Set the filter type for filter blit. */
402 gcoHAL_SetFilterType(
404 IN gceFILTER_TYPE FilterType
413 /* Call the kernel HAL layer. */
417 IN OUT gcsHAL_INTERFACE_PTR Interface
420 /* Schedule an event. */
422 gcoHAL_ScheduleEvent(
424 IN OUT gcsHAL_INTERFACE_PTR Interface
427 /* Destroy a surface. */
429 gcoHAL_DestroySurface(
434 /* Request a start/stop timestamp. */
442 /* Get Time delta from a Timer in microseconds. */
447 OUT gctINT32_PTR TimeDelta
450 /* set timeout value. */
458 gcoHAL_SetHardwareType(
460 IN gceHARDWARE_TYPE HardwardType
464 gcoHAL_GetHardwareType(
466 OUT gceHARDWARE_TYPE
* HardwardType
470 gcoHAL_QueryChipCount(
476 gcoHAL_QuerySeparated3D2D(
480 /* Get pointer to gcoVG object. */
489 gcoHAL_QueryChipLimits(
492 OUT gcsHAL_LIMITS
*Limits
);
495 gcoHAL_QueryChipFeature(
498 IN gceFEATURE Feature
);
501 /******************************************************************************\
502 ********************************** gcoOS Object *********************************
503 \******************************************************************************/
505 /* Get PLS value for given key */
511 /* Set PLS value of a given key */
518 /* Get access to the thread local storage. */
524 /* Destroy the objects associated with the current thread. */
526 gcoOS_FreeThreadData(
527 IN gctBOOL ProcessExiting
530 /* Construct a new gcoOS object. */
533 IN gctPOINTER Context
,
537 /* Destroy an gcoOS object. */
543 /* Get the base address for the physical memory. */
545 gcoOS_GetBaseAddress(
547 OUT gctUINT32_PTR BaseAddress
550 /* Allocate memory from the heap. */
555 OUT gctPOINTER
* Memory
558 /* Free allocated memory. */
565 /* Allocate memory. */
567 gcoOS_AllocateMemory(
570 OUT gctPOINTER
* Memory
580 /* Allocate contiguous memory. */
582 gcoOS_AllocateContiguous(
584 IN gctBOOL InUserSpace
,
585 IN OUT gctSIZE_T
* Bytes
,
586 OUT gctPHYS_ADDR
* Physical
,
587 OUT gctPOINTER
* Logical
590 /* Free contiguous memory. */
592 gcoOS_FreeContiguous(
594 IN gctPHYS_ADDR Physical
,
595 IN gctPOINTER Logical
,
599 #if gcdENABLE_BANK_ALIGNMENT
601 gcoOS_GetBankOffsetBytes(
603 IN gceSURF_TYPE Type
,
605 IN gctUINT32_PTR Bytes
609 /* Map user memory. */
613 IN gctPOINTER Memory
,
615 OUT gctPOINTER
* Info
,
616 OUT gctUINT32_PTR Address
619 /* Unmap user memory. */
621 gcoOS_UnmapUserMemory(
623 IN gctPOINTER Memory
,
629 /* Device I/O Control call to the kernel HAL layer. */
633 IN gctUINT32 IoControlCode
,
634 IN gctPOINTER InputBuffer
,
635 IN gctSIZE_T InputBufferSize
,
636 IN gctPOINTER OutputBuffer
,
637 IN gctSIZE_T OutputBufferSize
640 /* Allocate non paged memory. */
642 gcoOS_AllocateNonPagedMemory(
644 IN gctBOOL InUserSpace
,
645 IN OUT gctSIZE_T
* Bytes
,
646 OUT gctPHYS_ADDR
* Physical
,
647 OUT gctPOINTER
* Logical
650 /* Free non paged memory. */
652 gcoOS_FreeNonPagedMemory(
655 IN gctPHYS_ADDR Physical
,
656 IN gctPOINTER Logical
659 #define gcmOS_SAFE_FREE(os, mem) \
660 gcoOS_Free(os, mem); \
663 #define gcmkOS_SAFE_FREE(os, mem) \
664 gckOS_Free(os, mem); \
667 typedef enum _gceFILE_MODE
682 IN gctCONST_STRING FileName
,
683 IN gceFILE_MODE Mode
,
694 /* Read data from a file. */
699 IN gctSIZE_T ByteCount
,
701 OUT gctSIZE_T
* ByteRead
704 /* Write data to a file. */
709 IN gctSIZE_T ByteCount
,
710 IN gctCONST_POINTER Data
713 /* Flush data to a file. */
720 /* Create an endpoint for communication. */
730 /* Close a socket. */
737 /* Initiate a connection on a socket. */
742 IN gctCONST_POINTER HostName
,
745 /* Shut down part of connection on a socket. */
753 /* Send a message on a socket. */
758 IN gctSIZE_T ByteCount
,
759 IN gctCONST_POINTER Data
,
763 /* Initiate a connection on a socket. */
769 IN gctINT MicroSeconds
);
771 /* Get environment variable value. */
775 IN gctCONST_STRING VarName
,
776 OUT gctSTRING
* Value
779 /* Get current working directory. */
783 IN gctINT SizeInBytes
,
787 /* Get file status info. */
791 IN gctCONST_STRING FileName
,
792 OUT gctPOINTER Buffer
795 typedef enum _gceFILE_WHENCE
803 /* Set the current position of a file. */
809 IN gceFILE_WHENCE Whence
812 /* Set the current position of a file. */
817 IN gctUINT32 Position
820 /* Get the current position of a file. */
825 OUT gctUINT32
* Position
828 /* Perform a memory copy. */
831 IN gctPOINTER Destination
,
832 IN gctCONST_POINTER Source
,
836 /* Perform a memory fill. */
839 IN gctPOINTER Destination
,
847 IN gctPOINTER Memory
,
851 /* Find the last occurance of a character inside a string. */
853 gcoOS_StrFindReverse(
854 IN gctCONST_STRING String
,
855 IN gctINT8 Character
,
856 OUT gctSTRING
* Output
861 IN gctCONST_STRING String
,
862 OUT gctSIZE_T
* Length
868 IN gctCONST_STRING String
,
869 OUT gctSTRING
* Target
875 IN gctSTRING Destination
,
876 IN gctSIZE_T DestinationSize
,
877 IN gctCONST_STRING Source
880 /* Append a string. */
883 IN gctSTRING Destination
,
884 IN gctSIZE_T DestinationSize
,
885 IN gctCONST_STRING Source
888 /* Compare two strings. */
891 IN gctCONST_STRING String1
,
892 IN gctCONST_STRING String2
895 /* Compare characters of two strings. */
898 IN gctCONST_STRING String1
,
899 IN gctCONST_STRING String2
,
903 /* Convert string to float. */
906 IN gctCONST_STRING String
,
910 /* Convert hex string to integer. */
911 gceSTATUS
gcoOS_HexStrToInt(
912 IN gctCONST_STRING String
,
916 /* Convert hex string to float. */
917 gceSTATUS
gcoOS_HexStrToFloat(
918 IN gctCONST_STRING String
,
922 /* Convert string to integer. */
925 IN gctCONST_STRING String
,
931 IN gctCONST_POINTER Memory1
,
932 IN gctCONST_POINTER Memory2
,
938 OUT gctSTRING String
,
939 IN gctSIZE_T StringSize
,
940 IN OUT gctUINT
* Offset
,
941 IN gctCONST_STRING Format
,
948 IN gctCONST_STRING Library
,
949 OUT gctHANDLE
* Handle
959 gcoOS_GetProcAddress(
962 IN gctCONST_STRING Name
,
963 OUT gctPOINTER
* Function
971 #if VIVANTE_PROFILER /*gcdENABLE_PROFILING*/
980 IN gctCONST_STRING Title
984 gcoOS_SetProfileSetting(
987 IN gctCONST_STRING FileName
991 /* Query the video memory. */
993 gcoOS_QueryVideoMemory(
995 OUT gctPHYS_ADDR
* InternalAddress
,
996 OUT gctSIZE_T
* InternalSize
,
997 OUT gctPHYS_ADDR
* ExternalAddress
,
998 OUT gctSIZE_T
* ExternalSize
,
999 OUT gctPHYS_ADDR
* ContiguousAddress
,
1000 OUT gctSIZE_T
* ContiguousSize
1003 /*----------------------------------------------------------------------------*/
1004 /*----- Atoms ----------------------------------------------------------------*/
1006 typedef struct gcsATOM
* gcsATOM_PTR
;
1008 /* Construct an atom. */
1010 gcoOS_AtomConstruct(
1012 OUT gcsATOM_PTR
* Atom
1015 /* Destroy an atom. */
1022 /* Increment an atom. */
1024 gcoOS_AtomIncrement(
1026 IN gcsATOM_PTR Atom
,
1027 OUT gctINT32_PTR OldValue
1030 /* Decrement an atom. */
1032 gcoOS_AtomDecrement(
1034 IN gcsATOM_PTR Atom
,
1035 OUT gctINT32_PTR OldValue
1039 gcoOS_GetCurrentProcessID(
1044 gcoOS_GetCurrentThreadID(
1048 /*----------------------------------------------------------------------------*/
1049 /*----- Time -----------------------------------------------------------------*/
1051 /* Get the number of milliseconds since the system started. */
1057 /* Get time in microseconds. */
1063 /* Get CPU usage in microseconds. */
1066 gctUINT64_PTR CPUTime
1069 /* Get memory usage. */
1071 gcoOS_GetMemoryUsage(
1072 gctUINT32_PTR MaxRSS
,
1073 gctUINT32_PTR IxRSS
,
1074 gctUINT32_PTR IdRSS
,
1078 /* Delay a number of microseconds. */
1085 /*----------------------------------------------------------------------------*/
1086 /*----- Threads --------------------------------------------------------------*/
1089 /* Cannot include windows.h here becuase "near" and "far"
1090 * which are used in gcsDEPTH_INFO, are defined to nothing in WinDef.h.
1091 * So, use the real value of DWORD and WINAPI, instead.
1092 * DWORD is unsigned long, and WINAPI is __stdcall.
1093 * If these two are change in WinDef.h, the following two typdefs
1094 * need to be changed, too.
1096 typedef unsigned long gctTHREAD_RETURN
;
1097 typedef unsigned long (__stdcall
* gcTHREAD_ROUTINE
)(void * Argument
);
1099 typedef void * gctTHREAD_RETURN
;
1100 typedef void * (* gcTHREAD_ROUTINE
)(void *);
1103 /* Create a new thread. */
1107 IN gcTHREAD_ROUTINE Worker
,
1108 IN gctPOINTER Argument
,
1109 OUT gctPOINTER
* Thread
1112 /* Close a thread. */
1116 IN gctPOINTER Thread
1119 /*----------------------------------------------------------------------------*/
1120 /*----- Mutexes --------------------------------------------------------------*/
1122 /* Create a new mutex. */
1126 OUT gctPOINTER
* Mutex
1129 /* Delete a mutex. */
1136 /* Acquire a mutex. */
1140 IN gctPOINTER Mutex
,
1141 IN gctUINT32 Timeout
1144 /* Release a mutex. */
1151 /*----------------------------------------------------------------------------*/
1152 /*----- Signals --------------------------------------------------------------*/
1154 /* Create a signal. */
1158 IN gctBOOL ManualReset
,
1159 OUT gctSIGNAL
* Signal
1162 /* Destroy a signal. */
1164 gcoOS_DestroySignal(
1169 /* Signal a signal. */
1173 IN gctSIGNAL Signal
,
1177 /* Wait for a signal. */
1181 IN gctSIGNAL Signal
,
1185 /* Map a signal from another process */
1188 IN gctSIGNAL RemoteSignal
,
1189 OUT gctSIGNAL
* LocalSignal
1192 /* Unmap a signal mapped from another process */
1198 /* Write a register. */
1200 gcoOS_WriteRegister(
1202 IN gctUINT32 Address
,
1206 /* Read a register. */
1210 IN gctUINT32 Address
,
1211 OUT gctUINT32
* Data
1217 IN gcuVIDMEM_NODE_PTR Node
,
1218 IN gctPOINTER Logical
,
1225 IN gcuVIDMEM_NODE_PTR Node
,
1226 IN gctPOINTER Logical
,
1231 gcoOS_CacheInvalidate(
1233 IN gcuVIDMEM_NODE_PTR Node
,
1234 IN gctPOINTER Logical
,
1238 /*----------------------------------------------------------------------------*/
1239 /*----- Profile --------------------------------------------------------------*/
1242 gckOS_GetProfileTick(
1243 OUT gctUINT64_PTR Tick
1247 gckOS_QueryProfileTickRate(
1248 OUT gctUINT64_PTR TickRate
1257 gcoOS_GetProfileTick(
1258 OUT gctUINT64_PTR Tick
1262 gcoOS_QueryProfileTickRate(
1263 OUT gctUINT64_PTR TickRate
1266 #define _gcmPROFILE_INIT(prefix, freq, start) \
1268 prefix ## OS_QueryProfileTickRate(&(freq)); \
1269 prefix ## OS_GetProfileTick(&(start)); \
1272 #define _gcmPROFILE_QUERY(prefix, start, ticks) \
1274 prefix ## OS_GetProfileTick(&(ticks)); \
1275 (ticks) = ((ticks) > (start)) ? ((ticks) - (start)) \
1276 : (~0ull - (start) + (ticks) + 1); \
1279 #if gcdENABLE_PROFILING
1280 # define gcmkPROFILE_INIT(freq, start) _gcmPROFILE_INIT(gck, freq, start)
1281 # define gcmkPROFILE_QUERY(start, ticks) _gcmPROFILE_QUERY(gck, start, ticks)
1282 # define gcmPROFILE_INIT(freq, start) _gcmPROFILE_INIT(gco, freq, start)
1283 # define gcmPROFILE_QUERY(start, ticks) _gcmPROFILE_QUERY(gco, start, ticks)
1284 # define gcmPROFILE_ONLY(x) x
1285 # define gcmPROFILE_ELSE(x) do { } while (gcvFALSE)
1286 # define gcmPROFILE_DECLARE_ONLY(x) x
1287 # define gcmPROFILE_DECLARE_ELSE(x) typedef x
1289 # define gcmkPROFILE_INIT(start, freq) do { } while (gcvFALSE)
1290 # define gcmkPROFILE_QUERY(start, ticks) do { } while (gcvFALSE)
1291 # define gcmPROFILE_INIT(start, freq) do { } while (gcvFALSE)
1292 # define gcmPROFILE_QUERY(start, ticks) do { } while (gcvFALSE)
1293 # define gcmPROFILE_ONLY(x) do { } while (gcvFALSE)
1294 # define gcmPROFILE_ELSE(x) x
1295 # define gcmPROFILE_DECLARE_ONLY(x) typedef x
1296 # define gcmPROFILE_DECLARE_ELSE(x) x
1299 /*******************************************************************************
1303 #define gcdPI 3.14159265358979323846f
1314 gcoMATH_Log2in5dot5(
1320 gcoMATH_UIntAsFloat(
1325 gcoMATH_FloatAsUInt(
1330 gcoMATH_CompareEqualF(
1336 gcoMATH_UInt8AsFloat16(
1340 /******************************************************************************\
1341 **************************** Coordinate Structures *****************************
1342 \******************************************************************************/
1344 typedef struct _gcsPOINT
1351 typedef struct _gcsSIZE
1358 typedef struct _gcsRECT
1368 /******************************************************************************\
1369 ********************************* gcoSURF Object ********************************
1370 \******************************************************************************/
1372 /*----------------------------------------------------------------------------*/
1373 /*------------------------------- gcoSURF Common ------------------------------*/
1375 /* Color format classes. */
1376 typedef enum _gceFORMAT_CLASS
1378 gcvFORMAT_CLASS_RGBA
= 4500,
1379 gcvFORMAT_CLASS_YUV
,
1380 gcvFORMAT_CLASS_INDEX
,
1381 gcvFORMAT_CLASS_LUMINANCE
,
1382 gcvFORMAT_CLASS_BUMP
,
1383 gcvFORMAT_CLASS_DEPTH
,
1387 /* Special enums for width field in gcsFORMAT_COMPONENT. */
1388 typedef enum _gceCOMPONENT_CONTROL
1390 gcvCOMPONENT_NOTPRESENT
= 0x00,
1391 gcvCOMPONENT_DONTCARE
= 0x80,
1392 gcvCOMPONENT_WIDTHMASK
= 0x7F,
1393 gcvCOMPONENT_ODD
= 0x80
1395 gceCOMPONENT_CONTROL
;
1397 /* Color format component parameters. */
1398 typedef struct _gcsFORMAT_COMPONENT
1403 gcsFORMAT_COMPONENT
;
1405 /* RGBA color format class. */
1406 typedef struct _gcsFORMAT_CLASS_TYPE_RGBA
1408 gcsFORMAT_COMPONENT alpha
;
1409 gcsFORMAT_COMPONENT red
;
1410 gcsFORMAT_COMPONENT green
;
1411 gcsFORMAT_COMPONENT blue
;
1413 gcsFORMAT_CLASS_TYPE_RGBA
;
1415 /* YUV color format class. */
1416 typedef struct _gcsFORMAT_CLASS_TYPE_YUV
1418 gcsFORMAT_COMPONENT y
;
1419 gcsFORMAT_COMPONENT u
;
1420 gcsFORMAT_COMPONENT v
;
1422 gcsFORMAT_CLASS_TYPE_YUV
;
1424 /* Index color format class. */
1425 typedef struct _gcsFORMAT_CLASS_TYPE_INDEX
1427 gcsFORMAT_COMPONENT value
;
1429 gcsFORMAT_CLASS_TYPE_INDEX
;
1431 /* Luminance color format class. */
1432 typedef struct _gcsFORMAT_CLASS_TYPE_LUMINANCE
1434 gcsFORMAT_COMPONENT alpha
;
1435 gcsFORMAT_COMPONENT value
;
1437 gcsFORMAT_CLASS_TYPE_LUMINANCE
;
1439 /* Bump map color format class. */
1440 typedef struct _gcsFORMAT_CLASS_TYPE_BUMP
1442 gcsFORMAT_COMPONENT alpha
;
1443 gcsFORMAT_COMPONENT l
;
1444 gcsFORMAT_COMPONENT v
;
1445 gcsFORMAT_COMPONENT u
;
1446 gcsFORMAT_COMPONENT q
;
1447 gcsFORMAT_COMPONENT w
;
1449 gcsFORMAT_CLASS_TYPE_BUMP
;
1451 /* Depth and stencil format class. */
1452 typedef struct _gcsFORMAT_CLASS_TYPE_DEPTH
1454 gcsFORMAT_COMPONENT depth
;
1455 gcsFORMAT_COMPONENT stencil
;
1457 gcsFORMAT_CLASS_TYPE_DEPTH
;
1459 /* Format parameters. */
1460 typedef struct _gcsSURF_FORMAT_INFO
1462 /* Format code and class. */
1463 gceSURF_FORMAT format
;
1464 gceFORMAT_CLASS fmtClass
;
1466 /* The size of one pixel in bits. */
1467 gctUINT8 bitsPerPixel
;
1469 /* Component swizzle. */
1470 gceSURF_SWIZZLE swizzle
;
1472 /* Some formats have two neighbour pixels interleaved together. */
1473 /* To describe such format, set the flag to 1 and add another */
1474 /* like this one describing the odd pixel format. */
1475 gctUINT8 interleaved
;
1477 /* Format components. */
1480 gcsFORMAT_CLASS_TYPE_BUMP bump
;
1481 gcsFORMAT_CLASS_TYPE_RGBA rgba
;
1482 gcsFORMAT_CLASS_TYPE_YUV yuv
;
1483 gcsFORMAT_CLASS_TYPE_LUMINANCE lum
;
1484 gcsFORMAT_CLASS_TYPE_INDEX index
;
1485 gcsFORMAT_CLASS_TYPE_DEPTH depth
;
1488 gcsSURF_FORMAT_INFO
;
1490 /* Frame buffer information. */
1491 typedef struct _gcsSURF_FRAMEBUFFER
1494 gctUINT width
, height
;
1496 gceSURF_FORMAT format
;
1498 gcsSURF_FRAMEBUFFER
;
1500 typedef struct _gcsVIDMEM_NODE_SHARED_INFO
1502 gctBOOL tileStatusDisabled
;
1504 gcsPOINT DestOrigin
;
1506 gctUINT32 clearValue
;
1508 gcsVIDMEM_NODE_SHARED_INFO
;
1510 /* Generic pixel component descriptors. */
1511 extern gcsFORMAT_COMPONENT gcvPIXEL_COMP_XXX8
;
1512 extern gcsFORMAT_COMPONENT gcvPIXEL_COMP_XX8X
;
1513 extern gcsFORMAT_COMPONENT gcvPIXEL_COMP_X8XX
;
1514 extern gcsFORMAT_COMPONENT gcvPIXEL_COMP_8XXX
;
1516 typedef enum _gceORIENTATION
1518 gcvORIENTATION_TOP_BOTTOM
,
1519 gcvORIENTATION_BOTTOM_TOP
,
1524 /* Construct a new gcoSURF object. */
1531 IN gceSURF_TYPE Type
,
1532 IN gceSURF_FORMAT Format
,
1534 OUT gcoSURF
* Surface
1537 /* Destroy an gcoSURF object. */
1543 /* Map user-allocated surface. */
1545 gcoSURF_MapUserSurface(
1547 IN gctUINT Alignment
,
1548 IN gctPOINTER Logical
,
1549 IN gctUINT32 Physical
1552 /* Query vid mem node info. */
1554 gcoSURF_QueryVidMemNode(
1556 OUT gcuVIDMEM_NODE_PTR
* Node
,
1558 OUT gctUINT_PTR Bytes
1561 /* Set the color type of the surface. */
1563 gcoSURF_SetColorType(
1565 IN gceSURF_COLOR_TYPE ColorType
1568 /* Get the color type of the surface. */
1570 gcoSURF_GetColorType(
1572 OUT gceSURF_COLOR_TYPE
*ColorType
1575 /* Set the surface ration angle. */
1577 gcoSURF_SetRotation(
1579 IN gceSURF_ROTATION Rotation
1587 #ifndef VIVANTE_NO_3D
1588 /* Verify and return the state of the tile status mechanism. */
1590 gcoSURF_IsTileStatusSupported(
1594 /* Process tile status for the specified surface. */
1596 gcoSURF_SetTileStatus(
1600 /* Enable tile status for the specified surface. */
1602 gcoSURF_EnableTileStatus(
1606 /* Disable tile status for the specified surface. */
1608 gcoSURF_DisableTileStatus(
1610 IN gctBOOL Decompress
1612 #endif /* VIVANTE_NO_3D */
1614 /* Get surface size. */
1618 OUT gctUINT
* Width
,
1619 OUT gctUINT
* Height
,
1623 /* Get surface aligned sizes. */
1625 gcoSURF_GetAlignedSize(
1627 OUT gctUINT
* Width
,
1628 OUT gctUINT
* Height
,
1632 /* Get alignments. */
1634 gcoSURF_GetAlignment(
1635 IN gceSURF_TYPE Type
,
1636 IN gceSURF_FORMAT Format
,
1637 OUT gctUINT
* AddressAlignment
,
1638 OUT gctUINT
* XAlignment
,
1639 OUT gctUINT
* YAlignment
1642 /* Get surface type and format. */
1646 OUT gceSURF_TYPE
* Type
,
1647 OUT gceSURF_FORMAT
* Format
1650 /* Lock the surface. */
1654 IN OUT gctUINT32
* Address
,
1655 IN OUT gctPOINTER
* Memory
1658 /* Unlock the surface. */
1662 IN gctPOINTER Memory
1665 /* Return pixel format parameters. */
1667 gcoSURF_QueryFormat(
1668 IN gceSURF_FORMAT Format
,
1669 OUT gcsSURF_FORMAT_INFO_PTR
* Info
1672 /* Compute the color pixel mask. */
1674 gcoSURF_ComputeColorMask(
1675 IN gcsSURF_FORMAT_INFO_PTR Format
,
1676 OUT gctUINT32_PTR ColorMask
1679 /* Flush the surface. */
1685 /* Fill surface from it's tile status buffer. */
1687 gcoSURF_FillFromTile(
1691 /* Fill surface with a value. */
1695 IN gcsPOINT_PTR Origin
,
1696 IN gcsSIZE_PTR Size
,
1701 /* Alpha blend two surfaces together. */
1704 IN gcoSURF SrcSurface
,
1705 IN gcoSURF DestSurface
,
1706 IN gcsPOINT_PTR SrcOrig
,
1707 IN gcsPOINT_PTR DestOrigin
,
1708 IN gcsSIZE_PTR Size
,
1709 IN gceSURF_BLEND_MODE Mode
1712 /* Create a new gcoSURF wrapper object. */
1714 gcoSURF_ConstructWrapper(
1716 OUT gcoSURF
* Surface
1719 /* Set the underlying buffer for the surface wrapper. */
1723 IN gceSURF_TYPE Type
,
1724 IN gceSURF_FORMAT Format
,
1726 IN gctPOINTER Logical
,
1727 IN gctUINT32 Physical
1730 /* Set the size of the surface in pixels and map the underlying buffer. */
1740 /* Increase reference count of the surface. */
1742 gcoSURF_ReferenceSurface(
1746 /* Get surface reference count. */
1748 gcoSURF_QueryReferenceCount(
1750 OUT gctINT32
* ReferenceCount
1753 /* Set surface orientation. */
1755 gcoSURF_SetOrientation(
1757 IN gceORIENTATION Orientation
1760 /* Query surface orientation. */
1762 gcoSURF_QueryOrientation(
1764 OUT gceORIENTATION
* Orientation
1767 /******************************************************************************\
1768 ********************************* gcoDUMP Object ********************************
1769 \******************************************************************************/
1771 /* Construct a new gcoDUMP object. */
1779 /* Destroy a gcoDUMP object. */
1785 /* Enable/disable dumping. */
1789 IN gctSTRING FileName
1795 OUT gctBOOL
* Enabled
1804 IN gceSURF_FORMAT PixelFormat
,
1805 IN gctUINT32 Address
,
1806 IN gctSIZE_T ByteCount
1809 /* Mark the beginning of a frame. */
1815 /* Mark the end of a frame. */
1825 IN gceDUMP_TAG Type
,
1826 IN gctUINT32 Address
,
1827 IN gctSIZE_T ByteCount
,
1828 IN gctCONST_POINTER Data
1831 /* Delete an address. */
1835 IN gctUINT32 Address
1839 /******************************************************************************\
1840 ******************************* gcsRECT Structure ******************************
1841 \******************************************************************************/
1843 /* Initialize rectangle structure. */
1846 OUT gcsRECT_PTR Rect
,
1853 /* Return the width of the rectangle. */
1856 IN gcsRECT_PTR Rect
,
1857 OUT gctINT32
* Width
1860 /* Return the height of the rectangle. */
1863 IN gcsRECT_PTR Rect
,
1864 OUT gctINT32
* Height
1867 /* Ensure that top left corner is to the left and above the right bottom. */
1870 IN OUT gcsRECT_PTR Rect
1873 /* Compare two rectangles. */
1876 IN gcsRECT_PTR Rect1
,
1877 IN gcsRECT_PTR Rect2
,
1881 /* Compare the sizes of two rectangles. */
1883 gcsRECT_IsOfEqualSize(
1884 IN gcsRECT_PTR Rect1
,
1885 IN gcsRECT_PTR Rect2
,
1886 OUT gctBOOL
* EqualSize
1890 gcsRECT_RelativeRotation(
1891 IN gceSURF_ROTATION Orientation
,
1892 IN OUT gceSURF_ROTATION
*Relation
);
1898 IN OUT gcsRECT_PTR Rect
,
1900 IN gceSURF_ROTATION Rotation
,
1902 IN gceSURF_ROTATION toRotation
,
1904 IN gctINT32 SurfaceWidth
,
1906 IN gctINT32 SurfaceHeight
1910 /******************************************************************************\
1911 **************************** gcsBOUNDARY Structure *****************************
1912 \******************************************************************************/
1914 typedef struct _gcsBOUNDARY
1923 /******************************************************************************\
1924 ********************************* gcoHEAP Object ********************************
1925 \******************************************************************************/
1927 typedef struct _gcoHEAP
* gcoHEAP
;
1929 /* Construct a new gcoHEAP object. */
1933 IN gctSIZE_T AllocationSize
,
1937 /* Destroy an gcoHEAP object. */
1943 /* Allocate memory. */
1948 OUT gctPOINTER
* Node
1958 #if (VIVANTE_PROFILER /*gcdENABLE_PROFILING*/ || gcdDEBUG)
1959 /* Profile the heap. */
1961 gcoHEAP_ProfileStart(
1968 IN gctCONST_STRING Title
1973 /******************************************************************************\
1974 ******************************* Debugging Macros *******************************
1975 \******************************************************************************/
1978 gcoOS_SetDebugLevel(
1988 gcoOS_SetDebugLevelZone(
1994 gcoOS_SetDebugZones(
2001 IN gctCONST_STRING FileName
2004 /*******************************************************************************
2008 ** Print a message to the debugger and execute a break point.
2013 ** ... Optional arguments.
2018 IN gctCONST_STRING Message
,
2024 IN gctCONST_STRING Message
,
2028 #if gcmIS_DEBUG(gcdDEBUG_FATAL)
2029 # define gcmFATAL gcoOS_DebugFatal
2030 # define gcmkFATAL gckOS_DebugFatal
2031 #elif gcdHAS_ELLIPSES
2032 # define gcmFATAL(...)
2033 # define gcmkFATAL(...)
2035 gcmINLINE
static void
2037 IN gctCONST_STRING Message
,
2042 # define gcmFATAL __dummy_fatal
2043 # define gcmkFATAL __dummy_fatal
2046 #define gcmENUM2TEXT(e) case e: return #e
2048 /*******************************************************************************
2052 ** Print a message to the debugfer if the correct level has been set. In
2053 ** retail mode this macro does nothing.
2057 ** level Level of message.
2059 ** ... Optional arguments.
2061 #define gcvLEVEL_NONE -1
2062 #define gcvLEVEL_ERROR 0
2063 #define gcvLEVEL_WARNING 1
2064 #define gcvLEVEL_INFO 2
2065 #define gcvLEVEL_VERBOSE 3
2070 IN gctCONST_STRING Message
,
2077 IN gctUINT ArgumentSize
,
2078 IN gctCONST_STRING Message
,
2085 IN gctCONST_STRING Message
,
2089 #if gcmIS_DEBUG(gcdDEBUG_TRACE)
2090 # define gcmTRACE gcoOS_DebugTrace
2091 # define gcmkTRACE gckOS_DebugTrace
2092 # define gcmkTRACE_N gckOS_DebugTraceN
2093 #elif gcdHAS_ELLIPSES
2094 # define gcmTRACE(...)
2095 # define gcmkTRACE(...)
2096 # define gcmkTRACE_N(...)
2098 gcmINLINE
static void
2101 IN gctCONST_STRING Message
,
2107 gcmINLINE
static void
2110 IN gctUINT ArgumentSize
,
2111 IN gctCONST_STRING Message
,
2117 # define gcmTRACE __dummy_trace
2118 # define gcmkTRACE __dummy_trace
2119 # define gcmkTRACE_N __dummy_trace_n
2122 /* Zones common for kernel and user. */
2123 #define gcvZONE_OS (1 << 0)
2124 #define gcvZONE_HARDWARE (1 << 1)
2125 #define gcvZONE_HEAP (1 << 2)
2126 #define gcvZONE_SIGNAL (1 << 27)
2129 #define gcvZONE_KERNEL (1 << 3)
2130 #define gcvZONE_VIDMEM (1 << 4)
2131 #define gcvZONE_COMMAND (1 << 5)
2132 #define gcvZONE_DRIVER (1 << 6)
2133 #define gcvZONE_CMODEL (1 << 7)
2134 #define gcvZONE_MMU (1 << 8)
2135 #define gcvZONE_EVENT (1 << 9)
2136 #define gcvZONE_DEVICE (1 << 10)
2137 #define gcvZONE_DATABASE (1 << 11)
2138 #define gcvZONE_INTERRUPT (1 << 12)
2141 #define gcvZONE_HAL (1 << 3)
2142 #define gcvZONE_BUFFER (1 << 4)
2143 #define gcvZONE_CONTEXT (1 << 5)
2144 #define gcvZONE_SURFACE (1 << 6)
2145 #define gcvZONE_INDEX (1 << 7)
2146 #define gcvZONE_STREAM (1 << 8)
2147 #define gcvZONE_TEXTURE (1 << 9)
2148 #define gcvZONE_2D (1 << 10)
2149 #define gcvZONE_3D (1 << 11)
2150 #define gcvZONE_COMPILER (1 << 12)
2151 #define gcvZONE_MEMORY (1 << 13)
2152 #define gcvZONE_STATE (1 << 14)
2153 #define gcvZONE_AUX (1 << 15)
2154 #define gcvZONE_VERTEX (1 << 16)
2155 #define gcvZONE_CL (1 << 17)
2156 #define gcvZONE_COMPOSITION (1 << 17)
2157 #define gcvZONE_VG (1 << 18)
2158 #define gcvZONE_IMAGE (1 << 19)
2159 #define gcvZONE_UTILITY (1 << 20)
2160 #define gcvZONE_PARAMETERS (1 << 21)
2162 /* API definitions. */
2163 #define gcvZONE_API_HAL (0 << 28)
2164 #define gcvZONE_API_EGL (1 << 28)
2165 #define gcvZONE_API_ES11 (2 << 28)
2166 #define gcvZONE_API_ES20 (3 << 28)
2167 #define gcvZONE_API_VG11 (4 << 28)
2168 #define gcvZONE_API_GL (5 << 28)
2169 #define gcvZONE_API_DFB (6 << 28)
2170 #define gcvZONE_API_GDI (7 << 28)
2171 #define gcvZONE_API_D3D (8 << 28)
2173 #define gcmZONE_GET_API(zone) ((zone) >> 28)
2174 #define gcdZONE_MASK 0x0FFFFFFF
2177 #define gcvZONE_NONE 0
2178 #define gcvZONE_ALL gcdZONE_MASK
2180 /*******************************************************************************
2184 ** Print a message to the debugger if the correct level and zone has been
2185 ** set. In retail mode this macro does nothing.
2189 ** Level Level of message.
2190 ** Zone Zone of message.
2192 ** ... Optional arguments.
2196 gckOS_DebugTraceZone(
2199 IN gctCONST_STRING Message
,
2204 gckOS_DebugTraceZoneN(
2207 IN gctUINT ArgumentSize
,
2208 IN gctCONST_STRING Message
,
2213 gcoOS_DebugTraceZone(
2216 IN gctCONST_STRING Message
,
2220 #if gcmIS_DEBUG(gcdDEBUG_TRACE)
2221 # define gcmTRACE_ZONE gcoOS_DebugTraceZone
2222 # define gcmkTRACE_ZONE gckOS_DebugTraceZone
2223 # define gcmkTRACE_ZONE_N gckOS_DebugTraceZoneN
2224 #elif gcdHAS_ELLIPSES
2225 # define gcmTRACE_ZONE(...)
2226 # define gcmkTRACE_ZONE(...)
2227 # define gcmkTRACE_ZONE_N(...)
2229 gcmINLINE
static void
2233 IN gctCONST_STRING Message
,
2239 gcmINLINE
static void
2240 __dummy_trace_zone_n(
2243 IN gctUINT ArgumentSize
,
2244 IN gctCONST_STRING Message
,
2250 # define gcmTRACE_ZONE __dummy_trace_zone
2251 # define gcmkTRACE_ZONE __dummy_trace_zone
2252 # define gcmkTRACE_ZONE_N __dummy_trace_zone_n
2255 /*******************************************************************************
2259 ** Execute a statement or function only in DEBUG mode.
2263 ** f Statement or function to execute.
2265 #if gcmIS_DEBUG(gcdDEBUG_CODE)
2266 # define gcmDEBUG_ONLY(f) f
2268 # define gcmDEBUG_ONLY(f)
2271 /*******************************************************************************
2277 ** Push or pop a function with entry arguments on the trace stack.
2281 ** Function Name of function.
2282 ** Line Line number.
2283 ** Text Optional text.
2284 ** ... Optional arguments for text.
2286 #if gcmIS_DEBUG(gcdDEBUG_STACK)
2289 IN gctCONST_STRING Function
,
2291 IN gctCONST_STRING Text
,
2296 IN gctCONST_STRING Function
2302 # define gcmSTACK_PUSH gcoOS_StackPush
2303 # define gcmSTACK_POP gcoOS_StackPop
2304 # define gcmSTACK_DUMP gcoOS_StackDump
2305 #elif gcdHAS_ELLIPSES
2306 # define gcmSTACK_PUSH(...) do { } while (0)
2307 # define gcmSTACK_POP(Function) do { } while (0)
2308 # define gcmSTACK_DUMP() do { } while (0)
2310 gcmINLINE
static void
2312 IN gctCONST_STRING Function
,
2314 IN gctCONST_STRING Text
, ...
2318 # define gcmSTACK_PUSH __dummy_stack_push
2319 # define gcmSTACK_POP(Function) do { } while (0)
2320 # define gcmSTACK_DUMP() do { } while (0)
2323 /******************************************************************************\
2324 ******************************** Logging Macros ********************************
2325 \******************************************************************************/
2327 #define gcdHEADER_LEVEL gcvLEVEL_VERBOSE
2329 #if gcdENABLE_PROFILING
2332 IN gctCONST_STRING Function
,
2333 IN OUT gctBOOL_PTR Initialized
2336 #define gcmHEADER() \
2337 static gctBOOL __profile__initialized__ = gcvFALSE; \
2338 gcmSTACK_PUSH(__FUNCTION__, __LINE__, gcvNULL, gcvNULL); \
2339 gcoOS_ProfileDB(__FUNCTION__, &__profile__initialized__)
2340 #define gcmHEADER_ARG(...) \
2341 static gctBOOL __profile__initialized__ = gcvFALSE; \
2342 gcmSTACK_PUSH(__FUNCTION__, __LINE__, Text, __VA_ARGS__); \
2343 gcoOS_ProfileDB(__FUNCTION__, &__profile__initialized__)
2344 #define gcmFOOTER() \
2345 gcmSTACK_POP(__FUNCTION__); \
2346 gcoOS_ProfileDB(__FUNCTION__, gcvNULL)
2347 #define gcmFOOTER_NO() \
2348 gcmSTACK_POP(__FUNCTION__); \
2349 gcoOS_ProfileDB(__FUNCTION__, gcvNULL)
2350 #define gcmFOOTER_ARG(...) \
2351 gcmSTACK_POP(__FUNCTION__); \
2352 gcoOS_ProfileDB(__FUNCTION__, gcvNULL)
2353 #define gcmFOOTER_KILL() \
2354 gcmSTACK_POP(__FUNCTION__); \
2355 gcoOS_ProfileDB(gcvNULL, gcvNULL)
2357 #else /* gcdENABLE_PROFILING */
2360 #define gcmHEADER() \
2361 gctINT8 __user__ = 1; \
2362 gctINT8_PTR __user_ptr__ = &__user__; \
2363 gcmSTACK_PUSH(__FUNCTION__, __LINE__, gcvNULL, gcvNULL); \
2364 gcmTRACE_ZONE(gcdHEADER_LEVEL, _GC_OBJ_ZONE, \
2365 "++%s(%d)", __FUNCTION__, __LINE__)
2367 gcmINLINE
static void
2368 __dummy_header(void)
2371 # define gcmHEADER __dummy_header
2375 # define gcmHEADER_ARG(Text, ...) \
2376 gctINT8 __user__ = 1; \
2377 gctINT8_PTR __user_ptr__ = &__user__; \
2378 gcmSTACK_PUSH(__FUNCTION__, __LINE__, Text, __VA_ARGS__); \
2379 gcmTRACE_ZONE(gcdHEADER_LEVEL, _GC_OBJ_ZONE, \
2380 "++%s(%d): " Text, __FUNCTION__, __LINE__, __VA_ARGS__)
2382 gcmINLINE
static void
2384 IN gctCONST_STRING Text
,
2389 # define gcmHEADER_ARG __dummy_header_arg
2393 # define gcmFOOTER() \
2394 gcmSTACK_POP(__FUNCTION__); \
2395 gcmPROFILE_ONLY(gcmTRACE_ZONE(gcdHEADER_LEVEL, _GC_OBJ_ZONE, \
2396 "--%s(%d) [%llu,%llu]: status=%d(%s)", \
2397 __FUNCTION__, __LINE__, \
2398 __ticks__, __total__, \
2399 status, gcoOS_DebugStatus2Name(status))); \
2400 gcmPROFILE_ELSE(gcmTRACE_ZONE(gcdHEADER_LEVEL, _GC_OBJ_ZONE, \
2401 "--%s(%d): status=%d(%s)", \
2402 __FUNCTION__, __LINE__, \
2403 status, gcoOS_DebugStatus2Name(status))); \
2406 gcmINLINE
static void
2407 __dummy_footer(void)
2410 # define gcmFOOTER __dummy_footer
2414 #define gcmFOOTER_NO() \
2415 gcmSTACK_POP(__FUNCTION__); \
2416 gcmTRACE_ZONE(gcdHEADER_LEVEL, _GC_OBJ_ZONE, \
2417 "--%s(%d)", __FUNCTION__, __LINE__); \
2420 gcmINLINE
static void
2421 __dummy_footer_no(void)
2424 # define gcmFOOTER_NO __dummy_footer_no
2428 #define gcmFOOTER_KILL() \
2429 gcmSTACK_POP(__FUNCTION__); \
2430 gcmTRACE_ZONE(gcdHEADER_LEVEL, _GC_OBJ_ZONE, \
2431 "--%s(%d)", __FUNCTION__, __LINE__); \
2434 gcmINLINE
static void
2435 __dummy_footer_kill(void)
2438 # define gcmFOOTER_KILL __dummy_footer_kill
2442 # define gcmFOOTER_ARG(Text, ...) \
2443 gcmSTACK_POP(__FUNCTION__); \
2444 gcmTRACE_ZONE(gcdHEADER_LEVEL, _GC_OBJ_ZONE, \
2445 "--%s(%d): " Text, __FUNCTION__, __LINE__, __VA_ARGS__); \
2448 gcmINLINE
static void
2450 IN gctCONST_STRING Text
,
2455 # define gcmFOOTER_ARG __dummy_footer_arg
2458 #endif /* gcdENABLE_PROFILING */
2461 #define gcmkHEADER() \
2462 gctINT8 __kernel__ = 1; \
2463 gctINT8_PTR __kernel_ptr__ = &__kernel__; \
2464 gcmkTRACE_ZONE(gcdHEADER_LEVEL, _GC_OBJ_ZONE, \
2465 "++%s(%d)", __FUNCTION__, __LINE__)
2467 gcmINLINE
static void
2468 __dummy_kheader(void)
2471 # define gcmkHEADER __dummy_kheader
2475 # define gcmkHEADER_ARG(Text, ...) \
2476 gctINT8 __kernel__ = 1; \
2477 gctINT8_PTR __kernel_ptr__ = &__kernel__; \
2478 gcmkTRACE_ZONE(gcdHEADER_LEVEL, _GC_OBJ_ZONE, \
2479 "++%s(%d): " Text, __FUNCTION__, __LINE__, __VA_ARGS__)
2481 gcmINLINE
static void
2482 __dummy_kheader_arg(
2483 IN gctCONST_STRING Text
,
2488 # define gcmkHEADER_ARG __dummy_kheader_arg
2492 #define gcmkFOOTER() \
2493 gcmkTRACE_ZONE(gcdHEADER_LEVEL, _GC_OBJ_ZONE, \
2494 "--%s(%d): status=%d(%s)", \
2495 __FUNCTION__, __LINE__, status, gckOS_DebugStatus2Name(status)); \
2496 *__kernel_ptr__ -= 1
2498 gcmINLINE
static void
2499 __dummy_kfooter(void)
2502 # define gcmkFOOTER __dummy_kfooter
2506 #define gcmkFOOTER_NO() \
2507 gcmkTRACE_ZONE(gcdHEADER_LEVEL, _GC_OBJ_ZONE, \
2508 "--%s(%d)", __FUNCTION__, __LINE__); \
2509 *__kernel_ptr__ -= 1
2511 gcmINLINE
static void
2512 __dummy_kfooter_no(void)
2515 # define gcmkFOOTER_NO __dummy_kfooter_no
2519 # define gcmkFOOTER_ARG(Text, ...) \
2520 gcmkTRACE_ZONE(gcdHEADER_LEVEL, _GC_OBJ_ZONE, \
2521 "--%s(%d): " Text, \
2522 __FUNCTION__, __LINE__, __VA_ARGS__); \
2523 *__kernel_ptr__ -= 1
2525 gcmINLINE
static void
2526 __dummy_kfooter_arg(
2527 IN gctCONST_STRING Text
,
2532 # define gcmkFOOTER_ARG __dummy_kfooter_arg
2535 #define gcmOPT_VALUE(ptr) (((ptr) == gcvNULL) ? 0 : *(ptr))
2536 #define gcmOPT_POINTER(ptr) (((ptr) == gcvNULL) ? gcvNULL : *(ptr))
2537 #define gcmOPT_STRING(ptr) (((ptr) == gcvNULL) ? "(nil)" : (ptr))
2541 IN gctCONST_STRING Message
,
2547 IN gctUINT ArgumentSize
,
2548 IN gctCONST_STRING Message
,
2554 IN gctCONST_STRING Message
,
2560 IN gctCONST_STRING Message
,
2564 #define gcmPRINT gcoOS_Print
2565 #define gcmkPRINT gckOS_Print
2566 #define gcmkPRINT_N gckOS_PrintN
2568 #if gcdPRINT_VERSION
2569 # define gcmPRINT_VERSION() do { \
2570 _gcmPRINT_VERSION(gcm); \
2573 # define gcmkPRINT_VERSION() _gcmPRINT_VERSION(gcmk)
2574 # define _gcmPRINT_VERSION(prefix) \
2575 prefix##TRACE(gcvLEVEL_ERROR, \
2576 "Vivante HAL version %d.%d.%d build %d %s %s", \
2577 gcvVERSION_MAJOR, gcvVERSION_MINOR, gcvVERSION_PATCH, \
2578 gcvVERSION_BUILD, gcvVERSION_DATE, gcvVERSION_TIME )
2580 # define gcmPRINT_VERSION() do { gcmSTACK_DUMP(); } while (gcvFALSE)
2581 # define gcmkPRINT_VERSION() do { } while (gcvFALSE)
2584 typedef enum _gceDUMP_BUFFER
2586 gceDUMP_BUFFER_CONTEXT
,
2587 gceDUMP_BUFFER_USER
,
2588 gceDUMP_BUFFER_KERNEL
,
2589 gceDUMP_BUFFER_LINK
,
2590 gceDUMP_BUFFER_WAITLINK
,
2591 gceDUMP_BUFFER_FROM_USER
,
2598 IN gctPOINTER Buffer
,
2600 IN gceDUMP_BUFFER Type
,
2601 IN gctBOOL CopyMessage
2604 #define gcmkDUMPBUFFER gckOS_DumpBuffer
2607 # define gcmkDUMPCOMMAND(Os, Buffer, Size, Type, CopyMessage) \
2608 gcmkDUMPBUFFER(Os, Buffer, Size, Type, CopyMessage)
2610 # define gcmkDUMPCOMMAND(Os, Buffer, Size, Type, CopyMessage)
2613 #if gcmIS_DEBUG(gcdDEBUG_CODE)
2617 gctCONST_STRING CallerName
,
2619 gctUINT32 DmaAddress
2622 # define gcmkDEBUGFLUSH(DmaAddress) \
2623 gckOS_DebugFlush(__FUNCTION__, __LINE__, DmaAddress)
2625 # define gcmkDEBUGFLUSH(DmaAddress)
2629 /*******************************************************************************
2633 ** Print a dump message.
2637 ** gctSTRING Message.
2639 ** ... Optional arguments.
2645 IN gctCONST_STRING String
,
2648 # define gcmDUMP gcfDump
2649 #elif gcdHAS_ELLIPSES
2650 # define gcmDUMP(...)
2652 gcmINLINE
static void
2655 IN gctCONST_STRING Message
,
2660 # define gcmDUMP __dummy_dump
2663 /*******************************************************************************
2667 ** Add data to the dump.
2674 ** gctPOINTER Logical
2675 ** Logical address of buffer.
2681 #if gcdDUMP || gcdDUMP_COMMAND
2686 IN gctPOINTER Logical
,
2689 # define gcmDUMP_DATA gcfDumpData
2690 #elif gcdHAS_ELLIPSES
2691 # define gcmDUMP_DATA(...)
2693 gcmINLINE
static void
2697 IN gctPOINTER Logical
,
2702 # define gcmDUMP_DATA __dummy_dump_data
2705 /*******************************************************************************
2709 ** Print a buffer to the dump.
2716 ** gctUINT32 Physical
2717 ** Physical address of buffer.
2719 ** gctPOINTER Logical
2720 ** Logical address of buffer.
2723 ** Offset into buffer.
2729 #if gcdDUMP || gcdDUMP_COMMAND
2734 IN gctUINT32 Physical
,
2735 IN gctPOINTER Logical
,
2736 IN gctUINT32 Offset
,
2739 # define gcmDUMP_BUFFER gcfDumpBuffer
2740 #elif gcdHAS_ELLIPSES
2741 # define gcmDUMP_BUFFER(...)
2743 gcmINLINE
static void
2744 __dummy_dump_buffer(
2747 IN gctUINT32 Physical
,
2748 IN gctPOINTER Logical
,
2749 IN gctUINT32 Offset
,
2754 # define gcmDUMP_BUFFER __dummy_dump_buffer
2757 /*******************************************************************************
2761 ** Print a dump message for a high level API prefixed by the function name.
2765 ** gctSTRING Message.
2767 ** ... Optional arguments.
2772 IN gctCONST_STRING String
,
2775 # define gcmDUMP_API gcfDumpApi
2776 #elif gcdHAS_ELLIPSES
2777 # define gcmDUMP_API(...)
2779 gcmINLINE
static void
2781 IN gctCONST_STRING Message
,
2786 # define gcmDUMP_API __dummy_dump_api
2789 /*******************************************************************************
2791 ** gcmDUMP_API_ARRAY
2793 ** Print an array of data.
2797 ** gctUINT32_PTR Pointer to array.
2803 IN gctCONST_POINTER Data
,
2806 # define gcmDUMP_API_ARRAY gcfDumpArray
2807 #elif gcdHAS_ELLIPSES
2808 # define gcmDUMP_API_ARRAY(...)
2810 gcmINLINE
static void
2811 __dummy_dump_api_array(
2812 IN gctCONST_POINTER Data
,
2817 # define gcmDUMP_API_ARRAY __dummy_dump_api_array
2820 /*******************************************************************************
2822 ** gcmDUMP_API_ARRAY_TOKEN
2824 ** Print an array of data terminated by a token.
2828 ** gctUINT32_PTR Pointer to array.
2829 ** gctUINT32 Termination.
2834 IN gctCONST_POINTER Data
,
2835 IN gctUINT32 Termination
2837 # define gcmDUMP_API_ARRAY_TOKEN gcfDumpArrayToken
2838 #elif gcdHAS_ELLIPSES
2839 # define gcmDUMP_API_ARRAY_TOKEN(...)
2841 gcmINLINE
static void
2842 __dummy_dump_api_array_token(
2843 IN gctCONST_POINTER Data
,
2844 IN gctUINT32 Termination
2848 # define gcmDUMP_API_ARRAY_TOKEN __dummy_dump_api_array_token
2851 /*******************************************************************************
2855 ** Print an array of bytes.
2859 ** gctCONST_POINTER Pointer to array.
2865 IN gctCONST_POINTER Data
,
2868 # define gcmDUMP_API_DATA gcfDumpApiData
2869 #elif gcdHAS_ELLIPSES
2870 # define gcmDUMP_API_DATA(...)
2872 gcmINLINE
static void
2873 __dummy_dump_api_data(
2874 IN gctCONST_POINTER Data
,
2879 # define gcmDUMP_API_DATA __dummy_dump_api_data
2882 /*******************************************************************************
2886 ** Print a message to the shader debugger.
2891 ** ... Optional arguments.
2894 #define gcmTRACE_RELEASE gcoOS_DebugShaderTrace
2897 gcoOS_DebugShaderTrace(
2898 IN gctCONST_STRING Message
,
2903 gcoOS_SetDebugShaderFiles(
2904 IN gctCONST_STRING VSFileName
,
2905 IN gctCONST_STRING FSFileName
2909 gcoOS_SetDebugShaderFileType(
2910 IN gctUINT32 ShaderType
2914 gcoOS_EnableDebugBuffer(
2918 /*******************************************************************************
2922 ** Break into the debugger. In retail mode this macro does nothing.
2939 #if gcmIS_DEBUG(gcdDEBUG_BREAK)
2940 # define gcmBREAK gcoOS_DebugBreak
2941 # define gcmkBREAK gckOS_DebugBreak
2944 # define gcmkBREAK()
2947 /*******************************************************************************
2951 ** Evaluate an expression and break into the debugger if the expression
2952 ** evaluates to false. In retail mode this macro does nothing.
2956 ** exp Expression to evaluate.
2958 #if gcmIS_DEBUG(gcdDEBUG_ASSERT)
2959 # define _gcmASSERT(prefix, exp) \
2964 prefix##TRACE(gcvLEVEL_ERROR, \
2965 #prefix "ASSERT at %s(%d)", \
2966 __FUNCTION__, __LINE__); \
2967 prefix##TRACE(gcvLEVEL_ERROR, \
2973 # define gcmASSERT(exp) _gcmASSERT(gcm, exp)
2974 # define gcmkASSERT(exp) _gcmASSERT(gcmk, exp)
2976 # define gcmASSERT(exp)
2977 # define gcmkASSERT(exp)
2980 /*******************************************************************************
2984 ** Verify if an expression returns true. If the expression does not
2985 ** evaluates to true, an assertion will happen in debug mode.
2989 ** exp Expression to evaluate.
2991 #if gcmIS_DEBUG(gcdDEBUG_ASSERT)
2992 # define gcmVERIFY(exp) gcmASSERT(exp)
2993 # define gcmkVERIFY(exp) gcmkASSERT(exp)
2995 # define gcmVERIFY(exp) exp
2996 # define gcmkVERIFY(exp) exp
2999 /*******************************************************************************
3003 ** Verify a fucntion returns gcvSTATUS_OK. If the function does not return
3004 ** gcvSTATUS_OK, an assertion will happen in debug mode.
3008 ** func Function to evaluate.
3021 #if gcmIS_DEBUG(gcdDEBUG_ASSERT)
3022 # define gcmVERIFY_OK(func) \
3025 gceSTATUS verifyStatus = func; \
3026 gcoOS_Verify(verifyStatus); \
3027 if (verifyStatus != gcvSTATUS_OK) \
3031 "gcmVERIFY_OK(%d): function returned %d", \
3032 __LINE__, verifyStatus \
3035 gcmASSERT(verifyStatus == gcvSTATUS_OK); \
3038 # define gcmkVERIFY_OK(func) \
3041 gceSTATUS verifyStatus = func; \
3042 if (verifyStatus != gcvSTATUS_OK) \
3046 "gcmkVERIFY_OK(%d): function returned %d", \
3047 __LINE__, verifyStatus \
3050 gckOS_Verify(verifyStatus); \
3051 gcmkASSERT(verifyStatus == gcvSTATUS_OK); \
3055 # define gcmVERIFY_OK(func) func
3056 # define gcmkVERIFY_OK(func) func
3060 gcoOS_DebugStatus2Name(
3065 gckOS_DebugStatus2Name(
3069 /*******************************************************************************
3073 ** Executes a break statement on error.
3077 ** 'status' variable of gceSTATUS type must be defined.
3081 ** func Function to evaluate.
3083 #define _gcmERR_BREAK(prefix, func) \
3085 if (gcmIS_ERROR(status)) \
3087 prefix##PRINT_VERSION(); \
3088 prefix##TRACE(gcvLEVEL_ERROR, \
3089 #prefix "ERR_BREAK: status=%d(%s) @ %s(%d)", \
3090 status, gcoOS_DebugStatus2Name(status), __FUNCTION__, __LINE__); \
3093 do { } while (gcvFALSE)
3094 #define _gcmkERR_BREAK(prefix, func) \
3096 if (gcmIS_ERROR(status)) \
3098 prefix##PRINT_VERSION(); \
3099 prefix##TRACE(gcvLEVEL_ERROR, \
3100 #prefix "ERR_BREAK: status=%d(%s) @ %s(%d)", \
3101 status, gckOS_DebugStatus2Name(status), __FUNCTION__, __LINE__); \
3104 do { } while (gcvFALSE)
3105 #define gcmERR_BREAK(func) _gcmERR_BREAK(gcm, func)
3106 #define gcmkERR_BREAK(func) _gcmkERR_BREAK(gcmk, func)
3108 /*******************************************************************************
3112 ** Executes a return on error.
3116 ** 'status' variable of gceSTATUS type must be defined.
3120 ** func Function to evaluate.
3122 #define _gcmERR_RETURN(prefix, func) \
3124 if (gcmIS_ERROR(status)) \
3126 prefix##PRINT_VERSION(); \
3127 prefix##TRACE(gcvLEVEL_ERROR, \
3128 #prefix "ERR_RETURN: status=%d(%s) @ %s(%d)", \
3129 status, gcoOS_DebugStatus2Name(status), __FUNCTION__, __LINE__); \
3133 do { } while (gcvFALSE)
3134 #define _gcmkERR_RETURN(prefix, func) \
3136 if (gcmIS_ERROR(status)) \
3138 prefix##PRINT_VERSION(); \
3139 prefix##TRACE(gcvLEVEL_ERROR, \
3140 #prefix "ERR_RETURN: status=%d(%s) @ %s(%d)", \
3141 status, gckOS_DebugStatus2Name(status), __FUNCTION__, __LINE__); \
3145 do { } while (gcvFALSE)
3146 #define gcmERR_RETURN(func) _gcmERR_RETURN(gcm, func)
3147 #define gcmkERR_RETURN(func) _gcmkERR_RETURN(gcmk, func)
3150 /*******************************************************************************
3154 ** Jump to the error handler in case there is an error.
3158 ** 'status' variable of gceSTATUS type must be defined.
3162 ** func Function to evaluate.
3164 #define _gcmONERROR(prefix, func) \
3168 if (gcmIS_ERROR(status)) \
3170 prefix##PRINT_VERSION(); \
3171 prefix##TRACE(gcvLEVEL_ERROR, \
3172 #prefix "ONERROR: status=%d(%s) @ %s(%d)", \
3173 status, gcoOS_DebugStatus2Name(status), __FUNCTION__, __LINE__); \
3178 #define _gcmkONERROR(prefix, func) \
3182 if (gcmIS_ERROR(status)) \
3184 prefix##PRINT_VERSION(); \
3185 prefix##TRACE(gcvLEVEL_ERROR, \
3186 #prefix "ONERROR: status=%d(%s) @ %s(%d)", \
3187 status, gckOS_DebugStatus2Name(status), __FUNCTION__, __LINE__); \
3192 #define gcmONERROR(func) _gcmONERROR(gcm, func)
3193 #define gcmkONERROR(func) _gcmkONERROR(gcmk, func)
3195 /*******************************************************************************
3199 ** Verifies whether the surface is locked.
3203 ** surfaceInfo Pointer to the surface iniformational structure.
3205 #define gcmVERIFY_LOCK(surfaceInfo) \
3206 if (!surfaceInfo->node.valid) \
3208 gcmONERROR(gcvSTATUS_MEMORY_UNLOCKED); \
3211 /*******************************************************************************
3213 ** gcmVERIFY_NODE_LOCK
3215 ** Verifies whether the surface node is locked.
3219 ** surfaceInfo Pointer to the surface iniformational structure.
3221 #define gcmVERIFY_NODE_LOCK(surfaceNode) \
3222 if (!surfaceNode->valid) \
3224 status = gcvSTATUS_MEMORY_UNLOCKED; \
3227 do { } while (gcvFALSE)
3229 /*******************************************************************************
3231 ** gcmBADOBJECT_BREAK
3233 ** Executes a break statement on bad object.
3237 ** obj Object to test.
3238 ** t Expected type of the object.
3240 #define gcmBADOBJECT_BREAK(obj, t) \
3241 if ((obj == gcvNULL) \
3242 || (((gcsOBJECT *)(obj))->type != t) \
3245 status = gcvSTATUS_INVALID_OBJECT; \
3248 do { } while (gcvFALSE)
3250 /*******************************************************************************
3254 ** Executes a break statement on error.
3258 ** 'status' variable of gceSTATUS type must be defined.
3262 ** func Function to evaluate.
3264 #define _gcmCHECK_STATUS(prefix, func) \
3268 if (gcmIS_ERROR(last)) \
3270 prefix##TRACE(gcvLEVEL_ERROR, \
3271 #prefix "CHECK_STATUS: status=%d(%s) @ %s(%d)", \
3272 last, gcoOS_DebugStatus2Name(last), __FUNCTION__, __LINE__); \
3277 #define _gcmkCHECK_STATUS(prefix, func) \
3281 if (gcmIS_ERROR(last)) \
3283 prefix##TRACE(gcvLEVEL_ERROR, \
3284 #prefix "CHECK_STATUS: status=%d(%s) @ %s(%d)", \
3285 last, gckOS_DebugStatus2Name(last), __FUNCTION__, __LINE__); \
3290 #define gcmCHECK_STATUS(func) _gcmCHECK_STATUS(gcm, func)
3291 #define gcmkCHECK_STATUS(func) _gcmkCHECK_STATUS(gcmk, func)
3293 /*******************************************************************************
3295 ** gcmVERIFY_ARGUMENT
3297 ** Assert if an argument does not apply to the specified expression. If
3298 ** the argument evaluates to false, gcvSTATUS_INVALID_ARGUMENT will be
3299 ** returned from the current function. In retail mode this macro does
3304 ** arg Argument to evaluate.
3306 # define _gcmVERIFY_ARGUMENT(prefix, arg) \
3311 prefix##TRACE(gcvLEVEL_ERROR, #prefix "VERIFY_ARGUMENT failed:"); \
3312 prefix##ASSERT(arg); \
3313 prefix##FOOTER_ARG("status=%d", gcvSTATUS_INVALID_ARGUMENT); \
3314 return gcvSTATUS_INVALID_ARGUMENT; \
3318 # define gcmVERIFY_ARGUMENT(arg) _gcmVERIFY_ARGUMENT(gcm, arg)
3319 # define gcmkVERIFY_ARGUMENT(arg) _gcmVERIFY_ARGUMENT(gcmk, arg)
3321 /*******************************************************************************
3323 ** gcmDEBUG_VERIFY_ARGUMENT
3325 ** Works just like gcmVERIFY_ARGUMENT, but is only valid in debug mode.
3326 ** Use this to verify arguments inside non-public API functions.
3329 # define gcmDEBUG_VERIFY_ARGUMENT(arg) _gcmVERIFY_ARGUMENT(gcm, arg)
3330 # define gcmkDEBUG_VERIFY_ARGUMENT(arg) _gcmkVERIFY_ARGUMENT(gcm, arg)
3332 # define gcmDEBUG_VERIFY_ARGUMENT(arg)
3333 # define gcmkDEBUG_VERIFY_ARGUMENT(arg)
3335 /*******************************************************************************
3337 ** gcmVERIFY_ARGUMENT_RETURN
3339 ** Assert if an argument does not apply to the specified expression. If
3340 ** the argument evaluates to false, gcvSTATUS_INVALID_ARGUMENT will be
3341 ** returned from the current function. In retail mode this macro does
3346 ** arg Argument to evaluate.
3348 # define _gcmVERIFY_ARGUMENT_RETURN(prefix, arg, value) \
3353 prefix##TRACE(gcvLEVEL_ERROR, \
3354 #prefix "gcmVERIFY_ARGUMENT_RETURN failed:"); \
3355 prefix##ASSERT(arg); \
3356 prefix##FOOTER_ARG("value=%d", value); \
3361 # define gcmVERIFY_ARGUMENT_RETURN(arg, value) \
3362 _gcmVERIFY_ARGUMENT_RETURN(gcm, arg, value)
3363 # define gcmkVERIFY_ARGUMENT_RETURN(arg, value) \
3364 _gcmVERIFY_ARGUMENT_RETURN(gcmk, arg, value)
3366 #define MAX_LOOP_COUNT 0x7FFFFFFF
3372 #endif /* __gc_hal_base_h_ */