Seeking Help with OpenSBI for Console Input

Hi everyone,

I’m currently working with OpenSBI and QEMU in a RISC-V environment. My goal is to read input from the console device (uart8250). I’ve been using the sbi_ngets function defined in sbi_console.c, but I’ve encountered an issue. The function doesn’t wait for input; instead, it jumps to the next instruction immediately.

As a temporary workaround, I inserted a no-op operation to introduce a 2-second delay. However, I’m looking for a more efficient solution. Is there a way to make a wait for input call, or could you suggest a better approach to address this issue?

Your insights and suggestions would be greatly appreciated!


sbi_ngets calls sbi_getc. sbi_getc never waits. If there’s no character to read, it returns -1. It’s impossible to wait for input from openSBI. Its 8250 driver doesn’t support wait. You can implement or reuse a Linux 8250 driver that uses interrupt to notify you when input is available, or, simply periodically issuing ecall(getchar) to openSBI.