mirror of
https://github.com/espressif/esp-idf.git
synced 2026-08-18 06:35:35 +03:00
xtensa: move out trax
This commit is contained in:
88
components/esp_system/port/arch/xtensa/trax.c
Normal file
88
components/esp_system/port/arch/xtensa/trax.c
Normal file
@@ -0,0 +1,88 @@
|
||||
|
||||
// Copyright 2020 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <stdio.h>
|
||||
#include "esp_err.h"
|
||||
#include "esp_log.h"
|
||||
#include "xt_trax.h"
|
||||
#include "trax.h"
|
||||
#include "hal/trace_ll.h"
|
||||
#include "soc/dport_reg.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
// Utility functions for enabling TRAX in early startup (hence the use
|
||||
// of ESP_EARLY_LOGX) in Xtensa targets.
|
||||
|
||||
#if defined(CONFIG_ESP32_TRAX) || defined(CONFIG_ESP32S2_TRAX)
|
||||
#define WITH_TRAX 1
|
||||
#endif
|
||||
|
||||
static const char* __attribute__((unused)) TAG = "trax";
|
||||
|
||||
int trax_enable(trax_ena_select_t which)
|
||||
{
|
||||
#if !WITH_TRAX
|
||||
ESP_EARLY_LOGE(TAG, "trax_enable called, but trax is disabled in menuconfig!");
|
||||
return ESP_ERR_NO_MEM;
|
||||
#endif
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
#ifndef CONFIG_ESP32_TRAX_TWOBANKS
|
||||
if (which == TRAX_ENA_PRO_APP || which == TRAX_ENA_PRO_APP_SWAP) return ESP_ERR_NO_MEM;
|
||||
#endif
|
||||
if (which == TRAX_ENA_PRO_APP || which == TRAX_ENA_PRO_APP_SWAP) {
|
||||
trace_ll_set_mode((which == TRAX_ENA_PRO_APP_SWAP)?TRACEMEM_MUX_PROBLK1_APPBLK0:TRACEMEM_MUX_PROBLK0_APPBLK1);
|
||||
} else {
|
||||
trace_ll_set_mode(TRACEMEM_MUX_BLK0_ONLY);
|
||||
}
|
||||
trace_ll_mem_enable(0, (which == TRAX_ENA_PRO_APP || which == TRAX_ENA_PRO_APP_SWAP || which == TRAX_ENA_PRO));
|
||||
trace_ll_mem_enable(1, (which == TRAX_ENA_PRO_APP || which == TRAX_ENA_PRO_APP_SWAP || which == TRAX_ENA_APP));
|
||||
return ESP_OK;
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
|
||||
if (which != TRAX_ENA_PRO) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
trace_ll_set_mem_block(TRACEMEM_MUX_BLK1_NUM);
|
||||
return ESP_OK;
|
||||
#endif
|
||||
}
|
||||
|
||||
int trax_start_trace(trax_downcount_unit_t units_until_stop)
|
||||
{
|
||||
#if !WITH_TRAX
|
||||
ESP_EARLY_LOGE(TAG, "trax_start_trace called, but trax is disabled in menuconfig!");
|
||||
return ESP_ERR_NO_MEM;
|
||||
#endif
|
||||
if (xt_trax_trace_is_active()) {
|
||||
ESP_EARLY_LOGI(TAG, "Stopping active trace first.");
|
||||
//Trace is active. Stop trace.
|
||||
xt_trax_trigger_traceend_after_delay(0);
|
||||
}
|
||||
if (units_until_stop == TRAX_DOWNCOUNT_INSTRUCTIONS) {
|
||||
xt_trax_start_trace_instructions();
|
||||
} else {
|
||||
xt_trax_start_trace_words();
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
int trax_trigger_traceend_after_delay(int delay)
|
||||
{
|
||||
#if !WITH_TRAX
|
||||
ESP_EARLY_LOGE(TAG, "trax_trigger_traceend_after_delay called, but trax is disabled in menuconfig!");
|
||||
return ESP_ERR_NO_MEM;
|
||||
#endif
|
||||
xt_trax_trigger_traceend_after_delay(delay);
|
||||
return ESP_OK;
|
||||
}
|
||||
72
components/esp_system/port/include/trax.h
Normal file
72
components/esp_system/port/include/trax.h
Normal file
@@ -0,0 +1,72 @@
|
||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_err.h"
|
||||
#include "eri.h"
|
||||
#include "xtensa-debug-module.h"
|
||||
#include "xt_trax.h"
|
||||
|
||||
typedef enum {
|
||||
TRAX_DOWNCOUNT_WORDS,
|
||||
TRAX_DOWNCOUNT_INSTRUCTIONS
|
||||
} trax_downcount_unit_t;
|
||||
|
||||
typedef enum {
|
||||
TRAX_ENA_NONE = 0,
|
||||
TRAX_ENA_PRO,
|
||||
TRAX_ENA_APP,
|
||||
TRAX_ENA_PRO_APP,
|
||||
TRAX_ENA_PRO_APP_SWAP
|
||||
} trax_ena_select_t;
|
||||
|
||||
/**
|
||||
* @brief Enable the trax memory blocks to be used as Trax memory.
|
||||
*
|
||||
* @param pro_cpu_enable : true if Trax needs to be enabled for the pro CPU
|
||||
* @param app_cpu_enable : true if Trax needs to be enabled for the pro CPU
|
||||
* @param swap_regions : Normally, the pro CPU writes to Trax mem block 0 while
|
||||
* the app cpu writes to block 1. Setting this to true
|
||||
* inverts this.
|
||||
*
|
||||
* @return esp_err_t. Fails with ESP_ERR_NO_MEM if Trax enable is requested for 2 CPUs
|
||||
* but memmap only has room for 1, or if Trax memmap is disabled
|
||||
* entirely.
|
||||
*/
|
||||
int trax_enable(trax_ena_select_t ena);
|
||||
|
||||
/**
|
||||
* @brief Start a Trax trace on the current CPU
|
||||
*
|
||||
* @param units_until_stop : Set the units of the delay that gets passed to
|
||||
* trax_trigger_traceend_after_delay. One of TRAX_DOWNCOUNT_WORDS
|
||||
* or TRAX_DOWNCOUNT_INSTRUCTIONS.
|
||||
*
|
||||
* @return esp_err_t. Fails with ESP_ERR_NO_MEM if Trax is disabled.
|
||||
*/
|
||||
int trax_start_trace(trax_downcount_unit_t units_until_stop);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Trigger a Trax trace stop after the indicated delay. If this is called
|
||||
* before and the previous delay hasn't ended yet, this will overwrite
|
||||
* that delay with the new value. The delay will always start at the time
|
||||
* the function is called.
|
||||
*
|
||||
* @param delay : The delay to stop the trace in, in the unit indicated to
|
||||
* trax_start_trace. Note: the trace memory has 4K words available.
|
||||
*
|
||||
* @return esp_err_t
|
||||
*/
|
||||
int trax_trigger_traceend_after_delay(int delay);
|
||||
@@ -7,6 +7,7 @@ set(srcs "dport_panic_highint_hdl.S"
|
||||
"../../arch/xtensa/expression_with_stack_asm.S"
|
||||
"../../arch/xtensa/debug_helpers.c"
|
||||
"../../arch/xtensa/debug_helpers_asm.S"
|
||||
"../../arch/xtensa/trax.c"
|
||||
)
|
||||
add_prefix(srcs "${CMAKE_CURRENT_LIST_DIR}/" ${srcs})
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ set(srcs "async_memcpy_impl_cp_dma.c"
|
||||
"../../arch/xtensa/expression_with_stack_asm.S"
|
||||
"../../arch/xtensa/debug_helpers.c"
|
||||
"../../arch/xtensa/debug_helpers_asm.S"
|
||||
"../../arch/xtensa/trax.c"
|
||||
)
|
||||
add_prefix(srcs "${CMAKE_CURRENT_LIST_DIR}/" ${srcs})
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ set(srcs "dport_panic_highint_hdl.S"
|
||||
"../../arch/xtensa/expression_with_stack_asm.S"
|
||||
"../../arch/xtensa/debug_helpers.c"
|
||||
"../../arch/xtensa/debug_helpers_asm.S"
|
||||
"../../arch/xtensa/trax.c"
|
||||
)
|
||||
add_prefix(srcs "${CMAKE_CURRENT_LIST_DIR}/" ${srcs})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user