1
0
mirror of https://github.com/simh/simh.git synced 2026-01-25 19:56:25 +00:00

FRONTPANEL: sim_frontpanel API release 11

- Properly digest all register data when it arrives from register
   queries and repeat activities.
- Invoke register callback functon when transitioning to Halt state.
- Add option to access instruction history with sim_panel_get_history
   API
- More interesting testing in FrontPanelTest program
This commit is contained in:
Mark Pizzolato
2017-12-18 15:05:58 -08:00
parent 74a80c34bd
commit 33fc5c44e6
3 changed files with 209 additions and 74 deletions

View File

@@ -83,9 +83,6 @@ DisplayRegisters (PANEL *panel)
char buf1[100], buf2[100], buf3[100], buf4[100];
static const char *states[] = {"Halt", "Run "};
if (!update_display)
return;
update_display = 0;
buf1[sizeof(buf1)-1] = buf2[sizeof(buf2)-1] = buf3[sizeof(buf3)-1] = 0;
sprintf (buf1, "%4s PC: %08X SP: %08X AP: %08X FP: %08X @PC: %08X\r\n", states[sim_panel_get_state (panel)], PC, SP, AP, FP, atPC);
sprintf (buf2, "PSL: %08X Instructions Executed: %lld\r\n", PSL, simulation_time);
@@ -132,7 +129,7 @@ printf (CSI "H"); /* Position to Top of Screen (1,1) */
printf (CSI "2J"); /* Clear Screen */
#endif
printf ("\n\n\n\n");
printf ("^C to Halt, Commands: BOOT, CONT, EXIT, BREAK, NOBREAK\n");
printf ("^C to Halt, Commands: BOOT, CONT, EXIT, BREAK, NOBREAK, EXAMINE, HISTORY\n");
}
volatile int halt_cpu = 0;
@@ -159,6 +156,7 @@ if ((f = fopen (sim_config, "w"))) {
fprintf (f, "set remote telnet=2226\n");
fprintf (f, "set rem-con debug=XMT;RCV;MODE;REPEAT;CMD\n");
fprintf (f, "set remote notelnet\n");
fprintf (f, "set cpu history=128\n");
}
fprintf (f, "set cpu autoboot\n");
fprintf (f, "set cpu 64\n");
@@ -529,6 +527,30 @@ panel = NULL;
return -1;
}
int
match_command (const char *command, const char *string, const char **arg)
{
int match_chars = 0;
size_t i;
while (isspace (*string))
++string;
for (i=0; i < strlen (command); i++) {
if (command[i] == (islower (string[i]) ? toupper (string[i]) : string[i]))
continue;
if (string[i] == '\0')
break;
if ((!isspace (string[i])) || (i == 0))
return 0;
break;
}
while (isspace (string[i]))
++i;
if (arg)
*arg = &string[i];
return (i > 0) && (arg ? 1 : (string[i] == '\0'));
}
int
main (int argc, char **argv)
{
@@ -586,10 +608,42 @@ sim_panel_clear_error ();
InitDisplay();
if (panel_setup())
goto Done;
if (sim_panel_break_set (panel, "2004EAD3")) {
printf ("Error establishing breakpoint at test 52 failure path: %s\n", sim_panel_get_error());
goto Done;
}
if (sim_panel_break_set (panel, "2004E6EC")) { /* de_programmable_timers.lis line 228 */
printf ("Error establishing breakpoint at test 52 failure path programmable_timers.lis line 228: %s\n", sim_panel_get_error());
goto Done;
}
if (sim_panel_break_set (panel, "2004E7F9")) { /* de_programmable_timers.lis line 228 */
printf ("Error establishing breakpoint at test 52 failure path programmable_timers.lis line 381: %s\n", sim_panel_get_error());
goto Done;
}
if (sim_panel_break_set (panel, "2004E97C")) { /* Error clock failed to tick within at least 100 ms. - line 232 - Subtest 5 */
printf ("Error establishing breakpoint at Error clock failed to tick within at least 100 ms. - line 232 - Subtest 5: %s\n", sim_panel_get_error());
goto Done;
}
if (sim_panel_break_set (panel, "2004E9BB")) { /* Time of year clock is not ticking - line 274 - Subtest 7 */
printf ("Error establishing breakpoint at Time of year clock is not ticking - line 274 - Subtest 7: %s\n", sim_panel_get_error());
goto Done;
}
if (sim_panel_break_set (panel, "2004E9D3")) { /* Time of year clock is not ticking - line 295 - Subtest 8 */
printf ("Error establishing breakpoint at Time of year clock is not ticking - line 295 - Subtest 8: %s\n", sim_panel_get_error());
goto Done;
}
if (sim_panel_break_set (panel, "2004EA2D")) { /* Running Slow - line 359 - Subtest 9 */
printf ("Error establishing breakpoint at Running Slow - line 359 - Subtest 9: %s\n", sim_panel_get_error());
goto Done;
}
if (sim_panel_break_set (panel, "2004EA39")) { /* Running Fast - line 366 - Subtest 10 */
printf ("Error establishing breakpoint at the third test 53 failure path: %s\n", sim_panel_get_error());
goto Done;
}
sim_panel_debug (panel, "Testing with Command interface");
while (1) {
size_t i;
char cmd[512];
const char *arg;
while (sim_panel_get_state (panel) == Halt) {
DisplayRegisters (panel);
@@ -598,41 +652,55 @@ while (1) {
break;
while (strlen(cmd) && isspace(cmd[strlen(cmd)-1]))
cmd[strlen(cmd)-1] = '\0';
while (isspace(cmd[0]))
memmove (cmd, cmd+1, strlen(cmd));
for (i=0; i<strlen(cmd); i++) {
if (islower(cmd[i]))
cmd[i] = toupper(cmd[i]);
}
if (!memcmp("BOOT", cmd, 4)) {
if (sim_panel_exec_boot (panel, cmd + 4))
if (match_command ("BOOT", cmd, &arg)) {
if (sim_panel_exec_boot (panel, arg))
break;
}
else if (!strcmp("STEP", cmd)) {
else if (match_command ("BREAK ", cmd, &arg)) {
if (sim_panel_break_set (panel, arg))
printf("Error Setting Breakpoint '%s': %s\n", arg, sim_panel_get_error ());
}
else if (match_command ("NOBREAK ", cmd, &arg)) {
if (sim_panel_break_clear (panel, arg))
printf("Error Clearing Breakpoint '%s': %s\n", arg, sim_panel_get_error ());
}
else if (match_command ("STEP", cmd, NULL)) {
if (sim_panel_exec_step (panel))
break;
}
else if (!strcmp("CONT", cmd)) {
else if (match_command ("CONT", cmd, NULL)) {
if (sim_panel_exec_run (panel))
break;
}
else if (!strcmp("EXIT", cmd))
else if (match_command ("EXAMINE ", cmd, &arg)) {
int value;
if (sim_panel_gen_examine (panel, arg, sizeof (value), &value))
printf("Error EXAMINE %s: %s\n", arg, sim_panel_get_error ());
else
printf("%s: %08X\n", arg, value);
}
else if (match_command ("HISTORY ", cmd, &arg)) {
char history[10240];
int count = atoi (arg);
history[sizeof (history) - 1] = '\0';
if (sim_panel_get_history (panel, count, sizeof (history) -1, history))
printf("Error retrieving instruction history: %s\n", sim_panel_get_error ());
else
printf("%s\n", history);
}
else if ((match_command ("EXIT", cmd, NULL)) || (match_command ("QUIT", cmd, NULL)))
goto Done;
else if (!memcmp("BREAK ", cmd, 6)) {
if (sim_panel_break_set (panel, cmd + 6))
printf("Error Setting Breakpoint '%s': %s\n", cmd + 6, sim_panel_get_error ());
}
else if (!memcmp("NOBREAK ", cmd, 8)) {
if (sim_panel_break_clear (panel, cmd + 8))
printf("Error Clearing Breakpoint '%s': %s\n", cmd + 8, sim_panel_get_error ());
}
else
printf ("Huh? %s\r\n", cmd);
}
while (sim_panel_get_state (panel) == Run) {
usleep (100);
if (update_display)
if (update_display) {
update_display = 0;
DisplayRegisters(panel);
}
if (halt_cpu) {
halt_cpu = 0;
sim_panel_exec_halt (panel);