1
0
mirror of https://github.com/prirun/p50em.git synced 2026-03-08 03:19:23 +00:00

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.
This commit is contained in:
Dennis Boone
2021-02-06 17:11:55 -05:00
parent 3d71fd85f0
commit ea2edd89de

20
em.c
View File

@@ -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");