target/esp_xtensa: add xtensa on_halt handler

Right after target halt, some activities needs to be done
such as printing exception reason, disable wdts and reading
debug stubs information.
Missing activities will be submitted in the next patches.

Signed-off-by: Erhan Kurubas <erhan.kurubas@espressif.com>
Change-Id: I27aad5614d903f4bd7c8d6dba6bfb0bdb93ed8dc
Reviewed-on: https://review.openocd.org/c/openocd/+/7757
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Tested-by: jenkins
This commit is contained in:
Erhan Kurubas 2023-07-04 18:40:36 +02:00 committed by Antonio Borneo
parent 78daf24a5c
commit 29b02402ff
7 changed files with 35 additions and 3 deletions

View File

@ -266,7 +266,10 @@ static int esp32_disable_wdts(struct target *target)
static int esp32_on_halt(struct target *target)
{
return esp32_disable_wdts(target);
int ret = esp32_disable_wdts(target);
if (ret == ERROR_OK)
ret = esp_xtensa_smp_on_halt(target);
return ret;
}
static int esp32_arch_state(struct target *target)

View File

@ -385,7 +385,10 @@ static int esp32s2_arch_state(struct target *target)
static int esp32s2_on_halt(struct target *target)
{
return esp32s2_disable_wdts(target);
int ret = esp32s2_disable_wdts(target);
if (ret == ERROR_OK)
ret = esp_xtensa_on_halt(target);
return ret;
}
static int esp32s2_step(struct target *target, int current, target_addr_t address, int handle_breakpoints)

View File

@ -283,7 +283,10 @@ static int esp32s3_disable_wdts(struct target *target)
static int esp32s3_on_halt(struct target *target)
{
return esp32s3_disable_wdts(target);
int ret = esp32s3_disable_wdts(target);
if (ret == ERROR_OK)
ret = esp_xtensa_smp_on_halt(target);
return ret;
}
static int esp32s3_arch_state(struct target *target)

View File

@ -17,6 +17,12 @@
#include "esp_xtensa.h"
#include "esp_semihosting.h"
int esp_xtensa_on_halt(struct target *target)
{
/* will be used in the next patches */
return ERROR_OK;
}
int esp_xtensa_init_arch_info(struct target *target,
struct esp_xtensa_common *esp_xtensa,
struct xtensa_debug_module_config *dm_cfg,

View File

@ -36,5 +36,6 @@ void esp_xtensa_queue_tdi_idle(struct target *target);
int esp_xtensa_breakpoint_add(struct target *target, struct breakpoint *breakpoint);
int esp_xtensa_breakpoint_remove(struct target *target, struct breakpoint *breakpoint);
int esp_xtensa_poll(struct target *target);
int esp_xtensa_on_halt(struct target *target);
#endif /* OPENOCD_TARGET_ESP_XTENSA_H */

View File

@ -112,6 +112,21 @@ int esp_xtensa_smp_soft_reset_halt(struct target *target)
return ERROR_OK;
}
int esp_xtensa_smp_on_halt(struct target *target)
{
struct target_list *head;
if (!target->smp)
return esp_xtensa_on_halt(target);
foreach_smp_target(head, target->smp_targets) {
int res = esp_xtensa_on_halt(head->target);
if (res != ERROR_OK)
return res;
}
return ERROR_OK;
}
static struct target *get_halted_esp_xtensa_smp(struct target *target, int32_t coreid)
{
struct target_list *head;

View File

@ -37,6 +37,7 @@ int esp_xtensa_smp_step(struct target *target,
int esp_xtensa_smp_assert_reset(struct target *target);
int esp_xtensa_smp_deassert_reset(struct target *target);
int esp_xtensa_smp_soft_reset_halt(struct target *target);
int esp_xtensa_smp_on_halt(struct target *target);
int esp_xtensa_smp_watchpoint_add(struct target *target, struct watchpoint *watchpoint);
int esp_xtensa_smp_watchpoint_remove(struct target *target, struct watchpoint *watchpoint);
int esp_xtensa_smp_handle_target_event(struct target *target, enum target_event event, void *priv);