target/espressif: add semihosting support
[fw/openocd] / src / target / espressif / esp_semihosting.h
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2
3 /***************************************************************************
4  *   Semihosting API for Espressif chips                                   *
5  *   Copyright (C) 2022 Espressif Systems Ltd.                             *
6  ***************************************************************************/
7
8 #ifndef OPENOCD_TARGET_ESP_SEMIHOSTING_H
9 #define OPENOCD_TARGET_ESP_SEMIHOSTING_H
10
11 /* Legacy syscalls */
12 #define ESP_SYS_DRV_INFO_LEGACY                     0xE0
13
14 /* syscalls compatible to ARM standard */
15 #define ESP_SEMIHOSTING_SYS_DRV_INFO                0x100
16 #define ESP_SEMIHOSTING_SYS_APPTRACE_INIT           0x101
17 #define ESP_SEMIHOSTING_SYS_DEBUG_STUBS_INIT        0x102
18 #define ESP_SEMIHOSTING_SYS_BREAKPOINT_SET          0x103
19 #define ESP_SEMIHOSTING_SYS_WATCHPOINT_SET          0x104
20 #define ESP_SEMIHOSTING_SYS_SEEK                    0x105       /* custom lseek with whence */
21 /* not implemented yet */
22 #define ESP_SEMIHOSTING_SYS_MKDIR                   0x106
23 #define ESP_SEMIHOSTING_SYS_OPENDIR                 0x107
24 #define ESP_SEMIHOSTING_SYS_READDIR                 0x108
25 #define ESP_SEMIHOSTING_SYS_READDIR_R               0x109
26 #define ESP_SEMIHOSTING_SYS_SEEKDIR                 0x10A
27 #define ESP_SEMIHOSTING_SYS_TELLDIR                 0x10B
28 #define ESP_SEMIHOSTING_SYS_CLOSEDIR                0x10C
29 #define ESP_SEMIHOSTING_SYS_RMDIR                   0x10D
30 #define ESP_SEMIHOSTING_SYS_ACCESS                  0x10E
31 #define ESP_SEMIHOSTING_SYS_TRUNCATE                0x10F
32 #define ESP_SEMIHOSTING_SYS_UTIME                   0x110
33 #define ESP_SEMIHOSTING_SYS_FSTAT                   0x111
34 #define ESP_SEMIHOSTING_SYS_STAT                    0x112
35 #define ESP_SEMIHOSTING_SYS_FSYNC                   0x113
36 #define ESP_SEMIHOSTING_SYS_LINK                    0x114
37 #define ESP_SEMIHOSTING_SYS_UNLINK                  0x115
38
39 /**
40  * Semihost calls handling operations.
41  */
42 struct esp_semihost_ops {
43         /** Callback called before handling semihost call */
44         int (*prepare)(struct target *target);
45 };
46
47 struct esp_semihost_data {
48         bool need_resume;
49         struct esp_semihost_ops *ops;
50 };
51
52 int esp_semihosting_common(struct target *target);
53 int esp_semihosting_basedir_command(struct command_invocation *cmd);
54
55 #endif  /* OPENOCD_TARGET_ESP_SEMIHOSTING_H */