distribution/packages/sysutils/ectool/patches/001-read.patch

60 lines
1.8 KiB
Diff
Raw Normal View History

diff --git a/util/ectool/ectool.c b/util/ectool/ectool.c
index cb6f280f4c..585ae5faf1 100644
--- a/util/ectool/ectool.c
+++ b/util/ectool/ectool.c
@@ -52,6 +52,7 @@ void print_usage(const char *name)
" -d | --dump: print RAM\n"
" -i | --idx: print IDX RAM & RAM\n"
" -q | --query: print query byte\n"
+ " -r <addr in hex> read from addr\n"
" -w <addr in hex> write to addr\n"
" -z <data in hex> write to data\n"
"\n");
@@ -65,6 +66,7 @@ int main(int argc, char *argv[])
int i, opt, option_index = 0;
long write_data = -1;
long write_addr = -1;
+ long read_addr = -1;
static struct option long_options[] = {
{"version", 0, 0, 'v'},
@@ -81,7 +83,7 @@ int main(int argc, char *argv[])
exit(1);
}
- while ((opt = getopt_long(argc, argv, "vh?Vidqpw:z:",
+ while ((opt = getopt_long(argc, argv, "vh?Vidqpr:w:z:",
long_options, &option_index)) != EOF) {
switch (opt) {
case 'v':
@@ -95,6 +97,9 @@ int main(int argc, char *argv[])
dump_idx = 1;
dump_ram = 1;
break;
+ case 'r':
+ read_addr = strtol(optarg , NULL, 16);
+ break;
case 'w':
write_addr = strtol(optarg , NULL, 16);
break;
@@ -133,6 +138,7 @@ int main(int argc, char *argv[])
printf("You need to be root.\n");
exit(1);
}
+
if (write_addr >= 0 && write_data >= 0) {
write_addr &= 0xff;
write_data &= 0xff;
@@ -140,6 +146,11 @@ int main(int argc, char *argv[])
ec_write(write_addr & 0xff, write_data & 0xff);
}
+ if (read_addr >= 0) {
+ printf("%02x", ec_read(read_addr));
+ exit(0);
+ }
+
/* preserve default - dump_ram if nothing selected */
if (!dump_ram && !dump_idx && !dump_query && (write_addr == -1))
dump_ram = 1;