Skip to content

Commit

Permalink
Add sbe commit id in PIBMEM
Browse files Browse the repository at this point in the history
Add commit id in global structure for debug
./sbe-debug.py -l sbecommit

Change-Id: Ifd5b0f074efeda7d8c3dabeb82dd05cbce868579
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/49417
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Reviewed-by: AMIT J. TENDOLKAR <amit.tendolkar@in.ibm.com>
Reviewed-by: Sachin Gupta <sgupta2m@in.ibm.com>
  • Loading branch information
Shakeebbk authored and sgupta2m committed Nov 17, 2017
1 parent ba0028f commit 0b422e4
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/sbefw/sbeglobals.C
Expand Up @@ -24,7 +24,7 @@
/* IBM_PROLOG_END_TAG */
#include "sbetrace.H"
#include "sbeglobals.H"

#include "sbe_build_info.H"
////////////////////////////////////////////////////////////////
//// @brief Stacks for Non-critical Interrupts and Threads
//////////////////////////////////////////////////////////////////
Expand All @@ -40,3 +40,5 @@ SBEGlobalsSingleton& SBEGlobalsSingleton::getInstance()
static SBEGlobalsSingleton iv_instance;
return iv_instance;
}
// SBE commit id
uint32_t SBEGlobalsSingleton::fwCommitId = SBE_COMMIT_ID;
2 changes: 2 additions & 0 deletions src/sbefw/sbeglobals.H
Expand Up @@ -85,6 +85,8 @@ class SBEGlobalsSingleton
// SBE FW security enabled; 0 - disabled; 1 - enabled
uint8_t sbeFWSecurityEnabled;

// SBE commit id
static uint32_t fwCommitId;
////////////////////////////////////////////////////////////////
//// @brief PkThread structure for SBE Command Receiver thread
//////////////////////////////////////////////////////////////////
Expand Down
49 changes: 43 additions & 6 deletions src/tools/debug/sbe-debug.py
Expand Up @@ -73,6 +73,17 @@ def getOffset( symbol ):
offset = int(symAddr, base = 16) - baseAddr;
return hex(offset)

def getSymbolInfo( symbol ):
symAddr = ''
length = 0
for key, val in syms.items():
if(re.search(symbol, key)!= None):
symAddr = val[0]
length = val[1]
print "\n symAddress :", symAddr
offset = int(symAddr, base = 16) - baseAddr;
return (hex(offset), length)

def createPibmemDumpFile( file_path, offset, length ):
fileHandle = open(file_path)
fileHandle.seek(int(offset, 16))
Expand Down Expand Up @@ -257,8 +268,7 @@ def collectStackUsage (target, node, proc, file_path ):
'sbe_Kernel_NCInt_stack',
'sbeAsyncCommandProcessor_stack')
for thread in threads:
offset = getOffset( thread );
length = "0x" + syms[thread][1];
(offset, length) = getSymbolInfo( thread );
if(target == 'FILE'):
createPibmemDumpFile(file_path, offset, length)
else:
Expand All @@ -273,7 +283,7 @@ def collectStackUsage (target, node, proc, file_path ):
return 1

# Dump stack memory to binary file
cmd2 = "cat DumpPIBMEM >>"+thread
cmd2 = "cat DumpPIBMEM >"+thread
print "cmd2:", cmd2
rc = os.system( cmd2 )
if (rc):
Expand All @@ -289,11 +299,33 @@ def collectStackUsage (target, node, proc, file_path ):
while (1):
if (word == int("0xEFCDAB03", 16)):
leastAvailable += 4
word = struct.unpack('I', f.read(4))[0]
try:
word = struct.unpack('I', f.read(4))[0]
except:
break
else:
break
print str("["+thread+"]").ljust(40) + str(leastAvailable).ljust(30) + str("%.2f" % (100 * (1 - (leastAvailable/float(int("0x"+syms[thread][1], 16))))))

def getSbeCommit(target, node, proc, file_path ):
(offset, length) = getSymbolInfo( 'SBEGlobalsSingleton.*fwCommitId' );
if(target == 'FILE'):
createPibmemDumpFile(file_path, offset, length)
else:
cmd1 = (getFilePath("p9_pibmem_dump_wrap.exe")+" -quiet -start_byte " +
str(offset) +\
" -num_of_byte " + length + " "
" -n" + str(node) + " -p" + str(proc))
print "cmd1:", cmd1
rc = os.system( cmd1 )
if ( rc ):
print "ERROR running %s: %d " % ( cmd1, rc )
return 1

with open("DumpPIBMEM", "rb") as f:
# Big Endian word
word = struct.unpack('>I', f.read(4))[0]
print "SBE commit:", hex(word)

def ppeState( target, node, proc, file_path ):
if(target == 'FILE'):
Expand Down Expand Up @@ -497,6 +529,8 @@ def parsevalue(iValue):
tempVal = iValue[28:34]
print "Reserved Bit [26:31] : %s" %(tempVal)

LEVELS_ARRAY = ('trace', 'forced-trace','attr','stack','ppestate','sbestate','sbestatus','sbelocalregister', 'sym', 'sbecommit')

def usage():
print "usage: testarg.py [-h] [-l {trace,attr,ppestate,sbestate,sbestatus,sbelocalregister, sym}]\n\
\t\t\t\t[-t {AWAN,HW,FILE}] [-n NODE] [-p PROC] [-s SYMBOL] [-f FILE_PATH]\n\
Expand All @@ -505,7 +539,7 @@ def usage():
\n\
optional arguments:\n\
-h, --help show this help message and exitn\n\
-l {trace,attr,stack,ppestate,sbestate,sbestatus,sbelocalregister,sym}, --level {trace,attr,stack,ppestate,sbestate,sbestatus,sbelocalregisteri,sym}\n\
-l "+str(LEVELS_ARRAY)+", --level "+str(LEVELS_ARRAY)+"\n\
Parser level\n\
-t {AWAN,HW,FILE}, --target {AWAN,HW,FILE}\n\
Target type\n\
Expand Down Expand Up @@ -538,7 +572,7 @@ def main( argv ):
usage()
exit(1)
elif opt in ('-l', '--level'):
if arg in ('trace', 'forced-trace','attr','stack','ppestate','sbestate','sbestatus','sbelocalregister', 'sym'):
if arg in LEVELS_ARRAY:
level = arg
else:
print "level should be one of {trace,attr,stack,ppestate,sbestate,sbestatus,sbelocalregister, sym}"
Expand Down Expand Up @@ -629,6 +663,9 @@ def main( argv ):
elif ( level == 'sym' ):
fillSymTable(target, ddsuffix)
getSymbolVal(target, node, proc, symbol, file_path)
elif ( level == 'sbecommit' ):
fillSymTable(target, ddsuffix)
getSbeCommit(target, node, proc, file_path)

if(target != 'FILE'):
# On cronus, set the FIFO mode to previous state
Expand Down

0 comments on commit 0b422e4

Please sign in to comment.