2021-09-15 17:06:10 -04:00
|
|
|
/*
|
2021-01-05 18:26:07 -05:00
|
|
|
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
2021-09-15 17:06:10 -04:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
// This module implements debug/trace stubs. The stub is a piece of special code which can invoked by OpenOCD
|
|
|
|
// Currently one stub is used for GCOV functionality
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "esp_cpu.h"
|
|
|
|
#include "esp_log.h"
|
2021-01-05 18:26:07 -05:00
|
|
|
#include "riscv/semihosting.h"
|
|
|
|
|
2021-09-15 17:06:10 -04:00
|
|
|
const static char *TAG = "esp_dbg_stubs";
|
|
|
|
|
|
|
|
|
|
|
|
/* Advertises apptrace control block address to host */
|
|
|
|
static int esp_dbg_stubs_advertise_table(void *stub_table_addr)
|
|
|
|
{
|
2022-07-19 01:20:07 -04:00
|
|
|
if (!esp_cpu_dbgr_is_attached()) {
|
2021-09-15 17:06:10 -04:00
|
|
|
return 0;
|
|
|
|
}
|
2022-02-02 14:27:13 -05:00
|
|
|
return (int) semihosting_call_noerrno(ESP_SEMIHOSTING_SYS_DBG_STUBS_INIT, (long*)stub_table_addr);
|
2021-09-15 17:06:10 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void esp_dbg_stubs_ll_init(void *stub_table_addr)
|
|
|
|
{
|
|
|
|
// notify host about control block address
|
|
|
|
int res = esp_dbg_stubs_advertise_table(stub_table_addr);
|
2021-01-05 18:26:07 -05:00
|
|
|
assert(res == 0 && "Failed to send debug stubs table address to host!");
|
2021-09-15 17:06:10 -04:00
|
|
|
ESP_LOGV(TAG, "%s stubs %x", __func__, stub_table_addr);
|
|
|
|
}
|