#ifndef TX_EXECUTION_PROFILE_H
#define TX_EXECUTION_PROFILE_H

#if defined(TX_EXECUTION_PROFILE_ENABLE)

#define THREAD_TRACE_SIZE 100

typedef struct
{
  void*           thrd;
  unsigned        Tenter;
  unsigned        Texit;
} thread_trace;

extern const signed       ThreadTraceSize;
extern thread_trace       ThreadTrace[THREAD_TRACE_SIZE];
extern signed             ThreadTraceHead;
extern signed             ThreadTraceTail;
extern unsigned char      ThreadTraceFreeze;

extern unsigned           RTOS_Tstart;
extern unsigned           RTOS_Tmax;
extern unsigned           RTOS_Tused;
extern unsigned           RTOS_Calls;

typedef struct EXECUTION_TIME_STRUCT
{
  unsigned            T;
  unsigned            Tmax;
  unsigned            Tused;
  unsigned            Calls;
  unsigned            Pad;
  signed              Percent;
  unsigned            SavedTmax;
  unsigned            SavedTused;
  unsigned            SavedCalls;
} EXECUTION_TIME;

typedef struct EXECUTION_TIME_SOURCE_TYPE_STRUCT
{
  char                Pad;
} EXECUTION_TIME_SOURCE_TYPE;


extern void tx_reset_timing(unsigned* Tlast, unsigned* Tnow);

extern VOID _tx_execution_initialize(VOID);
extern VOID _tx_execution_thread_enter(VOID);
extern VOID _tx_execution_thread_exit(VOID);

extern VOID _tx_execution_isr_enter(VOID);
extern VOID _tx_execution_isr_exit(VOID);

#endif // defined(TX_EXECUTION_PROFILE_ENABLE)

#endif // TX_EXECUTION_PROFILE_H

