summaryrefslogtreecommitdiff
path: root/s51
diff options
context:
space:
mode:
Diffstat (limited to 's51')
-rw-r--r--s51/s51-command.c74
-rw-r--r--s51/s51-parse.c71
-rw-r--r--s51/s51.h23
3 files changed, 128 insertions, 40 deletions
diff --git a/s51/s51-command.c b/s51/s51-command.c
index 25328f1e..63d142f4 100644
--- a/s51/s51-command.c
+++ b/s51/s51-command.c
@@ -69,12 +69,12 @@ command_quit (int argc, char **argv)
}
static void
-dump_bytes(uint8_t *memory, int length, uint16_t start)
+dump_bytes(uint8_t *memory, int length, uint16_t start, char *format)
{
int group, i;
for (group = 0; group < length; group += 8) {
- s51_printf("0x%04x ", start + group);
+ s51_printf(format, start + group);
for (i = group; i < length && i < group + 8; i++)
s51_printf("%02x ", memory[i]);
for (; i < group + 8; i++)
@@ -105,7 +105,7 @@ command_di (int argc, char **argv)
return command_error;
length = (int) end - (int) start + 1;
status = ccdbg_read_memory(s51_dbg, start + 0xff00, memory, length);
- dump_bytes(memory, length, start);
+ dump_bytes(memory, length, start, "0x%02x ");
return command_success;
}
@@ -125,7 +125,7 @@ command_ds (int argc, char **argv)
return command_error;
length = (int) end - (int) start + 1;
status = ccdbg_read_sfr(s51_dbg, start, memory, length);
- dump_bytes(memory, length, start);
+ dump_bytes(memory, length, start, "0x%02x ");
return command_success;
}
@@ -145,7 +145,7 @@ command_dx (int argc, char **argv)
return command_error;
length = (int) end - (int) start + 1;
status = ccdbg_read_memory(s51_dbg, start, memory, length);
- dump_bytes(memory, length, start);
+ dump_bytes(memory, length, start, "0x%04x ");
return command_success;
}
@@ -174,6 +174,7 @@ enum command_result
command_file (int argc, char **argv)
{
struct hex_file *hex;
+ struct hex_image *image;
FILE *file;
if (argc != 2)
@@ -189,7 +190,10 @@ command_file (int argc, char **argv)
ccdbg_hex_file_free(hex);
return command_error;
}
- start_address = hex->records[0]->address;
+ image = ccdbg_hex_image_create(hex);
+ ccdbg_hex_file_free(hex);
+ start_address = image->address;
+ ccdbg_set_rom(s51_dbg, image);
return command_success;
}
@@ -474,6 +478,12 @@ command_halt (int argc, char **argv)
}
enum command_result
+command_stop (int argc, char **argv)
+{
+ return command_success;
+}
+
+enum command_result
command_reset (int argc, char **argv)
{
ccdbg_debug_mode(s51_dbg);
@@ -511,6 +521,58 @@ command_status(int argc, char **argv)
return command_success;
}
+static enum command_result
+info_breakpoints(int argc, char **argv)
+{
+ int b;
+ uint16_t address;
+ enum command_result result;
+
+ if (argc == 1) {
+ s51_printf("Num Type Disp Hit Cnt Address What\n");
+ for (b = 0; b < CC_NUM_BREAKPOINTS; b++)
+ if (breakpoints[b].enabled) {
+ s51_printf("%-3d fetch %s 1 1 0x%04x uc::disass() unimplemented\n",
+ b,
+ breakpoints[b].temporary ? "del " : "keep",
+ breakpoints[b].address);
+ }
+ return command_success;
+ }
+
+}
+
+static enum command_result
+info_help(int argc, char **argv);
+
+static struct command_function infos[] = {
+ { "breakpoints", "b", info_breakpoints, "[b]reakpoints",
+ "List current breakpoints\n" },
+ { "help", "?", info_help, "help",
+ "Print this list\n" },
+
+ { NULL, NULL, NULL, NULL, NULL },
+};
+
+static enum command_result
+info_help(int argc, char **argv)
+{
+ return command_function_help(infos, argc, argv);
+}
+
+enum command_result
+command_info(int argc, char **argv)
+{
+ struct command_function *func;
+
+ if (argc < 2)
+ return command_error;
+ func = command_string_to_function(infos, argv[1]);
+ if (!func)
+ return command_syntax;
+ return (*func->func)(argc-1, argv+1);
+}
+
enum command_result
cc_wait(void)
{
diff --git a/s51/s51-parse.c b/s51/s51-parse.c
index d0bfb45b..749d7bd8 100644
--- a/s51/s51-parse.c
+++ b/s51/s51-parse.c
@@ -18,14 +18,6 @@
#include "s51.h"
-struct command_function {
- char *name;
- char *alias;
- enum command_result (*func)(int argc, char **argv);
- char *usage;
- char *help;
-};
-
static struct command_function functions[] = {
{ "help", "?", command_help, "help", "Print this list\n" },
{ "quit", "q", command_quit, "[q]uit", "Quit\n" },
@@ -50,6 +42,8 @@ static struct command_function functions[] = {
"Clear break point\n" },
{ "run", "r", command_run, "[r]un [start] [stop]",
"Run with optional start and temp breakpoint addresses\n" },
+ { "go", "g", command_run, "[g]o [start] [stop]",
+ "Run with optional start and temp breakpoint addresses\n" },
{ "next", "n", command_next, "[n]ext",
"Step over one instruction, past any call\n" },
{ "step", "s", command_step, "[s]tep",
@@ -62,10 +56,13 @@ static struct command_function functions[] = {
"Reset the CPU\n" },
{ "status","status",command_status, "status",
"Display CC1111 debug status\n" },
+ { "info", "i", command_info, "[i]info",
+ "Get information\n" },
+ { "stop", "stop", command_stop, "stop",
+ "Ignored\n" },
+ { NULL, NULL, NULL, NULL, NULL },
};
-#define NUM_FUNCTIONS (sizeof functions / sizeof functions[0])
-
#ifndef FALSE
#define FALSE 0
#define TRUE 1
@@ -106,17 +103,41 @@ string_to_int(char *s, int *v)
return TRUE;
}
-static struct command_function *
-command_string_to_function(char *name)
+struct command_function *
+command_string_to_function(struct command_function *functions, char *name)
{
int i;
- for (i = 0; i < NUM_FUNCTIONS; i++)
+ for (i = 0; functions[i].name; i++)
if (!strcmp(name, functions[i].name) ||
!strcmp(name, functions[i].alias))
return &functions[i];
return NULL;
}
+enum command_result
+command_function_help(struct command_function *functions, int argc, char **argv)
+{
+ int i;
+ struct command_function *func;
+
+ if (argc == 1) {
+ for (i = 0; functions[i].name; i++)
+ s51_printf("%-10s%s\n", functions[i].name,
+ functions[i].usage);
+ } else {
+ for (i = 1; i < argc; i++) {
+ func = command_string_to_function(functions, argv[i]);
+ if (!func) {
+ s51_printf("%-10s unknown command\n", argv[i]);
+ return command_syntax;
+ }
+ s51_printf("%-10s %s\n%s", func->name,
+ func->usage, func->help);
+ }
+ }
+ return command_debug;
+}
+
static int
command_split_into_words(char *line, char **argv)
{
@@ -153,28 +174,10 @@ command_split_into_words(char *line, char **argv)
enum command_result
command_help(int argc, char **argv)
{
- int i;
- struct command_function *func;
-
- if (argc == 1) {
- for (i = 0; i < NUM_FUNCTIONS; i++)
- s51_printf("%-10s%s\n", functions[i].name,
- functions[i].usage);
- } else {
- for (i = 1; i < argc; i++) {
- func = command_string_to_function(argv[i]);
- if (!func) {
- s51_printf("%-10s unknown command\n", argv[i]);
- return command_syntax;
- }
- s51_printf("%-10s %s\n%s", func->name,
- func->usage, func->help);
- }
- }
- return command_debug;
+ return command_function_help(functions, argc, argv);
}
-static void
+void
command_syntax_error(int argc, char **argv)
{
s51_printf("Syntax error in:");
@@ -206,7 +209,7 @@ command_read (void)
s51_interrupted = 0;
argc = command_split_into_words(line, argv);
if (argc > 0) {
- func = command_string_to_function(argv[0]);
+ func = command_string_to_function(functions, argv[0]);
if (!func)
command_syntax_error(argc, argv);
else
diff --git a/s51/s51.h b/s51/s51.h
index eab61452..f4dcce66 100644
--- a/s51/s51.h
+++ b/s51/s51.h
@@ -27,6 +27,23 @@ enum command_result {
command_success, command_debug, command_syntax, command_interrupt, command_error,
};
+struct command_function {
+ char *name;
+ char *alias;
+ enum command_result (*func)(int argc, char **argv);
+ char *usage;
+ char *help;
+};
+
+struct command_function *
+command_string_to_function(struct command_function *functions, char *name);
+
+enum command_result
+command_function_help(struct command_function *functions, int argc, char **argv);
+
+void
+command_syntax_error(int argc, char **argv);
+
enum command_result
command_quit (int argc, char **argv);
@@ -34,6 +51,9 @@ enum command_result
command_help (int argc, char **argv);
enum command_result
+command_stop (int argc, char **argv);
+
+enum command_result
command_di (int argc, char **argv);
enum command_result
@@ -82,6 +102,9 @@ enum command_result
command_status (int argc, char **argv);
enum command_result
+command_info (int argc, char **argv);
+
+enum command_result
cc_wait(void);
void