static int cmd_run(cproc_t cp, char **arg) { device_t dev = cproc_device(cp); device_status_t status; if (dev->ctl(dev, DEVICE_CTL_RUN) < 0) return -1; printf("Running. Press Ctrl+C to interrupt...\n"); do { status = dev->poll(dev); } while (status == DEVICE_STATUS_RUNNING); if (status == DEVICE_STATUS_INTR) printf("\n"); if (status == DEVICE_STATUS_ERROR) return -1; if (dev->ctl(dev, DEVICE_CTL_HALT) < 0) return -1; return cmd_regs(cp, NULL); }
int cmd_run(char **arg) { device_status_t status; address_t regs[DEVICE_NUM_REGS]; (void)arg; if (device_getregs(regs) < 0) { printc_err("warning: device: can't fetch registers\n"); } else { int i; for (i = 0; i < device_default->max_breakpoints; i++) { struct device_breakpoint *bp = &device_default->breakpoints[i]; if ((bp->flags & DEVICE_BP_ENABLED) && bp->type == DEVICE_BPTYPE_BREAK && bp->addr == regs[0]) break; } if (i < device_default->max_breakpoints) { printc("Stepping over breakpoint #%d at 0x%04x\n", i, regs[0]); device_ctl(DEVICE_CTL_STEP); } } if (device_ctl(DEVICE_CTL_RUN) < 0) { printc_err("run: failed to start CPU\n"); return -1; } printc("Running. Press Ctrl+C to interrupt...\n"); do { status = device_poll(); } while (status == DEVICE_STATUS_RUNNING); if (status == DEVICE_STATUS_INTR) printc("\n"); if (status == DEVICE_STATUS_ERROR) return -1; if (device_ctl(DEVICE_CTL_HALT) < 0) return -1; return cmd_regs(NULL); }
static int cmd_step(cproc_t cp, char **arg) { device_t dev = cproc_device(cp); char *count_text = get_arg(arg); int count = 1; if (count_text) count = atoi(count_text); while (count > 0) { if (dev->ctl(dev, DEVICE_CTL_STEP) < 0) return -1; count--; } return cmd_regs(cp, NULL); }
static int cmd_trace(cproc_t cp, char **arg) { device_t dev = cproc_device(cp); stab_t stab = cproc_stab(cp); uint16_t regs[DEVICE_NUM_REGS]; char *addr_text = get_arg(arg); int addr; int started = 0; device_status_t status; if (!addr_text) { fprintf(stderr, "trace: address required\n"); return -1; } if (expr_eval(stab, addr_text, &addr) < 0) { fprintf(stderr, "trace: invalid address\n"); return -1; } while (1) { if (dev->ctl(dev, DEVICE_CTL_STEP) < 0) break; if (dev->getregs(dev, regs) < 0) break; status = dev->poll(dev); if (status == DEVICE_STATUS_INTR || status == DEVICE_STATUS_ERROR) break; printf("%06x\n", regs[0]); if ((regs[0] >= addr) && !started) { started = 1; printf("Watermark reached\n"); } else if ((regs[0] < addr) && started) { printf("Below Watermark \n"); break; } } if (dev->ctl(dev, DEVICE_CTL_HALT) < 0) return -1; return cmd_regs(cp, NULL); }
int cmd_step(char **arg) { char *count_text = get_arg(arg); address_t count = 1; int i; if (count_text) { if (expr_eval(count_text, &count) < 0) { printc_err("step: can't parse count: %s\n", count_text); return -1; } } for (i = 0; i < count; i++) if (device_ctl(DEVICE_CTL_STEP) < 0) return -1; reader_set_repeat("step"); return cmd_regs(NULL); }