1 /* 2 * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 // This module implements debug/trace stubs. The stub is a piece of special code which can invoked by OpenOCD 8 // Currently one stub is used for GCOV functionality 9 // 10 11 #include "esp_cpu.h" 12 #include "hal/cpu_hal.h" 13 14 #include "esp_log.h" 15 const static char *TAG = "esp_dbg_stubs"; 16 17 #define RISCV_DBG_STUBS_SYSNR 0x65 18 19 /* Advertises apptrace control block address to host */ esp_dbg_stubs_advertise_table(void * stub_table_addr)20static int esp_dbg_stubs_advertise_table(void *stub_table_addr) 21 { 22 if (!esp_cpu_in_ocd_debug_mode()) { 23 return 0; 24 } 25 return cpu_hal_syscall(RISCV_DBG_STUBS_SYSNR, (int)stub_table_addr, 0, 0, 0, NULL); 26 } 27 esp_dbg_stubs_ll_init(void * stub_table_addr)28void esp_dbg_stubs_ll_init(void *stub_table_addr) 29 { 30 // notify host about control block address 31 int res = esp_dbg_stubs_advertise_table(stub_table_addr); 32 assert(res == 0 && "Falied to send debug stubs table address to host!"); 33 ESP_LOGV(TAG, "%s stubs %x", __func__, stub_table_addr); 34 } 35