API Reference
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 - 2026 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
14#ifndef NEORV32_SEMIHOSTING_H
15#define NEORV32_SEMIHOSTING_H
16
17#include <neorv32.h>
18#include <stdint.h>
19
20/**********************************************************************/
52/**********************************************************************/
57enum SEMIHOST_OPEN_MODE_enum {
58 SEMIHOSTING_OPEN_R = 0,
59 SEMIHOSTING_OPEN_RB = 1,
60 SEMIHOSTING_OPEN_R_PLUS = 2,
61 SEMIHOSTING_OPEN_RB_PLUS = 3,
62 SEMIHOSTING_OPEN_W = 4,
63 SEMIHOSTING_OPEN_WB = 5,
64 SEMIHOSTING_OPEN_W_PLUS = 6,
65 SEMIHOSTING_OPEN_WB_PLUS = 7,
66 SEMIHOSTING_OPEN_A = 8,
67 SEMIHOSTING_OPEN_AB = 9,
68 SEMIHOSTING_OPEN_A_PLUS = 10,
69 SEMIHOSTING_OPEN_AB_PLUS = 11
70};
73/**********************************************************************/
77void neorv32_semihosting_putc(char c);
78void neorv32_semihosting_puts(const char* pnt);
80//
81int neorv32_semihosting_open(char *path, int mode);
82int neorv32_semihosting_close(int file);
83int neorv32_semihosting_write(int file, char *buffer, int len);
84int neorv32_semihosting_read(int file, char *buffer, int len);
85int neorv32_semihosting_istty(int file);
86int neorv32_semihosting_seek(int file, int pos);
87int neorv32_semihosting_flen(int file);
89int neorv32_semihosting_system(char *cmd);
92/**********************************************************************/
99static inline int __attribute__ ((always_inline)) neorv32_semihosting_req(int id, void* arg) {
100
101 register int value asm ("a0") = id;
102 register void* data asm ("a1") = arg;
103 asm volatile (
104 " .option push \n"
105 " .option norvc \n" // we need 32-bit instruction words here
106 " .balign 4 \n" // this has to be aligned
107 " slli x0, x0, 0x1f \n" // magic triplet: entry NOP
108 " ebreak \n" // magic triplet: break to debugger
109 " srai x0, x0, 0x07 \n" // magic triplet: exit NOP
110 " .option pop \n"
111 : "=r" (value) : "0" (value), "r" (data) : "memory"
112 );
113 return value;
114}
115
116#endif // NEORV32_SEMIHOSTING_H
Main NEORV32 core library / driver / HAL include file.
int neorv32_semihosting_istty(int file)
Definition neorv32_semihosting.c:103
int neorv32_semihosting_open(char *path, int mode)
Definition neorv32_semihosting.c:48
static int neorv32_semihosting_req(int id, void *arg)
Definition neorv32_semihosting.h:99
void neorv32_semihosting_puts(const char *pnt)
Definition neorv32_semihosting.c:29
int neorv32_semihosting_flen(int file)
Definition neorv32_semihosting.c:127
void neorv32_semihosting_putc(char c)
Definition neorv32_semihosting.c:21
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_time(void)
Definition neorv32_semihosting.c:137
int neorv32_semihosting_system(char *cmd)
Definition neorv32_semihosting.c:146
int neorv32_semihosting_close(int file)
Definition neorv32_semihosting.c:61
int neorv32_semihosting_read(int file, char *buffer, int len)
Definition neorv32_semihosting.c:89
int neorv32_semihosting_seek(int file, int pos)
Definition neorv32_semihosting.c:115
int neorv32_semihosting_write(int file, char *buffer, int len)
Definition neorv32_semihosting.c:74
char neorv32_semihosting_getc(void)
Definition neorv32_semihosting.c:38