NEORV32 Software Framework Documentation
The NEORV32 RISC-V Processor
Loading...
Searching...
No Matches
neorv32_semihosting.c File Reference

RISC-V semihosting source file. More...

#include <neorv32.h>
#include <string.h>

Functions

void neorv32_semihosting_putc (char c)
 
void neorv32_semihosting_puts (const char *pnt)
 
char neorv32_semihosting_getc (void)
 
int neorv32_semihosting_open (char *path, int mode)
 
int neorv32_semihosting_close (int file)
 
int neorv32_semihosting_write (int file, char *buffer, int len)
 
int neorv32_semihosting_read (int file, char *buffer, int len)
 
int neorv32_semihosting_istty (int file)
 
int neorv32_semihosting_seek (int file, int pos)
 
int neorv32_semihosting_flen (int file)
 
int neorv32_semihosting_time (void)
 
int neorv32_semihosting_system (char *cmd)
 

Detailed Description

RISC-V semihosting source file.

Function Documentation

◆ neorv32_semihosting_close()

int neorv32_semihosting_close ( int file)

Close file on host system.

Parameters
[in]fileFile handle.
Returns
0 if the call is successful, -1 if the call is not successful.

◆ neorv32_semihosting_flen()

int neorv32_semihosting_flen ( int file)

Returns the length of a specified file.

Parameters
[in]fileFile handle.
Returns
The current length of the file object, -1 if call fails.

◆ neorv32_semihosting_getc()

char neorv32_semihosting_getc ( void )

Read single character from host's STDIN.

Warning
This function is blocking.
Returns
Received character.

◆ neorv32_semihosting_istty()

int neorv32_semihosting_istty ( int file)

Checks if a host file is connected to an interactive device.

Parameters
[in]fileFile handle.
Returns
1 if the handle identifies an interactive device, 0 if the handle identifies a file, a value other than 1 or 0 if an error occurs.

◆ neorv32_semihosting_open()

int neorv32_semihosting_open ( char * path,
int mode )

Open file on host system.

Parameters
[in]pathPath/file name (zero-terminated string).
[in]modeFile access mode (ISO C).
Returns
File handle.

◆ neorv32_semihosting_putc()

void neorv32_semihosting_putc ( char c)

Print single character to host's STDOUT.

Parameters
[in]cCharacter to print.

◆ neorv32_semihosting_puts()

void neorv32_semihosting_puts ( const char * pnt)

Print zero-terminated string to host's STDOUT.

Parameters
[in]pntPointer to zero-terminated string.

◆ neorv32_semihosting_read()

int neorv32_semihosting_read ( int file,
char * buffer,
int len )

Read data buffer from host's file handle.

Parameters
[in]fileFile handle (stream; should be 0 = STDIN).
[in]bufferPointer to data buffer.
[in]lenLength of data to read.
Returns
Number of characters NOT read.

◆ neorv32_semihosting_seek()

int neorv32_semihosting_seek ( int file,
int pos )

Seeks to a specified position in a file.

Parameters
[in]fileFile handle.
[in]posOffset specified from the start of the file
Returns
0 if the request is successful.

◆ neorv32_semihosting_system()

int neorv32_semihosting_system ( char * cmd)

Execute command in host's console.

Warning
Be careful!
Parameters
[in]cmdPointer to zero-terminated command string.
Returns
Host command's exit status.

◆ neorv32_semihosting_time()

int neorv32_semihosting_time ( void )

Get host's current system time.

Returns
Unix timestamp (time in seconds since Jan 1st 1970)

◆ neorv32_semihosting_write()

int neorv32_semihosting_write ( int file,
char * buffer,
int len )

Write data buffer to host's file handle.

Parameters
[in]fileFile handle (stream; should be 1 = STDOUT).
[in]bufferPointer to data buffer.
[in]lenLength of data to write.
Returns
Number of characters NOT send.