From ff7d0cf68fab49bb965467bcd9a6a8068e799349 Mon Sep 17 00:00:00 2001 From: Patrick Williams Date: Fri, 22 Jul 2011 11:06:15 -0500 Subject: Create 'hb' utility script. Change-Id: Ib89bae2a3af6bf29d24e055727125eb1ee52c9f4 Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/211 Tested-by: Jenkins Server Reviewed-by: ADAM R. MUHLE --- .gitignore | 1 + env.bash | 18 ++- env.csh | 7 -- hb | 1 + src/build/citest/etc/workarounds | 16 +-- src/build/tools/cpfiles.pl | 10 +- src/build/tools/hb | 263 +++++++++++++++++++++++++++++++++++++++ 7 files changed, 289 insertions(+), 27 deletions(-) delete mode 100644 env.csh create mode 120000 hb create mode 100755 src/build/tools/hb diff --git a/.gitignore b/.gitignore index b7bd2c5a9..ede05381a 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ *.dep *.o.hash *.swp +customrc diff --git a/env.bash b/env.bash index d3ce5817e..94d2edfb1 100644 --- a/env.bash +++ b/env.bash @@ -4,4 +4,20 @@ if [ -e /esw/fakeroot/ ]; then export MCP_PATH=/esw/fakeroot fi -export PATH=${PATH}:${MCP_PATH}/opt/mcp/bin:${MCP_PATH}/usr/bin:`pwd`/src/build/lids:`pwd`/src/build/trace:`pwd`/src/build/tools +export PATH=${PATH}:${MCP_PATH}/opt/mcp/bin:${MCP_PATH}/usr/bin + +export PATH=${PATH}:`pwd`/src/build/lids +export PATH=${PATH}:`pwd`/src/build/trace +export PATH=${PATH}:`pwd`/src/build/tools + +export HOSTBOOTROOT=`pwd` + +if [ -e ./customrc ]; then + source ./customrc +fi + +if [ -n "${SANDBOXROOT}" ]; then + if [ -n "${SANDBOXNAME}" ]; then + export SANDBOXBASE="${SANDBOXROOT}/${SANDBOXNAME}" + fi +fi diff --git a/env.csh b/env.csh deleted file mode 100644 index 99fcb8857..000000000 --- a/env.csh +++ /dev/null @@ -1,7 +0,0 @@ -setenv MCP_PATH /opt/mcp/shared/powerhal -if (-e /esw/fakeroot/) then - setenv MCP_PATH /esw/fakeroot -endif - - -setenv PATH ${PATH}:${MCP_PATH}/opt/mcp/bin:${MCP_PATH}/usr/bin:`pwd`/src/build/lids:`pwd`/src/build/trace:`pwd`/src/build/tools diff --git a/hb b/hb new file mode 120000 index 000000000..e2844f8ed --- /dev/null +++ b/hb @@ -0,0 +1 @@ +src/build/tools/hb \ No newline at end of file diff --git a/src/build/citest/etc/workarounds b/src/build/citest/etc/workarounds index e874d5872..7b7a52867 100755 --- a/src/build/citest/etc/workarounds +++ b/src/build/citest/etc/workarounds @@ -1,5 +1,6 @@ #!/bin/sh +# This workaround is fixed in b0722a_1132.750 according to Ched." echo "+++ Workaround for SMM error starting simics." /afs/rchland/usr2/ched/public/hostboot/fix_ph110510.sh @@ -7,22 +8,9 @@ echo "+++ Copy desired SALERNO config file to sandbox and modify L3 to 8MB." mkdir -p $sb/simu/configs cp $BACKING_BUILD/src/simu/configs/P8_SALERNO.config $sb/simu/configs sed -i -e's/SETENV GFW_P8_SALERNO_L3_MB_SIZE.*/SETENV GFW_P8_SALERNO_L3_MB_SIZE 8/' $sb/simu/configs/P8_SALERNO.config -sed -i -e's/SETENV GFW_P8_SALERNO_MODEL_EC .*/SETENV GFW_P8_SALERNO_MODEL_EC 910431/' $sb/simu/configs/P8_SALERNO.config +sed -i -e's/SETENV GFW_P8_SALERNO_MODEL_EC.*/SETENV GFW_P8_SALERNO_MODEL_EC 910431/' $sb/simu/configs/P8_SALERNO.config echo "+++ Copy in the P8 scomdef." mkdir -p $sb/engd/scomdef cp /gsa/ausgsa/home/a/n/andrewg/web/public/hostboot/simics/p8_910431.scomdef $sb/engd/scomdef/ -# These workarounds should no longer be needed. -# Keep them here just in case. - -#echo "+++ XSCOM patch for HMER status." -#rm $sb/../simics/amd64-linux/lib/p8_phyp_scom.so -#ln -s /afs/rch/usr7/calebs/public/simics/salerno/p8_phyp_scom.so \ -# $sb/../simics/amd64-linux/lib/p8_phyp_scom.so - -#echo "+++ Clock state workaround." -#mkdir -p $sb/simu/data/cec-chip -#cp $BACKING_BUILD/src/simu/data/cec-chip/p8.por $sb/simu/data/cec-chip -#sed -i -e's/LOGIC(0xFF000001).*/LOGIC(0xFF000001)=0xFFFFFFFF FFFFFFFF/' \ -# $sb/simu/data/cec-chip/p8.por diff --git a/src/build/tools/cpfiles.pl b/src/build/tools/cpfiles.pl index da313c2b9..dc066d859 100755 --- a/src/build/tools/cpfiles.pl +++ b/src/build/tools/cpfiles.pl @@ -73,13 +73,13 @@ else { foreach (@ARGV) { - if ($_ eq "-help") + if (($_ eq "--help") || ($_ eq "-h")) { #Print command line help printUsage(); exit (0); } - elsif ($_ eq "-test") + elsif ($_ eq "--test") { #Set flag to copy hbicore_test. to hbcore_test. $test = 1; @@ -230,7 +230,7 @@ chdir $cwd; #------------------------------------------------------------------------------ sub printUsage() { - print ("\nUsage: cpFiles.pl [-help] | [] [-test]\n\n"); + print ("\nUsage: cpFiles.pl [--help] | [] [--test]\n\n"); print (" This program needs to be executed from the git repository.\n"); print (" It will copy all relevant files, scripts, hbotStringFile,\n"); print (" .list, .syms and .bin files needed for debug to one of two\n"); @@ -239,7 +239,7 @@ sub printUsage() print (" 2. if is not specified, then the files will be\n"); print (' copied to the path specified by env variable $SANDBOXBASE'."\n"); print (" if it is defined.\n\n"); - print (" -help: prints usage information\n"); - print (" -test: Copy hbicore_test. to hbicore.\n"); + print (" --help: prints usage information\n"); + print (" --test: Copy hbicore_test. to hbicore.\n"); } diff --git a/src/build/tools/hb b/src/build/tools/hb new file mode 100755 index 000000000..6e6531b3a --- /dev/null +++ b/src/build/tools/hb @@ -0,0 +1,263 @@ +#!/bin/sh + +execute_in_sandbox() +{ + [ -z "${SANDBOXBASE}" ] && echo "Missing SANDBOXBASE." && exit -1 + [ -z "${SANDBOXROOT}" ] && echo "Missing SANDBOXROOT." && exit -1 + [ -z "${SANDBOXNAME}" ] && echo "Missing SANDBOXNAME." && exit -1 + + SANDBOXRC="${SANDBOXROOT}/hbsandboxrc" + WORKON_CMD="workon -rc ${SANDBOXRC} -sb ${SANDBOXNAME} -m ppc " + + echo $1 > ${SANDBOXBASE}/src/sandbox_execute_cmd + chmod 700 ${SANDBOXBASE}/src/sandbox_execute_cmd + + ${WORKON_CMD} -c ./sandbox_execute_cmd + + rm ${SANDBOXBASE}/src/sandbox_execute_cmd +} + +hb_helptext() +{ + echo "Hostboot Utility Script" + + case $1 in + workon) + echo " Topic 'workon'" + echo + echo " Usage:" + echo " hb workon" + echo + echo " Sources necessary environment files for building hostboot" + echo " and begins a new shell. The workon may be left via 'exit'." + echo + echo " Environment Variables:" + echo " SHELL: The shell program to launch." + echo + echo " See also:" + echo " customrc" + ;; + simsetup) + echo " Topic 'simsetup'" + echo + echo " Usage:" + echo " hb simsetup" + echo + echo " Creates a simics workspace (FSP sandbox) in the directed" + echo " location and initializes simics as well as executing any" + echo " hostboot specific workarounds." + echo + echo " FSP backing build and workarounds are chosen as directed" + echo " by the CI test files (src/build/citest/etc)." + echo + echo " Environment Variables:" + echo " SANDBOXROOT: Root directory of where the sandboxes" + echo " should go." + echo " SANDBOXNAME: Desired name of the hostboot sandbox." + ;; + prime) + echo " Topic 'prime'" + echo + echo " Usage:" + echo " hb prime" + echo " hb prime --test" + echo + echo " Copies hostboot images and simics scripts into the" + echo " simics workspace." + echo + echo " See also:" + echo " simsetup" + ;; + startsimics) + echo " Topic 'startsimics'" + echo + echo " Usage:" + echo " hb startsimics " + echo + echo " Enters the simics workspace and starts simics using the" + echo " start_simics utility. Any options are passed directly to" + echo " the start_simics script." + echo + echo " Requires the hostboot image to be 'prime'd into the workspace." + echo + echo " Environment Variables:" + echo " MACHINE: Alternate simics machine type (default SALERNO)" + echo " SIMICSOPTIONS: Additional options to always pass to the" + echo " start simics script, such as '-nre'." + echo + echo " See also:" + echo " simsetup, prime" + ;; + rsync) + echo " Topic 'rsync'" + echo + echo " Usage:" + echo " hb rsync" + echo + echo " Synchronizes an entire Hostboot repository with another" + echo " directory. This can be useful for creating a backup of" + echo " the repository or for pushing it to a remote host, such" + echo " as a pool machine where simics is executed." + echo + echo " Environment Variables:" + echo " RSYNCHOST: (optional) remote host to rsync to." + echo " RSYNCDIR: Destination directory of the rsync." + echo + echo " The trailing slash on RSYNCDIR, or lack thereof, has" + echo " meaning to rsync. Specifically /.../foo will create a new" + echo " directory called 'foo' with the contents of your repository" + echo " in it, while /.../foo/ will create a subdirectory within foo" + echo " by the name of your repository's directory name." + ;; + customrc) + echo " Topic 'customrc'" + echo + echo " Setting up this file in the root of your repository gives a" + echo " convienient way to create default environment variables for" + echo " the 'hb' script and your hostboot workon environment. Some" + echo " of the hb sub-commands require environment variables assigned" + echo " and they should be done through this 'customrc' file. You" + echo " may also use this as a place to source other files you need" + echo " for your environment, such as setting up 'git'." + echo + echo " The 'customrc' file is in the .gitignore file and should" + echo " NEVER be committed to git. These are your own custom " + echo " settings." + echo + echo " The minimal example 'customrc' file is as follows:" + echo " #!/bin/sh" + echo " export SANDBOXROOT=~/sandboxes" + echo " export SANDBOXNAME=hostboot" + echo + echo " See also:" + echo " All other sub-commands." + ;; + *) + echo " Usage:" + echo " hb " + echo " hb help [|]" + echo + echo " Available Commands:" + echo " workon, simsetup, prime, startsimics, rsync" + echo + echo " Additional Help Topics:" + echo " customrc" + echo + echo " For initial setup:" + echo " 1) Create customrc file." + echo " 2) hb workon" + echo " 3) hb simsetup" + echo " 4) Create images (edit code, make, etc.)." + echo " 5) hb prime [--test]" + echo " 6) hb startsimics" + echo " 7) Return to step 4 until satisfied." + ;; + esac +} + +hb_workon() +{ + if [ -n "${HOSTBOOT_INSIDE_WORKON}" ]; then + echo "Already in a workon." + exit -1 + else + export HOSTBOOT_INSIDE_WORKON=1 + echo "Setting environment variables..." + source ./env.bash + + echo "Spawning new shell (${SHELL})..." + ${SHELL} && exit 0 + fi +} + +hb_prime() +{ + if [ -n "${SANDBOXBASE}" ]; then + cpfiles.pl $* + else + echo "SANDBOXBASE not set." + exit -1 + fi +} + +hb_simsetup() +{ + [ -z "${SANDBOXBASE}" ] && echo "Missing SANDBOXBASE." && exit -1 + [ -z "${SANDBOXROOT}" ] && echo "Missing SANDBOXROOT." && exit -1 + [ -z "${SANDBOXNAME}" ] && echo "Missing SANDBOXNAME." && exit -1 + [ -z "${HOSTBOOTROOT}" ] && echo "Missing HOSTBOOTROOT." && exit -1 + + SANDBOXRC="${SANDBOXROOT}/hbsandboxrc" + DRIVER=`cat ${HOSTBOOTROOT}/src/build/citest/etc/bbuild` + + if [ -d "${SANDBOXBASE}" ]; then + echo "Removing old sandbox." + mksb -rc ${SANDBOXRC} -dir ${SANDBOXROOT} -undo $SANDBOXNAME + fi + + if [ ! -d "${SANDBOXROOT}" ]; then + echo "Creating sandbox root directory." + mkdir -p ${SANDBOXROOT} + fi + + echo "Creating new sandbox." + mksb -rc ${SANDBOXRC} -dir ${SANDBOXROOT} -back $DRIVER \ + -sb ${SANDBOXNAME} -m ppc + + execute_in_sandbox "start_simics -no_start -machine ${MACHINE:-SALERNO}" + + echo "Running workarounds." + cp ${HOSTBOOTROOT}/src/build/citest/etc/workarounds ${SANDBOXBASE}/src + execute_in_sandbox "export BACKING_BUILD=\$bb && ./workarounds" + rm ${SANDBOXBASE}/src/workarounds + + mkdir ${SANDBOXBASE}/img +} + +hb_startsimics() +{ + execute_in_sandbox \ + "start_simics -machine ${MACHINE:-SALERNO} ${SIMICSOPTIONS} $*" +} + +hb_rsync() +{ + [ -z "${HOSTBOOTROOT}" ] && echo "Missing HOSTBOOTROOT." && exit -1 + [ -z "${RSYNCDIR}" ] && echo "Missing RSYNCDIR." && exit -1 + + if [ -z "${RSYNCHOST}" ]; then + rsync -av --delete ${HOSTBOOTROOT}/ ${RSYNCDIR} + else + rsync -zav --delete ${HOSTBOOTROOT}/ ${RSYNCHOST}:${RSYNCDIR} + fi +} + +if [ 0 == $# ]; then + hb_helptext + exit -1 +fi + +FIRST_PARAM=$1 +shift + +case ${FIRST_PARAM} in +workon) + hb_workon $* + ;; +prime) + hb_prime $* + ;; +simsetup) + hb_simsetup $* + ;; +startsimics) + hb_startsimics $* + ;; +rsync) + hb_rsync $* + ;; +*) + hb_helptext $* + exit -1 + ;; +esac -- cgit v1.2.1