#ifndef _PROTO_INCLUDED #define _PROTO_INCLUDED /************************************************************************** Basic types and includes **************************************************************************/ #include #include #ifdef _WIN32 # define PROTOAPI __cdecl #else # define PROTOAPI #endif #ifndef ATTRIBUTE_PRINTF # if defined(__GNUC__) || defined(__clang__) # define ATTRIBUTE_PRINTF(FORMATPOS,FIRSTARGPOS) __attribute__((format (__printf__, FORMATPOS, FIRSTARGPOS))) # else # define ATTRIBUTE_PRINTF(FORMATPOS,FIRSTARGPOS) # endif #endif #ifdef INT8_MIN /* ISO C99 standard types already defined */ #elif defined(_MSC_VER) && _MSC_VER<1600 /* Microsoft Visual C++ (< 2010) (not MinGW) */ typedef signed char int8_t; typedef unsigned char uint8_t; typedef short int16_t; typedef unsigned short uint16_t; typedef int int32_t; typedef unsigned int uint32_t; typedef __int64 int64_t; typedef unsigned __int64 uint64_t; #else # define __STDC_LIMIT_MACROS 1 # define __STDC_CONSTANT_MACROS 1 # if defined(__sun) || defined(__hpux) # include # else # include # endif #endif typedef ptrdiff_t protoSizeT; typedef uint32_t protoWord32; typedef uint64_t protoWord64; typedef int64_t protoTime; /* Brief version history: * * Version 1: initial version * Version 2: available since Apr 2010 * * - Add PROTO_RegisterShareCallback() * - Add PROTO_RegisterProfileChartCallback() * - Add PROTO_FindTrace() * * Version 3: available since Mar 2020 * * - Redefine protoSizeT to always be a 64-bit type on 64-bit platforms. This * change is ABI compatible in both directions. */ #define PROTO_VERSION 3 #define PROTO_MAXLEVELS 16 #define PROTO_MAXCHANNELS 256 #define PROTO_MAXSTRGLEN 4096 struct protoInfo_s; typedef struct protoInfo_s *protoContext; typedef void *protoPtr; #ifdef __cplusplus extern "C" { #endif typedef protoSizeT (PROTOAPI *protoProcessCallback) (protoContext context, protoPtr arrayOut, protoSizeT arrayOutSize, protoPtr arrayIn, protoSizeT arrayInSize, protoPtr localdata); typedef void (PROTOAPI *protoDisplayCallback) (protoContext context, protoPtr data, protoPtr localdata); typedef char const *(PROTOAPI *protoChartCallback) (protoContext context, protoPtr data, protoPtr localdata); typedef int (PROTOAPI *protoDrawCallback) (protoContext context, protoPtr data, protoPtr localdata, int *result); typedef int (PROTOAPI *protoFindCallback) (protoContext context, protoPtr data, protoPtr localdata); typedef void (PROTOAPI *protoExportCallback) (protoContext context, protoPtr data, protoPtr localdata); typedef int (PROTOAPI *protoShareCallback) (protoContext context, protoPtr sharedata, protoPtr localdata); typedef char const *(PROTOAPI *protoProfileChartCallback)(protoContext context, protoPtr data, int *color, protoPtr localdata); /************************************************************************** Time functions (the processing functions are not required) **************************************************************************/ #define PROTO_TIME_ONEMICROSECOND ((protoTime)(50*256)) #define PROTO_TIME_ONEMILLISECOND (PROTO_TIME_ONEMICROSECOND*1000) #define PROTO_TIME_ONESECOND (PROTO_TIME_ONEMICROSECOND*1000000) #define PROTO_TIME_TOINT(x) ((int)(x)) #define PROTO_TIME_DIV(x,y) ((x)/(y)) #define PROTO_TIME_DIVINT(x,y) ((x)/(y)) #define PROTO_TIME_MULT(x,y) ((x)*(y)) #define PROTO_TIME_MULTINT(x,y) ((x)*(y)) #define PROTO_TIME_ADD(x,y) ((x)+(y)) #define PROTO_TIME_SUB(x,y) ((x)-(y)) #define PROTO_TIME_ABS(x) (((x)<0)?-(x):(x)) #define PROTO_TIME_ISSMALLER(x,y) ((x)<(y)) #define PROTO_TIME_ISZERO(x) ((x)==0) /************************************************************************** Library entry and parser function **************************************************************************/ #define PROTO_OK 1 #define PROTO_FAIL -1 #define PROTO_COMMAND_LIST 0 #define PROTO_COMMAND_CHART 1 #define PROTO_COMMAND_DRAW 2 #define PROTO_COMMAND_FIND 3 #define PROTO_COMMAND_FINDNEXT 4 #define PROTO_COMMAND_EXPORT 5 #define PROTO_COMMAND_DISCONFIG 6 extern int PROTOAPI PROTO_Init(protoContext context, int command); /************************************************************************** Parameter Parser functions **************************************************************************/ #define PROTO_PARSE_CHANNEL 0x0100 #define PROTO_PARSE_INTEGER 0x0200 #define PROTO_PARSE_INTEGER64 0x0300 #define PROTO_PARSE_TIME 0x0400 #define PROTO_PARSE_FREQUENCY 0x0500 #define PROTO_PARSE_SELECTION 0x0600 #define PROTO_PARSE_STRING 0x0700 #define PROTO_PARSE_OK 0x0800 #define PROTO_PARSE_OPTIONAL 0x1000 #define PROTO_PARSE_CHECKRANGE 0x2000 extern void PROTOAPI PROTO_Parse(protoContext context, protoPtr result, const char * names, int flags); extern int PROTOAPI PROTO_RequestVersion(protoContext context, int version); /************************************************************************** Generic functions **************************************************************************/ extern void * PROTOAPI PROTO_Alloc(protoContext context, protoSizeT size); extern void PROTOAPI PROTO_Free(protoContext context, void * ptr); extern void PROTOAPI PROTO_SetDefaultLevel(protoContext context, int level); /************************************************************************** Callback register functions **************************************************************************/ #define PROTO_PROCESS_OUTOFMEMORY -1 #define PROTO_PROCESS_CANCEL -2 #define PROTO_PROCESS_ENDOFTRACE -3 #define PROTO_NOTFOUND 0 #define PROTO_FOUND 1 extern void PROTOAPI PROTO_RegisterProcessCallback(protoContext context, protoProcessCallback callback, protoPtr localdata, protoSizeT size, int flags); extern void PROTOAPI PROTO_RegisterDisplayCallback(protoContext context, protoDisplayCallback callback, protoPtr localdata, int flags); extern void PROTOAPI PROTO_RegisterChartCallback(protoContext context, protoChartCallback callback, protoPtr localdata, int flags); extern void PROTOAPI PROTO_RegisterProfileChartCallback(protoContext context, protoProfileChartCallback callback, protoPtr localdata, int flags); extern void PROTOAPI PROTO_RegisterDrawCallback(protoContext context, protoDrawCallback callback, protoPtr localdata, int flags, int channels, int low, int high); extern void PROTOAPI PROTO_RegisterFindCallback(protoContext context, protoFindCallback callback, protoPtr localdata, int flags); extern void PROTOAPI PROTO_RegisterExportCallback(protoContext context, protoExportCallback callback, protoPtr localdata, int flags); extern void PROTOAPI PROTO_RegisterShareCallback(protoContext context, protoShareCallback callback, protoPtr localdata, int flags); /************************************************************************** Functions callable from processing function **************************************************************************/ extern int PROTOAPI PROTO_Cancel(protoContext context); extern protoSizeT PROTOAPI PROTO_ReadTrace(protoContext context, protoSizeT index, protoTime * timestamp, int * data); extern protoSizeT PROTOAPI PROTO_FindTrace(protoContext context, protoSizeT index, int signal, protoTime * timestamp, int * data); /************************************************************************** Output functions for LIST command **************************************************************************/ #define PROTO_ATTRIBUTE_LEVEL0 0 #define PROTO_ATTRIBUTE_LEVEL1 1 #define PROTO_ATTRIBUTE_LEVEL2 2 #define PROTO_ATTRIBUTE_LEVEL3 3 #define PROTO_ATTRIBUTE_LEVEL4 4 #define PROTO_ATTRIBUTE_LEVEL5 5 #define PROTO_ATTRIBUTE_NORM 16 #define PROTO_ATTRIBUTE_LIGHT 17 #define PROTO_ATTRIBUTE_BOLD 18 #define PROTO_ATTRIBUTE_ERROR 19 #define PROTO_ATTRIBUTE_ASCII 20 #define PROTO_CONTROL_LINEFEED 30 #define PROTO_CONTROL_INDENT 31 #define PROTO_CONTROL_LINETILLEND 32 #define PROTO_CONTROL_PRINTNIL 33 #define PROTO_ATTRIBUTE_COLOR_BLACK 64 #define PROTO_ATTRIBUTE_COLOR_MAROON 65 #define PROTO_ATTRIBUTE_COLOR_GREEN 66 #define PROTO_ATTRIBUTE_COLOR_OLIVE 67 #define PROTO_ATTRIBUTE_COLOR_NAVY 68 #define PROTO_ATTRIBUTE_COLOR_PURPLE 69 #define PROTO_ATTRIBUTE_COLOR_TEAL 70 #define PROTO_ATTRIBUTE_COLOR_SILVER 71 #define PROTO_ATTRIBUTE_COLOR_GRAY 72 #define PROTO_ATTRIBUTE_COLOR_RED 73 #define PROTO_ATTRIBUTE_COLOR_LIME 74 #define PROTO_ATTRIBUTE_COLOR_YELLOW 75 #define PROTO_ATTRIBUTE_COLOR_BLUE 76 #define PROTO_ATTRIBUTE_COLOR_FUCHSIA 78 #define PROTO_ATTRIBUTE_COLOR_AQUA 79 #define PROTO_ATTRIBUTE_COLOR_WHITE 80 #define PROTO_ATTRIBUTE_COLOR0 64 #define PROTO_ATTRIBUTE_COLOR31 95 #define PROTO_ATTRIBUTE_BGCOLOR0 96 #define PROTO_ATTRIBUTE_BGCOLOR31 127 #define PROTO_ATTRIBUTE_CUSTOM0 256 #define PROTO_ATTRIBUTE_CUSTOM511 767 extern void PROTOAPI PROTO_Puts(protoContext context, const char *text); extern void PROTOAPI PROTO_Printf(protoContext context, const char *format, ...) ATTRIBUTE_PRINTF(2, 3); extern void PROTOAPI PROTO_Control(protoContext context, int controlcode); typedef struct { protoTime time; protoWord32 cycle; unsigned char datamask; unsigned char resv1; unsigned char flags; unsigned char resv2; protoWord64 address; protoWord64 data; } protoDiscycle, * protoDiscyclePtr; #define PROTO_DISCYCLE_FETCH 0x00000002 #define PROTO_DISCYCLE_READ 0x00000001 #define PROTO_DISCYCLE_READWIDE 0x00000101 #define PROTO_DISCYCLE_READORFETCH 0x00002001 #define PROTO_DISCYCLE_READORFETCHWIDE 0x00002101 #define PROTO_DISCYCLE_WRITE 0x00000041 /************************************************************************** End of Include **************************************************************************/ #ifdef __cplusplus } #endif #endif