Re: [PATCH] RISC-V: Add semihosting support

Kito Cheng via Newlib <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <CA+yXCZD0ZNUNob0srvDQvefwO7C+AvqOfwSrLgZ0c76-ZDBg3A@mail.gmail.com>
Hi Craig:

I verified with GCC testsuite on qemu with Keith's semihosting patch,
And that's LGTM, only two minor review comment, see below:

> +++ b/libgloss/riscv/semihost-sys_exit.c
> @@ -0,0 +1,19 @@
> +#include <machine/syscall.h>
> +#include "semihost_syscall.h"
> +
> +#define ADP_Stopped_ApplicationExit 0x20026
> +
> +/* Exit a program without cleaning up files.  */
> +void
> +_exit (int exit_status)
> +{
> +#if __riscv_xlen == 32
> +  syscall_errno (SEMIHOST_exit, (long *) ADP_Stopped_ApplicationExit);

Could you use SEMIHOST_exit_extended here, so that we could have
return value on rv32.

> +/* Return the fdentry for file or NULL if not found.  */
> +
> +struct fdentry *
> +__get_fdentry (int file)
> +{
> +  if (file<0 || file>RISCV_MAX_OPEN_FILES || fdtable[file].handle == -1)

Should be >= RISCV_MAX_OPEN_FILES here?
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.