1 /*************************************************************************/ /*!
3 @Title Host Trace Buffer server implementation.
4 @Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @Description Host Trace Buffer provides a mechanism to log Host events to a
6 buffer in a similar way to the Firmware Trace mechanism.
7 Host Trace Buffer logs data using a Transport Layer buffer.
8 The Transport Layer and pvrtld tool provides the mechanism to
9 retrieve the trace data.
10 @License Dual MIT/GPLv2
12 The contents of this file are subject to the MIT license as set out below.
14 Permission is hereby granted, free of charge, to any person obtaining a copy
15 of this software and associated documentation files (the "Software"), to deal
16 in the Software without restriction, including without limitation the rights
17 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18 copies of the Software, and to permit persons to whom the Software is
19 furnished to do so, subject to the following conditions:
21 The above copyright notice and this permission notice shall be included in
22 all copies or substantial portions of the Software.
24 Alternatively, the contents of this file may be used under the terms of
25 the GNU General Public License Version 2 ("GPL") in which case the provisions
26 of GPL are applicable instead of those above.
28 If you wish to allow use of your version of this file only under the terms of
29 GPL, and not to allow others to use your version of this file under the terms
30 of the MIT license, indicate your decision by deleting the provisions above
31 and replace them with the notice and other provisions required by GPL as set
32 out in the file called "GPL-COPYING" included in this distribution. If you do
33 not delete the provisions above, a recipient may use your version of this file
34 under the terms of either the MIT license or GPL.
36 This License is also included in this distribution in the file called
39 EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
40 PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
41 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
42 PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
43 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
44 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
45 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
46 */ /**************************************************************************/
48 #include "htbserver.h"
50 #include "htbuffer_types.h"
52 #include "pvrsrv_tlcommon.h"
53 #include "img_types.h"
54 #include "pvrsrv_error.h"
57 #include "pvr_notifier.h"
59 #include "pvrsrv_apphint.h"
61 /* size of circular buffer controlling the maximum number of concurrent PIDs logged */
62 #define HTB_MAX_NUM_PID 8
64 /* number of times to try rewriting a log entry */
65 #define HTB_LOG_RETRY_COUNT 5
67 /*************************************************************************/ /*!
68 Host Trace Buffer control information structure
69 */ /**************************************************************************/
72 IMG_CHAR *pszBufferName; /*!< Name to use for the trace buffer,
73 this will be required to request
75 Once set this may not be changed */
77 IMG_UINT32 ui32BufferSize; /*!< Requested buffer size in bytes
78 Once set this may not be changed */
80 HTB_OPMODE_CTRL eOpMode; /*!< Control what trace data is dropped if
82 Once set this may not be changed */
84 /* IMG_UINT32 ui32GroupEnable; */ /*!< Flags word controlling groups to be
87 IMG_UINT32 ui32LogLevel; /*!< Log level to control messages logged */
89 IMG_UINT32 aui32EnablePID[HTB_MAX_NUM_PID]; /*!< PIDs to enable logging for
90 a specific set of processes */
92 IMG_UINT32 ui32PIDCount; /*!< Current number of PIDs being logged */
94 IMG_UINT32 ui32PIDHead; /*!< Head of the PID circular buffer */
96 HTB_LOGMODE_CTRL eLogMode; /*!< Logging mode control */
98 IMG_BOOL bLogDropSignalled; /*!< Flag indicating if a log message has
99 been signalled as dropped */
101 /* synchronisation parameters */
102 IMG_UINT64 ui64SyncOSTS;
103 IMG_UINT64 ui64SyncCRTS;
104 IMG_UINT32 ui32SyncCalcClkSpd;
105 IMG_UINT32 ui32SyncMarker;
110 /*************************************************************************/ /*!
111 */ /**************************************************************************/
112 static const IMG_UINT32 MapFlags[] =
114 0, /* HTB_OPMODE_UNDEF = 0 */
115 TL_FLAG_RESERVE_DROP_NEWER, /* HTB_OPMODE_DROPLATEST */
116 0, /* HTB_OPMODE_DROPOLDEST */
117 TL_FLAG_RESERVE_BLOCK /* HTB_OPMODE_BLOCK */
120 static_assert(0 == HTB_OPMODE_UNDEF, "Unexpected value for HTB_OPMODE_UNDEF");
121 static_assert(1 == HTB_OPMODE_DROPLATEST, "Unexpected value for HTB_OPMODE_DROPLATEST");
122 static_assert(2 == HTB_OPMODE_DROPOLDEST, "Unexpected value for HTB_OPMODE_DROPOLDEST");
123 static_assert(3 == HTB_OPMODE_BLOCK, "Unexpected value for HTB_OPMODE_BLOCK");
125 static const IMG_UINT32 g_ui32TLBaseFlags = 0; //TL_FLAG_NO_SIGNAL_ON_COMMIT
127 /* Minimum TL buffer size,
128 * large enough for around 60 worst case messages or 200 average messages
130 #define HTB_TL_BUFFER_SIZE_MIN (0x10000)
133 static HTB_CTRL_INFO g_sCtrl = {0};
134 static IMG_BOOL g_bConfigured = IMG_FALSE;
135 static IMG_HANDLE g_hTLStream = NULL;
138 /************************************************************************/ /*!
139 @Function _LookupFlags
140 @Description Convert HTBuffer Operation mode to TLStream flags
142 @Input eModeHTBuffer Operation Mode
144 @Return IMG_UINT32 TLStream FLags
145 */ /**************************************************************************/
147 _LookupFlags( HTB_OPMODE_CTRL eMode )
149 return (eMode < (sizeof(MapFlags)/sizeof(MapFlags[0])))? MapFlags[eMode]: 0;
153 /************************************************************************/ /*!
154 @Function _HTBLogDebugInfo
155 @Description Debug dump handler used to dump the state of the HTB module.
156 Called for each verbosity level during a debug dump. Function
157 only prints state when called for High verbosity.
159 @Input hDebugRequestHandle See PFN_DBGREQ_NOTIFY
161 @Input ui32VerbLevel See PFN_DBGREQ_NOTIFY
163 @Input pfnDumpDebugPrintf See PFN_DBGREQ_NOTIFY
165 @Input pvDumpDebugFile See PFN_DBGREQ_NOTIFY
167 */ /**************************************************************************/
168 static void _HTBLogDebugInfo(
169 PVRSRV_DBGREQ_HANDLE hDebugRequestHandle,
170 IMG_UINT32 ui32VerbLevel,
171 DUMPDEBUG_PRINTF_FUNC *pfnDumpDebugPrintf,
172 void *pvDumpDebugFile
175 PVR_UNREFERENCED_PARAMETER(hDebugRequestHandle);
177 if (ui32VerbLevel == DEBUG_REQUEST_VERBOSITY_HIGH)
184 PVR_DUMPDEBUG_LOG("------[ HTB Log state: On ]------");
186 PVR_DUMPDEBUG_LOG("HTB Log mode: %d", g_sCtrl.eLogMode);
187 PVR_DUMPDEBUG_LOG("HTB Log level: %d", g_sCtrl.ui32LogLevel);
188 PVR_DUMPDEBUG_LOG("HTB Buffer Opmode: %d", g_sCtrl.eOpMode);
190 for (i=0; i < HTB_FLAG_NUM_EL; i++)
192 PVR_DUMPDEBUG_LOG("HTB Log group %d: %x", i, g_auiHTBGroupEnable[i]);
197 PVR_DUMPDEBUG_LOG("------[ HTB Log state: Off ]------");
202 /************************************************************************/ /*!
203 @Function HTBDeviceCreate
204 @Description Initialisation actions for HTB at device creation.
206 @Input psDeviceNode Reference to the device node in context
208 @Return eError Internal services call returned eError error
210 */ /**************************************************************************/
213 PVRSRV_DEVICE_NODE *psDeviceNode
216 PVRSRV_ERROR eError = PVRSRV_OK;
218 eError = PVRSRVRegisterDbgRequestNotify(&psDeviceNode->hHtbDbgReqNotify,
219 psDeviceNode, &_HTBLogDebugInfo, DEBUG_REQUEST_HTB, NULL);
220 PVR_LOG_IF_ERROR(eError, "PVRSRVRegisterDbgRequestNotify");
225 /************************************************************************/ /*!
226 @Function HTBIDeviceDestroy
227 @Description De-initialisation actions for HTB at device destruction.
229 @Input psDeviceNode Reference to the device node in context
231 */ /**************************************************************************/
234 PVRSRV_DEVICE_NODE *psDeviceNode
237 if (psDeviceNode->hHtbDbgReqNotify)
239 /* No much we can do if it fails, driver unloading */
240 (void)PVRSRVUnregisterDbgRequestNotify(psDeviceNode->hHtbDbgReqNotify);
241 psDeviceNode->hHtbDbgReqNotify = NULL;
246 /************************************************************************/ /*!
248 @Description Close the Host Trace Buffer and free all resources. Must
249 perform a no-op if already de-initialised.
251 @Return eError Internal services call returned eError error
253 */ /**************************************************************************/
259 TLStreamClose( g_hTLStream );
263 if (g_sCtrl.pszBufferName)
265 OSFreeMem( g_sCtrl.pszBufferName );
266 g_sCtrl.pszBufferName = NULL;
273 /*************************************************************************/ /*!
274 AppHint interface functions
275 */ /**************************************************************************/
277 PVRSRV_ERROR _HTBSetLogGroup(const PVRSRV_DEVICE_NODE *psDeviceNode,
278 const void *psPrivate,
279 IMG_UINT32 ui32Value)
281 PVR_UNREFERENCED_PARAMETER(psDeviceNode);
282 PVR_UNREFERENCED_PARAMETER(psPrivate);
284 return HTBControlKM(1, &ui32Value, 0, 0,
285 HTB_LOGMODE_UNDEF, HTB_OPMODE_UNDEF);
289 PVRSRV_ERROR _HTBReadLogGroup(const PVRSRV_DEVICE_NODE *psDeviceNode,
290 const void *psPrivate,
291 IMG_UINT32 *pui32Value)
293 PVR_UNREFERENCED_PARAMETER(psDeviceNode);
294 PVR_UNREFERENCED_PARAMETER(psPrivate);
296 *pui32Value = g_auiHTBGroupEnable[0];
301 PVRSRV_ERROR _HTBSetOpMode(const PVRSRV_DEVICE_NODE *psDeviceNode,
302 const void *psPrivate,
303 IMG_UINT32 ui32Value)
305 PVR_UNREFERENCED_PARAMETER(psDeviceNode);
306 PVR_UNREFERENCED_PARAMETER(psPrivate);
308 return HTBControlKM(0, NULL, 0, 0, HTB_LOGMODE_UNDEF, ui32Value);
312 PVRSRV_ERROR _HTBReadOpMode(const PVRSRV_DEVICE_NODE *psDeviceNode,
313 const void *psPrivate,
314 IMG_UINT32 *pui32Value)
316 PVR_UNREFERENCED_PARAMETER(psDeviceNode);
317 PVR_UNREFERENCED_PARAMETER(psPrivate);
319 *pui32Value = (IMG_UINT32)g_sCtrl.eOpMode;
323 /*************************************************************************/ /*!
324 @Function HTBConfigureKM
325 @Description Configure or update the configuration of the Host Trace Buffer
327 @Input ui32NameSize Size of the pszName string
329 @Input pszName Name to use for the underlying data buffer
331 @Input ui32BufferSize Size of the underlying data buffer
333 @Return eError Internal services call returned eError error
335 */ /**************************************************************************/
338 IMG_UINT32 ui32NameSize,
339 const IMG_CHAR * pszName,
340 const IMG_UINT32 ui32BufferSize
343 if ( !g_sCtrl.pszBufferName )
345 g_sCtrl.ui32BufferSize = (ui32BufferSize < HTB_TL_BUFFER_SIZE_MIN)? HTB_TL_BUFFER_SIZE_MIN: ui32BufferSize;
346 ui32NameSize = (ui32NameSize > PRVSRVTL_MAX_STREAM_NAME_SIZE)? PRVSRVTL_MAX_STREAM_NAME_SIZE: ui32NameSize;
347 g_sCtrl.pszBufferName = OSAllocMem(ui32NameSize * sizeof(IMG_CHAR));
348 OSStringNCopy(g_sCtrl.pszBufferName, pszName, ui32NameSize);
349 g_sCtrl.pszBufferName[ui32NameSize-1] = 0;
351 /* initialise rest of state */
352 g_sCtrl.eOpMode = HTB_OPMODE_DROPLATEST;
353 g_sCtrl.ui32LogLevel = 0;
354 g_sCtrl.ui32PIDCount = 0;
355 g_sCtrl.ui32PIDHead = 0;
356 g_sCtrl.eLogMode = HTB_LOGMODE_ALLPID;
357 g_sCtrl.bLogDropSignalled = IMG_FALSE;
359 PVRSRVAppHintRegisterHandlersUINT32(APPHINT_ID_EnableHTBLogGroup,
364 PVRSRVAppHintRegisterHandlersUINT32(APPHINT_ID_HTBOperationMode,
372 PVR_DPF((PVR_DBG_ERROR, "HTBConfigureKM: Reconfiguration is not supported\n"));
380 _OnTLReaderOpenCallback( void *pvArg )
385 IMG_UINT32 ui32Time = OSClockus();
386 eError = HTBLog(0, 0, ui32Time, HTB_SF_CTRL_FWSYNC_SCALE,
387 ((IMG_UINT32)((g_sCtrl.ui64SyncOSTS>>32)&0xffffffff)),
388 ((IMG_UINT32)(g_sCtrl.ui64SyncOSTS&0xffffffff)),
389 ((IMG_UINT32)((g_sCtrl.ui64SyncCRTS>>32)&0xffffffff)),
390 ((IMG_UINT32)(g_sCtrl.ui64SyncCRTS&0xffffffff)),
391 g_sCtrl.ui32SyncCalcClkSpd);
394 PVR_UNREFERENCED_PARAMETER(pvArg);
398 /*************************************************************************/ /*!
399 @Function HTBControlKM
400 @Description Update the configuration of the Host Trace Buffer
402 @Input ui32NumFlagGroups Number of group enable flags words
404 @Input aui32GroupEnable Flags words controlling groups to be logged
406 @Input ui32LogLevel Log level to record
408 @Input ui32EnablePID PID to enable logging for a specific process
410 @Input eLogMode Enable logging for all or specific processes,
412 @Input eOpMode Control the behaviour of the data buffer
414 @Return eError Internal services call returned eError error
416 */ /**************************************************************************/
419 const IMG_UINT32 ui32NumFlagGroups,
420 const IMG_UINT32 * aui32GroupEnable,
421 const IMG_UINT32 ui32LogLevel,
422 const IMG_UINT32 ui32EnablePID,
423 const HTB_LOGMODE_CTRL eLogMode,
424 const HTB_OPMODE_CTRL eOpMode
427 PVRSRV_ERROR eError = PVRSRV_OK;
428 IMG_UINT32 ui32RetryCount = HTB_LOG_RETRY_COUNT;
430 IMG_UINT32 ui32Time = OSClockus();
432 if ( !g_bConfigured && g_sCtrl.pszBufferName && ui32NumFlagGroups )
434 eError = TLStreamCreate(
436 g_sCtrl.pszBufferName,
437 g_sCtrl.ui32BufferSize,
438 _LookupFlags(HTB_OPMODE_DROPLATEST) | g_ui32TLBaseFlags,
439 _OnTLReaderOpenCallback, NULL, NULL, NULL );
440 PVR_LOGR_IF_ERROR( eError, "TLStreamCreate");
441 g_bConfigured = IMG_TRUE;
444 if ( HTB_OPMODE_UNDEF != eOpMode && g_sCtrl.eOpMode != eOpMode)
446 g_sCtrl.eOpMode = eOpMode;
447 eError = TLStreamReconfigure(g_hTLStream, _LookupFlags(g_sCtrl.eOpMode | g_ui32TLBaseFlags));
448 while ( PVRSRV_ERROR_NOT_READY == eError && ui32RetryCount-- )
450 OSReleaseThreadQuanta();
451 eError = TLStreamReconfigure(g_hTLStream, _LookupFlags(g_sCtrl.eOpMode | g_ui32TLBaseFlags));
453 PVR_LOGR_IF_ERROR( eError, "TLStreamReconfigure");
458 g_sCtrl.aui32EnablePID[g_sCtrl.ui32PIDHead] = ui32EnablePID;
459 g_sCtrl.ui32PIDHead++;
460 g_sCtrl.ui32PIDHead %= HTB_MAX_NUM_PID;
461 g_sCtrl.ui32PIDCount++;
462 if ( g_sCtrl.ui32PIDCount > HTB_MAX_NUM_PID )
464 g_sCtrl.ui32PIDCount = HTB_MAX_NUM_PID;
468 /* HTB_LOGMODE_ALLPID overrides ui32EnablePID */
469 if ( HTB_LOGMODE_ALLPID == eLogMode )
471 OSCachedMemSet(g_sCtrl.aui32EnablePID, 0, sizeof(g_sCtrl.aui32EnablePID));
472 g_sCtrl.ui32PIDCount = 0;
473 g_sCtrl.ui32PIDHead = 0;
475 if ( HTB_LOGMODE_UNDEF != eLogMode )
477 g_sCtrl.eLogMode = eLogMode;
480 if ( ui32NumFlagGroups )
482 for (i = 0; i < HTB_FLAG_NUM_EL && i < ui32NumFlagGroups; i++)
484 g_auiHTBGroupEnable[i] = aui32GroupEnable[i];
486 for (; i < HTB_FLAG_NUM_EL; i++)
488 g_auiHTBGroupEnable[i] = 0;
494 g_sCtrl.ui32LogLevel = ui32LogLevel;
497 /* Dump the current configuration state */
498 eError = HTBLog(0, 0, ui32Time, HTB_SF_CTRL_OPMODE, g_sCtrl.eOpMode);
499 PVR_LOG_IF_ERROR( eError, "HTBLog");
500 eError = HTBLog(0, 0, ui32Time, HTB_SF_CTRL_ENABLE_GROUP, g_auiHTBGroupEnable[0]);
501 PVR_LOG_IF_ERROR( eError, "HTBLog");
502 eError = HTBLog(0, 0, ui32Time, HTB_SF_CTRL_LOG_LEVEL, g_sCtrl.ui32LogLevel);
503 PVR_LOG_IF_ERROR( eError, "HTBLog");
504 eError = HTBLog(0, 0, ui32Time, HTB_SF_CTRL_LOGMODE, g_sCtrl.eLogMode);
505 PVR_LOG_IF_ERROR( eError, "HTBLog");
506 for (i = 0; i < g_sCtrl.ui32PIDCount; i++)
508 eError = HTBLog(0, 0, ui32Time, HTB_SF_CTRL_ENABLE_PID, g_sCtrl.aui32EnablePID[i]);
509 PVR_LOG_IF_ERROR( eError, "HTBLog");
512 if (0 != g_sCtrl.ui32SyncMarker && 0 != g_sCtrl.ui32SyncCalcClkSpd)
514 eError = HTBLog(0, 0, ui32Time, HTB_SF_CTRL_FWSYNC_MARK_RPT,
515 g_sCtrl.ui32SyncMarker);
516 PVR_LOG_IF_ERROR( eError, "HTBLog");
517 eError = HTBLog(0, 0, ui32Time, HTB_SF_CTRL_FWSYNC_SCALE_RPT,
518 ((IMG_UINT32)((g_sCtrl.ui64SyncOSTS>>32)&0xffffffff)), ((IMG_UINT32)(g_sCtrl.ui64SyncOSTS&0xffffffff)),
519 ((IMG_UINT32)((g_sCtrl.ui64SyncCRTS>>32)&0xffffffff)), ((IMG_UINT32)(g_sCtrl.ui64SyncCRTS&0xffffffff)),
520 g_sCtrl.ui32SyncCalcClkSpd);
521 PVR_LOG_IF_ERROR( eError, "HTBLog");
527 /*************************************************************************/ /*!
528 */ /**************************************************************************/
530 _ValidPID( IMG_UINT32 PID )
534 for (i = 0; i < g_sCtrl.ui32PIDCount; i++)
536 if ( g_sCtrl.aui32EnablePID[i] == PID )
545 /*************************************************************************/ /*!
546 @Function HTBSyncPartitionMarker
547 @Description Write an HTB sync partition marker to the HTB log
549 @Input ui33Marker Marker value
551 */ /**************************************************************************/
553 HTBSyncPartitionMarker(
554 const IMG_UINT32 ui32Marker
557 g_sCtrl.ui32SyncMarker = ui32Marker;
561 IMG_UINT32 ui32Time = OSClockus();
562 eError = HTBLog(0, 0, ui32Time, HTB_SF_CTRL_FWSYNC_MARK, ui32Marker);
563 if (PVRSRV_OK != eError)
565 PVR_DPF((PVR_DBG_WARNING, "%s() failed (%s) in %s()", "HTBLog", PVRSRVGETERRORSTRING(eError), __func__));
567 if (0 != g_sCtrl.ui32SyncCalcClkSpd)
569 eError = HTBLog(0, 0, ui32Time, HTB_SF_CTRL_FWSYNC_SCALE,
570 ((IMG_UINT32)((g_sCtrl.ui64SyncOSTS>>32)&0xffffffff)), ((IMG_UINT32)(g_sCtrl.ui64SyncOSTS&0xffffffff)),
571 ((IMG_UINT32)((g_sCtrl.ui64SyncCRTS>>32)&0xffffffff)), ((IMG_UINT32)(g_sCtrl.ui64SyncCRTS&0xffffffff)),
572 g_sCtrl.ui32SyncCalcClkSpd);
573 if (PVRSRV_OK != eError)
575 PVR_DPF((PVR_DBG_WARNING, "%s() failed (%s) in %s()", "HTBLog", PVRSRVGETERRORSTRING(eError), __func__));
582 /*************************************************************************/ /*!
583 @Function HTBSyncScale
584 @Description Write FW-Host synchronisation data to the HTB log when clocks
585 change or are re-calibrated
587 @Input bLogValues IMG_TRUE if value should be immediately written
590 @Input ui32OSTS OS Timestamp
592 @Input ui32CRTS Rogue timestamp
594 @Input ui32CalcClkSpd Calculated clock speed
596 */ /**************************************************************************/
599 const IMG_BOOL bLogValues,
600 const IMG_UINT64 ui64OSTS,
601 const IMG_UINT64 ui64CRTS,
602 const IMG_UINT32 ui32CalcClkSpd
605 g_sCtrl.ui64SyncOSTS = ui64OSTS;
606 g_sCtrl.ui64SyncCRTS = ui64CRTS;
607 g_sCtrl.ui32SyncCalcClkSpd = ui32CalcClkSpd;
608 if ( g_hTLStream && bLogValues)
611 IMG_UINT32 ui32Time = OSClockus();
612 eError = HTBLog(0, 0, ui32Time, HTB_SF_CTRL_FWSYNC_SCALE,
613 ((IMG_UINT32)((ui64OSTS>>32)&0xffffffff)), ((IMG_UINT32)(ui64OSTS&0xffffffff)),
614 ((IMG_UINT32)((ui64CRTS>>32)&0xffffffff)), ((IMG_UINT32)(ui64CRTS&0xffffffff)),
616 PVR_DPF((PVR_DBG_WARNING, "%s() failed (%s) in %s()", "HTBLog", PVRSRVGETERRORSTRING(eError), __func__));
621 /*************************************************************************/ /*!
623 @Description Record a Host Trace Buffer log event
625 @Input PID The PID of the process the event is associated
626 with. This is provided as an argument rather
627 than querying internally so that events associated
628 with a particular process, but performed by
629 another can be logged correctly.
631 @Input ui32TimeStamp The timestamp to be associated with this log event
633 @Input SF The log event ID
635 @Input ... Log parameters
637 @Return PVRSRV_OK Success.
639 */ /**************************************************************************/
643 IMG_UINT32 ui32TimeStamp,
645 IMG_UINT32 ui32NumArgs,
646 IMG_UINT32 * aui32Args
649 /* format of messages is: SF:PID:TIME:[PARn]*
650 * 32-bit timestamp (us) gives about 1h before looping
651 * Buffer allocated on the stack so don't need a semaphore to guard it
653 IMG_UINT32 aui32MessageBuffer[HTB_LOG_HEADER_SIZE+HTB_LOG_MAX_PARAMS];
655 PVRSRV_ERROR eError = PVRSRV_ERROR_NOT_ENABLED;
656 IMG_UINT32 ui32RetryCount = HTB_LOG_RETRY_COUNT;
657 IMG_UINT32 * pui32Message = aui32MessageBuffer;
658 IMG_UINT32 ui32MessageSize = 4 * (HTB_LOG_HEADER_SIZE+ui32NumArgs);
661 && ( 0 == PID || ~0 == PID || HTB_LOGMODE_ALLPID == g_sCtrl.eLogMode || _ValidPID(PID) )
662 /* && ( g_sCtrl.ui32GroupEnable & (0x1 << HTB_SF_GID(SF)) ) */
663 /* && ( g_sCtrl.ui32LogLevel >= HTB_SF_LVL(SF) ) */
666 *pui32Message++ = SF;
667 *pui32Message++ = PID;
668 *pui32Message++ = ui32TimeStamp;
669 while ( ui32NumArgs )
672 pui32Message[ui32NumArgs] = aui32Args[ui32NumArgs];
675 eError = TLStreamWrite( g_hTLStream, (IMG_UINT8*)aui32MessageBuffer, ui32MessageSize );
676 while ( PVRSRV_ERROR_NOT_READY == eError && ui32RetryCount-- )
678 OSReleaseThreadQuanta();
679 eError = TLStreamWrite( g_hTLStream, (IMG_UINT8*)aui32MessageBuffer, ui32MessageSize );
682 if ( PVRSRV_OK == eError )
684 g_sCtrl.bLogDropSignalled = IMG_FALSE;
686 else if ( PVRSRV_ERROR_STREAM_RESERVE_TOO_BIG != eError || !g_sCtrl.bLogDropSignalled )
688 PVR_DPF((PVR_DBG_WARNING, "%s() failed (%s) in %s()", "TLStreamWrite", PVRSRVGETERRORSTRING(eError), __func__));
690 if ( PVRSRV_ERROR_STREAM_RESERVE_TOO_BIG == eError )
692 g_sCtrl.bLogDropSignalled = IMG_TRUE;