ectool: add --dump / -d for RAM dump
This moves the ram dump behind an argument, but it's still called by default when no other arguments given. To hold backward compatibility -i also prints out RAM. Change-Id: I82648e8cf1eac455e9937bd3669a0e91a3ee87cf Signed-off-by: Alexander Couzens <lynxis@fe80.eu> Reviewed-on: http://review.coreboot.org/8381 Tested-by: build bot (Jenkins) Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Reviewed-by: Peter Stuge <peter@stuge.se>
This commit is contained in:
parent
7ca6522412
commit
46ca3a5534
|
@ -46,19 +46,20 @@ void print_version(void)
|
||||||
|
|
||||||
void print_usage(const char *name)
|
void print_usage(const char *name)
|
||||||
{
|
{
|
||||||
printf("usage: %s [-vh?Vi] [-w 0x<addr> -z 0x<data>]\n", name);
|
printf("usage: %s [-vh?Vid] [-w 0x<addr> -z 0x<data>]\n", name);
|
||||||
printf("\n"
|
printf("\n"
|
||||||
" -v | --version: print the version\n"
|
" -v | --version: print the version\n"
|
||||||
" -h | --help: print this help\n\n"
|
" -h | --help: print this help\n\n"
|
||||||
" -V | --verbose: print debug information\n"
|
" -V | --verbose: print debug information\n"
|
||||||
" -i | --idx: print IDX RAM\n"
|
" -d | --dump: print RAM\n"
|
||||||
|
" -i | --idx: print IDX RAM & RAM\n"
|
||||||
" -w <addr in hex> write to addr\n"
|
" -w <addr in hex> write to addr\n"
|
||||||
" -z <data in hex> write to data\n"
|
" -z <data in hex> write to data\n"
|
||||||
"\n");
|
"\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int verbose = 0, dump_idx = 0;
|
int verbose = 0, dump_idx = 0, dump_ram = 0;
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
@ -74,7 +75,7 @@ int main(int argc, char *argv[])
|
||||||
{0, 0, 0, 0}
|
{0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
while ((opt = getopt_long(argc, argv, "vh?Viw:z:",
|
while ((opt = getopt_long(argc, argv, "vh?Vidw:z:",
|
||||||
long_options, &option_index)) != EOF) {
|
long_options, &option_index)) != EOF) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'v':
|
case 'v':
|
||||||
|
@ -86,6 +87,7 @@ int main(int argc, char *argv[])
|
||||||
break;
|
break;
|
||||||
case 'i':
|
case 'i':
|
||||||
dump_idx = 1;
|
dump_idx = 1;
|
||||||
|
dump_ram = 1;
|
||||||
break;
|
break;
|
||||||
case 'w':
|
case 'w':
|
||||||
write_addr = strtol(optarg , NULL, 16);
|
write_addr = strtol(optarg , NULL, 16);
|
||||||
|
@ -93,6 +95,9 @@ int main(int argc, char *argv[])
|
||||||
case 'z':
|
case 'z':
|
||||||
write_data = strtol(optarg , NULL, 16);
|
write_data = strtol(optarg , NULL, 16);
|
||||||
break;
|
break;
|
||||||
|
case 'd':
|
||||||
|
dump_ram = 1;
|
||||||
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
case '?':
|
case '?':
|
||||||
default:
|
default:
|
||||||
|
@ -113,6 +118,12 @@ int main(int argc, char *argv[])
|
||||||
ec_write(write_addr & 0xff, write_data & 0xff);
|
ec_write(write_addr & 0xff, write_data & 0xff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* preserve default - dump_ram if nothing selected */
|
||||||
|
if (!dump_ram && !dump_idx) {
|
||||||
|
dump_ram = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dump_ram) {
|
||||||
printf("EC RAM:\n");
|
printf("EC RAM:\n");
|
||||||
for (i = 0; i < 0x100; i++) {
|
for (i = 0; i < 0x100; i++) {
|
||||||
if ((i % 0x10) == 0)
|
if ((i % 0x10) == 0)
|
||||||
|
@ -120,6 +131,7 @@ int main(int argc, char *argv[])
|
||||||
printf("%02x ", ec_read(i));
|
printf("%02x ", ec_read(i));
|
||||||
}
|
}
|
||||||
printf("\n\n");
|
printf("\n\n");
|
||||||
|
}
|
||||||
|
|
||||||
if (dump_idx) {
|
if (dump_idx) {
|
||||||
printf("EC IDX RAM:\n");
|
printf("EC IDX RAM:\n");
|
||||||
|
|
Loading…
Reference in New Issue