Skip to content

Commit

Permalink
libgloss/riscv: Fix wrong fdtable[i]->handle assignment
Browse files Browse the repository at this point in the history
This assignment is already done correctly in __add_fdentry

if we do it after open, it is wrong, the _open is return the
file handle index of fdtable not the handle return by semihost open
call which is recorded in fdtable[i]->handle

This should be able to fix unable to run qemu with semihosting in windows

see https://gito.corp.nucleisys.com/software/devtools/qemu/-/issues/128

This will fix nuclei sdk

make SEMIHOST=1 run_qemu
not output issue

Signed-off-by: Huaqi Fang <[email protected]>
  • Loading branch information
fanghuaqi committed Feb 7, 2024
1 parent 9f1e0f7 commit cbebc4b
Showing 1 changed file with 0 additions and 6 deletions.
6 changes: 0 additions & 6 deletions libgloss/riscv/semihost-sys_fdtable.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,12 @@ init_semihosting ()
/* Set up std streams. */
/* stdin. */
handle = _open (":tt", O_RDONLY);
fdtable[STDIN_FILENO].handle = handle;
fdtable[STDIN_FILENO].pos = 0;

/* stdout. */
handle = _open (":tt", O_WRONLY|O_CREAT|O_TRUNC);
fdtable[STDOUT_FILENO].handle = handle;
fdtable[STDOUT_FILENO].pos = 0;

/* stderr. */
handle = _open (":tt", O_WRONLY|O_CREAT|O_APPEND);
fdtable[STDERR_FILENO].handle = handle;
fdtable[STDERR_FILENO].pos = 0;
}

/* Add entry to fdtable. */
Expand Down

0 comments on commit cbebc4b

Please sign in to comment.