From ea2edd89de48fcd46e0078a160cb661108338ce5 Mon Sep 17 00:00:00 2001 From: Dennis Boone Date: Sat, 6 Feb 2021 17:11:55 -0500 Subject: [PATCH] Fix terminal i/o issue in d_hlt Due to the configuration of the tty, the getchar() call in d_hlt returns nothing. Work around this in the same way the SOC console code does, by opening it on a separate unit, and reading from that instead. Without this fix, the code which looks for certain halt cases and offers "continue or exit" just spins, printing its message and getting no input. --- em.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/em.c b/em.c index e802137..f87f681 100644 --- a/em.c +++ b/em.c @@ -6297,13 +6297,31 @@ d_hlt: /* 000000 */ if (bootarg) { printf("\nCPU halt, instruction #%u at %o/%o %s: %o %o ^%06o^\nA='%o/%d B='%o/%d L='%o/%d X=%o/%d", gv.instcount, RPH, RPL, searchloadmap(gv.prevpc,' '), get16t(gv.prevpc), get16t(gv.prevpc+1), lights, getcrs16(A), getcrs16s(A), getcrs16(B), getcrs16s(B), getcrs32(A), getcrs32s(A), getcrs16(X), getcrs16s(X)); while (1) { + int n; + static int ttydev; + ttydev = open("/dev/tty", O_RDWR, 0); + if (ttydev < 0) { + perror(" error opening /dev/tty"); + fatal(NULL); + } printf("\nPress Enter to continue, h to halt... "); - utempa = getchar(); + fflush(stdout); + utempa = ' '; + n = 0; + while (n == 0) + n = read(ttydev, &utempa, 1); +/* utempa = getchar(); */ printf("\n"); if (utempa == '\r' || utempa == '\n') + { + close(ttydev); goto fetch; + } if (utempa == 'h') + { + close(ttydev); break; + } } } fatal("CPU halt");