summaryrefslogtreecommitdiffstats
path: root/cli.c
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@dside.dyndns.org>2011-07-12 20:00:34 +0200
committerSuren A. Chilingaryan <csa@dside.dyndns.org>2011-07-12 20:00:34 +0200
commit146c9e6b93a37de51b1116d1bab59b909aa9eb8d (patch)
tree301e7d9ccbd71afd1534576a6d395434aec44aa2 /cli.c
parent9a7ec0c7c063c86e0c2775bbf7fb485c691d9bb9 (diff)
downloadpcitool-146c9e6b93a37de51b1116d1bab59b909aa9eb8d.tar.gz
pcitool-146c9e6b93a37de51b1116d1bab59b909aa9eb8d.tar.bz2
pcitool-146c9e6b93a37de51b1116d1bab59b909aa9eb8d.tar.xz
pcitool-146c9e6b93a37de51b1116d1bab59b909aa9eb8d.zip
Report writted register in hex if it was specified in hex
Diffstat (limited to 'cli.c')
-rw-r--r--cli.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/cli.c b/cli.c
index 8834865..e238bbc 100644
--- a/cli.c
+++ b/cli.c
@@ -802,14 +802,32 @@ int WriteRegister(pcilib_t *handle, pcilib_model_description_t *model_info, cons
unsigned long val;
pcilib_register_value_t value;
- if (!isnumber(*data)) {
+ const char *format;
+
+/*
+ pcilib_register_bank_t bank_id;
+ pcilib_register_bank_addr_t bank_addr;
+
+ pcilib_register_t regid = pcilib_find_register(handle, bank, reg);
+ if (regid == PCILIB_REGISTER_INVALID) Error("Can't find register (%s) from bank (%s)", reg, bank?bank:"autodetected");
+ bank_id = pcilib_find_bank_by_addr(handle, model_info->registers[regid].bank);
+ if (bank_id == PCILIB_REGISTER_BANK_INVALID) Error("Can't find bank of the register (%s)", reg);
+ format = model_info->banks[bank_id].format;
+ if (!format) format = "%lu";
+*/
+
+ if (isnumber(*data)) {
if (sscanf(*data, "%li", &val) != 1) {
Error("Can't parse data value (%s) is not valid decimal number", *data);
}
- } else if (!isxnumber(*data)) {
+
+ format = "%li";
+ } else if (isxnumber(*data)) {
if (sscanf(*data, "%lx", &val) != 1) {
Error("Can't parse data value (%s) is not valid decimal number", *data);
}
+
+ format = "0x%lx";
} else {
Error("Can't parse data value (%s) is not valid decimal number", *data);
}
@@ -825,7 +843,9 @@ int WriteRegister(pcilib_t *handle, pcilib_model_description_t *model_info, cons
if (val != value) {
Error("Failed to write register %s: %lu is written and %lu is read back", reg, val, value);
} else {
- printf("%s = %i\n", reg, value);
+ printf("%s = ", reg);
+ printf(format, value);
+ printf("\n");
}
return 0;