API Reference
The NEORV32 RISC-V Processor
Loading...
Searching...
No Matches
Macros | Functions | Variables
neorv32_newlib.c File Reference

NEORV32-specific Newlib system calls. More...

#include <neorv32.h>
#include <newlib.h>
#include <time.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <errno.h>

Macros

#define SYSCALL_ATTR   __attribute__((used, externally_visible, noinline))
 

Functions

SYSCALL_ATTR void _exit (int status)
 
SYSCALL_ATTR int _open (char *pathname, int flags)
 
SYSCALL_ATTR int _close (int file)
 
SYSCALL_ATTR int _fstat (int file, struct stat *st)
 
SYSCALL_ATTR int _fork (void)
 
SYSCALL_ATTR int _getpid ()
 
SYSCALL_ATTR int _isatty (int file)
 
SYSCALL_ATTR int _kill (int pid, int sig)
 
SYSCALL_ATTR int _link (char *old_name, char *new_name)
 
SYSCALL_ATTR int _lseek (int file, int ptr, int dir)
 
SYSCALL_ATTR int _stat (char *file, struct stat *st)
 
SYSCALL_ATTR int _wait (int status)
 
SYSCALL_ATTR int _unlink (char *name)
 
SYSCALL_ATTR int _read (int file, char *ptr, int len)
 
SYSCALL_ATTR int _write (int file, char *ptr, int len)
 
SYSCALL_ATTR void * _sbrk (int incr)
 
SYSCALL_ATTR int _gettimeofday (struct timeval *tv)
 

Variables

int errno
 
char * __env [1] = { 0 }
 
char ** environ = __env
 

Detailed Description

NEORV32-specific Newlib system calls.

Note
Sources: https://www.sourceware.org/newlib/libc.html#Syscalls https://interrupt.memfault.com/blog/boostrapping-libc-with-newlib https://www.embecosm.com/appnotes/ean9/ean9-howto-newlib-1.0.pdf

Function Documentation

◆ _close()

SYSCALL_ATTR int _close ( int  file)

Close file handle.

◆ _exit()

SYSCALL_ATTR void _exit ( int  status)

Issue a warning when semihosting is enabled. Exit a program without cleaning up anything.

◆ _fork()

SYSCALL_ATTR int _fork ( void  )

Create new process.

◆ _fstat()

SYSCALL_ATTR int _fstat ( int  file,
struct stat *  st 
)

Status of an open file. All files are regarded as character special devices.

◆ _getpid()

SYSCALL_ATTR int _getpid ( )

Process-ID; this is sometimes used to generate strings unlikely to conflict with other processes.

◆ _gettimeofday()

SYSCALL_ATTR int _gettimeofday ( struct timeval *  tv)

Get Unix time. Used by "time", among others.

◆ _isatty()

SYSCALL_ATTR int _isatty ( int  file)

Query whether output stream is a terminal.

◆ _kill()

SYSCALL_ATTR int _kill ( int  pid,
int  sig 
)

Send a signal.

◆ _link()

SYSCALL_ATTR int _link ( char *  old_name,
char *  new_name 
)

Rename existing file.

◆ _lseek()

SYSCALL_ATTR int _lseek ( int  file,
int  ptr,
int  dir 
)

Set position in a file.

◆ _open()

SYSCALL_ATTR int _open ( char *  pathname,
int  flags 
)

Open file handle.

◆ _read()

SYSCALL_ATTR int _read ( int  file,
char *  ptr,
int  len 
)

Read from a file. STDIN will read from UART0, all other input streams will read from UART1.

◆ _sbrk()

SYSCALL_ATTR void * _sbrk ( int  incr)

Dynamic memory management. Used by "malloc" and "free", among others.

◆ _stat()

SYSCALL_ATTR int _stat ( char *  file,
struct stat *  st 
)

Status of a file.

◆ _unlink()

SYSCALL_ATTR int _unlink ( char *  name)

Remove a file's directory entry.

◆ _wait()

SYSCALL_ATTR int _wait ( int  status)

Wait for child process.

◆ _write()

SYSCALL_ATTR int _write ( int  file,
char *  ptr,
int  len 
)

Write to a file. STDOUT and STDERR will write to UART0, all other output streams will write to UART1.