2024-01-29 13:51:15 +08:00
|
|
|
/***************************************************************************
|
|
|
|
* Copyright (c) 2024 Microsoft Corporation
|
|
|
|
*
|
|
|
|
* This program and the accompanying materials are made available under the
|
|
|
|
* terms of the MIT License which is available at
|
|
|
|
* https://opensource.org/licenses/MIT.
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
**************************************************************************/
|
2021-06-02 06:45:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************************/
|
|
|
|
/**************************************************************************/
|
|
|
|
/** */
|
|
|
|
/** ThreadX Component */
|
|
|
|
/** */
|
|
|
|
/** Execution Profile Kit */
|
|
|
|
/** */
|
|
|
|
/**************************************************************************/
|
|
|
|
/**************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef TX_EXECUTION_PROFILE_H
|
|
|
|
#define TX_EXECUTION_PROFILE_H
|
|
|
|
|
|
|
|
|
|
|
|
/* The thread execution profile kit is designed to track thread execution time
|
|
|
|
based on the hardware timer defined by TX_EXECUTION_TIME_SOURCE and
|
|
|
|
TX_EXECUTION_MAX_TIME_SOURCE below. When the thread's total time reaches
|
|
|
|
the maximum value, it remains there until the time is reset to 0 via a call
|
|
|
|
to tx_thread_execution_time_reset. There are several assumptions to the
|
|
|
|
operation of this kit, as follows:
|
|
|
|
|
|
|
|
1. The TX_EXECUTION_TIME_SOURCE and TX_EXECUTION_MAX_TIME_SOURCE macros are
|
|
|
|
defined to utilize a local hardware time source.
|
|
|
|
|
|
|
|
2. The following routines are called from assembly code:
|
|
|
|
VOID _tx_execution_thread_enter(void);
|
|
|
|
VOID _tx_execution_thread_exit(void);
|
|
|
|
VOID _tx_execution_isr_enter(void);
|
|
|
|
VOID _tx_execution_isr_exit(void);
|
|
|
|
|
|
|
|
3. The ThreadX library must be rebuilt with TX_EXECUTION_PROFILE_ENABLE so
|
|
|
|
the assembly code macros are enabled to call the execution profile routines.
|
|
|
|
|
|
|
|
4. Add tx_execution_profile.c to the application build. */
|
|
|
|
|
|
|
|
/* Define the basic time typedefs for 64-bit accumulation and a 32-bit timer source, which is the
|
|
|
|
most common configuration. */
|
|
|
|
|
|
|
|
typedef unsigned long long EXECUTION_TIME;
|
|
|
|
typedef unsigned long EXECUTION_TIME_SOURCE_TYPE;
|
|
|
|
/* For 64-bit time source, the typedef would be: */
|
|
|
|
/* typedef unsigned long long EXECUTION_TIME_SOURCE_TYPE; */
|
|
|
|
|
|
|
|
/* Define basic constants for the execution profile kit. */
|
|
|
|
|
|
|
|
/* Example for Cortex-M targets: */
|
|
|
|
#ifndef TX_EXECUTION_TIME_SOURCE
|
2022-04-20 05:07:02 +00:00
|
|
|
#define TX_EXECUTION_TIME_SOURCE (EXECUTION_TIME_SOURCE_TYPE) *((volatile ULONG *) 0xE0001004)
|
2021-06-02 06:45:05 +00:00
|
|
|
#endif
|
|
|
|
#ifndef TX_EXECUTION_MAX_TIME_SOURCE
|
|
|
|
#define TX_EXECUTION_MAX_TIME_SOURCE 0xFFFFFFFF
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* For 64-bit time source, the constant would be: */
|
2022-04-20 05:07:02 +00:00
|
|
|
/*#define TX_EXECUTION_TIME_SOURCE (EXECUTION_TIME_SOURCE_TYPE) *((volatile unsigned long long *) 0xE0001004) */
|
2021-06-02 06:45:05 +00:00
|
|
|
/*#define TX_EXECUTION_MAX_TIME_SOURCE 0xFFFFFFFFFFFFFFFF */
|
|
|
|
|
|
|
|
|
|
|
|
/* Define APIs of the execution profile kit. */
|
|
|
|
|
|
|
|
struct TX_THREAD_STRUCT;
|
2022-04-20 05:07:02 +00:00
|
|
|
VOID _tx_execution_initialize(void);
|
2021-06-02 06:45:05 +00:00
|
|
|
VOID _tx_execution_thread_enter(void);
|
|
|
|
VOID _tx_execution_thread_exit(void);
|
|
|
|
VOID _tx_execution_isr_enter(void);
|
|
|
|
VOID _tx_execution_isr_exit(void);
|
|
|
|
UINT _tx_execution_thread_time_reset(struct TX_THREAD_STRUCT *thread_ptr);
|
|
|
|
UINT _tx_execution_thread_total_time_reset(void);
|
|
|
|
UINT _tx_execution_isr_time_reset(void);
|
|
|
|
UINT _tx_execution_idle_time_reset(void);
|
|
|
|
UINT _tx_execution_thread_time_get(struct TX_THREAD_STRUCT *thread_ptr, EXECUTION_TIME *total_time);
|
|
|
|
UINT _tx_execution_thread_total_time_get(EXECUTION_TIME *total_time);
|
|
|
|
UINT _tx_execution_isr_time_get(EXECUTION_TIME *total_time);
|
|
|
|
UINT _tx_execution_idle_time_get(EXECUTION_TIME *total_time);
|
|
|
|
|
|
|
|
#endif
|