Zephyr Project API  3.3.0
A Scalable Open Source RTOS
semihost.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2022, Commonwealth Scientific and Industrial Research
3 * Organisation (CSIRO) ABN 41 687 119 230.
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 *
7 * Based on the ARM semihosting API from:
8 * https://github.com/ARM-software/abi-aa/blob/main/semihosting/semihosting.rst
9 *
10 * RISC-V semihosting also follows these conventions:
11 * https://github.com/riscv/riscv-semihosting-spec/blob/main/riscv-semihosting-spec.adoc
12 */
13
22#ifndef ZEPHYR_INCLUDE_ARCH_COMMON_SEMIHOST_H_
23#define ZEPHYR_INCLUDE_ARCH_COMMON_SEMIHOST_H_
24
27 /*
28 * File I/O operations
29 */
30
51
52 /*
53 * Terminal I/O operations
54 */
55
62
63 /*
64 * Time operations
65 */
70
71 /*
72 * System/Misc. operations
73 */
74
81 SEMIHOST_SYSTEM = 0x12
82};
83
103};
104
113long semihost_exec(enum semihost_instr instr, void *args);
114
121
128
139long semihost_open(const char *path, long mode);
140
149long semihost_close(long fd);
150
159long semihost_flen(long fd);
160
170long semihost_seek(long fd, long offset);
171
182long semihost_read(long fd, void *buf, long len);
183
194long semihost_write(long fd, const void *buf, long len);
195
200#endif /* ZEPHYR_INCLUDE_ARCH_COMMON_SEMIHOST_H_ */
void semihost_poll_out(char c)
Write a byte to the console.
semihost_open_mode
Modes to open a file with.
Definition: semihost.h:90
long semihost_open(const char *path, long mode)
Open a file on the host system.
char semihost_poll_in(void)
Read a byte from the console.
long semihost_write(long fd, const void *buf, long len)
Write the contents of a buffer into a file.
long semihost_seek(long fd, long offset)
Seeks to an absolute position in a file.
long semihost_exec(enum semihost_instr instr, void *args)
Manually execute a semihosting instruction.
long semihost_close(long fd)
Close a file.
semihost_instr
Semihosting instructions.
Definition: semihost.h:26
long semihost_flen(long fd)
Query the size of a file.
long semihost_read(long fd, void *buf, long len)
Read the contents of a file into a buffer.
@ SEMIHOST_OPEN_R_PLUS
Definition: semihost.h:93
@ SEMIHOST_OPEN_AB
Definition: semihost.h:100
@ SEMIHOST_OPEN_W
Definition: semihost.h:95
@ SEMIHOST_OPEN_A
Definition: semihost.h:99
@ SEMIHOST_OPEN_WB_PLUS
Definition: semihost.h:98
@ SEMIHOST_OPEN_RB
Definition: semihost.h:92
@ SEMIHOST_OPEN_A_PLUS
Definition: semihost.h:101
@ SEMIHOST_OPEN_WB
Definition: semihost.h:96
@ SEMIHOST_OPEN_AB_PLUS
Definition: semihost.h:102
@ SEMIHOST_OPEN_RB_PLUS
Definition: semihost.h:94
@ SEMIHOST_OPEN_R
Definition: semihost.h:91
@ SEMIHOST_OPEN_W_PLUS
Definition: semihost.h:97
@ SEMIHOST_READ
Definition: semihost.h:38
@ SEMIHOST_OPEN
Definition: semihost.h:32
@ SEMIHOST_ELAPSED
Definition: semihost.h:67
@ SEMIHOST_RENAME
Definition: semihost.h:50
@ SEMIHOST_TICKFREQ
Definition: semihost.h:68
@ SEMIHOST_WRITE0
Definition: semihost.h:59
@ SEMIHOST_WRITEC
Definition: semihost.h:57
@ SEMIHOST_SYSTEM
Definition: semihost.h:81
@ SEMIHOST_ISERROR
Definition: semihost.h:80
@ SEMIHOST_REMOVE
Definition: semihost.h:48
@ SEMIHOST_HEAPINFO
Definition: semihost.h:79
@ SEMIHOST_CLOSE
Definition: semihost.h:40
@ SEMIHOST_GET_CMDLINE
Definition: semihost.h:78
@ SEMIHOST_CLOCK
Definition: semihost.h:66
@ SEMIHOST_WRITE
Definition: semihost.h:36
@ SEMIHOST_SEEK
Definition: semihost.h:44
@ SEMIHOST_TMPNAM
Definition: semihost.h:46
@ SEMIHOST_ERRNO
Definition: semihost.h:76
@ SEMIHOST_ISTTY
Definition: semihost.h:34
@ SEMIHOST_READC
Definition: semihost.h:61
@ SEMIHOST_FLEN
Definition: semihost.h:42
@ SEMIHOST_TIME
Definition: semihost.h:69
char c
Definition: printk.c:112