Question about OS calls in RISCV BSP

Jim Wilson jimw@sifive.com
Tue Sep 17 23:25:00 GMT 2019


On Wed, Sep 11, 2019 at 6:40 PM Bandhav Veluri <bandhav@uw.edu> wrote:
> I'm the confused about the list of functions to be implemented in a BSP.
> Newlib documentation explains 19 syscalls listed here is the "complete set
> of system definitions <https://sourceware.org/newlib/libc.html#Syscalls>".
> But when I look at RISC-V BSP
> <https://github.com/riscv/riscv-newlib/tree/riscv-newlib-3.1.0/libgloss/riscv>,
> I see lot more extra routines implemented such as getcwd, chown, chdir etc.
> What is the exact list of subroutines a BSP has to implement?

I think that is a minor bug in the RISC-V libgloss port.  This used to
have a single syscall.c file which defined functions like open, but
that was wrong, as it conflicted with the open function in newlib
which expects to call _open in libgloss.  So the RISC-V syscalls.c
file was split into multiple files, and the functions all had the
missing underscore prefixed.  Unfortunately, the syscall.c file also
had a getcwd function which got renamed to _getcwd, which newlib
apparently never calls.  So we have an unused function _getcwd, and we
have a missing getcwd function, but we never should have needed getcwd
in libgloss in the first place.  Most of the RISC-V libgloss history
is out of tree, but I'd guess that they were trying to compile POSIX
programs, and just added every syscall they needed to get those
programs to compile.  It is better to just use a linux toolchain to
compile POSIX programs, but maybe they didn't have a working linux
toolchain at the time.

> Also, any reason why is fcntl missing in the Newlib documentation's list?
> It seems one of the syscalls required by this list
> <https://github.com/eblot/newlib/tree/master/newlib/libc/syscalls>.

Probably just forgot to update the docs when _fcntl support was added.

Jim



More information about the Newlib mailing list