Index: main.c =================================================================== RCS file: /cvs/ecos/ecos/packages/redboot/current/src/main.c,v retrieving revision 1.24 diff -u -p -r1.24 main.c --- main.c 2001/09/12 04:21:16 1.24 +++ main.c 2001/11/02 20:11:59 @@ -87,9 +87,19 @@ RedBoot_cmd("go", ); RedBoot_cmd("dump", "Display (hex dump) a range of memory", - "-b [-l ]", + "-b [-l ] [-B|W|L]", do_dump ); +RedBoot_cmd("edit", + "Edit the contents of memory", + "-b -v [-s ]", + do_edit + ); +RedBoot_cmd("fill", + "Fill the contents of memory", + "-b -l -v ", + do_fill + ); RedBoot_cmd("cksum", "Compute a 32bit checksum [POSIX algorithm] for a range of memory", "-b -l ", @@ -399,16 +409,26 @@ do_help(int argc, char *argv[]) void do_dump(int argc, char *argv[]) { - struct option_info opts[2]; + struct option_info opts[5]; unsigned long base, len; + bool set_long = false; + bool set_word = false; + bool set_byte = false; bool base_set, len_set; static unsigned long _base, _len; + static unsigned long _size = 1; init_opts(&opts[0], 'b', true, OPTION_ARG_TYPE_NUM, (void **)&base, (bool *)&base_set, "base address"); init_opts(&opts[1], 'l', true, OPTION_ARG_TYPE_NUM, (void **)&len, (bool *)&len_set, "length"); - if (!scan_opts(argc, argv, 1, opts, 2, 0, 0, "")) { + init_opts(&opts[2], 'L', false, OPTION_ARG_TYPE_FLG, + (void **)&set_long, (bool *)0, "dump long"); + init_opts(&opts[3], 'W', false, OPTION_ARG_TYPE_FLG, + (void **)&set_word, (bool *)0, "dump word"); + init_opts(&opts[4], 'B', false, OPTION_ARG_TYPE_FLG, + (void **)&set_byte, (bool *)0, "dump byte"); + if (!scan_opts(argc, argv, 1, opts, 5, 0, 0, "")) { return; } if (!base_set) { @@ -420,14 +440,111 @@ do_dump(int argc, char *argv[]) if (!len_set) { len = _len; len_set = true; - } + } } + + if ( set_long ) { + _size = 4; + } else if ( set_word ) { + _size = 2; + } else if ( set_byte ) { + _size = 1; + } + if (!len_set) { len = 32; + } + + switch( _size ) { + case 1: + diag_dump_buf((void *)base, len); + break; + case 2: + diag_dump_buf_word((void *)base, len); + break; + case 4: + diag_dump_buf_long((void *)base, len); + break; } - diag_dump_buf((void *)base, len); _base = base + len; _len = len; +} + +void +do_edit(int argc, char *argv[]) +{ + struct option_info opts[3]; + unsigned long base, value, size; + bool base_set, value_set, size_set; + static unsigned long _base; + + init_opts(&opts[0], 'b', true, OPTION_ARG_TYPE_NUM, + (void **)&base, (bool *)&base_set, "base address"); + init_opts(&opts[1], 'v', true, OPTION_ARG_TYPE_NUM, + (void **)&value, (bool *)&value_set, "value"); + init_opts(&opts[2], 's', true, OPTION_ARG_TYPE_NUM, + (void **)&size, (bool *)&size_set, "size"); + if (!scan_opts(argc, argv, 1, opts, 3, 0, 0, "")) { + return; + } + + if (!base_set) { + if (_base == 0) { + diag_printf("Edit what [location]?\n"); + return; + } + base = _base; + } + + if (!value_set) { + diag_printf("Edit what [value]?\n"); + return; + } + if (!size_set) { + size = 4; + } + + diag_edit((void*)base, value, size); + _base += size; +} + +void +do_fill(int argc, char *argv[]) +{ + struct option_info opts[3]; + unsigned long base, len, value; + bool base_set, len_set, value_set; + unsigned long i; + + init_opts(&opts[0], 'b', true, OPTION_ARG_TYPE_NUM, + (void **)&base, (bool *)&base_set, "base address"); + init_opts(&opts[1], 'l', true, OPTION_ARG_TYPE_NUM, + (void **)&len, (bool *)&len_set, "length"); + init_opts(&opts[2], 'v', true, OPTION_ARG_TYPE_NUM, + (void **)&value, (bool *)&value_set, "value"); + if (!scan_opts(argc, argv, 1, opts, 3, 0, 0, "")) { + return; + } + + if (!base_set) { + diag_printf("Fill what [location]?\n"); + return; + } + + if (!len_set) { + diag_printf("Fill what [length]?\n"); + return; + } + + if (!value_set) { + diag_printf("Fill what [value]?\n"); + return; + } + + for ( i = 0; i < len; i++ ) { + diag_edit((void*)base, value, 4); + base += sizeof(long); + } } void