# HG changeset patch # User Michael Spacefalcon # Date 1397289589 0 # Node ID 397b22c607c8c7a0eabb878dc36cdbf20ee5cdc7 # Parent 2c760f6b1fe00a26e85c6d6e1a42d6b3a3044002 gsm-fw/gpf/misc/*.c: import from Leonardo semi-src diff -r 2c760f6b1fe0 -r 397b22c607c8 gsm-fw/gpf/misc/misc_version.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gsm-fw/gpf/misc/misc_version.c Sat Apr 12 07:59:49 2014 +0000 @@ -0,0 +1,43 @@ +/* ++------------------------------------------------------------------------------ +| File: misc_version.c ++------------------------------------------------------------------------------ +| Copyright 2002 Texas Instruments Berlin, AG +| All rights reserved. +| +| This file is confidential and a trade secret of Texas +| Instruments Berlin, AG +| The receipt of or possession of this file does not convey +| any rights to reproduce or disclose its contents or to +| manufacture, use, or sell anything it may describe, in +| whole, or in part, without the specific written consent of +| Texas Instruments Berlin, AG. ++----------------------------------------------------------------------------- +| Purpose : This Module contain build date and time for MISC ++----------------------------------------------------------------------------- +*/ + +#ifndef __MISC_VERSION_C__ +#define __MISC_VERSION_C__ +#endif + + +/*==== INCLUDES ===================================================*/ + + +/*==== TYPES ======================================================*/ + + +/*==== CONSTANTS ==================================================*/ + +#ifndef RUN_INT_RAM +char const * const misc_version_date = __DATE__; +char const * const misc_version_time = __TIME__; +#endif + +/*==== EXTERNALS ==================================================*/ + + +/*==== FUNCTIONS ==================================================*/ + + diff -r 2c760f6b1fe0 -r 397b22c607c8 gsm-fw/gpf/misc/printtofile.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gsm-fw/gpf/misc/printtofile.c Sat Apr 12 07:59:49 2014 +0000 @@ -0,0 +1,228 @@ +/* ++------------------------------------------------------------------------------ +| File: printToFile.c ++------------------------------------------------------------------------------ +| Copyright 2002 Texas Instruments Berlin, AG +| All rights reserved. +| +| This file is confidential and a trade secret of Texas +| Instruments Berlin, AG +| The receipt of or possession of this file does not convey +| any rights to reproduce or disclose its contents or to +| manufacture, use, or sell anything it may describe, in +| whole, or in part, without the specific written consent of +| Texas Instruments Berlin, AG. ++----------------------------------------------------------------------------- +| Purpose: This module implements some stream output functions. ++----------------------------------------------------------------------------- +*/ + +#ifndef __PRINTTOFILE_C__ +#define __PRINTTOFILE_C__ +#endif + +#ifndef _TARGET_ + +/*==== INCLUDES ===================================================*/ + +#include "printtofile.h" + +#include "typedefs.h" +#ifndef _LINUX_ +#include +#include +#include +#include +#include "windows.h" +#include "vsi.h" +#include "time.h" +#include +#include +#endif /* _LINUX_ */ + +/*==== TYPES ======================================================*/ + + +/*==== CONSTANTS ==================================================*/ + + +/*==== EXTERNALS ==================================================*/ + + +/*==== VARIABLES ==================================================*/ + +#ifndef _LINUX_ +static HANDLE mutEx; +#endif /* _LINUX_ */ + +/*==== FUNCTIONS ==================================================*/ + +#ifndef RUN_INT_RAM +/* ++------------------------------------------------------------------------------ +| Function : PrintToFile ++------------------------------------------------------------------------------ +| Description : print to file xx and do a printf() with ident. arguments +| +| Parameters : const char *format, ... variable parameter list +| +| Return : printf retval +| ++------------------------------------------------------------------------------ +*/ +void initPrintToFile() +{ +#ifdef _LINUX_ + return; +#else /* _LINUX_ */ +#ifndef _TARGET_ +#ifdef _DEBUG + FILE *fp; +#endif + + if ( (mutEx = OpenMutex (MUTEX_ALL_ACCESS, FALSE, "PrintToFile")) == NULL ) + { + mutEx = CreateMutex( NULL, FALSE, "PrintToFile"); +#ifdef _DEBUG + fp = fopen("\\gpf\\BIN\\debug\\tstlog.txt", "w"); + PrintToFile("\n\nStart logging:\n"); +#endif + } + + if (mutEx == 0) + { + printf("PrintToFile semaphore creation failed!\n"); + } +#endif /* _LINUX_ */ +#endif +} +#endif + +#ifndef RUN_INT_RAM +/* ++------------------------------------------------------------------------------ +| Function : PrintToFile ++------------------------------------------------------------------------------ +| Description : print to file xx and do a printf() with ident. arguments +| +| Parameters : const char *format, ... variable parameter list +| +| Return : printf retval +| ++------------------------------------------------------------------------------ +*/ +int PrintToFile(const char *format, ... ) +{ + int retval = 0; +#ifndef _LINUX_ +#ifndef _TARGET_ + va_list unamedArgumentList; + char* nextChar; + int ival; + char* sval; +#ifdef _DEBUG + FILE *fp; + struct _timeb timebuf; + time_t seconds; + unsigned long int t; +#endif + + if ( WaitForSingleObject (mutEx, INFINITE) == WAIT_FAILED ) + { + printf("PrintToFile semaphore request failed! Is TST.exe up & running?\n"); + return -1; + } + va_start(unamedArgumentList, format); +#ifdef _DEBUG + fp = fopen("\\gpf\\BIN\\debug\\tstlog.txt", "a"); + if ( fp != 0 ) + { + time( &seconds ); // seconds after 1.1.70 GMT + _ftime( &timebuf ); + t = (unsigned long int)(seconds * 1000) + timebuf.millitm; + + /*lint -e668 */ + /*lint -e559 */ +#ifdef _TOOLS_ + fprintf(fp, "TST (%u): ", (unsigned int)t); +#else + fprintf(fp, "Stack (%u): ", (unsigned int)t); +#endif + } +#endif /* _DEBUG */ + + /*lint -e662 */ + for (nextChar = (char*) format; *nextChar; nextChar++) + { + if (*nextChar != '%') + { + putchar(*nextChar); +#ifdef _DEBUG + if (fp != 0) + { + fputc(*nextChar,fp); + } +#endif + continue; + } + + switch (*++nextChar) + { + case 'd': + ival = va_arg(unamedArgumentList, int); + printf("%d", ival); +#ifdef _DEBUG + if (fp != 0) + { + fprintf(fp, "%d", ival); + } +#endif + break; + case 'x': + ival = va_arg(unamedArgumentList, int); + printf("%x", ival); +#ifdef _DEBUG + if (fp != 0) + { + fprintf(fp, "%x", ival); + } +#endif + break; + case 's': + for(sval = va_arg(unamedArgumentList, char*); *sval; sval++) + { + putchar(*sval); +#ifdef _DEBUG + if (fp != 0) + { + fputc(*sval,fp); + } +#endif + } + break; + default: + putchar(*nextChar); +#ifdef _DEBUG + if (fp != 0) + { + fputc(*nextChar,fp); + } +#endif + break; + } + } + /*lint +e662 */ + va_end(unamedArgumentList); +#ifdef _DEBUG + if (fp != 0) + { + fclose(fp); + } +#endif + ReleaseMutex(mutEx); +#endif /* !_LINUX_ */ +#endif /* _TARGET_ */ + return retval; +} +#endif +#endif diff -r 2c760f6b1fe0 -r 397b22c607c8 gsm-fw/gpf/misc/tok.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gsm-fw/gpf/misc/tok.c Sat Apr 12 07:59:49 2014 +0000 @@ -0,0 +1,413 @@ +/* ++------------------------------------------------------------------------------ +| File: tok.c ++------------------------------------------------------------------------------ +| Copyright 2002 Texas Instruments Berlin, AG +| All rights reserved. +| +| This file is confidential and a trade secret of Texas +| Instruments Berlin, AG +| The receipt of or possession of this file does not convey +| any rights to reproduce or disclose its contents or to +| manufacture, use, or sell anything it may describe, in +| whole, or in part, without the specific written consent of +| Texas Instruments Berlin, AG. ++----------------------------------------------------------------------------- +| Purpose : This Modul performs Configuration string functions ++----------------------------------------------------------------------------- +*/ + +#ifndef __TOK_C__ +#define __TOK_C__ + +#include "typedefs.h" +#include +#include + +#include "tok.h" + +#ifdef _VXWORKS_ +#undef ERROR -1 /* Token types */ +#undef EOS 1 +#endif +#define ERROR -1 /* Token types */ +#define EOS 1 +#define COMMA 2 +#define EQUAL 3 +#define IDENT 4 +#define STRING 5 +#define LBRACK 6 +#define RBRACK 7 + +static SHORT tok_gettok (char **); +static SHORT tok_value (char **); +static int tok_issep (char); + +/* +Format: + List ::= Token + ::= Token , Token, ... + + Token ::= Ident + ::= Ident = Values + + Values ::= Value + ::= (Value) + ::= (Value , Value , ... ) + ::= () + + Value ::= Ident + ::= "String" + +*/ + +#ifndef RUN_INT_RAM +static TOK_DCB tok_dcb; +static char tok_buf[80]; +#endif + +#ifndef RUN_INT_RAM +/* +ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +| PROJEKT : TETRA-PS (6143) MODUL : TOK.C | +| STATUS : code ROUTINE : tok_key | +ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + + PURPOSE : Return code value of a keyword from table. + +*/ + +SHORT tok_key (KW_DATA * keytab, char * keyword) +{ + /* + * Empty string terminates + */ + while (keytab->keyword[0]) + { + if (strcmp (keytab->keyword, keyword ) == 0) + return (keytab->code); + keytab++; + } + + return (TOK_NOT_FOUND); +} +#endif + + +#ifndef RUN_INT_RAM +/* +ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +| PROJEKT : TETRA-PS (6143) MODUL : TOK.C | +| STATUS : code ROUTINE : tok_init | +ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + + PURPOSE : Initialize token scanner. + +*/ + +void tok_init (char * s) +{ + tok_dcb.tokbuf = tok_buf; + strncpy (tok_dcb.tokbuf, s, 79); + tok_dcb.tokbuf[79] = '\0'; + tok_dcb.nexttok = tok_dcb.tokbuf; + tok_dcb.lastchar = 0; +} +#endif + +#ifndef RUN_INT_RAM +/* +ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +| PROJEKT : TETRA-PS (6143) MODUL : TOK.C | +| STATUS : code ROUTINE : tok_next | +ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + + PURPOSE : Get next token (and its values) from token string. + Return number of value strings. + +*/ + +SHORT tok_next (char ** keyw, char * value []) +{ + char * val; + + if (tok_dcb.nexttok == NULL) + return (TOK_EOCS); + + if (tok_gettok (keyw) != IDENT) + { + tok_dcb.nexttok = NULL; + return (TOK_EOCS); + } + + /* + * Check next token + */ + switch (tok_gettok (&val)) + { + /* + * No value present + */ + case COMMA: + return (0); + /* + * Value(s) follows + */ + case EQUAL: + return (tok_value (value)); + /* + * No value present and EOS + */ + case EOS: + tok_dcb.nexttok = NULL; + return (0); + /* + * Syntax error + */ + default: + tok_dcb.nexttok = NULL; + return (TOK_EOCS); + } +} +#endif + +#ifndef RUN_INT_RAM +/* +ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +| PROJEKT : TETRA-PS (6143) MODUL : TOK.C | +| STATUS : code ROUTINE : tok_value | +ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + + PURPOSE : Get list of values for token. + Return number of values found. + + Formats: Value + (Value) + (Value, Value,...) + () +*/ + +static SHORT tok_value (char * value []) +{ + SHORT count; + SHORT tok; + SHORT inbrack; + char * val; + char * val2; + + inbrack = 0; + /* + * Get next token + */ + tok = tok_gettok (&val); + + switch (tok) + { + case LBRACK: + inbrack++; + break; + + case IDENT : + case STRING : + tok = tok_gettok (&val2); + if ((tok != COMMA) && (tok != EOS)) + { + tok_dcb.nexttok = NULL; + return (0); + } + + value[0] = val; + return (1); + + case EOS : + default : + tok_dcb.nexttok = NULL; + return (0); + } + + /* + * Get first token of list + */ + + tok = tok_gettok (&val); + count = 0; + for(;;) + { + if ((tok == IDENT) || (tok == STRING)) + value[count++] = val; + else + { + tok_dcb.nexttok = NULL; + return (0); + } + + tok = tok_gettok (&val); + switch (tok) + { + case COMMA: + break; + + case RBRACK : + if (inbrack) + { + if (((tok = tok_gettok (&val)) == COMMA) || + (tok == EOS)) + return (count); + } + /* + * Fall through + */ + /*lint -fallthrough */ + default: + tok_dcb.nexttok = NULL; + return (0); + } + tok = tok_gettok (&val); + } + /*lint -e527 suppress Warning -- Unreachable */ + return (0); + /*lint +e527 */ + +} +#endif + +#ifndef RUN_INT_RAM +/* +ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +| PROJEKT : TETRA-PS (6143) MODUL : TOK.C | +| STATUS : code ROUTINE : tok_gettok | +ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + + PURPOSE : Return next token in input string. + +*/ + +static SHORT tok_gettok (char ** token) +{ + SHORT tok; + char hadnull; + char * cp; + + cp = tok_dcb.nexttok; + hadnull = tok_dcb.lastchar != 0; + + if (tok_dcb.lastchar) + { + * tok_dcb.nexttok = tok_dcb.lastchar; + tok_dcb.lastchar = 0; + } + /* + * Skip leading white space + */ + while (isspace (* tok_dcb.nexttok)) + tok_dcb.nexttok++; + + * token = tok_dcb.nexttok++; + + switch (** token) + { + case '\0': /* End of string */ + case '\n': + tok = EOS; + break; + + case ',': + ** token = '\0'; + tok = COMMA; + break; + + case '=': + ** token = '\0'; + tok = EQUAL; + break; + + case '(': + case '<': + case '[': + ** token = '\0'; + tok = LBRACK; + break; + + case ')': + case '>': + case ']': + ** token = '\0'; + tok = RBRACK; + break; + + case '"': + /* + * Get first char of string + */ + * token = tok_dcb.nexttok; + while ((* tok_dcb.nexttok != '\0') && (* tok_dcb.nexttok != '"')) + tok_dcb.nexttok++; + + if (* tok_dcb.nexttok != '\0') + * tok_dcb.nexttok++ = '\0'; + + tok = STRING; + break; + + default: + /* + * Read an identifier + */ + if (!tok_issep (** token)) + { + while (!tok_issep (* tok_dcb.nexttok)) + tok_dcb.nexttok++; + + tok_dcb.lastchar = * tok_dcb.nexttok; + * tok_dcb.nexttok = '\0'; + + tok = IDENT; + } + else + tok = ERROR; + break; + } + /* + * '\0 was replaced with char + * Replace original '\0' + */ + + if (hadnull) + * cp = '\0'; + + return (tok); +} +#endif + +#ifndef RUN_INT_RAM +/* +ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ +| PROJEKT : TETRA-PS (6143) MODUL : TOK.C | +| STATUS : code ROUTINE : tok_issep | +ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ + + PURPOSE : Return 1 if special character. + +*/ + +static int tok_issep (char c) +{ + switch (c) + { + case '\0' : + case '\n' : + case ',' : + case '=' : + case '(' : + case '<' : + case '[' : + case ')' : + case '>' : + case ']' : + case '"' : return (1); + + default : return (isspace (c)); + } +} +#endif +#endif diff -r 2c760f6b1fe0 -r 397b22c607c8 gsm-fw/gpf/misc/tools.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gsm-fw/gpf/misc/tools.c Sat Apr 12 07:59:49 2014 +0000 @@ -0,0 +1,268 @@ +/* ++------------------------------------------------------------------------------ +| File: tools.c ++------------------------------------------------------------------------------ +| Copyright 2002 Texas Instruments Berlin, AG +| All rights reserved. +| +| This file is confidential and a trade secret of Texas +| Instruments Berlin, AG +| The receipt of or possession of this file does not convey +| any rights to reproduce or disclose its contents or to +| manufacture, use, or sell anything it may describe, in +| whole, or in part, without the specific written consent of +| Texas Instruments Berlin, AG. ++----------------------------------------------------------------------------- +| Purpose : This module implements some format conversion functions. ++----------------------------------------------------------------------------- +*/ + +#ifndef __TOOLS_C__ +#define __TOOLS_C__ +#endif + +/*==== INCLUDES ===================================================*/ + +#include "typedefs.h" +#include +#include +#include "vsi.h" +#include "tools.h" + +/*==== TYPES ======================================================*/ + + +/*==== CONSTANTS ==================================================*/ + + +/*==== EXTERNALS ==================================================*/ + + +/*==== VARIABLES ==================================================*/ + + +/*==== FUNCTIONS ==================================================*/ + + + +#ifndef RUN_INT_RAM +/* ++------------------------------------------------------------------------------ +| Function : GetNextToken ++------------------------------------------------------------------------------ +| Description : Exract text until next separator. +| +| Parameters : source - where to search +| token - destination for text +| seperator - sperator +| +| Return : string length of token ++------------------------------------------------------------------------------ +*/ +unsigned int GetNextToken (char *source, char *token, char const *seperators) +{ + unsigned int i, j, k, sep_len, src_len; + BOOL sepFound = FALSE; + + sep_len = strlen (seperators); + src_len = strlen (source); + + i = 0; + j = 0; + k = 0; + + do + { + j = 0; + sepFound = FALSE; + + while (j < sep_len) + { + if (source[i] EQ seperators[j]) + sepFound = TRUE; + j++; + } + if (sepFound) + i++; + } + while (i < src_len AND sepFound); + + sepFound = FALSE; + + while (!sepFound AND i < src_len) + { + j = 0; + while (!sepFound AND j < sep_len) + { + if (source[i] EQ seperators[j]) + sepFound = TRUE; + else + j++; + } + + if (!sepFound) + token[k++] = source[i++]; + } + token[k] = '\0'; + + return strlen (token); +} +#endif + +#ifndef RUN_FLASH +/* ++------------------------------------------------------------------------------ +| Function : HexToASCII ++------------------------------------------------------------------------------ +| Description : Convert hexadecimal value to ASCII string. +| +| Parameters : value - value to be converted +| *ptr - destination for string +| num - number of characters +| +| Return : pointer behind the end of string ++------------------------------------------------------------------------------ +*/ +char *HexToASCII (ULONG value, char *ptr, int num) +{ + UBYTE i; + char v; + + ptr += (num-1); + + for (i=0; i>= 4; + + if (v > 9) + v += ('A'-10); + else + v += '0'; + + *ptr-- = v; + } + + return(ptr+num+1); +} +#endif + +#ifndef RUN_INT_RAM +/* ++------------------------------------------------------------------------------ +| Function : ASCIIToHex ++------------------------------------------------------------------------------ +| Description : Convert ASCII string to hexadecimal value. +| +| Parameters : *ptr - string to be converted +| num - number of characters +| +| Return : value ++------------------------------------------------------------------------------ +*/ +unsigned int ASCIIToHex (char *ptr, int num) +{ + unsigned int i; + unsigned int result = 0; + unsigned int len; + char c; + + len = strlen(ptr); + if ( len < (unsigned int)num ) + num = (int)len; + + ptr += (num-1); + + for (i=0; i < (unsigned int)num; i++) + { + if (isxdigit (*ptr) ) + { + if (*ptr > '9') + c = *ptr-- - 'A' + 10; + else + c = *ptr-- - '0'; + + /*lint -e701 suppress Info -- shift left of signed quantity */ + result += (c << (i*4)); + /*lint +e701 */ + } + } + return result; +} +#endif + +#ifndef RUN_FLASH +/* ++------------------------------------------------------------------------------ +| Function : InsertString ++------------------------------------------------------------------------------ +| Description : write a string into the buffer. If the string has less than +| 'num' characters, spaces are added. +| +| Parameters : *string - string to be written +| *ptr - pointer to destination +| num - number of characters to be filled +| +| Return : pointer to next character ++------------------------------------------------------------------------------ +*/ +char *InsertString (char *string, char *ptr, int num) +{ + UBYTE i; + BYTE end_detected = FALSE; + + for (i=0;i= (char*)file)) + end--; + + return end + 1; +} +#endif diff -r 2c760f6b1fe0 -r 397b22c607c8 gsm-fw/gpf/misc/trace.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gsm-fw/gpf/misc/trace.c Sat Apr 12 07:59:49 2014 +0000 @@ -0,0 +1,239 @@ +/* ++------------------------------------------------------------------------------ +| File: trace.c ++------------------------------------------------------------------------------ +| Copyright 2002 Texas Instruments Berlin, AG +| All rights reserved. +| +| This file is confidential and a trade secret of Texas +| Instruments Berlin, AG +| The receipt of or possession of this file does not convey +| any rights to reproduce or disclose its contents or to +| manufacture, use, or sell anything it may describe, in +| whole, or in part, without the specific written consent of +| Texas Instruments Berlin, AG. ++----------------------------------------------------------------------------- +| Purpose : This Modul provides data and functions for fast in memory tracing ++----------------------------------------------------------------------------- +*/ + +#ifndef TRACE_C +#define TRACE_C +#endif +#define FAST_TRACE + +/*==== INCLUDES ===================================================*/ + +#include +#include "typedefs.h" +#include "header.h" +#include "custom.h" +#include "vsi.h" +#include "gsm.h" +#include "prim.h" +#include "pei.h" +#include "tok.h" + +#include "trace.h" + +#include +#include +#include "message.h" + +/*==== CONST ======================================================*/ + +#define TRC_ENTITY 0x60 +#define TRC_FILE 1 + + +#ifdef OPTION_MULTITHREAD +#define VSI_CALLER "ACI", +#define VSI_CALLER_SINGLE "ACI" +#else +#define VSI_CALLER +#define VSI_CALLER_SINGLE +#endif + + +/*==== TYPES ======================================================*/ + +/*==== VARIABLES ==================================================*/ + + +/*==== FUNCTIONS ==================================================*/ +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-F&D (8411) MODULE : TRACE | +| STATE : code ROUTINE : trc_init | ++--------------------------------------------------------------------+ + + PURPOSE : This function is called to initialize the trace function + +*/ + +GLOBAL void trc_init + ( + void + ) +{ + trc_p_buffer = trc_buffer; + trc_p_buffer_end = &trc_buffer[TRC_BUF_LEN-1]; + trc_wrap_around = FALSE; + trc_wrap_around_enable = TRUE; + trc_enabled = TRUE; + /*semTRC = vsi_s_open (VSI_CALLER "TRC"); */ +} + + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-F&D (8411) MODULE : TRACE | +| STATE : code ROUTINE : trc_enable_wrap_around | ++--------------------------------------------------------------------+ + + PURPOSE : This function is called to enable wrap around + +*/ + +GLOBAL void trc_enable_wrap_around + ( + void + ) +{ + trc_wrap_around_enable = TRUE; +} + + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-F&D (8411) MODULE : TRACE | +| STATE : code ROUTINE : trc_disable_wrap_around | ++--------------------------------------------------------------------+ + + PURPOSE : This function is called to disable wrap around + +*/ + +GLOBAL void trc_disable_wrap_around + ( + void + ) +{ + trc_wrap_around_enable = FALSE; +} + + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-F&D (8411) MODULE : TRACE | +| STATE : code ROUTINE : trc_enable | ++--------------------------------------------------------------------+ + + PURPOSE : This function is called to enable fast trace + +*/ + +GLOBAL void trc_enable + ( + void + ) +{ + trc_enabled = TRUE; +} + + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-F&D (8411) MODULE : TRACE | +| STATE : code ROUTINE : trc_disable | ++--------------------------------------------------------------------+ + + PURPOSE : This function is called to disable fast trace + +*/ + +GLOBAL void trc_disable + ( + void + ) +{ + trc_enabled = FALSE; +} + + +/* ++--------------------------------------------------------------------+ +| PROJECT : GSM-F&D (8411) MODULE : RA_SHM | +| STATE : code ROUTINE : trc_dump | ++--------------------------------------------------------------------+ + + PURPOSE : the content of the stored dump is dumped + into the system trace window. + +*/ + +GLOBAL void trc_dump (void) +{ + T_TRC_BUF_ENTRY *p_readOut; + ULONG *p; + ULONG i; + char buf [40]; + char buf1 [40]; + +#ifndef NEW_FRAME + vsi_o_trace ("", 0xff, "---FASTTRACEBUFFER---"); +#else + vsi_o_ttrace (0, 0xff, "---FASTTRACEBUFFER---"); +#endif + if (trc_wrap_around) + { + for (p_readOut= trc_p_buffer; + p_readOut < trc_p_buffer_end; + p_readOut++) + { + p = (ULONG*)p_readOut; + + buf1[0]='\0'; + + for (i = sizeof(T_TRC_BUF_ENTRY); i>=0; i-=sizeof(ULONG)) + { + sprintf(buf1, "0x%x ", *p++); + strcat (buf, buf1); + } +#ifndef NEW_FRAME + vsi_o_trace ("", 0xff, buf); + vsi_t_sleep("", 1); +#else + vsi_o_ttrace (0, 0xff, buf); + vsi_t_sleep(0, 1); +#endif + } + } + for (p_readOut= trc_buffer; + p_readOut < trc_p_buffer; + p_readOut++) + { + p = (ULONG*)p_readOut; + + buf1[0]='\0'; + + for (i = sizeof(T_TRC_BUF_ENTRY); i>=0; i-=sizeof(ULONG)) + { + sprintf(buf1, "0x%x ", *p++); + strcat (buf, buf1); + } +#ifndef NEW_FRAME + vsi_o_trace ("", 0xff, buf); + vsi_t_sleep("", 1); +#else + vsi_o_ttrace (0, 0xff, buf); + vsi_t_sleep(0, 1); +#endif + } + +#ifndef NEW_FRAME + vsi_o_trace ("", 0xff, "---END---"); +#else + vsi_o_ttrace (0, 0xff, "---END---"); +#endif +}