• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 #ifndef __TRAX_H__
15 #define __TRAX_H__
16 
17 #include "sdkconfig.h"
18 #include "esp_err.h"
19 #include "eri.h"
20 #include "xtensa-debug-module.h"
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif /* __cplusplus */
25 
26 
27 typedef enum {
28     TRAX_DOWNCOUNT_WORDS,
29     TRAX_DOWNCOUNT_INSTRUCTIONS
30 } trax_downcount_unit_t;
31 
32 typedef enum {
33     TRAX_ENA_NONE = 0,
34     TRAX_ENA_PRO,
35     TRAX_ENA_APP,
36     TRAX_ENA_PRO_APP,
37     TRAX_ENA_PRO_APP_SWAP
38 } trax_ena_select_t;
39 
40 
41 /**
42  * @brief  Enable the trax memory blocks to be used as Trax memory.
43  *
44  * @param  pro_cpu_enable : true if Trax needs to be enabled for the pro CPU
45  * @param  app_cpu_enable : true if Trax needs to be enabled for the pro CPU
46  * @param  swap_regions : Normally, the pro CPU writes to Trax mem block 0 while
47  *                        the app cpu writes to block 1. Setting this to true
48  *                        inverts this.
49  *
50  * @return esp_err_t. Fails with ESP_ERR_NO_MEM if Trax enable is requested for 2 CPUs
51  *                    but memmap only has room for 1, or if Trax memmap is disabled
52  *                    entirely.
53  */
54 int trax_enable(trax_ena_select_t ena);
55 
56 /**
57  * @brief  Start a Trax trace on the current CPU
58  *
59  * @param  units_until_stop : Set the units of the delay that gets passed to
60  *              trax_trigger_traceend_after_delay. One of TRAX_DOWNCOUNT_WORDS
61  *              or TRAX_DOWNCOUNT_INSTRUCTIONS.
62  *
63  * @return esp_err_t. Fails with ESP_ERR_NO_MEM if Trax is disabled.
64  */
65 int trax_start_trace(trax_downcount_unit_t units_until_stop);
66 
67 
68 /**
69  * @brief  Trigger a Trax trace stop after the indicated delay. If this is called
70  *         before and the previous delay hasn't ended yet, this will overwrite
71  *         that delay with the new value. The delay will always start at the time
72  *         the function is called.
73  *
74  * @param  delay : The delay to stop the trace in, in the unit indicated to
75  *              trax_start_trace. Note: the trace memory has 4K words available.
76  *
77  * @return esp_err_t
78  */
79 int trax_trigger_traceend_after_delay(int delay);
80 
81 
82 #ifdef __cplusplus
83 }
84 #endif /* __cplusplus */
85 #endif /* __TRAX_H__ */