Skip to content

Instantly share code, notes, and snippets.

@shenki
Created July 5, 2017 06:52
Show Gist options
  • Save shenki/d00e433eedcb904dbd6207787a4c6b5f to your computer and use it in GitHub Desktop.
Save shenki/d00e433eedcb904dbd6207787a4c6b5f to your computer and use it in GitHub Desktop.
Dump out the state of your SBE with pdbg
#!/usr/bin/python2
#
# OpenPOWER sbe Project
#
# Copyright 2016,2017 International Business Machines Corp.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied. See the License for the specific language governing
# permissions and limitations under the License.
import os
def sbe_status(proc=0):
cmd = "pdbg getcfam 0x2809 -p {}".format(proc)
output = os.popen(cmd).read()
# TODO: error handling
output = output.split('=')[1]
parsevalue(bin(int(output, 16)))
def parsevalue(cfam):
sbe_states = {'0000': 'SBE_STATE_UNKNOWN',
'0001' : 'SBE_STATE_IPLING',
'0010': 'SBE_STATE_ISTEP',
'0011' : 'SBE_STATE_MPIPL',
'0100': 'SBE_STATE_RUNTIME',
'0101' : 'SBE_STATE_DMT',
'0110': 'SBE_STATE_DUMP',
'0111' : 'SBE_STATE_FAILURE',
'1000': 'SBE_STATE_QUIESCE',
'1001' : 'SBE_STATE_QUIESCE',
'1111': 'SBE_INVALID_STATE'}
val = cfam[2:3]
val = 'True' if val == '1' else 'False'
print "SBE Booted : %s" %(val)
val = cfam[3:4]
val = 'True' if val == '1' else 'False'
print "Async FFDC : %s" %(val)
val = cfam[4:6]
print "Reserver Bit [2:3] : %s" %(val)
val = cfam[6:10]
print "SBE Previous State : %s (%s)" %(sbe_states[val], val)
val = cfam[10:14]
print "SBE Current State : %s (%s)" %(sbe_states[val], val)
val = cfam[14:22]
print "Istep Major : %s" %(int(val, 2))
val = cfam[22:28]
print "Istep Minor : %s" %(int(val, 2))
val = cfam[28:34]
print "Reserved Bit [26:31] : %s" %(val)
if __name__ == "__main__":
sbe_status()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment