Use SFR access funcs. Support 'dump' command. Add -m (monitor) flag.
authorKeith Packard <keithp@keithp.com>
Sun, 28 Dec 2008 08:11:13 +0000 (00:11 -0800)
committerKeith Packard <keithp@keithp.com>
Sun, 28 Dec 2008 08:11:13 +0000 (00:11 -0800)
Not all SFRs are visible in the unified address space, so the SFR-specific
accessors are required.

The dump command is the same as the various 'd*'
commands, but also supports dumping program memory.

The new -m (monitor) flag watches the command stream between s51 and sdcdb.

Signed-off-by: Keith Packard <keithp@keithp.com>
s51/s51-command.c
s51/s51-main.c
s51/s51.h

index b4f853be7794b60ac244902d5eeb2e38ef39fb2a..25328f1ece4e4b1f587edd4e677642ac092c724f 100644 (file)
@@ -46,6 +46,21 @@ parse_uint16(char *value, uint16_t *uint16)
        return command_success;
 }
 
        return command_success;
 }
 
+static enum command_result
+parse_uint8(char *value, uint8_t *uint8)
+{
+       int     v;
+       enum command_result result;
+
+       result = parse_int(value, &v);
+       if (result != command_success)
+               return command_error;
+       if (v < 0 || v > 0xff)
+               return command_error;
+       *uint8 = v;
+       return command_success;
+}
+
 enum command_result
 command_quit (int argc, char **argv)
 {
 enum command_result
 command_quit (int argc, char **argv)
 {
@@ -97,19 +112,19 @@ command_di (int argc, char **argv)
 enum command_result
 command_ds (int argc, char **argv)
 {
 enum command_result
 command_ds (int argc, char **argv)
 {
-       uint16_t start, end;
-       uint8_t memory[65536];
+       uint8_t start, end;
+       uint8_t memory[0x100];
        uint8_t status;
        int length;
        
        if (argc != 3)
                return command_error;
        uint8_t status;
        int length;
        
        if (argc != 3)
                return command_error;
-       if (parse_uint16(argv[1], &start) != command_success)
+       if (parse_uint8(argv[1], &start) != command_success)
                return command_error;
                return command_error;
-       if (parse_uint16(argv[2], &end) != command_success)
+       if (parse_uint8(argv[2], &end) != command_success)
                return command_error;
        length = (int) end - (int) start + 1;
                return command_error;
        length = (int) end - (int) start + 1;
-       status = ccdbg_read_memory(s51_dbg, start + 0xdf00, memory, length);
+       status = ccdbg_read_sfr(s51_dbg, start, memory, length);
        dump_bytes(memory, length, start);
        return command_success;
 }
        dump_bytes(memory, length, start);
        return command_success;
 }
@@ -143,6 +158,15 @@ command_set (int argc, char **argv)
 enum command_result
 command_dump (int argc, char **argv)
 {
 enum command_result
 command_dump (int argc, char **argv)
 {
+       if (argv[1]) {
+               if (strcmp(argv[1], "rom") == 0 ||
+                   strcmp(argv[1], "xram") == 0)
+                       return command_dx(argc-1, argv+1);
+               if (strcmp(argv[1], "iram") == 0)
+                       return command_di(argc-1, argv+1);
+               if (strcmp(argv[1], "sfr") == 0)
+                       return command_ds(argc-1, argv+1);
+       }
        return command_error;
 }
 
        return command_error;
 }
 
index 27ed571aca68eb360f5267d8aaff33d27ee55720..eef55157e2c8ead33bbca85695fb2e0439acac1b 100644 (file)
@@ -31,6 +31,7 @@ static double freq = 11059200;
 char *s51_prompt = "> ";
 struct ccdbg *s51_dbg;
 int s51_interrupted = 0;
 char *s51_prompt = "> ";
 struct ccdbg *s51_dbg;
 int s51_interrupted = 0;
+int s51_monitor = 0;
 
 static FILE *s51_input;
 static FILE *s51_output;
 
 static FILE *s51_input;
 static FILE *s51_output;
@@ -54,7 +55,7 @@ main(int argc, char **argv)
        char *endptr;
        struct sigvec vec, ovec;
 
        char *endptr;
        struct sigvec vec, ovec;
 
-       while ((opt = getopt(argc, argv, "PVvHht:X:c:r:Z:s:S:p:")) != -1) {
+       while ((opt = getopt(argc, argv, "PVvHhmt:X:c:r:Z:s:S:p:")) != -1) {
                switch (opt) {
                case 't':
                        cpu = optarg;
                switch (opt) {
                case 't':
                        cpu = optarg;
@@ -100,6 +101,9 @@ main(int argc, char **argv)
                case 'h':
                        usage ();
                        break;
                case 'h':
                        usage ();
                        break;
+               case 'm':
+                       s51_monitor = 1;
+                       break;
                }
        }
        if (s51_port) {
                }
        }
        if (s51_port) {
@@ -174,10 +178,8 @@ s51_printf(char *format, ...)
 
        va_start(ap, format);
        vfprintf(s51_output, format, ap);
 
        va_start(ap, format);
        vfprintf(s51_output, format, ap);
-#if 1
-       if (s51_port)
+       if (s51_monitor)
                vfprintf(stdout, format, ap);
                vfprintf(stdout, format, ap);
-#endif
        va_end(ap);
 }
 
        va_end(ap);
 }
 
@@ -197,10 +199,8 @@ s51_read_line(char *line, int len)
                s51_putc('\0');
        fflush(s51_output);
        ret = fgets(line, len, s51_input) != NULL;
                s51_putc('\0');
        fflush(s51_output);
        ret = fgets(line, len, s51_input) != NULL;
-#if 1
-       if (s51_port)
+       if (s51_monitor)
                printf("> %s", line);
                printf("> %s", line);
-#endif
        fflush(stdout);
        return ret;
 }
        fflush(stdout);
        return ret;
 }
index 7c96e2a65ca2fdb5de2d31036b38635ae8e60582..eab61452ad49e108e713d471b848199e1724294c 100644 (file)
--- a/s51/s51.h
+++ b/s51/s51.h
@@ -21,6 +21,7 @@
 extern char *s51_prompt;
 extern struct ccdbg *s51_dbg;
 extern int s51_interrupted;
 extern char *s51_prompt;
 extern struct ccdbg *s51_dbg;
 extern int s51_interrupted;
+extern int s51_monitor;
 
 enum command_result {
        command_success, command_debug, command_syntax, command_interrupt, command_error,
 
 enum command_result {
        command_success, command_debug, command_syntax, command_interrupt, command_error,