OpenOCD
semihosting_common.h File Reference
Include dependency graph for semihosting_common.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  semihosting
 

Macros

#define SEMIHOSTING_MAX_TCL_COMMAND_FIELD_LENGTH   (1024 * 1024)
 Maximum allowed Tcl command segment length in bytes. More...
 

Enumerations

enum  semihosting_operation_numbers {
  SEMIHOSTING_ENTER_SVC = 0x17 , SEMIHOSTING_SYS_CLOSE = 0x02 , SEMIHOSTING_SYS_CLOCK = 0x10 , SEMIHOSTING_SYS_ELAPSED = 0x30 ,
  SEMIHOSTING_SYS_ERRNO = 0x13 , SEMIHOSTING_SYS_EXIT = 0x18 , SEMIHOSTING_SYS_EXIT_EXTENDED = 0x20 , SEMIHOSTING_SYS_FLEN = 0x0C ,
  SEMIHOSTING_SYS_GET_CMDLINE = 0x15 , SEMIHOSTING_SYS_HEAPINFO = 0x16 , SEMIHOSTING_SYS_ISERROR = 0x08 , SEMIHOSTING_SYS_ISTTY = 0x09 ,
  SEMIHOSTING_SYS_OPEN = 0x01 , SEMIHOSTING_SYS_READ = 0x06 , SEMIHOSTING_SYS_READC = 0x07 , SEMIHOSTING_SYS_REMOVE = 0x0E ,
  SEMIHOSTING_SYS_RENAME = 0x0F , SEMIHOSTING_SYS_SEEK = 0x0A , SEMIHOSTING_SYS_SYSTEM = 0x12 , SEMIHOSTING_SYS_TICKFREQ = 0x31 ,
  SEMIHOSTING_SYS_TIME = 0x11 , SEMIHOSTING_SYS_TMPNAM = 0x0D , SEMIHOSTING_SYS_WRITE = 0x05 , SEMIHOSTING_SYS_WRITEC = 0x03 ,
  SEMIHOSTING_SYS_WRITE0 = 0x04 , SEMIHOSTING_ARM_RESERVED_START = 0x32 , SEMIHOSTING_ARM_RESERVED_END = 0xFF , SEMIHOSTING_USER_CMD_0X100 = 0x100 ,
  SEMIHOSTING_USER_CMD_0X107 = 0x107 , SEMIHOSTING_USER_CMD_0X1FF = 0x1FF
}
 
enum  semihosting_redirect_config { SEMIHOSTING_REDIRECT_CFG_NONE , SEMIHOSTING_REDIRECT_CFG_DEBUG , SEMIHOSTING_REDIRECT_CFG_STDIO , SEMIHOSTING_REDIRECT_CFG_ALL }
 
enum  semihosting_reported_exceptions { ADP_STOPPED_APPLICATION_EXIT = ((2 << 16) + 38) , ADP_STOPPED_RUN_TIME_ERROR = ((2 << 16) + 35) }
 
enum  semihosting_result { SEMIHOSTING_NONE , SEMIHOSTING_HANDLED , SEMIHOSTING_WAITING , SEMIHOSTING_ERROR }
 

Functions

int semihosting_common (struct target *target)
 Portable implementation of ARM semihosting calls. More...
 
int semihosting_common_init (struct target *target, void *setup, void *post_result)
 Initialize common semihosting support. More...
 
uint64_t semihosting_get_field (struct target *target, size_t index, uint8_t *fields)
 Extract a field from the buffer, considering register size and endianness. More...
 
const char * semihosting_opcode_to_str (uint64_t opcode)
 Convert the syscall opcode to a human-readable string. More...
 
int semihosting_read_fields (struct target *target, size_t number, uint8_t *fields)
 Read all fields of a command from target to buffer. More...
 
void semihosting_set_field (struct target *target, uint64_t value, size_t index, uint8_t *fields)
 Store a field in the buffer, considering register size and endianness. More...
 
int semihosting_write_fields (struct target *target, size_t number, uint8_t *fields)
 Write all fields of a command from buffer to target. More...
 

Variables

const struct command_registration semihosting_common_handlers []
 

Macro Definition Documentation

