]> cloudbase.mooo.com Git - z180-stamp.git/blobdiff - avr/cmd_mem.c
correct fatwrite docu
[z180-stamp.git] / avr / cmd_mem.c
index 53b18426fbcc1400718ab88f1b2581ab43cf3ed0..a725c612056b956fb68a05121abba015fc9a7b68 100644 (file)
@@ -4,7 +4,7 @@
  * (C) Copyright 2000
  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  *
- * SPDX-License-Identifier:    GPL-2.0+
+ * SPDX-License-Identifier:    GPL-2.0
  */
 
 /*
@@ -42,13 +42,14 @@ static      uint32_t        base_address = 0;
 
 /*--------------------------------------------------------------------------*/
 
-
-void z180_read_buf(uint8_t *buf, uint32_t addr, uint8_t count)
+int z180_read_buf(uint8_t *buf, uint32_t addr, uint8_t count)
 {
-               if (z80_bus_cmd(Request) & ZST_ACQUIRED) {
-                       z80_read_block (buf, addr, count);
-                       z80_bus_cmd(Release);
-               }
+       if (!(z80_bus_cmd(Request) & ZST_ACQUIRED))
+               return -1;
+
+       z80_read_block (buf, addr, count);
+       z80_bus_cmd(Release);
+       return 0;
 }
 
 /*--------------------------------------------------------------------------*/
@@ -92,10 +93,16 @@ command_ret_t do_mem_md(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[
        }
 
        /* Print the lines. */
-       dump_mem(addr, addr, length, z180_read_buf, NULL);
+       int ret = dump_mem(addr, addr, length, z180_read_buf, NULL);
+       if (ret == -2)  { /* TODO: Error codes */
+               my_puts_P(PSTR("Bus timeout\n"));
+               return  CMD_RET_FAILURE;
+       }
 
-       dp_last_addr = addr + length;
-       dp_last_length = length;
+       if (ret >= 0) {
+               dp_last_addr = addr + length;
+               dp_last_length = length;
+       }
        return CMD_RET_SUCCESS;
 }
 
@@ -144,7 +151,7 @@ mod_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const argv[])
                z80_bus_cmd(Release);
                printf_P(PSTR("%05lx: %02x"), addr, data);
 
-               nbytes = cli_readline(PSTR(" ? "));
+               nbytes = cli_readline(PSTR(" ? "), 0);
                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.
@@ -152,8 +159,8 @@ mod_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const argv[])
                        if (incrflag)
                                addr += nbytes ? -1 : 1;
                        nbytes = 1;
-               }
-               else {
+
+               else {
                        char *endp;
                        data = strtoul(console_buffer, &endp, 16);
                        nbytes = endp - console_buffer;