summaryrefslogtreecommitdiffstats
path: root/src/import
diff options
context:
space:
mode:
authorMartin Peschke <mpeschke@de.ibm.com>2016-11-30 18:09:47 +0100
committerSachin Gupta <sgupta2m@in.ibm.com>2017-02-15 22:16:36 -0500
commitb1f67ee1e509106d19a561c965aff58292689732 (patch)
tree88133bf60526cf0aea7b454b606654959fb5e650 /src/import
parent35683f5220ceca116ae19f4af90bbc4d80f68df9 (diff)
downloadtalos-sbe-b1f67ee1e509106d19a561c965aff58292689732.tar.gz
talos-sbe-b1f67ee1e509106d19a561c965aff58292689732.zip
p9_xip_tool: cleanup - no intermediate dissect output buffer
We write ring dissect output to stdout anyway. So there is no point in maintaining all that convoluted code that first writes into an intermediate buffer and then writes that buffer to stdout. Change-Id: I64c58daef85dddbfc96a85df6a4cd062a84b270d Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/33193 Tested-by: PPE CI <ppe-ci+hostboot@us.ibm.com> Reviewed-by: Sumit Kumar <sumit_kumar@in.ibm.com> Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com> Reviewed-by: Martin Peschke <mpeschke@de.ibm.com> Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/33309 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.C158
1 files changed, 34 insertions, 124 deletions
diff --git a/src/import/chips/p9/xip/p9_xip_tool.C b/src/import/chips/p9/xip/p9_xip_tool.C
index d07db3e7..af3e3aba 100644
--- a/src/import/chips/p9/xip/p9_xip_tool.C
+++ b/src/import/chips/p9/xip/p9_xip_tool.C
@@ -1742,9 +1742,6 @@ int dissectRingSectionTor( void* i_ringSection,
{
int rc = 0;
uint32_t i;
- char* disList = NULL;
- uint32_t sizeDisLine = 0, sizeList = 0, sizeListMax = 0, sizeListIncr;
- char lineDis[LINE_SIZE_MAX];
uint32_t numDdLevels;
uint8_t iDdLevel, ddLevel;
uint8_t ppeType;
@@ -1757,29 +1754,8 @@ int dissectRingSectionTor( void* i_ringSection,
char ringName[32];
uint32_t ringSeqNo = 0; // Ring sequence number
- //
- // Allocate buffer to hold dissected ring info. (Start out with min 10kB buffer size.)
- //
- sizeListIncr = 10 * LINE_SIZE_MAX;
- sizeListMax = sizeListIncr;
- disList = (char*)malloc(sizeListMax);
-
- if (disList == NULL)
- {
- fprintf( stderr, "ERROR : malloc() failed.\n");
- fprintf( stderr, "\tMore info: %s\n", DIS_ERROR_STRING(g_errorStringsDis, DIS_MEMORY_ERROR));
- return P9_XIP_DISASSEMBLER_ERROR;
- }
-
- *disList = '\0'; // Make sure the buffer is NULL terminated (though probably not needed.)
- sizeList = 0;
-
- sizeDisLine = snprintf( lineDis, LINE_SIZE_MAX,
- "-----------------------------\n"
- "* Ring summary *\n");
-
- disList = strcat(disList, lineDis);
- sizeList = sizeList + sizeDisLine;
+ fprintf( stdout, "-----------------------------\n"
+ "* Ring summary *\n");
//
// Allocate large buffer to hold max length ring block.
@@ -1883,105 +1859,52 @@ int dissectRingSectionTor( void* i_ringSection,
// Summarize a few key characteristics of the ring block if "short".
if (i_listingModeId == LMID_SHORT)
{
- sizeDisLine = snprintf( lineDis, LINE_SIZE_MAX,
- "-----------------------------\n"
- "%i.\n"
- "ddLevel = 0x%02x\n"
- "ppeType = %s\n"
- "ringName = %s\n"
- "ringVariant = %s\n"
- "instanceId = 0x%02x\n",
- ringSeqNo, ddLevel, ppeTypeName[ppeType], ringName,
- ringVariantName[ringVariant], instanceId );
-
- if (sizeDisLine >= LINE_SIZE_MAX)
- {
- fprintf(stderr, "The max print line size, LINE_SIZE_MAX=%d, has been reached.(1)",
- LINE_SIZE_MAX);
- fprintf(stderr, "You should investigate why this happened before increasing "
- "the value of LINE_SIZE_MAX since something might be wrong "
- "with the RS4 ring content.");
- exit(1);
- }
-
- // Update list buffer and readjust list buffer size, if needed.
- disList = strcat(disList, lineDis);
- sizeList = sizeList + sizeDisLine;
-
+ fprintf( stdout,
+ "-----------------------------\n"
+ "%i.\n"
+ "ddLevel = 0x%02x\n"
+ "ppeType = %s\n"
+ "ringName = %s\n"
+ "ringVariant = %s\n"
+ "instanceId = 0x%02x\n",
+ ringSeqNo, ddLevel, ppeTypeName[ppeType], ringName,
+ ringVariantName[ringVariant], instanceId );
}
// Summarize all characteristics of the ring block if "normal" or "long" (default).
if ( i_listingModeId == LMID_NORMAL || i_listingModeId == LMID_LONG )
{
- sizeDisLine = snprintf( lineDis, LINE_SIZE_MAX,
- "-----------------------------\n"
- "%i.\n"
- "ddLevel = 0x%02x\n"
- "ppeType = %s\n"
- "ringId = %u\n"
- "ringName = %s\n"
- "ringVariant = %s\n"
- "instanceId = 0x%02x\n"
- "ringBlockSize = 0x%08x\n",
- ringSeqNo, ddLevel, ppeTypeName[ppeType], ringId, ringName,
- ringVariantName[ringVariant], instanceId,
- ringBlockSize);
-
- if (sizeDisLine >= LINE_SIZE_MAX)
- {
- fprintf(stderr, "The max print line size, LINE_SIZE_MAX=%d, has been reached.(2)",
- LINE_SIZE_MAX);
- fprintf(stderr, "You should investigate why this happened before increasing "
- "the value of LINE_SIZE_MAX since something might be wrong "
- "with the RS4 ring content.");
- exit(1);
- }
-
- // Update list buffer and readjust list buffer size, if needed.
- disList = strcat(disList, lineDis);
- sizeList = sizeList + sizeDisLine;
-
+ fprintf( stdout,
+ "-----------------------------\n"
+ "%i.\n"
+ "ddLevel = 0x%02x\n"
+ "ppeType = %s\n"
+ "ringId = %u\n"
+ "ringName = %s\n"
+ "ringVariant = %s\n"
+ "instanceId = 0x%02x\n"
+ "ringBlockSize = 0x%08x\n",
+ ringSeqNo, ddLevel, ppeTypeName[ppeType], ringId, ringName,
+ ringVariantName[ringVariant], instanceId,
+ ringBlockSize);
}
// Dump ring block if "long".
if (i_listingModeId == LMID_LONG)
{
- sizeDisLine = snprintf( lineDis, LINE_SIZE_MAX,
- "Binary ring block dump (LE format):\n");
- disList = strcat(disList, lineDis);
- sizeList = sizeList + sizeDisLine;
-
- if (sizeDisLine >= LINE_SIZE_MAX)
- {
- fprintf(stderr, "The max print line size, LINE_SIZE_MAX=%d, has been reached.(3)",
- LINE_SIZE_MAX);
- fprintf(stderr, "You should investigate why this happened before increasing "
- "the value of LINE_SIZE_MAX since something might be wrong "
- "with the RS4 ring content.");
- exit(1);
- }
+ fprintf(stdout, "Binary ring block dump (LE format):\n");
for (i = 0; i < ringBlockSize / 8; i++)
{
- sizeDisLine = snprintf( lineDis, LINE_SIZE_MAX,
- "%04x: %04x %04x %04x %04x\n",
- i * 8,
- (uint16_t)( htobe64(*((uint64_t*)ringBlockPtr + i)) >> 48),
- (uint16_t)( htobe64(*((uint64_t*)ringBlockPtr + i)) >> 32),
- (uint16_t)( htobe64(*((uint64_t*)ringBlockPtr + i)) >> 16),
- (uint16_t)( htobe64(*((uint64_t*)ringBlockPtr + i))) );
-
- disList = strcat(disList, lineDis);
- sizeList = sizeList + sizeDisLine;
-
+ fprintf( stdout,
+ "%04x: %04x %04x %04x %04x\n",
+ i * 8,
+ (uint16_t)( htobe64(*((uint64_t*)ringBlockPtr + i)) >> 48),
+ (uint16_t)( htobe64(*((uint64_t*)ringBlockPtr + i)) >> 32),
+ (uint16_t)( htobe64(*((uint64_t*)ringBlockPtr + i)) >> 16),
+ (uint16_t)( htobe64(*((uint64_t*)ringBlockPtr + i))) );
}
}
-
- if (sizeList > (sizeListMax - LINE_SIZE_MAX))
- {
- sizeListMax = sizeListMax + sizeListIncr;
- disList = (char*)realloc( (void*)(disList), sizeListMax);
- }
}
else if (rc == TOR_RING_NOT_FOUND ||
rc == TOR_INVALID_INSTANCE_ID ||
@@ -2009,22 +1932,9 @@ int dissectRingSectionTor( void* i_ringSection,
} // End of for(iDdLevel)
- sizeDisLine = snprintf( lineDis, LINE_SIZE_MAX,
- "-----------------------------\n");
-
- disList = strcat(disList, lineDis);
- sizeList = sizeList + sizeDisLine;
-
- // Adjust final buffer size, add 1 for NULL char and print it.
- if (disList)
- {
- disList = (char*)realloc( (void*)(disList), sizeList + 1);
- fprintf(stdout, "%s\n", disList);
- free(disList);
- }
+ fprintf(stdout, "-----------------------------\n");
return 0;
-
}
OpenPOWER on IntegriCloud