summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xsbe/build/simics/makefile30
-rwxr-xr-xsbe/build/simics/sbe_standalone.simics2
-rwxr-xr-xsbe/build/simics/sbe_startup.simics7
-rwxr-xr-xsbe/build/simics/simics-debug-framework.py105
-rw-r--r--sbe/image/Makefile26
5 files changed, 170 insertions, 0 deletions
diff --git a/sbe/build/simics/makefile b/sbe/build/simics/makefile
new file mode 100755
index 00000000..003fa070
--- /dev/null
+++ b/sbe/build/simics/makefile
@@ -0,0 +1,30 @@
+#
+# FSP Destination: obj/ppc/sbei/sbfw/simics/makefile
+#
+# NOTE: Do NOT modify this file in CMVC directly! It comes from the SBE
+# repository and will be overwritten.
+
+.include <${RULES_MK}>
+
+OTHERS = copy_scripts
+
+SBE_SIMICS_PATH = ${MAKETOP}simu/scripts/sbfw/
+
+SBE_SRC_PATHS = ${.PATH:M*src*sbei*sbfw*simics*} ${.PATH:M*obj*sbei*sbfw*simics*}
+SBE_SRC_DIRS = ${SBE_SRC_PATHS:XD}
+SBE_SRC_FILES = ${:!${SBE_SRC_DIRS:@path@ls ${path};@}!}
+
+SBE_SCRIPTS_TO_COPY = ${SBE_SRC_FILES:Nmakefile}
+SBE_SCRIPTS_PATHS = ${SBE_SCRIPTS_TO_COPY:p}
+
+SBE_COPY_COMMAND = \
+ ${SBE_SCRIPTS_PATHS:@file@cp -r ${file} ${SBE_SIMICS_PATH}; @}
+SBE_REMOVE_COMMAND = \
+ ${SBE_SCRIPTS_TO_COPY:@file@rm -rf ${SBE_SIMICS_PATH}${file}; @}
+
+copy_scripts:
+ mkdir -p ${SBE_SIMICS_PATH}
+ ${SBE_COPY_COMMAND}
+
+clobber_copy_scripts:
+ ${SBE_REMOVE_COMMAND}
diff --git a/sbe/build/simics/sbe_standalone.simics b/sbe/build/simics/sbe_standalone.simics
new file mode 100755
index 00000000..8fd3bdb0
--- /dev/null
+++ b/sbe/build/simics/sbe_standalone.simics
@@ -0,0 +1,2 @@
+echo "SBE standalone Tools"
+
diff --git a/sbe/build/simics/sbe_startup.simics b/sbe/build/simics/sbe_startup.simics
new file mode 100755
index 00000000..fe8fbbab
--- /dev/null
+++ b/sbe/build/simics/sbe_startup.simics
@@ -0,0 +1,7 @@
+echo "Attempting to register SBE Tools"
+
+# Load SBE debug tools.
+try {
+ run-python-file (lookup-file sbfw/simics-debug-framework.py)
+} except { echo "ERROR: Failed to load SBE debug tools." }
+
diff --git a/sbe/build/simics/simics-debug-framework.py b/sbe/build/simics/simics-debug-framework.py
new file mode 100755
index 00000000..07bac725
--- /dev/null
+++ b/sbe/build/simics/simics-debug-framework.py
@@ -0,0 +1,105 @@
+import os
+import os.path
+import subprocess
+import re
+import random
+import sys
+sys.path.append("targets/p9_nimbus/sbeTest" )
+import testIstepAuto
+err = False
+
+syms = {};
+
+def check_sbe_tools_path ():
+ global SBE_TOOLS_PATH
+ print "checking for SBE_TOOLS_PATH .."
+ SB_SRC_PATH = os.environ['sb']
+ SB_BB_PATH = os.environ['bb']
+ SBE_TOOLS_REL_PATH = "/obj/ppc/sbei/sbfw/simics"
+ TOOLS_IN_SB = os.environ['sb'] + "/.." + SBE_TOOLS_REL_PATH
+ TOOLS_IN_BB = os.environ['bb'] + SBE_TOOLS_REL_PATH
+
+ if os.path.exists(TOOLS_IN_SB):
+ SBE_TOOLS_PATH = TOOLS_IN_SB
+ print "Found SBE_TOOLS_PATH at: ", SBE_TOOLS_PATH
+ elif os.path.exists(TOOLS_IN_BB):
+ SBE_TOOLS_PATH = TOOLS_IN_BB
+ print "Found SBE_TOOLS_PATH at: ", SBE_TOOLS_PATH
+ else:
+ print "C"
+ print "Error: Could not find SBE_TOOLS_PATH!"
+ SBE_TOOLS_PATH = ""
+
+# MAGIC_INSTRUCTION hap handler
+# arg contains the integer parameter n passed to MAGIC_INSTRUCTION(n)
+# See src/include/arch/ppc.H for the definitions of the magic args.
+# Hostboot magic args should range 7000..7999.
+def magic_instruction_callback_sb(user_arg, cpu, arg):
+ print "In magic_instruction_callback."
+ print arg
+ if arg == 8008:
+ cpu.r3 = random.randint(1, 0xffffffffffffffffL)
+
+ if arg == 8006: # MAGIC_SHUTDOWN
+ # KernelMisc::shutdown()
+ print "KernelMisc::shutdown() called."
+ # Could break/stop/pause the simics run, but presently
+ # shutdown() is called four times. --Monte Jan 2012
+ # SIM_break_simulation( "Shutdown. Simulation stopped." )
+
+
+# @fn register_hb_debug_framework_tools
+# @brief Create a simics command wrapper for each debug tool module.
+def register_sbe_debug_framework_tools():
+ check_sbe_tools_path ()
+ fillSymTable()
+ # Create command hook.
+ new_command("sbe-istep", testIstepAuto.sbe_istep_func,
+ args = [arg(int_t, "major"), arg(int_t, "minor")],
+ alias = "istep",
+ type = ["sbe-commands"],
+ short = "Runs the debug framework for istep ",
+ doc = "")
+ new_command("sbe-trace", collectTrace,
+ args = [],
+ alias = "strace",
+ type = ["sbe-commands"],
+ short = "Runs the debug framework for istep ",
+ doc = "")
+ print "SBE Debug Framework: Registered tool:", "sbe-istep"
+ print "SBE Debug Framework: Registered tool:", "sbe-trace"
+
+
+def fillSymTable():
+# symFile = os.environ['SBE_IMG_OUT_LOC'] + "/sbe.syms"
+ symFile = SBE_TOOLS_PATH + "/sbe.syms"
+# symFile = os.environ['sb'] + "/../obj/ppc/sbei/sbfw/simics/sbe.syms"
+ f = open( symFile, 'r')
+ for line in f:
+ words = line.split()
+ if( len(words) == 3):
+ syms[words[2]] = words[0]
+
+def collectTrace():
+ cmd1 = "pipe \"p9Proc0.sbe.mibo_space.x 0x" + syms['g_pk_trace_buf'] + " 0x2028\" \"sed 's/^p:0x........ //g' | sed 's/ ................$//g' | sed 's/ //g' | xxd -r -p> ppetrace.bin\""
+ cmd2 = "shell \"" + SBE_TOOLS_PATH + "/ppe2fsp ppetrace.bin sbetrace.bin \""
+ cmd3 = "shell \"" + SBE_TOOLS_PATH + "/fsp-trace -s " + SBE_TOOLS_PATH + "/trexStringFile sbetrace.bin > tracMERG \""
+ cmd4 = "shell \"" + "cat tracMERG \""
+
+ ( rc, out ) = quiet_run_command( cmd1, output_modes.regular )
+ if ( rc ):
+ print "simics ERROR running %s: %d "%( cmd1, rc )
+
+ SIM_run_alone( run_command, cmd2 )
+ SIM_run_alone( run_command, cmd3 )
+ SIM_run_alone( run_command, cmd4 )
+
+
+# Register the magic instruction hap handler (a callback).
+SIM_hap_add_callback_range( "Core_Magic_Instruction", magic_instruction_callback_sb, None, 8000, 8190 )
+
+
+
+# Run the registration automatically whenever this script is loaded.
+register_sbe_debug_framework_tools()
+
diff --git a/sbe/image/Makefile b/sbe/image/Makefile
index e5f6bbef..3f5567d7 100644
--- a/sbe/image/Makefile
+++ b/sbe/image/Makefile
@@ -93,6 +93,23 @@ LIB_DIRS += -L$(OBJDIR)/nest
NESTLIB := $(OBJDIR)/nest/libnest.a
LLIBS += -lnest
+SIMICS_PPE_TAR_FILES += $(OBJDIR)/$(IMAGE_SBE_NAME).out
+SIMICS_PPE_TAR_FILES += $(OBJDIR)/$(IMAGE_SBE_NAME).map
+SIMICS_PPE_TAR_FILES += $(OBJDIR)/$(IMAGE_SBE_NAME).dis
+SIMICS_PPE_TAR_FILES += $(OBJDIR)/$(IMAGE_LOADER_NAME).out
+SIMICS_PPE_TAR_FILES += $(OBJDIR)/$(IMAGE_LOADER_NAME).map
+SIMICS_PPE_TAR_FILES += $(OBJDIR)/$(IMAGE_LOADER_NAME).dis
+SIMICS_PPE_TAR_FILES += $(OBJDIR)/$(IMAGE_SEEPROM_NAME).out
+SIMICS_PPE_TAR_FILES += $(OBJDIR)/$(IMAGE_SEEPROM_NAME).map
+SIMICS_PPE_TAR_FILES += $(OBJDIR)/$(IMAGE_SEEPROM_NAME).dis
+SIMICS_PPE_TAR_FILES += $(OBJDIR)/sbe.syms
+SIMICS_PPE_TAR_FILES += $(OBJDIR)/../test/*.xml
+SIMICS_PPE_TAR_FILES += $(OBJDIR)/../test/*.py
+SIMICS_PPE_TAR_FILES += $(OBJDIR)/../../tools/ppetracepp/fsp-trace
+SIMICS_PPE_TAR_FILES += $(OBJDIR)/../../tools/ppetracepp/ppe2fsp
+SIMICS_PPE_TAR_FILES += $(OBJDIR)/trexStringFile
+SIMICS_BB_TAR_FILES += $(OBJDIR)/../build/simics/*
+
SBE_TOOLS := $(TOOLS_IMAGE_DIR)/sbe_default_tool
P9_XIP_TOOL := $(P9_XIP_BINDIR)/p9_xip_tool
@@ -172,6 +189,15 @@ $(LINK_SCRIPT_LOADER): linkloader.cmd
# option of PK enabled
ifndef FAPI2_TEST
all: seeprom $(OBJDIR)/$(IMAGE_SBE_NAME).bin $(OBJDIR)/$(IMAGE_LOADER_NAME).bin $(SBE_TOOLS) appendbase appendloader
+install: all
+ @echo "Installing simics.tar"
+ @rm -rf $(OBJDIR)/simics-tar-dir
+ @mkdir $(OBJDIR)/simics-tar-dir
+ @cp $(SIMICS_PPE_TAR_FILES) $(OBJDIR)/simics-tar-dir
+ @cp $(SIMICS_BB_TAR_FILES) $(OBJDIR)/simics-tar-dir
+ @cd $(OBJDIR)/simics-tar-dir && tar -cvf simics.tar * && mv simics.tar $(OBJDIR) && cd ..
+ @rm -rf $(OBJDIR)/simics-tar-dir
+ @echo "Generated simics.tar in Sbe Obj Directory"
else
all:
@echo "Makefile option error: ALL is not compatible with FAPI2_test"
OpenPOWER on IntegriCloud