◆ SEMIHOSTING_MAX_TCL_COMMAND_FIELD_LENGTH

#define SEMIHOSTING_MAX_TCL_COMMAND_FIELD_LENGTH   (1024 * 1024)

Maximum allowed Tcl command segment length in bytes.

Definition at line 76 of file semihosting_common.h.

Enumeration Type Documentation

◆ semihosting_operation_numbers

Enumerator
SEMIHOSTING_ENTER_SVC 
SEMIHOSTING_SYS_CLOSE 
SEMIHOSTING_SYS_CLOCK 
SEMIHOSTING_SYS_ELAPSED 
SEMIHOSTING_SYS_ERRNO 
SEMIHOSTING_SYS_EXIT 
SEMIHOSTING_SYS_EXIT_EXTENDED 
SEMIHOSTING_SYS_FLEN 
SEMIHOSTING_SYS_GET_CMDLINE 
SEMIHOSTING_SYS_HEAPINFO 
SEMIHOSTING_SYS_ISERROR 
SEMIHOSTING_SYS_ISTTY 
SEMIHOSTING_SYS_OPEN 
SEMIHOSTING_SYS_READ 
SEMIHOSTING_SYS_READC 
SEMIHOSTING_SYS_REMOVE 
SEMIHOSTING_SYS_RENAME 
SEMIHOSTING_SYS_SEEK 
SEMIHOSTING_SYS_SYSTEM 
SEMIHOSTING_SYS_TICKFREQ 
SEMIHOSTING_SYS_TIME 
SEMIHOSTING_SYS_TMPNAM 
SEMIHOSTING_SYS_WRITE 
SEMIHOSTING_SYS_WRITEC 
SEMIHOSTING_SYS_WRITE0 
SEMIHOSTING_ARM_RESERVED_START 
SEMIHOSTING_ARM_RESERVED_END 
SEMIHOSTING_USER_CMD_0X100 
SEMIHOSTING_USER_CMD_0X107 
SEMIHOSTING_USER_CMD_0X1FF 

Definition at line 38 of file semihosting_common.h.

◆ semihosting_redirect_config

Enumerator
SEMIHOSTING_REDIRECT_CFG_NONE 
SEMIHOSTING_REDIRECT_CFG_DEBUG 
SEMIHOSTING_REDIRECT_CFG_STDIO 
SEMIHOSTING_REDIRECT_CFG_ALL 

Definition at line 90 of file semihosting_common.h.

◆ semihosting_reported_exceptions

Enumerator
ADP_STOPPED_APPLICATION_EXIT 
ADP_STOPPED_RUN_TIME_ERROR 

Definition at line 83 of file semihosting_common.h.

◆ semihosting_result

Enumerator
SEMIHOSTING_NONE 
SEMIHOSTING_HANDLED 
SEMIHOSTING_WAITING 
SEMIHOSTING_ERROR 

Definition at line 97 of file semihosting_common.h.

Function Documentation

◆ semihosting_common()

int semihosting_common ( struct target target)

Portable implementation of ARM semihosting calls.

Performs the currently pending semihosting operation encoded in target->semihosting.

This is a user defined operation (while user cmds 0x100-0x1ff are possible, only 0x100-0x107 are currently implemented).

Reads the user operation parameters from target, then fires the corresponding target event. When the target callbacks returned, cleans up the command parameter buffer.

Entry On entry, the PARAMETER REGISTER contains a pointer to a two-field data block:

  • field 1 Contains a pointer to the bound command parameter string
  • field 2 Contains the command parameter string length

Return On exit, the RETURN REGISTER contains the return status.

Definition at line 366 of file semihosting_common.c.

