#include "envopt.h"
#include "envdep.h"
+#include "stdint.h"
#include "rl_interface.h"
-
#include <stdio.h>
#include <unistd.h>
#include <sys/socket.h>
char g_fileList[RLOG_MAX_FILES][MAX_FILENAME_LEN];
#ifdef RLOG_USE_CIRCULAR_BUFFER
static THREAD_DATA *g_pSingCirBuff = NULL;
-static U16 g_prevLogOffset=0;
+static uint16_t g_prevLogOffset=0;
#endif
#ifndef RLOG_ENABLE_TEXT_LOGGING
-static volatile U32 g_rlogPositionIndex=0;
-U32 gIpType = CM_IPV4ADDR_TYPE;
+static volatile uint32_t g_rlogPositionIndex=0;
+uint32_t gIpType = CM_IPV4ADDR_TYPE;
#endif
///////////////////////////////////////////////////////////////////////////////////////////////////
Data *g_l2LogBufBasePtr = NULLP;
Data *g_logBufRcvdFromL2 = NULLP;
Data *g_l2LogBaseBuff = NULLP;
-U32 g_logBufLenRcvdFromL2 = 0;
-U32 g_l2LogBufLen = 0;
-U32 startL2Logging = 0;
-U32 g_l2logBuffPos = 0;
+uint32_t g_logBufLenRcvdFromL2 = 0;
+uint32_t g_l2LogBufLen = 0;
+uint32_t startL2Logging = 0;
+uint32_t g_l2logBuffPos = 0;
/* end */
#endif /* Binary Logging */
int g_logLevel = L_MAX_LOG_LEVEL;
#endif
/* MAX Log Files 1 */
-U8 g_nMaxLogFiles = 1;
+uint8_t g_nMaxLogFiles = 1;
/* Max File Size limit for each log file */
-U32 g_uiMaxFileSizeLimit = MAX_FILE_SIZE;
+uint32_t g_uiMaxFileSizeLimit = MAX_FILE_SIZE;
/* Default circular buffer size 100Kb*/
-U32 g_cirMaxBufferSize = RLOG_MAX_CIRBUF_SIZE;
+uint32_t g_cirMaxBufferSize = RLOG_MAX_CIRBUF_SIZE;
/* Default mask for each module is disabled */
-U32 g_modMask = 0;
-
+uint32_t g_modMask = 0;
/* Remote Logging port */
-static U32 g_nLogPort = RLOG_REMOTE_LOGGING_PORT;
+static uint32_t g_nLogPort = RLOG_REMOTE_LOGGING_PORT;
/* Current File Number index */
int g_nCurrFileIdx = 0;
/* Remote logging flag */
-static U8 g_bRemoteLoggingDisabled=1;
+static uint8_t g_bRemoteLoggingDisabled=1;
/* Global file descriptor for L2 & L3 */
static int g_fd;
pthread_mutex_t g_logmutex, g_condmutex;
pthread_cond_t g_cond;
-U8 g_writeCirBuf = 0;
+uint8_t g_writeCirBuf = 0;
static int thread_signalled;
#endif
/* TTI Count */
-static U32 numTtiTicks;
+static uint32_t numTtiTicks;
/* Console input handling parameters */
static int g_kIdx, g_action, g_storeKeys;
static char g_keyBuf[32];
/* Standard C library, timezone */
-extern char *tzname[2];
+char *tzname[2];
///////////////////////////////////////////////////////////////////////////////
// FUNCTION DECLARATIONS //
///////////////////////////////////////////////////////////////////////////////
void handleSigIO(int sig);
void rlPrintConfiguration(void);
THREAD_DATA* rlRegisterThread(const char* taskName);
-extern void (*rlSigHandler)(int);
+void (*rlSigHandler)(int);
/* L2 Logging */
void rlInitL2Log(void);
-U32 g_rlogWriteCount = 0;
-U32 g_maxRlogCount = 50;
-U32 g_logsDropCnt = 0;
+uint32_t g_rlogWriteCount = 0;
+uint32_t g_maxRlogCount = 50;
+uint32_t g_logsDropCnt = 0;
RLLogCntLmt g_rlLogCntLimit = RL_LOG_COUNT_LIMIT_STOP;
#ifndef RLOG_ENABLE_TEXT_LOGGING
void readL2LogBuff(void);
S16 rlValidateL2LogBuf(void);
-void rlSetL2LogBuf(U8 *l2LogBuf,U32 l2logLen);
+void rlSetL2LogBuf(uint8_t *l2LogBuf,uint32_t l2logLen);
void rlResetL2LogBuf(void);
#endif
#ifndef RLOG_ENABLE_TEXT_LOGGING
EndianType getCPU_Endian(Void);
void storeFileHeader(FILE* fp);
-void saveLogDataFromCpul(const void* buf, U16 len);
-void saveLogData(const void* buf, U16 len, U32 g_rlogWritePosIndex);
-void sendToPostProcessor(const void* buf, U16 len);
+void saveLogDataFromCpul(const void* buf, uint16_t len);
+void saveLogData(const void* buf, uint16_t len, uint32_t g_rlogWritePosIndex);
+void sendToPostProcessor(const void* buf, uint16_t len);
void getLogTimeStr(char* ts);
#endif
///////////////////////////////////////////////////////////////////////////////////////////////////
// @param[in] modMask - bit mask for any particular module.
// Sets or clears bit for the particular module. If mask value is zero all bits are cleared.
///////////////////////////////////////////////////////////////////////////////////////////////////
-void rlSetModuleMask(U32 modMask)
+void rlSetModuleMask(uint32_t modMask)
{
g_modMask = (modMask == 0 ) ? 0 : (g_modMask ^ modMask);
}
// @param[in] - maxFileSize - Maximum file size in MB.
// @brief This function sets the limit to log file size.
///////////////////////////////////////////////////////////////////////////////////////////////////
-void rlSetLogFileSizeLimit(U32 maxFileSize)
+void rlSetLogFileSizeLimit(uint32_t maxFileSize)
{
g_uiMaxFileSizeLimit = (maxFileSize == 0) ? MAX_FILE_SIZE : maxFileSize*1048576;
}
//
//
///////////////////////////////////////////////////////////////////////////////////////////////////
-void rlSetNumOfLogFiles(U8 nMaxFiles)
+void rlSetNumOfLogFiles(uint8_t nMaxFiles)
{
if( nMaxFiles > RLOG_MAX_FILES || nMaxFiles == 0 ) {
g_nMaxLogFiles = RLOG_MAX_FILES;
// @param[in] port - Server port
// @brief Use this API to configure port for remote logging application.
///////////////////////////////////////////////////////////////////////////////////////////////////
-void rlSetLogPort(U32 port)
+void rlSetLogPort(uint32_t port)
{
g_nLogPort = port;
}
// @param[in] bufSize - Circulaer buffer size in multiples of 1Kb or 1024 bytes.
// This function is called to set circular buffer size for each thread.
///////////////////////////////////////////////////////////////////////////////////////////////////
-void rlSetCircularBufferSize(U32 bufSize)
+void rlSetCircularBufferSize(uint32_t bufSize)
{
g_cirMaxBufferSize = bufSize*1024;
g_cirMaxBufferSize = (g_cirMaxBufferSize/50) * 50;
#define CHECK_FILE_SIZE if( ++g_nWrites == 200 ) \
{ \
g_nWrites = 0; \
- logLev1(L_TIME_REFERENCE, L_ALWAYS, (U32)time(NULL));\
+ logLev1(L_TIME_REFERENCE, L_ALWAYS, (uint32_t)time(NULL));\
}
#else
#define CHECK_FILE_SIZE
createNewLogFile(); \
}\
g_nWrites = 0; \
- logLev1(L_TIME_REFERENCE, L_ALWAYS, (U32)time(NULL));\
+ logLev1(L_TIME_REFERENCE, L_ALWAYS, (uint32_t)time(NULL));\
}
#else
#define CHECK_FILE_SIZE if( ++g_nWrites == 200 ) \
{ \
- if( g_fp && ( (U32)(ftell(g_fp)) > g_uiMaxFileSizeLimit) ) { \
+ if( g_fp && ( (uint32_t)(ftell(g_fp)) > g_uiMaxFileSizeLimit) ) { \
createNewLogFile(); \
}\
g_nWrites = 0; \
pthread_mutex_lock(&g_logmutex);
/* Allocate circular buffer */
- pThrData->logBuff = (U8*) rlAlloc(g_cirMaxBufferSize);
+ pThrData->logBuff = (uint8_t*) rlAlloc(g_cirMaxBufferSize);
if( pThrData->logBuff == NULL ) {
#ifndef ALIGN_64BIT
///////////////////////////////////////////////////////////////////////////////////////////////////
void readCircularBuffers()
{
- U32 i, writerPos;
+ uint32_t i, writerPos;
/* Check if process is L2. If L2 then return from here */
if (SFndProcId() == TENB_L2_PROC_ID)
unsigned short x;
unsigned char c;
- x = 0x0001;;
+ x = 0x0001;
c = *(unsigned char *)(&x);
return ( c == 0x01 ) ? little_endian : big_endian;
// remote application can connect & receive binary logs. If circular buffer is enabled, it creates
// thread key, which is used to store & retrieve thread specific buffers and data.
///////////////////////////////////////////////////////////////////////////////////////////////////
-void rlInitLog(U8 type)
+void rlInitLog(uint8_t type)
{
#ifdef SS_RBUF
/* Initilize the signal handler */
int newsockfd;
int clilen = 0;
int domain = AF_INET;
- memset((void*)&serv_addr, 0, sizeof(serv_addr));
+ memset(&serv_addr, 0, sizeof(serv_addr));
if(gIpType == CM_IPV4ADDR_TYPE)
//
///////////////////////////////////////////////////////////////////////////////////////////////////
void logLevE(PSTR strLogLevel, PSTR modName, PSTR file, int lineno, PSTR fmtStr, R_SPL_ARG splType,
- U32 splVal, U32 arg1, U32 arg2, U32 arg3, U32 arg4, ...)
+ uint32_t splVal, uint32_t arg1, uint32_t arg2, uint32_t arg3, uint32_t arg4, ...)
{
int microseconds=0;
//
//
///////////////////////////////////////////////////////////////////////////////////////////////////
-void logLev1(PSTR strLogLevel, PSTR modName, PSTR file, int lineno, PSTR fmtStr, U32 arg1, ...)
+void logLev1(PSTR strLogLevel, PSTR modName, PSTR file, int lineno, PSTR fmtStr, uint32_t arg1, ...)
{
int microseconds=0;
//
//
///////////////////////////////////////////////////////////////////////////////////////////////////
-void logLev2(PSTR strLogLevel, PSTR modName, PSTR file, int lineno, PSTR fmtStr, U32 arg1, U32 arg2, ...)
+void logLev2(PSTR strLogLevel, PSTR modName, PSTR file, int lineno, PSTR fmtStr, uint32_t arg1, uint32_t arg2, ...)
{
int microseconds=0;
//
///////////////////////////////////////////////////////////////////////////////////////////////////
void logLev3(PSTR strLogLevel, PSTR modName, PSTR file, int lineno, PSTR fmtStr,
- U32 arg1, U32 arg2, U32 arg3, ...)
+ uint32_t arg1, uint32_t arg2, uint32_t arg3, ...)
{
int microseconds=0;
//
///////////////////////////////////////////////////////////////////////////////////////////////////
void logLev4(PSTR strLogLevel, PSTR modName, PSTR file, int lineno, PSTR fmtStr,
- U32 arg1, U32 arg2, U32 arg3, U32 arg4, ...)
+ uint32_t arg1, uint32_t arg2, uint32_t arg3, uint32_t arg4, ...)
{
int microseconds=0;
#define RLOG_SAVE_TIME(_logTime) _logTime.ms_tti=numTtiTicks;
-void saveLogDataFromCpul(const void* buf, U16 len)
+void saveLogDataFromCpul(const void* buf, uint16_t len)
{
#ifdef RLOG_USE_CIRCULAR_BUFFER
THREAD_DATA* p = (THREAD_DATA*) g_pSingCirBuff;
S32 remlen = len-tempLen;
if ((tempLen < 0) || (remlen < 0))
{
- RETVOID;
+ return;
}
if(remlen == 0)
{
/* Copy data till end of the buffer */
memcpy(p->logBuff+p->logBufLen, buf, tempLen);
/* Copy remaining data from the start of buffer */
- memcpy(p->logBuff, ((const U8 *)buf)+tempLen, remlen);
+ memcpy(p->logBuff, ((const uint8_t *)buf)+tempLen, remlen);
/* Store buffer length position */
p->logBufLen = len-tempLen;
}
}
-void saveLogData(const void* buf, U16 len, U32 g_rlogWritePosIndex)
+void saveLogData(const void* buf, uint16_t len, uint32_t g_rlogWritePosIndex)
{
++g_rlogWriteCount ;
return;
}
#ifdef RLOG_USE_CIRCULAR_BUFFER
- U32 logWritePointerPosition;
+ uint32_t logWritePointerPosition;
THREAD_DATA* p = (THREAD_DATA*) g_pSingCirBuff;
/* if buffer is about to full, write till end and continue writing from begining */
}
-void sendToPostProcessor(const void* buf, U16 len)
+void sendToPostProcessor(const void* buf, uint16_t len)
{
if( send(g_nCliSocket, buf, len, 0 ) == -1 ) {
perror("ERROR Sending");
}
void logLevS( LOGID logId, R_LOG_LEVEL logLevel, const char* str, ...)
{
- ARGDATA arg; U16 bufsize;
+ ARGDATA arg; uint16_t bufsize;
RLOG_SAVE_TIME(arg.logData.logTime);
saveLogData((const void*)&arg, bufsize,g_rlogPositionIndex++);
}
-void logLevE(LOGID logId, R_LOG_LEVEL logLevel, R_SPL_ARG splType, U32 splVal, U32 arg1, U32 arg2,
- U32 arg3, U32 arg4, ...)
+void logLevE(LOGID logId, R_LOG_LEVEL logLevel, R_SPL_ARG splType, uint32_t splVal, uint32_t arg1, uint32_t arg2,
+ uint32_t arg3, uint32_t arg4, ...)
{
SPL_ARGDATA arg;
int bufsize;
arg.logData.numOfArgs = 0;
}
- arg.logData.len = sizeof(u_int8_t) + sizeof(U32) + (sizeof(U32)*arg.logData.numOfArgs);
+ arg.logData.len = sizeof(u_int8_t) + sizeof(uint32_t) + (sizeof(uint32_t)*arg.logData.numOfArgs);
arg.splEnum = splType;
arg.splArg = splVal;
saveLogData((const void*)&arg, sizeof(LOGDATA),g_rlogPositionIndex++);
}
-void logLev1( LOGID logId, R_LOG_LEVEL logLevel, U32 arg1, ...)
+void logLev1( LOGID logId, R_LOG_LEVEL logLevel, uint32_t arg1, ...)
{
ARG4DATA arg;
int bufsize;
arg.logData.argType = LOG_ARG_INT;
arg.logData.logLevel = logLevel;
arg.logData.numOfArgs = 1;
- arg.logData.len = sizeof(U32);
+ arg.logData.len = sizeof(uint32_t);
arg.arg1 = arg1;
bufsize = sizeof(LOGDATA)+arg.logData.len;
saveLogData((const void*)&arg, bufsize,g_rlogPositionIndex++);
}
-void logLev2( LOGID logId, R_LOG_LEVEL logLevel, U32 arg1, U32 arg2, ...)
+void logLev2( LOGID logId, R_LOG_LEVEL logLevel, uint32_t arg1, uint32_t arg2, ...)
{
ARG4DATA arg;
int bufsize;
arg.logData.argType = LOG_ARG_INT;
arg.logData.logLevel = logLevel;
arg.logData.numOfArgs = 2;
- arg.logData.len = 2 * sizeof(U32);
+ arg.logData.len = 2 * sizeof(uint32_t);
arg.arg1 = arg1;
arg.arg2 = arg2;
saveLogData((const void*)&arg, bufsize,g_rlogPositionIndex++);
}
-void logLev3( LOGID logId, R_LOG_LEVEL logLevel, U32 arg1, U32 arg2, U32 arg3, ...)
+void logLev3( LOGID logId, R_LOG_LEVEL logLevel, uint32_t arg1, uint32_t arg2, uint32_t arg3, ...)
{
ARG4DATA arg;
int bufsize;
arg.logData.argType = LOG_ARG_INT;
arg.logData.logLevel = logLevel;
arg.logData.numOfArgs = 3;
- arg.logData.len = 3 * sizeof(U32);
+ arg.logData.len = 3 * sizeof(uint32_t);
arg.arg1 = arg1;
arg.arg2 = arg2;
saveLogData((const void*)&arg, bufsize,g_rlogPositionIndex++);
}
-void logLev4( LOGID logId, R_LOG_LEVEL logLevel, U32 arg1, U32 arg2, U32 arg3, U32 arg4, ...)
+void logLev4( LOGID logId, R_LOG_LEVEL logLevel, uint32_t arg1, uint32_t arg2, uint32_t arg3, uint32_t arg4, ...)
{
ARG4DATA arg;
arg.logData.argType = LOG_ARG_INT;
arg.logData.logLevel = logLevel;
arg.logData.numOfArgs = 4;
- arg.logData.len = 4 * sizeof(U32);
+ arg.logData.len = 4 * sizeof(uint32_t);
arg.arg1 = arg1;
arg.arg2 = arg2;
#ifndef RLOG_ENABLE_TEXT_LOGGING
#ifdef RLOG_USE_TTI_LOGGING
- logLev1(L_TIME_REFERENCE, L_ALWAYS, (U32)time(NULL));
+ logLev1(L_TIME_REFERENCE, L_ALWAYS, (uint32_t)time(NULL));
#endif
#endif
}
{
#ifndef RLOG_ENABLE_TEXT_LOGGING
#ifdef RLOG_USE_TTI_LOGGING
- logLev1(L_TIME_TTI_UPDT, L_ALWAYS, (U32)time(NULL));
+ logLev1(L_TIME_TTI_UPDT, L_ALWAYS, (uint32_t)time(NULL));
#endif
#endif
}
*/
#ifdef ANSI
-PUBLIC Void rlProcessLogBufFromL2
+Void rlProcessLogBufFromL2
(
void *mBuf
)
#else
-PUBLIC Void rlProcessLogBufFromL2(mBuf)
+Void rlProcessLogBufFromL2(mBuf)
void *mBuf;
#endif
{
#ifndef RLOG_ENABLE_TEXT_LOGGING
- U32 logLength;
+ uint32_t logLength;
Data* logPtr;
startL2Logging = 1;
if(mBuf == NULL)
{
printf("NULL MBUF received \n");
- RETVOID;
+ return;
}
/* Get Buffer pointer and length. This is SOC specific function which
will extract Log-Buffer pointer and length from mBuf */
rlSetL2LogBuf(logPtr,logLength);
readL2LogBuff();
#endif
- RETVOID;
+ return;
}
/* This function will get tick from RLC/CL and will process logs
according to tick threshold. Tick threshold is SOC specific */
-PUBLIC Void rlProcessTicks(void)
+Void rlProcessTicks(void)
{
- static U32 rlogTickCount;
+ static uint32_t rlogTickCount;
numTtiTicks++;
if(++rlogTickCount >= RLOGTICKSCNTTOPRCL2LOGS)
{
/* L3 specific functions */
}
}
- RETVOID;
+ return;
}
#ifndef RLOG_ENABLE_TEXT_LOGGING
// @out : void
//////////////////////////////////////////////////////////////////////////
-PUBLIC Void readL2LogBuff(void)
+Void readL2LogBuff(void)
{
/* Validate global buffer pointer and length */
- U8 ret;
+ uint8_t ret;
ret = rlValidateL2LogBuf();
if(ret != ROK)
{
rlInvalidateL2LogsInCache(g_logBufRcvdFromL2 - sizeof(g_logBufLenRcvdFromL2) , (g_logBufLenRcvdFromL2 + sizeof(g_logBufLenRcvdFromL2)));
rlResetL2LogBuf();
g_writeCirBuf = 0;
- RETVOID;
+ return;
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
#ifdef ANSI
-PUBLIC S16 rlValidateL2LogBuf(void)
+S16 rlValidateL2LogBuf(void)
#else
-PUBLIC S16 rlValidateL2LogBuf(void)
+S16 rlValidateL2LogBuf(void)
#endif
{
S16 ret = ROK;
//////////////////////////////////////////////////////////////////////////
#ifdef ANSI
-PUBLIC void rlSetL2LogBuf
+void rlSetL2LogBuf
(
-U8 *l2LogBuf,
-U32 l2logLen
+uint8_t *l2LogBuf,
+uint32_t l2logLen
)
#else
-PUBLIC void rlSetL2LogBuf(l2LogBuf,l2logLen)
-U8 *l2LogBuf;
-U32 l2logLen;
+void rlSetL2LogBuf(l2LogBuf,l2logLen)
+uint8_t *l2LogBuf;
+uint32_t l2logLen;
#endif
{
g_logBufRcvdFromL2 = l2LogBuf;
//////////////////////////////////////////////////////////////////////////
#ifdef ANSI
-PUBLIC void rlResetL2LogBuf
+void rlResetL2LogBuf
(
void
)
#else
-PUBLIC void rlResetL2LogBuf(void)
+void rlResetL2LogBuf(void)
#endif
{
g_logBufRcvdFromL2 = NULL;