Message ID | 20181115071929.206974-16-amitay@ozlabs.org |
---|---|
State | Superseded |
Headers | show |
Series | Device tree path based targeting | expand |
Context | Check | Description |
---|---|---|
snowpatch_ozlabs/apply_patch | success | master/apply_patch Successfully applied |
snowpatch_ozlabs/build-multiarch | success | Test build-multiarch on branch master |
Looks good, I like the output format. Thanks. Reviewed-by: Alistair Popple <alistair@popple.id.au> On Thursday, 15 November 2018 6:19:28 PM AEDT Amitay Isaacs wrote: > Signed-off-by: Amitay Isaacs <amitay@ozlabs.org> > --- > src/scom.c | 95 +++++++++++++++++++++++++++++++++++--------- > tests/test_hw_bmc.sh | 7 ++-- > 2 files changed, 81 insertions(+), 21 deletions(-) > > diff --git a/src/scom.c b/src/scom.c > index 2372e91..1f8e6c7 100644 > --- a/src/scom.c > +++ b/src/scom.c > @@ -18,41 +18,100 @@ > #include <stdlib.h> > #include <string.h> > #include <inttypes.h> > +#include <assert.h> > > #include <libpdbg.h> > > #include "main.h" > #include "optcmd.h" > +#include "path.h" > > -static int _getscom(struct pdbg_target *target, uint32_t index, uint64_t > *addr, uint64_t *unused) +/* Check if a target has scom region */ > +static bool scommable(struct pdbg_target *target) > { > - uint64_t value; > - > - if (pib_read(target, *addr, &value)) > - return 0; > + char *classname; > > - printf("p%d:0x%" PRIx64 " = 0x%016" PRIx64 "\n", index, *addr, value); > + classname = pdbg_target_class_name(target); > + if (!strcmp(classname, "pib") || > + !strcmp(classname, "core") || > + !strcmp(classname, "thread")) > + return true; > > - return 1; > + return false; > } > > - int getscom(uint64_t addr) > +int getscom(uint64_t addr) > { > - return for_each_target("pib", _getscom, &addr, NULL); > + struct pdbg_target *target; > + char *path; > + uint64_t value; > + int count = 0; > + > + for_each_path_target(target) { > + struct pdbg_target *addr_base; > + uint64_t xlate_addr; > + > + if (pdbg_target_status(target) != PDBG_TARGET_ENABLED) > + continue; > + > + if (!scommable(target)) { > + continue; > + } > + > + path = pdbg_target_path(target); > + assert(path); > + > + xlate_addr = addr; > + addr_base = pdbg_address_absolute(target, &xlate_addr); > + > + if (pib_read(target, addr, &value)) { > + printf("p%d: 0x%016" PRIx64 " failed (%s)\n", > pdbg_target_index(addr_base), xlate_addr, path); + free(path); > + continue; > + } > + > + printf("p%d: 0x%016" PRIx64 " = 0x%016" PRIx64 " (%s)\n", > pdbg_target_index(addr_base), xlate_addr, value, path); + free(path); > + count++; > + } > + > + return count; > } > OPTCMD_DEFINE_CMD_WITH_ARGS(getscom, getscom, (ADDRESS)); > > -static int _putscom(struct pdbg_target *target, uint32_t index, uint64_t > *addr, uint64_t *data) +int putscom(uint64_t addr, uint64_t data, uint64_t > mask) > { > - if (pib_write(target, *addr, *data)) > - return 0; > + struct pdbg_target *target; > + char *path; > + int count = 0; > > - return 1; > -} > + for_each_path_target(target) { > + struct pdbg_target *addr_base; > + uint64_t xlate_addr; > > - int putscom(uint64_t addr, uint64_t data, uint64_t mask) > -{ > - /* TODO: Restore the <mask> functionality */ > - return for_each_target("pib", _putscom, &addr, &data); > + if (pdbg_target_status(target) != PDBG_TARGET_ENABLED) > + continue; > + > + if (!scommable(target)) { > + continue; > + } > + > + path = pdbg_target_path(target); > + assert(path); > + > + xlate_addr = addr; > + addr_base = pdbg_address_absolute(target, &xlate_addr); > + > + /* TODO: Restore the <mask> functionality */ > + if (pib_write(target, addr, data)) { > + printf("p%d: 0x%016" PRIx64 " failed (%s)\n", > pdbg_target_index(addr_base), xlate_addr, path); + free(path); > + continue; > + } > + > + count++; > + } > + > + return count; > } > OPTCMD_DEFINE_CMD_WITH_ARGS(putscom, putscom, (ADDRESS, DATA, > DEFAULT_DATA("0xffffffffffffffff"))); diff --git a/tests/test_hw_bmc.sh > b/tests/test_hw_bmc.sh > index 850afd9..ab6af35 100755 > --- a/tests/test_hw_bmc.sh > +++ b/tests/test_hw_bmc.sh > @@ -79,8 +79,9 @@ test_wrapper run_over_ssh > > result_filter () > { > - sed -E -e 's#0x[[:xdigit:]]{16}#HEX16#' \ > - -E -e 's#0x[[:xdigit:]]{8}#HEX8#' > + sed -E -e 's#0x[[:xdigit:]]{16}#HEX16#g' \ > + -E -e 's#0x[[:xdigit:]]{8}#HEX8#g' \ > + -E -e 's#/.*fsi@0/pib@1000#PIB0PATH#' > } > > test_result 0 <<EOF > @@ -91,7 +92,7 @@ do_skip > test_run $PDBG -p0 getcfam 0xc09 > > test_result 0 <<EOF > -p0:0xf000f = HEX16 > +p0: HEX16 = HEX16 (PIB0PATH) > EOF > > do_skip
diff --git a/src/scom.c b/src/scom.c index 2372e91..1f8e6c7 100644 --- a/src/scom.c +++ b/src/scom.c @@ -18,41 +18,100 @@ #include <stdlib.h> #include <string.h> #include <inttypes.h> +#include <assert.h> #include <libpdbg.h> #include "main.h" #include "optcmd.h" +#include "path.h" -static int _getscom(struct pdbg_target *target, uint32_t index, uint64_t *addr, uint64_t *unused) +/* Check if a target has scom region */ +static bool scommable(struct pdbg_target *target) { - uint64_t value; - - if (pib_read(target, *addr, &value)) - return 0; + char *classname; - printf("p%d:0x%" PRIx64 " = 0x%016" PRIx64 "\n", index, *addr, value); + classname = pdbg_target_class_name(target); + if (!strcmp(classname, "pib") || + !strcmp(classname, "core") || + !strcmp(classname, "thread")) + return true; - return 1; + return false; } - int getscom(uint64_t addr) +int getscom(uint64_t addr) { - return for_each_target("pib", _getscom, &addr, NULL); + struct pdbg_target *target; + char *path; + uint64_t value; + int count = 0; + + for_each_path_target(target) { + struct pdbg_target *addr_base; + uint64_t xlate_addr; + + if (pdbg_target_status(target) != PDBG_TARGET_ENABLED) + continue; + + if (!scommable(target)) { + continue; + } + + path = pdbg_target_path(target); + assert(path); + + xlate_addr = addr; + addr_base = pdbg_address_absolute(target, &xlate_addr); + + if (pib_read(target, addr, &value)) { + printf("p%d: 0x%016" PRIx64 " failed (%s)\n", pdbg_target_index(addr_base), xlate_addr, path); + free(path); + continue; + } + + printf("p%d: 0x%016" PRIx64 " = 0x%016" PRIx64 " (%s)\n", pdbg_target_index(addr_base), xlate_addr, value, path); + free(path); + count++; + } + + return count; } OPTCMD_DEFINE_CMD_WITH_ARGS(getscom, getscom, (ADDRESS)); -static int _putscom(struct pdbg_target *target, uint32_t index, uint64_t *addr, uint64_t *data) +int putscom(uint64_t addr, uint64_t data, uint64_t mask) { - if (pib_write(target, *addr, *data)) - return 0; + struct pdbg_target *target; + char *path; + int count = 0; - return 1; -} + for_each_path_target(target) { + struct pdbg_target *addr_base; + uint64_t xlate_addr; - int putscom(uint64_t addr, uint64_t data, uint64_t mask) -{ - /* TODO: Restore the <mask> functionality */ - return for_each_target("pib", _putscom, &addr, &data); + if (pdbg_target_status(target) != PDBG_TARGET_ENABLED) + continue; + + if (!scommable(target)) { + continue; + } + + path = pdbg_target_path(target); + assert(path); + + xlate_addr = addr; + addr_base = pdbg_address_absolute(target, &xlate_addr); + + /* TODO: Restore the <mask> functionality */ + if (pib_write(target, addr, data)) { + printf("p%d: 0x%016" PRIx64 " failed (%s)\n", pdbg_target_index(addr_base), xlate_addr, path); + free(path); + continue; + } + + count++; + } + + return count; } OPTCMD_DEFINE_CMD_WITH_ARGS(putscom, putscom, (ADDRESS, DATA, DEFAULT_DATA("0xffffffffffffffff"))); diff --git a/tests/test_hw_bmc.sh b/tests/test_hw_bmc.sh index 850afd9..ab6af35 100755 --- a/tests/test_hw_bmc.sh +++ b/tests/test_hw_bmc.sh @@ -79,8 +79,9 @@ test_wrapper run_over_ssh result_filter () { - sed -E -e 's#0x[[:xdigit:]]{16}#HEX16#' \ - -E -e 's#0x[[:xdigit:]]{8}#HEX8#' + sed -E -e 's#0x[[:xdigit:]]{16}#HEX16#g' \ + -E -e 's#0x[[:xdigit:]]{8}#HEX8#g' \ + -E -e 's#/.*fsi@0/pib@1000#PIB0PATH#' } test_result 0 <<EOF @@ -91,7 +92,7 @@ do_skip test_run $PDBG -p0 getcfam 0xc09 test_result 0 <<EOF -p0:0xf000f = HEX16 +p0: HEX16 = HEX16 (PIB0PATH) EOF do_skip
Signed-off-by: Amitay Isaacs <amitay@ozlabs.org> --- src/scom.c | 95 +++++++++++++++++++++++++++++++++++--------- tests/test_hw_bmc.sh | 7 ++-- 2 files changed, 81 insertions(+), 21 deletions(-)