NEORV32 Software Framework Documentation
The NEORV32 RISC-V Processor
Loading...
Searching...
No Matches
neorv32_semihosting.h
Go to the documentation of this file.
1// ================================================================================ //
2// The NEORV32 RISC-V Processor - https://github.com/stnolting/neorv32 //
3// Copyright (c) NEORV32 contributors. //
4// Copyright (c) 2020 - 2025 Stephan Nolting. All rights reserved. //
5// Licensed under the BSD-3-Clause license, see LICENSE for details. //
6// SPDX-License-Identifier: BSD-3-Clause //
7// ================================================================================ //
8
13
14#ifndef NEORV32_SEMIHOSTING_H
15#define NEORV32_SEMIHOSTING_H
16
17#include <stdint.h>
18
19
20/**********************************************************************/
50
51
52
53/**********************************************************************/
57void neorv32_semihosting_putc(char c);
58void neorv32_semihosting_puts(const char* pnt);
60//
61int neorv32_semihosting_open(char *path, int mode);
62int neorv32_semihosting_close(int file);
63int neorv32_semihosting_write(int file, char *buffer, int len);
64int neorv32_semihosting_read(int file, char *buffer, int len);
65int neorv32_semihosting_istty(int file);
66int neorv32_semihosting_seek(int file, int pos);
67int neorv32_semihosting_flen(int file);
69int neorv32_semihosting_system(char *cmd);
71
72
73/**********************************************************************/
80inline int __attribute__ ((always_inline)) neorv32_semihosting_req(int id, void* arg) {
81
82 register int value asm ("a0") = id;
83 register void* data asm ("a1") = arg;
84 asm volatile (
85 " .option push \n"
86 " .option norvc \n" // we need 32-bit instruction words here
87 " .align 4 \n" // this has to be aligned
88 " slli x0, x0, 0x1f \n" // magic triplet: entry NOP
89 " ebreak \n" // magic triplet: break to debugger
90 " srai x0, x0, 0x07 \n" // magic triplet: exit NOP
91 " .option pop \n"
92 : "=r" (value) : "0" (value), "r" (data) : "memory"
93 );
94 return value;
95}
96
97
98#endif // NEORV32_SEMIHOSTING_H
int neorv32_semihosting_istty(int file)
Definition neorv32_semihosting.c:119
int neorv32_semihosting_open(char *path, int mode)
Definition neorv32_semihosting.c:56
void neorv32_semihosting_puts(const char *pnt)
Definition neorv32_semihosting.c:32
int neorv32_semihosting_flen(int file)
Definition neorv32_semihosting.c:147
void neorv32_semihosting_putc(char c)
Definition neorv32_semihosting.c:22
int neorv32_semihosting_time(void)
Definition neorv32_semihosting.c:159
int neorv32_semihosting_system(char *cmd)
Definition neorv32_semihosting.c:172
int neorv32_semihosting_close(int file)
Definition neorv32_semihosting.c:71
NEORV32_SEMIHOSTING_SYS_enum
Definition neorv32_semihosting.h:26
@ SEMIHOSTING_SYS_TICKFREQ
Definition neorv32_semihosting.h:48
@ SEMIHOSTING_SYS_TMPNAME
Definition neorv32_semihosting.h:37
@ SEMIHOSTING_SYS_EXCEPTION
Definition neorv32_semihosting.h:46
@ SEMIHOSTING_SYS_WRITE
Definition neorv32_semihosting.h:31
@ SEMIHOSTING_SYS_FLEN
Definition neorv32_semihosting.h:36
@ SEMIHOSTING_SYS_GET_CMDLINE
Definition neorv32_semihosting.h:44
@ SEMIHOSTING_SYS_ELLAPSED
Definition neorv32_semihosting.h:47
@ SEMIHOSTING_SYS_REMOVE
Definition neorv32_semihosting.h:38
@ SEMIHOSTING_SYS_SEEK
Definition neorv32_semihosting.h:35
@ SEMIHOSTING_SYS_TIME
Definition neorv32_semihosting.h:41
@ SEMIHOSTING_SYS_CLOCK
Definition neorv32_semihosting.h:40
@ SEMIHOSTING_SYS_WRITEC
Definition neorv32_semihosting.h:29
@ SEMIHOSTING_SYS_ERRNO
Definition neorv32_semihosting.h:43
@ SEMIHOSTING_SYS_ISTTY
Definition neorv32_semihosting.h:34
@ SEMIHOSTING_SYS_HEAPINFO
Definition neorv32_semihosting.h:45
@ SEMIHOSTING_SYS_WRITE0
Definition neorv32_semihosting.h:30
@ SEMIHOSTING_SYS_READ
Definition neorv32_semihosting.h:32
@ SEMIHOSTING_SYS_SYSTEM
Definition neorv32_semihosting.h:42
@ SEMIHOSTING_SYS_CLOSE
Definition neorv32_semihosting.h:28
@ SEMIHOSTING_SYS_READC
Definition neorv32_semihosting.h:33
@ SEMIHOSTING_SYS_OPEN
Definition neorv32_semihosting.h:27
@ SEMIHOSTING_SYS_RENAME
Definition neorv32_semihosting.h:39
int neorv32_semihosting_read(int file, char *buffer, int len)
Definition neorv32_semihosting.c:103
int neorv32_semihosting_seek(int file, int pos)
Definition neorv32_semihosting.c:133
int neorv32_semihosting_write(int file, char *buffer, int len)
Definition neorv32_semihosting.c:86
char neorv32_semihosting_getc(void)
Definition neorv32_semihosting.c:44
int neorv32_semihosting_req(int id, void *arg)
Definition neorv32_semihosting.h:80