ENGR00156850 gpu-viv: add gpu-viv driver source
[wandboard.git] / drivers / mxc / gpu-viv / hal / kernel / inc / gc_hal_base.h
blob1c1c1adf9f0dfceeb88e57689c55054e633b587f
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"
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
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;
45 #ifndef VIVANTE_NO_3D
46 typedef struct _gco3D * gco3D;
47 #endif
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;
61 #if gcdENABLE_VG
62 typedef struct _gcoVG * gcoVG;
63 typedef struct _gcsCOMPLETION_SIGNAL * gcsCOMPLETION_SIGNAL_PTR;
64 typedef struct _gcsCONTEXT_MAP * gcsCONTEXT_MAP_PTR;
65 #else
66 typedef void * gcoVG;
67 #endif
69 /******************************************************************************\
70 ******************************* Process local storage *************************
71 \******************************************************************************/
73 typedef struct _gcsPLS * gcsPLS_PTR;
74 typedef struct _gcsPLS
76 /* Global objects. */
77 gcoOS os;
78 gcoHAL hal;
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;
99 gcsPLS;
101 extern gcsPLS gcPLS;
103 /******************************************************************************\
104 ******************************* Thread local storage *************************
105 \******************************************************************************/
107 typedef struct _gcsTLS * gcsTLS_PTR;
109 typedef void (* gctTLS_DESTRUCTOR) (
110 gcsTLS_PTR TLS
113 typedef struct _gcsTLS
115 gceHARDWARE_TYPE currentType;
116 gcoHARDWARE hardware;
117 /* Only for separated 3D and 2D */
118 gcoHARDWARE hardware2D;
119 #if gcdENABLE_VG
120 gcoVGHARDWARE vg;
121 #endif /* gcdENABLE_VG */
122 gctPOINTER context;
123 gctTLS_DESTRUCTOR destructor;
124 gctBOOL ProcessExiting;
126 gcsTLS;
128 /******************************************************************************\
129 ********************************* Enumerations *********************************
130 \******************************************************************************/
132 typedef enum _gcePLS_VALUE
134 gcePLS_VALUE_EGL_DISPLAY_INFO,
135 gcePLS_VALUE_EGL_SURFACE_INFO
137 gcePLS_VALUE;
139 /* Video memory pool type. */
140 typedef enum _gcePOOL
142 gcvPOOL_UNKNOWN = 0,
143 gcvPOOL_DEFAULT,
144 gcvPOOL_LOCAL,
145 gcvPOOL_LOCAL_INTERNAL,
146 gcvPOOL_LOCAL_EXTERNAL,
147 gcvPOOL_UNIFIED,
148 gcvPOOL_SYSTEM,
149 gcvPOOL_VIRTUAL,
150 gcvPOOL_USER,
151 gcvPOOL_CONTIGUOUS,
153 gcvPOOL_NUMBER_OF_POOLS
155 gcePOOL;
157 #ifndef VIVANTE_NO_3D
158 /* Blending functions. */
159 typedef enum _gceBLEND_FUNCTION
161 gcvBLEND_ZERO,
162 gcvBLEND_ONE,
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,
177 gceBLEND_FUNCTION;
179 /* Blending modes. */
180 typedef enum _gceBLEND_MODE
182 gcvBLEND_ADD,
183 gcvBLEND_SUBTRACT,
184 gcvBLEND_REVERSE_SUBTRACT,
185 gcvBLEND_MIN,
186 gcvBLEND_MAX,
188 gceBLEND_MODE;
190 /* API flags. */
191 typedef enum _gceAPI
193 gcvAPI_D3D = 0x1,
194 gcvAPI_OPENGL = 0x2,
195 gcvAPI_OPENVG = 0x3,
196 gcvAPI_OPENCL = 0x4,
198 gceAPI;
200 /* Depth modes. */
201 typedef enum _gceDEPTH_MODE
203 gcvDEPTH_NONE,
204 gcvDEPTH_Z,
205 gcvDEPTH_W,
207 gceDEPTH_MODE;
208 #endif /* VIVANTE_NO_3D */
210 typedef enum _gceWHERE
212 gcvWHERE_COMMAND,
213 gcvWHERE_RASTER,
214 gcvWHERE_PIXEL,
216 gceWHERE;
218 typedef enum _gceHOW
220 gcvHOW_SEMAPHORE = 0x1,
221 gcvHOW_STALL = 0x2,
222 gcvHOW_SEMAPHORE_STALL = 0x3,
224 gceHOW;
226 #if gcdENABLE_VG
227 /* gcsHAL_Limits*/
228 typedef struct _gcsHAL_LIMITS
230 /* chip info */
231 gceCHIPMODEL chipModel;
232 gctUINT32 chipRevision;
233 gctUINT32 featureCount;
234 gctUINT32 *chipFeatures;
236 /* target caps */
237 gctUINT32 maxWidth;
238 gctUINT32 maxHeight;
239 gctUINT32 multiTargetCount;
240 gctUINT32 maxSamples;
242 }gcsHAL_LIMITS;
243 #endif
245 /******************************************************************************\
246 ********************************* gcoHAL Object *********************************
247 \******************************************************************************/
249 /* Construct a new gcoHAL object. */
250 gceSTATUS
251 gcoHAL_Construct(
252 IN gctPOINTER Context,
253 IN gcoOS Os,
254 OUT gcoHAL * Hal
257 /* Destroy an gcoHAL object. */
258 gceSTATUS
259 gcoHAL_Destroy(
260 IN gcoHAL Hal
263 /* Get pointer to gco2D object. */
264 gceSTATUS
265 gcoHAL_Get2DEngine(
266 IN gcoHAL Hal,
267 OUT gco2D * Engine
270 #ifndef VIVANTE_NO_3D
271 /* Get pointer to gco3D object. */
272 gceSTATUS
273 gcoHAL_Get3DEngine(
274 IN gcoHAL Hal,
275 OUT gco3D * Engine
277 #endif /* VIVANTE_NO_3D */
279 /* Verify whether the specified feature is available in hardware. */
280 gceSTATUS
281 gcoHAL_IsFeatureAvailable(
282 IN gcoHAL Hal,
283 IN gceFEATURE Feature
286 /* Query the identity of the hardware. */
287 gceSTATUS
288 gcoHAL_QueryChipIdentity(
289 IN gcoHAL Hal,
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(
298 IN gcoHAL Hal,
299 OUT gctUINT32* NumFeatures,
300 OUT gctUINT32* ChipMinorFeatures
303 /* Query the amount of video memory. */
304 gceSTATUS
305 gcoHAL_QueryVideoMemory(
306 IN gcoHAL Hal,
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. */
316 gceSTATUS
317 gcoHAL_MapMemory(
318 IN gcoHAL Hal,
319 IN gctPHYS_ADDR Physical,
320 IN gctSIZE_T NumberOfBytes,
321 OUT gctPOINTER * Logical
324 /* Unmap video memory. */
325 gceSTATUS
326 gcoHAL_UnmapMemory(
327 IN gcoHAL Hal,
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. */
334 gceSTATUS
335 gcoHAL_ScheduleUnmapMemory(
336 IN gcoHAL Hal,
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. */
343 gceSTATUS
344 gcoHAL_ScheduleUnmapUserMemory(
345 IN gcoHAL Hal,
346 IN gctPOINTER Info,
347 IN gctSIZE_T Size,
348 IN gctUINT32 Address,
349 IN gctPOINTER Memory
352 /* Commit the current command buffer. */
353 gceSTATUS
354 gcoHAL_Commit(
355 IN gcoHAL Hal,
356 IN gctBOOL Stall
359 /* Query the tile capabilities. */
360 gceSTATUS
361 gcoHAL_QueryTiled(
362 IN gcoHAL Hal,
363 OUT gctINT32 * TileWidth2D,
364 OUT gctINT32 * TileHeight2D,
365 OUT gctINT32 * TileWidth3D,
366 OUT gctINT32 * TileHeight3D
369 gceSTATUS
370 gcoHAL_Compact(
371 IN gcoHAL Hal
374 #if VIVANTE_PROFILER /*gcdENABLE_PROFILING*/
375 gceSTATUS
376 gcoHAL_ProfileStart(
377 IN gcoHAL Hal
380 gceSTATUS
381 gcoHAL_ProfileEnd(
382 IN gcoHAL Hal,
383 IN gctCONST_STRING Title
385 #endif
387 /* Power Management */
388 gceSTATUS
389 gcoHAL_SetPowerManagementState(
390 IN gcoHAL Hal,
391 IN gceCHIPPOWERSTATE State
394 gceSTATUS
395 gcoHAL_QueryPowerManagementState(
396 IN gcoHAL Hal,
397 OUT gceCHIPPOWERSTATE *State
400 /* Set the filter type for filter blit. */
401 gceSTATUS
402 gcoHAL_SetFilterType(
403 IN gcoHAL Hal,
404 IN gceFILTER_TYPE FilterType
407 gceSTATUS
408 gcoHAL_GetDump(
409 IN gcoHAL Hal,
410 OUT gcoDUMP * Dump
413 /* Call the kernel HAL layer. */
414 gceSTATUS
415 gcoHAL_Call(
416 IN gcoHAL Hal,
417 IN OUT gcsHAL_INTERFACE_PTR Interface
420 /* Schedule an event. */
421 gceSTATUS
422 gcoHAL_ScheduleEvent(
423 IN gcoHAL Hal,
424 IN OUT gcsHAL_INTERFACE_PTR Interface
427 /* Destroy a surface. */
428 gceSTATUS
429 gcoHAL_DestroySurface(
430 IN gcoHAL Hal,
431 IN gcoSURF Surface
434 /* Request a start/stop timestamp. */
435 gceSTATUS
436 gcoHAL_SetTimer(
437 IN gcoHAL Hal,
438 IN gctUINT32 Index,
439 IN gctBOOL Start
442 /* Get Time delta from a Timer in microseconds. */
443 gceSTATUS
444 gcoHAL_GetTimerTime(
445 IN gcoHAL Hal,
446 IN gctUINT32 Timer,
447 OUT gctINT32_PTR TimeDelta
450 /* set timeout value. */
451 gceSTATUS
452 gcoHAL_SetTimeOut(
453 IN gcoHAL Hal,
454 IN gctUINT32 timeOut
457 gceSTATUS
458 gcoHAL_SetHardwareType(
459 IN gcoHAL Hal,
460 IN gceHARDWARE_TYPE HardwardType
463 gceSTATUS
464 gcoHAL_GetHardwareType(
465 IN gcoHAL Hal,
466 OUT gceHARDWARE_TYPE * HardwardType
469 gceSTATUS
470 gcoHAL_QueryChipCount(
471 IN gcoHAL Hal,
472 OUT gctINT32 * Count
475 gceSTATUS
476 gcoHAL_QuerySeparated3D2D(
477 IN gcoHAL Hal
480 /* Get pointer to gcoVG object. */
481 gceSTATUS
482 gcoHAL_GetVGEngine(
483 IN gcoHAL Hal,
484 OUT gcoVG * Engine
487 #if gcdENABLE_VG
488 gceSTATUS
489 gcoHAL_QueryChipLimits(
490 IN gcoHAL Hal,
491 IN gctINT32 Chip,
492 OUT gcsHAL_LIMITS *Limits);
494 gceSTATUS
495 gcoHAL_QueryChipFeature(
496 IN gcoHAL Hal,
497 IN gctINT32 Chip,
498 IN gceFEATURE Feature);
500 #endif
501 /******************************************************************************\
502 ********************************** gcoOS Object *********************************
503 \******************************************************************************/
505 /* Get PLS value for given key */
506 gctPOINTER
507 gcoOS_GetPLSValue(
508 IN gcePLS_VALUE key
511 /* Set PLS value of a given key */
512 void
513 gcoOS_SetPLSValue(
514 IN gcePLS_VALUE key,
515 OUT gctPOINTER value
518 /* Get access to the thread local storage. */
519 gceSTATUS
520 gcoOS_GetTLS(
521 OUT gcsTLS_PTR * TLS
524 /* Destroy the objects associated with the current thread. */
525 void
526 gcoOS_FreeThreadData(
527 IN gctBOOL ProcessExiting
530 /* Construct a new gcoOS object. */
531 gceSTATUS
532 gcoOS_Construct(
533 IN gctPOINTER Context,
534 OUT gcoOS * Os
537 /* Destroy an gcoOS object. */
538 gceSTATUS
539 gcoOS_Destroy(
540 IN gcoOS Os
543 /* Get the base address for the physical memory. */
544 gceSTATUS
545 gcoOS_GetBaseAddress(
546 IN gcoOS Os,
547 OUT gctUINT32_PTR BaseAddress
550 /* Allocate memory from the heap. */
551 gceSTATUS
552 gcoOS_Allocate(
553 IN gcoOS Os,
554 IN gctSIZE_T Bytes,
555 OUT gctPOINTER * Memory
558 /* Free allocated memory. */
559 gceSTATUS
560 gcoOS_Free(
561 IN gcoOS Os,
562 IN gctPOINTER Memory
565 /* Allocate memory. */
566 gceSTATUS
567 gcoOS_AllocateMemory(
568 IN gcoOS Os,
569 IN gctSIZE_T Bytes,
570 OUT gctPOINTER * Memory
573 /* Free memory. */
574 gceSTATUS
575 gcoOS_FreeMemory(
576 IN gcoOS Os,
577 IN gctPOINTER Memory
580 /* Allocate contiguous memory. */
581 gceSTATUS
582 gcoOS_AllocateContiguous(
583 IN gcoOS Os,
584 IN gctBOOL InUserSpace,
585 IN OUT gctSIZE_T * Bytes,
586 OUT gctPHYS_ADDR * Physical,
587 OUT gctPOINTER * Logical
590 /* Free contiguous memory. */
591 gceSTATUS
592 gcoOS_FreeContiguous(
593 IN gcoOS Os,
594 IN gctPHYS_ADDR Physical,
595 IN gctPOINTER Logical,
596 IN gctSIZE_T Bytes
599 #if gcdENABLE_BANK_ALIGNMENT
600 gceSTATUS
601 gcoOS_GetBankOffsetBytes(
602 IN gcoOS Os,
603 IN gceSURF_TYPE Type,
604 IN gctUINT32 Stride,
605 IN gctUINT32_PTR Bytes
607 #endif
609 /* Map user memory. */
610 gceSTATUS
611 gcoOS_MapUserMemory(
612 IN gcoOS Os,
613 IN gctPOINTER Memory,
614 IN gctSIZE_T Size,
615 OUT gctPOINTER * Info,
616 OUT gctUINT32_PTR Address
619 /* Unmap user memory. */
620 gceSTATUS
621 gcoOS_UnmapUserMemory(
622 IN gcoOS Os,
623 IN gctPOINTER Memory,
624 IN gctSIZE_T Size,
625 IN gctPOINTER Info,
626 IN gctUINT32 Address
629 /* Device I/O Control call to the kernel HAL layer. */
630 gceSTATUS
631 gcoOS_DeviceControl(
632 IN gcoOS Os,
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. */
641 gceSTATUS
642 gcoOS_AllocateNonPagedMemory(
643 IN gcoOS Os,
644 IN gctBOOL InUserSpace,
645 IN OUT gctSIZE_T * Bytes,
646 OUT gctPHYS_ADDR * Physical,
647 OUT gctPOINTER * Logical
650 /* Free non paged memory. */
651 gceSTATUS
652 gcoOS_FreeNonPagedMemory(
653 IN gcoOS Os,
654 IN gctSIZE_T Bytes,
655 IN gctPHYS_ADDR Physical,
656 IN gctPOINTER Logical
659 #define gcmOS_SAFE_FREE(os, mem) \
660 gcoOS_Free(os, mem); \
661 mem = gcvNULL
663 #define gcmkOS_SAFE_FREE(os, mem) \
664 gckOS_Free(os, mem); \
665 mem = gcvNULL
667 typedef enum _gceFILE_MODE
669 gcvFILE_CREATE = 0,
670 gcvFILE_APPEND,
671 gcvFILE_READ,
672 gcvFILE_CREATETEXT,
673 gcvFILE_APPENDTEXT,
674 gcvFILE_READTEXT,
676 gceFILE_MODE;
678 /* Open a file. */
679 gceSTATUS
680 gcoOS_Open(
681 IN gcoOS Os,
682 IN gctCONST_STRING FileName,
683 IN gceFILE_MODE Mode,
684 OUT gctFILE * File
687 /* Close a file. */
688 gceSTATUS
689 gcoOS_Close(
690 IN gcoOS Os,
691 IN gctFILE File
694 /* Read data from a file. */
695 gceSTATUS
696 gcoOS_Read(
697 IN gcoOS Os,
698 IN gctFILE File,
699 IN gctSIZE_T ByteCount,
700 IN gctPOINTER Data,
701 OUT gctSIZE_T * ByteRead
704 /* Write data to a file. */
705 gceSTATUS
706 gcoOS_Write(
707 IN gcoOS Os,
708 IN gctFILE File,
709 IN gctSIZE_T ByteCount,
710 IN gctCONST_POINTER Data
713 /* Flush data to a file. */
714 gceSTATUS
715 gcoOS_Flush(
716 IN gcoOS Os,
717 IN gctFILE File
720 /* Create an endpoint for communication. */
721 gceSTATUS
722 gcoOS_Socket(
723 IN gcoOS Os,
724 IN gctINT Domain,
725 IN gctINT Type,
726 IN gctINT Protocol,
727 OUT gctINT *SockFd
730 /* Close a socket. */
731 gceSTATUS
732 gcoOS_CloseSocket(
733 IN gcoOS Os,
734 IN gctINT SockFd
737 /* Initiate a connection on a socket. */
738 gceSTATUS
739 gcoOS_Connect(
740 IN gcoOS Os,
741 IN gctINT SockFd,
742 IN gctCONST_POINTER HostName,
743 IN gctUINT Port);
745 /* Shut down part of connection on a socket. */
746 gceSTATUS
747 gcoOS_Shutdown(
748 IN gcoOS Os,
749 IN gctINT SockFd,
750 IN gctINT How
753 /* Send a message on a socket. */
754 gceSTATUS
755 gcoOS_Send(
756 IN gcoOS Os,
757 IN gctINT SockFd,
758 IN gctSIZE_T ByteCount,
759 IN gctCONST_POINTER Data,
760 IN gctINT Flags
763 /* Initiate a connection on a socket. */
764 gceSTATUS
765 gcoOS_WaitForSend(
766 IN gcoOS Os,
767 IN gctINT SockFd,
768 IN gctINT Seconds,
769 IN gctINT MicroSeconds);
771 /* Get environment variable value. */
772 gceSTATUS
773 gcoOS_GetEnv(
774 IN gcoOS Os,
775 IN gctCONST_STRING VarName,
776 OUT gctSTRING * Value
779 /* Get current working directory. */
780 gceSTATUS
781 gcoOS_GetCwd(
782 IN gcoOS Os,
783 IN gctINT SizeInBytes,
784 OUT gctSTRING Buffer
787 /* Get file status info. */
788 gceSTATUS
789 gcoOS_Stat(
790 IN gcoOS Os,
791 IN gctCONST_STRING FileName,
792 OUT gctPOINTER Buffer
795 typedef enum _gceFILE_WHENCE
797 gcvFILE_SEEK_SET,
798 gcvFILE_SEEK_CUR,
799 gcvFILE_SEEK_END
801 gceFILE_WHENCE;
803 /* Set the current position of a file. */
804 gceSTATUS
805 gcoOS_Seek(
806 IN gcoOS Os,
807 IN gctFILE File,
808 IN gctUINT32 Offset,
809 IN gceFILE_WHENCE Whence
812 /* Set the current position of a file. */
813 gceSTATUS
814 gcoOS_SetPos(
815 IN gcoOS Os,
816 IN gctFILE File,
817 IN gctUINT32 Position
820 /* Get the current position of a file. */
821 gceSTATUS
822 gcoOS_GetPos(
823 IN gcoOS Os,
824 IN gctFILE File,
825 OUT gctUINT32 * Position
828 /* Perform a memory copy. */
829 gceSTATUS
830 gcoOS_MemCopy(
831 IN gctPOINTER Destination,
832 IN gctCONST_POINTER Source,
833 IN gctSIZE_T Bytes
836 /* Perform a memory fill. */
837 gceSTATUS
838 gcoOS_MemFill(
839 IN gctPOINTER Destination,
840 IN gctUINT8 Filler,
841 IN gctSIZE_T Bytes
844 /* Zero memory. */
845 gceSTATUS
846 gcoOS_ZeroMemory(
847 IN gctPOINTER Memory,
848 IN gctSIZE_T Bytes
851 /* Find the last occurance of a character inside a string. */
852 gceSTATUS
853 gcoOS_StrFindReverse(
854 IN gctCONST_STRING String,
855 IN gctINT8 Character,
856 OUT gctSTRING * Output
859 gceSTATUS
860 gcoOS_StrLen(
861 IN gctCONST_STRING String,
862 OUT gctSIZE_T * Length
865 gceSTATUS
866 gcoOS_StrDup(
867 IN gcoOS Os,
868 IN gctCONST_STRING String,
869 OUT gctSTRING * Target
872 /* Copy a string. */
873 gceSTATUS
874 gcoOS_StrCopySafe(
875 IN gctSTRING Destination,
876 IN gctSIZE_T DestinationSize,
877 IN gctCONST_STRING Source
880 /* Append a string. */
881 gceSTATUS
882 gcoOS_StrCatSafe(
883 IN gctSTRING Destination,
884 IN gctSIZE_T DestinationSize,
885 IN gctCONST_STRING Source
888 /* Compare two strings. */
889 gceSTATUS
890 gcoOS_StrCmp(
891 IN gctCONST_STRING String1,
892 IN gctCONST_STRING String2
895 /* Compare characters of two strings. */
896 gceSTATUS
897 gcoOS_StrNCmp(
898 IN gctCONST_STRING String1,
899 IN gctCONST_STRING String2,
900 IN gctSIZE_T Count
903 /* Convert string to float. */
904 gceSTATUS
905 gcoOS_StrToFloat(
906 IN gctCONST_STRING String,
907 OUT gctFLOAT * Float
910 /* Convert hex string to integer. */
911 gceSTATUS gcoOS_HexStrToInt(
912 IN gctCONST_STRING String,
913 OUT gctINT * Int
916 /* Convert hex string to float. */
917 gceSTATUS gcoOS_HexStrToFloat(
918 IN gctCONST_STRING String,
919 OUT gctFLOAT * Float
922 /* Convert string to integer. */
923 gceSTATUS
924 gcoOS_StrToInt(
925 IN gctCONST_STRING String,
926 OUT gctINT * Int
929 gceSTATUS
930 gcoOS_MemCmp(
931 IN gctCONST_POINTER Memory1,
932 IN gctCONST_POINTER Memory2,
933 IN gctSIZE_T Bytes
936 gceSTATUS
937 gcoOS_PrintStrSafe(
938 OUT gctSTRING String,
939 IN gctSIZE_T StringSize,
940 IN OUT gctUINT * Offset,
941 IN gctCONST_STRING Format,
945 gceSTATUS
946 gcoOS_LoadLibrary(
947 IN gcoOS Os,
948 IN gctCONST_STRING Library,
949 OUT gctHANDLE * Handle
952 gceSTATUS
953 gcoOS_FreeLibrary(
954 IN gcoOS Os,
955 IN gctHANDLE Handle
958 gceSTATUS
959 gcoOS_GetProcAddress(
960 IN gcoOS Os,
961 IN gctHANDLE Handle,
962 IN gctCONST_STRING Name,
963 OUT gctPOINTER * Function
966 gceSTATUS
967 gcoOS_Compact(
968 IN gcoOS Os
971 #if VIVANTE_PROFILER /*gcdENABLE_PROFILING*/
972 gceSTATUS
973 gcoOS_ProfileStart(
974 IN gcoOS Os
977 gceSTATUS
978 gcoOS_ProfileEnd(
979 IN gcoOS Os,
980 IN gctCONST_STRING Title
983 gceSTATUS
984 gcoOS_SetProfileSetting(
985 IN gcoOS Os,
986 IN gctBOOL Enable,
987 IN gctCONST_STRING FileName
989 #endif
991 /* Query the video memory. */
992 gceSTATUS
993 gcoOS_QueryVideoMemory(
994 IN gcoOS Os,
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. */
1009 gceSTATUS
1010 gcoOS_AtomConstruct(
1011 IN gcoOS Os,
1012 OUT gcsATOM_PTR * Atom
1015 /* Destroy an atom. */
1016 gceSTATUS
1017 gcoOS_AtomDestroy(
1018 IN gcoOS Os,
1019 IN gcsATOM_PTR Atom
1022 /* Increment an atom. */
1023 gceSTATUS
1024 gcoOS_AtomIncrement(
1025 IN gcoOS Os,
1026 IN gcsATOM_PTR Atom,
1027 OUT gctINT32_PTR OldValue
1030 /* Decrement an atom. */
1031 gceSTATUS
1032 gcoOS_AtomDecrement(
1033 IN gcoOS Os,
1034 IN gcsATOM_PTR Atom,
1035 OUT gctINT32_PTR OldValue
1038 gctHANDLE
1039 gcoOS_GetCurrentProcessID(
1040 void
1043 gctHANDLE
1044 gcoOS_GetCurrentThreadID(
1045 void
1048 /*----------------------------------------------------------------------------*/
1049 /*----- Time -----------------------------------------------------------------*/
1051 /* Get the number of milliseconds since the system started. */
1052 gctUINT32
1053 gcoOS_GetTicks(
1054 void
1057 /* Get time in microseconds. */
1058 gceSTATUS
1059 gcoOS_GetTime(
1060 gctUINT64_PTR Time
1063 /* Get CPU usage in microseconds. */
1064 gceSTATUS
1065 gcoOS_GetCPUTime(
1066 gctUINT64_PTR CPUTime
1069 /* Get memory usage. */
1070 gceSTATUS
1071 gcoOS_GetMemoryUsage(
1072 gctUINT32_PTR MaxRSS,
1073 gctUINT32_PTR IxRSS,
1074 gctUINT32_PTR IdRSS,
1075 gctUINT32_PTR IsRSS
1078 /* Delay a number of microseconds. */
1079 gceSTATUS
1080 gcoOS_Delay(
1081 IN gcoOS Os,
1082 IN gctUINT32 Delay
1085 /*----------------------------------------------------------------------------*/
1086 /*----- Threads --------------------------------------------------------------*/
1088 #ifdef _WIN32
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);
1098 #else
1099 typedef void * gctTHREAD_RETURN;
1100 typedef void * (* gcTHREAD_ROUTINE)(void *);
1101 #endif
1103 /* Create a new thread. */
1104 gceSTATUS
1105 gcoOS_CreateThread(
1106 IN gcoOS Os,
1107 IN gcTHREAD_ROUTINE Worker,
1108 IN gctPOINTER Argument,
1109 OUT gctPOINTER * Thread
1112 /* Close a thread. */
1113 gceSTATUS
1114 gcoOS_CloseThread(
1115 IN gcoOS Os,
1116 IN gctPOINTER Thread
1119 /*----------------------------------------------------------------------------*/
1120 /*----- Mutexes --------------------------------------------------------------*/
1122 /* Create a new mutex. */
1123 gceSTATUS
1124 gcoOS_CreateMutex(
1125 IN gcoOS Os,
1126 OUT gctPOINTER * Mutex
1129 /* Delete a mutex. */
1130 gceSTATUS
1131 gcoOS_DeleteMutex(
1132 IN gcoOS Os,
1133 IN gctPOINTER Mutex
1136 /* Acquire a mutex. */
1137 gceSTATUS
1138 gcoOS_AcquireMutex(
1139 IN gcoOS Os,
1140 IN gctPOINTER Mutex,
1141 IN gctUINT32 Timeout
1144 /* Release a mutex. */
1145 gceSTATUS
1146 gcoOS_ReleaseMutex(
1147 IN gcoOS Os,
1148 IN gctPOINTER Mutex
1151 /*----------------------------------------------------------------------------*/
1152 /*----- Signals --------------------------------------------------------------*/
1154 /* Create a signal. */
1155 gceSTATUS
1156 gcoOS_CreateSignal(
1157 IN gcoOS Os,
1158 IN gctBOOL ManualReset,
1159 OUT gctSIGNAL * Signal
1162 /* Destroy a signal. */
1163 gceSTATUS
1164 gcoOS_DestroySignal(
1165 IN gcoOS Os,
1166 IN gctSIGNAL Signal
1169 /* Signal a signal. */
1170 gceSTATUS
1171 gcoOS_Signal(
1172 IN gcoOS Os,
1173 IN gctSIGNAL Signal,
1174 IN gctBOOL State
1177 /* Wait for a signal. */
1178 gceSTATUS
1179 gcoOS_WaitSignal(
1180 IN gcoOS Os,
1181 IN gctSIGNAL Signal,
1182 IN gctUINT32 Wait
1185 /* Map a signal from another process */
1186 gceSTATUS
1187 gcoOS_MapSignal(
1188 IN gctSIGNAL RemoteSignal,
1189 OUT gctSIGNAL * LocalSignal
1192 /* Unmap a signal mapped from another process */
1193 gceSTATUS
1194 gcoOS_UnmapSignal(
1195 IN gctSIGNAL Signal
1198 /* Write a register. */
1199 gceSTATUS
1200 gcoOS_WriteRegister(
1201 IN gcoOS Os,
1202 IN gctUINT32 Address,
1203 IN gctUINT32 Data
1206 /* Read a register. */
1207 gceSTATUS
1208 gcoOS_ReadRegister(
1209 IN gcoOS Os,
1210 IN gctUINT32 Address,
1211 OUT gctUINT32 * Data
1214 gceSTATUS
1215 gcoOS_CacheClean(
1216 IN gcoOS Os,
1217 IN gcuVIDMEM_NODE_PTR Node,
1218 IN gctPOINTER Logical,
1219 IN gctSIZE_T Bytes
1222 gceSTATUS
1223 gcoOS_CacheFlush(
1224 IN gcoOS Os,
1225 IN gcuVIDMEM_NODE_PTR Node,
1226 IN gctPOINTER Logical,
1227 IN gctSIZE_T Bytes
1230 gceSTATUS
1231 gcoOS_CacheInvalidate(
1232 IN gcoOS Os,
1233 IN gcuVIDMEM_NODE_PTR Node,
1234 IN gctPOINTER Logical,
1235 IN gctSIZE_T Bytes
1238 /*----------------------------------------------------------------------------*/
1239 /*----- Profile --------------------------------------------------------------*/
1241 gceSTATUS
1242 gckOS_GetProfileTick(
1243 OUT gctUINT64_PTR Tick
1246 gceSTATUS
1247 gckOS_QueryProfileTickRate(
1248 OUT gctUINT64_PTR TickRate
1251 gctUINT32
1252 gckOS_ProfileToMS(
1253 IN gctUINT64 Ticks
1256 gceSTATUS
1257 gcoOS_GetProfileTick(
1258 OUT gctUINT64_PTR Tick
1261 gceSTATUS
1262 gcoOS_QueryProfileTickRate(
1263 OUT gctUINT64_PTR TickRate
1266 #define _gcmPROFILE_INIT(prefix, freq, start) \
1267 do { \
1268 prefix ## OS_QueryProfileTickRate(&(freq)); \
1269 prefix ## OS_GetProfileTick(&(start)); \
1270 } while (gcvFALSE)
1272 #define _gcmPROFILE_QUERY(prefix, start, ticks) \
1273 do { \
1274 prefix ## OS_GetProfileTick(&(ticks)); \
1275 (ticks) = ((ticks) > (start)) ? ((ticks) - (start)) \
1276 : (~0ull - (start) + (ticks) + 1); \
1277 } while (gcvFALSE)
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
1288 #else
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
1297 #endif
1299 /*******************************************************************************
1300 ** gcoMATH object
1303 #define gcdPI 3.14159265358979323846f
1305 /* Kernel. */
1306 gctINT
1307 gckMATH_ModuloInt(
1308 IN gctINT X,
1309 IN gctINT Y
1312 /* User. */
1313 gctUINT32
1314 gcoMATH_Log2in5dot5(
1315 IN gctINT X
1319 gctFLOAT
1320 gcoMATH_UIntAsFloat(
1321 IN gctUINT32 X
1324 gctUINT32
1325 gcoMATH_FloatAsUInt(
1326 IN gctFLOAT X
1329 gctBOOL
1330 gcoMATH_CompareEqualF(
1331 IN gctFLOAT X,
1332 IN gctFLOAT Y
1335 gctUINT16
1336 gcoMATH_UInt8AsFloat16(
1337 IN gctUINT8 X
1340 /******************************************************************************\
1341 **************************** Coordinate Structures *****************************
1342 \******************************************************************************/
1344 typedef struct _gcsPOINT
1346 gctINT32 x;
1347 gctINT32 y;
1349 gcsPOINT;
1351 typedef struct _gcsSIZE
1353 gctINT32 width;
1354 gctINT32 height;
1356 gcsSIZE;
1358 typedef struct _gcsRECT
1360 gctINT32 left;
1361 gctINT32 top;
1362 gctINT32 right;
1363 gctINT32 bottom;
1365 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,
1385 gceFORMAT_CLASS;
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
1400 gctUINT8 start;
1401 gctUINT8 width;
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. */
1478 union
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;
1486 } u;
1488 gcsSURF_FORMAT_INFO;
1490 /* Frame buffer information. */
1491 typedef struct _gcsSURF_FRAMEBUFFER
1493 gctPOINTER logical;
1494 gctUINT width, height;
1495 gctINT stride;
1496 gceSURF_FORMAT format;
1498 gcsSURF_FRAMEBUFFER;
1500 typedef struct _gcsVIDMEM_NODE_SHARED_INFO
1502 gctBOOL tileStatusDisabled;
1503 gcsPOINT SrcOrigin;
1504 gcsPOINT DestOrigin;
1505 gcsSIZE RectSize;
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,
1521 gceORIENTATION;
1524 /* Construct a new gcoSURF object. */
1525 gceSTATUS
1526 gcoSURF_Construct(
1527 IN gcoHAL Hal,
1528 IN gctUINT Width,
1529 IN gctUINT Height,
1530 IN gctUINT Depth,
1531 IN gceSURF_TYPE Type,
1532 IN gceSURF_FORMAT Format,
1533 IN gcePOOL Pool,
1534 OUT gcoSURF * Surface
1537 /* Destroy an gcoSURF object. */
1538 gceSTATUS
1539 gcoSURF_Destroy(
1540 IN gcoSURF Surface
1543 /* Map user-allocated surface. */
1544 gceSTATUS
1545 gcoSURF_MapUserSurface(
1546 IN gcoSURF Surface,
1547 IN gctUINT Alignment,
1548 IN gctPOINTER Logical,
1549 IN gctUINT32 Physical
1552 /* Query vid mem node info. */
1553 gceSTATUS
1554 gcoSURF_QueryVidMemNode(
1555 IN gcoSURF Surface,
1556 OUT gcuVIDMEM_NODE_PTR * Node,
1557 OUT gcePOOL * Pool,
1558 OUT gctUINT_PTR Bytes
1561 /* Set the color type of the surface. */
1562 gceSTATUS
1563 gcoSURF_SetColorType(
1564 IN gcoSURF Surface,
1565 IN gceSURF_COLOR_TYPE ColorType
1568 /* Get the color type of the surface. */
1569 gceSTATUS
1570 gcoSURF_GetColorType(
1571 IN gcoSURF Surface,
1572 OUT gceSURF_COLOR_TYPE *ColorType
1575 /* Set the surface ration angle. */
1576 gceSTATUS
1577 gcoSURF_SetRotation(
1578 IN gcoSURF Surface,
1579 IN gceSURF_ROTATION Rotation
1582 gceSTATUS
1583 gcoSURF_IsValid(
1584 IN gcoSURF Surface
1587 #ifndef VIVANTE_NO_3D
1588 /* Verify and return the state of the tile status mechanism. */
1589 gceSTATUS
1590 gcoSURF_IsTileStatusSupported(
1591 IN gcoSURF Surface
1594 /* Process tile status for the specified surface. */
1595 gceSTATUS
1596 gcoSURF_SetTileStatus(
1597 IN gcoSURF Surface
1600 /* Enable tile status for the specified surface. */
1601 gceSTATUS
1602 gcoSURF_EnableTileStatus(
1603 IN gcoSURF Surface
1606 /* Disable tile status for the specified surface. */
1607 gceSTATUS
1608 gcoSURF_DisableTileStatus(
1609 IN gcoSURF Surface,
1610 IN gctBOOL Decompress
1612 #endif /* VIVANTE_NO_3D */
1614 /* Get surface size. */
1615 gceSTATUS
1616 gcoSURF_GetSize(
1617 IN gcoSURF Surface,
1618 OUT gctUINT * Width,
1619 OUT gctUINT * Height,
1620 OUT gctUINT * Depth
1623 /* Get surface aligned sizes. */
1624 gceSTATUS
1625 gcoSURF_GetAlignedSize(
1626 IN gcoSURF Surface,
1627 OUT gctUINT * Width,
1628 OUT gctUINT * Height,
1629 OUT gctINT * Stride
1632 /* Get alignments. */
1633 gceSTATUS
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. */
1643 gceSTATUS
1644 gcoSURF_GetFormat(
1645 IN gcoSURF Surface,
1646 OUT gceSURF_TYPE * Type,
1647 OUT gceSURF_FORMAT * Format
1650 /* Lock the surface. */
1651 gceSTATUS
1652 gcoSURF_Lock(
1653 IN gcoSURF Surface,
1654 IN OUT gctUINT32 * Address,
1655 IN OUT gctPOINTER * Memory
1658 /* Unlock the surface. */
1659 gceSTATUS
1660 gcoSURF_Unlock(
1661 IN gcoSURF Surface,
1662 IN gctPOINTER Memory
1665 /* Return pixel format parameters. */
1666 gceSTATUS
1667 gcoSURF_QueryFormat(
1668 IN gceSURF_FORMAT Format,
1669 OUT gcsSURF_FORMAT_INFO_PTR * Info
1672 /* Compute the color pixel mask. */
1673 gceSTATUS
1674 gcoSURF_ComputeColorMask(
1675 IN gcsSURF_FORMAT_INFO_PTR Format,
1676 OUT gctUINT32_PTR ColorMask
1679 /* Flush the surface. */
1680 gceSTATUS
1681 gcoSURF_Flush(
1682 IN gcoSURF Surface
1685 /* Fill surface from it's tile status buffer. */
1686 gceSTATUS
1687 gcoSURF_FillFromTile(
1688 IN gcoSURF Surface
1691 /* Fill surface with a value. */
1692 gceSTATUS
1693 gcoSURF_Fill(
1694 IN gcoSURF Surface,
1695 IN gcsPOINT_PTR Origin,
1696 IN gcsSIZE_PTR Size,
1697 IN gctUINT32 Value,
1698 IN gctUINT32 Mask
1701 /* Alpha blend two surfaces together. */
1702 gceSTATUS
1703 gcoSURF_Blend(
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. */
1713 gceSTATUS
1714 gcoSURF_ConstructWrapper(
1715 IN gcoHAL Hal,
1716 OUT gcoSURF * Surface
1719 /* Set the underlying buffer for the surface wrapper. */
1720 gceSTATUS
1721 gcoSURF_SetBuffer(
1722 IN gcoSURF Surface,
1723 IN gceSURF_TYPE Type,
1724 IN gceSURF_FORMAT Format,
1725 IN gctUINT Stride,
1726 IN gctPOINTER Logical,
1727 IN gctUINT32 Physical
1730 /* Set the size of the surface in pixels and map the underlying buffer. */
1731 gceSTATUS
1732 gcoSURF_SetWindow(
1733 IN gcoSURF Surface,
1734 IN gctUINT X,
1735 IN gctUINT Y,
1736 IN gctUINT Width,
1737 IN gctUINT Height
1740 /* Increase reference count of the surface. */
1741 gceSTATUS
1742 gcoSURF_ReferenceSurface(
1743 IN gcoSURF Surface
1746 /* Get surface reference count. */
1747 gceSTATUS
1748 gcoSURF_QueryReferenceCount(
1749 IN gcoSURF Surface,
1750 OUT gctINT32 * ReferenceCount
1753 /* Set surface orientation. */
1754 gceSTATUS
1755 gcoSURF_SetOrientation(
1756 IN gcoSURF Surface,
1757 IN gceORIENTATION Orientation
1760 /* Query surface orientation. */
1761 gceSTATUS
1762 gcoSURF_QueryOrientation(
1763 IN gcoSURF Surface,
1764 OUT gceORIENTATION * Orientation
1767 /******************************************************************************\
1768 ********************************* gcoDUMP Object ********************************
1769 \******************************************************************************/
1771 /* Construct a new gcoDUMP object. */
1772 gceSTATUS
1773 gcoDUMP_Construct(
1774 IN gcoOS Os,
1775 IN gcoHAL Hal,
1776 OUT gcoDUMP * Dump
1779 /* Destroy a gcoDUMP object. */
1780 gceSTATUS
1781 gcoDUMP_Destroy(
1782 IN gcoDUMP Dump
1785 /* Enable/disable dumping. */
1786 gceSTATUS
1787 gcoDUMP_Control(
1788 IN gcoDUMP Dump,
1789 IN gctSTRING FileName
1792 gceSTATUS
1793 gcoDUMP_IsEnabled(
1794 IN gcoDUMP Dump,
1795 OUT gctBOOL * Enabled
1798 /* Add surface. */
1799 gceSTATUS
1800 gcoDUMP_AddSurface(
1801 IN gcoDUMP Dump,
1802 IN gctINT32 Width,
1803 IN gctINT32 Height,
1804 IN gceSURF_FORMAT PixelFormat,
1805 IN gctUINT32 Address,
1806 IN gctSIZE_T ByteCount
1809 /* Mark the beginning of a frame. */
1810 gceSTATUS
1811 gcoDUMP_FrameBegin(
1812 IN gcoDUMP Dump
1815 /* Mark the end of a frame. */
1816 gceSTATUS
1817 gcoDUMP_FrameEnd(
1818 IN gcoDUMP Dump
1821 /* Dump data. */
1822 gceSTATUS
1823 gcoDUMP_DumpData(
1824 IN gcoDUMP Dump,
1825 IN gceDUMP_TAG Type,
1826 IN gctUINT32 Address,
1827 IN gctSIZE_T ByteCount,
1828 IN gctCONST_POINTER Data
1831 /* Delete an address. */
1832 gceSTATUS
1833 gcoDUMP_Delete(
1834 IN gcoDUMP Dump,
1835 IN gctUINT32 Address
1839 /******************************************************************************\
1840 ******************************* gcsRECT Structure ******************************
1841 \******************************************************************************/
1843 /* Initialize rectangle structure. */
1844 gceSTATUS
1845 gcsRECT_Set(
1846 OUT gcsRECT_PTR Rect,
1847 IN gctINT32 Left,
1848 IN gctINT32 Top,
1849 IN gctINT32 Right,
1850 IN gctINT32 Bottom
1853 /* Return the width of the rectangle. */
1854 gceSTATUS
1855 gcsRECT_Width(
1856 IN gcsRECT_PTR Rect,
1857 OUT gctINT32 * Width
1860 /* Return the height of the rectangle. */
1861 gceSTATUS
1862 gcsRECT_Height(
1863 IN gcsRECT_PTR Rect,
1864 OUT gctINT32 * Height
1867 /* Ensure that top left corner is to the left and above the right bottom. */
1868 gceSTATUS
1869 gcsRECT_Normalize(
1870 IN OUT gcsRECT_PTR Rect
1873 /* Compare two rectangles. */
1874 gceSTATUS
1875 gcsRECT_IsEqual(
1876 IN gcsRECT_PTR Rect1,
1877 IN gcsRECT_PTR Rect2,
1878 OUT gctBOOL * Equal
1881 /* Compare the sizes of two rectangles. */
1882 gceSTATUS
1883 gcsRECT_IsOfEqualSize(
1884 IN gcsRECT_PTR Rect1,
1885 IN gcsRECT_PTR Rect2,
1886 OUT gctBOOL * EqualSize
1889 gceSTATUS
1890 gcsRECT_RelativeRotation(
1891 IN gceSURF_ROTATION Orientation,
1892 IN OUT gceSURF_ROTATION *Relation);
1894 gceSTATUS
1896 gcsRECT_Rotate(
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
1916 gctINT x;
1917 gctINT y;
1918 gctINT width;
1919 gctINT height;
1921 gcsBOUNDARY;
1923 /******************************************************************************\
1924 ********************************* gcoHEAP Object ********************************
1925 \******************************************************************************/
1927 typedef struct _gcoHEAP * gcoHEAP;
1929 /* Construct a new gcoHEAP object. */
1930 gceSTATUS
1931 gcoHEAP_Construct(
1932 IN gcoOS Os,
1933 IN gctSIZE_T AllocationSize,
1934 OUT gcoHEAP * Heap
1937 /* Destroy an gcoHEAP object. */
1938 gceSTATUS
1939 gcoHEAP_Destroy(
1940 IN gcoHEAP Heap
1943 /* Allocate memory. */
1944 gceSTATUS
1945 gcoHEAP_Allocate(
1946 IN gcoHEAP Heap,
1947 IN gctSIZE_T Bytes,
1948 OUT gctPOINTER * Node
1951 /* Free memory. */
1952 gceSTATUS
1953 gcoHEAP_Free(
1954 IN gcoHEAP Heap,
1955 IN gctPOINTER Node
1958 #if (VIVANTE_PROFILER /*gcdENABLE_PROFILING*/ || gcdDEBUG)
1959 /* Profile the heap. */
1960 gceSTATUS
1961 gcoHEAP_ProfileStart(
1962 IN gcoHEAP Heap
1965 gceSTATUS
1966 gcoHEAP_ProfileEnd(
1967 IN gcoHEAP Heap,
1968 IN gctCONST_STRING Title
1970 #endif
1973 /******************************************************************************\
1974 ******************************* Debugging Macros *******************************
1975 \******************************************************************************/
1977 void
1978 gcoOS_SetDebugLevel(
1979 IN gctUINT32 Level
1982 void
1983 gcoOS_SetDebugZone(
1984 IN gctUINT32 Zone
1987 void
1988 gcoOS_SetDebugLevelZone(
1989 IN gctUINT32 Level,
1990 IN gctUINT32 Zone
1993 void
1994 gcoOS_SetDebugZones(
1995 IN gctUINT32 Zones,
1996 IN gctBOOL Enable
1999 void
2000 gcoOS_SetDebugFile(
2001 IN gctCONST_STRING FileName
2004 /*******************************************************************************
2006 ** gcmFATAL
2008 ** Print a message to the debugger and execute a break point.
2010 ** ARGUMENTS:
2012 ** message Message.
2013 ** ... Optional arguments.
2016 void
2017 gckOS_DebugFatal(
2018 IN gctCONST_STRING Message,
2022 void
2023 gcoOS_DebugFatal(
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(...)
2034 #else
2035 gcmINLINE static void
2036 __dummy_fatal(
2037 IN gctCONST_STRING Message,
2042 # define gcmFATAL __dummy_fatal
2043 # define gcmkFATAL __dummy_fatal
2044 #endif
2046 #define gcmENUM2TEXT(e) case e: return #e
2048 /*******************************************************************************
2050 ** gcmTRACE
2052 ** Print a message to the debugfer if the correct level has been set. In
2053 ** retail mode this macro does nothing.
2055 ** ARGUMENTS:
2057 ** level Level of message.
2058 ** message 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
2067 void
2068 gckOS_DebugTrace(
2069 IN gctUINT32 Level,
2070 IN gctCONST_STRING Message,
2074 void
2075 gckOS_DebugTraceN(
2076 IN gctUINT32 Level,
2077 IN gctUINT ArgumentSize,
2078 IN gctCONST_STRING Message,
2082 void
2083 gcoOS_DebugTrace(
2084 IN gctUINT32 Level,
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(...)
2097 #else
2098 gcmINLINE static void
2099 __dummy_trace(
2100 IN gctUINT32 Level,
2101 IN gctCONST_STRING Message,
2107 gcmINLINE static void
2108 __dummy_trace_n(
2109 IN gctUINT32 Level,
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
2120 #endif
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)
2128 /* Kernel zones. */
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)
2140 /* User zones. */
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
2176 /* Handy zones. */
2177 #define gcvZONE_NONE 0
2178 #define gcvZONE_ALL gcdZONE_MASK
2180 /*******************************************************************************
2182 ** gcmTRACE_ZONE
2184 ** Print a message to the debugger if the correct level and zone has been
2185 ** set. In retail mode this macro does nothing.
2187 ** ARGUMENTS:
2189 ** Level Level of message.
2190 ** Zone Zone of message.
2191 ** Message Message.
2192 ** ... Optional arguments.
2195 void
2196 gckOS_DebugTraceZone(
2197 IN gctUINT32 Level,
2198 IN gctUINT32 Zone,
2199 IN gctCONST_STRING Message,
2203 void
2204 gckOS_DebugTraceZoneN(
2205 IN gctUINT32 Level,
2206 IN gctUINT32 Zone,
2207 IN gctUINT ArgumentSize,
2208 IN gctCONST_STRING Message,
2212 void
2213 gcoOS_DebugTraceZone(
2214 IN gctUINT32 Level,
2215 IN gctUINT32 Zone,
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(...)
2228 #else
2229 gcmINLINE static void
2230 __dummy_trace_zone(
2231 IN gctUINT32 Level,
2232 IN gctUINT32 Zone,
2233 IN gctCONST_STRING Message,
2239 gcmINLINE static void
2240 __dummy_trace_zone_n(
2241 IN gctUINT32 Level,
2242 IN gctUINT32 Zone,
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
2253 #endif
2255 /*******************************************************************************
2257 ** gcmDEBUG_ONLY
2259 ** Execute a statement or function only in DEBUG mode.
2261 ** ARGUMENTS:
2263 ** f Statement or function to execute.
2265 #if gcmIS_DEBUG(gcdDEBUG_CODE)
2266 # define gcmDEBUG_ONLY(f) f
2267 #else
2268 # define gcmDEBUG_ONLY(f)
2269 #endif
2271 /*******************************************************************************
2273 ** gcmSTACK_PUSH
2274 ** gcmSTACK_POP
2275 ** gcmSTACK_DUMP
2277 ** Push or pop a function with entry arguments on the trace stack.
2279 ** ARGUMENTS:
2281 ** Function Name of function.
2282 ** Line Line number.
2283 ** Text Optional text.
2284 ** ... Optional arguments for text.
2286 #if gcmIS_DEBUG(gcdDEBUG_STACK)
2287 void
2288 gcoOS_StackPush(
2289 IN gctCONST_STRING Function,
2290 IN gctINT Line,
2291 IN gctCONST_STRING Text,
2294 void
2295 gcoOS_StackPop(
2296 IN gctCONST_STRING Function
2298 void
2299 gcoOS_StackDump(
2300 void
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)
2309 #else
2310 gcmINLINE static void
2311 __dummy_stack_push(
2312 IN gctCONST_STRING Function,
2313 IN gctINT Line,
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)
2321 #endif
2323 /******************************************************************************\
2324 ******************************** Logging Macros ********************************
2325 \******************************************************************************/
2327 #define gcdHEADER_LEVEL gcvLEVEL_VERBOSE
2329 #if gcdENABLE_PROFILING
2330 void
2331 gcoOS_ProfileDB(
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 */
2359 #if gcdHAS_ELLIPSES
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__)
2366 #else
2367 gcmINLINE static void
2368 __dummy_header(void)
2371 # define gcmHEADER __dummy_header
2372 #endif
2374 #if gcdHAS_ELLIPSES
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__)
2381 #else
2382 gcmINLINE static void
2383 __dummy_header_arg(
2384 IN gctCONST_STRING Text,
2389 # define gcmHEADER_ARG __dummy_header_arg
2390 #endif
2392 #if gcdHAS_ELLIPSES
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))); \
2404 *__user_ptr__ -= 1
2405 #else
2406 gcmINLINE static void
2407 __dummy_footer(void)
2410 # define gcmFOOTER __dummy_footer
2411 #endif
2413 #if gcdHAS_ELLIPSES
2414 #define gcmFOOTER_NO() \
2415 gcmSTACK_POP(__FUNCTION__); \
2416 gcmTRACE_ZONE(gcdHEADER_LEVEL, _GC_OBJ_ZONE, \
2417 "--%s(%d)", __FUNCTION__, __LINE__); \
2418 *__user_ptr__ -= 1
2419 #else
2420 gcmINLINE static void
2421 __dummy_footer_no(void)
2424 # define gcmFOOTER_NO __dummy_footer_no
2425 #endif
2427 #if gcdHAS_ELLIPSES
2428 #define gcmFOOTER_KILL() \
2429 gcmSTACK_POP(__FUNCTION__); \
2430 gcmTRACE_ZONE(gcdHEADER_LEVEL, _GC_OBJ_ZONE, \
2431 "--%s(%d)", __FUNCTION__, __LINE__); \
2432 *__user_ptr__ -= 1
2433 #else
2434 gcmINLINE static void
2435 __dummy_footer_kill(void)
2438 # define gcmFOOTER_KILL __dummy_footer_kill
2439 #endif
2441 #if gcdHAS_ELLIPSES
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__); \
2446 *__user_ptr__ -= 1
2447 #else
2448 gcmINLINE static void
2449 __dummy_footer_arg(
2450 IN gctCONST_STRING Text,
2455 # define gcmFOOTER_ARG __dummy_footer_arg
2456 #endif
2458 #endif /* gcdENABLE_PROFILING */
2460 #if gcdHAS_ELLIPSES
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__)
2466 #else
2467 gcmINLINE static void
2468 __dummy_kheader(void)
2471 # define gcmkHEADER __dummy_kheader
2472 #endif
2474 #if gcdHAS_ELLIPSES
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__)
2480 #else
2481 gcmINLINE static void
2482 __dummy_kheader_arg(
2483 IN gctCONST_STRING Text,
2488 # define gcmkHEADER_ARG __dummy_kheader_arg
2489 #endif
2491 #if gcdHAS_ELLIPSES
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
2497 #else
2498 gcmINLINE static void
2499 __dummy_kfooter(void)
2502 # define gcmkFOOTER __dummy_kfooter
2503 #endif
2505 #if gcdHAS_ELLIPSES
2506 #define gcmkFOOTER_NO() \
2507 gcmkTRACE_ZONE(gcdHEADER_LEVEL, _GC_OBJ_ZONE, \
2508 "--%s(%d)", __FUNCTION__, __LINE__); \
2509 *__kernel_ptr__ -= 1
2510 #else
2511 gcmINLINE static void
2512 __dummy_kfooter_no(void)
2515 # define gcmkFOOTER_NO __dummy_kfooter_no
2516 #endif
2518 #if gcdHAS_ELLIPSES
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
2524 #else
2525 gcmINLINE static void
2526 __dummy_kfooter_arg(
2527 IN gctCONST_STRING Text,
2532 # define gcmkFOOTER_ARG __dummy_kfooter_arg
2533 #endif
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))
2539 void
2540 gckOS_Print(
2541 IN gctCONST_STRING Message,
2545 void
2546 gckOS_PrintN(
2547 IN gctUINT ArgumentSize,
2548 IN gctCONST_STRING Message,
2552 void
2553 gckOS_CopyPrint(
2554 IN gctCONST_STRING Message,
2558 void
2559 gcoOS_Print(
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); \
2571 gcmSTACK_DUMP(); \
2572 } while (0)
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 )
2579 #else
2580 # define gcmPRINT_VERSION() do { gcmSTACK_DUMP(); } while (gcvFALSE)
2581 # define gcmkPRINT_VERSION() do { } while (gcvFALSE)
2582 #endif
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,
2593 gceDUMP_BUFFER;
2595 void
2596 gckOS_DumpBuffer(
2597 IN gckOS Os,
2598 IN gctPOINTER Buffer,
2599 IN gctUINT Size,
2600 IN gceDUMP_BUFFER Type,
2601 IN gctBOOL CopyMessage
2604 #define gcmkDUMPBUFFER gckOS_DumpBuffer
2606 #if gcdDUMP_COMMAND
2607 # define gcmkDUMPCOMMAND(Os, Buffer, Size, Type, CopyMessage) \
2608 gcmkDUMPBUFFER(Os, Buffer, Size, Type, CopyMessage)
2609 #else
2610 # define gcmkDUMPCOMMAND(Os, Buffer, Size, Type, CopyMessage)
2611 #endif
2613 #if gcmIS_DEBUG(gcdDEBUG_CODE)
2615 void
2616 gckOS_DebugFlush(
2617 gctCONST_STRING CallerName,
2618 gctUINT LineNumber,
2619 gctUINT32 DmaAddress
2622 # define gcmkDEBUGFLUSH(DmaAddress) \
2623 gckOS_DebugFlush(__FUNCTION__, __LINE__, DmaAddress)
2624 #else
2625 # define gcmkDEBUGFLUSH(DmaAddress)
2626 #endif
2629 /*******************************************************************************
2631 ** gcmDUMP
2633 ** Print a dump message.
2635 ** ARGUMENTS:
2637 ** gctSTRING Message.
2639 ** ... Optional arguments.
2641 #if gcdDUMP
2642 gceSTATUS
2643 gcfDump(
2644 IN gcoOS Os,
2645 IN gctCONST_STRING String,
2648 # define gcmDUMP gcfDump
2649 #elif gcdHAS_ELLIPSES
2650 # define gcmDUMP(...)
2651 #else
2652 gcmINLINE static void
2653 __dummy_dump(
2654 IN gcoOS Os,
2655 IN gctCONST_STRING Message,
2660 # define gcmDUMP __dummy_dump
2661 #endif
2663 /*******************************************************************************
2665 ** gcmDUMP_DATA
2667 ** Add data to the dump.
2669 ** ARGUMENTS:
2671 ** gctSTRING Tag
2672 ** Tag for dump.
2674 ** gctPOINTER Logical
2675 ** Logical address of buffer.
2677 ** gctSIZE_T Bytes
2678 ** Number of bytes.
2681 #if gcdDUMP || gcdDUMP_COMMAND
2682 gceSTATUS
2683 gcfDumpData(
2684 IN gcoOS Os,
2685 IN gctSTRING Tag,
2686 IN gctPOINTER Logical,
2687 IN gctSIZE_T Bytes
2689 # define gcmDUMP_DATA gcfDumpData
2690 #elif gcdHAS_ELLIPSES
2691 # define gcmDUMP_DATA(...)
2692 #else
2693 gcmINLINE static void
2694 __dummy_dump_data(
2695 IN gcoOS Os,
2696 IN gctSTRING Tag,
2697 IN gctPOINTER Logical,
2698 IN gctSIZE_T Bytes
2702 # define gcmDUMP_DATA __dummy_dump_data
2703 #endif
2705 /*******************************************************************************
2707 ** gcmDUMP_BUFFER
2709 ** Print a buffer to the dump.
2711 ** ARGUMENTS:
2713 ** gctSTRING Tag
2714 ** Tag for dump.
2716 ** gctUINT32 Physical
2717 ** Physical address of buffer.
2719 ** gctPOINTER Logical
2720 ** Logical address of buffer.
2722 ** gctUINT32 Offset
2723 ** Offset into buffer.
2725 ** gctSIZE_T Bytes
2726 ** Number of bytes.
2729 #if gcdDUMP || gcdDUMP_COMMAND
2730 gceSTATUS
2731 gcfDumpBuffer(
2732 IN gcoOS Os,
2733 IN gctSTRING Tag,
2734 IN gctUINT32 Physical,
2735 IN gctPOINTER Logical,
2736 IN gctUINT32 Offset,
2737 IN gctSIZE_T Bytes
2739 # define gcmDUMP_BUFFER gcfDumpBuffer
2740 #elif gcdHAS_ELLIPSES
2741 # define gcmDUMP_BUFFER(...)
2742 #else
2743 gcmINLINE static void
2744 __dummy_dump_buffer(
2745 IN gcoOS Os,
2746 IN gctSTRING Tag,
2747 IN gctUINT32 Physical,
2748 IN gctPOINTER Logical,
2749 IN gctUINT32 Offset,
2750 IN gctSIZE_T Bytes
2754 # define gcmDUMP_BUFFER __dummy_dump_buffer
2755 #endif
2757 /*******************************************************************************
2759 ** gcmDUMP_API
2761 ** Print a dump message for a high level API prefixed by the function name.
2763 ** ARGUMENTS:
2765 ** gctSTRING Message.
2767 ** ... Optional arguments.
2769 #if gcdDUMP_API
2770 gceSTATUS
2771 gcfDumpApi(
2772 IN gctCONST_STRING String,
2775 # define gcmDUMP_API gcfDumpApi
2776 #elif gcdHAS_ELLIPSES
2777 # define gcmDUMP_API(...)
2778 #else
2779 gcmINLINE static void
2780 __dummy_dump_api(
2781 IN gctCONST_STRING Message,
2786 # define gcmDUMP_API __dummy_dump_api
2787 #endif
2789 /*******************************************************************************
2791 ** gcmDUMP_API_ARRAY
2793 ** Print an array of data.
2795 ** ARGUMENTS:
2797 ** gctUINT32_PTR Pointer to array.
2798 ** gctUINT32 Size.
2800 #if gcdDUMP_API
2801 gceSTATUS
2802 gcfDumpArray(
2803 IN gctCONST_POINTER Data,
2804 IN gctUINT32 Size
2806 # define gcmDUMP_API_ARRAY gcfDumpArray
2807 #elif gcdHAS_ELLIPSES
2808 # define gcmDUMP_API_ARRAY(...)
2809 #else
2810 gcmINLINE static void
2811 __dummy_dump_api_array(
2812 IN gctCONST_POINTER Data,
2813 IN gctUINT32 Size
2817 # define gcmDUMP_API_ARRAY __dummy_dump_api_array
2818 #endif
2820 /*******************************************************************************
2822 ** gcmDUMP_API_ARRAY_TOKEN
2824 ** Print an array of data terminated by a token.
2826 ** ARGUMENTS:
2828 ** gctUINT32_PTR Pointer to array.
2829 ** gctUINT32 Termination.
2831 #if gcdDUMP_API
2832 gceSTATUS
2833 gcfDumpArrayToken(
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(...)
2840 #else
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
2849 #endif
2851 /*******************************************************************************
2853 ** gcmDUMP_API_DATA
2855 ** Print an array of bytes.
2857 ** ARGUMENTS:
2859 ** gctCONST_POINTER Pointer to array.
2860 ** gctSIZE_T Size.
2862 #if gcdDUMP_API
2863 gceSTATUS
2864 gcfDumpApiData(
2865 IN gctCONST_POINTER Data,
2866 IN gctSIZE_T Size
2868 # define gcmDUMP_API_DATA gcfDumpApiData
2869 #elif gcdHAS_ELLIPSES
2870 # define gcmDUMP_API_DATA(...)
2871 #else
2872 gcmINLINE static void
2873 __dummy_dump_api_data(
2874 IN gctCONST_POINTER Data,
2875 IN gctSIZE_T Size
2879 # define gcmDUMP_API_DATA __dummy_dump_api_data
2880 #endif
2882 /*******************************************************************************
2884 ** gcmTRACE_RELEASE
2886 ** Print a message to the shader debugger.
2888 ** ARGUMENTS:
2890 ** message Message.
2891 ** ... Optional arguments.
2894 #define gcmTRACE_RELEASE gcoOS_DebugShaderTrace
2896 void
2897 gcoOS_DebugShaderTrace(
2898 IN gctCONST_STRING Message,
2902 void
2903 gcoOS_SetDebugShaderFiles(
2904 IN gctCONST_STRING VSFileName,
2905 IN gctCONST_STRING FSFileName
2908 void
2909 gcoOS_SetDebugShaderFileType(
2910 IN gctUINT32 ShaderType
2913 void
2914 gcoOS_EnableDebugBuffer(
2915 IN gctBOOL Enable
2918 /*******************************************************************************
2920 ** gcmBREAK
2922 ** Break into the debugger. In retail mode this macro does nothing.
2924 ** ARGUMENTS:
2926 ** None.
2929 void
2930 gcoOS_DebugBreak(
2931 void
2934 void
2935 gckOS_DebugBreak(
2936 void
2939 #if gcmIS_DEBUG(gcdDEBUG_BREAK)
2940 # define gcmBREAK gcoOS_DebugBreak
2941 # define gcmkBREAK gckOS_DebugBreak
2942 #else
2943 # define gcmBREAK()
2944 # define gcmkBREAK()
2945 #endif
2947 /*******************************************************************************
2949 ** gcmASSERT
2951 ** Evaluate an expression and break into the debugger if the expression
2952 ** evaluates to false. In retail mode this macro does nothing.
2954 ** ARGUMENTS:
2956 ** exp Expression to evaluate.
2958 #if gcmIS_DEBUG(gcdDEBUG_ASSERT)
2959 # define _gcmASSERT(prefix, exp) \
2960 do \
2962 if (!(exp)) \
2964 prefix##TRACE(gcvLEVEL_ERROR, \
2965 #prefix "ASSERT at %s(%d)", \
2966 __FUNCTION__, __LINE__); \
2967 prefix##TRACE(gcvLEVEL_ERROR, \
2968 "(%s)", #exp); \
2969 prefix##BREAK(); \
2972 while (gcvFALSE)
2973 # define gcmASSERT(exp) _gcmASSERT(gcm, exp)
2974 # define gcmkASSERT(exp) _gcmASSERT(gcmk, exp)
2975 #else
2976 # define gcmASSERT(exp)
2977 # define gcmkASSERT(exp)
2978 #endif
2980 /*******************************************************************************
2982 ** gcmVERIFY
2984 ** Verify if an expression returns true. If the expression does not
2985 ** evaluates to true, an assertion will happen in debug mode.
2987 ** ARGUMENTS:
2989 ** exp Expression to evaluate.
2991 #if gcmIS_DEBUG(gcdDEBUG_ASSERT)
2992 # define gcmVERIFY(exp) gcmASSERT(exp)
2993 # define gcmkVERIFY(exp) gcmkASSERT(exp)
2994 #else
2995 # define gcmVERIFY(exp) exp
2996 # define gcmkVERIFY(exp) exp
2997 #endif
2999 /*******************************************************************************
3001 ** gcmVERIFY_OK
3003 ** Verify a fucntion returns gcvSTATUS_OK. If the function does not return
3004 ** gcvSTATUS_OK, an assertion will happen in debug mode.
3006 ** ARGUMENTS:
3008 ** func Function to evaluate.
3011 void
3012 gcoOS_Verify(
3013 IN gceSTATUS Status
3016 void
3017 gckOS_Verify(
3018 IN gceSTATUS Status
3021 #if gcmIS_DEBUG(gcdDEBUG_ASSERT)
3022 # define gcmVERIFY_OK(func) \
3023 do \
3025 gceSTATUS verifyStatus = func; \
3026 gcoOS_Verify(verifyStatus); \
3027 if (verifyStatus != gcvSTATUS_OK) \
3029 gcmTRACE( \
3030 gcvLEVEL_ERROR, \
3031 "gcmVERIFY_OK(%d): function returned %d", \
3032 __LINE__, verifyStatus \
3033 ); \
3035 gcmASSERT(verifyStatus == gcvSTATUS_OK); \
3037 while (gcvFALSE)
3038 # define gcmkVERIFY_OK(func) \
3039 do \
3041 gceSTATUS verifyStatus = func; \
3042 if (verifyStatus != gcvSTATUS_OK) \
3044 gcmkTRACE( \
3045 gcvLEVEL_ERROR, \
3046 "gcmkVERIFY_OK(%d): function returned %d", \
3047 __LINE__, verifyStatus \
3048 ); \
3050 gckOS_Verify(verifyStatus); \
3051 gcmkASSERT(verifyStatus == gcvSTATUS_OK); \
3053 while (gcvFALSE)
3054 #else
3055 # define gcmVERIFY_OK(func) func
3056 # define gcmkVERIFY_OK(func) func
3057 #endif
3059 gctCONST_STRING
3060 gcoOS_DebugStatus2Name(
3061 gceSTATUS status
3064 gctCONST_STRING
3065 gckOS_DebugStatus2Name(
3066 gceSTATUS status
3069 /*******************************************************************************
3071 ** gcmERR_BREAK
3073 ** Executes a break statement on error.
3075 ** ASSUMPTIONS:
3077 ** 'status' variable of gceSTATUS type must be defined.
3079 ** ARGUMENTS:
3081 ** func Function to evaluate.
3083 #define _gcmERR_BREAK(prefix, func) \
3084 status = 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__); \
3091 break; \
3093 do { } while (gcvFALSE)
3094 #define _gcmkERR_BREAK(prefix, func) \
3095 status = 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__); \
3102 break; \
3104 do { } while (gcvFALSE)
3105 #define gcmERR_BREAK(func) _gcmERR_BREAK(gcm, func)
3106 #define gcmkERR_BREAK(func) _gcmkERR_BREAK(gcmk, func)
3108 /*******************************************************************************
3110 ** gcmERR_RETURN
3112 ** Executes a return on error.
3114 ** ASSUMPTIONS:
3116 ** 'status' variable of gceSTATUS type must be defined.
3118 ** ARGUMENTS:
3120 ** func Function to evaluate.
3122 #define _gcmERR_RETURN(prefix, func) \
3123 status = 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__); \
3130 prefix##FOOTER(); \
3131 return status; \
3133 do { } while (gcvFALSE)
3134 #define _gcmkERR_RETURN(prefix, func) \
3135 status = 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__); \
3142 prefix##FOOTER(); \
3143 return status; \
3145 do { } while (gcvFALSE)
3146 #define gcmERR_RETURN(func) _gcmERR_RETURN(gcm, func)
3147 #define gcmkERR_RETURN(func) _gcmkERR_RETURN(gcmk, func)
3150 /*******************************************************************************
3152 ** gcmONERROR
3154 ** Jump to the error handler in case there is an error.
3156 ** ASSUMPTIONS:
3158 ** 'status' variable of gceSTATUS type must be defined.
3160 ** ARGUMENTS:
3162 ** func Function to evaluate.
3164 #define _gcmONERROR(prefix, func) \
3165 do \
3167 status = 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__); \
3174 goto OnError; \
3177 while (gcvFALSE)
3178 #define _gcmkONERROR(prefix, func) \
3179 do \
3181 status = 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__); \
3188 goto OnError; \
3191 while (gcvFALSE)
3192 #define gcmONERROR(func) _gcmONERROR(gcm, func)
3193 #define gcmkONERROR(func) _gcmkONERROR(gcmk, func)
3195 /*******************************************************************************
3197 ** gcmVERIFY_LOCK
3199 ** Verifies whether the surface is locked.
3201 ** ARGUMENTS:
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.
3217 ** ARGUMENTS:
3219 ** surfaceInfo Pointer to the surface iniformational structure.
3221 #define gcmVERIFY_NODE_LOCK(surfaceNode) \
3222 if (!surfaceNode->valid) \
3224 status = gcvSTATUS_MEMORY_UNLOCKED; \
3225 break; \
3227 do { } while (gcvFALSE)
3229 /*******************************************************************************
3231 ** gcmBADOBJECT_BREAK
3233 ** Executes a break statement on bad object.
3235 ** ARGUMENTS:
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; \
3246 break; \
3248 do { } while (gcvFALSE)
3250 /*******************************************************************************
3252 ** gcmCHECK_STATUS
3254 ** Executes a break statement on error.
3256 ** ASSUMPTIONS:
3258 ** 'status' variable of gceSTATUS type must be defined.
3260 ** ARGUMENTS:
3262 ** func Function to evaluate.
3264 #define _gcmCHECK_STATUS(prefix, func) \
3265 do \
3267 last = 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__); \
3273 status = last; \
3276 while (gcvFALSE)
3277 #define _gcmkCHECK_STATUS(prefix, func) \
3278 do \
3280 last = 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__); \
3286 status = last; \
3289 while (gcvFALSE)
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
3300 ** nothing.
3302 ** ARGUMENTS:
3304 ** arg Argument to evaluate.
3306 # define _gcmVERIFY_ARGUMENT(prefix, arg) \
3307 do \
3309 if (!(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; \
3317 while (gcvFALSE)
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.
3328 #if gcdDEBUG
3329 # define gcmDEBUG_VERIFY_ARGUMENT(arg) _gcmVERIFY_ARGUMENT(gcm, arg)
3330 # define gcmkDEBUG_VERIFY_ARGUMENT(arg) _gcmkVERIFY_ARGUMENT(gcm, arg)
3331 #else
3332 # define gcmDEBUG_VERIFY_ARGUMENT(arg)
3333 # define gcmkDEBUG_VERIFY_ARGUMENT(arg)
3334 #endif
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
3342 ** nothing.
3344 ** ARGUMENTS:
3346 ** arg Argument to evaluate.
3348 # define _gcmVERIFY_ARGUMENT_RETURN(prefix, arg, value) \
3349 do \
3351 if (!(arg)) \
3353 prefix##TRACE(gcvLEVEL_ERROR, \
3354 #prefix "gcmVERIFY_ARGUMENT_RETURN failed:"); \
3355 prefix##ASSERT(arg); \
3356 prefix##FOOTER_ARG("value=%d", value); \
3357 return value; \
3360 while (gcvFALSE)
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
3368 #ifdef __cplusplus
3370 #endif
3372 #endif /* __gc_hal_base_h_ */