Skip to content

Commit

Permalink
Use Simics CPU Object passed in when executing hap handler code
Browse files Browse the repository at this point in the history
Change-Id: I589529f3550e7c9a11f0e0027a75edd0eec48e25
CQ: SW445281
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/66677
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Reviewed-by: Ilya Smirnov <ismirno@us.ibm.com>
Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com>
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Reviewed-by: Christian R. Geddes <crgeddes@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
  • Loading branch information
wghoffa authored and dcrowell77 committed Sep 27, 2018
1 parent 9f4cbc9 commit 0d43552
Showing 1 changed file with 39 additions and 29 deletions.
68 changes: 39 additions & 29 deletions src/build/debug/simics-debug-framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,35 +90,35 @@ def loads(self,string):
# types into the appropriate simics interface.
#
class DebugFrameworkProcess:
process = ""; # subprocess object.
tool = ""; # string - tool module name.
toolOptions = ""; # string - tool options
outputToString = None; # mode - String output instead of STDOUT.
imgPath = None; # Image dir path override.
result = ""; # Result string for Usage-mode.
outputFile = None; # Output file for results in addition to STDOUT
process = "" # subprocess object.
tool = "" # string - tool module name.
toolOptions = "" # string - tool options
outputToString = None # mode - String output instead of STDOUT.
imgPath = None # Image dir path override.
result = "" # Result string for Usage-mode.
outputFile = None # Output file for results in addition to STDOUT

def __init__(self, tool = "Printk", toolOptions = "",
outputToString = None, usage = None,
imgPath = None,
outputFile = None):
# Assign instance 'imgPath' variable.
self.imgPath = imgPath if imgPath else (os.environ['HB_TOOLPATH']+"/");
self.imgPath = imgPath if imgPath else (os.environ['HB_TOOLPATH']+"/")

# Determine sub-process arguments.
process_args = [self.imgPath+"simics-debug-framework.pl"];
process_args = [self.imgPath+"simics-debug-framework.pl"]
if (usage): # Pass --usage if Usage mode selected.
process_args = process_args + [ "--usage" ];
outputToString = True;
process_args = process_args + [ "--usage" ]
outputToString = True

# Spawn sub-process
self.process = subprocess.Popen(process_args,
stdin=subprocess.PIPE, stdout=subprocess.PIPE)
# Update instance variables.
self.tool = tool;
self.toolOptions = toolOptions;
self.outputToString = outputToString;
self.outputFile = open(outputFile, 'w') if outputFile else None;
self.tool = tool
self.toolOptions = toolOptions
self.outputToString = outputToString
self.outputFile = open(outputFile, 'w') if outputFile else None

# Read a message from the process pipe.
def recvMsg(self):
Expand Down Expand Up @@ -169,9 +169,9 @@ def write_data(self,data):

addr = int(match.group(1))
size = int(match.group(2))
data = map(ord, match.group(3).decode("hex"));
data = map(ord, match.group(3).decode("hex"))

conf.system_cmp0.phys_mem.memory[[addr, addr+size-1]] = data;
conf.system_cmp0.phys_mem.memory[[addr, addr+size-1]] = data

# Read data from PNOR.
# This message has data of the format "0dADDRESS,0dSIZE".
Expand Down Expand Up @@ -304,22 +304,22 @@ def register_hb_debug_framework_tools():
files = os.listdir(os.environ['HB_TOOLPATH']+"/Hostboot")

# Filter out any prefixed with '_' (utility module) or a '.' (hidden file).
pattern = re.compile("[^\._]");
pattern = re.compile("[^\._]")
files = [f for f in files if pattern.match(f)]

# Filter out modules written for vbu only
pattern = re.compile("AutoIpl|ContTrace");
pattern = re.compile("AutoIpl|ContTrace")
files = [f for f in files if not pattern.match(f)]

# Remove the .pm extension from the tool modules.
files = [re.sub("\.pm","",f) for f in files];
files = [re.sub("\.pm","",f) for f in files]

# Create an entry for each module.
for tool in files:
# Get usage information for each module, fix text to HTML-like.
usage = run_hb_debug_framework(tool, usage = 1)
usage = re.sub("<","&lt;", usage);
usage = re.sub(">","&gt;", usage);
usage = re.sub("<","&lt;", usage)
usage = re.sub(">","&gt;", usage)
usage = re.sub("\t"," ",usage)
usage = "<pre>"+usage+"</pre>"

Expand Down Expand Up @@ -372,6 +372,11 @@ def getHRMOR():
result = SIM_get_object(simenv.hb_cpu).hrmor
return result

# Fetch the current HRMOR value for inputted cpu obj
def getHrmorCpu(cpu):
# Use the cpu object to get the hrmor value
iface = SIM_get_interface(cpu, "int_register")
return iface.read(iface.get_number("hrmor"))

# Read simics memory and return a list of strings such as ['0x0','0x2b','0x8']
# representing the data read from simics. The list returned may be handed
Expand Down Expand Up @@ -404,20 +409,20 @@ def writeLong(address,datvalue):
def writeSimicsMemory(address,data):
address = address + getHRMOR()
size = len(data)
conf.system_cmp0.phys_mem.memory[[address, address+size-1]] = data;
conf.system_cmp0.phys_mem.memory[[address, address+size-1]] = data

# Convert an integer to a byte list <size> bytes long.
def intToList(n,size):
lst = []
for i in range(size):
b = n & 0xFF;
b = n & 0xFF
lst.insert(0,b)
n = n >> 8
return lst

# Convert a byte list to an integer.
def listToInt(l):
i = 0;
i = 0
for c in l:
i = (i << 8) | c
return i
Expand Down Expand Up @@ -499,14 +504,19 @@ def magic_instruction_callback(user_arg, cpu, arg):
if( os.environ.has_key('HB_DISABLE_MAGIC')
and (os.environ['HB_DISABLE_MAGIC'] == '1') ):
#print 'Skipping HB magic (disabled)', arg
return;
return

#Only respond to haps for cpu model types we care about (mambo)
if 'mambo_core' not in cpu.classname:
#print 'Skipping HB magic (Not a Mambo core)', arg
return

# Disable our handler if we aren't inside HB part of IPL
# If HB is running then HRMOR==128MB (ignoring high bits)
# 0x40000000=1GB, 0x8000000=128MB
if( (getHRMOR() % 0x40000000) != 0x8000000 ):
if( (getHrmorCpu(cpu) % 0x40000000) != 0x8000000 ):
#print 'Skipping HB magic (outside of HB)', arg
return;
return

if arg == 7006: # MAGIC_SHUTDOWN
# KernelMisc::shutdown()
Expand Down Expand Up @@ -535,7 +545,7 @@ def magic_instruction_callback(user_arg, cpu, arg):
#print 'loading payload from', flash_file, 'to 0x%x' % load_addr
#cmd = 'shell "fcp --force -o0 -R %s:PAYLOAD simicsPayload.ecc; ecc --remove --p8 simicsPayload.ecc simicsPayload"; load-file simicsPayload 0x%x' % (flash_file, load_addr)
#SIM_run_alone( run_command, cmd )
print "MAGIC_LOAD_PAYLOAD not implemented\n";
print "MAGIC_LOAD_PAYLOAD not implemented\n"

if arg == 7018: # MAGIC_BREAK_ON_ERROR
# Stop the simulation if an env var is set
Expand Down

0 comments on commit 0d43552

Please sign in to comment.