+/*
+ * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * (C) Copyright 2000-2003
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * SPDX-License-Identifier: GPL-2.0
+ */
/*
* Misc boot support
#include <util/atomic.h>
#include "command.h"
+#include "cli_readline.h"
+#include "cli.h"
+#include "env.h"
#include "con-utils.h"
#include "z80-if.h"
#include "z180-serv.h"
hdrom_address[sec]+hdrom_length_of_sections[sec] - 1,
hdrom_length_of_sections[sec]);
- z80_bus_cmd(Request);
z80_write_block_P((const FLASH unsigned char *) &hdrom[sec_base], /* src */
hdrom_address[sec], /* dest */
hdrom_length_of_sections[sec]); /* len */
- z80_bus_cmd(Release);
sec_base+=hdrom_length_of_sections[sec];
sec++;
}
(void) cmdtp; (void) flag; (void) argc; (void) argv;
if (z80_bus_state() & ZST_RUNNING) {
- printf_P(PSTR("## Can't load while CPU is running!\n"));
+ my_puts_P(PSTR("Can't load while CPU is running!\n"));
return CMD_RET_FAILURE;
}
-
+ if (!(z80_bus_cmd(Request) & ZST_ACQUIRED)) {
+ my_puts_P(PSTR("Bus timeout\n"));
+ return CMD_RET_FAILURE;
+ }
z80_load_mem();
+ z80_bus_cmd(Release);
return CMD_RET_SUCCESS;
}
}
if (argc > 1)
- count = (uint16_t) strtoul(argv[2], NULL, 16);
+ count = (uint16_t) strtoul(argv[1], NULL, 16);
z80_bus_cmd(Request);
while (count--)
if (addr != 0) {
uint8_t tmp[3];
- uint_fast8_t i;
z80_bus_cmd(Request);
- for (i = 0; i < 3; i++)
- tmp[i] = z80_read(i);
+ z80_read_block (tmp, 0, 3);
z80_write(0, 0xc3);
z80_write(1, addr);
z80_write(2, (addr >> 8));
z80_bus_cmd(Run);
z80_bus_cmd(M_Cycle);
z80_bus_cmd(M_Cycle);
- for (i = 0; i < 3; i++)
- z80_write(i, tmp[i]);
+ z80_write_block(tmp, 0, 3);
} else
z80_bus_cmd(Run);
{
(void) cmdtp; (void) flag; (void) argc; (void) argv;
- printf_P(PSTR("## CPU now in reset state.\n"));
+ printf_P(PSTR("CPU now in reset state.\n"));
reset_cpu(Reset);
return CMD_RET_SUCCESS;
{ printf_P(PSTR("\n"
"------------------------------------------------\n"
" ?,H - This Help\n"
- " R - Reset (Restart) CPU\n"
" Q,X - Return to command line\n"
- " \\ - code input:\n"
- " \\nnn 3 decimal digits character code\n"
- " \\Xhh 2 hexadecimal digits character code\n"
- " ^%c - (Escape char) Type again to send itself\n"
+ " R - Reset (Restart) CPU\n"
+ " : - Execute monitor command\n"
+ " \\ - code input:\n"
+ " \\nnn 3 decimal digits character code\n"
+ " \\Xhh 2 hexadecimal digits character code\n"
+ " ^%c - (Escape char) Type again to send itself\n"
"key>"
), esc + 0x40);
}
// uint8_t help_prompt = 0;
uint8_t code = 0;
uint8_t state = 0;
+ char esc_char = (char) getenv_ulong(PSTR(ENV_ESC_CHAR), 16, CONFIG_ESC_CHAR);
(void) cmdtp; (void) flag; (void) argc; (void) argv;
+ printf_P(PSTR("Connecting to CPU. Escape character is '^%c'.\n"),
+ esc_char + 0x40);
while (1) {
pending = (Stat & S_CON_PENDING) != 0;
Stat &= ~S_CON_PENDING;
}
- if (pending)
- while ((ch = z80_memfifo_getc(fifo_conout)) >= 0)
+ if (pending) {
+ uint8_t count = 100;
+ while ((ch = z80_memfifo_getc(fifo_conout)) >= 0 && --count)
putchar(ch);
+ }
if ((ch = my_getchar(0)) >= 0) {
switch (state) {
case 0:
- if (ch == CONFIG_ESC_CHAR) {
+ if (ch == esc_char) {
state = 1;
/* TODO: Timer starten */
} else {
case '?':
case 'H':
- print_con_usage(CONFIG_ESC_CHAR);
+ print_con_usage(esc_char);
state = 2;
break;
goto quit;
break;
+ case ':':
+ putchar('\n');
+ int cmdlen = cli_readline(PSTR(": "), 1);
+ if (cmdlen > 0)
+ run_command(console_buffer, 0);
+ break;
+
case '\\':
code = 0;
state = 3;
break;
- case CONFIG_ESC_CHAR:
- z80_memfifo_putc(fifo_conin, ch);
- break;
default:
+ if (ch == esc_char)
+ z80_memfifo_putc(fifo_conin, ch);
break;
}
break;
if (isdigit(ch)) {
code = code * 10 + ch - '0';
state++;
+ } else {
+ if (state > 3)
+ z80_memfifo_putc(fifo_conin, code);
+ z80_memfifo_putc(fifo_conin, ch);
+ state = 0;
}
if (state > 5) {
z80_memfifo_putc(fifo_conin, code);
ch -= 'A' - 10;
code = code * 16 + ch - '0';
state++;
+ }else {
+ if (state > 6)
+ z80_memfifo_putc(fifo_conin, code);
+ z80_memfifo_putc(fifo_conin, ch);
+ state = 0;
}
if (state > 7) {
z80_memfifo_putc(fifo_conin, code);