@@ -86,6 +86,7 @@ void create_parser(QCommandLineParser &p) {
8686 p.addOption (
8787 { { " serial-out" , " serout" }, " File connected to the serial port output." , " FNAME" });
8888 p.addOption ({ { " os-emulation" , " osemu" }, " Operating system emulation." });
89+ p.addOption ({ { " std-in" , " stdin" }, " File connected to the syscall standard input." , " FNAME" });
8990 p.addOption ({ { " std-out" , " stdout" }, " File connected to the syscall standard output." , " FNAME" });
9091 p.addOption ({ { " os-fs-root" , " osfsroot" }, " Emulated system root/prefix for opened files" , " DIR" });
9192 p.addOption ({ { " isa-variant" , " isavariant" }, " Instruction set to emulate (default RV32IMA)" , " STR" });
@@ -409,8 +410,13 @@ void configure_serial_port(QCommandLineParser &p, SerialPort *ser_port) {
409410
410411void configure_osemu (QCommandLineParser &p, MachineConfig &config, Machine *machine) {
411412 CharIOHandler *std_out = nullptr ;
413+ QScopedPointer<QString> std_in_path;
412414 int siz;
413415
416+ siz = p.values (" std-in" ).size ();
417+ if (siz >= 1 ) {
418+ std_in_path.reset (new QString (p.values (" std-in" ).at (siz - 1 )));
419+ }
414420 siz = p.values (" std-out" ).size ();
415421 if (siz >= 1 ) {
416422 auto *qf = new QFile (p.values (" std-out" ).at (siz - 1 ));
@@ -427,6 +433,12 @@ void configure_osemu(QCommandLineParser &p, MachineConfig &config, Machine *mach
427433 auto *osemu_handler = new osemu::OsSyscallExceptionHandler (
428434 config.osemu_known_syscall_stop (), config.osemu_unknown_syscall_stop (),
429435 config.osemu_fs_root ());
436+ if (!std_in_path.isNull () && !std_in_path->isEmpty ()) {
437+ if (!osemu_handler->map_stdin_to_hostfile (*std_in_path)) {
438+ fprintf (stderr, " Failed to map stdin to host file '%s'\n " , std_in_path->toLatin1 ().data ());
439+ exit (EXIT_FAILURE);
440+ }
441+ }
430442 if (std_out) {
431443 machine::Machine::connect (
432444 osemu_handler, &osemu::OsSyscallExceptionHandler::char_written,
0 commit comments