jacinto6: sgx: update DDK version to 1.12/2701748
[android-sdk/device-ti-proprietary-open.git] / jacinto6 / sgx_src / eurasia_km / include4 / services.h
1 /*************************************************************************/ /*!
2 @Title          Services API Header
3 @Copyright      Copyright (c) Imagination Technologies Ltd. All Rights Reserved
4 @Description    Exported services API details
5 @License        Dual MIT/GPLv2
7 The contents of this file are subject to the MIT license as set out below.
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
19 Alternatively, the contents of this file may be used under the terms of
20 the GNU General Public License Version 2 ("GPL") in which case the provisions
21 of GPL are applicable instead of those above.
23 If you wish to allow use of your version of this file only under the terms of
24 GPL, and not to allow others to use your version of this file under the terms
25 of the MIT license, indicate your decision by deleting the provisions above
26 and replace them with the notice and other provisions required by GPL as set
27 out in the file called "GPL-COPYING" included in this distribution. If you do
28 not delete the provisions above, a recipient may use your version of this file
29 under the terms of either the MIT license or GPL.
31 This License is also included in this distribution in the file called
32 "MIT-COPYING".
34 EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
35 PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
36 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
37 PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
38 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
39 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
40 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
41 */ /**************************************************************************/
43 #ifndef __SERVICES_H__
44 #define __SERVICES_H__
46 #if defined (__cplusplus)
47 extern "C" {
48 #endif
50 #include "img_defs.h"
51 #include "servicesext.h"
52 #include "pdumpdefs.h"
55 /* The comment below is the front page for code-generated doxygen documentation */
56 /*!
57  ******************************************************************************
58  @mainpage
59  This document details the APIs and implementation of the Consumer Services.
60  It is intended to be used in conjunction with the Consumer Services
61  Software Architectural Specification and the Consumer Services Software
62  Functional Specification.
63  *****************************************************************************/
65 /******************************************************************************
66  *      #defines
67  *****************************************************************************/
69 /* 4k page size definition */
70 #define PVRSRV_4K_PAGE_SIZE             4096UL
72 #define PVRSRV_MAX_CMD_SIZE             1024/*!< max size in bytes of a command */
74 #define PVRSRV_MAX_DEVICES              16      /*!< Largest supported number of devices on the system */
76 #define EVENTOBJNAME_MAXLENGTH (50)
78 /*
79         Flags associated with memory allocation
80         (bits 0-11)
81 */
82 #define PVRSRV_MEM_READ                                         (1U<<0)
83 #define PVRSRV_MEM_WRITE                                        (1U<<1)
84 #define PVRSRV_MEM_CACHE_CONSISTENT                     (1U<<2)
85 #define PVRSRV_MEM_NO_SYNCOBJ                           (1U<<3)
86 #define PVRSRV_MEM_INTERLEAVED                          (1U<<4)
87 #define PVRSRV_MEM_DUMMY                                        (1U<<5)
88 #define PVRSRV_MEM_EDM_PROTECT                          (1U<<6)
89 #define PVRSRV_MEM_ZERO                                         (1U<<7)
90 #define PVRSRV_MEM_USER_SUPPLIED_DEVVADDR       (1U<<8)
91 #define PVRSRV_MEM_RAM_BACKED_ALLOCATION        (1U<<9)
92 #define PVRSRV_MEM_NO_RESMAN                            (1U<<10)
93 #define PVRSRV_MEM_EXPORTED                                     (1U<<11)
96 /*
97         Heap Attribute flags
98         (bits 12-23)
99 */
100 #define PVRSRV_HAP_CACHED                                       (1U<<12)
101 #define PVRSRV_HAP_UNCACHED                                     (1U<<13)
102 #define PVRSRV_HAP_WRITECOMBINE                         (1U<<14)
103 #define PVRSRV_HAP_CACHETYPE_MASK                       (PVRSRV_HAP_CACHED|PVRSRV_HAP_UNCACHED|PVRSRV_HAP_WRITECOMBINE)
104 #define PVRSRV_HAP_KERNEL_ONLY                          (1U<<15)
105 #define PVRSRV_HAP_SINGLE_PROCESS                       (1U<<16)
106 #define PVRSRV_HAP_MULTI_PROCESS                        (1U<<17)
107 #define PVRSRV_HAP_FROM_EXISTING_PROCESS        (1U<<18)
108 #define PVRSRV_HAP_NO_CPU_VIRTUAL                       (1U<<19)
109 #define PVRSRV_HAP_MAPTYPE_MASK                         (PVRSRV_HAP_KERNEL_ONLY \
110                                             |PVRSRV_HAP_SINGLE_PROCESS \
111                                             |PVRSRV_HAP_MULTI_PROCESS \
112                                             |PVRSRV_HAP_FROM_EXISTING_PROCESS \
113                                             |PVRSRV_HAP_NO_CPU_VIRTUAL)
115 /*
116         Allows user allocations to override heap attributes
117         (Bits shared with heap flags)
118 */
119 #define PVRSRV_MEM_CACHED                                       PVRSRV_HAP_CACHED
120 #define PVRSRV_MEM_UNCACHED                                     PVRSRV_HAP_UNCACHED
121 #define PVRSRV_MEM_WRITECOMBINE                         PVRSRV_HAP_WRITECOMBINE
123 /*
124         Backing store flags (defined internally)
125         (bits 24-26)
126 */
127 #define PVRSRV_MEM_BACKINGSTORE_FIELD_SHIFT     (24)
129 /*
130         Per allocation/mapping flags
131         (bits 27-30)
132  */
133 #define PVRSRV_MAP_NOUSERVIRTUAL            (1UL<<27)
134 #define PVRSRV_MEM_XPROC                                        (1U<<28)
135 /* Bit 29 is unused */
136 #define PVRSRV_MEM_ALLOCATENONCACHEDMEM         (1UL<<30)
138 /*
139         Internal allocation/mapping flags
140         (bit 31)
141 */
142 #define PVRSRV_MEM_SPARSE                                       (1U<<31)
145 /*
146  * How much context we lose on a (power) mode change
147  */
148 #define PVRSRV_NO_CONTEXT_LOSS                                  0               /*!< Do not lose state on power down */
149 #define PVRSRV_SEVERE_LOSS_OF_CONTEXT                   1               /*!< lose state on power down */
150 #define PVRSRV_PRE_STATE_CHANGE_MASK                    0x80    /*!< power state change mask */
153 /*
154  * Device cookie defines
155  */
156 #define PVRSRV_DEFAULT_DEV_COOKIE                       (1)      /*!< default device cookie */
159 /*
160  * Misc Info. present flags
161  */
162 #define PVRSRV_MISC_INFO_TIMER_PRESENT                                  (1U<<0)
163 #define PVRSRV_MISC_INFO_CLOCKGATE_PRESENT                              (1U<<1)
164 #define PVRSRV_MISC_INFO_MEMSTATS_PRESENT                               (1U<<2)
165 #define PVRSRV_MISC_INFO_GLOBALEVENTOBJECT_PRESENT              (1U<<3)
166 #define PVRSRV_MISC_INFO_DDKVERSION_PRESENT                             (1U<<4)
167 #define PVRSRV_MISC_INFO_CPUCACHEOP_PRESENT                             (1U<<5)
168 #define PVRSRV_MISC_INFO_FREEMEM_PRESENT                                (1U<<6)
169 #define PVRSRV_MISC_INFO_GET_REF_COUNT_PRESENT                  (1U<<7)
170 #define PVRSRV_MISC_INFO_GET_PAGE_SIZE_PRESENT                  (1U<<8)
171 #define PVRSRV_MISC_INFO_FORCE_SWAP_TO_SYSTEM_PRESENT   (1U<<9)
173 #define PVRSRV_MISC_INFO_RESET_PRESENT                                  (1U<<31)
175 /* PDUMP defines */
176 #define PVRSRV_PDUMP_MAX_FILENAME_SIZE                  20
177 #define PVRSRV_PDUMP_MAX_COMMENT_SIZE                   200
180 /*
181         Flags for PVRSRVChangeDeviceMemoryAttributes call.
182 */
183 #define PVRSRV_CHANGEDEVMEM_ATTRIBS_CACHECOHERENT               0x00000001
185 /*
186         Flags for PVRSRVMapExtMemory and PVRSRVUnmapExtMemory
187         ALTERNATEVA             -       Used when mapping multiple virtual addresses to the same physical address. Set this flag on extra maps.
188         PHYSCONTIG              -       Physical pages are contiguous (unused)
189 */
190 #define PVRSRV_MAPEXTMEMORY_FLAGS_ALTERNATEVA                   0x00000001
191 #define PVRSRV_MAPEXTMEMORY_FLAGS_PHYSCONTIG                    0x00000002
193 /*
194         Flags for PVRSRVModifySyncOps
195         WO_INC          -       Used to increment "WriteOpsPending/complete of sync info"
196         RO_INC          -       Used to increment "ReadOpsPending/complete of sync info"
197         RO2_INC         -       Used to increment "ReadOps2Pending/complete of sync info"
198 */
199 #define PVRSRV_MODIFYSYNCOPS_FLAGS_WO_INC                               (1U<<0)
200 #define PVRSRV_MODIFYSYNCOPS_FLAGS_RO_INC                               (1U<<1)
201 #define PVRSRV_MODIFYSYNCOPS_FLAGS_RO2_INC                              (1U<<2)
203 /*
204         Flags for Services connection.
205         Allows to define per-client policy for Services
206 */
207 #define SRV_FLAGS_PERSIST               0x1
208 #define SRV_FLAGS_PDUMP_ACTIVE  0x2
210 /*
211         Pdump flags which are accessible to Services clients
212 */
213 #define PVRSRV_PDUMP_FLAGS_CONTINUOUS           0x1
216 /******************************************************************************
217  * Enums
218  *****************************************************************************/
220 /*!
221  ******************************************************************************
222  * List of known device types.
223  *****************************************************************************/
224 typedef enum _PVRSRV_DEVICE_TYPE_
226         PVRSRV_DEVICE_TYPE_UNKNOWN                      = 0 ,
227         PVRSRV_DEVICE_TYPE_MBX1                         = 1 ,
228         PVRSRV_DEVICE_TYPE_MBX1_LITE            = 2 ,
230         PVRSRV_DEVICE_TYPE_M24VA                        = 3,
231         PVRSRV_DEVICE_TYPE_MVDA2                        = 4,
232         PVRSRV_DEVICE_TYPE_MVED1                        = 5,
233         PVRSRV_DEVICE_TYPE_MSVDX                        = 6,
235         PVRSRV_DEVICE_TYPE_SGX                          = 7,
237         PVRSRV_DEVICE_TYPE_VGX                          = 8,
239         /* 3rd party devices take ext type */
240         PVRSRV_DEVICE_TYPE_EXT                          = 9,
242     PVRSRV_DEVICE_TYPE_LAST             = 9,
244         PVRSRV_DEVICE_TYPE_FORCE_I32            = 0x7fffffff
246 } PVRSRV_DEVICE_TYPE;
248 #define HEAP_ID( _dev_ , _dev_heap_idx_ )       (  ((_dev_)<<24) | ((_dev_heap_idx_)&((1<<24)-1))  )
249 #define HEAP_IDX( _heap_id_ )                           ( (_heap_id_)&((1<<24) - 1 ) )
250 #define HEAP_DEV( _heap_id_ )                           ( (_heap_id_)>>24 )
252 /* common undefined heap ID define */
253 #define PVRSRV_UNDEFINED_HEAP_ID                        (~0LU)
255 /*!
256  ******************************************************************************
257  * User Module type
258  *****************************************************************************/
259 typedef enum
261         IMG_EGL                         = 0x00000001,
262         IMG_OPENGLES1           = 0x00000002,
263         IMG_OPENGLES2           = 0x00000003,
264         IMG_D3DM                        = 0x00000004,
265         IMG_SRV_UM                      = 0x00000005,
266         IMG_OPENVG                      = 0x00000006,
267         IMG_SRVCLIENT           = 0x00000007,
268         IMG_VISTAKMD            = 0x00000008,
269         IMG_VISTA3DNODE         = 0x00000009,
270         IMG_VISTAMVIDEONODE     = 0x0000000A,
271         IMG_VISTAVPBNODE        = 0x0000000B,
272         IMG_OPENGL                      = 0x0000000C,
273         IMG_D3D                         = 0x0000000D,
274 #if defined(SUPPORT_GRAPHICS_HAL) || defined(SUPPORT_COMPOSER_HAL)
275         IMG_ANDROID_HAL         = 0x0000000E,
276 #endif
277 #if defined(SUPPORT_OPENCL)
278         IMG_OPENCL                      = 0x0000000F,
279 #endif
281         IMG_MODULE_UNDEF        = 0xFFFFFFFF
282 } IMG_MODULE_ID;
285 #define APPHINT_MAX_STRING_SIZE 256
287 /*!
288  ******************************************************************************
289  * IMG data types
290  *****************************************************************************/
291 typedef enum
293         IMG_STRING_TYPE         = 1,
294         IMG_FLOAT_TYPE          ,
295         IMG_UINT_TYPE           ,
296         IMG_INT_TYPE            ,
297         IMG_FLAG_TYPE
298 }IMG_DATA_TYPE;
301 /******************************************************************************
302  * Structure definitions.
303  *****************************************************************************/
305 /*!
306  * Forward declaration
307  */
308 typedef struct _PVRSRV_DEV_DATA_ *PPVRSRV_DEV_DATA;
310 /*!
311  ******************************************************************************
312  * Device identifier structure
313  *****************************************************************************/
314 typedef struct _PVRSRV_DEVICE_IDENTIFIER_
316         PVRSRV_DEVICE_TYPE              eDeviceType;            /*!< Identifies the type of the device */
317         PVRSRV_DEVICE_CLASS             eDeviceClass;           /*!< Identifies more general class of device - display/3d/mpeg etc */
318         IMG_UINT32                              ui32DeviceIndex;        /*!< Index of the device within the system */
319         IMG_CHAR                                *pszPDumpDevName;       /*!< Pdump memory bank name */
320         IMG_CHAR                                *pszPDumpRegName;       /*!< Pdump register bank name */
322 } PVRSRV_DEVICE_IDENTIFIER;
325 /******************************************************************************
326  * Client dev info
327  ******************************************************************************
328  */
329 typedef struct _PVRSRV_CLIENT_DEV_DATA_
331         IMG_UINT32              ui32NumDevices;                         /*!< Number of services-managed devices connected */
332         PVRSRV_DEVICE_IDENTIFIER asDevID[PVRSRV_MAX_DEVICES];           /*!< Device identifiers */
333         PVRSRV_ERROR    (*apfnDevConnect[PVRSRV_MAX_DEVICES])(PPVRSRV_DEV_DATA);        /*< device-specific connection callback */
334         PVRSRV_ERROR    (*apfnDumpTrace[PVRSRV_MAX_DEVICES])(PPVRSRV_DEV_DATA);         /*!< device-specific debug trace callback */
336 } PVRSRV_CLIENT_DEV_DATA;
339 /*!
340  ******************************************************************************
341  * Kernel Services connection structure
342  *****************************************************************************/
343 typedef struct _PVRSRV_CONNECTION_
345         IMG_HANDLE hServices;                                   /*!< UM IOCTL handle */
346         IMG_UINT32 ui32ProcessID;                               /*!< Process ID for resource locking */
347         PVRSRV_CLIENT_DEV_DATA  sClientDevData; /*!< Client device data */
348         IMG_UINT32 ui32SrvFlags;                                /*!< Per-client Services flags */
349 }PVRSRV_CONNECTION;
352 /*!
353  ******************************************************************************
354  * This structure allows the user mode glue code to have an OS independent
355  * set of prototypes.
356  *****************************************************************************/
357 typedef struct _PVRSRV_DEV_DATA_
359         IMG_CONST PVRSRV_CONNECTION      *psConnection; /*!< Services connection info */
360         IMG_HANDLE                      hDevCookie;                             /*!< Dev cookie */
362 } PVRSRV_DEV_DATA;
364 /*!
365  ******************************************************************************
366  * address:value update structure
367  *****************************************************************************/
368 typedef struct _PVRSRV_MEMUPDATE_
370         IMG_UINT32                      ui32UpdateAddr;         /*!< Address */
371         IMG_UINT32                      ui32UpdateVal;          /*!< value */
372 } PVRSRV_MEMUPDATE;
374 /*!
375  ******************************************************************************
376  * address:value register structure
377  *****************************************************************************/
378 typedef struct _PVRSRV_HWREG_
380         IMG_UINT32                      ui32RegAddr;    /*!< Address */
381         IMG_UINT32                      ui32RegVal;             /*!< value */
382 } PVRSRV_HWREG;
384 /*!
385  ******************************************************************************
386  * Implementation details for memory handling
387  *****************************************************************************/
388 typedef struct _PVRSRV_MEMBLK_
390         IMG_DEV_VIRTADDR        sDevVirtAddr;                   /*!< Address of the memory in the IMG MMUs address space */
391         IMG_HANDLE                      hOSMemHandle;                   /*!< Stores the underlying memory allocation handle */
392         IMG_HANDLE                      hOSWrapMem;                             /*!< FIXME: better way to solve this problem */
393         IMG_HANDLE                      hBuffer;                                /*!< Stores the BM_HANDLE for the underlying memory management */
394         IMG_HANDLE                      hResItem;                               /*!< handle to resource item for allocate */
395         IMG_SYS_PHYADDR         *psIntSysPAddr;
397 } PVRSRV_MEMBLK;
399 /*!
400  ******************************************************************************
401  * Memory Management (externel interface)
402  *****************************************************************************/
403 typedef struct _PVRSRV_KERNEL_MEM_INFO_ *PPVRSRV_KERNEL_MEM_INFO;
405 typedef struct _PVRSRV_CLIENT_MEM_INFO_
407         /* CPU Virtual Address */
408         IMG_PVOID                               pvLinAddr;
410         /* CPU Virtual Address (for kernel mode) */
411         IMG_PVOID                               pvLinAddrKM;
413         /* Device Virtual Address */
414         IMG_DEV_VIRTADDR                sDevVAddr;
416         /* allocation flags */
417         IMG_UINT32                              ui32Flags;
419         /* client allocation flags */
420         IMG_UINT32                              ui32ClientFlags;
422         /* allocation size in bytes */
423         IMG_SIZE_T                              uAllocSize;
426         /* ptr to associated client sync info - NULL if no sync */
427         struct _PVRSRV_CLIENT_SYNC_INFO_        *psClientSyncInfo;
429         /* handle to client mapping data (OS specific) */
430         IMG_HANDLE                                                      hMappingInfo;
432         /* handle to kernel mem info */
433         IMG_HANDLE                                                      hKernelMemInfo;
435         /* resman handle for UM mapping clean-up */
436         IMG_HANDLE                                                      hResItem;
438 #if defined(SUPPORT_MEMINFO_IDS)
439         #if !defined(USE_CODE)
440         /* Globally unique "stamp" for allocation (not re-used until wrap) */
441         IMG_UINT64                                                      ui64Stamp;
442         #else /* !defined(USE_CODE) */
443         IMG_UINT32                                                      dummy1;
444         IMG_UINT32                                                      dummy2;
445         #endif /* !defined(USE_CODE) */
446 #endif /* defined(SUPPORT_MEMINFO_IDS) */
447 #if defined(SUPPORT_ION)
448         IMG_SIZE_T                                                      uiIonBufferSize;
449 #endif /* defined(SUPPORT_ION) */
451         /*
452                 ptr to next mem info
453                 D3D uses psNext for mid-scene texture reload.
454         */
455         struct _PVRSRV_CLIENT_MEM_INFO_         *psNext;
457 } PVRSRV_CLIENT_MEM_INFO, *PPVRSRV_CLIENT_MEM_INFO;
460 /*!
461  ******************************************************************************
462  * Memory Heap Information
463  *****************************************************************************/
464 #define PVRSRV_MAX_CLIENT_HEAPS (32)
465 typedef struct _PVRSRV_HEAP_INFO_
467         IMG_UINT32                      ui32HeapID;
468         IMG_HANDLE                      hDevMemHeap;
469         IMG_DEV_VIRTADDR        sDevVAddrBase;
470         IMG_UINT32                      ui32HeapByteSize;
471         IMG_UINT32                      ui32Attribs;
472         IMG_UINT32                      ui32XTileStride;
473 }PVRSRV_HEAP_INFO;
478 /*
479         Event Object information structure
480 */
481 typedef struct _PVRSRV_EVENTOBJECT_
483         /* globally unique name of the event object */
484         IMG_CHAR        szName[EVENTOBJNAME_MAXLENGTH];
485         /* kernel specific handle for the event object */
486         IMG_HANDLE      hOSEventKM;
488 } PVRSRV_EVENTOBJECT;
490 /*
491         Cache operation type
492 */
493 typedef enum
495         PVRSRV_MISC_INFO_CPUCACHEOP_NONE = 0,
496         PVRSRV_MISC_INFO_CPUCACHEOP_CLEAN,
497         PVRSRV_MISC_INFO_CPUCACHEOP_FLUSH
498 } PVRSRV_MISC_INFO_CPUCACHEOP_TYPE;
500 /*!
501  ******************************************************************************
502  * Structure to retrieve misc. information from services
503  *****************************************************************************/
504 typedef struct _PVRSRV_MISC_INFO_
506         IMG_UINT32      ui32StateRequest;               /*!< requested State Flags */
507         IMG_UINT32      ui32StatePresent;               /*!< Present/Valid State Flags */
509         /*!< SOC Timer register */
510         IMG_VOID        *pvSOCTimerRegisterKM;
511         IMG_VOID        *pvSOCTimerRegisterUM;
512         IMG_HANDLE      hSOCTimerRegisterOSMemHandle;
513         IMG_HANDLE      hSOCTimerRegisterMappingInfo;
515         /*!< SOC Clock Gating registers */
516         IMG_VOID        *pvSOCClockGateRegs;
517         IMG_UINT32      ui32SOCClockGateRegsSize;
519         /* Memory Stats/DDK version string depending on ui32StateRequest flags */
520         IMG_CHAR        *pszMemoryStr;
521         IMG_UINT32      ui32MemoryStrLen;
523         /* global event object */
524         PVRSRV_EVENTOBJECT      sGlobalEventObject;//FIXME: should be private to services
525         IMG_HANDLE                      hOSGlobalEvent;
527         /* Note: add misc. items as required */
528         IMG_UINT32      aui32DDKVersion[4];
530         /*!< CPU cache flush controls: */
531         struct
532         {
533                 /*!< Defer the CPU cache op to the next HW op to be submitted (else flush now) */
534                 IMG_BOOL bDeferOp;
536                 /*!< Type of cache operation to perform */
537                 PVRSRV_MISC_INFO_CPUCACHEOP_TYPE eCacheOpType;
539                 /* This union is a bit unsightly. We need it because we'll use the psMemInfo
540                  * directly in the srvclient PVRSRVGetMiscInfo code, and then convert it
541                  * to a kernel meminfo if required. Try to not waste space.
542                  */
543                 union
544                 {
545                         /*!< Input client meminfo (UM side) */
546                         PVRSRV_CLIENT_MEM_INFO *psClientMemInfo;
548                         /*!< Output kernel meminfo (Bridge+KM side) */
549                         struct _PVRSRV_KERNEL_MEM_INFO_ *psKernelMemInfo;
550                 } u;
552                 /*!< Offset in MemInfo to start cache op */
553                 IMG_VOID *pvBaseVAddr;
555                 /*!< Length of range to perform cache op  */
556                 IMG_UINT32      ui32Length;
557         } sCacheOpCtl;
559         /*!< Meminfo refcount controls: */
560         struct
561         {
562                 /* This union is a bit unsightly. We need it because we'll use the psMemInfo
563                  * directly in the srvclient PVRSRVGetMiscInfo code, and then convert it
564                  * to a kernel meminfo if required. Try to not waste space.
565                  */
566                 union
567                 {
568                         /*!< Input client meminfo (UM side) */
569                         PVRSRV_CLIENT_MEM_INFO *psClientMemInfo;
571                         /*!< Output kernel meminfo (Bridge+KM side) */
572                         struct _PVRSRV_KERNEL_MEM_INFO_ *psKernelMemInfo;
573                 } u;
575                 /*!< Resulting refcount */
576                 IMG_UINT32 ui32RefCount;
577         } sGetRefCountCtl;
579         IMG_UINT32 ui32PageSize;
580 } PVRSRV_MISC_INFO;
582 /*!
583  ******************************************************************************
584  * Synchronisation token
585  *****************************************************************************/
586 typedef struct _PVRSRV_SYNC_TOKEN_
588         /* This token is supposed to be passed around as an opaque object
589            - caller should not rely on the internal fields staying the same.
590            The fields are hidden in sPrivate in order to reinforce this. */
591         struct
592         {
593                 IMG_HANDLE hKernelSyncInfo;
594                 IMG_UINT32 ui32ReadOpsPendingSnapshot;
595                 IMG_UINT32 ui32WriteOpsPendingSnapshot;
596                 IMG_UINT32 ui32ReadOps2PendingSnapshot;
597         } sPrivate;
598 } PVRSRV_SYNC_TOKEN;
601 /******************************************************************************
602  * PVR Client Event handling in Services
603  *****************************************************************************/
604 typedef enum _PVRSRV_CLIENT_EVENT_
606         PVRSRV_CLIENT_EVENT_HWTIMEOUT = 0
607 } PVRSRV_CLIENT_EVENT;
609 typedef IMG_VOID (*PFN_QUEUE_COMMAND_COMPLETE)(IMG_HANDLE hCallbackData);
611 IMG_IMPORT
612 PVRSRV_ERROR IMG_CALLCONV PVRSRVClientEvent(IMG_CONST PVRSRV_CLIENT_EVENT eEvent,
613                                                                                         PVRSRV_DEV_DATA *psDevData,
614                                                                                         IMG_PVOID pvData);
616 /******************************************************************************
617  * PVR Services API prototypes.
618  *****************************************************************************/
619 IMG_IMPORT
620 PVRSRV_ERROR IMG_CALLCONV PVRSRVConnect(PVRSRV_CONNECTION **ppsConnection, IMG_UINT32 ui32SrvFlags);
622 IMG_IMPORT
623 PVRSRV_ERROR IMG_CALLCONV PVRSRVDisconnect(IMG_CONST PVRSRV_CONNECTION *psConnection);
625 IMG_IMPORT
626 PVRSRV_ERROR IMG_CALLCONV PVRSRVEnumerateDevices(IMG_CONST PVRSRV_CONNECTION                    *psConnection,
627                                                                                                         IMG_UINT32                                      *puiNumDevices,
628                                                                                                         PVRSRV_DEVICE_IDENTIFIER        *puiDevIDs);
629 IMG_IMPORT
630 PVRSRV_ERROR IMG_CALLCONV PVRSRVAcquireDeviceData(IMG_CONST PVRSRV_CONNECTION   *psConnection,
631                                                                                                         IMG_UINT32                      uiDevIndex,
632                                                                                                         PVRSRV_DEV_DATA         *psDevData,
633                                                                                                         PVRSRV_DEVICE_TYPE      eDeviceType);
634 IMG_IMPORT
635 PVRSRV_ERROR IMG_CALLCONV PVRSRVGetMiscInfo (IMG_CONST PVRSRV_CONNECTION *psConnection, PVRSRV_MISC_INFO *psMiscInfo);
637 IMG_IMPORT
638 PVRSRV_ERROR IMG_CALLCONV PVRSRVReleaseMiscInfo (IMG_CONST PVRSRV_CONNECTION *psConnection, PVRSRV_MISC_INFO *psMiscInfo);
640 IMG_IMPORT
641 PVRSRV_ERROR PVRSRVPollForValue ( const PVRSRV_CONNECTION *psConnection,
642                                                         IMG_HANDLE hOSEvent,
643                                                         volatile IMG_UINT32 *pui32LinMemAddr,
644                                                         IMG_UINT32 ui32Value,
645                                                         IMG_UINT32 ui32Mask,
646                                                         IMG_UINT32 ui32Waitus,
647                                                         IMG_UINT32 ui32Tries);
649 /* memory APIs */
650 IMG_IMPORT
651 PVRSRV_ERROR IMG_CALLCONV PVRSRVCreateDeviceMemContext(IMG_CONST PVRSRV_DEV_DATA *psDevData,
652                                                                                         IMG_HANDLE *phDevMemContext,
653                                                                                         IMG_UINT32 *pui32SharedHeapCount,
654                                                                                         PVRSRV_HEAP_INFO *psHeapInfo);
656 IMG_IMPORT
657 PVRSRV_ERROR IMG_CALLCONV PVRSRVDestroyDeviceMemContext(IMG_CONST PVRSRV_DEV_DATA *psDevData,
658                                                                                         IMG_HANDLE                      hDevMemContext
659         );
661 IMG_IMPORT
662 PVRSRV_ERROR IMG_CALLCONV PVRSRVGetDeviceMemHeapInfo(IMG_CONST PVRSRV_DEV_DATA *psDevData,
663                                                                                         IMG_HANDLE hDevMemContext,
664                                                                                         IMG_UINT32 *pui32SharedHeapCount,
665                                                                                         PVRSRV_HEAP_INFO *psHeapInfo);
667 #if defined(PVRSRV_LOG_MEMORY_ALLOCS)
668         #define PVRSRVAllocDeviceMem_log(psDevData, hDevMemHeap, ui32Attribs, ui32Size, ui32Alignment, ppsMemInfo, logStr) \
669                 (PVR_TRACE(("PVRSRVAllocDeviceMem(" #psDevData "," #hDevMemHeap "," #ui32Attribs "," #ui32Size "," #ui32Alignment "," #ppsMemInfo ")" \
670                         ": " logStr " (size = 0x%lx)", ui32Size)), \
671                 PVRSRVAllocDeviceMem(psDevData, hDevMemHeap, ui32Attribs, ui32Size, ui32Alignment, ppsMemInfo))
672 #else
673         #define PVRSRVAllocDeviceMem_log(psDevData, hDevMemHeap, ui32Attribs, ui32Size, ui32Alignment, ppsMemInfo, logStr) \
674                 PVRSRVAllocDeviceMem(psDevData, hDevMemHeap, ui32Attribs, ui32Size, ui32Alignment, ppsMemInfo)
675 #endif
678 IMG_IMPORT
679 PVRSRV_ERROR IMG_CALLCONV PVRSRVAllocDeviceMem2(IMG_CONST PVRSRV_DEV_DATA       *psDevData,
680                                                                         IMG_HANDLE              hDevMemHeap,
681                                                                         IMG_UINT32              ui32Attribs,
682                                                                         IMG_SIZE_T              ui32Size,
683                                                                         IMG_SIZE_T              ui32Alignment,
684                                                                         IMG_PVOID               pvPrivData,
685                                                                         IMG_UINT32              ui32PrivDataLength,
686                                                                         PVRSRV_CLIENT_MEM_INFO  **ppsMemInfo);
688 IMG_IMPORT
689 PVRSRV_ERROR IMG_CALLCONV PVRSRVAllocDeviceMem(IMG_CONST PVRSRV_DEV_DATA        *psDevData,
690                                                                         IMG_HANDLE              hDevMemHeap,
691                                                                         IMG_UINT32              ui32Attribs,
692                                                                         IMG_SIZE_T              ui32Size,
693                                                                         IMG_SIZE_T              ui32Alignment,
694                                                                         PVRSRV_CLIENT_MEM_INFO  **ppsMemInfo);
696 IMG_IMPORT
697 PVRSRV_ERROR IMG_CALLCONV PVRSRVFreeDeviceMem(IMG_CONST PVRSRV_DEV_DATA *psDevData,
698                                                                 PVRSRV_CLIENT_MEM_INFO          *psMemInfo);
700 IMG_IMPORT
701 PVRSRV_ERROR IMG_CALLCONV PVRSRVExportDeviceMem(IMG_CONST PVRSRV_DEV_DATA       *psDevData,
702                                                                                                 PVRSRV_CLIENT_MEM_INFO          *psMemInfo,
703                                                                                                 IMG_HANDLE                                      *phMemInfo
704         );
706 IMG_IMPORT
707 PVRSRV_ERROR IMG_CALLCONV PVRSRVReserveDeviceVirtualMem(IMG_CONST PVRSRV_DEV_DATA *psDevData,
708                                                                                         IMG_HANDLE                      hDevMemHeap,
709                                                                                         IMG_DEV_VIRTADDR        *psDevVAddr,
710                                                                                         IMG_SIZE_T                      ui32Size,
711                                                                                         IMG_SIZE_T                      ui32Alignment,
712                                                                                         PVRSRV_CLIENT_MEM_INFO          **ppsMemInfo);
713 IMG_IMPORT
714 PVRSRV_ERROR IMG_CALLCONV PVRSRVFreeDeviceVirtualMem(IMG_CONST PVRSRV_DEV_DATA *psDevData,
715                                                                                                         PVRSRV_CLIENT_MEM_INFO *psMemInfo);
717 IMG_IMPORT
718 PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceMemory (IMG_CONST PVRSRV_DEV_DATA *psDevData,
719                                                                         IMG_HANDLE hKernelMemInfo,
720                                                                         IMG_HANDLE hDstDevMemHeap,
721                                                                         PVRSRV_CLIENT_MEM_INFO **ppsDstMemInfo);
723 IMG_IMPORT
724 PVRSRV_ERROR IMG_CALLCONV PVRSRVUnmapDeviceMemory (IMG_CONST PVRSRV_DEV_DATA *psDevData,
725                                                                                 PVRSRV_CLIENT_MEM_INFO *psMemInfo);
727 IMG_IMPORT
728 PVRSRV_ERROR IMG_CALLCONV PVRSRVMapExtMemory (IMG_CONST PVRSRV_DEV_DATA *psDevData,
729                                                                         PVRSRV_CLIENT_MEM_INFO          *psMemInfo,
730                                                                         IMG_SYS_PHYADDR                         *psSysPAddr,
731                                                                         IMG_UINT32                                      ui32Flags);
732 IMG_IMPORT
733 PVRSRV_ERROR IMG_CALLCONV PVRSRVUnmapExtMemory (IMG_CONST PVRSRV_DEV_DATA *psDevData,
734                                                                         PVRSRV_CLIENT_MEM_INFO          *psMemInfo,
735                                                                         IMG_UINT32                                      ui32Flags);
737 IMG_IMPORT
738 PVRSRV_ERROR IMG_CALLCONV PVRSRVWrapExtMemory(IMG_CONST PVRSRV_DEV_DATA *psDevData,
739                                                                                                 IMG_HANDLE                              hDevMemContext,
740                                                                                                 IMG_SIZE_T                              ui32ByteSize,
741                                                                                                 IMG_SIZE_T                              ui32PageOffset,
742                                                                                                 IMG_BOOL                                bPhysContig,
743                                                                                                 IMG_SYS_PHYADDR                 *psSysPAddr,
744                                                                                                 IMG_VOID                                *pvLinAddr,
745                                                                                                 IMG_UINT32                              ui32Flags,
746                                                                                                 PVRSRV_CLIENT_MEM_INFO **ppsMemInfo);
747 IMG_IMPORT
748 PVRSRV_ERROR IMG_CALLCONV PVRSRVUnwrapExtMemory (IMG_CONST PVRSRV_DEV_DATA *psDevData,
749                                                                                                 PVRSRV_CLIENT_MEM_INFO *psMemInfo);
751 PVRSRV_ERROR PVRSRVChangeDeviceMemoryAttributes(IMG_CONST PVRSRV_DEV_DATA                       *psDevData,
752                                                                                                 PVRSRV_CLIENT_MEM_INFO  *psClientMemInfo,
753                                                                                                 IMG_UINT32                              ui32Attribs);
755 IMG_IMPORT
756 PVRSRV_ERROR IMG_CALLCONV PVRSRVMapPhysToUserSpace(IMG_CONST PVRSRV_DEV_DATA *psDevData,
757                                                                           IMG_SYS_PHYADDR sSysPhysAddr,
758                                                                           IMG_UINT32 uiSizeInBytes,
759                                                                           IMG_PVOID *ppvUserAddr,
760                                                                           IMG_UINT32 *puiActualSize,
761                                                                           IMG_PVOID *ppvProcess);
763 IMG_IMPORT
764 PVRSRV_ERROR IMG_CALLCONV PVRSRVUnmapPhysToUserSpace(IMG_CONST PVRSRV_DEV_DATA *psDevData,
765                                                                                 IMG_PVOID pvUserAddr,
766                                                                                 IMG_PVOID pvProcess);
768 #if defined(LINUX)
769 IMG_IMPORT
770 PVRSRV_ERROR IMG_CALLCONV PVRSRVExportDeviceMem2(IMG_CONST PVRSRV_DEV_DATA      *psDevData,
771                                                                                                  PVRSRV_CLIENT_MEM_INFO         *psMemInfo,
772                                                                                                  IMG_INT                                        *iFd);
774 IMG_IMPORT
775 PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceMemory2(IMG_CONST PVRSRV_DEV_DATA      *psDevData,
776                                                                                                  IMG_INT                                        iFd,
777                                                                                                  IMG_HANDLE                                     hDstDevMemHeap,
778                                                                                                  PVRSRV_CLIENT_MEM_INFO         **ppsDstMemInfo);
779 #endif /* defined(LINUX) */
781 #if defined(SUPPORT_ION)
782 PVRSRV_ERROR PVRSRVMapIonHandle(const PVRSRV_DEV_DATA *psDevData,
783                                                                 IMG_HANDLE hDevMemHeap,
784                                                                 IMG_UINT32 ui32NumFDs,
785                                                                 IMG_INT    *paiBufferFDs,
786                                                                 IMG_UINT32 ui32ChunkCount,
787                                                                 IMG_SIZE_T *pauiOffset,
788                                                                 IMG_SIZE_T *pauiSize,
789                                                                 IMG_UINT32 ui32Attribs,
790                                                                 PVRSRV_CLIENT_MEM_INFO **ppsMemInfo);
792 PVRSRV_ERROR PVRSRVUnmapIonHandle(const PVRSRV_DEV_DATA *psDevData,
793                                                                   PVRSRV_CLIENT_MEM_INFO *psMemInfo);
794 #endif /* defined (SUPPORT_ION) */
797 IMG_IMPORT
798 PVRSRV_ERROR IMG_CALLCONV PVRSRVAllocDeviceMemSparse(const PVRSRV_DEV_DATA *psDevData,
799                                                                                                         IMG_HANDLE hDevMemHeap,
800                                                                                                         IMG_UINT32 ui32Attribs,
801                                                                                                         IMG_SIZE_T uAlignment,
802                                                                                                         IMG_UINT32 ui32ChunkSize,
803                                                                                                         IMG_UINT32 ui32NumVirtChunks,
804                                                                                                         IMG_UINT32 ui32NumPhysChunks,
805                                                                                                         IMG_BOOL *pabMapChunk,
806                                                                                                         PVRSRV_CLIENT_MEM_INFO **ppsMemInfo);
808 /******************************************************************************
809  * PVR Allocation Synchronisation Functionality...
810  *****************************************************************************/
812 typedef enum _PVRSRV_SYNCVAL_MODE_
814         PVRSRV_SYNCVAL_READ                             = IMG_TRUE,
815         PVRSRV_SYNCVAL_WRITE                    = IMG_FALSE
817 } PVRSRV_SYNCVAL_MODE, *PPVRSRV_SYNCVAL_MODE;
819 typedef IMG_UINT32 PVRSRV_SYNCVAL;
821 IMG_IMPORT PVRSRV_ERROR PVRSRVWaitForOpsComplete(PPVRSRV_CLIENT_MEM_INFO psMemInfo,
822         PVRSRV_SYNCVAL_MODE eMode, PVRSRV_SYNCVAL OpRequired);
824 IMG_IMPORT PVRSRV_ERROR PVRSRVWaitForAllOpsComplete(PPVRSRV_CLIENT_MEM_INFO psMemInfo,
825         PVRSRV_SYNCVAL_MODE eMode);
827 IMG_IMPORT IMG_BOOL PVRSRVTestOpsComplete(PPVRSRV_CLIENT_MEM_INFO psMemInfo,
828         PVRSRV_SYNCVAL_MODE eMode, PVRSRV_SYNCVAL OpRequired);
830 IMG_IMPORT IMG_BOOL PVRSRVTestAllOpsComplete(PPVRSRV_CLIENT_MEM_INFO psMemInfo,
831         PVRSRV_SYNCVAL_MODE eMode);
833 IMG_IMPORT IMG_BOOL PVRSRVTestOpsNotComplete(PPVRSRV_CLIENT_MEM_INFO psMemInfo,
834         PVRSRV_SYNCVAL_MODE eMode, PVRSRV_SYNCVAL OpRequired);
836 IMG_IMPORT IMG_BOOL PVRSRVTestAllOpsNotComplete(PPVRSRV_CLIENT_MEM_INFO psMemInfo,
837         PVRSRV_SYNCVAL_MODE eMode);
839 IMG_IMPORT PVRSRV_SYNCVAL PVRSRVGetPendingOpSyncVal(PPVRSRV_CLIENT_MEM_INFO psMemInfo,
840         PVRSRV_SYNCVAL_MODE eMode);
842 #if defined(SUPPORT_PVRSRV_DEVICE_CLASS)
844 IMG_IMPORT
845 PVRSRV_ERROR IMG_CALLCONV PVRSRVMapDeviceClassMemory (IMG_CONST PVRSRV_DEV_DATA *psDevData,
846                                                                                 IMG_HANDLE hDevMemContext,
847                                                                                 IMG_HANDLE hDeviceClassBuffer,
848                                                                                 PVRSRV_CLIENT_MEM_INFO **ppsMemInfo);
849 IMG_IMPORT
850 PVRSRV_ERROR IMG_CALLCONV PVRSRVUnmapDeviceClassMemory (IMG_CONST PVRSRV_DEV_DATA *psDevData,
851                                                                                 PVRSRV_CLIENT_MEM_INFO *psMemInfo);
853 /******************************************************************************
854  * Common Device Class Enumeration
855  *****************************************************************************/
856 IMG_IMPORT
857 PVRSRV_ERROR IMG_CALLCONV PVRSRVEnumerateDeviceClass(IMG_CONST PVRSRV_CONNECTION *psConnection,
858                                                                                                         PVRSRV_DEVICE_CLASS DeviceClass,
859                                                                                                         IMG_UINT32 *pui32DevCount,
860                                                                                                         IMG_UINT32 *pui32DevID);
862 /******************************************************************************
863  * Display Device Class API definition
864  *****************************************************************************/
865 IMG_IMPORT
866 IMG_HANDLE IMG_CALLCONV PVRSRVOpenDCDevice(IMG_CONST PVRSRV_DEV_DATA *psDevData,
867                                                                                         IMG_UINT32 ui32DeviceID);
869 IMG_IMPORT
870 PVRSRV_ERROR IMG_CALLCONV PVRSRVCloseDCDevice(IMG_CONST PVRSRV_CONNECTION       *psConnection, IMG_HANDLE hDevice);
872 IMG_IMPORT
873 PVRSRV_ERROR IMG_CALLCONV PVRSRVEnumDCFormats (IMG_HANDLE hDevice,
874                                                                                         IMG_UINT32              *pui32Count,
875                                                                                         DISPLAY_FORMAT  *psFormat);
877 IMG_IMPORT
878 PVRSRV_ERROR IMG_CALLCONV PVRSRVEnumDCDims (IMG_HANDLE hDevice,
879                                                                                 IMG_UINT32              *pui32Count,
880                                                                                 DISPLAY_FORMAT  *psFormat,
881                                                                                 DISPLAY_DIMS    *psDims);
883 IMG_IMPORT
884 PVRSRV_ERROR IMG_CALLCONV PVRSRVGetDCSystemBuffer(IMG_HANDLE hDevice,
885                                                                                 IMG_HANDLE *phBuffer
886         );
888 IMG_IMPORT
889 PVRSRV_ERROR IMG_CALLCONV PVRSRVGetDCInfo(IMG_HANDLE hDevice,
890                                                                                 DISPLAY_INFO* psDisplayInfo);
892 IMG_IMPORT
893 PVRSRV_ERROR IMG_CALLCONV PVRSRVCreateDCSwapChain (IMG_HANDLE                           hDevice,
894                                                                                                         IMG_UINT32                              ui32Flags,
895                                                                                                         DISPLAY_SURF_ATTRIBUTES *psDstSurfAttrib,
896                                                                                                         DISPLAY_SURF_ATTRIBUTES *psSrcSurfAttrib,
897                                                                                                         IMG_UINT32                              ui32BufferCount,
898                                                                                                         IMG_UINT32                              ui32OEMFlags,
899                                                                                                         IMG_UINT32                              *pui32SwapChainID,
900                                                                                                         IMG_HANDLE                              *phSwapChain
901         );
903 IMG_IMPORT
904 PVRSRV_ERROR IMG_CALLCONV PVRSRVDestroyDCSwapChain (IMG_HANDLE hDevice,
905                                                                                         IMG_HANDLE              hSwapChain
906         );
908 IMG_IMPORT
909 PVRSRV_ERROR IMG_CALLCONV PVRSRVSetDCDstRect (IMG_HANDLE hDevice,
910                                                                                 IMG_HANDLE      hSwapChain,
911                                                                                 IMG_RECT        *psDstRect);
913 IMG_IMPORT
914 PVRSRV_ERROR IMG_CALLCONV PVRSRVSetDCSrcRect (IMG_HANDLE hDevice,
915                                                                                 IMG_HANDLE      hSwapChain,
916                                                                                 IMG_RECT        *psSrcRect);
918 IMG_IMPORT
919 PVRSRV_ERROR IMG_CALLCONV PVRSRVSetDCDstColourKey (IMG_HANDLE hDevice,
920                                                                                         IMG_HANDLE      hSwapChain,
921                                                                                         IMG_UINT32      ui32CKColour);
923 IMG_IMPORT
924 PVRSRV_ERROR IMG_CALLCONV PVRSRVSetDCSrcColourKey (IMG_HANDLE hDevice,
925                                                                                         IMG_HANDLE      hSwapChain,
926                                                                                         IMG_UINT32      ui32CKColour);
928 IMG_IMPORT
929 PVRSRV_ERROR IMG_CALLCONV PVRSRVGetDCBuffers(IMG_HANDLE hDevice,
930                                                                         IMG_HANDLE hSwapChain,
931                                                                         IMG_HANDLE *phBuffer
932         );
934 IMG_IMPORT
935 PVRSRV_ERROR IMG_CALLCONV PVRSRVGetDCBuffers2(IMG_HANDLE hDevice,
936                                                                                           IMG_HANDLE hSwapChain,
937                                                                                           IMG_HANDLE *phBuffer,
938                                                                                           IMG_SYS_PHYADDR *psPhyAddr);
940 IMG_IMPORT
941 PVRSRV_ERROR IMG_CALLCONV PVRSRVSwapToDCBuffer (IMG_HANDLE hDevice,
942                                                                                 IMG_HANDLE hBuffer,
943                                                                                 IMG_UINT32 ui32ClipRectCount,
944                                                                                 IMG_RECT  *psClipRect,
945                                                                                 IMG_UINT32 ui32SwapInterval,
946                                                                                 IMG_HANDLE hPrivateTag
947         );
949 IMG_IMPORT
950 PVRSRV_ERROR IMG_CALLCONV PVRSRVSwapToDCBuffer2 (IMG_HANDLE hDevice,
951                                                                                 IMG_HANDLE hBuffer,
952                                                                                 IMG_UINT32 ui32SwapInterval,
953                                                                                 PVRSRV_CLIENT_MEM_INFO **ppsMemInfos,
954                                                                                 PVRSRV_CLIENT_SYNC_INFO **ppsSyncInfos,
955                                                                                 IMG_UINT32 ui32NumMemSyncInfos,
956                                                                                 IMG_PVOID  pvPrivData,
957                                                                                 IMG_UINT32 ui32PrivDataLength,
958                                                                                 IMG_HANDLE *phFence);
960 IMG_IMPORT
961 PVRSRV_ERROR IMG_CALLCONV PVRSRVSwapToDCSystem (IMG_HANDLE hDevice,
962                                                                                 IMG_HANDLE hSwapChain
963         );
965 /******************************************************************************
966  * Buffer Device Class API definition
967  *****************************************************************************/
968 IMG_IMPORT
969 IMG_HANDLE IMG_CALLCONV PVRSRVOpenBCDevice(IMG_CONST PVRSRV_DEV_DATA *psDevData,
970                                                                                         IMG_UINT32 ui32DeviceID);
972 IMG_IMPORT
973 PVRSRV_ERROR IMG_CALLCONV PVRSRVCloseBCDevice(IMG_CONST PVRSRV_CONNECTION *psConnection,
974                                                                                                 IMG_HANDLE hDevice);
976 IMG_IMPORT
977 PVRSRV_ERROR IMG_CALLCONV PVRSRVGetBCBufferInfo(IMG_HANDLE hDevice,
978                                                                                                 BUFFER_INFO     *psBuffer);
980 IMG_IMPORT
981 PVRSRV_ERROR IMG_CALLCONV PVRSRVGetBCBuffer(IMG_HANDLE hDevice,
982                                                                                                 IMG_UINT32 ui32BufferIndex,
983                                                                                                 IMG_HANDLE *phBuffer
984         );
986 #endif /* #if defined(SUPPORT_PVRSRV_DEVICE_CLASS) */
988 /******************************************************************************
989  * PDUMP Function prototypes...
990  *****************************************************************************/
991 IMG_IMPORT
992 PVRSRV_ERROR IMG_CALLCONV PVRSRVPDumpInit(IMG_CONST PVRSRV_CONNECTION *psConnection);
994 IMG_IMPORT
995 PVRSRV_ERROR IMG_CALLCONV PVRSRVPDumpStartInitPhase(IMG_CONST PVRSRV_CONNECTION *psConnection);
997 IMG_IMPORT
998 PVRSRV_ERROR IMG_CALLCONV PVRSRVPDumpStopInitPhase(IMG_CONST PVRSRV_CONNECTION *psConnection);
1000 IMG_IMPORT
1001 PVRSRV_ERROR IMG_CALLCONV PVRSRVPDumpMemPol(IMG_CONST PVRSRV_CONNECTION *psConnection,
1002                                                                                   PVRSRV_CLIENT_MEM_INFO *psMemInfo,
1003                                                                                   IMG_UINT32 ui32Offset,
1004                                                                                   IMG_UINT32 ui32Value,
1005                                                                                   IMG_UINT32 ui32Mask,
1006                                                                                   PDUMP_POLL_OPERATOR eOperator,
1007                                                                                   IMG_UINT32 ui32Flags);
1009 IMG_IMPORT
1010 PVRSRV_ERROR IMG_CALLCONV PVRSRVPDumpSyncPol(IMG_CONST PVRSRV_CONNECTION *psConnection,
1011                                                                                          PVRSRV_CLIENT_SYNC_INFO *psClientSyncInfo,
1012                                                                                          IMG_BOOL   bIsRead,
1013                                                                                          IMG_UINT32 ui32Value,
1014                                                                                          IMG_UINT32 ui32Mask);
1016 IMG_IMPORT
1017 PVRSRV_ERROR IMG_CALLCONV PVRSRVPDumpSyncPol2(IMG_CONST PVRSRV_CONNECTION *psConnection,
1018                                                                                          PVRSRV_CLIENT_SYNC_INFO *psClientSyncInfo,
1019                                                                                          IMG_BOOL bIsRead);
1021 IMG_IMPORT
1022 PVRSRV_ERROR IMG_CALLCONV PVRSRVPDumpMem(IMG_CONST PVRSRV_CONNECTION *psConnection,
1023                                                                         IMG_PVOID pvAltLinAddr,
1024                                                                         PVRSRV_CLIENT_MEM_INFO *psMemInfo,
1025                                                                         IMG_UINT32 ui32Offset,
1026                                                                         IMG_UINT32 ui32Bytes,
1027                                                                         IMG_UINT32 ui32Flags);
1029 IMG_IMPORT
1030 PVRSRV_ERROR IMG_CALLCONV PVRSRVPDumpSync(IMG_CONST PVRSRV_CONNECTION *psConnection,
1031                                                                                 IMG_PVOID pvAltLinAddr,
1032                                                                                 PVRSRV_CLIENT_SYNC_INFO *psClientSyncInfo,
1033                                                                                 IMG_UINT32 ui32Offset,
1034                                                                                 IMG_UINT32 ui32Bytes);
1036 IMG_IMPORT
1037 PVRSRV_ERROR IMG_CALLCONV PVRSRVPDumpReg(IMG_CONST PVRSRV_DEV_DATA *psDevData,
1038                                                                                  IMG_CHAR *pszRegRegion,
1039                                                                                         IMG_UINT32 ui32RegAddr,
1040                                                                                         IMG_UINT32 ui32RegValue,
1041                                                                                         IMG_UINT32 ui32Flags);
1043 IMG_IMPORT
1044 PVRSRV_ERROR IMG_CALLCONV PVRSRVPDumpRegPolWithFlags(const PVRSRV_DEV_DATA *psDevData,
1045                                                                                                          IMG_CHAR *pszRegRegion,
1046                                                                                                          IMG_UINT32 ui32RegAddr,
1047                                                                                                          IMG_UINT32 ui32RegValue,
1048                                                                                                          IMG_UINT32 ui32Mask,
1049                                                                                                          IMG_UINT32 ui32Flags);
1050 IMG_IMPORT
1051 PVRSRV_ERROR IMG_CALLCONV PVRSRVPDumpRegPol(const PVRSRV_DEV_DATA *psDevData,
1052                                                                                         IMG_CHAR *pszRegRegion,
1053                                                                                         IMG_UINT32 ui32RegAddr,
1054                                                                                         IMG_UINT32 ui32RegValue,
1055                                                                                         IMG_UINT32 ui32Mask);
1057 IMG_IMPORT
1058 PVRSRV_ERROR IMG_CALLCONV PVRSRVPDumpPDReg(IMG_CONST PVRSRV_CONNECTION *psConnection,
1059                                                                                         IMG_UINT32 ui32RegAddr,
1060                                                                                         IMG_UINT32 ui32RegValue);
1061 IMG_IMPORT
1062 PVRSRV_ERROR IMG_CALLCONV PVRSRVPDumpPDDevPAddr(IMG_CONST PVRSRV_CONNECTION *psConnection,
1063                                                                                                 PVRSRV_CLIENT_MEM_INFO *psMemInfo,
1064                                                                                                 IMG_UINT32 ui32Offset,
1065                                                                                                 IMG_DEV_PHYADDR sPDDevPAddr);
1067 #if !defined(USE_CODE)
1068 IMG_IMPORT
1069 PVRSRV_ERROR IMG_CALLCONV PVRSRVPDumpMemPages(IMG_CONST PVRSRV_DEV_DATA *psDevData,
1070                                                                                                                    IMG_HANDLE                   hKernelMemInfo,
1071                                                                                                                    IMG_DEV_PHYADDR              *pPages,
1072                                                                                                                    IMG_UINT32                   ui32NumPages,
1073                                                                                                                    IMG_DEV_VIRTADDR             sDevVAddr,
1074                                                                                                                    IMG_UINT32                   ui32Start,
1075                                                                                                                    IMG_UINT32                   ui32Length,
1076                                                                                                                    IMG_UINT32                   ui32Flags);
1077 #endif
1079 IMG_IMPORT
1080 PVRSRV_ERROR IMG_CALLCONV PVRSRVPDumpSetFrame(IMG_CONST PVRSRV_CONNECTION *psConnection,
1081                                                                                           IMG_UINT32 ui32Frame);
1083 IMG_IMPORT
1084 PVRSRV_ERROR IMG_CALLCONV PVRSRVPDumpComment(IMG_CONST PVRSRV_CONNECTION *psConnection,
1085                                                                                          IMG_CONST IMG_CHAR *pszComment,
1086                                                                                          IMG_BOOL bContinuous);
1088 IMG_IMPORT
1089 PVRSRV_ERROR IMG_CALLCONV PVRSRVPDumpCommentf(IMG_CONST PVRSRV_CONNECTION *psConnection,
1090                                                                                           IMG_BOOL bContinuous,
1091                                                                                           IMG_CONST IMG_CHAR *pszFormat, ...)
1092 #if !defined(USE_CODE)
1093                                                                                           IMG_FORMAT_PRINTF(3, 4)
1094 #endif
1097 IMG_IMPORT
1098 PVRSRV_ERROR IMG_CALLCONV PVRSRVPDumpCommentWithFlagsf(IMG_CONST PVRSRV_CONNECTION *psConnection,
1099                                                                                                            IMG_UINT32 ui32Flags,
1100                                                                                                            IMG_CONST IMG_CHAR *pszFormat, ...)
1101 #if !defined(USE_CODE)
1102                                                                                                            IMG_FORMAT_PRINTF(3, 4)
1103 #endif
1106 IMG_IMPORT
1107 PVRSRV_ERROR IMG_CALLCONV PVRSRVPDumpDriverInfo(IMG_CONST PVRSRV_CONNECTION *psConnection,
1108                                                                                                 IMG_CHAR *pszString,
1109                                                                                                 IMG_BOOL bContinuous);
1111 IMG_IMPORT
1112 PVRSRV_ERROR IMG_CALLCONV PVRSRVPDumpIsCapturing(IMG_CONST PVRSRV_CONNECTION *psConnection,
1113                                                                                                 IMG_BOOL *pbIsCapturing);
1115 IMG_IMPORT
1116 PVRSRV_ERROR IMG_CALLCONV PVRSRVPDumpBitmap(IMG_CONST PVRSRV_DEV_DATA *psDevData,
1117                                                                                         IMG_CHAR *pszFileName,
1118                                                                                         IMG_UINT32 ui32FileOffset,
1119                                                                                         IMG_UINT32 ui32Width,
1120                                                                                         IMG_UINT32 ui32Height,
1121                                                                                         IMG_UINT32 ui32StrideInBytes,
1122                                                                                         IMG_DEV_VIRTADDR sDevBaseAddr,
1123                                                                                         IMG_HANDLE hDevMemContext,
1124                                                                                         IMG_UINT32 ui32Size,
1125                                                                                         PDUMP_PIXEL_FORMAT ePixelFormat,
1126                                                                                         PDUMP_MEM_FORMAT eMemFormat,
1127                                                                                         IMG_UINT32 ui32PDumpFlags);
1129 IMG_IMPORT
1130 PVRSRV_ERROR IMG_CALLCONV PVRSRVPDumpRegRead(IMG_CONST PVRSRV_DEV_DATA *psDevData,
1131                                                                                         IMG_CONST IMG_CHAR *pszRegRegion,
1132                                                                                         IMG_CONST IMG_CHAR *pszFileName,
1133                                                                                         IMG_UINT32 ui32FileOffset,
1134                                                                                         IMG_UINT32 ui32Address,
1135                                                                                         IMG_UINT32 ui32Size,
1136                                                                                         IMG_UINT32 ui32PDumpFlags);
1139 IMG_IMPORT
1140 IMG_BOOL IMG_CALLCONV PVRSRVPDumpIsCapturingTest(IMG_CONST PVRSRV_CONNECTION *psConnection);
1142 IMG_IMPORT
1143 PVRSRV_ERROR IMG_CALLCONV PVRSRVPDumpCycleCountRegRead(IMG_CONST PVRSRV_DEV_DATA *psDevData,
1144                                                                                                                 IMG_UINT32 ui32RegOffset,
1145                                                                                                                 IMG_BOOL bLastFrame);
1147 IMG_IMPORT IMG_HANDLE   PVRSRVLoadLibrary(const IMG_CHAR *pszLibraryName);
1148 IMG_IMPORT PVRSRV_ERROR PVRSRVUnloadLibrary(IMG_HANDLE hExtDrv);
1149 IMG_IMPORT PVRSRV_ERROR PVRSRVGetLibFuncAddr(IMG_HANDLE hExtDrv, const IMG_CHAR *pszFunctionName, IMG_VOID **ppvFuncAddr);
1151 IMG_IMPORT IMG_UINT32 PVRSRVClockus (void);
1152 IMG_IMPORT IMG_VOID PVRSRVWaitus (IMG_UINT32 ui32Timeus);
1153 IMG_IMPORT IMG_VOID PVRSRVReleaseThreadQuanta (void);
1154 IMG_IMPORT IMG_UINT32 IMG_CALLCONV PVRSRVGetCurrentProcessID(void);
1155 IMG_IMPORT IMG_CHAR * IMG_CALLCONV PVRSRVSetLocale(const IMG_CHAR *pszLocale);
1161 IMG_IMPORT IMG_VOID IMG_CALLCONV PVRSRVCreateAppHintState(IMG_MODULE_ID eModuleID,
1162                                                                                                                 const IMG_CHAR *pszAppName,
1163                                                                                                                 IMG_VOID **ppvState);
1164 IMG_IMPORT IMG_VOID IMG_CALLCONV PVRSRVFreeAppHintState(IMG_MODULE_ID eModuleID,
1165                                                                                  IMG_VOID *pvHintState);
1167 IMG_IMPORT IMG_BOOL IMG_CALLCONV PVRSRVGetAppHint(IMG_VOID                      *pvHintState,
1168                                                                                                   const IMG_CHAR        *pszHintName,
1169                                                                                                   IMG_DATA_TYPE         eDataType,
1170                                                                                                   const IMG_VOID        *pvDefault,
1171                                                                                                   IMG_VOID                      *pvReturn);
1173 /******************************************************************************
1174  * Memory API(s)
1175  *****************************************************************************/
1177 /* Exported APIs */
1178 IMG_IMPORT IMG_PVOID IMG_CALLCONV PVRSRVAllocUserModeMem (IMG_SIZE_T uiSize);
1179 IMG_IMPORT IMG_PVOID IMG_CALLCONV PVRSRVCallocUserModeMem (IMG_SIZE_T uiSize);
1180 IMG_IMPORT IMG_PVOID IMG_CALLCONV PVRSRVReallocUserModeMem (IMG_PVOID pvBase, IMG_SIZE_T uiNewSize);
1181 IMG_IMPORT IMG_VOID  IMG_CALLCONV PVRSRVFreeUserModeMem (IMG_PVOID pvMem);
1182 IMG_IMPORT IMG_VOID PVRSRVMemCopy(IMG_VOID *pvDst, const IMG_VOID *pvSrc, IMG_SIZE_T uiSize);
1183 IMG_IMPORT IMG_VOID PVRSRVMemSet(IMG_VOID *pvDest, IMG_UINT8 ui8Value, IMG_SIZE_T uiSize);
1185 struct _PVRSRV_MUTEX_OPAQUE_STRUCT_;
1186 typedef struct  _PVRSRV_MUTEX_OPAQUE_STRUCT_ *PVRSRV_MUTEX_HANDLE;
1189 #if defined(PVR_DEBUG_MUTEXES)
1191 IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVCreateMutex(PVRSRV_MUTEX_HANDLE *phMutex,
1192                                                                                                            IMG_CHAR pszMutexName[],
1193                                                                                                            IMG_CHAR pszFilename[],
1194                                                                                                            IMG_INT iLine);
1195 IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVDestroyMutex(PVRSRV_MUTEX_HANDLE hMutex,
1196                                                                                                                 IMG_CHAR pszMutexName[],
1197                                                                                                                 IMG_CHAR pszFilename[],
1198                                                                                                                 IMG_INT iLine);
1199 IMG_IMPORT IMG_VOID IMG_CALLCONV PVRSRVLockMutex(PVRSRV_MUTEX_HANDLE hMutex,
1200                                                                                                  IMG_CHAR pszMutexName[],
1201                                                                                                  IMG_CHAR pszFilename[],
1202                                                                                                  IMG_INT iLine);
1203 IMG_IMPORT IMG_VOID IMG_CALLCONV PVRSRVUnlockMutex(PVRSRV_MUTEX_HANDLE hMutex,
1204                                                                                                    IMG_CHAR pszMutexName[],
1205                                                                                                    IMG_CHAR pszFilename[],
1206                                                                                                    IMG_INT iLine);
1208 #define PVRSRVCreateMutex(phMutex) PVRSRVCreateMutex(phMutex, #phMutex, __FILE__, __LINE__)
1209 #define PVRSRVDestroyMutex(hMutex) PVRSRVDestroyMutex(hMutex, #hMutex, __FILE__, __LINE__)
1210 #define PVRSRVLockMutex(hMutex) PVRSRVLockMutex(hMutex, #hMutex, __FILE__, __LINE__)
1211 #define PVRSRVUnlockMutex(hMutex) PVRSRVUnlockMutex(hMutex, #hMutex, __FILE__, __LINE__)
1213 #else /* defined(PVR_DEBUG_MUTEXES) */
1215 IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVCreateMutex(PVRSRV_MUTEX_HANDLE *phMutex);
1216 IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVDestroyMutex(PVRSRV_MUTEX_HANDLE hMutex);
1217 IMG_IMPORT IMG_VOID IMG_CALLCONV PVRSRVLockMutex(PVRSRV_MUTEX_HANDLE hMutex);
1218 IMG_IMPORT IMG_VOID IMG_CALLCONV PVRSRVUnlockMutex(PVRSRV_MUTEX_HANDLE hMutex);
1220 #endif /* defined(PVR_DEBUG_MUTEXES) */
1223 struct _PVRSRV_RECMUTEX_OPAQUE_STRUCT_;
1224 typedef struct  _PVRSRV_RECMUTEX_OPAQUE_STRUCT_ *PVRSRV_RECMUTEX_HANDLE;
1227 #if defined(PVR_DEBUG_MUTEXES)
1229 IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVCreateRecursiveMutex(PVRSRV_RECMUTEX_HANDLE *phMutex,
1230                                                                                                            IMG_CHAR pszMutexName[],
1231                                                                                                            IMG_CHAR pszFilename[],
1232                                                                                                            IMG_INT iLine);
1233 IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVDestroyRecursiveMutex(PVRSRV_RECMUTEX_HANDLE hMutex,
1234                                                                                                                 IMG_CHAR pszMutexName[],
1235                                                                                                                 IMG_CHAR pszFilename[],
1236                                                                                                                 IMG_INT iLine);
1237 IMG_IMPORT IMG_VOID IMG_CALLCONV PVRSRVLockRecursiveMutex(PVRSRV_RECMUTEX_HANDLE hMutex,
1238                                                                                                  IMG_CHAR pszMutexName[],
1239                                                                                                  IMG_CHAR pszFilename[],
1240                                                                                                  IMG_INT iLine);
1241 IMG_IMPORT IMG_VOID IMG_CALLCONV PVRSRVUnlockRecursiveMutex(PVRSRV_RECMUTEX_HANDLE hMutex,
1242                                                                                                    IMG_CHAR pszMutexName[],
1243                                                                                                    IMG_CHAR pszFilename[],
1244                                                                                                    IMG_INT iLine);
1246 #define PVRSRVCreateRecursiveMutex(phMutex) PVRSRVCreateRecursiveMutex(phMutex, #phMutex, __FILE__, __LINE__)
1247 #define PVRSRVDestroyRecursiveMutex(hMutex) PVRSRVDestroyRecursiveMutex(hMutex, #hMutex, __FILE__, __LINE__)
1248 #define PVRSRVLockRecursiveMutex(hMutex) PVRSRVLockRecursiveMutex(hMutex, #hMutex, __FILE__, __LINE__)
1249 #define PVRSRVUnlockRecursiveMutex(hMutex) PVRSRVUnlockRecursiveMutex(hMutex, #hMutex, __FILE__, __LINE__)
1251 #else /* defined(PVR_DEBUG_MUTEXES) */
1253 IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVCreateRecursiveMutex(PVRSRV_RECMUTEX_HANDLE *phMutex);
1254 IMG_IMPORT PVRSRV_ERROR IMG_CALLCONV PVRSRVDestroyRecursiveMutex(PVRSRV_RECMUTEX_HANDLE hMutex);
1255 IMG_IMPORT IMG_VOID IMG_CALLCONV PVRSRVLockRecursiveMutex(PVRSRV_RECMUTEX_HANDLE hMutex);
1256 IMG_IMPORT IMG_VOID IMG_CALLCONV PVRSRVUnlockRecursiveMutex(PVRSRV_RECMUTEX_HANDLE hMutex);
1258 #endif /* defined(PVR_DEBUG_MUTEXES) */
1260 /* Non-recursive coarse-grained mutex shared between all threads in a proccess */
1261 IMG_IMPORT IMG_VOID IMG_CALLCONV PVRSRVLockProcessGlobalMutex(void);
1262 IMG_IMPORT IMG_VOID IMG_CALLCONV PVRSRVUnlockProcessGlobalMutex(void);
1265 struct _PVRSRV_SEMAPHORE_OPAQUE_STRUCT_;
1266 typedef struct  _PVRSRV_SEMAPHORE_OPAQUE_STRUCT_ *PVRSRV_SEMAPHORE_HANDLE;
1269         #define IMG_SEMAPHORE_WAIT_INFINITE       ((IMG_UINT64)0xFFFFFFFFFFFFFFFFull)
1272 #if !defined(USE_CODE)
1274 #ifdef INLINE_IS_PRAGMA
1275 #pragma inline(PVRSRVCreateSemaphore)
1276 #endif
1277 static INLINE PVRSRV_ERROR PVRSRVCreateSemaphore(PVRSRV_SEMAPHORE_HANDLE *phSemaphore, IMG_INT iInitialCount)
1279         PVR_UNREFERENCED_PARAMETER(iInitialCount);
1280         *phSemaphore = 0;
1281         return PVRSRV_OK;
1284 #ifdef INLINE_IS_PRAGMA
1285 #pragma inline(PVRSRVDestroySemaphore)
1286 #endif
1287 static INLINE PVRSRV_ERROR PVRSRVDestroySemaphore(PVRSRV_SEMAPHORE_HANDLE hSemaphore)
1289         PVR_UNREFERENCED_PARAMETER(hSemaphore);
1290         return PVRSRV_OK;
1293 #ifdef INLINE_IS_PRAGMA
1294 #pragma inline(PVRSRVWaitSemaphore)
1295 #endif
1296 static INLINE PVRSRV_ERROR PVRSRVWaitSemaphore(PVRSRV_SEMAPHORE_HANDLE hSemaphore, IMG_UINT64 ui64TimeoutMicroSeconds)
1298         PVR_UNREFERENCED_PARAMETER(hSemaphore);
1299         PVR_UNREFERENCED_PARAMETER(ui64TimeoutMicroSeconds);
1300         return PVRSRV_ERROR_INVALID_PARAMS;
1303 #ifdef INLINE_IS_PRAGMA
1304 #pragma inline(PVRSRVPostSemaphore)
1305 #endif
1306 static INLINE IMG_VOID PVRSRVPostSemaphore(PVRSRV_SEMAPHORE_HANDLE hSemaphore, IMG_INT iPostCount)
1308         PVR_UNREFERENCED_PARAMETER(hSemaphore);
1309         PVR_UNREFERENCED_PARAMETER(iPostCount);
1312 #endif /* !defined(USE_CODE) */
1315 /* Non-exported APIs */
1316 #if defined(DEBUG) && (defined(__linux__) || defined(__QNXNTO__) )
1317 IMG_IMPORT IMG_PVOID IMG_CALLCONV PVRSRVAllocUserModeMemTracking(IMG_SIZE_T ui32Size, IMG_CHAR *pszFileName, IMG_UINT32 ui32LineNumber);
1319 IMG_IMPORT IMG_PVOID IMG_CALLCONV PVRSRVCallocUserModeMemTracking(IMG_SIZE_T ui32Size, IMG_CHAR *pszFileName, IMG_UINT32 ui32LineNumber);
1321 IMG_IMPORT IMG_VOID  IMG_CALLCONV PVRSRVFreeUserModeMemTracking(IMG_VOID *pvMem);
1323 IMG_IMPORT IMG_PVOID IMG_CALLCONV PVRSRVReallocUserModeMemTracking(IMG_VOID *pvMem, IMG_SIZE_T ui32NewSize, 
1324                                                                                                           IMG_CHAR *pszFileName, IMG_UINT32 ui32LineNumber);
1325 #endif
1327 /******************************************************************************
1328  * PVR Event Object API(s)
1329  *****************************************************************************/
1331 IMG_IMPORT PVRSRV_ERROR PVRSRVEventObjectWait(const PVRSRV_CONNECTION *psConnection,
1332                                                                         IMG_HANDLE hOSEvent
1333         );
1335 /*!
1336  ******************************************************************************
1338  @Function              PVRSRVCreateSyncInfoModObj
1340  @Description   Creates an empty Modification object to be later used by PVRSRVModifyPendingSyncOps
1342  ******************************************************************************/
1343 IMG_IMPORT
1344 PVRSRV_ERROR IMG_CALLCONV PVRSRVCreateSyncInfoModObj(const PVRSRV_CONNECTION *psConnection,
1345                                                                                                          IMG_HANDLE *phKernelSyncInfoModObj
1346         );
1348 /*!
1349  ******************************************************************************
1351  @Function              PVRSRVDestroySyncInfoModObj
1353  @Description   Destroys a Modification object.  Must be empty.
1355  ******************************************************************************/
1356 IMG_IMPORT
1357 PVRSRV_ERROR IMG_CALLCONV PVRSRVDestroySyncInfoModObj(const PVRSRV_CONNECTION *psConnection,
1358                                                                                                           IMG_HANDLE hKernelSyncInfoModObj
1359         );
1363 /*!
1364  ******************************************************************************
1366  @Function              PVRSRVModifyPendingSyncOps
1368  @Description   Returns PRE-INCREMENTED sync op values. Performs thread safe increment
1369                                 of sync ops values as specified by ui32ModifyFlags.
1371                                 PVRSRV_ERROR_RETRY is returned if the supplied modification object
1372                 is not empty.  This is on the assumption that a different thread
1373                                 will imminently call PVRSRVModifyCompleteSyncOps.  This thread should
1374                                 sleep before retrying.  It should be regarded as an error if no such
1375                                 other thread exists.
1377                                 Note that this API has implied locking semantics, as follows:
1379                                 PVRSRVModifyPendingSyncOps() 
1380                                         -  announces an operation on the buffer is "pending", and 
1381                                                    conceptually takes a ticket to represent your place in the queue.
1382                                                 -  NB: ** exclusive access to the resource is  _NOT_ granted at this time **
1383                                 PVRSRVSyncOpsFlushToModObj()
1384                                         -  ensures you have exclusive access to the resource (conceptually, a LOCK)
1385                                                 -  the previously "pending" operation can now be regarded as "in progress"
1386                                 PVRSRVModifyCompleteSyncOps()
1387                                         -  declares that the previously "in progress" operation is now complete. (UNLOCK)
1388                                 
1390  ******************************************************************************/
1391 IMG_IMPORT
1392 PVRSRV_ERROR IMG_CALLCONV PVRSRVModifyPendingSyncOps(const PVRSRV_CONNECTION *psConnection,
1393                                                                                                           IMG_HANDLE hKernelSyncInfoModObj,
1394                                                                                                           PVRSRV_CLIENT_SYNC_INFO *psSyncInfo,
1395                                                                                                           IMG_UINT32 ui32ModifyFlags,
1396                                                                                                           IMG_UINT32 *pui32ReadOpsPending,
1397                                                                                                           IMG_UINT32 *pui32WriteOpsPending);
1399 /*!
1400  ******************************************************************************
1402  @Function              PVRSRVModifyCompleteSyncOps
1404  @Description   Performs thread safe increment of sync ops values as specified
1405                 by the ui32ModifyFlags that were given to PVRSRVModifyPendingSyncOps.
1406                                 The supplied Modification Object will become empty.
1408                                 Note that this API has implied locking semantics, as
1409                                 described above in PVRSRVModifyPendingSyncOps
1411  ******************************************************************************/
1412 IMG_IMPORT
1413 PVRSRV_ERROR IMG_CALLCONV PVRSRVModifyCompleteSyncOps(const PVRSRV_CONNECTION *psConnection,
1414                                                                                                           IMG_HANDLE hKernelSyncInfoModObj
1415         );
1417 /*!
1418  ******************************************************************************
1420  @Function      PVRSRVSyncOpsTakeToken
1422  @Description Takes a "deli-counter" style token for future use with
1423               PVRSRVSyncOpsFlushToToken().  In practice this means
1424               recording a snapshot of the current "pending" values.  A
1425               future PVRSRVSyncOpsFlushToToken() will ensure that all
1426               operations that were pending at the time of this
1427               PVRSRVSyncOpsTakeToken() call will be flushed.
1428               Operations may be subsequently queued after this call
1429               and would not be flushed.  The caller is required to
1430               provide storage for the token.  The token is disposable
1431               - i.e. the caller can simply let the token go out of
1432               scope without telling us... in particular, there is no
1433               obligation to call PVRSRVSyncOpsFlushToToken().
1434               Multiple tokens may be taken.  There is no implied
1435               locking with this API.
1437  ******************************************************************************/
1438 IMG_IMPORT
1439 PVRSRV_ERROR IMG_CALLCONV PVRSRVSyncOpsTakeToken(const PVRSRV_CONNECTION *psConnection,
1440                                                                                                  const PVRSRV_CLIENT_SYNC_INFO *psSyncInfo,
1441                                                                                                  PVRSRV_SYNC_TOKEN *psSyncToken);
1442 /*!
1443  ******************************************************************************
1445  @Function      PVRSRVSyncOpsFlushToToken
1447  @Description Tests whether the dependencies for a pending sync op modification
1448               have been satisfied.  If this function returns PVRSRV_OK, then the
1449               "complete" counts have caught up with the snapshot of the "pending"
1450               values taken when PVRSRVSyncOpsTakeToken() was called.
1451               In the event that the dependencies are not (yet) met,
1452                           this call will auto-retry if bWait is specified, otherwise, it will
1453                           return PVRSRV_ERROR_RETRY.  (Not really an "error")
1455                           (auto-retry behaviour not implemented)
1457  ******************************************************************************/
1458 IMG_IMPORT
1459 PVRSRV_ERROR IMG_CALLCONV PVRSRVSyncOpsFlushToToken(const PVRSRV_CONNECTION *psConnection,
1460                                                                                                         const PVRSRV_CLIENT_SYNC_INFO *psSyncInfo,
1461                                                                                                         const PVRSRV_SYNC_TOKEN *psSyncToken,
1462                                                                                                         IMG_BOOL bWait);
1463 /*!
1464  ******************************************************************************
1466  @Function      PVRSRVSyncOpsFlushToModObj
1468  @Description Tests whether the dependencies for a pending sync op modification
1469               have been satisfied.  If this function returns PVRSRV_OK, then the
1470               "complete" counts have caught up with the snapshot of the "pending"
1471               values taken when PVRSRVModifyPendingSyncOps() was called.
1472               PVRSRVModifyCompleteSyncOps() can then be called without risk of
1473                           stalling.  In the event that the dependencies are not (yet) met,
1474                           this call will auto-retry if bWait is specified, otherwise, it will
1475                           return PVRSRV_ERROR_RETRY.  (Not really an "error")
1477                           Note that this API has implied locking semantics, as
1478                           described above in PVRSRVModifyPendingSyncOps
1480  ******************************************************************************/
1481 IMG_IMPORT
1482 PVRSRV_ERROR IMG_CALLCONV PVRSRVSyncOpsFlushToModObj(const PVRSRV_CONNECTION *psConnection,
1483                                                                                                          IMG_HANDLE hKernelSyncInfoModObj,
1484                                                                                                          IMG_BOOL bWait);
1486 /*!
1487  ******************************************************************************
1489  @Function      PVRSRVSyncOpsFlushToDelta
1491  @Description Compares the number of outstanding operations (pending count minus
1492               complete count) with the limit specified.  If no more than ui32Delta
1493               operations are outstanding, this function returns PVRSRV_OK.
1494               In the event that there are too many outstanding operations,
1495                           this call will auto-retry if bWait is specified, otherwise, it will
1496                           return PVRSRV_ERROR_RETRY.  (Not really an "error")
1498  ******************************************************************************/
1499 IMG_IMPORT
1500 PVRSRV_ERROR IMG_CALLCONV PVRSRVSyncOpsFlushToDelta(const PVRSRV_CONNECTION *psConnection,
1501                                                                                                         PVRSRV_CLIENT_SYNC_INFO *psClientSyncInfo,
1502                                                                                                         IMG_UINT32 ui32Delta,
1503                                                                                                         IMG_BOOL bWait);
1505 /*!
1506  ******************************************************************************
1508  @Function      PVRSRVAllocSyncInfo
1510  @Description Creates a Sync Object.  Unlike the sync objects created
1511                           automatically with "PVRSRVAllocDeviceMem", the sync objects
1512                           returned by this function do _not_ have a UM mapping to the
1513                           sync data and they do _not_ have the device virtual address
1514                           of the "opscomplete" fields.  These data are to be deprecated.
1516  ******************************************************************************/
1518 IMG_IMPORT
1519 PVRSRV_ERROR IMG_CALLCONV PVRSRVAllocSyncInfo(IMG_CONST PVRSRV_DEV_DATA *psDevData,
1520                                                                                           PVRSRV_CLIENT_SYNC_INFO **ppsSyncInfo);
1522 /*!
1523  ******************************************************************************
1525  @Function      PVRSRVFreeSyncInfo
1527  @Description Destroys a Sync Object created via
1528               PVRSRVAllocSyncInfo.
1530  ******************************************************************************/
1532 IMG_IMPORT
1533 PVRSRV_ERROR IMG_CALLCONV PVRSRVFreeSyncInfo(IMG_CONST PVRSRV_DEV_DATA *psDevData,
1534                                                                                          PVRSRV_CLIENT_SYNC_INFO *psSyncInfo);
1536 /*!
1537  ******************************************************************************
1539  @Function              PVRSRVGetErrorString
1541  @Description   Returns a text string relating to the PVRSRV_ERROR enum.
1543  ******************************************************************************/
1544 IMG_IMPORT
1545 const IMG_CHAR *PVRSRVGetErrorString(PVRSRV_ERROR eError);
1548 /*!
1549  ******************************************************************************
1551  @Function              PVRSRVCacheInvalidate
1553  @Description   Invalidate the CPU cache for a specified memory
1554                 area. Note that PVRSRVGetMiscInfo provides similar cpu
1555                 cache flush/invalidate functionality for some platforms.
1557  ******************************************************************************/
1559 IMG_IMPORT
1560 PVRSRV_ERROR IMG_CALLCONV PVRSRVCacheInvalidate(const PVRSRV_CONNECTION *psConnection,
1561                                                 IMG_PVOID pvLinearAddress,
1562                                                     IMG_UINT32 ui32Size);
1564 /******************************************************************************
1565  Time wrapping macro
1566 ******************************************************************************/
1567 #define TIME_NOT_PASSED_UINT32(a,b,c)           (((a) - (b)) < (c))
1569 #if defined (__cplusplus)
1571 #endif
1572 #endif /* __SERVICES_H__ */
1574 /******************************************************************************
1575  End of file (services.h)
1576 ******************************************************************************/