This repository has been archived on 2025-06-06. You can view files and clone it, but cannot push or open issues or pull requests.
Files
android-g900/Start_WM/test6/inc/GFDiag.h
2010-10-16 00:02:07 +06:00

443 lines
14 KiB
C
Executable File

/* Copyright (c) 2006 NVIDIA Corporation. All rights reserved.
*
* NVIDIA Corporation and its licensors retain all intellectual property
* and proprietary rights in and to this software, related documentation
* and any modifications thereto. Any use, reproduction, disclosure or
* distribution of this software and related documentation without an
* express license agreement from NVIDIA Corporation is strictly prohibited.
*/
/**
* @file GFDiag.h
* @brief GFSDK module for diagnostics
* GFDiag is a testing framework which includes functionality
* for running sets of different tests and is mostly for internal
* use.
*
* Apps should use the GF_DIAG_* macros to communicate with GFDiag
* All GFDiag API calls take the DiagHandle as the first arg. Useful for
* error messages, and MODS needs some way to identify what test is talking
* to it.
*/
#ifndef __GFDIAG_H__
#define __GFDIAG_H__
#include "GFRm.h"
#include <stdarg.h>
/** Utility macro */
#define CHECK_STATUS_CLEANUP(f) \
do { \
if(ISGFERROR( ( status = (f) ) )) \
goto Cleanup; \
} while(0)
#if !defined(NV_MODS)
#ifdef __cplusplus
extern "C"
{
#endif
/*
* READ THIS FIRST:
*
* None of these funtions should be called directly by an application. The
* macros below should be used instead.
*/
/** Diag context structure */
typedef struct _GFDIAGCONTEXT
{
NvU32 processID;
NvU32 threadID;
} GFDIAGCONTEXT, *PGFDIAGCONTEXT;
/** Public exposed DIAG API functions in the table */
typedef struct _GFDIAGTABLE
{
/**
@see GF_DIAG_INITIALIZE
*/
GF_RETTYPE ( *DiagInitialize)( GFDiagHandle DiagHandle, int argc, char **argv );
/**
@see GF_DIAG_GET_VERSION
*/
GF_RETTYPE ( *DiagGetVersion)( GFDiagHandle DiagHandle, char *versionStr, int bufferLen );
/**
@see GF_DIAG_SET_RENDER_SURFACE
*/
GF_RETTYPE ( *DiagSetRenderSurface)( GFDiagHandle DiagHandle, PGFRMSURFACE surface );
/**
@see GF_DIAG_SET_IDLE_CHIP_CALLBACK
*/
GF_RETTYPE ( *DiagSetIdleChipCallback)( GFDiagHandle DiagHandle,
GF_RETTYPE (*pIdleCallback)(void *idleCallbackData), void *data );
/**
@see GF_DIAG_FRAME_DONE
*/
GF_RETTYPE ( *DiagFrameDone)( GFDiagHandle DiagHandle );
/**
@see GF_DIAG_CLEANUP
*/
GF_RETTYPE ( *DiagCleanup)( GFDiagHandle DiagHandle );
/**
@see GF_DIAG_RUN_TEST
*/
GF_RETTYPE (* DiagRunTest)( GFDiagHandle DiagHandle, char *testName,
const char *pCmdLine, NvU8 flag, GFDiagHandle *pDiagChildHandle );
/**
@see GF_DIAG_WAIT_FOR_TEST
*/
GF_RETTYPE (* DiagWaitForTest)( GFDiagHandle DiagHandle );
/**
@see GF_DIAG_PRINT
*/
GF_RETTYPE (* DiagPrint)( GFDiagHandle DiagHandle, const char *msg );
/**
@see GF_DIAG_GET_CONTEXT
*/
GF_RETTYPE (* DiagGetContext)( GFDiagHandle DiagHandle, GFDIAGCONTEXT *pContext );
} GFDIAGTABLE, *PGFDIAGTABLE;
/*
*****************************************************************************
* MACROS - Apps should use these to communicate with GFDiag
*****************************************************************************
*/
// Function documentation goes here to bypass #ifdef problems
/** @name Functions
@{*/
/** @def GF_DIAG_MAIN
Replace your standard definition of "int main" with with this macro
for use with GFDiag.
@param unused1 (int) Unused -- obsolete argument, to be removed
@param unused2 (char**) Unused -- obsolete argument, to be removed
@param testName (char*) Name of the test
@retval #GF_SUCCESS Success
@retval #GF_ERROR Some error occured
*/
/** @def GF_DIAG_INITIALIZE
Control things like storing vs checking, HW vs SW crcs via this function.
@param DiagHandle (#GFDiagHandle) Handle to Diag
@param argc (int) Argument count
@param argv (char**) Argument data
@retval #GF_SUCCESS Success
@retval #GF_ERROR Some error occured
Will read in the stored CRCs if applicable.
*/
/** @def GF_DIAG_GET_VERSION
Query the GFDiag version.
@param DiagHandle (#GFDiagHandle) Handle to Diag
@param str (char*) Pointer to a buffer that will be filled with the GFDiag version
@param len (int) Length of the buffer, versionStr
@retval #GF_SUCCESS Success
@retval #GF_ERROR Some error occured
The application allocates a buffer and passes it
(along with its length) to GFDiag.
*/
/** @def GF_DIAG_SET_IDLE_CHIP_CALLBACK
Allow the test to idle the chip in its own way.
@param DiagHandle (#GFDiagHandle) Handle to Diag
@param callbackFn (GF_RETTYPE (void *idleCallbackData)) Function pointer to call on idle
@param callbackData (void*) Data to pass to pIdleCallback when it is called
@retval #GF_SUCCESS Success
@retval #GF_ERROR Some error occured
*/
/** @def GF_DIAG_SET_RENDER_SURFACE
Tell GFDiag what surface we want to CRC etc.
@param DiagHandle (#GFDiagHandle) Handle to Diag
@param surface (#PGFRMSURFACE) Surface we want to CRC
@retval #GF_SUCCESS Success
@retval #GF_ERROR Some error occured
*/
/** @def GF_DIAG_FRAME_DONE
Announce the completion of a frame.
@param DiagHandle (#GFDiagHandle) Handle to Diag
@retval #GF_SUCCESS Success
@retval #GF_ERROR Some error occured
GFDiag has the option to:
Calculate a CRC on the primary surface. This function calls the callback
function set by GFDiagSetIdleChipCallback (or a default if no idle chip
callback is supplied) to idle the chip before calculating CRCs
In "storing mode" this will store the CRC in some DB that gets written
to file later.
In "checking mode" this checks the CRC against the one we read in from file.
*/
/** @def GF_DIAG_CLEANUP
Perform any necessary cleanup operations before the test exits and write
CRCs to file if applicable.
@param DiagHandle (#GFDiagHandle) Handle to Diag
@retval #GF_SUCCESS Success
@retval #GF_ERROR Some error occured
*/
/** @def GF_DIAG_PRINT
Prints to GFDiag.
@param DiagHandle (#GFDiagHandle) Handle to Diag
@param x (const char*) Message to print
@retval #GF_SUCCESS Success
@retval #GF_ERROR Some error occured
*/
/** @def GF_DIAG_RUN_TEST
Starts a test executing.
@param DiagHandle (#GFDiagHandle) Handle to Diag
@param testName (char*) Name of the test to execute
@param pCmdLine (const char*) The command line to execute the test
@param flag (NvU8) This is an option specifying how the test should be run. May contain one of: GF_DIAG_RUN_NEW_PROCESS, GF_DIAG_RUN_NEW_THREAD or GF_DIAG_RUN_NORMAL
@param pDiagChildHandle (#GFDiagHandle) This is a pointer to a GFDiagHandle that will be filled in with the handle of the child process
@retval #GF_SUCCESS Success
@retval #GF_ERROR Some error occured
*/
/** @def GF_DIAG_WAIT_FOR_TEST
Waits for test to complete, return value will be result of test.
@param DiagHandle (#GFDiagHandle) Handle to Diag of test to run (probably the handle placed in pDiagChildHandle from GF_DAIG_RUN_TEST)
@retval #GF_SUCCESS Success
@retval #GF_ERROR Some error occured
@see GF_DIAG_RUN_TEST
*/
/** @def GF_DIAG_GET_CONTEXT
Gets context from GFDiag.
@param DiagHandle (#GFDiagHandle) Handle to Diag
@param pContext (#GFDIAGCONTEXT) Points to a structure that will be filled with the current context
@retval #GF_SUCCESS Success
@retval #GF_ERROR Some error occured
*/
/** @def GF_DIAG_PRINTF
Format prints a message.
@param x (bracketed printf string) Message to print
*/
/*@}*/
/* Run flags */
/** Test is run in same thread */
#define GF_DIAG_RUN_NORMAL 1
#define GF_DIAG_RUN_NEW_THREAD 2
#define GF_DIAG_RUN_NEW_PROCESS 4
/** @def GF_DIAG_CRC_STATUS
Helper macro to check the status of a call to GF_DIAG_FRAME_DONE
and increment a fail count if the status was a failure.
eg:
@code GF_DIAG_CRC_STATUS(GF_DIAG_FRAME_DONE("DxTest"), GF_Diag_CrcFailCount);
@endcode
@param status The status of a call to GF_DIAG_FRAME_DONE
@param gf_diag_crcFailCount The var containing the current failure count
@see GF_DIAG_FRAME_DONE
*/
#define GF_DIAG_CRC_STATUS(status, gf_diag_crcFailCount)
#ifdef GF_DIAG_ENABLED
/*
* See doxygen comments above for info on the following macros
*/
#define GF_DIAG_MAIN(unused1, unused2, testName) \
int TestMain(int argc, char *argv[], GFDiagHandle handle)
#define GF_DIAG_INITIALIZE(handle, argc, argv) \
((PGFDIAGTABLE)handle)->DiagInitialize((handle), (argc), (argv))
#define GF_DIAG_GET_VERSION(handle, str, len) \
((PGFDIAGTABLE)handle)->DiagGetVersion((handle), (str), (len))
#define GF_DIAG_SET_IDLE_CHIP_CALLBACK(handle, callbackFn, callbackData) \
((PGFDIAGTABLE)handle)->DiagSetIdleChipCallback(handle, callbackFn, callbackData)
#define GF_DIAG_SET_RENDER_SURFACE(handle, surface) \
((PGFDIAGTABLE)handle)->DiagSetRenderSurface((handle), (surface))
#define GF_DIAG_FRAME_DONE(handle) \
((PGFDIAGTABLE)handle)->DiagFrameDone((handle))
#define GF_DIAG_CLEANUP(handle) \
((PGFDIAGTABLE)handle)->DiagCleanup((handle))
#define GF_DIAG_PRINT(handle, x) \
((PGFDIAGTABLE)handle)->DiagPrint(handle, x)
#define GF_DIAG_RUN_TEST(handle, testName, pCmdLine, flag, pDiagChildHandle) \
((PGFDIAGTABLE)handle)->DiagRunTest(handle, testName, pCmdLine, flag, pDiagChildHandle)
#define GF_DIAG_WAIT_FOR_TEST(handle) \
((PGFDIAGTABLE)handle)->DiagWaitForTest(handle)
#define GF_DIAG_GET_CONTEXT(handle, pContext) \
((PGFDIAGTABLE)handle)->DiagGetContext(handle, pContext)
static void
GFDiagPrintf( GFDiagHandle handle, const char *fmt, ... )
{
char buf[1024];
va_list list;
va_start(list, fmt);
GFSprintfVAL(buf, fmt, list);
GF_DIAG_PRINT(handle, buf);
va_end(list);
}
#define GF_DIAG_PRINTF(x) GFDiagPrintf x
#else
/*
* Do this exactly like nvplat...so this will have an OS specific
* implementation in the final GFDiag.h
*/
#if NVOS_IS_LINUX || NVOS_IS_WINDOWS
#define GF_DIAG_MAIN(unused1, unused2, testName) \
int TestMain(int argc, char *argv[])
#define GF_DIAG_MAIN_DEFAULT_1ARG(unused1, unused2, testName, arg1) \
int TestMain(int argc, char *argv[])
#define GF_DIAG_MAIN_DEFAULT_2ARGS(unused1, unused2, testName, arg1, arg2) \
int TestMain(int argc, char *argv[])
#define GF_DIAG_MAIN_DEFAULT_3ARGS(unused1, unused2, testName, arg1, arg2, arg3) \
int TestMain(int argc, char *argv[])
#else
#define GF_DIAG_MAIN(unused1, unused2, testName) \
int argc = 1; \
char *argv[] = { #testName }; \
int main()
#define GF_DIAG_MAIN_DEFAULT_1ARG(unused1, unused2, testName, arg1) \
int argc = 2; \
char *argv[] = { #testName, arg1 }; \
int main()
#define GF_DIAG_MAIN_DEFAULT_2ARGS(unused1, unused2, testName, arg1, arg2) \
int argc = 3; \
char *argv[] = { #testName, arg1, arg2 }; \
int main()
#define GF_DIAG_MAIN_DEFAULT_3ARGS(unused1, unused2, testName, arg1, arg2, arg3) \
int argc = 4; \
char *argv[] = { #testName, arg1, arg2, arg3 }; \
int main()
#endif
#define GF_DIAG_INITIALIZE(testName, argc, argv) GF_SUCCESS
#define GF_DIAG_CLEANUP(testName) GF_SUCCESS
/* These should be removed once all the Apps & MODS are updated */
#define GF_DIAG_GET_VERSION(testName, str, len) GF_SUCCESS
#define GF_DIAG_SET_IDLE_CHIP_CALLBACK(testName, callbackFn, callbackData) GF_SUCCESS
#define GF_DIAG_SET_RENDER_SURFACE(testName, surface) GF_SUCCESS
#define GF_DIAG_FRAME_DONE(testName) GF_SUCCESS
#define GF_DIAG_PRINT(handle, x) GF_SUCCESS
#define GF_DIAG_RUN_TEST(handle, testName, pCmdLine, flag, pDiagChildHandle) GF_SUCCESS
#define GF_DIAG_WAIT_FOR_TEST(handle) GF_SUCCESS
#define GF_DIAG_GET_CONTEXT(handle, pContext) GF_SUCCESS
#define GF_DIAG_PRINTF(x) GFPrintf x
#endif /* GF_DIAG_ENABLED */
#ifdef __cplusplus
}
#endif
/* NV_MODS */
#else
/* GFDiag is always enabled in NV_MODS builds */
#define GF_DIAG_ENABLED 1
#ifndef INCLUDED_GFMODS_H
#include "../GFMods/src/GFMods.h"
#endif
#endif /* NV_MODS */
#define CHECK_STATUS_MSG(f,TEXT) \
do { \
if(ISGFERROR( ( status = (f) ) )) \
{ \
GF_DIAG_PRINTF((TEXT)); \
} \
} while(0)
#define CHECK_STATUS_CLEANUP_MSG(f , TEXT) \
do { \
if(ISGFERROR( ( status = (f) ) )) \
{ \
GF_DIAG_PRINTF(TEXT); \
goto Cleanup; \
} \
} while(0)
#define CHECK_STATUS_AND_DISPLAY_CLEANUP_MSG(f , TEXT) \
do { \
if(ISGFERROR( ( status = (f) ) )) \
{ \
GF_DIAG_PRINTF((TEXT,f)); \
goto Cleanup; \
} \
} while(0)
#endif /* __GFDIAG_H__ */