]> cloudbase.mooo.com Git - z180-stamp.git/commitdiff
Add display offset to dump_mem()
authorLeo C <erbl259-lmu@yahoo.de>
Fri, 21 Nov 2014 12:46:48 +0000 (13:46 +0100)
committerLeo C <erbl259-lmu@yahoo.de>
Fri, 21 Nov 2014 12:46:48 +0000 (13:46 +0100)
avr/cmd_mem.c
avr/debug.c
avr/print-utils.c
include/debug.h
include/print-utils.h

index 975cab4fd965e4778b4f81d9c76fe690e6157d2a..66ace105d1514288d2272f31432d088bddfaba05 100644 (file)
@@ -88,7 +88,7 @@ command_ret_t do_mem_md(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[
        }
 
        /* Print the lines. */
-       dump_mem(addr, length, z180_read_buf, NULL);
+       dump_mem(addr, addr, length, z180_read_buf, NULL);
 
        dp_last_addr = addr + length;
        dp_last_length = length;
index 1940eb003d240db4fe3d6936d7ec83fe1a8191cc..27b5329d5defdf39f9ffc8dc5e56d79f28fc3e25 100644 (file)
 #ifdef DEBUG
 
 
-void eeprom_read_buf(uint8_t *buf, uint32_t addr, uint8_t count)
-{
-       eeprom_read_block((void *) buf, (const void *) (size_t) addr, count);
-}
-
-void ram_read_buf(uint8_t *buf, uint32_t addr, uint8_t count)
-{
-               while (count--)
-                       *buf++ = *(uint8_t *) (size_t) addr++;
-}
-
-
-void dump_eep(uint32_t addr, unsigned int len, char *title)
-{
-       dump_mem(addr, len, eeprom_read_buf, title);
-}
-
-void dump_ram(uint32_t addr, unsigned int len, char *title)
-{
-       dump_mem(addr, len, ram_read_buf, title);
-}
-
-
 #if 0
 void dump_heap(void)
 {
@@ -80,7 +57,7 @@ command_ret_t do_dump_mem(cmd_tbl_t *cmdtp, int flag, int argc, char * const arg
                length = (uint16_t) strtoul(argv[2], NULL, 16);
 
        /* Print the lines. */
-       dump_mem(addr, length, readhow, NULL);
+       dump_mem(addr, addr, length, readhow, NULL);
 
        return CMD_RET_SUCCESS;
 }
index 2bd132873b75f9b528e73f337a988e1b2eb6ec3a..050140ff9215247d9d688d18c92e0758e494d2b7 100644 (file)
@@ -11,14 +11,25 @@ void print_blanks(uint_fast8_t count)
 }
 
 
-int dump_mem(uint32_t startaddr, uint32_t len,
+void eeprom_read_buf(uint8_t *buf, uint32_t addr, uint8_t count)
+{
+       eeprom_read_block((void *) buf, (const void *) (size_t) addr, count);
+}
+
+void ram_read_buf(uint8_t *buf, uint32_t addr, uint8_t count)
+{
+               while (count--)
+                       *buf++ = *(uint8_t *) (size_t) addr++;
+}
+
+int dump_mem(uint32_t address, uint32_t offset, uint32_t len,
                void (*readfkt)(uint8_t *, uint32_t, uint8_t), char *title)
 {
        uint8_t buf[16];
        char *indent = NULL;
        uint8_t llen = 16;
-       uint8_t pre = startaddr % 16;
-       uint32_t addr = startaddr & ~0x0f;
+       uint8_t pre = offset % 16;
+       offset = offset & ~0x0f;
        len += pre;
        uint8_t i;
 
@@ -30,9 +41,9 @@ int dump_mem(uint32_t startaddr, uint32_t len,
        while (len) {
                if (len < 16)
                        llen = len;
-               readfkt(buf, addr + pre, llen - pre);
+               readfkt(buf, address, llen - pre);
 
-               printf_P(PSTR("%s%.5lx:"),indent, addr);
+               printf_P(PSTR("%s%.5lx:"),indent, offset);
                for (i = 0; i < llen; i++) {
                        if ((i % 8) == 0)
                                putchar(' ');
@@ -48,8 +59,9 @@ int dump_mem(uint32_t startaddr, uint32_t len,
                        printf_P(PSTR("%c"), isprint(buf[i-pre]) ? buf[i-pre] : '.');
                putchar('\n');
 
+               address += llen - pre;
+               offset += 16;
                pre = 0;
-               addr += 16;
                len -= llen;
 
                if (ctrlc())
@@ -57,3 +69,13 @@ int dump_mem(uint32_t startaddr, uint32_t len,
        }
        return 0;
 }
+
+void dump_eep(uint32_t addr, unsigned int len, char *title)
+{
+       dump_mem(addr, addr, len, eeprom_read_buf, title);
+}
+
+void dump_ram(uint32_t addr, uint32_t offset, unsigned int len, char *title)
+{
+       dump_mem(addr, offset, len, ram_read_buf, title);
+}
index 70039a6483390f9daa4164823d6beb4c2f7ecf8a..da8e9a060ee89437c2bfd0b1ad0d2436869d6ac8 100644 (file)
@@ -30,8 +30,6 @@
 #endif /* 0 */
 
 
-void dump_eep(uint32_t addr, unsigned int len, char *title);
-void dump_ram(uint32_t addr, unsigned int len, char *title);
 void printfreelist(const char * title);
 
 
index e76cba7a994388c0487b4e0db784c91242cd71cb..238cf4074282911184fa818c745db8e5e4cc5303 100644 (file)
@@ -1,3 +1,17 @@
+#ifndef PRINT_UTILS_H
+#define PRINT_UTILS_H
+
+#include "common.h"
+#include <avr/eeprom.h>
+
 void print_blanks(uint_fast8_t count);
-int dump_mem(uint32_t startaddr, uint32_t len,
+int dump_mem(uint32_t address, uint32_t offset, uint32_t len,
                void (*readfkt)(uint8_t *, uint32_t, uint8_t), char *title);
+
+void dump_eep(uint32_t addr, unsigned int len, char *title);
+void dump_ram(uint32_t addr, uint32_t offset, unsigned int len, char *title);
+
+void eeprom_read_buf(uint8_t *buf, uint32_t addr, uint8_t count);
+void ram_read_buf(uint8_t *buf, uint32_t addr, uint8_t count);
+
+#endif /* PRINT_UTILS_H */