diff options
author | George Keishing <gkeishin@in.ibm.com> | 2016-03-24 02:43:11 -0500 |
---|---|---|
committer | Sachin Gupta <sgupta2m@in.ibm.com> | 2016-04-25 06:06:34 -0400 |
commit | 6166c56693bac5f1d0906b5ccacb1507a437ddd5 (patch) | |
tree | 4acae29fef4df1dcb683164e5e2b94d2a20a2c37 /sbe | |
parent | 957197894cfff915515ea65ea07bc79a159e1a50 (diff) | |
download | talos-sbe-6166c56693bac5f1d0906b5ccacb1507a437ddd5.tar.gz talos-sbe-6166c56693bac5f1d0906b5ccacb1507a437ddd5.zip |
RTC 149037: sbe distribute simics patching ( prime/simsetup/sandbox create )
Change-Id: I54ec7af4f00167da5b82fc0bed4356350bf9ec4c
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/22428
Tested-by: Jenkins Server
Reviewed-by: Sachin Gupta <sgupta2m@in.ibm.com>
Diffstat (limited to 'sbe')
-rwxr-xr-x | sbe/build/citest/etc/workarounds.postsimsetup | 11 | ||||
-rw-r--r-- | sbe/build/tools/README | 35 | ||||
-rwxr-xr-x | sbe/build/tools/sandbox-create | 37 | ||||
-rwxr-xr-x | sbe/build/tools/sbeCmvcConstants.py | 4 | ||||
-rwxr-xr-x | sbe/build/tools/sbeCmvcUtility.py | 4 | ||||
-rw-r--r-- | sbe/build/tools/sbePatchUtility.py | 156 | ||||
-rwxr-xr-x | sbe/build/tools/sbePrime.py (renamed from sbe/build/tools/sbeDistribute.py) | 62 |
7 files changed, 290 insertions, 19 deletions
diff --git a/sbe/build/citest/etc/workarounds.postsimsetup b/sbe/build/citest/etc/workarounds.postsimsetup index bea2d5e4..dcd74a2e 100755 --- a/sbe/build/citest/etc/workarounds.postsimsetup +++ b/sbe/build/citest/etc/workarounds.postsimsetup @@ -9,14 +9,15 @@ #cp $BACKING_BUILD/src/simu/data/cec-chip/base_cec_chip_file $sb/simu/data/cec-chip #patch -p0 $sb/simu/data/cec-chip/base_cec_chip_file $SBEROOT/src/build/citest/etc/patches/my_patch_File -echo "+++ Add FSIMBOX KW for actions on 50018 register" -patch -p0 $sb/simu/data/cec-chip/pervasive.act $SBEROOT/sbe/build/citest/etc/patches/pervasive.act.patch +echo " +++ Add FSIMBOX KW for actions on 50018 register" +echo " patch -p0 $SANDBOXBASE/src/simu/data/cec-chip/pervasive.act $SBEROOT/sbe/build/citest/etc/patches/pervasive.act.patch" +patch -p0 $SANDBOXBASE/src/simu/data/cec-chip/pervasive.act $SBEROOT/sbe/build/citest/etc/patches/pervasive.act.patch # NOTE: The below patch removes mailbox settings in standalone.simics (comes # from HB) that cause the SBE to run in plck mode. For our CI, we need the SBE # to be in istep mode. This patch is likely never going to be removed as long as # we need our CI to run in istep mode. echo "+++ Patching standalone.simics" -mkdir -p $sb/../obj/ppc/simu/scripts/hbfw -cp $BACKING_BUILD/obj/ppc/simu/scripts/hbfw/standalone.simics $sb/../obj/ppc/simu/scripts/hbfw -patch -p0 $sb/../obj/ppc/simu/scripts/hbfw/standalone.simics $SBEROOT/sbe/build/citest/etc/patches/standalone.simics.patch +mkdir -p $SANDBOXBASE/obj/ppc/simu/scripts/hbfw +cp $BACKING_BUILD/obj/ppc/simu/scripts/hbfw/standalone.simics $SANDBOXBASE/obj/ppc/simu/scripts/hbfw +patch -p0 $SANDBOXBASE/obj/ppc/simu/scripts/hbfw/standalone.simics $SBEROOT/sbe/build/citest/etc/patches/standalone.simics.patch diff --git a/sbe/build/tools/README b/sbe/build/tools/README index ff9fd33e..3f27a6b0 100644 --- a/sbe/build/tools/README +++ b/sbe/build/tools/README @@ -3,7 +3,7 @@ CONTENT OF THIS FILE -------------------- 1. Tools: * Automate SBE Image integration into FIPS driver - * Developer SBE fips tool for copy and compile ( TBD ) + * Developer SBE fips tool for copy and compile ------------------------------------------------- @@ -34,6 +34,33 @@ CONTENT OF THIS FILE - Jenkin job trigger at the end after fix completing record. -------------------------------------------------- -* Developer SBE fips tool for copy and compile ( TBD ) -------------------------------------------------- +------------------------------------------------------------------ +* Developer SBE fips tool for copy,compile & simics action patches +------------------------------------------------------------------ + + [ Files ] : sbeDistribute.py (Main) + sbePatchUtility.py + sbeCmvcConstants.py + sbeCmvcUtility.py + + [ Brief ] : This tool will copy the SBFW files from PPE repo to fips sandbox and compile. + Additionaly it would patch the simics action files at the end of compilation. + + [ Feature ] : + - By default, the tool doesn't need any input as an argument + + - Refers the Sandbox and Repo ENV and identifies which fips sandbox and PPE Repo needed. + + - Find the list of pre-define file list in the PPE repo and copies to fips sandbox + Refer: sbeCmvcConstants.py + + - Loads the ENV and compiles the fips sandbox code. + + - User can create a fips sandbox manually and still use this tool by passing -s <sandbox name > + as an argument + + - User can specify file as an input but -ONLY- those pre-define files selectively using option + -i <file1,file2> + + - Sets up simics directory and patches the action files needed. + diff --git a/sbe/build/tools/sandbox-create b/sbe/build/tools/sandbox-create new file mode 100755 index 00000000..f52397d5 --- /dev/null +++ b/sbe/build/tools/sandbox-create @@ -0,0 +1,37 @@ +#!/bin/bash + +echo " Creating ODE sandbox..." + +# Ensure backing build is accessible. +if [ ! -d "$BACKING_BUILD" ]; +then + echo " Cannot access the backing build: $BACKING_BUILD" + exit -1 +fi + +SANDBOXRC=${SANDBOXROOT}/sbesandboxrc; + +# Delete existing sandbox if it exists. +if [ -d "$SANDBOXBASE" ]; +then + # prompt the user to delete the sanbox or not if exist + echo -ne " Remove existing sandbox? {y/n}:" + read input + if [ "$input" == "y" ];then + echo " Executing : mksb -undo -auto -rc $SANDBOXRC -dir $SANDBOXROOT -sb $SANDBOXNAME" + mksb -undo -auto -rc $SANDBOXRC -dir $SANDBOXROOT -sb $SANDBOXNAME + else + exit 0 + fi +fi + +if [ -d "$SANDBOXBASE" ]; +then + rm -rf $SANDBOXBASE + rm -f $SANDBOXRC +fi + +# Create sandbox. +echo " Sandbox backing build = $BACKING_BUILD" +echo " mksb -rc $SANDBOXRC -dir $SANDBOXROOT -back $BACKING_BUILD -sb $SANDBOXNAME -m ppc -auto" +mksb -rc $SANDBOXRC -dir $SANDBOXROOT -back $BACKING_BUILD -sb $SANDBOXNAME -m ppc -auto || exit -1 diff --git a/sbe/build/tools/sbeCmvcConstants.py b/sbe/build/tools/sbeCmvcConstants.py index a1d8fe4a..a281c251 100755 --- a/sbe/build/tools/sbeCmvcConstants.py +++ b/sbe/build/tools/sbeCmvcConstants.py @@ -18,7 +18,7 @@ Generic Failure RC code ''' SUCCESS_EXIT = 0 -SHELL_EXIT = 1 +SHELL_EXIT = 1 # Shell Exited with error ERROR_EXIT = 2 HELP_EXIT = 3 SUCCESS_DEV_EXIT = 4 @@ -45,7 +45,6 @@ SUCCESS_CI_TRIGGER = 54 CMVC_FILE_LIST ="sbe_sp_intf.H,simics.tar,sbe_pibmem.bin,sbe_seeprom.bin" CMVC_FILE_UNDO_LIST ="src/sbei/sbfw/sbe_sp_intf.H src/sbei/sbfw/simics.tar src/sbei/sbfw/img/sbe_pibmem.bin src/sbei/sbfw/img/sbe_seeprom.bin" -#CMVC_FILE_LIST ="src/sbei/sbfw/sbe_sp_intf.H,src/sbei/sbfw/simics.tar,src/sbei/sbfw/img/sbe_main.bin,src/sbei/sbfw/img/sbe_pibmem.bin,src/sbei/sbfw/img/sbe_seeprom.bin" CMVC_DIR_CREATE ="sandbox_" @@ -58,4 +57,5 @@ ERROR_HASH_CHECK = 101 ERROR_SANDBOX_EXIST = 200 # Sandbox doesnt exist ERROR_FILE_INPUT = 201 # User have entered no file ERROR_BUILD_FAILED = 202 # Compilation failed +ERROR_HOOKING_FILE = 203 # Error while building shell hooks FILE_LOOKUP_LIST ="src/sbei/sbfw/sbe_sp_intf.H,src/sbei/sbfw/simics.tar,src/sbei/sbfw/img/sbe_pibmem.bin,src/sbei/sbfw/img/sbe_seeprom.bin" diff --git a/sbe/build/tools/sbeCmvcUtility.py b/sbe/build/tools/sbeCmvcUtility.py index 357aa8fd..3ccb2659 100755 --- a/sbe/build/tools/sbeCmvcUtility.py +++ b/sbe/build/tools/sbeCmvcUtility.py @@ -510,8 +510,8 @@ def utilWriteShell_hooks(i_sandbox_path): cd_cmd= 'cd ' + i_sandbox_path + '/src/sbei/sbfw/' f.write(cd_cmd) f.write('\n') - f.write('mk -a \n') - f.write('mk install_all \n') + f.write('mk -a || exit -1 \n') + f.write('mk install_all || exit -1\n') f.close() # Change the file permission for execute diff --git a/sbe/build/tools/sbePatchUtility.py b/sbe/build/tools/sbePatchUtility.py new file mode 100644 index 00000000..1ae1bb63 --- /dev/null +++ b/sbe/build/tools/sbePatchUtility.py @@ -0,0 +1,156 @@ +#!/usr/bin/python +''' +########################################################### +# @file sbeCmvcUtility.py +# @author: George Keishing <gkeishin@in.ibm.com> +# @brief Utilility Module to Patching files for SBE simics +# +# Created on March 23, 2016 +# ---------------------------------------------------- +# @version Developer Date Description +# ---------------------------------------------------- +# 1.0 gkeishin 23/03/16 Initial create +########################################################### +''' + +#------------------------- +# Imports +#------------------------- +import os, sys +import time +import os.path +import subprocess +import shutil +import hashlib +from subprocess import Popen, PIPE +from os.path import expanduser # for getting $HOME PATH +import stat # for File permission op + +# Libraries/utility funcs and user define const +import sbeCmvcConstants as errorcode +import sbeCmvcUtility as utilcode + +########################################################################## +# Function : utilPatchSimics +# +# @param i_sandbox_path : Sandbox full path +# +# @param i_sandbox_root : Sandbox RC root path +# +# @brief Patch pre-req patches for simics +# +########################################################################## +def utilPatchSimics(i_sandbox_path, i_sandbox_root): + print "\n ... Patching simics files " + + sb_name=os.path.basename(i_sandbox_path) + + # Write the hooks for sim setup + l_sim_file = utilShell_hooks(i_sandbox_path) + + if not l_sim_file: + return errorcode.ERROR_HOOKING_FILE + + l_sim_cmd = "workon -m ppc " + sb_name + " -c " + l_sim_file + " -rc " + i_sandbox_root +"/sbesandboxrc" + print " ", l_sim_cmd + + os.system(l_sim_cmd) + + # Copy action files. As we are taking actions files from ppe, copy them here + # so that any workaround necessary can be applied over them in pre-simsetup path + # mkdir -p $SANDBOXBASE/src/simu/data/cec-chip + # cp $SBEROOT/import/chips/p9/sw_simulation/* $SANDBOXBASE/src/simu/data/cec-chip || exit -1 + + print " [ Copying action files to fips Sandbox ]" + # Ge the Sandbox base + sandbox_base = utilcode.utilFind_ENV_string("SANDBOXBASE").rstrip('\n') + sandbox_path = sandbox_base + "/src/simu/data/cec-chip" + cmd = "mkdir -p " + sandbox_path + print " * Executing : ",cmd + os.system(cmd) + + # Ge the ppe root + ppe_base = utilcode.utilFind_ENV_string("SBEROOT").rstrip('\n') + ppe_path = ppe_base + "/import/chips/p9/sw_simulation/" + p_cmd = "cp -f " + ppe_path + "* " + sandbox_path + print " * Executing : ",p_cmd + rc = os.system(p_cmd) + if rc: + print " ERROR rc :",rc + return rc + + return errorcode.SUCCESS_EXIT + +########################################################################## +# Function : utilExecuteShell +# +# @param i_ppe_root : Root folder for PPE. This script must be +# from PPE repo. +# +# @param i_sandbox_path : fips Sandbox path +# +# @param i_shell_file : User defined shell script name +# +# @brief Apply the simics patches pre define in shell script. +# +########################################################################## +def utilExecuteShell(i_ppe_root, i_sandbox_path, i_shell_file): + print "\n ... Executing shell : ",i_shell_file + + # Sanbox name + if i_sandbox_path != "None": + sb_name=os.path.basename(i_sandbox_path) + + # Find the file and execute + l_path_name = i_ppe_root + '/sbe/build/' + l_shell_path=utilcode.utilFindFile(i_shell_file, l_path_name) + print " [ %s ]"%l_shell_path + + if i_sandbox_path != "None": + # Load the shell onto the Sandbox env and execute + l_shell_exec = "workon -m ppc " + sb_name + " -c " + l_shell_path + " -rc " + i_sandbox_path.replace(sb_name,"") +"/sbesandboxrc" + else: + # Execute a stand alone script + l_shell_exec = l_shell_path + + #rc = subprocess.call([l_shell_exec]) + rc = os.system(l_shell_exec) + if rc : + return rc + + return errorcode.SUCCESS_EXIT + +########################################################################## +# Function : utilShell_hooks +# +# @param i_sandbox_path : Sandbox full path +# +# @brief find the ENV string set in the env +# +########################################################################## +def utilShell_hooks(i_sandbox_path): + # Find the simics machine from ENV + l_machine = os.environ['MACHINE'].rstrip('\n') + print " Machine : ",l_machine + l_cmd_exec = 'start_simics -no_start -machine ' + l_machine + ' -batch_mode ' + + # Write the compile shell hook on the fips sandbox location + hook_file=i_sandbox_path + '/src/simsb' + f = open(hook_file,'w') + + # simsb: This hook schell script will look like this + # + # #!/bin/sh + # start_simics -no_start -machine NIMBUS -batch_mode + + f.write('#!/bin/sh \n') + f.write('\n') + f.write(l_cmd_exec) + f.close() + + # Change the file permission for execute + perm_st = os.stat(hook_file) + os.chmod(hook_file, perm_st.st_mode | stat.S_IEXEC) + + return hook_file # path of the shell file + diff --git a/sbe/build/tools/sbeDistribute.py b/sbe/build/tools/sbePrime.py index 9615621a..d82d4215 100755 --- a/sbe/build/tools/sbeDistribute.py +++ b/sbe/build/tools/sbePrime.py @@ -1,9 +1,9 @@ #!/usr/bin/python ''' ########################################################### -# @file sbeDistribute.py +# @file sbePrime.py # @author: George Keishing <gkeishin@in.ibm.com> -# @brief Main Module to support developer compilation +# @brief Main Module to support developer compilation # and patching. # # Created on March 03, 2016 @@ -25,6 +25,7 @@ import stat # for File permission op # Libraries/utility funcs and user define const import sbeCmvcConstants as errorcode import sbeCmvcUtility as utilcode +import sbePatchUtility as utilpatch #------------------------- # Main Function @@ -44,6 +45,7 @@ def main(): print " | By default NO argument is needed as an input . |" print " +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" print " \n ***** Options Supported *****" + print " \t -p,--patch = [ Optional ] Patch Simics related files on Sandbox " print " \t -s,--sb = [ Optional ] Sandbox base name" print " \t By default it picks up the ppe Repo test_sb sandbox" print " \t but if you have created a sandbox of your own manually " @@ -73,12 +75,13 @@ def main(): print "\n [ ERROR - MAIN ] Exiting with error code = ", rc sys.exit(rc) else: - print "\n Fips Sandbox compilation completed [ OK ] " + print "\n Fips Sandbox compilation and simics patching completed [ OK ] " sys.exit(0) #------------------------------------------ # Local var place name holder's #------------------------------------------ + sim_patch = "None" sandbox_name = "None" path_name = "None" # PPE Repo file_name = "None" @@ -86,11 +89,13 @@ def main(): #---------------------------- # Read command line args #---------------------------- - opts, args = getopt.getopt(sys.argv[1:],"s:i:h",['sb=', 'files=', 'help']) + opts, args = getopt.getopt(sys.argv[1:],"p:s:i:h",['patch=', 'sb=', 'files=', 'help']) for opt, arg in opts: if opt in ('-h', '--help'): usage() exit_main(errorcode.HELP_EXIT) + elif opt in ('-p', '--patch'): + sim_patch = arg elif opt in ('-s', '--sb'): sandbox_name = arg elif opt in ('-i', '--files'): @@ -127,7 +132,7 @@ def main(): path_name = l_ppe_path #----------------------------------- - # 2) Get the Sanbox and repo paths + # 2) Get the Sanbox and repo paths #----------------------------------- # Get the base path of the fips sandbox if sandbox_name == "None": @@ -153,6 +158,51 @@ def main(): else: print " Sandbox root path\t : ",sandbox_root + #--------------------------------------------- + # sim setup if user initiates + #--------------------------------------------- + if sim_patch != "None": + #--------------------------------------------- + # Create sandbox for simics + #--------------------------------------------- + rc_sb = utilpatch.utilExecuteShell(path_name,"None","sandbox-create") + if rc_sb == errorcode.SUCCESS_EXIT: + print " Sandbox Created.. [ OK ] \n" + else: + print " Sandbox Create.. [ ERROR ]",rc_sb + exit_main(rc_sb) + + #---------------------------------------- + # Patch up the simics patches files + #---------------------------------------- + + print "\n *** Update Simics patches onto Sandbox *** \n " + # Pre sim setup + rc_shell = utilpatch.utilExecuteShell(path_name,sandbox_path,"workarounds.presimsetup") + if rc_shell == errorcode.SUCCESS_EXIT: + print " presimsetup [ OK ]\n" + else: + print " presimsetup [ ERROR ] : ",rc_shell + exit_main(rc_shell) + + # Patch the simics files + rc_sim = utilpatch.utilPatchSimics(sandbox_path,sandbox_root) + if rc_sim != errorcode.SUCCESS_EXIT: + exit_main(rc_sim) + else: + print " Patch the simics files on Sandbox [ OK ] \n" + + # Post sim setup + rc_shell = utilpatch.utilExecuteShell(path_name,sandbox_path,"workarounds.postsimsetup") + if rc_shell == errorcode.SUCCESS_EXIT: + print " postsimsetup [ OK ]\n" + # Clean exit Get out from here + exit_main(errorcode.SUCCESS_EXIT) + else: + print " postsimsetup [ ERROR ] : ",rc_shell + exit_main(rc_shell) + + #---------------------------------------- # 4) Copy the files from repo to sandbox #---------------------------------------- @@ -192,7 +242,7 @@ def main(): if sandbox_name == "None": compile_cmd="workon -m ppc " + sb_name + " -c " + hook_file + " -rc " + sandbox_root +"/sbesandboxrc" else: - compile_cmd="workon -m ppc " + sb_name + " -c " + hook_file + sandbox_root +"/.sandboxrc" + compile_cmd="workon -m ppc " + sb_name + " -c " + hook_file + " -rc " + sandbox_root +"/.sandboxrc" print "\n [ COMPILE ] Executing :%s \n"%compile_cmd rc = os.system(compile_cmd) |