target/espressif: read entry addresses of pre-defined stub functions
[openocd.git] / src / target / espressif / esp.h
diff --git a/src/target/espressif/esp.h b/src/target/espressif/esp.h
new file mode 100644 (file)
index 0000000..3ba2b8b
--- /dev/null
@@ -0,0 +1,85 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+/***************************************************************************
+ *   Espressif chips common target API for OpenOCD                         *
+ *   Copyright (C) 2021 Espressif Systems Ltd.                             *
+ ***************************************************************************/
+
+#ifndef OPENOCD_TARGET_ESP_H
+#define OPENOCD_TARGET_ESP_H
+
+#include <stdint.h>
+#include <helper/bits.h>
+
+/* must be in sync with ESP-IDF version */
+/** Size of the pre-compiled target buffer for stub trampoline.
+ * @note Must be in sync with ESP-IDF version */
+#define ESP_DBG_STUBS_CODE_BUF_SIZE         32 /* TODO: move this info to esp_dbg_stubs_desc */
+/** Size of the pre-compiled target buffer for stack.
+ * @note Must be in sync with ESP-IDF version */
+#define ESP_DBG_STUBS_STACK_MIN_SIZE        2048/* TODO: move this info to esp_dbg_stubs_desc */
+
+/**
+ * Debug stubs table entries IDs
+ *
+ * @note Must be in sync with ESP-IDF version
+ */
+enum esp_dbg_stub_id {
+       ESP_DBG_STUB_ENTRY_MAGIC_NUM,
+       ESP_DBG_STUB_TABLE_SIZE,
+       ESP_DBG_STUB_TABLE_START,
+       ESP_DBG_STUB_DESC = ESP_DBG_STUB_TABLE_START,   /*< Stubs descriptor ID */
+       ESP_DBG_STUB_ENTRY_FIRST,
+       ESP_DBG_STUB_ENTRY_GCOV = ESP_DBG_STUB_ENTRY_FIRST,     /*< GCOV stub ID */
+       ESP_DBG_STUB_CAPABILITIES,
+       /* add new stub entries here */
+       ESP_DBG_STUB_ENTRY_MAX,
+};
+
+#define ESP_DBG_STUB_MAGIC_NUM_VAL      0xFEEDBEEF
+#define ESP_DBG_STUB_CAP_GCOV_THREAD    BIT(0)
+
+/**
+ * Debug stubs descriptor. ID: ESP_DBG_STUB_DESC
+ *
+ * @note Must be in sync with ESP-IDF version
+ */
+struct esp_dbg_stubs_desc {
+       /** Address of pre-compiled target buffer for stub trampoline.
+        * Size of the buffer is ESP_DBG_STUBS_CODE_BUF_SIZE
+        */
+       uint32_t tramp_addr;
+       /** Pre-compiled target buffer's addr for stack. The size of the buffer is ESP_DBG_STUBS_STACK_MIN_SIZE.
+        * Target has the buffer which is used for the stack of onboard algorithms.
+        * If stack size required by algorithm exceeds ESP_DBG_STUBS_STACK_MIN_SIZE,
+        * it should be allocated using onboard function pointed by 'data_alloc' and
+        * freed by 'data_free'. They fit to the minimal stack. See below.
+        */
+       uint32_t min_stack_addr;
+       /** Address of malloc-like function to allocate buffer on target. */
+       uint32_t data_alloc;
+       /** Address of free-like function to free buffer allocated with data_alloc. */
+       uint32_t data_free;
+};
+
+/**
+ * Debug stubs info.
+ */
+struct esp_dbg_stubs {
+       /** Address. */
+       uint32_t base;
+       /** Table contents. */
+       uint32_t entries[ESP_DBG_STUB_ENTRY_MAX];
+       /** Number of table entries. */
+       uint32_t entries_count;
+       /** Debug stubs decsriptor. */
+       struct esp_dbg_stubs_desc desc;
+};
+
+struct esp_common {
+       struct esp_dbg_stubs dbg_stubs;
+};
+
+int esp_dbgstubs_table_read(struct target *target, struct esp_dbg_stubs *dbg_stubs);
+
+#endif /* OPENOCD_TARGET_ESP_H */

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)