#define CONFIG_SYS_MEMTEST_SCRATCH 0
#endif
-static int mod_mem(cmd_tbl_t *, int, int, int, char * const []);
-
/* Display values from last command.
* Memory modify remembered values are different from display memory.
*/
if (len < 16)
llen = len;
- z80_request_bus();
+ z80_bus_cmd(Request);
for (i = pre; i < llen; i++)
buf[i] = z80_read(addr + i);
- z80_release_bus();
+ z80_bus_cmd(Release);
printf_P(PSTR("%.5lx:"), addr);
#if 0
* Syntax:
* md {addr} {len}
*/
-int do_mem_md(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+command_ret_t do_mem_md(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
uint32_t addr, length;
dp_last_addr = addr + length;
dp_last_length = length;
- return 0;
+ return CMD_RET_SUCCESS;
+}
+
+/* Modify memory.
+ *
+ * Syntax:
+ * mm {addr}
+ * nm {addr}
+ */
+static command_ret_t
+mod_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const argv[])
+{
+ uint32_t addr;
+ uint8_t data;
+ int nbytes;
+
+ (void) cmdtp;
+
+ if (argc != 2)
+ return CMD_RET_USAGE;
+
+ /* We use the last specified parameters, unless new ones are
+ * entered.
+ */
+ addr = mm_last_addr;
+
+ if ((flag & CMD_FLAG_REPEAT) == 0) {
+ /* New command specified.
+ */
+
+ /* Address is specified since argc > 1
+ */
+ addr = strtoul(argv[1], NULL, 16);
+ addr += base_address;
+ }
+
+ /* Print the address, followed by value. Then accept input for
+ * the next value. A non-converted value exits.
+ */
+ do {
+ z80_bus_cmd(Request);
+ data = z80_read(addr);
+ printf_P(PSTR("%05lx: %02x"), addr, data);
+ z80_bus_cmd(Release);
+
+ nbytes = cli_readline(PSTR(" ? "));
+ if (nbytes == 0 || (nbytes == 1 && console_buffer[0] == '-')) {
+ /* <CR> pressed as only input, don't modify current
+ * location and move to next. "-" pressed will go back.
+ */
+ if (incrflag)
+ addr += nbytes ? -1 : 1;
+ nbytes = 1;
+ }
+ else {
+ char *endp;
+ data = strtoul(console_buffer, &endp, 16);
+ nbytes = endp - console_buffer;
+ if (nbytes) {
+ z80_bus_cmd(Request);
+ z80_write(addr, data);
+ z80_bus_cmd(Release);
+ if (incrflag)
+ addr++;
+ }
+ }
+ } while (nbytes);
+
+ mm_last_addr = addr;
+ return CMD_RET_SUCCESS;
}
-int do_mem_mm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+
+command_ret_t do_mem_mm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
return mod_mem (cmdtp, 1, flag, argc, argv);
}
-int do_mem_nm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+command_ret_t do_mem_nm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
return mod_mem (cmdtp, 0, flag, argc, argv);
}
-int do_mem_mw(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+command_ret_t do_mem_mw(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
uint8_t writeval;
uint32_t addr, count;
count = 1;
}
- z80_request_bus();
+ z80_bus_cmd(Request);
while (count-- > 0) {
z80_write(addr, writeval);
++addr;
}
- z80_release_bus();
+ z80_bus_cmd(Release);
- return 0;
+ return CMD_RET_SUCCESS;
}
#ifdef CONFIG_MX_CYCLIC
-int do_mem_mdc ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+command_ret_t do_mem_mdc ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
int i;
uint32_t count;
/* check for ctrl-c to abort... */
if (ctrlc()) {
- my_puts("Abort\n");
- return 0;
+ my_puts_P(PSTR("Abort\n"));
+ return CMD_RET_SUCCESS;
}
}
- return 0;
+ return CMD_RET_SUCCESS;
}
-int do_mem_mwc ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+command_ret_t do_mem_mwc ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
int i;
uint32_t count;
/* check for ctrl-c to abort... */
if (ctrlc()) {
- my_puts("Abort\n");
- return 0;
+ my_puts_P(PSTR("Abort\n"));
+ return CMD_RET_SUCCESS;
}
}
- return 0;
+ return CMD_RET_SUCCESS;
}
#endif /* CONFIG_MX_CYCLIC */
-int do_mem_cmp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+command_ret_t do_mem_cmp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
uint32_t addr1, addr2, count, ngood;
- int rcode = 0;
+ command_ret_t rcode = CMD_RET_SUCCESS;
uint8_t byte1, byte2;
(void) cmdtp;
count = strtoul(argv[3], NULL, 16);
for (ngood = 0; ngood < count; ++ngood) {
- z80_request_bus();
+ z80_bus_cmd(Request);
byte1 = z80_read(addr1);
byte2 = z80_read(addr2);
- z80_release_bus();
+ z80_bus_cmd(Release);
if (byte1 != byte2) {
printf( "byte at 0x%05lx (%#02x) != "
"byte at 0x%05lx (%#02x)\n",
addr1, byte1, addr2, byte2);
- rcode = 1;
+ rcode = CMD_RET_FAILURE;
break;
}
addr1++;
/* check for ctrl-c to abort... */
if (ctrlc()) {
- my_puts("Abort\n");
- return 0;
+ my_puts_P(PSTR("Abort\n"));
+ return CMD_RET_SUCCESS;
}
}
- printf("Total of %ld byte(s) (0x%lx) were the same\n", ngood, ngood);
+ printf_P(PSTR("Total of %ld byte(s) (0x%lx) were the same\n"), ngood, ngood);
return rcode;
}
-int do_mem_cp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+command_ret_t do_mem_cp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
uint32_t src, dest, count;
int_fast8_t step;
count = strtoul(argv[3], NULL, 16);
if (count == 0) {
- my_puts ("Zero length ???\n");
- return 1;
+ my_puts_P(PSTR("Zero length?\n"));
+ return CMD_RET_FAILURE;
}
if (dest > src) {
while (count-- > 0) {
uint8_t data;
- z80_request_bus();
+ z80_bus_cmd(Request);
data = z80_read(src);
z80_write(dest, data);
- z80_release_bus();
+ z80_bus_cmd(Release);
src += step;
dest += step;
/* check for ctrl-c to abort... */
if (ctrlc()) {
- my_puts("Abort\n");
- return 0;
+ my_puts_P(PSTR("Abort\n"));
+ return CMD_RET_SUCCESS;
}
}
- return 0;
+ return CMD_RET_SUCCESS;
}
-int do_mem_base(cmd_tbl_t *cmdtp, int flag, int argc,
+command_ret_t do_mem_base(cmd_tbl_t *cmdtp, int flag, int argc,
char * const argv[])
{
(void) cmdtp;
base_address = strtoul(argv[1], NULL, 16);
}
/* Print the current base address. */
- printf("Base Address: 0x%05lx\n", base_address);
- return 0;
+ printf_P(PSTR("Base Address: 0x%05lx\n"), base_address);
+ return CMD_RET_SUCCESS;
}
-int do_mem_loop(cmd_tbl_t *cmdtp, int flag, int argc,
+command_ret_t do_mem_loop(cmd_tbl_t *cmdtp, int flag, int argc,
char * const argv[])
{
uint32_t addr, length;
* If we have only one object, just run infinite loops.
*/
if (length == 1) {
- z80_request_bus();
+ z80_bus_cmd(Request);
for (;;)
z80_read(addr);
- z80_release_bus();
+ z80_bus_cmd(Release);
}
- z80_request_bus();
+ z80_bus_cmd(Request);
for (;;) {
uint32_t i = length;
uint32_t p = addr;
while (i-- > 0)
z80_read(p++);
}
- z80_release_bus();
+ z80_bus_cmd(Release);
- return 0;
+ return CMD_RET_SUCCESS;
}
#ifdef CONFIG_LOOPW
-int do_mem_loopw (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+command_ret_t do_mem_loopw (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
uint32_t addr, length;
uint8_t data;
* If we have only one object, just run infinite loops.
*/
if (length == 1) {
- z80_request_bus();
+ z80_bus_cmd(Request);
for (;;)
z80_write(addr, data);
}
*dummy = ~val; /* clear the test data off the bus */
readback = *addr;
if (readback != val) {
- printf("FAILURE (data line): "
- "expected %05lx, actual %05lx\n",
+ printf_P(PSTR("FAILURE (data line): "
+ "expected %05lx, actual %05lx\n"),
val, readback);
errs++;
if (ctrlc())
*dummy = val;
readback = *addr;
if (readback != ~val) {
- printf("FAILURE (data line): "
- "Is %05lx, should be %05lx\n",
+ printf_P(PSTR("FAILURE (data line): "
+ "Is %05lx, should be %05lx\n"),
readback, ~val);
errs++;
if (ctrlc())
for (offset = 1; offset < num_words; offset <<= 1) {
temp = addr[offset];
if (temp != pattern) {
- printf("\nFAILURE: Address bit stuck high @ 0x%.5lx:"
- " expected 0x%.5lx, actual 0x%.5lx\n",
+ printf_P(PSTR("\nFAILURE: Address bit stuck high @ 0x%.5lx:"
+ " expected 0x%.5lx, actual 0x%.5lx\n"),
start_addr + offset*sizeof(vu_long),
pattern, temp);
errs++;
for (offset = 1; offset < num_words; offset <<= 1) {
temp = addr[offset];
if ((temp != pattern) && (offset != test_offset)) {
- printf("\nFAILURE: Address bit stuck low or"
+ printf_P(PSTR("\nFAILURE: Address bit stuck low or"
" shorted @ 0x%.5lx: expected 0x%.5lx,"
- " actual 0x%.5lx\n",
+ " actual 0x%.5lx\n"),
start_addr + offset*sizeof(vu_long),
pattern, temp);
errs++;
for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
temp = addr[offset];
if (temp != pattern) {
- printf("\nFAILURE (read/write) @ 0x%.5lx:"
- " expected 0x%.5lx, actual 0x%.5lx)\n",
+ printf_P(PSTR("\nFAILURE (read/write) @ 0x%.5lx:"
+ " expected 0x%.5lx, actual 0x%.5lx)\n"),
start_addr + offset*sizeof(vu_long),
pattern, temp);
errs++;
anti_pattern = ~pattern;
temp = addr[offset];
if (temp != anti_pattern) {
- printf("\nFAILURE (read/write): @ 0x%.5lx:"
- " expected 0x%.5lx, actual 0x%.5lx)\n",
+ printf_P(PSTR("\nFAILURE (read/write): @ 0x%.5lx:"
+ " expected 0x%.5lx, actual 0x%.5lx)\n"),
start_addr + offset*sizeof(vu_long),
anti_pattern, temp);
errs++;
}
length = (end_addr - start_addr) / sizeof(uint32_t);
end = buf + length;
- printf("\rPattern %08lX Writing..."
+ printf_P(PSTR("\rPattern %08lX Writing..."
"%12s"
- "\b\b\b\b\b\b\b\b\b\b",
+ "\b\b\b\b\b\b\b\b\b\b"),
pattern, "");
for (addr = buf, val = pattern; addr < end; addr++) {
val += incr;
}
- my_puts("Reading...");
+ my_puts_P(PSTR("Reading..."));
for (addr = buf, val = pattern; addr < end; addr++) {
readback = *addr;
if (readback != val) {
uint32_t offset = addr - buf;
- printf("\nMem error @ 0x%08X: "
- "found %08lX, expected %08lX\n",
+ printf_P(PSTR("\nMem error @ 0x%08X: "
+ "found %08lX, expected %08lX\n"),
(unsigned int)(uintptr_t)(start_addr + offset*sizeof(vu_long)),
readback, val);
errs++;
* configured using CONFIG_SYS_ALT_MEMTEST. The complete test loops until
* interrupted by ctrl-c or by a failure of one of the sub-tests.
*/
-int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc,
+command_ret_t do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc,
char * const argv[])
{
uint32_t start, end;
vu_long *buf, *dummy;
int iteration_limit;
+/* TODO: command_ret_t */
int ret;
uint32_t errs = 0; /* number of errors, or -1 if interrupted */
uint32_t pattern;
else
iteration_limit = 0;
- printf("Testing %08x ... %08x:\n", (unsigned int)start, (unsigned int)end);
+ printf_P(PSTR("Testing %08x ... %08x:\n"), (unsigned int)start, (unsigned int)end);
debug("%s:%d: start %#05lx end %#05lx\n", __func__, __LINE__,
start, end);
break;
}
- printf("Iteration: %6d\r", iteration + 1);
+ printf_P(PSTR("Iteration: %6d\r"), iteration + 1);
debug("\n");
if (alt_test) {
errs = mem_test_alt(buf, start, end, dummy);
putc('\n');
ret = 1;
} else {
- printf("Tested %d iteration(s) with %lu errors.\n",
+ printf_P(PSTR("Tested %d iteration(s) with %lu errors.\n"),
iteration, errs);
ret = errs != 0;
}
}
#endif /* CONFIG_CMD_MEMTEST */
-/* Modify memory.
- *
- * Syntax:
- * mm {addr}
- * nm {addr}
- */
-static int
-mod_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const argv[])
-{
- uint32_t addr;
- uint8_t data;
- int nbytes;
-
- (void) cmdtp;
-
- if (argc != 2)
- return CMD_RET_USAGE;
-
- /* We use the last specified parameters, unless new ones are
- * entered.
- */
- addr = mm_last_addr;
-
- if ((flag & CMD_FLAG_REPEAT) == 0) {
- /* New command specified.
- */
-
- /* Address is specified since argc > 1
- */
- addr = strtoul(argv[1], NULL, 16);
- addr += base_address;
- }
-
- /* Print the address, followed by value. Then accept input for
- * the next value. A non-converted value exits.
- */
- do {
- z80_request_bus();
- data = z80_read(addr);
- printf("%05lx: %02x", addr, data);
- z80_release_bus();
-
- nbytes = cli_readline(PSTR(" ? "));
- if (nbytes == 0 || (nbytes == 1 && console_buffer[0] == '-')) {
- /* <CR> pressed as only input, don't modify current
- * location and move to next. "-" pressed will go back.
- */
- if (incrflag)
- addr += nbytes ? -1 : 1;
- nbytes = 1;
- }
- else {
- char *endp;
- data = strtoul(console_buffer, &endp, 16);
- nbytes = endp - console_buffer;
- if (nbytes) {
- z80_request_bus();
- z80_write(addr, data);
- z80_release_bus();
- if (incrflag)
- addr++;
- }
- }
- } while (nbytes);
-
- mm_last_addr = addr;
- return 0;
-}
-