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/GFRmHelp.h
2010-10-16 00:02:07 +06:00

516 lines
16 KiB
C
Executable File
Raw Blame History

/*
* Copyright 2003 NVIDIA Corporation. All Rights Reserved.
*
* BY INSTALLING THE SOFTWARE THE USER AGREES TO THE TERMS BELOW.
*
* User agrees to use the software under carefully controlled conditions
* and to inform all employees and contractors who have access to the software
* that the source code of the software is confidential and proprietary
* information of NVIDIA and is licensed to user as such. User acknowledges
* and agrees that protection of the source code is essential and user shall
* retain the source code in strict confidence.User shall restrict access to
* the source code of the software to those employees and contractors of user
* who have agreed to be bound by a confidentiality obligation which
* incorporates the protections and restrictions substantially set forth
* herein, and who have a need to access the source code in order to carry out
* the business purpose between NVIDIA and user. The software provided
* herewith to user may only be used so long as the software is used solely
* with NVIDIA products and no other third party products (hardware or
* software). The software must carry the NVIDIA copyright notice shown
* above. User must not disclose, copy, duplicate, reproduce, modify,
* publicly display, create derivative works of the software other than as
* expressly authorized herein. User must not under any circumstances,
* distribute or in any way disseminate the information contained in the
* source code and/or the source code itself to third parties except as
* expressly agreed to by NVIDIA. In the event that user discovers any bugs
* in the software, such bugs must be reported to NVIDIA and any fixes may be
* inserted into the source code of the software by NVIDIA only. User shall
* not modify the source code of the software in any way. User shall be fully
* responsible for the conduct of all of its employees, contractors and
* representatives who may in any way violate these restrictions.
*
* NO WARRANTY
* THE ACCOMPANYING SOFTWARE (INCLUDING OBJECT AND SOURCE CODE) PROVIDED BY
* NVIDIA TO USER IS PROVIDED "AS IS." NVIDIA DISCLAIMS ALL WARRANTIES,
* EXPRESS, IMPLIED OR STATUTORY, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT.
* LIMITATION OF LIABILITY
* NVIDIA SHALL NOT BE LIABLE TO USER, USER<45>S CUSTOMERS, OR ANY OTHER PERSON
* OR ENTITY CLAIMING THROUGH OR UNDER USER FOR ANY LOSS OF PROFITS, INCOME,
* SAVINGS, OR ANY OTHER CONSEQUENTIAL, INCIDENTAL, SPECIAL, PUNITIVE, DIRECT
* OR INDIRECT DAMAGES (WHETHER IN AN ACTION IN CONTRACT, TORT OR BASED ON A
* WARRANTY), EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGES. THESE LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF THE
* ESSENTIAL PURPOSE OF ANY LIMITED REMEDY. IN NO EVENT SHALL NVIDIA<49>S
* AGGREGATE LIABILITY TO USER OR ANY OTHER PERSON OR ENTITY CLAIMING THROUGH
* OR UNDER USER EXCEED THE AMOUNT OF MONEY ACTUALLY PAID BY USER TO NVIDIA
* FOR THE SOFTWARE PROVIDED HEREWITH.
*/
/*
* File: GFRmHelp.inl
* GFSDK Resource Manager Helper Manager inline header file.
* #### The helper functions are highly dependent on Operating System ####
* #### and Compiler. A number of these functions are macros that ####
* #### maps to corresonding operating system functions directly. ####
*/
#ifndef __GFRMHelp_INL__
#define __GFRMHelp_INL__
#include "nvtypes.h"
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
/* Defined in GFRMHelp.c */
extern int GFStricmp(char *, char *);
extern int GFStrincmp(char *, char *, int);
extern void *GFMalloc(int);
extern void GFFree(void *ptr);
#if NVOS_IS_WINDOWS_CE
#ifndef __KERNEL__
#include <string.h>
#include <stdlib.h>
#endif // __KERNEL__
/* String Helper functions */
#define GFStrcpy(p1, p2) strcpy(p1, p2)
#define GFStrncpy(p1, p2, p3) strncpy(p1, p2, p3)
#define GFStrcat(p1, p2) strcat(p1, p2)
#define GFStrncat(p1, p2, p3) strncat(p1, p2, p3)
#define GFStrlen(p1) strlen(p1)
#define GFStrchr(p1, p2) strchr(p1, p2)
#define GFStrcmp(p1, p2) strcmp(p1, p2)
#define GFStrncmp(p1, p2, p3) strncmp(p1, p2, p3)
#define GFStrtok(p1, p2) strtok(p1, p2)
#define GFStrstr(p1, p2) strstr(p1, p2)
#define GFSscanf(p1, p2, p3) sscanf(p1, p2, p3)
#define GFToupper(p1) toupper(p1)
#define GFTolower(p1) tolower(p1)
#define GFAtoi(p1) atoi(p1)
// convert char string to wchar_t
// p1 = src string of type char
// p2 = dst string of type wchar_t
// p3 = size of dst string in wchar_t unit
#define GFStrConvert(p1, p2, p3) \
MultiByteToWideChar(CP_ACP, 0, p1, -1, p2, p3);
// convert wchar_t string to char
// p1 = src string of type wchar_t
// p2 = dst string of type char
// p3 = size of dst string in char unit
#define GFWStrConvert(p1, p2, p3) \
WideCharToMultiByte(CP_ACP, 0, p1, -1, p2, p3, NULL, NULL)
/* Standard Helper functions */
#define GFStrtol(p1, p2, p3) strtol(p1, p2, p3)
#define GFStrtod(p1, p2) strtod(p1, p2)
/* Memory Helper functions */
#define GFMemcpy( p1, p2, p3 ) memcpy( p1, p2, p3 )
#define GFMemmove( p1, p2, p3 ) memmove( p1, p2, p3 )
#define GFMemcmp( p1, p2, p3 ) memcmp( p1, p2, p3 )
#define GFMemset( p1, p2, p3 ) memset( p1, p2, p3 )
#if defined(GF_ENABLE_RMC_TRACE)
void GFRmRMCTrace(const char *printf_format, ...);
void GFRmRMCVTrace(const char *printf_format, va_list ap);
#define GFRMCTrace(a) GFRmRMCTrace a
#define GFRMCVTrace(a) GFRmRMCVTrace a
#else
#define GFRMCTrace(a)
#define GFRMCVTrace(a)
#endif
/* Debug Helper functions */
#if !defined(PROJECT_SEC_G1) || defined(DEBUG)
#define GFPrintf printf
#else
#define GFPrintf
#endif
#define GFSprintf sprintf
#define GFSprintfVAL vsprintf
#define GFPrintfVAL vprintf
#ifdef DEBUG
extern void RmDebugBreak(void);
#define GFDEBUG_ASSERT(x) if(!(x)) \
{ \
GFPrintf(" Assert at Line no: %d in %s ", \
__LINE__, __FILE__); \
RmDebugBreak(); \
}
#endif
#elif NVOS_IS_LINUX
#ifndef __KERNEL__
void RmDebugBreak(void);
#ifdef DEBUG
#define GFDEBUG_ASSERT(x) if(!(x)) \
{ \
GFPrintf(" Assert at Line no: %d in %s ", \
__LINE__, __FILE__); \
RmDebugBreak(); \
}
#endif
#include <ctype.h>
#define GFToupper toupper
#define GFTolower tolower
#include <string.h>
#ifndef GF_XTENSA_RM_TASK
#include <strings.h>
#endif
#define GFMemcpy memcpy
#define GFMemmove memmove
#define GFMemset memset
#define GFMemcmp memcmp
#define GFStrchr strchr
#define GFStrcmp strcmp
#define GFStrcpy strcpy
#define GFStrncpy strncpy
#define GFStrlen strlen
#define GFStrcat strcat
#define GFStrncmp strncmp
#define GFStrtok strtok
#define GFStrstr strstr
#define GFSscanf sscanf
#include <stdio.h>
#define GFPrintf printf
#define GFSprintf sprintf
#define GFSprintfVAL vsprintf
#define GFPrintf printf
#define GFSprintf sprintf
#define GFSprintfVAL vsprintf
#define GFPrintfVAL vprintf
#include <stdlib.h>
#define GFStrtol strtol
#define GFStrtod strtod
#define GFAtoi atoi
#include <unistd.h>
/* Add or overload RMCTrace function here */
#if defined(GF_ENABLE_RMC_TRACE)
#include <stdarg.h>
void GFRmRMCTrace(const char *printf_format, ...);
void GFRmRMCVTrace(const char *printf_format, va_list ap);
#define GFRMCTrace(a) GFRmRMCTrace a
#define GFRMCVTrace(a) GFRmRMCVTrace a
#else
#define GFRMCTrace(a)
#define GFRMCVTrace(a)
#endif
#else /* kernel mode */
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/ctype.h>
#define GFToupper toupper
#define GFTolower tolower
#include <linux/string.h>
#define GFMemcpy memcpy
#define GFMemmove memmove
#define GFMemset memset
#define GFStrcpy strcpy
#define GFStrncpy strncpy
#define GFStrlen strlen
#define GFMemcmp memcmp
#define GFStrcmp strcmp
#define GFStrncmp strncmp
#define GFStrcat strcat
#define GFStrncat strncat
#define GFStrstr strstr
#define GFSscanf sscanf
#define GFPrintf printk
#define GFSprintf sprintf
#define GFSprintfVAL vsprintf
#define GFPrintfVAL vprintf
#define GFAtoi atoi
#if defined(GF_ENABLE_RMC_TRACE)
#include <stdarg.h>
void GFRmRMCTrace(const char *printf_format, ...);
void GFRmRMCVTrace(const char *printf_format, va_list ap);
#define GFRMCTrace(a) GFRmRMCTrace a
#define GFRMCVTrace(a) GFRmRMCVTrace a
#else
#define GFRMCTrace(a)
#define GFRMCVTrace(a)
#endif
#endif /* KERNEL */
#elif NVOS_IS_WINDOWS
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
/* String functions */
#define GFStrcpy(p1, p2) strcpy(p1, p2)
#define GFStrncpy(p1, p2, p3) strncpy(p1, p2, p3)
#define GFStrcat(p1, p2) strcat(p1, p2)
#define GFStrncat(p1, p2, p3) strncat(p1, p2, p3)
#define GFStrstr(p1, p2) strstr(p1, p2)
#define GFSscanf(p1, p2, p3) sscanf(p1, p2, p3)
#define GFStrlen(p1) strlen(p1)
#define GFStrchr(p1, p2) strchr(p1, p2)
#define GFStrcmp(p1, p2) strcmp(p1, p2)
#define GFStrncmp(p1, p2, p3) strncmp(p1, p2, p3)
#define GFStrtok(p1, p2) strtok(p1, p2)
#define GFToupper(p1) toupper(p1)
#define GFTolower(p1) tolower(p1)
#define GFStrConvert(p1, p2, p3) \
strcpy(p2,p1)
// MultiByteToWideChar( CP_ACP, 0, p1, -1, p2, p3 );
// convert char string to Wide
// p1 = src string of type char
// p2 = dst string of type wchar_t
// p3 = size of dst string in wchar_t unit
/* Standard Helper functions */
#define GFStrtol(p1, p2, p3) strtol(p1, p2, p3)
#define GFStrtod(p1, p2) strtod(p1, p2)
/* Memory Helper functions */
#define GFMemcpy( p1, p2, p3 ) memcpy( p1, p2, p3 )
#define GFMemmove( p1, p2, p3 ) memmove( p1, p2, p3 )
#define GFMemcmp( p1, p2, p3 ) memcmp( p1, p2, p3 )
#define GFMemset( p1, p2, p3 ) memset( p1, p2, p3 )
#define GFAtoi( p1 ) atoi( p1 )
/* Debug Helper functions */
#if !defined(PROJECT_SEC_G1) || defined(DEBUG)
#define GFPrintf printf
#else
#define GFPrintf
#endif
#define GFSprintf sprintf
#define GFSprintfVAL vsprintf
#define GFPrintfVAL vprintf
#if defined(GF_ENABLE_RMC_TRACE)
void GFRmRMCTrace(const char *printf_format, ...);
void GFRmRMCVTrace(const char *printf_format, va_list ap);
#define GFRMCTrace(a) GFRmRMCTrace a
#define GFRMCVTrace(a) GFRmRMCVTrace a
#else
#define GFRMCTrace(a)
#define GFRMCVTrace(a)
#endif
void RmDebugBreak(void);
#ifdef DEBUG
#define GFDEBUG_ASSERT(x) if(!(x)) \
{ \
GFPrintf(" Assert at Line no: %d in %s ", \
__LINE__, __FILE__); \
RmDebugBreak(); \
}
#endif
// Operating system running on the Xtensa
#elif NVCPU_IS_XTENSA
#include <string.h>
/* Memory Helper functions */
#define GFMemcpy( p1, p2, p3 ) memcpy(p1, p2, p3)
#define GFMemset( p1, p2, p3 ) memset(p1, p2, p3)
#define GFRMCTrace(a)
#define GFRMCVTrace(a)
#else
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <stdio.h>
#include <stdarg.h>
/* String functions */
extern char GFToupper(char);
extern char GFTolower(char);
extern int GFAtoi(const char *);
extern void *GFMemcpy(void *, const void *, int);
extern void *GFMemmove(void *, const void *, int);
extern void *GFMemset(void *, int, int);
extern int GFMemcmp(void *, void *, int);
extern char *GFStrcpy(char *, const char *);
extern char *GFStrncpy(char *, const char *, int);
extern char *GFStrcat(char *, const char *);
extern char *GFStrncat(char *, const char *, int);
extern int GFStrlen(const char *);
extern char *GFStrchr(const char *,int);
extern char *GFStrrchr(const char *,int);
extern int GFStrcmp(const char *, const char *);
extern int GFStrncmp(const char *, const char *, int);
extern char *GFStrstr(const char * string1, const char * string2);
extern int GFSscanf(char * string1, const char * string2, ...);
extern char *GFStrtok(char *, const char *);
extern long GFStrtol(const char *, char **, int);
extern double GFStrtod(const char *, char **);
extern int GFPrintf(const char *, ... );
extern int GFSprintf(char * , const char *, ... );
extern int GFSprintfVAL(char *, const char *, va_list);
extern int GFPrintfVAL(const char *, va_list);
#define GFStrConvert(p1, p2, p3) GFStrncpy(p1, p2, p3)
#if defined(GF_ENABLE_RMC_TRACE)
#define GFRMCTrace(a) printf a
#define GFRMCVTrace(a) vprintf a
#else
#define GFRMCTrace(a)
#define GFRMCVTrace(a)
#endif
#ifdef DEBUG
#define GFDEBUG_ASSERT(x) if(!(x)) \
{ \
GFPrintf(" Assert at Line no: %d in %s ", \
__LINE__, __FILE__); \
}
#endif
#endif /* GF_OS */
/* Virtual Key Mappings for Specific OS */
#if NVOS_IS_LINUX
/* Virtual Keys */
#define GF_VKEY_BACK 27
#define GF_VKEY_FORWARD 13
#define GF_VKEY_UP 65
#define GF_VKEY_LEFT 68
#define GF_VKEY_RIGHT 67
#define GF_VKEY_DOWN 66
#define GF_VKEY_SEND 46
#define GF_VKEY_END 44
#define GF_VKEY_0 48
#define GF_VKEY_1 49
#define GF_VKEY_2 50
#define GF_VKEY_3 51
#define GF_VKEY_4 52
#define GF_VKEY_5 53
#define GF_VKEY_6 54
#define GF_VKEY_7 55
#define GF_VKEY_8 56
#define GF_VKEY_9 57
#define GF_VKEY_STAR 42
#define GF_VKEY_POUND 35
#elif NVOS_IS_WINDOWS_CE
/* Virtual Keys */
#define GF_VKEY_BACK 27
#define GF_VKEY_FORWARD 13
#define GF_VKEY_UP 72
#define GF_VKEY_LEFT 75
#define GF_VKEY_RIGHT 77
#define GF_VKEY_DOWN 80
#define GF_VKEY_SEND 46
#define GF_VKEY_END 44
#define GF_VKEY_0 48
#define GF_VKEY_1 49
#define GF_VKEY_2 50
#define GF_VKEY_3 51
#define GF_VKEY_4 52
#define GF_VKEY_5 53
#define GF_VKEY_6 54
#define GF_VKEY_7 55
#define GF_VKEY_8 56
#define GF_VKEY_9 57
#define GF_VKEY_STAR 42
#define GF_VKEY_POUND 35
#elif NVOS_IS_WINDOWS
/* Virtual Keys */
#define GF_VKEY_BACK 27
#define GF_VKEY_FORWARD 13
#define GF_VKEY_UP 72
#define GF_VKEY_LEFT 75
#define GF_VKEY_RIGHT 77
#define GF_VKEY_DOWN 80
#define GF_VKEY_SEND 46
#define GF_VKEY_END 44
#define GF_VKEY_0 48
#define GF_VKEY_1 49
#define GF_VKEY_2 50
#define GF_VKEY_3 51
#define GF_VKEY_4 52
#define GF_VKEY_5 53
#define GF_VKEY_6 54
#define GF_VKEY_7 55
#define GF_VKEY_8 56
#define GF_VKEY_9 57
#define GF_VKEY_STAR 42
#define GF_VKEY_POUND 35
#else
/* Virtual Keys */
#define GF_VKEY_BACK 2
#define GF_VKEY_FORWARD 3
#define GF_VKEY_UP 4
#define GF_VKEY_LEFT 5
#define GF_VKEY_RIGHT 6
#define GF_VKEY_DOWN 7
#define GF_VKEY_SEND 8
#define GF_VKEY_END 9
#define GF_VKEY_0 10
#define GF_VKEY_1 11
#define GF_VKEY_2 12
#define GF_VKEY_3 13
#define GF_VKEY_4 14
#define GF_VKEY_5 15
#define GF_VKEY_6 16
#define GF_VKEY_7 17
#define GF_VKEY_8 18
#define GF_VKEY_9 19
#define GF_VKEY_STAR 20
#define GF_VKEY_POUND 21
#endif /* GF_OS */
#ifndef GFDEBUG_ASSERT
#define GFDEBUG_ASSERT(x) do {} while (0)
#endif /* GFDEBUG_ASSERT */
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GFRMHelp_INL__ */