From 7df3522ef1bf325bb4feed07d31a60d73ed4f923 Mon Sep 17 00:00:00 2001 From: Martin Peschke Date: Wed, 8 Feb 2017 21:44:20 +0100 Subject: p9_xip_tool: tabular ring output for dissect Prints a table as dissect output with one line per ring, including number of bits in ring. The compressed ring is decompressed, and hence verified as to correct decompression. Change-Id: I016c02949efa7a13bda0ba6529e24a34fe99ebe5 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/32796 Tested-by: Hostboot CI Tested-by: PPE CI Tested-by: Jenkins Server Reviewed-by: Martin Peschke Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/33310 Reviewed-by: Hostboot Team Tested-by: FSP CI Jenkins Reviewed-by: Sachin Gupta --- src/import/chips/p9/xip/p9_xip_tool.C | 94 ++++++++++++++++++++++++++++------- 1 file changed, 75 insertions(+), 19 deletions(-) (limited to 'src/import/chips/p9/xip/p9_xip_tool.C') diff --git a/src/import/chips/p9/xip/p9_xip_tool.C b/src/import/chips/p9/xip/p9_xip_tool.C index af3e3aba..21c06b90 100644 --- a/src/import/chips/p9/xip/p9_xip_tool.C +++ b/src/import/chips/p9/xip/p9_xip_tool.C @@ -58,9 +58,10 @@ // enum LISTING_MODE_ID { - LMID_SHORT = 0, - LMID_NORMAL = 1, // default - LMID_LONG = 2 + LMID_TABLE, + LMID_SHORT, + LMID_NORMAL, // default + LMID_LONG }; // Usage: p9_xip_tool [- ...] normalize @@ -73,7 +74,7 @@ enum LISTING_MODE_ID // p9_xip_tool [- ...] append
// p9_xip_tool [- ...] extract
// p9_xip_tool [- ...] delete
[ ... ] -// p9_xip_tool [- ...] dissect [short,normal(default),long] +// p9_xip_tool [- ...] dissect [table,short,normal(default),long] // p9_xip_tool [- ...] disasm // // This simple application uses the P9-XIP image APIs to normalize, search @@ -136,8 +137,9 @@ enum LISTING_MODE_ID // // The 'dissect' command dissects the ring section named by the section argument // and summarizes the content of the ring section. The second argument to -// 'dissect', i.e. [short,normal(default),long], specifies how much information +// 'dissect', i.e. [table,short,normal(default),long], specifies how much information // is included in the listing: +// table: Tabular overview. // short: The bare necessities. // normal: Everything but a raw binary dump of the actual ring block. // long: Everything inclusing a raw binary dump of the actual ring block. @@ -165,7 +167,7 @@ const char* g_usage = " p9_xip_tool [-i ...] extract
\n" " p9_xip_tool [-i ...] delete
[ ... ]\n" " p9_xip_tool [-i ...] dis
\n" - " p9_xip_tool [-i ...] dissect [short,normal(default),long]\n" + " p9_xip_tool [-i ...] dissect [table,short,normal(default),long]\n" " p9_xip_tool [-i ...] disasm \n" " p9_xip_tool [-i ...] check-sbe-ring-section
\n" "\n" @@ -229,12 +231,13 @@ const char* g_usage = "\n" "The 'dissect' command dissects the ring section named by the section argument\n" "and summarizes the content of the ring section. The second argument to\n" - "'dissect', i.e. [short,normal(default),long], specifies how much information\n" + "'dissect', i.e. [table,short,normal(default),long], specifies how much information\n" "is included in the listing:\n" + " table: Tabular overview.\n" " short: The bare necessities.\n" " normal: Everything but a raw binary dump of the actual ring block.\n" " long: Everything inclusing a raw binary dump of the actual ring block.\n" - "Note that iff the second argument is omitted, a 'normal' listing of the ring\n" + "Note that if the second argument is omitted, a 'normal' listing of the ring\n" "section will occur.\n" "\n" "The 'disasm' command disassembles the text section named by the section\n" @@ -1729,7 +1732,7 @@ TEST(void* io_image, const int i_argc, const char** i_argv) /// /// \param[in] i_imageMagicNo The image's MAGIC number. /// -/// \param[in] i_listingModeId The listing mode: {short, normal(default), long}. +/// \param[in] i_listingModeId The listing mode: {table, short, normal(default), long}. /// /// Assumptions: /// - Dissection only works with .rings section. It does not work with .overrides @@ -1753,9 +1756,19 @@ int dissectRingSectionTor( void* i_ringSection, uint32_t ringBlockSize; char ringName[32]; uint32_t ringSeqNo = 0; // Ring sequence number - - fprintf( stdout, "-----------------------------\n" - "* Ring summary *\n"); + CompressedScanData* rs4; + uint8_t* data; + uint8_t* care; + uint32_t bits; + int rs4rc; + uint16_t ringSize; + double comprRate; + + if (i_listingModeId != LMID_TABLE) + { + fprintf( stdout, "-----------------------------\n" + "* Ring summary *\n"); + } // // Allocate large buffer to hold max length ring block. @@ -1778,6 +1791,11 @@ int dissectRingSectionTor( void* i_ringSection, fprintf( stderr, "Image contains only one DD level set of rings.\n"); } + if (i_listingModeId == LMID_TABLE) + { + fprintf(stdout, "\n # DD PPE Var Inst Bits Compr Name\n"); + } + //---------------- // DD level loop. for (iDdLevel = 0; iDdLevel < numDdLevels; iDdLevel++) @@ -1842,20 +1860,49 @@ int dissectRingSectionTor( void* i_ringSection, // if (rc == TOR_RING_FOUND) { - uint32_t l_ringSize = htobe16(((CompressedScanData*)ringBlockPtr)->iv_size); + rs4 = (CompressedScanData*)ringBlockPtr; + ringSize = be16toh(rs4->iv_size); // Check ring block size. - if ( l_ringSize != ringBlockSize || l_ringSize == 0 ) + if ( ringSize != ringBlockSize || ringSize == 0 ) { fprintf(stderr, "tor_access_ring() was successful and found a ring but " - "RS4 header's iv_size(=0x%08x) is either zero or doesn't match " - "size of ring buffer (ringBlockSize=0x%08x).\n", - l_ringSize, ringBlockSize); + "RS4 header's iv_size(=0x%04x) is either zero or doesn't match " + "size of ring buffer (ringBlockSize=0x%04x).\n", + ringSize, ringBlockSize); exit(1); } ringSeqNo++; + // decompress ring to obtain ring length and to verify compressed string + rs4rc = rs4_decompress(&data, &care, &bits, rs4); + comprRate = (double)ringSize / (double)bits * 100.0; + + // tabular ring list if "table". + if (i_listingModeId == LMID_TABLE) + { + fprintf(stdout, + "%4i " + "0x%02x " + "%4s " + "%4s " + "0x%02x " + "%7d " + "%6.2f " + "%s ", + ringSeqNo, ddLevel, ppeTypeName[ppeType], + ringVariantName[ringVariant], instanceId, + bits, comprRate, ringName); + + if (rs4rc != SCAN_COMPRESSION_OK) + { + fprintf(stdout, "Decompression error %i)", rs4rc); + } + + fprintf(stdout, "\n"); + } + // Summarize a few key characteristics of the ring block if "short". if (i_listingModeId == LMID_SHORT) { @@ -1905,6 +1952,9 @@ int dissectRingSectionTor( void* i_ringSection, (uint16_t)( htobe64(*((uint64_t*)ringBlockPtr + i))) ); } } + + free(data); + free(care); } else if (rc == TOR_RING_NOT_FOUND || rc == TOR_INVALID_INSTANCE_ID || @@ -1931,8 +1981,10 @@ int dissectRingSectionTor( void* i_ringSection, } // End of for(iDdLevel) - - fprintf(stdout, "-----------------------------\n"); + if (i_listingModeId != LMID_TABLE) + { + fprintf(stdout, "-----------------------------\n"); + } return 0; } @@ -2046,6 +2098,10 @@ int dissectRingSection(void* i_image, { listingModeId = LMID_NORMAL; } + else if (strcmp(listingModeName, "table") == 0) + { + listingModeId = LMID_TABLE; + } else if (strcmp(listingModeName, "short") == 0) { listingModeId = LMID_SHORT; -- cgit v1.2.1