diff options
author | Martin Peschke <mpeschke@de.ibm.com> | 2016-09-15 12:27:05 +0200 |
---|---|---|
committer | Sachin Gupta <sgupta2m@in.ibm.com> | 2016-09-19 13:07:24 -0400 |
commit | 733bed36b738677619e8586f9c3fe4f9212ea063 (patch) | |
tree | 1981ca277d1ef3eea6390597956f36221e497220 /src/import | |
parent | 2b40e2e100c7a0725762c40865d36ac7639e12cc (diff) | |
download | talos-sbe-733bed36b738677619e8586f9c3fe4f9212ea063.tar.gz talos-sbe-733bed36b738677619e8586f9c3fe4f9212ea063.zip |
p9_xip_tool: remove duplicated code in tocListing()
It is preferable to share code in attrListing().
This change prepares an enhancement inside the formerly duplicate
and now shared code.
Change-Id: I2aee399255fb275d3da946a69bf368b93e2e498c
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/29742
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: PPE CI <ppe-ci+hostboot@us.ibm.com>
Reviewed-by: Richard J. Knight <rjknight@us.ibm.com>
Reviewed-by: Shakeeb A. Pasha B K <shakeebbk@in.ibm.com>
Reviewed-by: Martin Peschke <mpeschke@de.ibm.com>
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/29745
Reviewed-by: Hostboot Team <hostboot@us.ibm.com>
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Reviewed-by: Sachin Gupta <sgupta2m@in.ibm.com>
Diffstat (limited to 'src/import')
-rw-r--r-- | src/import/chips/p9/xip/p9_xip_tool.C | 203 |
1 files changed, 41 insertions, 162 deletions
diff --git a/src/import/chips/p9/xip/p9_xip_tool.C b/src/import/chips/p9/xip/p9_xip_tool.C index 0309db3c..b85dd50f 100644 --- a/src/import/chips/p9/xip/p9_xip_tool.C +++ b/src/import/chips/p9/xip/p9_xip_tool.C @@ -385,169 +385,10 @@ normalize(void* io_image, const int i_argc, const char** i_argv, uint32_t i_mask } -// Print a line of a report, listing the index, symbol, type and current -// value. - -int -tocListing(void* io_image, - const P9XipItem* i_item, - void* arg) -{ - int rc; - ReportControl* control; - uint64_t data; - char* s; - - control = (ReportControl*)arg; - - do - { - rc = 0; - - if (control->regex) - { - if (regexec(&(control->preg), i_item->iv_id, 0, 0, 0)) - { - break; - } - } - - printf("0x%04x | %-42s | %s | ", - control->index, i_item->iv_id, - P9_XIP_TYPE_STRING(g_typeAbbrevs, i_item->iv_type)); - - switch (i_item->iv_type) - { - case P9_XIP_UINT8: - rc = p9_xip_get_scalar(io_image, i_item->iv_id, &data); - - if (rc) - { - break; - } - - printf("0x%02x", (uint8_t)data); - break; - - case P9_XIP_UINT16: - rc = p9_xip_get_scalar(io_image, i_item->iv_id, &data); - - if (rc) - { - break; - } - - printf("0x%04x", (uint16_t)data); - break; - - case P9_XIP_UINT32: - rc = p9_xip_get_scalar(io_image, i_item->iv_id, &data); - - if (rc) - { - break; - } - - printf("0x%08x", (uint32_t)data); - break; - - case P9_XIP_UINT64: - rc = p9_xip_get_scalar(io_image, i_item->iv_id, &data); - - if (rc) - { - break; - } - - printf("0x%016lx", data); - break; - - case P9_XIP_INT8: - rc = p9_xip_get_scalar(io_image, i_item->iv_id, &data); - - if (rc) - { - break; - } - - printf("0x%02x", (uint8_t)data); - break; - - case P9_XIP_INT16: - rc = p9_xip_get_scalar(io_image, i_item->iv_id, &data); - - if (rc) - { - break; - } - - printf("0x%04x", (uint16_t)data); - break; - - case P9_XIP_INT32: - rc = p9_xip_get_scalar(io_image, i_item->iv_id, &data); - - if (rc) - { - break; - } - - printf("0x%08x", (uint32_t)data); - break; - - case P9_XIP_INT64: - rc = p9_xip_get_scalar(io_image, i_item->iv_id, &data); - - if (rc) - { - break; - } - - printf("0x%016lx", data); - break; - - case P9_XIP_STRING: - rc = p9_xip_get_string(io_image, i_item->iv_id, &s); - - if (rc) - { - break; - } - - printf("%s", s); - break; - - case P9_XIP_ADDRESS: - rc = p9_xip_get_scalar(io_image, i_item->iv_id, &data); - - if (rc) - { - break; - } - - printf("0x%04x:0x%08x", - (uint16_t)((data >> 32) & 0xffff), - (uint32_t)(data & 0xffffffff)); - break; - - default: - printf("unknown type\n"); - rc = P9_XIP_BUG; - break; - } - - printf("\n"); - } - while (0); - - control->index += 1; - return rc; -} - // Print a line of attribute report, listing the symbol, type and current // value. int -attrListing(const P9XipItem* i_item) +attrListing(const P9XipItem* i_item, const char* prefix) { int rc = 0; uint64_t data = 0; @@ -558,7 +399,7 @@ attrListing(const P9XipItem* i_item) return rc; } - printf("%-42s | %s | ", i_item->iv_id, + printf("%s%-42s | %s | ", prefix, i_item->iv_id, P9_XIP_TYPE_STRING(g_typeAbbrevs, i_item->iv_type)); rc = p9_xip_get_item(i_item, &data); @@ -623,6 +464,44 @@ attrListing(const P9XipItem* i_item) return rc; } + +// Print a line of a report, listing the index, symbol, type and current +// value. + +int +tocListing(void* i_image, + const P9XipItem* i_item, + void* arg) +{ + P9XipItem item; + int rc = 0; + ReportControl* control = (ReportControl*)arg; + char prefix[10]; + + do + { + if (control->regex) + { + if (regexec(&(control->preg), i_item->iv_id, 0, 0, 0)) + { + break; + } + } + + rc = p9_xip_find(i_image, i_item->iv_id, &item); + + if (!rc) + { + snprintf(prefix, sizeof(prefix), "0x%04x | ", control->index); + attrListing(&item, prefix); + } + } + while (0); + + control->index += 1; + return rc; +} + // Dump the image header, including the section table int @@ -772,7 +651,7 @@ reportAttr(void* io_image, size_t i_imageSize, void* io_dump) if (!rc) { //helper function to print the attributes - attrListing(&item); + attrListing(&item, ""); } } |