References addr, ADP_STOPPED_APPLICATION_EXIT, ADP_STOPPED_RUN_TIME_ERROR, semihosting::basedir, cmd, semihosting::cmdline, count, ENOTSUP, ERROR_FAIL, ERROR_NOT_IMPLEMENTED, ERROR_OK, target::fileio_info, gdb_get_actual_connections(), semihosting::has_resumable_exit, semihosting::hit_fileio, gdb_fileio_info::identifier, semihosting::is_fileio, semihosting::is_resumable, LOG_DEBUG, LOG_ERROR, mode, NULL, semihosting::op, open_gdb_modeflags, open_host_modeflags, semihosting::param, gdb_fileio_info::param_1, gdb_fileio_info::param_2, gdb_fileio_info::param_3, gdb_fileio_info::param_4, semihosting::post_result, semihosting::result, target::semihosting, semihosting_get_field(), semihosting_getchar(), SEMIHOSTING_MAX_TCL_COMMAND_FIELD_LENGTH, semihosting_opcode_to_str(), semihosting_putchar(), semihosting_read(), semihosting_read_fields(), semihosting_set_field(), SEMIHOSTING_SYS_CLOCK, SEMIHOSTING_SYS_CLOSE, SEMIHOSTING_SYS_ELAPSED, SEMIHOSTING_SYS_ERRNO, SEMIHOSTING_SYS_EXIT, SEMIHOSTING_SYS_EXIT_EXTENDED, SEMIHOSTING_SYS_FLEN, SEMIHOSTING_SYS_GET_CMDLINE, SEMIHOSTING_SYS_HEAPINFO, SEMIHOSTING_SYS_ISERROR, SEMIHOSTING_SYS_ISTTY, SEMIHOSTING_SYS_OPEN, SEMIHOSTING_SYS_READ, SEMIHOSTING_SYS_READC, SEMIHOSTING_SYS_REMOVE, SEMIHOSTING_SYS_RENAME, SEMIHOSTING_SYS_SEEK, SEMIHOSTING_SYS_SYSTEM, SEMIHOSTING_SYS_TICKFREQ, SEMIHOSTING_SYS_TIME, SEMIHOSTING_SYS_TMPNAM, SEMIHOSTING_SYS_WRITE, SEMIHOSTING_SYS_WRITE0, SEMIHOSTING_SYS_WRITEC, SEMIHOSTING_USER_CMD_0X100, SEMIHOSTING_USER_CMD_0X107, semihosting_user_op_params, semihosting_write(), semihosting_write_fields(), semihosting::setup_time, size, semihosting::stderr_fd, semihosting::stdin_fd, semihosting::stdout_fd, semihosting::sys_errno, target_call_event_callbacks(), TARGET_EVENT_HALTED, target_handle_event(), target_read_buffer(), target_read_memory(), target_write_buffer(), target_write_memory(), type, semihosting::user_command_extension, and semihosting::word_size_bytes.

Referenced by arm_semihosting(), and esp_xtensa_semihosting().

◆ semihosting_common_init()

◆ semihosting_get_field()

uint64_t semihosting_get_field ( struct target target,
size_t  index,
uint8_t *  fields 
)

Extract a field from the buffer, considering register size and endianness.

Definition at line 1744 of file semihosting_common.c.

References target::semihosting, target_buffer_get_u32(), target_buffer_get_u64(), and semihosting::word_size_bytes.

Referenced by esp_semihosting_common(), and semihosting_common().

◆ semihosting_opcode_to_str()

◆ semihosting_read_fields()

int semihosting_read_fields ( struct target target,
size_t  number,
uint8_t *  fields 
)

Read all fields of a command from target to buffer.

Definition at line 1720 of file semihosting_common.c.

References number, semihosting::param, target::semihosting, target_read_memory(), and semihosting::word_size_bytes.

Referenced by esp_semihosting_common(), and semihosting_common().

◆ semihosting_set_field()

void semihosting_set_field ( struct target target,
uint64_t  value,
size_t  index,
uint8_t *  fields 
)

Store a field in the buffer, considering register size and endianness.

Definition at line 1757 of file semihosting_common.c.

References target::semihosting, target_buffer_set_u32(), target_buffer_set_u64(), and semihosting::word_size_bytes.

Referenced by semihosting_common().

◆ semihosting_write_fields()

int semihosting_write_fields ( struct target target,
size_t  number,
uint8_t *  fields 
)

Write all fields of a command from buffer to target.

Definition at line 1732 of file semihosting_common.c.

References number, semihosting::param, target::semihosting, target_write_memory(), and semihosting::word_size_bytes.

Referenced by semihosting_common().

Variable Documentation

◆ semihosting_common_handlers

const struct command_registration semihosting_common_handlers[]
extern

Definition at line 2079 of file semihosting_common.c.