diff options
author | Stephan Broyles <sbroyles@us.ibm.com> | 2014-11-17 16:12:42 -0600 |
---|---|---|
committer | Stephan Broyles <sbroyles@us.ibm.com> | 2014-11-17 16:53:58 -0600 |
commit | adf09ed6e89a0489a8efb16da94ec7cfe88efa59 (patch) | |
tree | 188e0cf360e89f5430755d11864971d657fb67b0 | |
parent | 8af3c1a8c64086fb01b3e0839270ae123d6e2630 (diff) | |
download | talos-occ-adf09ed6e89a0489a8efb16da94ec7cfe88efa59.tar.gz talos-occ-adf09ed6e89a0489a8efb16da94ec7cfe88efa59.zip |
Removed tools and debug trace files, Makefile fixes
Change-Id: I28234a83bb0b01ba5adda25d03ab415ad00c3f57
Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/14525
Reviewed-by: Stephan Broyles <sbroyles@us.ibm.com>
Tested-by: Stephan Broyles <sbroyles@us.ibm.com>
31 files changed, 45 insertions, 7927 deletions
diff --git a/src/Makefile b/src/Makefile index 8b2a26f..093a355 100755 --- a/src/Makefile +++ b/src/Makefile @@ -1,33 +1,8 @@ -# $Id$ -# @file Makefile -# -# @brief bootloader Makefile -# - -# @page ChangeLogs Change Logs -# @section Makefile -# @verbatim -# -# -# Change Log ****************************************************************** -# Flag Defect/Feature User Date Description -# ------ -------------- ---------- ------------ ----------- -# pb000 pbavari 07/21/11 Created -# th000 thallet 01/09/12 Removed simics-workspace -# at009 859308 alvinwan 10/15/2012 Added tracepp support -# at011 866759 alvinwan 01/15/2013 Fix OCC trexStringFile and trace -# rt001 901927 tapiar 10/01/2013 SRC plugin file generation -# gitprep sbroyles 11/02/2014 Prepare files for move to git/gnu build -# @endverbatim -# - -# >> gitprep ifndef ROOTPATH ROOTPATH = $(shell pwd) export OCCROOT = $(ROOTPATH) endif -# << gitprep #******************************************************************************* # mk variable Declaration @@ -43,7 +18,6 @@ IMAGEFILE = image.bin #******************************************************************************* # Compilation #******************************************************************************* - all: $(foreach dir,$(SUBDIRS),$(ALLCMD)) @@ -60,7 +34,7 @@ combineImage: #******************************************************************************* .PHONY : 81e004%.ruhx 81e004%.ruhx: - ./occ/tools/occgenlid.pl -i ${IMAGEFILE} -l $(basename $@) + occgenlid.pl -i ${IMAGEFILE} -l $(basename $@) .PHONY : 81e004%.lid 81e004%.lid: @@ -69,17 +43,19 @@ combineImage: #******************************************************************************* # Create trexStringFile #******************************************************************************* +# FIXME tracehash tool location unknown, references to sandboxes .PHONY : tracehash tracehash: mkdir -p ${sb}/../obj tracehash.pl -c -d ${SANDBOXBASE}/obj/ppc/occc/405/ -s ${SANDBOXBASE}/obj/trexStringFile #******************************************************************************* -# Create occcSrcParse.C @rt001 +# Create occcSrcParse.C #******************************************************************************* +# FIXME error log parser plugins not relevant to OpenPOWER, tool location unknown .PHONY : srcPluginFile srcPluginFile: - ./occ/tools/scanforsrcs.pl + scanforsrcs.pl #******************************************************************************* # Clean diff --git a/src/occ/Makefile b/src/occ/Makefile index 9a9f975..5cc4800 100755 --- a/src/occ/Makefile +++ b/src/occ/Makefile @@ -1,28 +1,8 @@ -# $Id$ - -# @file Makefile -# -# @brief Makefile occ application -# - -# @page ChangeLogs Change Logs -# @section Makefile -# @verbatim -# -# -# Change Log ****************************************************************** -# Flag Defect/Feature User Date Description -# ------ -------------- ---------- ------------ ----------- -# @rc003 rickylie 02/03/2012 Verify & Clean Up OCC Headers & Comments -# -# @endverbatim -# include cfiles.mk include gpefiles.mk -include debug_trace.mk -APP = occ +APP = occ APP_INCLUDES += -I../ssx APP_INCLUDES += -I../lib APP_INCLUDES += -I./incl @@ -49,10 +29,12 @@ APP_INCLUDES += -I./timer export APP_INCLUDES D += -DOCC_FIRMWARE=1 \ - -DSIMICS_MAGIC_PANIC=1 \ - -DOCC=1 \ - -DNONCACHEABLE_SUPPORT=1 \ - -DUSE_SSX_APP_CFG_H=1 + -DSIMICS_MAGIC_PANIC=1 \ + -DOCC=1 \ + -DNONCACHEABLE_SUPPORT=1 \ + -DUSE_SSX_APP_CFG_H=1 + +# FIXME Needs section comment on default values for compile defs and info on what defs do #D = -DVERIFICATION=1 \ -DSSX_STACK_CHECK=0 \ -DINITIALIZE_PMC=0 \ @@ -62,6 +44,7 @@ D += -DOCC_FIRMWARE=1 \ -DSIMICS_MAGIC_PANIC=1 \ -DSSX_KERNEL_TRACE_ENABLE=1 +# FIXME Aren't trace strings hashed out of the image already? # If this makefile is called as "make NO_TRAC_STRINGS=1" then trace strings # won't be built into the image. This will be used for metrics regarded to the # realistic OCC Code Size. Note that "make clean" must be run before this define @@ -69,36 +52,15 @@ D += -DOCC_FIRMWARE=1 \ # be used. You can also see the space used by strings by running: # strings occ.bin | \grep "ERR\|INF\|IMP" | sed 's/^...: %s: //g' | wc -m ifdef NO_TRAC_STRINGS -D += -DNO_TRAC_STRINGS=1 # @th002a -endif - -# @pb009a - Added define to be used to enable/disable debug traces -# usage to enable debug traces: "make OCC_DBG_TRACE=1" -# @rc001d - remove OCC_DBG_TRACE 01/16/2012 - trace debug improvement - - -# Added define to be used to enable/disable OCC_ALONE simics model -# supported components. The only components not supported on occ_alone -# is FSP & PHYP, so this will be used to fake out all commands we need -# from FSP, and automatically go ACTIVE. -# usage: "make FSPLESS_SIMICS=1" to enable this mode -ifdef FSPLESS_SIMICS # @th029c -D += -DFSPLESS_SIMICS=1 -endif - -# Added define to be used to enable GCOV based code coverage tools. -# For now, this only works in the "occ" source files, not ssx or lib. -# usage: "make GCOV_CODE_COVERAGE=1" -ifdef GCOV_CODE_COVERAGE # @th029a -D += -DGCOV_CODE_COVERAGE=1 +D += -DNO_TRAC_STRINGS=1 endif SOURCES = ${all_cfiles} ${all_gpefiles} -MODE = validation - +MODE = validation PGP_ASYNC_SUPPORT = 1 include ./app.mk pgas: $(CC) $(CFLAGS) -c -Wa,-al -Wa,--listing-cont-lines='10' ${all_gpefiles} + diff --git a/src/occ/debug_trace.mk b/src/occ/debug_trace.mk deleted file mode 100755 index 4e3367e..0000000 --- a/src/occ/debug_trace.mk +++ /dev/null @@ -1,76 +0,0 @@ -# $Id$ - -# @file debug_trace.mk -# -# @brief mk occ application -# - -# @page ChangeLogs Change Logs -# @section debug_trace.mk -# @verbatim -# -# -# Change Log ****************************************************************** -# Flag Defect/Feature User Date Description -# ------ -------------- ---------- ------------ ----------- -# @rc001 rickylie 01/09/2012 Created -# -# @endverbatim -# - -#******************************************************************************* -# Defines -#******************************************************************************* -#//>@rc001a - -ifdef MAIN_DEBUG -D += -DMAIN_DEBUG=1 -endif - -ifdef RTLS_DEBUG -D += -DRTLS_DEBUG=1 -endif - -ifdef THRD_DEBUG -D += -DTHRD_DEBUG=1 -endif - -ifdef PROC_DEBUG -D += -DPROC_DEBUG=1 -endif - -ifdef AMEC_DEBUG -D += -DAMEC_DEBUG=1 -endif - -ifdef APLT_DEBUG -D += -DAPLT_DEBUG=1 -endif - -ifdef DCOM_DEBUG -D += -DDCOM_DEBUG=1 -endif - -ifdef ERRL_DEBUG -D += -DERRL_DEBUG=1 -endif - -ifdef APSS_DEBUG -D += -DAPSS_DEBUG=1 -endif - -ifdef DPSS_DEBUG -D += -DDPSS_DEBUG=1 -endif - -ifdef SNSR_DEBUG -D += -DSNSR_DEBUG=1 -endif - -ifdef TMER_DEBUG -D += -DTMER_DEBUG=1 -endif - -#//@<rc001a - -#******************************************************************************* diff --git a/src/occ/debug_trace_ode.mk b/src/occ/debug_trace_ode.mk deleted file mode 100755 index 3503eae..0000000 --- a/src/occ/debug_trace_ode.mk +++ /dev/null @@ -1,76 +0,0 @@ -# $Id$ - -# @file debug_trace.mk -# -# @brief mk occ application -# - -# @page ChangeLogs Change Logs -# @section debug_trace.mk -# @verbatim -# -# -# Change Log ****************************************************************** -# Flag Defect/Feature User Date Description -# ------ -------------- ---------- ------------ ----------- -# @rc001 rickylie 01/09/2012 Created -# #pb00E pbavari 03/11/2012 ODE Makefile support -# @endverbatim -# - -#******************************************************************************* -# Defines -#******************************************************************************* -#//>@rc001a - -.ifdef MAIN_DEBUG -DEFS += -DMAIN_DEBUG=1 -.endif - -.ifdef RTLS_DEBUG -DEFS += -DRTLS_DEBUG=1 -.endif - -.ifdef THRD_DEBUG -DEFS += -DTHRD_DEBUG=1 -.endif - -.ifdef PROC_DEBUG -DEFS += -DPROC_DEBUG=1 -.endif - -.ifdef AMEC_DEBUG -DEFS += -DAMEC_DEBUG=1 -.endif - -.ifdef APLT_DEBUG -DEFS += -DAPLT_DEBUG=1 -.endif - -.ifdef DCOM_DEBUG -DEFS += -DDCOM_DEBUG=1 -.endif - -.if defined( ERRL_DEBUG ) -DEFS += -DERRL_DEBUG=1 -.endif - -.ifdef APSS_DEBUG -DEFS += -DAPSS_DEBUG=1 -.endif - -.ifdef DPSS_DEBUG -DEFS += -DDPSS_DEBUG=1 -.endif - -.ifdef SNSR_DEBUG -DEFS += -DSNSR_DEBUG=1 -.endif - -.ifdef TMER_DEBUG -DEFS += -DTMER_DEBUG=1 -.endif - -#//@<rc001a - -#******************************************************************************* diff --git a/src/occ/tools/EXAMPLE_.occ_simics_config b/src/occ/tools/EXAMPLE_.occ_simics_config deleted file mode 100755 index 1414e24..0000000 --- a/src/occ/tools/EXAMPLE_.occ_simics_config +++ /dev/null @@ -1,22 +0,0 @@ -# This is the configuration file for the 'start_occ_simics' script. The script will start -# a simics session and attempt to automatically load the OCC binaries based off the -# inputs and values below - -# Location of simics-workspace that contains simics executable and target directory -SIMICS_WORKSPACE = /afs/rchland.ibm.com/usr8/arink/sandboxes/occ/simics-workspace - -# Target to use. Can be overridden via "-t" option to start_occ_simics -DEFAULT_TARGET = /afs/rchland.ibm.com/usr8/arink/sandboxes/occ/simics-workspace/targets/occ/occ-simple-common.simics - -# Binary file to use. Can be overridden by passing in a .out file to start_occ_simics -DEFAULT_BINARY = /afs/rchland.ibm.com/usr8/arink/sandboxes/occ/src/occ/occ.out - -# Directories to check when looking for target/binary files -PATH = /afs/rchland.ibm.com/usr8/arink/sandboxes/occ/src/occ -PATH = /afs/rchland.ibm.com/usr8/arink/sandboxes/occ/src/validation -PATH = /afs/rchland.ibm.com/usr8/arink/sandboxes/occ/src/occ - -# Default commands to run -COMMAND = pushd tools -COMMAND = output-radix 16 -COMMAND = enable-magic-breakpoint diff --git a/src/occ/tools/Gcov.pm b/src/occ/tools/Gcov.pm deleted file mode 100644 index d79339e..0000000 --- a/src/occ/tools/Gcov.pm +++ /dev/null @@ -1,811 +0,0 @@ -#!/usr/bin/perl -use strict; -use File::Path; -use File::Basename; - -package Gcov; -#use Hostboot::_DebugFrameworkVMM qw(NotFound NotPresent getPhysicalAddr); - -use Exporter; -our @EXPORT_OK = ('main'); - -# NOTE: -# -# Neither the in-memory structures or the resulting file format is well -# documented for GCOV. I was able to piece together enough of this to -# make it work for our purposes by looking at gcov-io.h and libgcov.c -# from the gcc source and gcov/gcc_3_4.c from the linux source. -# -# Since this is a Perl script only used internally for debug, I do not see -# any risk for contamination. If we decided to give Hostboot to external -# vendors than this Perl script would be distributed as source which should -# not lead us into any issues. -# -# If you are personally concerned about contamination by reading this -# code you are hereby warned of the potential. Proceed at your own choice. - -use constant GCOV_EXTENDED_IMAGE_ADDRESS => (0xfff80000); -use constant GCOV_INFO_HEAD_SYMBOLNAME => "_gcov_info_head"; - -use constant GCOV_INFO_VERSION_OFFSET => 0; -use constant GCOV_INFO_NEXT_OFFSET => GCOV_INFO_VERSION_OFFSET + 4; -use constant GCOV_INFO_TIMESTAMP_OFFSET => GCOV_INFO_NEXT_OFFSET + 4; -use constant GCOV_INFO_FILENAME_OFFSET => GCOV_INFO_TIMESTAMP_OFFSET + 4; -use constant GCOV_INFO_NFUNCTIONS_OFFSET => GCOV_INFO_FILENAME_OFFSET + 4; -use constant GCOV_INFO_FUNCTIONS_OFFSET => GCOV_INFO_NFUNCTIONS_OFFSET + 4; -use constant GCOV_INFO_CTRMASK_OFFSET => GCOV_INFO_FUNCTIONS_OFFSET + 4; -use constant GCOV_INFO_COUNTS_OFFSET => GCOV_INFO_CTRMASK_OFFSET + 4; - -use constant GCOV_FNINFO_IDENT_OFFSET => 0; -use constant GCOV_FNINFO_CHECKSUM_OFFSET => GCOV_FNINFO_IDENT_OFFSET + 4; -use constant GCOV_FNINFO_NCTRS_OFFSET => GCOV_FNINFO_CHECKSUM_OFFSET + 4; - -use constant GCOV_CTRINFO_COUNT_OFFSET => 0; -use constant GCOV_CTRINFO_VALUEPTR_OFFSET => GCOV_CTRINFO_COUNT_OFFSET + 4; - -use constant GCOV_GCDA_MAGIC_VALUE => 0x67636461; -use constant GCOV_FUNCTION_TAG => 0x01000000; -use constant GCOV_COUNTERS_TAG => 0x01a10000; - -# In memory format: -# GCC creates a 'gcov_info' structure for each .o file. The info -# structure has a next pointer to form a chain. In Hostboot we have -# organized the chains so that the pointer to the first entry is -# stored at [modulename]_gcov_info_head (where modulename = "core" for -# kernel and basic system libraries). -# -# The gcov_info has a version id (for the gcc compiled with), a -# compile timestamp, c-string with the name of the .gcda file to be -# generated, a count of the number of functions in the object, a -# pointer to a set of function descriptors, a "counter mask" and a -# set of counter descriptors. -# -# GCOV supports multiple types of counters. The only one we are -# interested in is the "ARCS" counter, which describes the number of -# times a particular branch is executed. The other counters are for, -# for instance, profiling the value of a particular variable. The -# "counter mask" specifies which counters are instrumented, which -# determines the size of some of the array structures, but we only -# parse the ARCS-counter type (we do properly calculate sizes if -# needed). -# -# Each function descriptor contains an identity number and checksum -# pair so the processing tools can match data to code information. -# Also the function descriptor has an "n_counters" array which -# determines for each counter type how many counters are instrumented. -# Again, we are only concerned with the ARCS counter type. -# -# The counter descriptor is a size and pointer to array of counter -# values. If there were 3 functions in the object each with n_counter -# values of [3, 5, 2], then the size of the counter descriptor would be -# 3+5+2 = 10. The values are arranged such that the first function has -# the first 3 values, second one has the next 5, etc. The relationship -# between function descriptor / "n_counters" and counter descriptor -# values was not obvious from reading the gcov-io.h. -# -# For more details on these structures search the internet for gcov-io.h -# or ask the building block team for the source code to the compiler we -# are currently using. The offsets of all of these structures are all -# documented in Perl constants above so you should only need this if -# something breaks. -# -# .gcda file format: -# The gcov tools expect a .gcda (gcov data) file as input, containing the -# instrumented counter values, to go along with the .gcno (gcov note) -# file created by the compiler. The format is documented in gcov-io.h -# as well but was again not obvious to decipher. -# -# Here is a distilled file format description. Each entity is an u32. -# -# file : magic version stamp {function counts}* -# function: f_header ident checksum -# counts: c_header count* -# count: lo hi -# f_header: F_TAG(=0x01000000) F_LENGTH(=2) -# c_header: C_TAG(=0x01a10000) C_LENGTH(=count_length*2) -# -# The file has three u32 of header followed by any number of function -# descriptor and count set pairs. The function descriptor is the -# identity and checksum of the function. The count set is an array of -# uint64_ts, containing instrumented counts, for the preceeding function. - -# Global of where we want the output to go. -our $output_dir; -our $debug_mode; -BEGIN -{ - $debug_mode = 1; - $output_dir = ""; -} -return 1; - -#----------------------------------------------------------------------------- -# Added for OCC usage -# -use IO::Seekable; -our ($parsedSymbolFile, %symbolAddress, %symbolTOC, - %addressSymbol, %symbolSize); -our ($parsedModuleFile, %moduleAddress); -our $imgPath; -use constant NotFound => 'not found'; -use constant NotPresent => 'not present'; - -# @sub getPhysicalAddr -# -# Find the physical address in the VMM from a VA passed in. -# -# @param address we are looking for -# @param debug var to indicate debug mode (1 = debug on) -# @return physical address -# -sub getPhysicalAddr -{ - my $vaddr = shift; - my $debug = shift; - my $displaySPTE = shift; - - my $phyAddr = NotFound; - - #if( ($vaddr - 0xfff80000) > 0 ){ - # $phyAddr = ($vaddr - 0xfff80000); - #} - $phyAddr = $vaddr; - - return $phyAddr; -} - -# @sub readData -# -# Reads a data blob from the dump file. -# -# @param integer - Address to read at. -# @param size - Size (in bytes) to read. -# -# @return The blob of data requested. -# -sub _readData -{ - my $addr = shift; - my $size = shift; - - if( ($addr >= 0xfff80000) ){ - $addr = ($addr - 0xfff80000); - } else { - $addr = 0; - } - - seek DUMPFILE, $addr, SEEK_SET; - - my $result = ""; - read DUMPFILE, $result, $size; - - return $result; -} - -# @sub userDisplay -# -# Display parameters to the user. -# -# @param varargs - Items to display to the user. -# -sub userDisplay -{ - foreach my $value (@_) - { - print $value; - } -} - -sub getImgPath -{ - #my $path = "/home/thallet/ProjectWorkspace/temp/occ.syms"; - my $path = $imgPath; - return $path; -} - -# @sub parseSymbolFile <INTERNAL ONLY> -# -# Parses through a .syms file and populates a hash. -# -sub parseSymbolFile -{ - if ($parsedSymbolFile) { return; } - - my $symsFile = getImgPath(); - - open(FILE, "< $symsFile") or die "Cannot open symbol file $symsFile"; - while (my $line = <FILE>) - { - $line =~ m/(.*?) (.*?) (.*)/; - my $name = $3; - my $addr = hex $1; - my $tocAddr = 0; - my $size = 0; - my $type = $2; - - $addressSymbol{$addr} = $name; - $addressSymbol{$tocAddr} = $name; - - # Use only the first definition of a symbol. - # This is useful for constructors where we only want to call the - # 'in-charge' version of the constructor. - if (defined $symbolAddress{$name}) - { - next; - } - - $symbolAddress{$name} = $addr; - if ($type eq "F") - { - $symbolTOC{$name} = $tocAddr; - } - $symbolSize{$name} = $size; - - } - close(FILE); - - $parsedSymbolFile = 1; -} - -# @sub findSymbolAddress -# -# Searchs a syms file for the address of a particular symbol name. -# -# @param string - Symbol to search for. -# @return array of (address, size) or (not-defined, not-defined). -# -sub findSymbolAddress -{ - my $name = shift; - - parseSymbolFile(); - - return ($symbolAddress{$name}, $symbolSize{$name} ); -} - - -# @sub littleendian -# -# Utility function to determine if the current machine is little or big -# endian. -# -# @return true if machine is little-endian. -# -sub _littleendian -{ - return (unpack("L", pack("N", 0xabcd1234)) != 0xabcd1234); -} - -# @sub read64 -# -# Reads a 64-bit unsigned integer from an address. -# -# @param Address to read from. -# @return Value. -# -sub _read64 -{ - my $addr = shift; - - my $result = _readData($addr, 8); - if (_littleendian()) { $result = reverse($result); } - - return unpack("Q", $result); -} - -# @sub read32 -# -# Reads a 32-bit unsigned integer from an address. -# -# @param Address to read from. -# @return Value. -# -sub _read32 -{ - my $addr = shift; - - my $result = _readData($addr, 4); - if (_littleendian()) { $result = reverse($result); } - - return unpack("L", $result); -} - -# @sub read16 -# -# Reads a 16-bit unsigned integer from an address. -# -# @param Address to read from. -# @return Value. -# -sub _read16 -{ - my $addr = shift; - - my $result = _readData($addr, 2); - if (littleendian()) { $result = reverse($result); } - - return unpack("S", $result); -} - -# @sub read8 -# -# Reads a 8-bit unsigned integer from an address. -# -# @param Address to read from. -# @return Value. -# -sub _read8 -{ - my $addr = shift; - - my $result = _readData($addr, 1); - - return unpack("C", $result); -} - -# @sub readStr -# -# Reads a string from an address. -# -# @param Address to read from. -# @return Value. -# -sub _readStr -{ - my $addr = shift; - - my $result = ""; - my $byte = 0; - - do - { - $byte = read8($addr); - $addr += 1; - - if ($byte != 0) - { - $result = $result.pack("C",$byte); - } - } while ($byte != 0); - - return $result; -} - -# @sub readExtImage -# -# Reads from the extended image file. -# -# @param addr - Address to read. -# @param size - Size to read. -sub _readExtImage -{ - my $addr = shift; - my $size = shift; - - my $extImage = extImageFile(); - - seek $extImage, $addr, SEEK_SET; - - my $result = ""; - read $extImage, $result, $size; - - return $result; -} - -# @sub extImageFile -# -# Returns a file descriptor to the extended image file. -# -my $extImage = 0; -sub extImageFile -{ - if ($extImage == 0) - { - my $path = getImgPath(); - - userDebug("".$path."\n"); - - open($extImage, "< $path") or die "Cannot find extended image"; - binmode($extImage); - } - - return $extImage; -} - -# -# -#----------------------------------------------------------------------------- -sub main -{ - # Pick a new output directory based on the time. - $output_dir = sprintf "gcov.output.%d/", time; - File::Path::mkpath($output_dir); - - #my $dumpfile = "/home/thallet/ProjectWorkspace/temp/occ_gcov.bin"; - my $dumpfile = shift; - $imgPath = shift; - - # Open dump file. - open(DUMPFILE, "< $dumpfile") or die "Can't open dump file.\n"; - binmode(DUMPFILE); - - # Find all the hostboot modules. - my @modules = getModules(); - - # Search for the gcov_info object for each module and parse. - foreach my $module (@modules) - { - parseModuleGcov($module); - } - - my $pwd = `pwd`; - chomp $pwd; - userDisplay "GCOV output written to: $pwd/$output_dir\n"; -} - -sub parseModuleGcov -{ - my $module = shift; - userDisplay "Extracting GCOV info for ".$module."\n"; - - # Search for gcov_info chain symbol. - my ($gcov_info, $unused) = - findSymbolAddress($module.GCOV_INFO_HEAD_SYMBOLNAME); - - userDebug("\tFound info at 0x" . (sprintf "%x", $gcov_info) . "\n"); - - # Translate gcov_info chain to a physical address if in a module. - if (isVirtualAddress($gcov_info)) - { - $gcov_info = getPhysicalAddr($gcov_info); - - if (($gcov_info eq NotFound) || ($gcov_info eq NotPresent)) - { - userDisplay "\tModule data is not present.\n"; - return; - } - } - - # Check that we found the gcov_info chain. - if ($gcov_info == 0) - { - userDisplay "\tUnable to find gcov_info chain. Skipped.\n"; - return; - } - - userDebug("\tFound info at 0x" . (sprintf "%x", $gcov_info) . "\n"); - - # Parse info chain. - parseGcovInfo(read32($gcov_info)); -} - -sub parseGcovInfo -{ - my $info_ptr = shift; - return if (0 eq $info_ptr); - - userDebug("\tAddr = ".(sprintf "%x", $info_ptr)."\n"); - my $filename = readStr(read32($info_ptr + GCOV_INFO_FILENAME_OFFSET)); - userDebug("\tFile = ".$filename."\n"); - - my $version = read32($info_ptr + GCOV_INFO_VERSION_OFFSET); - my $stamp = read32($info_ptr + GCOV_INFO_TIMESTAMP_OFFSET); - - my $func_count = read32($info_ptr + GCOV_INFO_NFUNCTIONS_OFFSET); - userDebug("\tFunction Count = ".$func_count."\n"); - - my $funcs = read32($info_ptr + GCOV_INFO_FUNCTIONS_OFFSET); - userDebug("\tFunc Address = ".(sprintf "%x", $funcs)."\n"); - - my $ctrmask = read32($info_ptr + GCOV_INFO_CTRMASK_OFFSET); - if ($ctrmask % 2) # Check that COUNTER_ARCS is turned on. - { - # COUNTER_ARCS is on. Create file, find arc-values array, - # parse functions. - - my $fd = createGcovFile($filename, $version, $stamp); - - my $arcs_ptr = read32($info_ptr + GCOV_INFO_COUNTS_OFFSET + - GCOV_CTRINFO_VALUEPTR_OFFSET); - parseGcovFuncs($fd, $funcs, $func_count, $ctrmask, $arcs_ptr); - - close $fd; - } - else - { - userDebug("COUNTER_ARCS is missing!\n"); - } - - # Look for next .o in gcov_info chain, parse. - my $next = read32($info_ptr + GCOV_INFO_NEXT_OFFSET); - sleep(4); - parseGcovInfo($next); -} - -sub parseGcovFuncs -{ - my $fd = shift; - my $func_ptr = shift; - my $func_count = shift; - my $mask = shift; - my $val_ptr = shift; - - my $fn_offset = 0; - - # Need to calculate the number of counters based on the bits on in - # the 'mask'. This is used to determine the size of the function - # descriptor object. - my $counters = 0; - { - my $_mask = $mask; - - while (0 != $_mask) - { - $counters++; - $_mask = ($_mask >> 1); - } - } - - userDebug("\tCounters = ".$counters."\n"); - - # Round up the counter count to the nearest two for alignment of the - # function descriptor object. - if ($counters % 2) - { - $counters++; - } - my $func_size = GCOV_FNINFO_CHECKSUM_OFFSET + 4 * $counters; - - userDebug("\tFunction size = ".$func_size."\n"); - - # Iterate through the functions and parse. - for(my $function = 0; $function < $func_count; $function++) - { - my $func_off = ($func_ptr + $func_size * $function); - my $ident = read32($func_off + GCOV_FNINFO_IDENT_OFFSET); - my $chksum = read32($func_off + GCOV_FNINFO_CHECKSUM_OFFSET); - - userDebug("Ident = ".(sprintf "%x", $ident)."\n"); - userDebug("Chksum = ".(sprintf "%x", $chksum)."\n"); - - print $fd pack('l', GCOV_FUNCTION_TAG); # Write function tag. - print $fd pack('l', 2); # Write size = 2. - print $fd pack('l', $ident); # Write ident. - print $fd pack('l', $chksum); # Write checksum. - - my $nctr_val = read32($func_off + GCOV_FNINFO_NCTRS_OFFSET); - userDebug("N-Counters = ".$nctr_val."\n"); - - print $fd pack('l', GCOV_COUNTERS_TAG); # Write counter tag. - print $fd pack('l', $nctr_val * 2); # Write counter length. - - # Read each counter value, output. - # Read as one big block for performance reasons. - my $counters = readData($val_ptr + 8*($fn_offset), 8 * $nctr_val); - #my $counters = readData($val_ptr + 4*($fn_offset), 8 * $nctr_val); - for(my $v_idx = 0; $v_idx < $nctr_val; $v_idx++) - { - my $val = substr $counters, 0, 8; - $counters = substr $counters, 8; - if (_littleendian()) { $val = reverse($val); } - $val = unpack("Q", $val); - userDebug("\tValue[$v_idx] = ".$val."\n"); - - print $fd pack('l', $val & 0xFFFFFFFF); # Write lower word. - print $fd pack('l', $val >> 32) ; # Write upper word. - } - - # We used up a number of counters, so move the offset forward for - # the next function. - $fn_offset += $nctr_val; - } - -} - -# The *.gcda filename found in the gcov_info struct is an absolute path to -# the corresponding .o file (not the .C file). This is of the form: -# ${HOSTBOOTROOT}/src/usr/module/${ROOTPATH}/obj/${MODULE}/foo.gcda . -# Since we might not even be running this on the same machine, we need to put -# the output into the "output_dir" but we need to strip off a lot of stuff. -# The path is going to have an obj in it somewhere so we key off that -# as the location for where the output file will go. -sub createGcovFile -{ - my $name = shift; - my $version = shift; - my $stamp = shift; - - # Change *./../obj/ into obj/, prepend output_dir. - $name =~ s/.*\/obj\//obj\//; - $name = $output_dir.$name; - - # Make sure everything after 'obj/' exists (create subdirs). - my $dir = File::Basename::dirname($name); - File::Path::mkpath($dir); - - # Create file. - open(my $GCOVFILE, "> $name"); - binmode($GCOVFILE); - - # Write out header. - print $GCOVFILE pack('l', GCOV_GCDA_MAGIC_VALUE); - print $GCOVFILE pack('l', $version); - print $GCOVFILE pack('l', $stamp); - - return $GCOVFILE; -} - -# Search the module list for each code module (lib*.so). Also add "core" -# for the kernel instrumentation. -sub getModules -{ - my @result = ( "core" ); - return @result; -} - -# Determine if an address is virtual. -sub isVirtualAddress -{ - my $addr = shift; - - return (0); -} - -# Utility to read a block of data from eithr memory or using the extended -# image file as a fallback if not present in memory. -use constant PAGESIZE => 4096; -sub readData -{ - my $addr = shift; - my $size = shift; - - if (isVirtualAddress($addr)) - { - my $result = ""; - - while($size) - { - my $amount = $size; - - if ((($addr % PAGESIZE) + $size) >= PAGESIZE) - { - $amount = PAGESIZE - ($addr % PAGESIZE); - } - - my $paddr = getPhysicalAddr($addr); - if ((NotFound eq $paddr) || (NotPresent eq $paddr)) - { - $paddr = $addr - GCOV_EXTENDED_IMAGE_ADDRESS; - $result = $result._readExtImage($paddr, $amount); - } - else - { - $result = $result._readData($paddr, $amount); - } - - $size = $size - $amount; - } - - return $result; - } - - return _readData($addr, $size); -} - -# Utility to read 64 bits from either memory or using the extended image file -# as a fallback if not present in memory. -sub read64 -{ - my $addr = shift; - my $old_addr = $addr; - if (isVirtualAddress($addr)) - { - $addr = getPhysicalAddr($addr); - if ((NotFound eq $addr) || (NotPresent eq $addr)) - { - $addr = $old_addr - GCOV_EXTENDED_IMAGE_ADDRESS; - my $result = _readExtImage($addr, 8); - if (_littleendian()) { $result = reverse($result); } - return unpack("Q", $result); - } - } - - return _read64($addr); -} - -# Utility to read 32 bits from either memory or using the extended image file -# as a fallback if not present in memory. -sub read32 -{ - my $addr = shift; - my $old_addr = $addr; - if (isVirtualAddress($addr)) - { - $addr = getPhysicalAddr($addr); - if ((NotFound eq $addr) || (NotPresent eq $addr)) - { - $addr = $old_addr - GCOV_EXTENDED_IMAGE_ADDRESS; - my $result = _readExtImage($addr, 4); - if (_littleendian()) { $result = reverse($result); } - return unpack("L", $result); - } - } - - return _read32($addr); -} - -# Utility to read 8 bits from either memory or using the extended image file -# as a fallback if not present in memory. -sub read8 -{ - my $addr = shift; - my $old_addr = $addr; - if (isVirtualAddress($addr)) - { - $addr = getPhysicalAddr($addr); - if ((NotFound eq $addr) || (NotPresent eq $addr)) - { - $addr = $old_addr - GCOV_EXTENDED_IMAGE_ADDRESS; - my $result = _readExtImage($addr, 1); - return unpack("C", $result); - } - } - - return _read8($addr); -} - -# Utility to read a string from either memory or using the extended image file -# as a fallback if not present in memory. -sub readStr -{ - my $addr = shift; - my $old_addr = $addr; - if (isVirtualAddress($addr)) - { - $addr = $addr - GCOV_EXTENDED_IMAGE_ADDRESS; - - # Virtual address, so need to read 1 byte at a time from the file. - my $string = ""; - my $byte = 0; - - do - { - $byte = _readExtImage($addr,1); - $addr = $addr + 1; - - if (unpack("C",$byte) eq 0) - { - return $string; - } - - $string = $string.$byte; - - } while (1) - } - else - { - _readStr($addr); - } -} - -sub userDebug -{ - return if (!$debug_mode); - - my $string = shift; - userDisplay $string; -} - -# Debug tool help info. -sub helpInfo -{ - my %info = ( - name => "Gcov", - intro => [ "Extracts the GCOV information."], - ); -} - -#----------------------------------------------------------------------------- - - - diff --git a/src/occ/tools/OccSimicsAutomate.pm b/src/occ/tools/OccSimicsAutomate.pm deleted file mode 100755 index f385243..0000000 --- a/src/occ/tools/OccSimicsAutomate.pm +++ /dev/null @@ -1,1010 +0,0 @@ -############################################################################## -# -# @file OccSimicsAutomate.pm -# -# @author Timothy Hallett -# -# @package OccSimicsAutomate -# -# @brief Perl class for automating simics for OCC. -# -# @verbatim -# -# Updates: 11/28/2011 -- thallet -- File/Class created -# 11/29/2011 -- thallet -- Methods for automating tracing and simics -# added and tested. Integration into Code -# Coverage Tool (HOCCT) works as well. -# v0.2 01/17/2012 -- thallet -- Made change to handle post_model_hook.simics -# v0.2.1 01/19/2012 -- thallet -- Clear accum on Expect calls. Changed simics -# prompt string. -# -# @endverbatim -# -# -############################################################################## - -package OccSimicsAutomate; - -use strict; -use Expect; - - - -############################################################################## -#----------------------------------------------------------------------------- -# -# Package Config/Default Parms -# -#----------------------------------------------------------------------------- -############################################################################## - -# @brief VERSION - contains VERSION of this class -my $VERSION = "0.2.1"; - -# @brief DEBUG_LEVEL - sets debug level of this class's print output -my $DEBUG_LEVEL = 1; - -# @brief CMD_PROMPT - sets what Expect should see for Linux bash prompt -my $CMD_PROMPT = '^.*[$%>#]\s'; - -# @brief CMD_PROMPT - sets what Expect should see for Simics prompt -my $SIMICS_PROMPT = "simics> \x1b.*m"; - -# @brief EXPECT_COMMAND - sets what Expect should run to get a bash prompt -my $EXPECT_COMMAND = "bash -i"; - -# @brief DEFAULT_TRACE_FILE - sets default filename for simics execution trace -my $DEFAULT_TRACE_FILE = "occ_exe_trace"; - -# @brief DEFAULT_INSTRUCTION_FILE - sets default filename for parsed out instruction trace -my $DEFAULT_INSTRUCTION_FILE = "/tmp/occ_instructions.txt"; - -# @brief SIMICS_CYCLES_PER_MS - sets timing for how many simics cycles are in 1ms. -my $SIMICS_CYCLES_PER_MS = (150016 * 4); - - -############################################################################## -#----------------------------------------------------------------------------- -# -# Package Global Variables -# -#----------------------------------------------------------------------------- -############################################################################## - -# @var G_occ_start_cmds -# -# @brief Holds commands that need to run to initialize simics for OCC execution -# -my @G_occ_start_cmds = -( - "enable-magic-breakpoint", - "new-symtable st_auto ../src/occ/occ.out", - "\@conf.OccComplex.OccSimpleSlot.cpu.current_context.symtable = conf.st_auto", -); - -# @var G_trace_start_cmds -# -# @brief Holds commands that need to run to initialize simics for tracing instructions -# -my @G_trace_start_cmds = -( - "load-module trace", - "new-tracer", - "trace0->trace_data = 0", - "trace0->trace_exceptions = 0", - "trace0->print_virtual_address = 0", - "trace0->print_memory_type = 0", - "trace0->print_linear_address = 0", - "trace0->print_data = 0", -); - - -############################################################################## -#----------------------------------------------------------------------------- -# -# Constructor -# -#----------------------------------------------------------------------------- -############################################################################## - -#------------------------------------------------ -# @fn new -# -# @brief Constructor, spawns bash shell with expect. -# -# @param None -# -# @return self - Pointer to $self as class pointer -#------------------------------------------------ -sub new -{ - my $class = shift; - my $self = - { - debug_lvl => $DEBUG_LEVEL, - prompt => $CMD_PROMPT, - shell_cmd => $EXPECT_COMMAND, - cyc_per_ms => $SIMICS_CYCLES_PER_MS, - trace_file => $DEFAULT_TRACE_FILE, - instr_file => $DEFAULT_INSTRUCTION_FILE, - expect_obj => undef, - last_rc => undef, - temp_file1 => undef, - temp_file2 => undef, - }; - - # Spawn a bash shell to run in - my @params; - $self->{expect_obj} = Expect->spawn($self->{shell_cmd}, @params) or die "Cannot spawn $self->{shell_cmd}: $!\n"; - #$self->{expect_obj}->log_file("filename", "w"); #Later, add option to log all expect activity? - #$self->{expect_obj}->log_file("filename"); #Later, add option to log all expect activity? - $self->{last_rc} = $self->{expect_obj}->expect(10,'-re',$self->{prompt}); - - #If call fails, print out error - if(0 == $self->{last_rc}) - { - print "Could not get bash prompt!"; die; - } - - # For now, lets die if we aren't in a sandbox - if( !defined($ENV{"sb"}) ){die "This script needs to run in an ODE sandbox!\n";} - - - bless ($self, $class); - return $self; -} - -############################################################################## -#----------------------------------------------------------------------------- -# -# Destructor -# -#----------------------------------------------------------------------------- -############################################################################## - -#------------------------------------------------ -# @fn DESTROY -# -# @brief Cleans up class, closes simics & expect. -# -# @param None -# -# @return None -#------------------------------------------------ -sub DESTROY -{ - my ( $self ) = @_; - - simics_cmd($self,"exit"); - - $self->{expect_obj}->soft_close(); -} - - -############################################################################## -#----------------------------------------------------------------------------- -# -# Base Methods -# -#----------------------------------------------------------------------------- -############################################################################## - -#------------------------------------------------ -# @fn prereq_simics -# -# @brief Makes sure that prereqs are in place to starts the simics session -# -# @param None -# -# @return rc - Return code of expect operation -#------------------------------------------------ -sub prereq_simics -{ - my ( $self ) = @_; - - # Make sure we have the simics command script setup to run - #if( !(-e $ENV{"sb"}."/../post_model_hook.simics") ) - { - if( -e $ENV{"sb"}."/occ/tools/occ_post_model_hook.simics" ) - { - print "Setting up Symlinks...\n"; - system("rm ".$ENV{"sb"}."/../simics/post_model_hook.simics"); - system("ln -s ".$ENV{"sb"}."/occ/tools/occ_post_model_hook.simics ".$ENV{"sb"}."/../simics/post_model_hook.simics"); - } - } -} - -#------------------------------------------------ -# @fn start_simics -# -# @brief Starts the simics session via expect -# -# @param None -# -# @return rc - Return code of expect operation -#------------------------------------------------ -sub start_simics -{ - my ( $self ) = @_; - - prereq_simics($self); - - $self->{expect_obj}->clear_accum(); - $self->{expect_obj}->send("start_simics -m occ_alone -st -batch_mode\n"); - $self->{last_rc} = $self->{expect_obj}->expect(300,'-re',$SIMICS_PROMPT); - - #If call fails, print out error - if(0 == $self->{last_rc}) - { - print "Couldn't get simics prompt ".$self->{last_rc}." \n"; die; - } - - return $self->{last_rc}; -} - -#------------------------------------------------ -# @fn close -# -# @brief Exits & Closes the simics session via expect -# -# @param None -# -# @return None -#------------------------------------------------ -sub close -{ - my ( $self ) = @_; - - simics_cmd_w_timeout($self,1,"exit"); - - $self->{expect_obj}->soft_close(); -} - -#------------------------------------------------ -# @fn simics_cmd -# -# @brief Runs a simics command, watis for "simics>" -# -# @param cmd - String with command that will be sent -# -# @return rc - Return code of expect operation -#------------------------------------------------ -sub simics_cmd -{ - my ( $self, $cmd ) = @_; - - $self->{expect_obj}->clear_accum(); - $self->{expect_obj}->send("$cmd\n"); - $self->{last_rc} = $self->{expect_obj}->expect(10,'-re',$SIMICS_PROMPT) or return; - - #If a person wanted to parse out the command, you would use this - #expect call here: - # @lines = $self->{expect_obj}->before(); - # foreach(@lines){do something to $_}; - - return $self->{last_rc}; -} - - -#------------------------------------------------ -# @fn simics_cmd_w_response -# -# @brief Runs a simics command, watis for "simics>" -# -# @param cmd - String with command that will be sent -# -# @return rc - Return code of expect operation -#------------------------------------------------ -sub simics_cmd_w_response -{ - my ( $self, $cmd ) = @_; - - $self->{expect_obj}->clear_accum(); - $self->{expect_obj}->send("$cmd\n"); - $self->{last_rc} = $self->{expect_obj}->expect(10,'-re',$SIMICS_PROMPT) or return; - - #If a person wanted to parse out the command, you would use this - #expect call here: - my @lines = $self->{expect_obj}->before(); - # foreach(@lines){do something to $_}; - return @lines; -} - -#------------------------------------------------ -# @fn get_last_simics_cmd_response -# -# @brief Returns what expect read before last prompt -# -# @return All response from last command before prompt -#------------------------------------------------ -sub get_last_simics_cmd_response -{ - my ( $self ) = @_; - - return $self->{expect_obj}->before(); -} - -#------------------------------------------------ -# @fn simics_cmd_w_timeout -# -# @brief Runs a simics command, watis for "simics>" -# -# @param t - Timeout in seconds of expect operation -# @param cmd - String with command that will be sent -# -# @return rc - Return code of expect operation -#------------------------------------------------ -sub simics_cmd_w_timeout -{ - my ($self, $t, $cmd) = @_; - - $self->{expect_obj}->clear_accum(); - $self->{expect_obj}->send("$cmd\n"); - $self->{last_rc} = $self->{expect_obj}->expect($t,'-re',$SIMICS_PROMPT) or return; - - return $self->{last_rc}; -} - -#------------------------------------------------ -# @fn simics_cmd_w_timeout_w_running -# -# @brief Runs a simics command, watis for "running>" -# -# @param t - Timeout in seconds of expect operation -# @param cmd - String with command that will be sent -# -# @return rc - Return code of expect operation -#------------------------------------------------ -sub simics_cmd_w_timeout_w_running -{ - my ($self, $t, $cmd) = @_; - - $self->{expect_obj}->clear_accum(); - $self->{expect_obj}->send("$cmd\n"); - $self->{last_rc} = $self->{expect_obj}->expect($t,'-re','running> ') or return; - - return $self->{last_rc}; -} - -#------------------------------------------------ -# @fn simics_cmd_w_running -# -# @brief Runs a simics command, watis for "running>" -# -# @param cmd - String with command that will be sent -# -# @return rc - Return code of expect operation -#------------------------------------------------ -sub simics_cmd_w_running -{ - my ( $self, $cmd ) = @_; - - $self->{expect_obj}->clear_accum(); - $self->{expect_obj}->send("$cmd\n"); - $self->{last_rc} = $self->{expect_obj}->expect(10,'-re','running> ') or return; - - return $self->{last_rc}; -} - -#------------------------------------------------ -# @fn DEBUG -# -# @brief Prints out debug data, based on debug_lvl -# -# @param lvl - Min Level of debug at which string will print -# @param str - String that will be printed -# -# @return None -#------------------------------------------------ -sub DEBUG -{ - my ($self,$lvl,$str) = @_; - if($lvl <= $self->{debug_lvl}) - { - print $str; - } -} - -#------------------------------------------------ -# @fn DEBUG -# -# @brief Prints out debug data, based on debug_lvl -# -# @param lvl - Min Level of debug at which string will print -# @param str - String that will be printed -# -# @return None -#------------------------------------------------ -sub SET_DEBUG_LVL -{ - my ($self,$lvl) = @_; - - $self->{debug_lvl} = $lvl; - - if($lvl <= 5) - { - print "Turning on Expect debugging\n\n"; - $self->{expect_obj}->debug(3); - $self->{expect_obj}->exp_internal(1); - } -} - - - -#----------------------------------------------------------------------------- -# Base Utilities (generic, based off base methods) -#----------------------------------------------------------------------------- - -#------------------------------------------------ -# @fn waitForSimicsPrompt -# -# @brief Helper function, returns when "simics>" is seen -# -# @return None -#------------------------------------------------ -sub waitForSimicsPrompt -{ - my ( $self ) = @_; - - simics_cmd($self,"echo"); -} - -#------------------------------------------------ -# @fn waitForRunningPrompt -# -# @brief Helper function, returns when "running>" is seen -# -# @return None -#------------------------------------------------ -sub waitForRunningPrompt -{ - my ( $self ) = @_; - - simics_cmd_w_timeout_w_running($self,10,"echo"); -} - -#------------------------------------------------ -# @fn getSimicsTime -# -# @brief Helper function -# -# @return None -#------------------------------------------------ -sub getSimicsTime -{ - my ( $self ) = @_; - - simics_cmd($self,"print-time"); - simics_cmd($self,"print-time -t"); -} - -#------------------------------------------------ -# @fn dumpOccStackTrace -# -# @brief Helper function -# -# @return None -#------------------------------------------------ -sub dumpOccStackTrace -{ - my ( $self ) = @_; - - simics_cmd($self,"stack-trace"); -} - -#------------------------------------------------ -# @fn interact -# -# @brief Swithes to interactive mode so that user can -# interact directly with simics, when script wants -# that to happen -# -# @return rc - Return code of expect operation -#------------------------------------------------ -sub interact -{ - my ( $self ) = @_; - - waitForSimicsPrompt($self); - waitForSimicsPrompt($self); - waitForSimicsPrompt($self); - waitForSimicsPrompt($self); - waitForSimicsPrompt($self); - waitForSimicsPrompt($self); - waitForSimicsPrompt($self); - waitForSimicsPrompt($self); - waitForSimicsPrompt($self); - - print "Switching to Interactive Mode: Type \"END\" and hit \"<Return>\" twice to return to script\n\n"; - - $self->{expect_obj}->interact(\*STDIN, "END"); - - return $self->{last_rc}; -} - -#------------------------------------------------ -# @fn setOccVariable -# -# @brief Sets variable abstracting weird simics syntax -# -# @param var - String with variable name -# @param value - Value to write to variable -# -# @return None -#------------------------------------------------ -sub setOccVariable -{ - my ( $self, $var, $value ) = @_; - - simics_cmd($self,"set (sym \"&$var\") $value (sym \"sizeof($var)\")"); -} - -#------------------------------------------------ -# @fn getOccVariable -# -# @brief Gets variable abstracting weird simics syntax -# -# @param var - String with variable name -# -# @return None -#------------------------------------------------ -sub getOccVariable -{ - my ( $self, $var) = @_; - - simics_cmd($self,"psym \"$var\""); -} - - - -############################################################################## -#----------------------------------------------------------------------------- -# -# OCC Simics Execution -# -#----------------------------------------------------------------------------- -############################################################################## - -#------------------------------------------------ -# @fn startAndRunOccUntilMain -# -# @brief Automates all steps needed to reach OCC -# application code main(), then stops on -# breakpoint there. -# -# @return None -#------------------------------------------------ -sub startAndRunOccUntilMain -{ - my ( $self ) = @_; - - start_simics($self); - runOccSimicsInitCmds($self); - runOccSimicsTraceInitCmds($self); - setOccBreakpointOnFunction($self,"main"); - runOccToBreakpoint($self); - deleteOccBreakpoints($self); - getSimicsTime($self); -} - -#------------------------------------------------ -# @fn startAndRunOccUntilSsxBoot -# -# @brief Automates all steps needed to reach SSX -# entry point __ssx_boot(), then stops on -# breakpoint there. -# -# @return None -#------------------------------------------------ -sub startAndRunOccUntilSsxBoot -{ - my ( $self ) = @_; - - start_simics($self); - runOccSimicsInitCmds($self); - runOccSimicsTraceInitCmds($self); - setOccBreakpointOnFunction($self,"__ssx_boot"); - runOccToBreakpoint($self); - deleteOccBreakpoints($self); - getSimicsTime($self); -} - - -#------------------------------------------------ -# @fn runOccSimicsInitCmds -# -# @brief Runs batch of simics commands to init OCC -# Simics Environment -# -# @return None -#------------------------------------------------ -sub runOccSimicsInitCmds -{ - my ( $self ) = @_; - - foreach(@G_occ_start_cmds) - { - simics_cmd($self,$_); - } -} - -#------------------------------------------------ -# @fn setOccBreakpointOnFunction -# -# @brief Sets breakpoint -# -# @param func - String with name of function to break on -# -# @return None -#------------------------------------------------ -sub setOccBreakpointOnFunction -{ - my ( $self, $func ) = @_; - - simics_cmd($self,"break (sym $func)"); -} - -#------------------------------------------------ -# @fn setOccBreakpointOnWriteToVariable -# -# @brief Sets breakpoint -# -# @param var - String with name of variable to break on -# when it is written to -# -# @return None -#------------------------------------------------ -sub setOccBreakpointOnWriteToVariable -{ - my ( $self, $var ) = @_; - - setOccBreakpointOnAddressWrite($self,"(sym \"&$var\")"); -} - -#------------------------------------------------ -# @fn setOccBreakpointOnCycles -# -# @brief Sets breakpoint -# -# @param num_cycles - Number of cycles until now that -# simics will run until it breaks. -# -# @return None -#------------------------------------------------ -sub setOccBreakpointOnCycles -{ - my ( $self, $num_cycles ) = @_; - - simics_cmd($self,"OccComplex.OccSimpleSlot.cpu.cycle-break $num_cycles"); -} - -#------------------------------------------------ -# @fn setOccBreakpointOnSource -# -# @brief Sets breakpoint -# -# @param file - Filename that breakpoint is in -# @param line - Line in filename that breakpoint is on -# -# @return None -#------------------------------------------------ -sub setOccBreakpointOnSource -{ - my ( $self, $file, $line ) = @_; - - simics_cmd($self,"break -x (pos $file:$line)"); -} - -#------------------------------------------------ -# @fn setOccBreakpointOnAddress -# -# @brief Sets breakpoint -# -# @param hex_addr - "0x"-prefixed string with address -# to break on when accessed as read, -# write, or executed (see $flags) -# @param flags - String; can be -r, -w, -x. -x is default -# -# @return None -#------------------------------------------------ -sub setOccBreakpointOnAddress -{ - # flags can be -r, -w, -x. -x is default - my ( $self, $hex_addr, $flags ) = @_; - - simics_cmd($self,"break $hex_addr $flags"); -} - -#------------------------------------------------ -# @fn setOccBreakpointOnAddressExecute -# -# @brief Sets breakpoint -# -# @param hex_addr - "0x"-prefixed string with address -# to break on when accessed as execute, -# -# @return None -#------------------------------------------------ -sub setOccBreakpointOnAddressExecute -{ - my ( $self, $hex_addr) = @_; - - setOccBreakpointOnAddress($self, $hex_addr, "-x"); -} - -#------------------------------------------------ -# @fn setOccBreakpointOnAddressWrite -# -# @brief Sets breakpoint -# -# @param hex_addr - "0x"-prefixed string with address -# to break on when accessed as write, -# -# @return None -#------------------------------------------------ -sub setOccBreakpointOnAddressWrite -{ - my ( $self, $hex_addr) = @_; - - setOccBreakpointOnAddress($self, $hex_addr, "-w"); -} - -#------------------------------------------------ -# @fn runOccToBreakpoint -# -# @brief Runs simics until breakpoint is set, or -# timeout (60 seconds) is reached. -# -# @return None -#------------------------------------------------ -sub runOccToBreakpoint -{ - my ( $self ) = @_; - - simics_cmd_w_timeout_w_running($self,60,"r"); - waitForSimicsPrompt($self); -} - -#------------------------------------------------ -# @fn deleteOccBreakpoints -# -# @brief Deletes all breakpoints -# -# @return None -#------------------------------------------------ -sub deleteOccBreakpoints -{ - my ( $self ) = @_; - - simics_cmd($self,"delete -all"); -} - - -#------------------------------------------------ -# @fn runOccForTimeInterval -# -# @brief Runs OCC for time interval of x ms -# -# @param time_in_ms - Time in ms that simics should run -# before stopping. -# -# @return None -#------------------------------------------------ -sub runOccForTimeInterval -{ - my ( $self, $time_in_ms ) = @_; - - # x = 150016 cycles ~= 250us; - # x * 40 = 10ms - - my $ms_per_loop = 10; - my $cyc_per_ms = $self->{cyc_per_ms}; - my $cyc_per_loop = $cyc_per_ms * 10; - - my $loops = int($time_in_ms / $ms_per_loop); - my $cyc_in_last_loop = ($time_in_ms % $ms_per_loop) * $cyc_per_ms; - - for (my $f=0; $f<$loops; $f++) - { - setOccBreakpointOnCycles($self,$cyc_per_loop); - runOccToBreakpoint($self); - } - - setOccBreakpointOnCycles($self,$cyc_in_last_loop); - runOccToBreakpoint($self); -} - - -############################################################################## -#----------------------------------------------------------------------------- -# -# OCC Simics Instruction Trace -# -#----------------------------------------------------------------------------- -############################################################################## - -#------------------------------------------------ -# @fn runOccSimicsTraceInitCmds -# -# @brief Initializes Simics and filesyste to grab -# OCC instruction trace -# -# @return None -#------------------------------------------------ -sub runOccSimicsTraceInitCmds -{ - my ( $self ) = @_; - - $self->{temp_file1} = "/tmp/temp_a".time().".txt"; - $self->{temp_file2} = "/tmp/temp_b".time().".txt"; - - if ( -e $self->{instr_file} ) - { - system("rm ".$self->{instr_file}.""); - } - system("touch ".$self->{instr_file}.""); - - system("touch ".$self->{trace_file}.""); - system("cat /dev/null >| ".$self->{trace_file}.""); - - - foreach(@G_trace_start_cmds) - { - simics_cmd($self,$_); - } -} - -#------------------------------------------------ -# @fn startOccSimicsTrace -# -# @brief Starts the simics instruction trace -# -# @return None -#------------------------------------------------ -sub startOccSimicsTrace -{ - my ( $self ) = @_; - - simics_cmd($self,"trace0.start ".$self->{trace_file}.""); - simics_cmd($self,"!touch ".$self->{trace_file}.""); -} - -#------------------------------------------------ -# @fn stopOccSimicsTrace -# -# @brief Stops the simics instruction trace and -# verifies file exists before returning. -# -# @return None -#------------------------------------------------ -sub stopOccSimicsTrace -{ - my ( $self ) = @_; - - # Stop the trace - simics_cmd_w_timeout($self,200,"trace0.stop"); - - # Flush the filesystem (not sure this actually does anything useful) - simics_cmd($self,"!sync"); - - # Used to see an issue where the file wouldn't get updated in GSA between - # the simics pool system and the sandbox pool system, so this is a check - # making sure the file update occurs - if( (-z $ENV{"sb"}."/../simics/".$self->{trace_file}."") ){print "..";sleep(5);} - if( (-z $ENV{"sb"}."/../simics/".$self->{trace_file}."") ){print "..";sleep(5);} - if( (-z $ENV{"sb"}."/../simics/".$self->{trace_file}."") ){print "..";sleep(5);} - if( (-z $ENV{"sb"}."/../simics/".$self->{trace_file}."") ){print "..";sleep(5);} - if( (-z $ENV{"sb"}."/../simics/".$self->{trace_file}."") ){print "..";sleep(5);} - if( (-z $ENV{"sb"}."/../simics/".$self->{trace_file}."") ){print "..";sleep(5);} - if( (-z $ENV{"sb"}."/../simics/".$self->{trace_file}."") ){system("sync"); DEBUG($self,1,"ERROR: Don't see trace file ".$ENV{"sb"}."/../simics/".$self->{trace_file}."");} -} - - -#------------------------------------------------ -# @fn parseOccSimicsTraceFile -# -# @brief Parses the simics instruction trace and -# prepares files for another pass. -# -# @return None -#------------------------------------------------ -sub parseOccSimicsTraceFile -{ - my ( $self ) = @_; - - my $trace_file = $self->{trace_file}; - DEBUG($self,1,"Lines in Trace file: "); - system("wc -l \$sb/../simics/$trace_file"); - - DEBUG($self,1,"Get instructions\n"); - system("strings \$sb/../simics/$trace_file | head -n 2"); - - # Simics sometimes dumps some garbage into the trace file, so need to pass it through - # strings first. - system("\\strings \$sb/../simics/$trace_file | \\grep inst | \\grep -ho \"p:0x........\" | \\grep -ho \"........\$\" | sort | uniq > ".$self->{temp_file1}.""); - - system("cat ".$self->{instr_file}." ".$self->{temp_file1}." | sort | uniq > ".$self->{temp_file2}.""); - system("mv ".$self->{temp_file2}." ".$self->{instr_file}.""); - - DEBUG($self,1,"Emptying Trace files to save space\n"); - DEBUG($self,1,"Lines in Inst file: "); - system("wc -l ".$self->{instr_file}.""); - system("LINES=`wc -l \$sb/../simics/$trace_file | cut -d\" \" -f1`; if [ \"\$LINES\" -lt 3 ]; then mv \$sb/../simics/$trace_file /tmp/failure__t_ccov_".int(rand(1000)).".txt; fi"); - system("LINES=`wc -l ".$self->{instr_file}." | cut -d\" \" -f1`; if [ \"\$LINES\" -eq 0 ]; then mv \$sb/../simics/$trace_file /tmp/failure_ccov_".int(rand(1000)).".txt; fi"); - #if( (-z $ENV{"sb"}."/../simics/".$self->{instr_file}."") ){system("mv $self->{instr_file} /tmp/failure_ccov.txt"); die "Instruction File Empty!!!\n";} - - system("echo \"\" > \$sb/../simics/$trace_file"); - system("echo \"\" > ".$self->{temp_file1}.""); -} - - -#------------------------------------------------ -# @fn runOccWithInstructionTrace -# -# @brief Runs simics w/ instruction trace, parses instructions -# out of trace file, and appends to overall instruction -# trace. -# -# @param time_in_ms - Time in ms that simics should -# execute OCC and grab the instruction -# trace. -# -# @return None -#------------------------------------------------ -sub runOccWithInstructionTrace -{ - my ( $self, $time_in_ms ) = @_; - - # x = 150016 cycles ~= 250us; - # x * 40 = 10ms - - my $ms_per_loop = 10; - my $cyc_per_ms = $self->{cyc_per_ms}; - my $cyc_per_loop = $cyc_per_ms * 10; - - my $loops = int($time_in_ms / $ms_per_loop); - my $cyc_in_last_loop = ($time_in_ms % $ms_per_loop) * $cyc_per_ms; - - #WORKAROUND: First Loop (10 cycles for workaround) - startOccSimicsTrace($self); - setOccBreakpointOnCycles($self,10); - runOccToBreakpoint($self); - stopOccSimicsTrace($self); - parseOccSimicsTraceFile($self); - - for (my $f=0; $f<$loops; $f++) - { - startOccSimicsTrace($self); - setOccBreakpointOnCycles($self,$cyc_per_loop); - runOccToBreakpoint($self); - stopOccSimicsTrace($self); - parseOccSimicsTraceFile($self); - } - - #Last Loop - startOccSimicsTrace($self); - setOccBreakpointOnCycles($self,$cyc_in_last_loop); - runOccToBreakpoint($self); - stopOccSimicsTrace($self); - parseOccSimicsTraceFile($self); -} - - -############################################################################## -#----------------------------------------------------------------------------- -# -# End of Package -# -#----------------------------------------------------------------------------- -############################################################################## - -1; - -############################################################################## -#----------------------------------------------------------------------------- -# -# End of File -# -#----------------------------------------------------------------------------- -############################################################################## - diff --git a/src/occ/tools/cpPluginFiles.pl b/src/occ/tools/cpPluginFiles.pl deleted file mode 100755 index 2f24c28..0000000 --- a/src/occ/tools/cpPluginFiles.pl +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/perl - -# This is a utility to generate tmgtSrcParse.C automatically. -# It will searching backing build if file is not present in the sandbox. - -use strict; -use File::Find (); -use Time::localtime; - - -#use re 'debug'; -my $VERSION = 1.0; - - -sub usage() { - print "Usage: $0 -o output directory \n"; - print "\n"; - print "-o: Used as the output directory where plugins files are dropped\n"; - print "\n\n"; - exit 1; -} - - -# Locals -my $base = $ENV{PWD}; -my $baseBB = $ENV{PWD}; -my $output; -my $arg; -my %Comps; -my $ignore = 1; -my $fips_comp_id = "$ENV{bs}/fstp/fsp/fips_comp_id.H"; -#occ/incl/comp_ids.h -my $wordn = "userdata"; -my $wordnd = 0; -my $Errno = 0; -my $NA = 1; - -while ($ARGV = shift) -{ - if ( $ARGV =~ m/-o/i ) - { - $output = shift; - } -} - -if ( $output eq "" ) -{ - print "Please specify an output directory\n\n"; - usage(); -} -# Hardcode just the values that occc needs -$base="$ENV{SANDBOXBASE}/src/occc/405/"; -#$baseBB="$ENV{bb}/src/occc/405/"; -#$baseBB="/afs/austin.ibm.com/projects/esw/occ810/Builds/occ810_130926a/src/occc/405/"; -$baseBB="$ENV{BACKED_SANDBOXDIR}"; -my @values = split(':', $baseBB); -foreach my $val (@values) -{ - if ( $val =~ m/occ810/) - { - $baseBB=$val; - } - } -#we should not input -d option, let $ignore = 1; #so compile won't fail if there are dups -$wordnd = 4; #look at userdata4 -$wordn .= $wordnd; -#$NA = 0; -my $IgnoreDir = "ssx"; - -# grab all the files we want to copy -# *_service_codes.h, occSrcParse.C, comp_ids.h -my $IncludeFiles=`find $base -type f -name \"comp_ids.h\" -or -name \"*_service_codes.h\" -or -name \"*SrcParse.C"`; -my @IncludeFilesArray= split("\n", $IncludeFiles); -foreach my $val (@IncludeFilesArray) -{ - print "cp $val $output\n"; - system "cp $val $output\n"; -} diff --git a/src/occ/tools/fsp_trace_parse.pl b/src/occ/tools/fsp_trace_parse.pl deleted file mode 100755 index 72c2f82..0000000 --- a/src/occ/tools/fsp_trace_parse.pl +++ /dev/null @@ -1,73 +0,0 @@ -#!/usr/bin/perl -# -# This file is used by the trace.simics script to format an OCC trace. It pulls -# data out of the memory of the simics session, packs it into hex, outputs as a -# file and then runs fsp-trace. -# -# FUTURE IMPROVEMENTS -# 1. -# -# - -my $filename = "/tmp/occ_output_trace_data.txt"; -my $fsp_trace_loc = "fsp-trace"; -my $data; - -while (defined($line = <STDIN>)) -{ - chomp $line; - - # Initial format is p:0xfffc30b0 0000 0000 0000 0000 0000 0000 0000 0000 ................ - # and we just want to keep the hex digits - $line =~ /^p:\S+\s\s+(\S+.*)\s\s/; - my $hex_string = $1; - - #print "$line ---> $hex_string\n"; - # Split it up into 2 byte segments - my @array = split(/\s+/, $hex_string); - - # And pack as hex - foreach $entry (@array) - { - $data .= pack('H4', $entry); - } -} - -# Output toa file -open(FILEHANDLE, ">$filename"); -print FILEHANDLE $data; -close(FILEHANDLE); - - -# Format the trace -open(TRAC, "fsp-trace -s trexStringFile $filename |") || die "Failed: $!\n"; -while( <TRAC> ) -{ - my $line = $_; - chomp $line; - - # Find the timestamp. Example: 0015543.977001 - if($line =~ /^(\d+\.\d+)\|/) - { - $num = $1; - - $text = sprintf("%014f", $num / 3.6); - #print $text . " "; - - $line =~ s/^(\d+\.\d+)\|/$text\|/; - } - - - if($line =~ /Can't open device 2/) - { - # get rid of stupid warning message - } - else - { - print $line . "\n"; - } -} -close(TRAC); - -# And delete the file -#unlink($filename); diff --git a/src/occ/tools/hocct.pl b/src/occ/tools/hocct.pl deleted file mode 100755 index ff30a43..0000000 --- a/src/occ/tools/hocct.pl +++ /dev/null @@ -1,739 +0,0 @@ -#!/usr/bin/perl -# -# Homemade OCC Code Coverage Tool (HOCCT) -# -# Written by: Timothy Hallett (tghallett@us.ibm.com) -# Date: 11/17/2011 -# Purpose: To determine code coverage by parsing OCC Simics Execution Trace -# and comparing it to OCC objdump source code output. -# -# Updates: 11/28/2011 - Automatic dump of source/assembler within sandbox -# - Handle CLI args better (flags instead of static) -# - Added ability to interleave source code into ccov -# output files, with variable parameters for number -# of lines of source context. -# 11/29/2011 - Added ability to use simics (via OccSimincsAutomate -# package) to generate the execution/instruction trace -# 11/30/2011 - Modified Help to give useful information. -# Added timing of simics & viewer for source-interleave dump -# Added autobuild of occ.out & image.bin if they are not -# present in the sandbox. -# 01/17/2012 - Check for zero instructions run (and helpful error) -# 01/20/2012 - Updated tool for multi-user/system use (unique instructions.txt filename) -# Updated tool to start code coverage from __ssx_boot() instead of main() -# -# Usage: hocct.pl [args] -# -# Output File will be dumped to: /tmp/occ_source_dump.ccov.txt -# -# It will contain ":::::" at the start of lines that have been -# executed in the simics trace that was grabbed. -# -# It is receommeded that if a user wants a graphical view of the -# code coverage, they use the following command: -# gvimdiff /tmp/occ_source_dump.txt /tmp/occ_source_dump.ccov.txt -# -# Ideas: - When opening in Gvim, could eaily convert to HTML (:TOhtml), save -# and then have a visual representation of the changes. -# - If it is in HTML, might as well make the hyperlinks actually -# link to the file...somehow... -# - Of course, 1 & 1a are moot if you are well versed at GVIM and use -# that as the diff tool. If that is the case, then you can just use -# the gF command to go directly to the source & line number you have -# under the cursor. -# -# Todo: 11/30/2011 - Have arg that allows folders to be skipped for counting -# code coverage, or for source-interleave tool. -# 11/30/2011 - Create a sandbox and enter it, check out files, compile, -# start simics, etc. Easy to do, hard to do correctly... -# ...i.e. ask user for backing build/svn revs? etc... -# 12/01/2011 - Could probably easily allow user to pass in command file to -# run while getting trace... -# 01/20/2012 - Code coverage on applet space? Complex, Would need to break on applet -# start & end, and keep track of which applet ran. - -use strict; -use File::Basename; - -# First email in the list is the primary contact -my @G_contact_emails = ("tghallett\@us.ibm.com","someone_else\@us.ibm.com"); -my $G_primary_contact = @G_contact_emails[0]; -my $VERSION = "0.1.0"; - -# Will be using following env vars -# $ENV{"sb"} -# $ENV{"MCP_PATH"} -# $ENV{"MCP_VER"} -# $ENV{"SANDBOX"} -# $ENV{"USER"} -# - -# Global variables modified by CLI args -my $G_instructions_file = ""; -my $G_source_dump_file = ""; -my $G_diff_prog = ""; -my $G_viewer = ""; -my $G_objdump_args = "-d -l"; -my $G_debug_lvl = 0; -my $G_interleave_source = 0; -my $G_num_src_lines_context = 5; -my $G_num_src_lines_before = 0; -my $G_date = "occ"; -my $G_ccov_time_in_ms = 25; - -#Global variables that are internal only -my $G_inst_counter = 0; -my $G_source_counter = 0; -my @G_func_list_from_source; -my @G_func_executed; - -# For debug statistics -my $G_time_started = 0; -my $G_time_compare_started = 0; -my $G_time_compare_ended = 0; -my $G_time_simics_started = 0; -my $G_time_simics_ended = 0; -my $G_time_interleave_started = 0; -my $G_time_interleave_ended = 0; - -#------------------------------------------------ -# Parse Arguments -#------------------------------------------------ -@ARGV = ('-') unless @ARGV; -#Available -: __c__fg____lmnopqr__u_wxyz1234567890 -#Available +: abcdefghijklmnopqrstuvwxyz1234567890 - -while ($ARGV = shift) -{ - if ($ARGV =~ m%^-i%i) - { - $G_instructions_file = shift; - } - elsif ($ARGV =~ m%^-s%i) - { - $G_source_dump_file = shift; - } - elsif ($ARGV =~ m%^-d%i) - { - # External Diff program - $G_diff_prog = shift; - } - elsif ($ARGV =~ m%^-w%i) - { - # External EDITOR program - $G_viewer = shift; - } - elsif ($ARGV =~ m%^-v%i) - { - # Makes use of DEBUG subroutine to spit out debug into - $G_debug_lvl = shift; - } - elsif ($ARGV =~ m%^-j%i) - { - # Don't play with this unless you know what you are doing - $G_objdump_args = shift; - } - elsif ($ARGV =~ m%^-t%i) - { - # Don't play with this unless you know what you are doing - $G_ccov_time_in_ms = shift; - } - elsif ($ARGV =~ m%^-e%i) - { - # Create ccov src interleaved output file - if($G_interleave_source == 0){$G_interleave_source = 1;} - } - elsif ($ARGV =~ m%^-k%i) - { - # Hide executed assembly from ccov src interleaved output file - $G_interleave_source = 2; - } - elsif ($ARGV =~ m%^-a%i) - { - # Number of src lines after current in ccov src interleaved output file - $G_num_src_lines_context = shift; - } - elsif ($ARGV =~ m%^-b%i) - { - # Number of src lines before current in ccov src interleaved output file - $G_num_src_lines_before = shift; - } - elsif ($ARGV =~ m%^-u%i) - { - # Create unique filenames each run (appends date/time) - $G_date = ""; - } - elsif ($ARGV =~ m%^-h%i) - { - dump_help(); - exit 0; - } - else - { - dump_help(); - exit 0; - } -} - -#------------------------------------------------ -# Check for all required arguments -#------------------------------------------------ -if(0) -{ - # No arguments required at this time. -} - - -#------------------------------------------------ -# For now, lets die if we aren't in a sandbox -#------------------------------------------------ -if( !defined($ENV{"sb"}) ){die "This script needs to run in an ODE sandbox!\n";} - -#------------------------------------------------ -# Get all Date/Time info for use later in script -#------------------------------------------------ -my ($second, $minute, $hour, $dayOfMonth, $monthOffset, $yearOffset, $dayOfWeek, $dayOfYear, $daylightSavings) = localtime(); -my $year = 1900 + $yearOffset; -my $month = 1 + $monthOffset; -my $day = $dayOfMonth; -my $yyyymmdd = sprintf("%04d%02d%02d",$year,$month,$day); -my $hhmmss = sprintf("%02d%02d%02d",$hour,$minute,$second); - -if(!($G_date)) -{ - $G_date = "".$yyyymmdd."_".$hhmmss.""; -} -$G_time_started = time(); - -#------------------------------------------------ -# Run commands to generate binaries if needed -#------------------------------------------------ -if( !(-e "".$ENV{"sb"}."/occ/occ.out") ) -{ - system("pushd \$sb; make clean && make; popd"); - - if( !(-e "".$ENV{"sb"}."/occ/occ.out") ){die "No \$sb/occ/occ.out to run objdump against!";} -} - -if( !(-e "".$ENV{"sb"}."/image.bin") ) -{ - system("pushd \$sb; make combineImage; popd"); - - if( !(-e "".$ENV{"sb"}."/image.bin") ){die "No \$sb/image.bin to run simics with!";} -} - -#------------------------------------------------ -# Run commands to generate objdump file if needed -#------------------------------------------------ -if(!($G_source_dump_file)) -{ - my $objdump_args = $G_objdump_args; - my $elf_file = "".$ENV{"sb"}."/occ/occ.out"; - my $output_file = "/tmp/occ_source_".$ENV{"USER"}."_".$ENV{"SANDBOX"}."_".$G_date.""; - $G_source_dump_file = $output_file; - - my $temp_elf = "/tmp/occ.out.".$ENV{"USER"}.""; - - system("cp $elf_file $temp_elf"); - - print "Generating Source/Assembler Dump File: $G_source_dump_file\n"; - system("".$ENV{"MCP_PATH"}."/opt/mcp/bin/ppcnf-".$ENV{"MCP_VER"}."-objdump ".$objdump_args." ".$temp_elf." > ".$output_file.""); - - system("ls -lrth $output_file"); - - system("rm $temp_elf"); -} - - -#------------------------------------------------ -# Run simics to generate instruction trace file if needed -#------------------------------------------------ -$G_time_simics_started = time(); -if(!($G_instructions_file)) -{ - print "Generating OCC Instruction Trace via Simics:\n"; - sleep(1); - - use lib "/afs/rch/usr4/thallet/public/bin/"; - use OccSimicsAutomate; - - $G_instructions_file = "/tmp/instructions_".$ENV{"USER"}."_".$ENV{"SANDBOX"}."_".$G_date.".txt"; - - my $simics = new OccSimicsAutomate; - $OccSimicsAutomate::DEBUG_LEVEL = 1; - - $simics->{instr_file} = $G_instructions_file; - $simics->startAndRunOccUntilSsxBoot(); - - $simics->runOccWithInstructionTrace($G_ccov_time_in_ms); - - $simics->close(); -} -$G_time_simics_ended = time(); - - -#------------------------------------------------ -# Open Files -#------------------------------------------------ -open(INST,"<$G_instructions_file"); -open(SOURCE,"<$G_source_dump_file"); -open(CCOV,">$G_source_dump_file.ccov.txt"); - - -#------------------------------------------------------------------- -# Compare Instructions to Source; Create new file with Coverage Info -#------------------------------------------------------------------- -$G_time_compare_started = time(); - -while (<INST>) -{ - my $str = $_; - chomp($str); - - DEBUG(2,"Searching for $str\n"); - if( !($_ =~ /^fff/)){DEBUG(1,"Invalid instruction address: $str\n"); next;} #should check to make sure address makes sense - - while(<SOURCE>) - { - # Only increment source line count if address starts the line. - if($_ =~ /^fff/){$G_source_counter++} - - # If this line contains a function call, add it to list. - if($_ =~ /(^fff..... <)(.*)(>:)/){push(@G_func_list_from_source,$2);} - - # See if this source line matches the instruction - if($_ =~ /^$str/) - { - # Print to the screen when we see we covered a function call - # but don't leave while look, because there will be another - # instruction with this same address - if($_ =~ /(^fff..... <)(.*)(>:)/){push(@G_func_executed,$2); DEBUG(0,"Executed Function: $2\n");print CCOV ":::::$_";} - else - { - $G_inst_counter++; # Found instruction that matches - print CCOV ":::::$_"; - - last; - } - } - else - { - print CCOV $_; - } - if(eof(SOURCE)){print "Couldn't find instruction @ $str!!!\n";} - } -} - -#------------------------------------------------ -# Finish dumping rest of source file -#------------------------------------------------ -while(<SOURCE>) -{ - print CCOV $_; -} - - -#------------------------------------------------ -# Compare list of functions (executed v. source) -#------------------------------------------------ -foreach (@G_func_executed) -{ - my $func = $_; - - # This must be set to zero before the following foreach - # loop runs. It is used as the index to the array. - my $idx = 0; - - # Loops through function list in source, looking for - # match to an executed function. - foreach(@G_func_list_from_source) - { - $idx++; - - # If funtion matches... - if($_ =~ /$func/) - { - #print "Removing $func Idx: ".($idx-1)."\n"; - - # Remove element from this array - splice(@G_func_list_from_source,$idx-1,1); - - # Leave for loop - last; - } - } -} - -foreach(@G_func_list_from_source) -{ - DEBUG(0,"Didn't Execute Function: $_\n"); -} - - -#------------------------------------------------ -# Print Results to screen -#------------------------------------------------ -if($G_source_counter) -{ - printf("Code Coverage: %2.1f % (%d of %d instructions executed)\n",($G_inst_counter/$G_source_counter)*100,$G_inst_counter,$G_source_counter); - print "\nDumped executed code coverage file into ccov output file: $G_source_dump_file.ccov.txt\n\n"; -} -else -{ - die "No instructions were executed, exiting script without continuing processing\n"; -} - - -#------------------------------------------------ -# Cleanup -#------------------------------------------------ -close(SOURCE); -close(CCOV); -close(INST); - -$G_time_compare_ended = time(); - - -#------------------------------------------------ -# Do a diff if requested -#------------------------------------------------ -if($G_diff_prog) -{ - system("$G_diff_prog $G_source_dump_file $G_source_dump_file.ccov.txt"); -} - - -#------------------------------------------------ -# Do a source dump info ccov file if requested -#------------------------------------------------ -$G_time_interleave_started = time(); -if($G_interleave_source) -{ - print "Dumping source code into ccov output file: $G_source_dump_file.ccov_src.txt\n"; - - open(CCOV,"<$G_source_dump_file.ccov.txt"); - open(SRCCOV,">$G_source_dump_file.ccov_src.txt"); - - my $last_file = ""; - my $last_dir = ""; - my $last_line_num = 0; - my $l_new_file = 0; - - while(<CCOV>) - { - # Grab file/line num every time - if($_ =~ /(^\/gsa\/.*)(:)([0-9]*$)/) - { - if($l_new_file == 0){print SRCCOV "\n\n"}; - $last_file = $1; - $last_line_num = $3; - $l_new_file = 1; - DEBUG(1,"Source File: $last_file, Line: $last_line_num\n"); - my ($f, $d) = fileparse($last_file); - $last_dir = $d; - DEBUG(4,"Basename: $last_dir\n"); - if(2 == $G_interleave_source){next;} - } - elsif ($_ =~ /(^\..*\/.*\.[chS])(:)([0-9]*$)/) - { - if($l_new_file == 0){print SRCCOV "\n\n"}; - $last_file = $last_dir.$1; - if ( !(-e $last_file)){$last_file = $ENV{"sb"}."/occ/".$1;} - if ( !(-e $last_file)){$last_file = $ENV{"sb"}."/ssx/".$1;} - if ( !(-e $last_file)){$last_file = $ENV{"sb"}."/ssx/ppc405/".$1;} - $last_line_num = $3; - $l_new_file = 1; - DEBUG(1,"Source File: $last_file, Line: $last_line_num\n"); - if(2 == $G_interleave_source){next;} - } - elsif ($_ =~ /(^[a-zA-Z]*\/.*\.[chS])(:)([0-9]*$)/) - { - if($l_new_file == 0){print SRCCOV "\n\n"}; - $last_file = $ENV{"sb"}."/occ/".$1; - $last_line_num = $3; - $l_new_file = 1; - DEBUG(1,"Source File: $last_file, Line: $last_line_num\n"); - if(2 == $G_interleave_source){next;} - } - - # If line starts with fff, it is instruction that didn't get executed - if($_ =~ /^fff/) - { - if($l_new_file) - { - $l_new_file = 0; - open(READ,"<$last_file"); - my @src_lines = <READ>; - - print SRCCOV "-----------------------------------------------------------------------------\n"; - print SRCCOV "$last_file:$last_line_num\n"; - print SRCCOV "-----------------------------------------------------------------------------\n"; - - print SRCCOV "\n"; - print SRCCOV "Source:\n"; - print SRCCOV "------------------------------\n"; - for(my $f=($G_num_src_lines_before*-1); $f<$G_num_src_lines_context; $f++) - { - if($last_line_num+$f > 0) - { - print SRCCOV "".($last_line_num+$f).":\t".@src_lines[($last_line_num+$f-1)]; - } - } - print SRCCOV "\n"; - print SRCCOV "Assembly:\n"; - print SRCCOV "------------------------------\n"; - - close(READ); - } - print SRCCOV $_; - } - else - { - if(2 == $G_interleave_source) - { - if( !($_ =~ /^:::::/) ) - { - print SRCCOV $_; - } - } - else - { - print SRCCOV $_; - } - } - - - } - - close(CCOV); - close(SRCCOV); - - #------------------------------------------------ - # Open file for viewing if requested - #------------------------------------------------ - if($G_viewer) - { - system("$G_viewer $G_source_dump_file.ccov_src.txt"); - } -} -$G_time_interleave_ended = time(); - - - - - -#------------------------------------------------ -# Dump some Stats if in Debug -#------------------------------------------------ -if($G_debug_lvl > 0) -{ - my $fs1 = -s "$G_instructions_file"; - my $fs2 = -s "$G_source_dump_file"; - my $fs3 = -s "$G_source_dump_file.ccov.txt"; - my $fs4 = -s "$G_source_dump_file.ccov_src.txt"; - - my $script_time = time() - $G_time_started; - my $mDiff = int($script_time / 60); - my $sDiff = sprintf("%02d", $script_time - 60 * $mDiff); - - $script_time = $G_time_compare_ended - $G_time_compare_started; - my $cmDiff = int($script_time / 60); - my $csDiff = sprintf("%02d", $script_time - 60 * $cmDiff); - - $script_time = $G_time_simics_ended - $G_time_simics_started; - my $smDiff = int($script_time / 60); - my $ssDiff = sprintf("%02d", $script_time - 60 * $smDiff); - - $script_time = $G_time_interleave_ended - $G_time_interleave_started; - my $imDiff = int($script_time / 60); - my $isDiff = sprintf("%02d", $script_time - 60 * $imDiff); - - printf("Total Time (mm:ss) = %02d\:%02d\n",$mDiff,$sDiff); - printf(" - Simics (mm:ss) = %02d\:%02d\n",$smDiff,$ssDiff); - printf(" - Compare (mm:ss) = %02d\:%02d\n",$cmDiff,$csDiff); - printf(" - Interleave (mm:ss) = %02d\:%02d\n",$imDiff,$isDiff); - print "\n"; - print "File Sizes:\n"; - printf(" - $G_instructions_file: %.2f kB\n",($fs1/1024)); - printf(" - $G_source_dump_file: %.2f kB\n",($fs2/1024)); - printf(" - $G_source_dump_file.ccov.txt: %.2f kB\n",($fs3/1024)); - printf(" - $G_source_dump_file.ccov_src.txt: %.2f kB\n",($fs4/1024)); - print "\n"; -} - - - - - -exit 0; -#------------------------------------------------ -# End of Program -#------------------------------------------------ - - - - - - - - - -############################################################################## -############################################################################## -# -# Subroutines -# -############################################################################## -############################################################################## - -#Simics command reference -# - -# -sub DEBUG -{ - my ($lvl,$str) = @_; - if($lvl <= $G_debug_lvl) - { - print $str; - } -} - - -############################################################################## -############################################################################## -# -# Help Dump -# -############################################################################## -############################################################################## -sub dump_help() -{ - my $name = "hocct.pl"; - - print "\n"; - print "Usage: $name [options]\n"; - print "\n"; - print "Version: $VERSION\n\n"; - - print "Usage Notes:\n"; - print " - Must be run from sandbox unless both [-s] and [-i] args are passed in\n"; - print " - Output File(s) will be dumped to *.ccov.txt and or *.ccov_src.txt\n"; - print " - Ccov file will contain \":::::\" at the start of lines that have been\n"; - print " executed in the simics instruction trace that was used.\n"; - - print "\n"; - - print "Options:\n"; - print "\t[-i <file>] Use <file> as instruction trace instead of generating one.\n"; - print "\t[-s <file>] Use <file> as source dump file instead of generating one.\n"; - print "\t[-d <program>] Use <program> as diff viewer, and view diff of source dump\n"; - print "\t and Code Coverage modified source dump.\n"; - print "\t[-w <program>] Use <program as viewer, and view source-interleaved-code-coverage\n"; - print "\t output file.\n"; - print "\t[-v <lvl>] Set verbose to debug level <lvl>\n"; - print "\t[-t <time(ms)>] Run simics for <time(ms)> of OCC execution time to gather\n"; - print "\t instruction trace (can't be used with [-i]\n"; - print "\t[-e] Create source-interleaved-code-coverage file *.ccov_src.txt\n"; - print "\t leaving all executed instructions from file\n"; - print "\t[-k] Create source-interleaved-code-coverage file *.ccov_src.txt\n"; - print "\t but remove all executed instructions from file\n"; - print "\t[-a <num>] Used with [-e] or [-k]. When doing source-interleave, print\n"; - print "\t <num> lines after 'unexecuted' source line as context.\n"; - print "\t[-b <num>] Used with [-e] or [-k]. When doing source-interleave, print\n"; - print "\t <num> lines after 'unexecuted' source line as context.\n"; - print "\t[-u] Create unique filenames for each run (appends date/time to filename\n"; - print "\t[-h] Dump Help\n"; - print "\n"; - - DEBUG(1,"Secret Options:\n"); - DEBUG(1,"\t[-j <string>] Modifiy objdump arguments\n"); - DEBUG(1,"\n"); - - print "Examples:\n"; - print "\t- Get code coverage automatically for 35ms of OCC time\n"; - print "\t $name -t 35\n"; - print "\n"; - print "\t- Get code coverage w/ source-interleave automatically for 35ms of OCC time\n"; - print "\t and print 3 lines of source before un-executed instruction and 5 lines after\n"; - print "\t then view source-interleaved file in gvim when complete\n"; - print "\t $name -t 35 -k -a 5 -b 3 -w /usr/bin/gvim\n"; - print "\n"; - print "\t- Get code coverage based on an already dumped instruction trace\n"; - print "\t $name -i /tmp/instructions.txt\n"; - print "\n"; - print "\t- Get code coverage based on an already dumped instruction trace, and stop most\n"; - print "\t STDOUT printing\n"; - print "\t $name -i /tmp/instructions.txt -v \"-1\"\n"; - print "\n"; - print "\t- Get code coverage based on an already dumped instruction trace and source dump\n"; - print "\t $name -i /tmp/instructions.txt -s /tmp/source_dump.txt\n"; - print "\n"; - - print "Contact:\n"; - print "\tFor bugs, feature requests, etc., please contact:\n"; - print "\tPrimary Contact: $G_primary_contact\n"; - print "\tAll Contacts: "; - foreach(@G_contact_emails){print "$_, ";}print "\n"; - print "\n"; - - - #---------------------------------------- - # Only print this if we are in debug mode - #---------------------------------------- - if(1 <= $G_debug_lvl) - { -print <<END; ------------------------------------------------------------------------------- -Instructions for Use ------------------------------------------------------------------------------- -To get the instruction trace needed for <instruction trace file>: - - Start Simics - - Load OCC - - Set a breakpoint (if you don't do this, the file will be way too huge - before you can Ctrl+C) - - Run in Simics: - simics> load-module trace - simics> new-tracer - simics> trace0->trace_data = 0 - simics> trace0->trace_exceptions = 0 - simics> trace0.start occ_exe_trace - simics> r - running>...breakpoint hits - simics> trace0.stop - - - Run in Sandbox (Bash Prompt): - \\grep inst \$sb/../simics/occ_exe_trace | \\grep -ho "p:0x........" | \\grep -ho "........\$" | sort | uniq > /tmp/occ_instructions.txt - - - This grabs all instructions run & physical mem addresses, sorts them, - and removes duplicate addresses) - - This takes ~1.3seconds/250us worth of OCC data - - -To get the source file needed for <source dump file>: - - After compiling: - ppcnf-mcp5-objdump -d -l \$sb/occ/occ.out > /tmp/occ_source_dump.txt - -- or -- - The script will just take care of this for you. - -Output File will be dumped to: /tmp/occ_source_dump.ccov.txt - - It will contain ":::::" at the start of lines that have been - executed in the simics trace that was grabbed. - - - It is recommeded that if a user wants a graphical view of the - code coverage, they use the following command: - gvimdiff /tmp/occ_source_dump.txt /tmp/occ_source_dump.ccov.txt - -Notes: - - To trace 8 real-world seconds of OCC Simics Execution, simics - creates a 250MB file. - - This takes ~45 seconds to parse w/ grep/sort/uniq - - To trace 250us in OCC time, Simics creates a 10MB file. - - This takes ~1.5 seconds to parse w/ grep/sort/uniq - - It is very important that both the instruction trace and source file - have all their addresses in numerical order. - -END -} -} - diff --git a/src/occ/tools/mkvpozip.sh b/src/occ/tools/mkvpozip.sh deleted file mode 100755 index dca6e56..0000000 --- a/src/occ/tools/mkvpozip.sh +++ /dev/null @@ -1,66 +0,0 @@ -DESC=$1 - -DATE=`date +'%m%d%y84S'` -VPODIR="/tmp/vpo_zip_$DESC" -USERNAME=$USER - -mkdir -p $VPODIR -mkdir $VPODIR/gpe -cd $sb/occc/405 -# Added 3-15-2012, Commented out 3-30-2012 -#make clean && make NO_TRAC_STRINGS=1 OCC_SVN_SIMICS=1 && make combineImage #No APSS -# Added 3-30-2012, Commented out x-xx-xxxx -#make clean && make NO_TRAC_STRINGS=1 && make combineImage #w/ APSS -mk clobber_all && mk -a -DFSPLESS_SIMICS=1 && mk combineImage #w/ APSS -cp $sb/../obj/ppc/occc/405/image.bin $VPODIR/occ_l3_image_$DESC.bin - -# Copy OCC SRAM Image & Symbol/Disassembly -cp $sb/../obj/ppc/occc/405/occ/occ.bin $VPODIR/occ_sram_image_$DESC.bin -cp $sb/../obj/ppc/occc/405/occ/occ.out $VPODIR/occ_sram_image_$DESC.out -cp $sb/../obj/ppc/occc/405/occ/occ.map $VPODIR/occ_sram_image_$DESC.map -cp $sb/../obj/ppc/occc/405/occ/occ.dis $VPODIR/occ_sram_image_$DESC.dis - -# Copy OCC Bootloader & Symbol/Disassembly -cp $sb/../obj/ppc/occc/405/occBootLoader/bootloader.map $VPODIR/occ_bootloader_$DESC.map -cp $sb/../obj/ppc/occc/405/occBootLoader/bootloader.out $VPODIR/occ_bootloader_$DESC.out -cp $sb/../obj/ppc/occc/405/occBootLoader/bootloader.dis $VPODIR/occ_bootloader_$DESC.dis - -# Disassemble GPEs & Copy Disassembly of GPE into Zip -for gpeobj in $(for f in $(find ./ -iname '*\.ps'); do echo $f | sed 's/\.pS/\.o/'; done); -do - BASE=`basename $gpeobj`; - /afs/awd/projects/cte/tools/porebinutils/prod/bin/pore-elf64-objdump -d $gpeobj > $VPODIR/gpe/$BASE.$DESC.dis; -done - -zip -r occ_vpo_$DESC.$DATE.zip $VPODIR -chmod 775 occ_vpo_$DESC.$DATE.zip - -echo "Created occ_vpo_$DESC.$DATE.zip @ full path:" -echo "$sb/occ_vpo_$DESC.$DATE.zip" - -rm -rf $VPODIR -#tar cvf - ./occ_vpo_$DESC.$DATE.zip | ssh $USERNAME@hdmdbld.boeblingen.de.ibm.com 'umask 0022; cd /afs/apd/u/thallet/public/occ_vpo/; tar xvf -' - -echo "Do you want to copy occ_vpo_$DESC.$DATE.zip to...?" -echo "1. hdmdbld.boeblingen.de.ibm.com:/modbld/mur/tim/" -echo "2. /afs/bb/u/rembold/occ/" -echo "3. /afs/apd/u/thallet/public/occ_vpo/" -echo "4. None" -read choice - - -case $choice in - [1]* ) #scp $sb/occ_vpo_$DESC.$DATE.zip $USERNAME@hdmdbld.boeblingen.de.ibm.com:/modbld/mur/tim/; - #ssh $USERNAME@hdmdbld.boeblingen.de.ibm.com chmod 755 /modbld/mur/tim/occ_vpo_$DESC.$DATE.zip - tar cvf - ./occ_vpo_$DESC.$DATE.zip | ssh $USERNAME@hdmdbld.boeblingen.de.ibm.com 'umask 0022; cd /modbld/mur/tim/; tar xvf -' - exit;; - [2]* ) #scp $sb/occ_vpo_$DESC.$DATE.zip $USERNAME@hdmdbld.boeblingen.de.ibm.com:/afs/bb/u/rembold/occ/; - #ssh $USERNAME@hdmdbld.boeblingen.de.ibm.com chmod 755 /afs/bb/u/rembold/occ/occ_vpo_$DESC.$DATE.zip - tar cvf - ./occ_vpo_$DESC.$DATE.zip | ssh $USERNAME@hdmdbld.boeblingen.de.ibm.com 'umask 0022; cd /afs/bb/u/rembold/occ/; tar xvf -' - exit;; - [3]* ) cp $sb/occ_vpo_$DESC.$DATE.zip /afs/apd/u/thallet/public/occ_vpo/; - chmod 755 /afs/apd/u/thallet/public/occ_vpo/occ_vpo_$DESC.$DATE.zip - exit;; - * ) exit;; -esac - diff --git a/src/occ/tools/occGcov.pl b/src/occ/tools/occGcov.pl deleted file mode 100755 index 2c22ca0..0000000 --- a/src/occ/tools/occGcov.pl +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/perl - - -use strict; -use Getopt::Long; - -use lib "$ENV{sb}/occc/405/occ/tools"; -use Gcov; - -my $dumpfile = "$ENV{sb}/../simics/occ_gcov.bin"; -my $symfile = "$ENV{sb}/../obj/ppc/occc/405/occ/occ.syms"; - -GetOptions( "file:s" => \$dumpfile, - "symfile:s" => \$symfile); - -Gcov::main($dumpfile, $symfile); - - - diff --git a/src/occ/tools/occWebTool/Makefile b/src/occ/tools/occWebTool/Makefile deleted file mode 100755 index 35033e5..0000000 --- a/src/occ/tools/occWebTool/Makefile +++ /dev/null @@ -1,36 +0,0 @@ -# $Id$ - -# @file Makefile -# -# @brief Makefile OCC Error Log Parser application -# - -# @page ChangeLogs Change Logs -# @section Makefile -# @verbatim -# -# -# Change Log ****************************************************************** -# Flag Defect/Feature User Date Description -# ------ -------------- ---------- ------------ ----------- -# @rc004 rickylie 03/12/2012 Created -# @ai009 865968 ailutsar 01/09/2013 OCC Error log and trace parser web tool enhancement -# -# @endverbatim -# -CC = g++ - -INCDIR += -I../../incl -INCDIR += -I../../errl -INCDIR += -I../../trac -INCDIR += -I../../../ssx/ - -errllog_CFILES = parser.c - - -all_cfiles = ${errllog_CFILES} -SOURCES = ${all_cfiles} -MODE = validation - -pgas: - $(CC) ${all_cfiles} $(INCDIR) -DOCC_X86_PARSER -Wl,--hash-style=sysv -g -o OCCFileParser diff --git a/src/occ/tools/occWebTool/parser.c b/src/occ/tools/occWebTool/parser.c deleted file mode 100755 index 2c4b263..0000000 --- a/src/occ/tools/occWebTool/parser.c +++ /dev/null @@ -1,451 +0,0 @@ -/****************************************************************************** -// @file parser.c -// @brief OCC ERRL TEST -*/ -/****************************************************************************** - * - * @page ChangeLogs Change Logs - * @section parser.c PARSER.C - * @verbatim - * - * Flag Def/Fea Userid Date Description - * ------- ---------- -------- ---------- ---------------------------------- - * @rc004 rickylie 02/15/2012 Created - * @ai009 865968 ailutsar 01/07/2012 Initial version - * OCC Error log and trace parser web tool enhancement - * @jh001 881996 joshych 05/07/2013 Support SRAM error log format - * @jh006 897972 joshych 09/17/2013 Problems with OCC elog web parser - * @jh008 899096 joshych 09/23/2013 OCC Event Log Parser UserDetail Failure - * - * @endverbatim - * - *///*************************************************************************/ - -//************************************************************************* -// Includes -//************************************************************************* -#include <stdio.h> -#include <string.h> -#include <iostream> -#include <fstream> -#include <sstream> -#include <iomanip> -#include <vector> -#include <memory> -#include <time.h> -#include <errl.h> -#include <sys/types.h> -#include <netinet/in.h> - -//************************************************************************* -// Externs -//************************************************************************* - -//************************************************************************* -// Macros -//************************************************************************* - -//************************************************************************* -// Defines/Enums -//************************************************************************* -#define HEX(value,digit_width) std::uppercase << std::setfill('0') << \ - std::setw(digit_width) << std::hex << (uint32_t)value -#define DEC(value) std::dec << (uint32_t)value -#define tracr_buffer_size 1024 - -// This definition would be changing this to a dynamic variable to be passed -// into this function -#define SSX_TIMEBASE_FREQUENCY_HZ 600000000 - -//************************************************************************* -// Function Prototypes -//************************************************************************* -std::string hex_dump(uint8_t* i_binary_buffer, uint32_t i_buffer_size); - -//************************************************************************* -// Global variables -//************************************************************************* -std::string g_severityTbl[3] = { "INFORMATIONAL", "PREDICTIVE", "UNRECOVERABLE"}; // @jh006a -std::string g_calloutTypeTbl[2] = { "HUID", "CompID"}; // @jh006a -std::string g_UsrDtlTypeTbl[3] = { "TRACE", "CallHome", "BINARY"}; // @jh008a - -//************************************************************************* -// Structures/Classes -//************************************************************************* -class ErrlUserDetailsEntryContent -{ - public: - uint8_t* iv_Content; - uint32_t iv_length; - - ErrlUserDetailsEntryContent() { - iv_length = 0; - iv_Content = NULL; - } - - ErrlUserDetailsEntryContent(uint8_t* i_binary_buffer, uint32_t i_buffer_size) { - iv_length = i_buffer_size; - iv_Content = new uint8_t[iv_length]; - memcpy(iv_Content, i_binary_buffer, iv_length); - } - - ErrlUserDetailsEntryContent & operator=(const ErrlUserDetailsEntryContent & i_ErrlUserDetailsEntryContent){ - iv_length = i_ErrlUserDetailsEntryContent.iv_length; - iv_Content = new uint8_t[iv_length]; - memcpy(iv_Content, i_ErrlUserDetailsEntryContent.iv_Content, iv_length); - } - - ErrlUserDetailsEntryContent(const ErrlUserDetailsEntryContent& i_ErrlUserDetailsEntryContent) { - iv_length = i_ErrlUserDetailsEntryContent.iv_length; - iv_Content = new uint8_t[iv_length]; - memcpy(iv_Content, i_ErrlUserDetailsEntryContent.iv_Content, iv_length); - } - - ~ErrlUserDetailsEntryContent() { - if(iv_Content) - { - delete [] iv_Content; - } - } - - std::string hexdump() { - return hex_dump(iv_Content, iv_length); - } -}; - -class OCC_ERRL -{ - public: - OCC_ERRL(); - OCC_ERRL(uint8_t*, uint32_t); - - std::string dump_header(); - std::string dump_userDetails(); - - private: - /// Error Log Header - ErrlEntry_t iv_header; - - /// User Details Entry - std::vector<ErrlUserDetailsEntry_t> iv_UserDetailsHeader; - - /// User Details Entry Content - std::vector<ErrlUserDetailsEntryContent> iv_UserDetailsContent; -}; - -//************************************************************************* -// Globals -//************************************************************************* - -//************************************************************************* -// Functions -//************************************************************************* -std::string OCC_ERRL::dump_header() // jh001c -{ - std::stringstream l_stream; - std::string l_string; - - l_stream << "\n OCC Error Log Dump"; - l_stream << "\n-------------------------------------------------------------------------------"; - l_stream << "\n Error Log Header"; - l_stream << "\n-------------------------------------------------------------------------------"; - l_stream << "\n Version : 0x" << HEX(iv_header.iv_version, 2); - l_stream << "\n Entry Id : 0x" << HEX(iv_header.iv_entryId, 2); - l_stream << "\n Reason Code : 0x" << HEX(iv_header.iv_reasonCode,2); - l_stream << "\n Severity : " << g_severityTbl[iv_header.iv_severity]; // @jh006c - l_stream << "\n Actions : 0x" << HEX(iv_header.iv_actions.word,2); - l_stream << "\n Word 4 : 0x" << HEX(ntohl(iv_header.iv_userData4), 8); - - // loop for print out Callouts - // @jh006c - start - uint8_t l_index = 0; - uint32_t l_callout = 0; - for (uint8_t i=0 ; i<iv_header.iv_numCallouts ; i++) - { - l_callout = iv_header.iv_callouts[i].iv_calloutValue >> 32; - if (0 == l_callout) - { - break; - } - l_index++; - } - l_stream << "\n-------------------------------------------------------------------------------"; - l_stream << "\n Number Of Callouts : 0x" << HEX(l_index, 2) - << " (Dec " << DEC(l_index) << ")"; - l_stream << "\n-------------------------------------------------------------------------------"; - for (uint8_t i=0 ; i<l_index ; i++) - { - l_callout = iv_header.iv_callouts[i].iv_calloutValue >> 32; - l_stream << "\n Type : " << g_calloutTypeTbl[iv_header.iv_callouts[i].iv_type-1]; - l_stream << "\n Callout Value : 0x" << HEX(ntohl(l_callout), 8); - l_stream << "\n Priority : 0x" << HEX(iv_header.iv_callouts[i].iv_priority, 2); - l_stream << "\n-------------------------------------------------------------------------------"; - } - // @jh006c - end - - // print out User Details Header - l_stream << "\n UserDetails Header "; - l_stream << "\n-------------------------------------------------------------------------------"; - l_stream << "\n Version : 0x" << HEX(iv_header.iv_userDetails.iv_version, 2); - l_stream << "\n Module Id : 0x" << HEX(ntohs(iv_header.iv_userDetails.iv_modId), 4); - l_stream << "\n Firmware Level : 0x" << HEX(ntohl(iv_header.iv_userDetails.iv_fwLevel), 8); - - // parsing timestamp to format( seconds: microseconds) - l_stream << "\n Time : " << DEC((iv_header.iv_userDetails.iv_timeStamp/SSX_TIMEBASE_FREQUENCY_HZ)/CLOCKS_PER_SEC) << " seconds:" - << DEC((iv_header.iv_userDetails.iv_timeStamp/SSX_TIMEBASE_FREQUENCY_HZ)%CLOCKS_PER_SEC ) << " microseconds"; - - l_stream << "\n OCC ID : 0x" << HEX(iv_header.iv_userDetails.iv_occId, 2); - l_stream << "\n OCC Role : " << ((iv_header.iv_userDetails.iv_occRole != 0) ? "OCC_MASTER":"OCC_SLAVE"); - l_stream << "\n OCC State : 0x" << HEX(iv_header.iv_userDetails.iv_operatingState, 2); - - // the commited bit is actually stored at reserved1 due to reverse bit order - uint8_t l_commited = iv_header.iv_userDetails.iv_reserved1 >> 6; - l_stream << "\n Committed : " << (l_commited == 1 ? "true":"false"); // @jh006c - l_stream << "\n Word 1 : 0x" << HEX(ntohl(iv_header.iv_userDetails.iv_userData1), 8); - l_stream << "\n Word 2 : 0x" << HEX(ntohl(iv_header.iv_userDetails.iv_userData2), 8); - l_stream << "\n Word 3 : 0x" << HEX(ntohl(iv_header.iv_userDetails.iv_userData3), 8); - - l_stream << "\n-------------------------------------------------------------------------------"; - l_stream << "\n Error log Entry Size : " << HEX(ntohs(iv_header.iv_userDetails.iv_entrySize), 4) - << " (Dec " << DEC(ntohs(iv_header.iv_userDetails.iv_entrySize)) << ")"; - l_stream << "\n-------------------------------------------------------------------------------"; - l_stream << "\n User Details Size : " << HEX(ntohs(iv_header.iv_userDetails.iv_userDetailEntrySize), 4) - << " (Dec " << DEC(ntohs(iv_header.iv_userDetails.iv_userDetailEntrySize)) << ")"; - l_stream << "\n-------------------------------------------------------------------------------"; - - l_string = l_stream.str(); - - return l_string; -} - -std::string OCC_ERRL::dump_userDetails() -{ - std::stringstream l_stream; - std::string l_string; - FILE *fd = NULL; - uint8_t * l_readBufEntry = NULL; - - for(uint32_t l_index = 0; l_index < iv_UserDetailsHeader.size(); l_index++) - { - // print out header of User Detail Section - l_stream << "\n Section : " << l_index+1; // @jh008c - l_stream << "\n Version : 0x" << HEX(iv_UserDetailsHeader[l_index].iv_version, 2); - l_stream << "\n Type : " << g_UsrDtlTypeTbl[iv_UserDetailsHeader[l_index].iv_type-1]; // jh008c - l_stream << "\n Section Size : 0x" << HEX(ntohs(iv_UserDetailsHeader[l_index].iv_size), 4) - << " (Dec " << DEC(ntohs(iv_UserDetailsHeader[l_index].iv_size)) << ")"; - l_stream << "\n Section Data : "; - l_stream << iv_UserDetailsContent[l_index].hexdump(); - - // parsing User Detail - switch(iv_UserDetailsHeader[l_index].iv_type) - { - case ERRL_USR_DTL_TRACE_DATA: // Traces - l_stream << "\n-------------------------------------------------------------------------------"; - l_stream << "\n Trace Data\n"; - - do{ - // open file to store traces data - std::ofstream l_fstr_out("/tmp/tmp_occ_trace", std::ios::binary); - if(!l_fstr_out.is_open()) - { - //open fstream failed - l_stream << "\nFailed to open trace file"; - break; - } - - // dump trace data to file, then close it - l_fstr_out.write((const char*)iv_UserDetailsContent[l_index].iv_Content, - iv_UserDetailsContent[l_index].iv_length); - l_fstr_out.close(); - - // call fsp-trace to get traces content - l_readBufEntry = new uint8_t[tracr_buffer_size]; - - // use popen to execute fsp-trace - fd = popen("./fsp-trace -s ./trexStringFile /tmp/tmp_occ_trace|sed \"/Can't open device 2/d\";rm /tmp/tmp_occ_trace", "r"); - if(NULL == fd) - { - //popen failed - l_stream << "\nFailed to execute fsp-trace command"; - break; - } - - //read all data into buffer - while(fgets((char*)l_readBufEntry, tracr_buffer_size, fd)) - { - l_stream << l_readBufEntry; - } - - // close popen fd - pclose(fd); - - - }while(FALSE); - break; - default: - break; - } - l_stream << "\n-------------------------------------------------------------------------------"; - } - - l_string = l_stream.str(); - - if(l_readBufEntry) - { - delete [] l_readBufEntry; - } - - return l_string; -} - -OCC_ERRL::OCC_ERRL() -{ - memset(&iv_header, 0, sizeof(iv_header)); -} - -// @jh008c -OCC_ERRL::OCC_ERRL(uint8_t* i_binary_buffer, uint32_t i_buffer_size) -{ - uint32_t l_sizeRead = 0; - ErrlUserDetailsEntry_t l_UserDetailsEntry; - //copy Error Log Header into ErrlEntry_t - if (i_buffer_size >= sizeof(ErrlEntry_t)) - { - memcpy(&iv_header, i_binary_buffer, sizeof(ErrlEntry_t)); - l_sizeRead = sizeof(ErrlEntry_t); - } - - while(l_sizeRead < i_buffer_size){ - // make sure we have the enough buffer size - if (l_sizeRead+sizeof(ErrlUserDetailsEntry_t) <= i_buffer_size) - { - // copy User Details Entry structure - memset(&l_UserDetailsEntry, 0x00, sizeof(l_UserDetailsEntry)); - memcpy(&l_UserDetailsEntry, i_binary_buffer + l_sizeRead, sizeof(ErrlUserDetailsEntry_t)); - l_sizeRead += sizeof(ErrlUserDetailsEntry_t); - if (l_sizeRead+ntohs(l_UserDetailsEntry.iv_size) <= i_buffer_size) - { - //get User Details Entry content - ErrlUserDetailsEntryContent l_UserDetailsEntryContent(i_binary_buffer + l_sizeRead, - ntohs(l_UserDetailsEntry.iv_size)); - l_sizeRead += ntohs(l_UserDetailsEntry.iv_size); - // push user detail structure and content into containers - iv_UserDetailsHeader.push_back(l_UserDetailsEntry); - iv_UserDetailsContent.push_back(l_UserDetailsEntryContent); - } - else - { - break; - } // check l_UserDetailsEntry.iv_size - } - else - { - break; - } // check ErrlUserDetailsEntry_t - } - -} - -std::string hex_dump(uint8_t* i_binary_buffer, uint32_t i_buffer_size) -{ - std::stringstream l_stream; - std::string l_string; - - for(uint32_t i = 0; i < i_buffer_size; i++) - { - l_stream << HEX((uint32_t)i_binary_buffer[i], 2); - if(3 == i%4) // 4 bytes as a group - { - l_stream << " "; - } - if(15 == i%16) // insert new line and space - { - l_stream << "\n "; - } - } - - l_string = l_stream.str(); - - return l_string; -} - -// Function Specification -// -// Name: main -// -// Description: main function -// -// Flow: FN=None -// -// End Function Specification - -int main(int argc, char* argv[]) -{ - OCC_ERRL * l_occ_errl = NULL; // Error Log Object - std::vector<uint8_t> l_readBufEntry; // Buffer for storing source data - uint32_t l_len = 0; // length of source data - - if (argc > 2) - { - do { - std::ifstream l_fstr_in; - std::ofstream l_fstr_out; - - //open file for reading source of Error Log - l_fstr_in.open(argv[1], std::ios::binary); - - // open file for writing parsing result - l_fstr_out.open(argv[2], std::ios::binary); - - if (!l_fstr_in.is_open() || !l_fstr_out.is_open()) - { - //open fstream failed - std::cout << "Failed to open file\n"; - break; - } - - // get length of file: - l_fstr_in.seekg (0, std::ios::end); - l_len = l_fstr_in.tellg(); - l_fstr_in.seekg (0, std::ios::beg); - - l_readBufEntry.resize((l_len)); - l_fstr_in.read ((char*)&l_readBufEntry[0],l_len); - l_fstr_in.close(); - - try{ - // create OCC ERRL object - l_occ_errl = new OCC_ERRL(&l_readBufEntry[0], l_readBufEntry.size()); - - if(l_occ_errl) - { - // get ERRL header and dump to file - std::string l_string = l_occ_errl->dump_header(); - l_fstr_out << l_string; - - // get user details and dump to file - l_string = l_occ_errl->dump_userDetails(); - l_fstr_out << l_string; - } - } - catch(...) - { - l_fstr_out << "Parsing error!\n"; - } - - l_fstr_out.close(); - - }while(FALSE); - } - else - { - std::cout << "Usage: OCCFileParser <input_file> <output_file>\n"; - } - - if(l_occ_errl) - { - delete l_occ_errl; - } - - return 0; -} diff --git a/src/occ/tools/occ_amec_sensors.py b/src/occ/tools/occ_amec_sensors.py deleted file mode 100755 index 0994790..0000000 --- a/src/occ/tools/occ_amec_sensors.py +++ /dev/null @@ -1,367 +0,0 @@ -# @file - occ_amec_sensors.py -# @brief Create Simics Commands for Reading AMEC Sensors -# -# Flag Def/Fea Userid Date Description -# ------- ---------- -------- ---------- ---------------------------------- -# thallet 02/28/2012 Created -# $fk002 905632 fmkassem 11/18/2013 Removed cpm support. - - -from time import sleep -from random import randint -import sys -import re - -############################################################################## -########################################################### -# Globals -########################################################### -############################################################################## - -# To create this listing, run the following command: -#\grep g_amec_sys sensor_table.c | \grep " SENSOR_PTR" | sed 's/),.*$/",/g' | sed 's/^.*&/"/g' -amec_sensors = [ -"g_amec_sys.fw.ameintdur", -"g_amec_sys.fw.amessdur[0]", -"g_amec_sys.fw.amessdur[1]", -"g_amec_sys.fw.amessdur[2]", -"g_amec_sys.fw.amessdur[3]", -"g_amec_sys.fw.amessdur[4]", -"g_amec_sys.fw.amessdur[5]", -"g_amec_sys.fw.amessdur[6]", -"g_amec_sys.fw.amessdur[7]", -"g_amec_sys.fw.probe250us[0]", -"g_amec_sys.fw.probe250us[1]", -"g_amec_sys.fw.probe250us[2]", -"g_amec_sys.fw.probe250us[3]", -"g_amec_sys.fw.probe250us[4]", -"g_amec_sys.fw.probe250us[5]", -"g_amec_sys.fw.probe250us[6]", -"g_amec_sys.fw.probe250us[7]", -"g_amec_sys.fw.gpetickdur[0]", -"g_amec_sys.fw.gpetickdur[1]", -"g_amec_sys.fw.prcdupdatedur", -"g_amec_sys.sys.tempambient", -"g_amec_sys.sys.altitude", -"g_amec_sys.sys.pwr250us", -"g_amec_sys.fan.pwr250usfan", -"g_amec_sys.io.pwr250usio", -"g_amec_sys.storage.pwr250usstore", -"g_amec_sys.fan.fanspeedavg", -"g_amec_sys.sys.todclock0 ", -"g_amec_sys.sys.todclock1 ", -"g_amec_sys.sys.todclock2 ", -"g_amec_sys.proc[0].freqa250us", -"g_amec_sys.proc[0].ips2ms", -"g_amec_sys.proc[0].memsp2ms", -"g_amec_sys.proc[0].pwr250us", -"g_amec_sys.proc[0].pwr250usvdd", -"g_amec_sys.proc[0].cur250usvdd", -"g_amec_sys.proc[0].pwr250usvcs", -"g_amec_sys.proc[0].pwr250usmem", -"g_amec_sys.proc[0].sleepcnt2ms", -"g_amec_sys.proc[0].winkcnt2ms", -"g_amec_sys.proc[0].sp250us", -"g_amec_sys.proc[0].temp2ms", -"g_amec_sys.proc[0].temp2mspeak", -"g_amec_sys.proc[0].util2ms", -"g_amec_sys.sys.vrfan250usproc", -"g_amec_sys.sys.vrhot250usproc", -"g_amec_sys.sys.vrfan250usmem", -"g_amec_sys.sys.vrhot250usmem", -"g_amec_sys.proc[0].temp2mscent", -"g_amec_sys.proc[0].temp2msdimm", -"g_amec_sys.proc[0].memsp2ms_tls", -"g_amec_sys.proc[0].vrm[0].uvolt250us", -"g_amec_sys.proc[0].vrm[1].uvolt250us", -"g_amec_sys.proc[0].vrm[0].volt250us", -"g_amec_sys.proc[0].vrm[1].volt250us", -] - -#\grep g_amec_sys sensor_table.c | \grep " CORE_SENSOR_PTR" | sed 's/),.*$/",/g' | sed 's/^.*&/"/g' | sed 's/core, /core[0]./g' -amec_core_sensors = [ -"g_amec_sys.proc[0].core[0].freq250us", -"g_amec_sys.proc[0].core[0].freqa250us", -"g_amec_sys.proc[0].core[0].ips2ms", -"g_amec_sys.proc[0].core[0].mcpifd2ms", -"g_amec_sys.proc[0].core[0].mcpifi2ms", -"g_amec_sys.proc[0].core[0].spurr2ms", -"g_amec_sys.proc[0].core[0].temp2ms", -"g_amec_sys.proc[0].core[0].util2ms", -"g_amec_sys.proc[0].core[0].mstl2ms", -"g_amec_sys.proc[0].core[0].cmt2ms", -"g_amec_sys.proc[0].core[0].cmrd2ms", -"g_amec_sys.proc[0].core[0].cmwr2ms", -"g_amec_sys.proc[0].core[0].ppic", -"g_amec_sys.proc[0].core[0].pwrpx250us", -] - -#\grep g_amec_sys sensor_table.c | \grep " PORTPAIR_SENSOR_PTR" | sed 's/),.*$/",/g' | sed 's/^.*&/"/g' | sed 's/memctl, /memctl[0]./g' | sed 's/portpair, /portpair[0]./g' -amec_portpair_sensors = [ -"g_amec_sys.proc[0].memctl[0].centaur.portpair[0].mac2ms", -"g_amec_sys.proc[0].memctl[0].centaur.portpair[0].mpu2ms", -"g_amec_sys.proc[0].memctl[0].centaur.portpair[0].mirb2ms", -"g_amec_sys.proc[0].memctl[0].centaur.portpair[0].mirl2ms", -"g_amec_sys.proc[0].memctl[0].centaur.portpair[0].mirm2ms", -"g_amec_sys.proc[0].memctl[0].centaur.portpair[0].mirh2ms", -"g_amec_sys.proc[0].memctl[0].centaur.portpair[0].mts2ms", -"g_amec_sys.proc[0].memctl[0].centaur.portpair[0].memsp2ms", -] - -############################################################################## -########################################################### -# Functions -########################################################### -############################################################################## -def print_symbol( str ): - tick = cli.quiet_run_command(G_occ_list[0] + ".cpu.psym " + '\"' + str + '\"') - print str + ": ", tick[1].rstrip('\n') - return - -def print_all_as_hex( str ): - tick = cli.quiet_run_command(G_occ_list[0] + ".cpu.psym " + '\"' + str + '\"') - splitter = re.compile(r'(\d+)') - p_sym = tick[1].rstrip('\n') - r_sym = splitter.split(p_sym) - out_str = '' - for item in r_sym: - if item.isdigit(): - if (int(item) > 0xffffffff): - out_str += "0x%016x" % int(item) - else: - out_str += "0x%08x" % int(item) - else: - out_str += `item` - - print out_str - return - -def print_symbol_value_hex( str ): - tick = cli.quiet_run_command(G_occ_list[0] + ".cpu.psym " + '\"' + str + '\"') - print str + ": \t", "0x%04x" % int(tick[1].rstrip('\n')) - return - -def print_symbol_value_hex_apss( str ): - tick = cli.quiet_run_command(G_occ_list[0] + ".cpu.psym " + '\"' + str + '\"') - value = int(tick[1].rstrip('\n')) - print str + ": \t", "0x%04x (raw=0x%04x), %d" % ((value&0x0fff), (value),(value&0x0fff)) - return - -def print_sensor_quick( str ): - sample = ".sample" - max = ".sample_max" - min = ".sample_min" - mnsnsr = ".mini_sensor" - update = ".update_tag" - - s_sample = cli.quiet_run_command(G_occ_list[0] + ".cpu.psym " + '\"' + str + sample + '\"') - s_max = cli.quiet_run_command(G_occ_list[0] + ".cpu.psym " + '\"' + str + max + '\"') - s_min = cli.quiet_run_command(G_occ_list[0] + ".cpu.psym " + '\"' + str + min + '\"') - s_upd = cli.quiet_run_command(G_occ_list[0] + ".cpu.psym " + '\"' + str + update + '\"') - s_mns = cli.quiet_run_command(G_occ_list[0] + ".cpu.psym " + '\"*' + str + mnsnsr + '\"') - - p_str = str.replace("g_amec_sys.","") - p_sample = s_sample[1].rstrip('\n') - p_max = s_max[1].rstrip('\n') - p_min = s_min[1].rstrip('\n') - p_upd = s_upd[1].rstrip('\n') - p_mns = s_mns[1].rstrip('\n') - - print p_str.ljust(45) + ":\t", p_sample.rjust(6) + ", " \ - + p_max.rjust(6) + ", " \ - + p_min.rjust(6) + ", " \ - + p_mns.rjust(6) + ", " \ - + p_upd.rjust(10) - return - -def print_core_sensor_quick( ): - for sensor in amec_core_sensors: - print "" - for x in range(0,12): - name = sensor.replace("core[0]","core["+str(x)+"]") - print_sensor_quick(name) - -def print_sensor_quick_string( strin ): - print "Name".ljust(45) + " \t", "Sample".rjust(6) + ", " \ - + "Max".rjust(6) + ", " \ - + "Min".rjust(6) + ", " \ - + "MnSnsr".rjust(6) + ", " \ - + "UpdateTag".rjust(10) - - for sensor in amec_core_sensors: - for x in range(0,12): - name = sensor.replace("core[0]","core["+str(x)+"]") - if re.search( strin, name ): - print_sensor_quick(name) - for sensor in amec_sensors: - if re.search( strin, sensor ): - print_sensor_quick(sensor) - for sensor in amec_portpair_sensors: - for x in range(0,8): - t_name = sensor.replace("memctl[0]","memctl["+str(x)+"]") - for x in range(0,2): - name = t_name.replace("portpair[0]","portpair["+str(x)+"]") - if re.search( strin, name ): - print_sensor_quick(name) - - -def print_array_quick( strin, idx ): - for x in range(0,idx): - name = strin.replace("[0]","["+str(x)+"]") - s_sample = cli.quiet_run_command(G_occ_list[0] + ".cpu.psym " + '\"' + name + '\"') - p_sample = s_sample[1].rstrip('\n') - print name + ":\t" + p_sample - -def set_value( strin, value ): - s_sample = cli.quiet_run_command(G_occ_list[0] + ".cpu.psym " + '\"' + strin + '\"') - p_sample = s_sample[1].rstrip('\n') - print "Old: " + strin + ":\t" + p_sample - - s_sample = cli.quiet_run_command( G_occ_list[0] + ".oci_space.set (" + G_occ_list[0] + ".cpu.sym " + '\"&' + strin + '\") ' + str(value) + " (sym \"sizeof(" + strin + ")\")") - - s_sample = cli.quiet_run_command(G_occ_list[0] + ".cpu.psym " + '\"' + strin + '\"') - p_sample = s_sample[1].rstrip('\n') - print "New: " + strin + ":\t" + p_sample - - -def print_sensors_all( ): - print "Name".ljust(45) + " \t", "Sample".rjust(6) + ", " \ - + "Max".rjust(6) + ", " \ - + "Min".rjust(6) + ", " \ - + "MnSnsr".rjust(6) + ", " \ - + "UpdateTag".rjust(10) - for sensor in amec_sensors: - print_sensor_quick(sensor) - - print_core_sensor_quick() - - for sensor in amec_portpair_sensors: - for x in range(0,8): - t_name = sensor.replace("memctl[0]","memctl["+str(x)+"]") - for x in range(0,2): - name = t_name.replace("portpair[0]","portpair["+str(x)+"]") - print_sensor_quick(name) - print "" - - print __file__ - - - -def print_apss_pwr( ): - strin = "G_apss_pwr_meas->adc[0]" - for x in range(0,16): - name = strin.replace("[0]","["+str(x)+"]") - print_symbol_value_hex_apss(name) - print "" - print_symbol_value_hex("G_apss_pwr_meas->gpio[0]") - print_symbol_value_hex("G_apss_pwr_meas->gpio[1]") - print "" - print_symbol_value_hex("G_apss_pwr_meas->tod") - - -############################################################################## -########################################################### -# Register some New Simics Commands -########################################################### -############################################################################## - -#---------------------------------------------------------- -# -# -new_command("occ-print-sensor", print_sensor_quick_string, - args = [arg(str_t, "name")], - alias = "ps", - type = "occ-fw-module-commands", - short = "Print a sensor", - doc_items = [("NOTE", "This command is best")], - see_also = ["my_other_command"], - doc = """ - <b>my-command</b> is best. - This is its documentation. <i>arg</i> - is the first argument...""") - -#---------------------------------------------------------- -# -# -new_command("occ-print-sensors-all", print_sensors_all, - args = [], - alias = "psa", - type = "occ-fw-module-commands", - short = "Print all sensors", - doc_items = [("NOTE", "This command is best")], - see_also = ["my_other_command"], - doc = """ - <b>my-command</b> is best. - This is its documentation. <i>arg</i> - is the first argument...""") - -#---------------------------------------------------------- -# -# -new_command("occ-print-array", print_array_quick, - args = [arg(str_t, "name"),arg(int_t, "arg", "?", 10),], - alias = "pa", - type = "occ-fw-module-commands", - short = "Print an array", - doc_items = [("NOTE", "This command is best")], - see_also = ["my_other_command"], - doc = """ - <b>my-command</b> is best. - This is its documentation. <i>arg</i> - is the first argument...""") - -#---------------------------------------------------------- -# -# -new_command("occ-set-value", set_value, - args = [arg(str_t, "name"),arg(int_t, "arg", "?", 10),], - alias = "sv", - type = "occ-fw-module-commands", - short = "Set a variable to a value", - doc_items = [("NOTE", "This command is best")], - see_also = ["my_other_command"], - doc = """ - <b>my-command</b> is best. - This is its documentation. <i>arg</i> - is the first argument...""") - -#---------------------------------------------------------- -# -# -new_command("occ-dump-raw-power", print_apss_pwr, - args = [], - alias = "drp", - type = "occ-fw-module-commands", - short = "OCC Dump Raw Power from APSS", - doc_items = [("NOTE", "This command is best")], - see_also = ["my_other_command"], - doc = """ - <b>my-command</b> is best. - This is its documentation. <i>arg</i> - is the first argument...""") - -# this is my Python function that will be called when the -# command is invoked from the Simics prompt. -#def my_command_fun(int_arg, str_arg, flag_arg): -# print "My integer: %d" % int_arg -# print "My string: %s" % str_arg -# print "Flag is", -# if flag_arg: -# print "given" -# else: -# print "not given" -# return int_arg -## register our new command -#new_command("my-command", my_command_fun, -# args = [arg(int_t, "arg", "?", 10), arg(str_t, "name"), -# arg(flag_t, "-f")], -# alias = "mc", -# type = "my-module-commands", -# short = "my command does it", -# doc_items = [("NOTE", "This command is best")], -# see_also = ["my_other_command"], -# doc = """ -# <b>my-command</b> is best. -# This is its documentation. <i>arg</i> -# is the first argument...""") - diff --git a/src/occ/tools/occ_autotest b/src/occ/tools/occ_autotest deleted file mode 100755 index 0743b82..0000000 --- a/src/occ/tools/occ_autotest +++ /dev/null @@ -1,609 +0,0 @@ -#!/bin/bash -################################################################################ -## Simics automation using autosim -## 2011-10-15 tgh modified to run occ in simics -## -## Usage: -## autocitest [--quiet] <backing_build> <sandbox_name> <hbi_image> -################################################################################ -function waitkb() -{ - - ## wait for kbhit to continue - ## echo "Hit any key to continue" - ## read kb - echo "." -} - -function usage() -{ - - echo "usage:" - echo "$0 [--quiet] backing_tree_dir sandbox_name path_to_hbicore_test_img " -} - - -function stopsim() -{ - # Stop simics - echo "Stopping simics" - autosim $NOWIN $VERBOSE --stopsim - if [ $? -ne 0 ] ; then - echo "WARNING: Unable to stop simics cleanly" - fi -} - - -function stopserver() -{ - # Stop simics server - echo "Stopping simics server" - autosim $NOWIN $VERBOSE --stopserver - if [ $? -ne 0 ] ; then - echo "WARNING: Unable to stop simics server cleanly" - fi -} - - -function runsimics() -{ - # Stop simics server - echo "Starting simics server" - autosim $NOWIN $VERBOSE --simcmd "r" - if [ $? -ne 0 ] ; then - echo "WARNING: Unable to start simics server cleanly" - fi -} - -function loadocc() -{ - # Stop simics server - echo "Loading OCC" - autosim $NOWIN $VERBOSE --simcmd "run-command-file $sb/occc/405/occ/tools/occ_post_model_hook.simics" 1>> /tmp/totaltests3.log 2> /dev/null - if [ $? -ne 0 ] ; then - echo "WARNING: Unable to load OCC cleanly" - fi -} - -function simicsCmd() -{ - # Run a Simics command - echo "Running Simics Command -- $1" - autosim $NOWIN $VERBOSE --simcmd "$1" 1>> /tmp/totaltests2.log 2> /dev/null - if [ $? -ne 0 ] ; then - echo "WARNING: Unable to run Simics Command $1" - fi -} - -function fspCmd() -{ - # Run a FSP command - echo "Running Simics FSP Command -- $1" - autosim $NOWIN $VERBOSE --fspcmd "$1" 1>> /tmp/totaltests2.log 2> /dev/null - if [ $? -ne 0 ] ; then - echo "WARNING: Unable to run Simics FSP Command $1" - fi -} - -function simicsFspToOccCmd() -{ - # Stop simics server - echo "Running FSP->OCC Command -- $*" - # There must be a more eloquent way than this - case "$#" in - 1) autosim $NOWIN $VERBOSE --simcmd "@occ_fsp_command('$1')" 1>> /tmp/totaltests2.log 2> /dev/null - ;; - 2) autosim $NOWIN $VERBOSE --simcmd "@occ_fsp_command('$1', '$2')" 1>> /tmp/totaltests2.log 2> /dev/null - ;; - 3) autosim $NOWIN $VERBOSE --simcmd "@occ_fsp_command('$1', '$2', '$3')" 1>> /tmp/totaltests2.log 2> /dev/null - ;; - *) echo "Num args not supported" - ;; - esac - if [ $? -ne 0 ] ; then - echo "WARNING: Unable to run Simics Command $1" - fi - sleep 10; - autosim $NOWIN $VERBOSE --simcmd "@occ_fsp_response(128)" 1>> /tmp/totaltests2.log 2> /dev/null -} - -function occTrace() -{ - TRAC_ADDR_TMP=`nm $sb/../obj/ppc/occc/405/occ/occ.out | \grep "g_trac_inf_buffer" | awk '{print $1}' | sed 's/^00000000/0x/g'` - TRAC_ADDR=`perl -e "printf(\"0x%08x\",$TRAC_ADDR_TMP - 0xfff80000)"` - TRAC_LEN="0x6000" - - # Save off full OCC binary to generate code coverage from - echo "Collecting Trace" - rm $sb/../simics/occ_trace.bin - simicsCmd "p8Proc0.OccComplexSlot.OccSimpleSlot.sram_image.save occ_trace.bin $TRAC_ADDR $TRAC_LEN" - - #Wait in case of filesystem sync issues - sleep 60 - echo "Attempting a filesystem sync" - sync - sleep 10 - - # Parse - echo "Parsing Trace" - fsp-trace -s $sb/../obj/trexStringFile $sb/../simics/occ_trace.bin | strings | tee $sb/../simics/occ_trace.txt -} - -function runTestApplet() -{ - applet=$1 - - if [ ! -d $sb/../unit_test ]; then - mkdir -p $sb/../unit_test - fi - - pushd $sb/../unit_test > /dev/null - - rm $sb/../unit_test/* - - echo "------------------------------------------" - echo "Running OCC Testcase Applet -- $applet" - echo "------------------------------------------" - testAppletFilename=$applet - split -b2k $testAppletFilename `basename $testAppletFilename`. - NN=0 - for f in $(find . -xtype f -name "`basename $testAppletFilename`.*" -print | sed 's=.*/==') - do - SS=`printf "%02x" $NN` - - simicsFspToOccCmd "40" "E0"$SS"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" "$sb/../unit_test/$f" - - NN=$((NN+1)) - done - - simicsFspToOccCmd "40" "E0FF" - - sleep 20 - - popd > /dev/null -} - - -############################################################################## -## -## parse args -## -############################################################################## -## verbose is the default. -VERBOSE=" --verbose" -NOWIN="--nowin" ## remote execution does not have a display -COMPILE_GCOV=0 -GCOV=0 -FSPLESS_SIM=0 -UNIT_TEST=0 -WATCH_SIM=0 -ENABLE_VPM="" -RUN_STANDARD_CMDS=1 -EXTEND_SCRIPT_ARRAY=() - -while [ "$1" ] -do - case "$1" in - -m|--machine) - shift - MACHINE=$1 - ;; - -g|--gcov) - GCOV=1 - ;; - -u|--unit-test) - UNIT_TEST=1 - ;; - -e|--extend-test) - # This can be passed multiple times - shift - EXTEND_SCRIPT_ARRAY=("${EXTEND_SCRIPT_ARRAY[@]}" "$1") # Push - ;; - -c|--compile-gcov) - COMPILE_GCOV=1 - ;; - -f|--fspless) - FSPLESS_SIM=1 - ;; - -n|--skip-std-cmds) - RUN_STANDARD_CMDS=0 - ;; - -q|--quiet) - VERBOSE="" - ;; - -w|--show-window) - NOWIN="" - ;; - -t|--watch-sim) - WATCH_SIM=1 - ;; - --enable-vpm) - ENABLE_VPM="" - ;; - *) - echo "Usage:" - echo " [-m | --machine] <machine> Specify machine type to run test on" - echo " [-g | --gcov] Grab GCOV data" - echo " [-u | --unit-test] Run UnitTests" - echo " [-e | --extend-test] <path/to/fileOrDir> Run tests from specified file" - echo " [-c | --compile-gcov] Grab GCOV data" - echo " [-f | --fspless] FSPLESS Sim Compile of OCC; no TMGT cmds" - echo " [-n | --skip-std-cmds] Don't run standard FSP commands test" - echo " [-q | --quiet] Don't dump so much output" - echo " [-w | --show-window] Show a Simics Output xterm window" - echo " [-t | --watch-sim] Watch Simics commands and output via tail -f" - echo " [--enable-vpm] Tell VPM to run" - echo "" - echo "Example:" - echo " # Run a test doign pretty much everything" - echo " $0 -m tuleta -c -g -u -w -t -e \$sb/first_test.sh -e \$sb/test_dir/" - echo "" - echo "" - exit 1 - ;; - esac - shift -done - -echo "Variables Passed:" -echo "---------------------------" -echo "MACHINE: $MACHINE" -echo "GCOV: $GCOV" -echo "FSPLESS_SIM: $FSPLESS_SIM" -echo "VERBOSE: $VERBOSE" -echo "COMPILE_GCOV: $COMPILE_GCOV" -echo "UNIT_TEST: $UNIT_TEST" -echo "NOWIN: $NOWIN" -echo "ENABLE_VPM: $ENABLE_VPM" -echo "EXT_SCRIPT: ${EXTEND_SCRIPT_ARRAY[@]}" -echo "" - -# Quit if we aren't in a sandbox -if [ -z $sb ]; then - exit 1 -fi - -waitkb - -############################################################################## -## -## Compile for code coverage -## -############################################################################## -if [ $COMPILE_GCOV -eq 1 ] -then - pushd $sb/occc/405/ - - make clean && make FSPLESS_SIMICS=1 GCOV_CODE_COVERAGE=1 && make combineImage - - if [ $? -ne 0 ]; then - echo "Compile failed, exiting" - exit 1; - fi - - # Compile Pstate Table - pushd $sb/occc/405/lib/test > /dev/null - make pss.bin - popd > /dev/null - - if [ $? -ne 0 ]; then - echo "Pstate Compile failed, exiting" - exit 1; - else - if [ ! -d $sb/../obj/ppc/occc/405/occ ]; then - mkdir -p $sb/../obj/ppc/occc/405/occ - fi - - echo "Copying output files to obj/ppc..." - cp -f $sb/occc/405/image.bin $sb/../obj/ppc/occc/405/ - cp -f $sb/occc/405/occ/occ.out $sb/../obj/ppc/occc/405/occ/ - cp -f $sb/occc/405/occApplet/testApplet/*.bin $sb/../obj/ppc/occc/405/occApplet/testApplet/ - fi -fi - - -############################################################################## -## -## set up -## -############################################################################## -DEFAULT_OCC_MACHINE="occ_alone" - -MACHINE=${MACHINE:-$DEFAULT_OCC_MACHINE} -export MACHINE - -timestamp=`date +'%H:%M:%S'` -echo "$timestamp Starting autosample test..." - -waitkb - -# Run set up in current shell -echo "run autosimsetup.." -. autosimsetup - -waitkb - -###### Start the simics server -echo "Starting simics server in sandbox $SANDBOX on machine $MACHINE" -autosim $NOWIN $VERBOSE --startserver --wp --sandbox $SANDBOX --machine $MACHINE -if [ $? -ne 0 ] ; then - echo "ERROR: Unable to start simics server $?" - exit 1 -fi - -waitkb - - -############################################################################## -## -## Start simics and wait for it to reach standby -## -############################################################################## -echo "Starting simics" -#autosim $VERBOSE --startsim --chkpt standby <<< chkpt not working yet -autosim $NOWIN $VERBOSE --startsim --norun -if [ $? -ne 0 ] ; then - echo "ERROR: Unable to start simics $?" - stopserver ## kill the server again. - exit 1 -fi - - -waitkb - -if [ $WATCH_SIM -eq 1 ]; then - xterm -hold -e tail -f ~/autosim.log & -fi - -############################################################################## -## -## Load OCC and run it until steady state -## -############################################################################## - -loadocc -runsimics - -## Need to wait here for OCC to get up to a steady state -sleep 30 - -# Print out Simulation Time -simicsCmd 'ptime' - -waitkb - -############################################################################## -## -## Run FSP commands needed to get OCC into working Active State -## -############################################################################## - -#if [ -z $FSPLESS_SIM ] -#then -# simicsFspToOccCmd "21" "03000000" # Set Slave -# sleep 5 -# simicsFspToOccCmd "21" "03010000" # Set Master -# sleep 5 -# simicsFspToOccCmd "20" "01030000" # Set Active -#fi - -############################################################################## -## -## Start running OCC testcases -## -############################################################################## - -if [ $RUN_STANDARD_CMDS -eq 1 ]; -then - # Poll - simicsFspToOccCmd "00" "01" - - # QFL - simicsFspToOccCmd "01" - - # ClearElog - simicsFspToOccCmd "12" "FF" - - # CNFG -- Invalid - simicsFspToOccCmd "21" "05" - simicsFspToOccCmd "20" "00010000" # Set Standby - simicsFspToOccCmd "21" "03000000" # Set Slave - simicsFspToOccCmd "21" "03010000" # Set Master - simicsFspToOccCmd "20" "00030000" # Set Active - simicsFspToOccCmd "21" "04010000" # APSS Config Data - simicsFspToOccCmd "21" "020003020C22030C33050C00" # Freq Operation Points - if [ -f "$sb/occc/405/lib/test/pss.bin" ]; then - simicsFspToOccCmd "21" "01000000" "$sb/occc/405/lib/test/pss.bin" # PstateSuperStructure - fi - - # Debug - simicsFspToOccCmd "40" "00" - - # SMS - simicsFspToOccCmd "20" "01000000" # SMS BadVersion - simicsFspToOccCmd "20" "00010000" # NoChange, Standby - sleep 10 - simicsFspToOccCmd "20" "00030100" # Nominal, Active - sleep 10 - simicsFspToOccCmd "20" "00000200" # Benchmark - sleep 10 - simicsFspToOccCmd "20" "00000300" # Turbo - sleep 10 - simicsFspToOccCmd "20" "00000400" # Safe - sleep 10 - simicsFspToOccCmd "20" "00000500" # PowerSave - sleep 10 - simicsFspToOccCmd "20" "00000600" # Dynamic PowerSave - sleep 10 - simicsFspToOccCmd "20" "00000700" # Min Freq - sleep 10 - simicsFspToOccCmd "20" "00000800" # Invalid - sleep 10 - simicsFspToOccCmd "20" "00000900" # Invalid - sleep 10 - simicsFspToOccCmd "20" "00000A00" # Invalid - sleep 10 - simicsFspToOccCmd "20" "00000B00" # FFO - sleep 10 - simicsFspToOccCmd "20" "00000C00" # SuperTurbo - sleep 10 - simicsFspToOccCmd "20" "00000100" # Nominal - - # AME Passthrough - simicsFspToOccCmd "41" "3C001C" # AME component level constants - simicsFspToOccCmd "41" "3C001D" # Just return 2 bytes of zero data - simicsFspToOccCmd "41" "3C0021" # Clear Min/Max of all sensors - simicsFspToOccCmd "41" "3C0025" # Get sensors info - simicsFspToOccCmd "41" "3C00FEAABBCCDD" # Echo - simicsFspToOccCmd "41" "3C00FF0010" # Return sequential bytes string - simicsFspToOccCmd "41" "3B0003" # CPU Present bitmask - -fi - - -############################################################################## -## -## Extend this script -## * Extensions run in the order they are sent on the command line -## * Within a directory, they are run in "sort" order, and only files that -## have the executable bit set will be run -## -############################################################################## -for index in "${EXTEND_SCRIPT_ARRAY[@]}" -do - EXTEND_SCRIPT_FILENAME=$index - if [ ! -z $EXTEND_SCRIPT_FILENAME ]; then - if [ -d $EXTEND_SCRIPT_FILENAME ]; then - for extend in $(find $EXTEND_SCRIPT_FILENAME -xtype f -perm -001 | sort) - do - echo "---------------------------------------------" - echo "Running OCC Script Extension via Dir -- $extend" - echo " * Only runs files with executable bit set *" - echo "---------------------------------------------" - source $extend - done - elif [ -e $EXTEND_SCRIPT_FILENAME ]; then - echo "------------------------------------------" - echo "Running OCC Script Extension -- $EXTEND_SCRIPT_FILENAME" - echo "------------------------------------------" - source $EXTEND_SCRIPT_FILENAME - fi - fi -done - - -############################################################################## -## -## Automatic Unit Tests based on test Applets -## -############################################################################## -if [ $UNIT_TEST -eq 1 ] -then - for applet in $(find $sb/../obj/ppc/occc/405/occApplet/testApplet/ -xtype f \( -name "errl*.bin" -o -name "trace*.bin" -o -name "apss*.bin" \) ) - do - runTestApplet $applet - done - -fi - -############################################################################## -## -## Dump an OCC Trace -## -############################################################################## -occTrace - -############################################################################## -## -## Code Coverage Processing -## -############################################################################## -if [ $GCOV -eq 1 ] -then - timestamp_gcov=`date +"%s"` - - # Save off full OCC binary to generate code coverage from - simicsCmd 'p8Proc0.OccComplexSlot.OccSimpleSlot.sram_image.save occ_gcov.bin' - #Wait in case of filesystem sync issues - sleep 10 - # Build the syms file out of the occ.out file - pushd $sb/../obj/ppc/occc/405/occ > /dev/null - nm -n occ.out > occ.syms - popd > /dev/null - - # Move old gcov output direcories if they exist - for f in `find . -xtype d -name "gcov.output*" | xargs -n 1 basename`; do mv -v $f _$f; done - - #Delete any old gcda data files - pushd $sb/occc/405 > /dev/null - find . -xtype f -name "*.gcda" -exec rm {} + - popd > /dev/null - - # Build GCDA files out of occ_gcov.bin - $sb/occc/405/occ/tools/occGcov.pl - - # Copy GCDA files into directory structure - for f in `find . -xtype d -name "gcov.output*" | xargs -n 1 basename`; - do - echo "GCOV data in $f" - pushd $f > /dev/null - echo "rsync -r -a -v .`readlink -f $sb`/occc/405/occ/ $sb/occc/405/occ/" - rsync -r -a -v .`readlink -f $sb`/occc/405/occ/ $sb/occc/405/occ/ - popd > /dev/null - done - - # Build up LCOV HTML output - pushd $sb/occc/405/occ > /dev/null - lcov -b . --capture --directory . --output-file coverage.info - genhtml coverage.info --output-directory /tmp/gcov_$SANDBOX_$timestamp_gcov - popd > /dev/null - - # Open output in firefox - firefox /tmp/gcov_$SANDBOX_$timestamp_gcov/index.html & -fi - -waitkb - - -############################################################################## -## -## Calculate test results if applicable -## -############################################################################## - -echo "====> dump totaltests..." -autosim $NOWIN --simcmd "(ptime -t)" 1> /tmp/totaltests.log 2> /dev/null -if [ $? -ne 0 ] ; then - echo "ERROR: Unable to run $?" - stopsim - stopserver - exit 1 -fi -totaltests=`cat /tmp/totaltests.log | xargs echo -n` - - -############################################################################## -## -## done. Stop the simulation -## -############################################################################## -stopsim - - -## now stop the server. -stopserver - - -############################################################################## -## -## Print out results in footer -## -############################################################################## -timestamp_end=`date +'%H:%M:%S'` - -echo "Started: $timestamp" -echo "Ended: $timestamp_end" - -exit 0 - - diff --git a/src/occ/tools/occ_autotest_extend.example b/src/occ/tools/occ_autotest_extend.example deleted file mode 100644 index 0da932c..0000000 --- a/src/occ/tools/occ_autotest_extend.example +++ /dev/null @@ -1,46 +0,0 @@ -############################################################################## -# -# Example OCC Autotest Extension File -# -# Purpose of these scripts are to extend the OCC Autotest without making -# one gigantic script. -# -# RULES -# ------------------------------------- -# These scripts will only execute if they are specified on the cli, and if they -# are marked execuable (chmod a+x) -# -# If a directory is specified on the cli, the scripts in that directory will be -# run in the order that occurs during `find . -xtype f -perm -001 | sort` -# -# This file is run as a bash script, so you can do anything that bash can do. -# That includes calling external programs, file operations, sleep, echo, etc. -# -# Anything that you can do in the autotest you *could* do here, but to keep it -# simple, here are some thing that are most useful, and probably what you should -# stick to. -# -# Variables Available: -# $sb: All Sandbox / Environment variable are available -# $MACHINE: Machine Type Simics is simulating -# $ENABLE_VPM: Did caller request VPM to start -# -# Functions Available: -# Send a simics command -# simicsCmd "command" -# -# Send a fsp command (once FSP is up...) -# fspCmd "command" : -# -# Run a test applet -# runTestApplet "path/to/applet" -# -# Send OCC a command from the FSP (fake out FSP if it's not there) -# simicsFspToOccCmd "command" [data] [datafile] -# Example: simicsFspToOccCmd "00" "01" # Send a Poll Command -# -# Happy Scripting! -# -############################################################################## - - diff --git a/src/occ/tools/occ_fsp_fakeout.py b/src/occ/tools/occ_fsp_fakeout.py deleted file mode 100755 index c681d47..0000000 --- a/src/occ/tools/occ_fsp_fakeout.py +++ /dev/null @@ -1,302 +0,0 @@ -# @file - occ_fsp_fakeout.py -# @brief Create Simics Commands for Reading AMEC Sensors -# -# Flag Def/Fea Userid Date Description -# ------- ---------- -------- ---------- ---------------------------------- -# thallet 07/01/2012 Created - - -from time import sleep -from random import randint -import sys -import re - -import struct -import array -import os - -G_occ_command = [] -G_occ_response = [] -G_occ_resp_rc = {0x00:'ERRL_RC_SUCCESS', - 0x01:'ERRL_RC_CONDITIONAL_SUCCESS', - 0x11:'ERRL_RC_INVALID_CMD', - 0x12:'ERRL_RC_INVALID_CMD_LEN', - 0x13:'ERRL_RC_INVALID_DATA', - 0x14:'ERRL_RC_CHECKSUM_FAIL', - 0x15:'ERRL_RC_INTERNAL_FAIL', - 0x16:'ERRL_RC_INVALID_STATE'} - -def occ_calc_cksm( ): - global G_occ_command - cksm = sum( G_occ_command ) - cksm_16 = cksm & 0xFFFF - cksm_hi = cksm_16/256 - cksm_lo = cksm_16%256 - cksm_data = [cksm_hi,cksm_lo] - return cksm_data - - -def occ_send_command( occ_idx ): - simics_occ_send_commands = [] - - # SCOM to set up OCBAR - simics_occ_send_commands.append("p8Proc" + occ_idx + ".proc_chip.invoke parallel_store SCOM 0x6b010 \"0xffff6000_00000000\" 64") - - # SCOMs to send data to OCC sram (8bytes per scom, so must pad) - full = (len(G_occ_command)/8) - partial = (len(G_occ_command)%8) - - # Pad out to 8byte boundry - for byte in range((8-partial)): - G_occ_command.append(0); - - # Build up simics commands - for byte in range(full+1): - simics_occ_send_commands.append( "p8Proc" + occ_idx + ".proc_chip.invoke parallel_store SCOM 0x6b015 \"0x" + \ - '%02x' % (G_occ_command[((byte*8) + 0)]) + \ - '%02x' % (G_occ_command[((byte*8) + 1)]) + \ - '%02x' % (G_occ_command[((byte*8) + 2)]) + \ - '%02x' % (G_occ_command[((byte*8) + 3)]) + \ - "_" + \ - '%02x' % (G_occ_command[((byte*8) + 4)]) + \ - '%02x' % (G_occ_command[((byte*8) + 5)]) + \ - '%02x' % (G_occ_command[((byte*8) + 6)]) + \ - '%02x' % (G_occ_command[((byte*8) + 7)]) + \ - "\" 64") - - # SCOM to send doorbell to OCC - simics_occ_send_commands.append("p8Proc" + occ_idx + ".proc_chip.invoke parallel_store SCOM 0x6b035 \"0x11111111_22222222\" 64") - - # Send SCOMs - for line in simics_occ_send_commands: - cli.quiet_run_command(line) - - -def occ_read_command( occ_idx, i_length=128 ): - simics_occ_read_commands = [] - - # SCOM to set up OCBAR - simics_occ_read_commands.append("p8Proc" + occ_idx + ".proc_chip.invoke parallel_store SCOM 0x6b010 \"0xffff7000_00000000\" 64") - - # Build up simics commands to read the requested amount of data from SRAM - for doublewords in range((i_length/8)): - simics_occ_read_commands.append("p8Proc" + occ_idx + ".proc_chip.invoke parallel_load SCOM 0x6b015 64") - - # Send SCOMs - for line in simics_occ_read_commands: - rsp = cli.run_command(line) - - -def occ_read_command_sram_direct( occ_idx ): - global G_occ_response - - # Clear out response buffer - G_occ_response = [] - - simics_occ_read_commands = [] - - # Build up simics command to read SRAM - simics_occ_read_commands.append("p8Proc" + occ_idx + ".OccComplexSlot.OccSimpleSlot.cpu.x 0xffff7000 128") - - # Convert SRAM read into bytes, then fill in G_occ_response array - for line in simics_occ_read_commands: - data = [] - rsp = cli.quiet_run_command(line) - - # Loop through lines returned, and do patter matching to split into bytes - for byteline in rsp[1].split('\n'): - #Pattern Example: v:0xffff7000 aa00 0000 0b03 0101 ff00 0000 00f4 0506 ................ - data = re.match(r'(v.0xffff7...) (..)(..) (..)(..) (..)(..) (..)(..) (..)(..) (..)(..) (..)(..) (..)(..) (.{16})',byteline,re.M) - # If match, add to G_occ_response - if data: - G_occ_response.append(int(data.group(2) ,16)) - G_occ_response.append(int(data.group(3) ,16)) - G_occ_response.append(int(data.group(4) ,16)) - G_occ_response.append(int(data.group(5) ,16)) - G_occ_response.append(int(data.group(6) ,16)) - G_occ_response.append(int(data.group(7) ,16)) - G_occ_response.append(int(data.group(8) ,16)) - G_occ_response.append(int(data.group(9) ,16)) - G_occ_response.append(int(data.group(10),16)) - G_occ_response.append(int(data.group(11),16)) - G_occ_response.append(int(data.group(12),16)) - G_occ_response.append(int(data.group(13),16)) - G_occ_response.append(int(data.group(14),16)) - G_occ_response.append(int(data.group(15),16)) - G_occ_response.append(int(data.group(16),16)) - G_occ_response.append(int(data.group(17),16)) - - - -def hexstr2bytearray( data_str ): - # Convert a ascii hex string of indeterminite length to byte array - byte_array = [] - if data_str: - for x in xrange(0, len(data_str), 2): - byte_array.append(int(data_str[x:x+2], 16)) - return byte_array - - -def binfile2bytearray( file_name ): - # Convert a binary of indeterminite length to byte array - data_file = open(file_name,"rb") - byte_array = array.array('B') - fsize = os.path.getsize(file_name) - fsize %= 4096 - byte_array.fromfile(data_file,fsize) - byte_list = byte_array.tolist() - return byte_list - - -def occ_build_command(command, data, seq='AA'): - global G_occ_command - - # Command is string 'XX' ascii hex representation - # Seq is string 'XX' ascii hex representation - # Data is array of data bytes - - # Empty G_occ_command buffer - G_occ_command = [] - - #Add seq num into byte 0 - G_occ_command.insert(0,int(seq,16)) - - #Add command into byte 1 - G_occ_command.insert(1,int(command,16)) - - # Add data length - data_len_hi = (len(data)/256) - data_len_lo = (len(data)%256) - G_occ_command.insert(2,data_len_hi) - G_occ_command.insert(3,data_len_lo) - - # Add data - G_occ_command = G_occ_command + data - - # Add checksum - cksm = occ_calc_cksm() - G_occ_command = G_occ_command + cksm - - -def occ_parse_command_generic(): - print "----------------------" - print "Sent OCC Command" - print "----------------------" - print "SEQUENCE: %02x" % G_occ_command[0] - print "COMMAND : %02x" % G_occ_command[1] - print "DATA_LEN: %02x%02x" % (int(G_occ_command[2]),int(G_occ_command[3])) - print "DATA :", - data_len = int(int(G_occ_command[2])*256 + int(G_occ_command[3])) - for byte in range((data_len -1)): - print "%02x" % G_occ_command[byte+4], - print "" - print "CHECKSUM: %02x%02x" % (G_occ_command[ (data_len + 4) ], G_occ_command[ (data_len + 5 ) ]) - - -def occ_parse_response_generic(): - print "----------------------" - print "Received OCC Response" - print "----------------------" - print "SEQUENCE: %02x" % G_occ_response[0] - print "COMMAND : %02x" % G_occ_response[1] - print "RC : %02x (%s)" % (G_occ_response[2],G_occ_resp_rc[ G_occ_response[2] ]) - print "DATA_LEN: %02x%02x" % (int(G_occ_response[3]),int(G_occ_response[4])) - print "DATA :", - data_len = int(int(G_occ_response[3]) + int(G_occ_response[4])) - for byte in range((data_len )): - print "%02x" % G_occ_response[byte+5], - print "" - print "CHECKSUM: %02x%02x" % (G_occ_response[ (data_len + 5) ], G_occ_response[ (data_len + 6 ) ]) - print "" - - -def occ_trace_grabber(occid=0): - cli.quiet_run_command("pipe \"p8Proc" + occid + ".OccComplexSlot.OccSimpleSlot.oci_space.x (p8Proc" + occid + ".OccComplexSlot.OccSimpleSlot.cpu.sym g_trac_inf) 0x6000\" \"sed 's/^p:0x........ //g' | sed 's/ ................$//g' | sed 's/ //g' | xxd -r -p> test.bin\"") - cli.run_command("!fsp-trace -s " + os.getenv("sb") + "/../obj/trexStringFile test.bin | strings") - - -#---------------------------------------------------------- -# Simics Helper functions -# - -def occ_fsp_command(command,data="",datafile="",seq="",occid=0): - if datafile: - # If binary data file is passed in, append that to any other data bytes we have - occ_build_command(command=command, data=hexstr2bytearray(data) + binfile2bytearray(datafile)) - else: - # Do this without data bytes - occ_build_command(command=command, data=hexstr2bytearray(data)) - - # Send Command - occ_send_command(str(int(occid or 0))) - # Parse out the command we just sent to the screen - occ_parse_command_generic() - - -def occ_fsp_response(length,occid=0): - # Get response from SCOMs - occ_read_command(str(int(occid or 0))) - # Get response from SRAM -- same as above, but easier to parse - occ_read_command_sram_direct(str(int(occid or 0))) - # Parse out the response we just sent to the screen - occ_parse_response_generic() - - -def occ_trace(occid=0): - occ_trace_grabber(str(int(occid or 0))) - - - - -#---------------------------------------------------------- -# Simics Command: occ-fsp-cmd -# -new_command("occ-fsp-cmd", occ_fsp_command, - args = [arg(str_t, "command"),arg(str_t, "data","?"),arg(str_t, "datafile","?"),arg(str_t, "seq","?"),arg(int_t, "occid","?")], - alias = "", - type = "occ-fw-module-commands", - short = "Send FSP Command to OCC", - doc_items = [("NOTE", "")], - see_also = ["occ-fsp-rsp"], - doc = """ - <b>occ-fsp-cmd</b> is used to send commands to OCC. Checksum is automatically calculated.\n - <i>command</i> is the hex value of the command to be sent. i.e. "21"\n - <i>data</i> is the hex data that should be sent. i.e "AA55BB66CC77"\n - <i>datafile</i> is filename of a binary data file that should be sent. It will be added after the data arg. i.e. "pss.bin"\n - <i>seq</i> is the sequence number, and it currently ignored, and defaults to AA\n - <i>occid</i> is the OCC ID Number you want to send the command to (defaults to 0)\n - <b>Example:</b> occ-fsp-cmd command="21" data="0B" datafile="0123.bin" \n - will build a command like "AA2100050B0001020300E1" -""") - -#---------------------------------------------------------- -# Simics Command: occ-fsp-rsp -# -new_command("occ-fsp-rsp", occ_fsp_response, - args = [arg(int_t, "size","?"),arg(int_t, "occid","?")], - alias = "", - type = "occ-fw-module-commands", - short = "Get FSP Command Response from OCC", - doc_items = [("NOTE", "")], - see_also = ["occ-fsp-cmd"], - doc = """ - <b>occ-fsp-rsp</b> is used to get/parse response from OCC. - <i>occid</i> is the OCC ID Number you want to send the command to\n - <i>size</i> - is the only other argument, and currently is ignored""") - - -#---------------------------------------------------------- -# Simics Command: occ-trace -# -new_command("occ-trace", occ_trace, - args = [arg(int_t, "occid","?")], - alias = "", - type = "occ-fw-module-commands", - short = "Get Trace from OCC", - doc_items = [("NOTE", "")], - see_also = ["occ-fsp-cmd"], - doc = """ - <b>occ-trace</b> is used to get trace from OCC. - <i>occid</i> is the OCC ID Number you want to send the command to\n""") - diff --git a/src/occ/tools/occ_gdb.pl b/src/occ/tools/occ_gdb.pl deleted file mode 100755 index c5b5de1..0000000 --- a/src/occ/tools/occ_gdb.pl +++ /dev/null @@ -1,282 +0,0 @@ -#!/usr/bin/perl -############################################################################## -# -# @file occ_gdb.pl -# -# @author Timothy Hallett -# -# @brief Perl script for starting OCC Simics & GDB -# -# @verbatim -# -# Updates: -# v0.1.0 01/10/2012 -- thallet -- created. -# v0.1.1 01/27/2012 -- thallet -- Allow starting @ __ssx_boot or in OCC -# bootloader. -# -# @endverbatim -# -# -############################################################################## - - - -use strict; - -use lib "/afs/rch/usr4/thallet/public/bin/"; -use OccSimicsAutomate; - -my $VERSION = "0.1.1"; - -#---------------------------------------------------------- -# GDB/DDD Related Globals -#---------------------------------------------------------- -my $G_gdb_path = "/gsa/ausgsa/home/t/h/thallet/web/shared/gdb_ppc_eabi/usr/local/bin/powerpc-\*-eabi-gdb"; -my $G_ddd_path = "ddd --debugger $G_gdb_path"; -my $G_gdbscript_filename = "/tmp/occgdb.".$ENV{"USER"}.".txt"; -my $G_gdb_cmd_file = ""; -my $G_gdb = 1; -my $G_ddd = 0; -my $G_xterm = 1; -my $G_custom_term = 0; -my $G_nexus = 0; -my $G_ssx_boot_start = 0; -my $G_occ_bootloader_start = 0; - - -#---------------------------------------------------------- -# Simics Related Globals -#---------------------------------------------------------- -my $port = "0"; -my $name = "occgdb"; -my $hostname = ""; - - - -#---------------------------------------------------------- -# Handle Args -#---------------------------------------------------------- -while ($ARGV = shift) -{ - if ($ARGV =~ m%^-d%i) - { - # Use DDD instead of GDB - $G_gdb = 0; - $G_ddd = 1; - } - elsif ($ARGV =~ m%^-f%i) - { - # Allow user to specify file with gdb commands - # that will be run after OCC GDB setup commands - $G_gdb_cmd_file = shift; - } - elsif ($ARGV =~ m%^-n%i) - { - # Allow user to specify file with gdb commands - # that will be run after OCC GDB setup commands - $G_nexus = 1; - } - elsif ($ARGV =~ m%^-t%i) - { - $G_xterm = 0; - } - elsif ($ARGV =~ m%^-p%i) - { - # Allow user to specify path to gdb - $G_gdb_path = shift; - $G_ddd_path = "ddd --debugger $G_gdb_path" - } - elsif ($ARGV =~ m%^-s%i) - { - $G_ssx_boot_start = 1; - } - elsif ($ARGV =~ m%^-x%i) - { - $G_occ_bootloader_start = 1; - } - else - { - # Use defaults - dump_help(); - exit; - } -} - -my @months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec); -my @weekDays = qw(Sun Mon Tue Wed Thu Fri Sat Sun); -my ($second, $minute, $hour, $dayOfMonth, $month, $yearOffset, $dayOfWeek, $dayOfYear, $daylightSavings) = localtime(); -my $year = 1900 + $yearOffset; -my $hhmmss = sprintf("%02d:%02d:%02d",$hour,$minute,$second); -my $G_time = @weekDays[$dayOfWeek]." ".$months[$month]." ".$dayOfMonth.", $year ".$hhmmss; - -#---------------------------------------------------------- -# Start Simics, start OCC, start GDB, then hand control to user -#---------------------------------------------------------- -if(1) -{ - #---------------------------------------------------------- - # Start Simics & run OCC in Simics until main(), __ssx_boot or - # first instruction. - #---------------------------------------------------------- - my $simics = new OccSimicsAutomate; - if($G_ssx_boot_start) - { - $simics->startAndRunOccUntilSsxBoot(); - } - elsif($G_occ_bootloader_start) - { - $simics->start_simics(); - $simics->getSimicsTime(); - } - else - { - $simics->startAndRunOccUntilMain(); - } - - #-------------------------------------------------------- - # Start GDB Session - #-------------------------------------------------------- - $simics->simics_cmd("new-gdb-remote port=$port name=$name"); - - - #-------------------------------------------------------- - # Get Hostname Simics is running on - #-------------------------------------------------------- - $simics->simics_cmd("!hostname > occ_simics_hostname"); - sleep(5); - open(HOSTNAME,"<".$ENV{"sb"}."/../simics/occ_simics_hostname"); - while(<HOSTNAME>) - { - if ($_ =~ /ibm/){$hostname = $_; chomp($hostname);} - } - close(HOSTNAME); - $simics->simics_cmd("!echo \"\" > occ_simics_hostname"); - - - #-------------------------------------------------------- - # Get Port GDB is listening on - #-------------------------------------------------------- - $simics->simics_cmd("pipe \"print -d $name->listen\" \"cat > occ_simics_port\""); - sleep(5); - open(PORT,"<".$ENV{"sb"}."/../simics/occ_simics_port"); - while(<PORT>) - { - if ($_ =~ /[0-9]{4,}/){$port = $_; chomp($port);} - } - close(PORT); - $simics->simics_cmd("!echo \"\" > occ_simics_port"); - - - #-------------------------------------------------------- - # Create a file with GDB Initialization commands - #-------------------------------------------------------- - my @gdb_start_commands = - ( - "echo \"Automating GDB Connection to OCC in Simics: $hostname:$port\n", - "set architecture powerpc:common\n", - "symbol-file ".$ENV{"sb"}."/occ/occ.out\n", - "target remote $hostname:$port" - ); - open(GDB_SCRIPT,">$G_gdbscript_filename"); - foreach(@gdb_start_commands) - { - print GDB_SCRIPT $_; - } - close(GDB_SCRIPT); - - #-------------------------------------------------------- - # If user passed in a GDB command file, append it to GDBscript - # we just created - #-------------------------------------------------------- - if($G_gdb_cmd_file) - { - system("cat $G_gdb_cmd_file >> $G_gdbscript_filename"); - } - - #-------------------------------------------------------- - # Make simics command prompt interactive - # or tell user that it is not interactive - #-------------------------------------------------------- - if($G_xterm == 0) - { - system("echo \"Simics Command Line is Unavailable while running GDB\""); - } - - #-------------------------------------------------------- - # Now start GDB or DDD, passing in the command file - #-------------------------------------------------------- - if($G_ddd) - { - system("$G_ddd_path --command=$G_gdbscript_filename"); - } - elsif($G_nexus) - { - # Don't start GDB - } - elsif($G_xterm) - { - system("xterm -bg darkolivegreen -fg wheat -sb -sl 10000 -geometry 120x40 -hold -title \"GDB -> OCC [".$ENV{"SANDBOX"}."] @ $hostname:$port, started $G_time\" -e $G_gdb_path --command=$G_gdbscript_filename &"); - } - elsif($G_custom_term) - { - system("$G_custom_term \"$G_gdb_path --command=$G_gdbscript_filename\""); - } - else - { - system("$G_gdb_path --command=$G_gdbscript_filename"); - } - - #-------------------------------------------------------- - # Make simics command prompt interactive - #-------------------------------------------------------- - $simics->interact(); - - #-------------------------------------------------------- - # When we are done, close simics & clean up files - #-------------------------------------------------------- - $simics->close(); - system("if [ -e $G_gdbscript_filename ]; then rm $G_gdbscript_filename; fi"); -} - - -sub dump_help -{ - my $name = "occgdb.pl"; - - print "\n"; - print "Usage: $name [options]\n"; - print "\n"; - print "Version: $VERSION\n\n"; - - print "Usage Notes:\n"; - print " This script will start simics and make a gdb or ddd connection to it automatically.\n"; - print " - Must be run from sandbox\n"; - print " - DDD must be in PATH\n"; - - print "\n"; - - print "Options:\n"; - print "\t[-d] Use DDD instead of GDB\n"; - print "\t[-n] Use Nexus Debugger instead of GDB (must manually start & attach Nexus)\n"; - print "\t[-t] Don't start a seperate xterm to do debugging (no simics interaction allowed) \n"; - print "\t[-f <gdb cmd file>] Use <gdb command file> to run gdb commands after OCC has started\n"; - print "\t[-p <path/to/gdb>] Use <path/to/gdb> as the gdb executable\n"; - print "\t[-s] Don't start @ OCC main(), start @ __ssx_boot() instead.\n"; - print "\t[-x] Don't start @ OCC main(), start @ first instruction (bootloader)) \n"; - - print "\n"; -} - - -############################################################################## -# Notes: -# ---------------------------------------------------------------------------- -# -# GDB Command File Example Commands: -# graph display g_amec_sys.fw.ameintdur -# break rtl_do_tick -# c -# print g_amec_sys.fw.ameintdur -# - - diff --git a/src/occ/tools/occ_gdb.py b/src/occ/tools/occ_gdb.py deleted file mode 100755 index 0344187..0000000 --- a/src/occ/tools/occ_gdb.py +++ /dev/null @@ -1,116 +0,0 @@ -# @file - occ_gdb.py -# @brief Start GDB on OCC -# -# Flag Def/Fea Userid Date Description -# ------- ---------- -------- ---------- ---------------------------------- -# thallet 08/14/2012 Created - - -from time import sleep -from random import randint -import sys -import re - -G_gdb_path = "/gsa/ausgsa/home/t/h/thallet/web/shared/gdb_ppc_eabi/usr/local/bin/powerpc-\*-eabi-gdb"; -G_ddd_path = "ddd --debugger " + G_gdb_path; -G_gdb_port = 0 -G_gdb_hostname = "" - -############################################################################## -########################################################### -# Functions -########################################################### -############################################################################## - -def start_gdb_server( occ_idx ): - global G_gdb_port - global G_gdb_hostname - - # TODO: Add a check here for not restarting gdb if already started - tick = cli.quiet_run_command("object-exists occgdb" + str(occ_idx)) - exists = tick[0] - if exists: - print "Object occgdb" + str(occ_idx) + "already exists" - else: - tick = cli.run_command("new-gdb-remote cpu = " + G_occ_list[int(occ_idx)] + ".cpu " + "port=0 name=occgdb" + str(occ_idx)) - - tick = cli.run_command("occgdb" + str(occ_idx) + "->listen") - port = tick - tick = cli.quiet_run_command("!hostname") - hostname = tick[0] - - print "Port: %d" % port - print "Hostname: %s" % hostname - - gdb_start_commands = [ - "echo \"Automating GDB Connection to OCC in Simics: " + hostname +": " + str(port) + "\n", - "set architecture powerpc:common\n", - "symbol-file " + os.getenv("sb") + "/../obj/ppc/occc/405/occ/occ.out\n", - "target remote " + hostname + ":" + str(port) + "\n", - "handle SIGTRAP nostop noprint\n", - ] - fout = open("occgdb_" + str(occ_idx) + "_gdb_cmds.txt","w") - for cmd in gdb_start_commands: - fout.write(cmd) - fout.close() - - G_gdb_port = port - G_gdb_hostname = hostname - - return - - -def ddd_connect( occ_idx ): - os.system(G_ddd_path + " --command=occgdb_" + str(occ_idx) + "_gdb_cmds.txt &") - return - -def gdb_connect( occ_idx ): - if occ_idx == 0: - os.system("xterm -bg darkolivegreen -fg wheat -sb -sl 10000 -geometry 120x40 -hold -title \"GDB -> OCC["+ str(occ_idx) +"] [" + os.getenv("SANDBOX") + "] @ " + G_gdb_hostname + ":" + str(G_gdb_port) + "\" -e " + G_gdb_path + " --command=occgdb_" + str(occ_idx) + "_gdb_cmds.txt &") - else: - os.system("xterm -bg honeydew4 -fg wheat -sb -sl 10000 -geometry 120x40 -hold -title \"GDB -> OCC["+ str(occ_idx) +"] [" + os.getenv("SANDBOX") + "] @ " + G_gdb_hostname + ":" + str(G_gdb_port) + "\" -e " + G_gdb_path + " --command=occgdb_" + str(occ_idx) + "_gdb_cmds.txt &") - - return - -def occ_gdb_start ( occ_idx ): - start_gdb_server(int(occ_idx)) - gdb_connect(int(occ_idx)) - return - -def occ_ddd_start ( occ_idx ): - start_gdb_server(int(occ_idx)) - ddd_connect(int(occ_idx)) - return - - -############################################################################## -########################################################### -# Register some New Simics Commands -########################################################### -############################################################################## - -#---------------------------------------------------------- -# Simics Command: occ-gdb-start -# -new_command("occ-gdb-start", occ_gdb_start, - args = [arg(int_t, "occidx")], - alias = "", - type = "occ-fw-module-commands", - short = "Connect GDB to OCC", - doc_items = [("NOTE", "")], - see_also = ["occ-ddd-start"], - doc = """ -""") - -#---------------------------------------------------------- -# Simics Command: occ-ddd-start -# -new_command("occ-ddd-start", occ_ddd_start, - args = [arg(int_t, "occidx","?")], - alias = "", - type = "occ-fw-module-commands", - short = "Connect DDD to OCC", - doc_items = [("NOTE", "")], - see_also = ["occ-ddd-start"], - doc = """ -""") diff --git a/src/occ/tools/occ_hwp_id.pl b/src/occ/tools/occ_hwp_id.pl deleted file mode 100644 index ff7242c..0000000 --- a/src/occ/tools/occ_hwp_id.pl +++ /dev/null @@ -1,458 +0,0 @@ -#!/usr/bin/perl - -# @file occ_hwp_id.pl -# -# @brief occ_hwp_id script to generate the occ/tools/occ_hwp_id.html page that -# will be displayed in the build page and lists the hardware procedures and -# the version checked in into that build level. -# -# -# Change Log ****************************************************************** -# Flag Defect/Feature User Date Description -# ------ -------------- ---------- ------------ ----------- -# @fk007 918955 fmkassem 03/11/2013 create. -# - -use strict; -use File::Find (); -use File::Path; -use File::Basename; -use Cwd; - -# Variables -my $DEBUG = 0; -my @outputFnVn; -my @foundFn; -my $baseDir = "."; -my $basePath; -my @searchFiles; -my @searchDirs; -my $baseName; - -my $SHOW_INFO = 0; -# a bit for each: -use constant SHOW_IMAGEID => 0x01; -use constant SHOW_MISSING => 0x02; -use constant SHOW_VERSION => 0x04; -use constant SHOW_SHORT => 0x08; -use constant SHOW_FULLPATH => 0x10; -use constant SHOW_HTML => 0x20; -use constant SHOW_ONLYMISS => 0x40; - -# directories that we'll check for files: -my @dirList = ( - "src/occc/", - ) ; - -# set defaults -my $imageId = ""; -$SHOW_INFO = SHOW_VERSION; - -while( $ARGV = shift ) -{ - if( $ARGV =~ m/-h/ ) - { - usage(); - } - elsif( $ARGV =~ m/-D/ ) - { - if ( $baseDir = shift ) - { - print("Using directory(s): $baseDir\n"); - } - else - { - usage(); - } - } - elsif( $ARGV =~ m/-d/ ) - { - $DEBUG = 1; - } - elsif( $ARGV =~ m/-f/ ) - { - $SHOW_INFO |= SHOW_FULLPATH; - } - elsif( $ARGV =~ m/-F/ ) - { - # no directory, list of files - $baseDir = ""; - @searchFiles = @ARGV; - last; # done with options - } - elsif( $ARGV =~ m/-I/ ) - { - $SHOW_INFO |= SHOW_IMAGEID; - if ( $imageId = shift ) - { - debugMsg("using supplied Hostboot version: $imageId\n"); - } - else - { - usage(); - } - } - elsif( $ARGV =~ m/-i/ ) - { - $SHOW_INFO |= SHOW_IMAGEID; - } - elsif( $ARGV =~ m/-l/ ) - { - $SHOW_INFO |= SHOW_HTML; - $SHOW_INFO &= ~SHOW_VERSION; - $SHOW_INFO &= ~SHOW_SHORT; - } - elsif( $ARGV =~ m/-M/ ) - { - $SHOW_INFO |= SHOW_ONLYMISS; - } - elsif( $ARGV =~ m/-m/ ) - { - $SHOW_INFO |= SHOW_MISSING; - } - elsif( $ARGV =~ m/-s/ ) - { - $SHOW_INFO |= SHOW_SHORT; - $SHOW_INFO &= ~SHOW_VERSION; - $SHOW_INFO &= ~SHOW_HTML; - } - elsif( $ARGV =~ m/-v/ ) - { - $SHOW_INFO |= SHOW_VERSION; - $SHOW_INFO &= ~SHOW_SHORT; - $SHOW_INFO &= ~SHOW_HTML; - } - else - { - usage(); - } -} - -if ($SHOW_INFO & SHOW_ONLYMISS) -{ - $SHOW_INFO &= ~SHOW_VERSION; - $SHOW_INFO &= ~SHOW_SHORT; - $SHOW_INFO &= ~SHOW_HTML; -} - -# generate starting html if needed -if ($SHOW_INFO & SHOW_HTML) -{ - print "<html>\n"; - print " <head><title>OCC HWP names and version IDs</title></head>\n"; - print <<STYLESHEET; - <style type="text/css"> - table.occ_hwp_id { - border-width: 1px; - border-spacing: 2px; - border-style: outset; - border-color: gray; - border-collapse: separate; - background-color: white; - } - table.occ_hwp_id th { - border-width: 1px; - padding: 1px; - border-style: inset; - border-color: gray; - background-color: white; - } - table.occ_hwp_id td { - border-width: 1px; - padding: 1px; - border-style: inset; - border-color: gray; - background-color: white; - } - </style> -STYLESHEET - print " <body>\n"; -} - -# determine what the hbi_ImageId would be, if we were asked to display that -if ($SHOW_INFO & SHOW_IMAGEID) -{ - $baseName = basename($baseDir); - if ($SHOW_INFO & SHOW_HTML) - { - print "<h1>OCC version: $baseName</h1>\n"; - } - else - { - print("OCC version: $baseName\n"); - } -} - -# if baseDir - recurse into directories -if ($baseDir) -{ - # there may be multiple base directories - @searchDirs = split(/:/, $baseDir); - - foreach( @searchDirs ) - { - # make sure we're in the correct place - chdir "$_"; - $basePath = $_; - - # do the work - for each directory, check the files... - foreach( @dirList ) - { - @outputFnVn = (); - checkDirs( $_ ); - - if (scalar(@outputFnVn) > 0) - { - outputFileInfo($_, @outputFnVn); - } - } - } -} -else # list of files -{ - @outputFnVn = (); - - # do the work - for each file, check it - foreach( @searchFiles ) - { - findIdVersion( $_ ); - } - - if (scalar(@outputFnVn) > 0) - { - my $pwd = getcwd(); - outputFileInfo($pwd, @outputFnVn); - } -} - -# generate closing html if needed -if ($SHOW_INFO & SHOW_HTML) -{ - print " </body>\n"; - print "</html>\n"; -} - -#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -# End of Main program -#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - -################################################################################ -# -# Print debug messages if $DEBUG is enabled. -# -################################################################################ - -sub debugMsg -{ - my ($msg) = @_; - if( $DEBUG ) - { - print "DEBUG: $msg\n"; - } -} - -################################################################################ -# -# outputFileInfo - Print output, as options dictate -# -################################################################################ - -sub outputFileInfo -{ - my $dir = shift; - - if ($SHOW_INFO & SHOW_HTML) - { - print("<h2>OCC HWP files in $basePath/$dir</h2>\n"); - } - else - { - print("[OCC HWP files in $dir]\n"); - } - - if ($SHOW_INFO & SHOW_SHORT) - { - print("[Procedure,Revision]\n" ); - } - - if ($SHOW_INFO & SHOW_HTML) - { - print "<table class='occ_hwp_id'>\n"; - print " <tr>\n"; - print " <th>Filename</th>\n"; - print " <th>Version</th>\n"; - print " </tr>\n"; - } - - foreach( sort(@_) ) - { - print( "$_\n" ); - } - - if ($SHOW_INFO & SHOW_HTML) - { - print "</table>\n"; - } -} - -################################################################################ -# -# findIdVersion - prints out filename and version from the $Id: string. -# -################################################################################ - -sub findIdVersion -{ - my ($l_file) = @_; - debugMsg( "finding Id & Version from file: $l_file" ); - - local *FH; - open(FH, "$l_file") or die("Cannot open: $l_file: $!"); - my $data; - read(FH, $data, -s FH) or die("Error reading $l_file: $!"); - close FH; - - # look for special string to skip file - if ($data =~ /HWP_IGNORE_VERSION_CHECK/ ) - { - debugMsg( "findIdVersion: found HWP_IGNORE_VERSION_CHECK in: $l_file" ); - next; - } - - # look for - # $Id: - means this IS an hwp - print version and continue - # else - missing! - if ($data =~ /\$Id: (.*),v ([0-9.]*) .* \$/mgo ) - { - my $fn = $1; # filename - my $vn = $2; # version - my $display_name; - my $redundant = 0; - if ($SHOW_INFO & SHOW_FULLPATH) - { - $display_name = $l_file; - } - else - { - $display_name = $fn; - } - $redundant = grep { m/^$fn$/ } @foundFn; - if ( !$redundant ) - { - push( @foundFn, $display_name ); - debugMsg( "File: $display_name Version: $vn" ); - if ($SHOW_INFO & SHOW_VERSION) - { - push( @outputFnVn, "File: $display_name Version: $vn" ); - } - elsif ($SHOW_INFO & SHOW_SHORT) - { - push( @outputFnVn, "$display_name,$vn" ); - } - elsif ($SHOW_INFO & SHOW_HTML) - { - push( @outputFnVn, "<tr><td>$display_name</td><td>$vn</td></tr>" ); - } - } - } - else - { - debugMsg( "findIdVersion: MISSING \$Id tag: $l_file" ); - if ($SHOW_INFO & SHOW_MISSING) - { - if ($SHOW_INFO & SHOW_VERSION) - { - print( "File: $l_file Version: \$Id is MISSING\n" ); - } - elsif ($SHOW_INFO & SHOW_SHORT) - { - print( "$l_file,MISSING\n" ); - } - elsif ($SHOW_INFO & SHOW_HTML) - { - print( "<tr><td>$l_file</td><td>\$Id is MISSING</td></tr>\n" ); - } - } - elsif ($SHOW_INFO & SHOW_ONLYMISS) - { - print( "File: $l_file Version: \$Id is MISSING\n" ); - } - } -} - -################################################################################ -# -# checkDirs - find *.[hHcC] and *.initfile files that are hwp files -# and prints out their filename and version from the $Id: string. -# This recursively searches the input directory passed in for all files. -# -################################################################################ - -sub checkDirs -{ - my ($l_input_dir) = @_; - - debugMsg( "Getting Files for dir: $l_input_dir" ); - - # Open the directory and read all entry names. - - local *DH; - opendir(DH, $l_input_dir) ;#or die("Cannot open $l_input_dir: $!"); - # skip the dots - my @dir_entry; - @dir_entry = grep { !/^\./ } readdir(DH); - closedir(DH); - while (@dir_entry) - { - my $l_entry = shift(@dir_entry); - my $full_path = "$l_input_dir/$l_entry"; - - debugMsg( "checkDirs: Full Path: $full_path" ); - - # if this is valid file: - if (($l_entry =~ /\.[H|h|C|c|S]$/) || - ($l_entry =~ /\.pS$/) || - ($l_entry =~ /\.mk$/) || - ($l_entry =~ /\.ode$/) || - ($l_entry =~ /Makefile$/)) - { - findIdVersion($full_path); - } - # else if this is a directory - elsif (-d $full_path) - { - # recursive here - checkDirs($full_path); - } - # else we ignore the file. - } -} - -################################################################################ -# -# Print the Usage message -# -################################################################################ - -sub usage -{ - print "Usage: $0 <option> [-F <files>]\n"; - print "\n"; - print "Default - show name and version for hwp files with \$Id string.\n"; - print "-D dirs Use dir as top of build, may be ':' separated list.\n"; - print "-d Enable Debug messages.\n"; - print "-f Show full pathname of all files.\n"; - print "-F files Search listed full-path files. Must be last parameter.\n"; - print "-h Display usage message.\n"; - print "-I lvl Show hostboot ImageId value as supplied lvl\n"; - print "-i Show hostboot ImageId value.\n"; - print "-m Include files that are missing Id strings.\n"; - print "\n"; - print " output is in one of 4 formats:\n"; - print "-l Output in html table.\n"; - print "-s Show short \"filename,version\" format.\n"; - print "-v Show longer \"File: f Version: v\" format. (default)\n"; - print "-M Only show files that are missing Id strings.\n"; - print "\n"; - exit 1; -} diff --git a/src/occ/tools/occ_post_model_hook.simics b/src/occ/tools/occ_post_model_hook.simics deleted file mode 100755 index a383af9..0000000 --- a/src/occ/tools/occ_post_model_hook.simics +++ /dev/null @@ -1,344 +0,0 @@ -################################################################################ -# post_model_hook.simics -# This file is used to run a set of commands on the simics console after -# modules have loaded. - -$occc = [0] -$proc_chip = [0] - -if not (lookup-file ../src/occc/405/occ/tools/occ_simics_gen_lists.py ){ - #run-python-file /gsa/ausgsa/projects/o/occfw/public/simics/scripts/cc_simics_gen_lists.py - - #---------------------------------------------------------- - # Figure out what OCCs are out there & create a list - #---------------------------------------------------------- - $occc[0]=0; $b=0; foreach $c in (get-object-list -all occ_simple) {$occc[$b] = $c; $b = $b + 1} - #---------------------------------------------------------- - # Figure out what CEC-chips are out there & create a list - #---------------------------------------------------------- - $proc_chip[0]=0; $f=0; foreach $g in (get-object-list -all cec-chip) {$proc_chip[$f] = $g; $f = $f + 1} -} else { - run-python-file ../src/occc/405/occ/tools/occ_simics_gen_lists.py -} - -#---------------------------------------------------------- -# Figure out what OCCs are out there & create a list -#---------------------------------------------------------- -#$occc[0]=0; $b=0; foreach $c in (get-object-list -all occ_simple) {$occc[$b] = $c; $b = $b + 1} - -#---------------------------------------------------------- -# Figure out what PSSs are out there & create a list -#---------------------------------------------------------- -$apss = [0] -$apss[0]=0; $d=0; foreach $e in (get-object-list -all apss_device) {$apss[$d] = $e; $d = $d + 1} -#$dpss[0]=0; $f=0; foreach $g in (get-object-list -all dpss_device) {$dpss[$f] = $g; $f = $f + 1} - -#---------------------------------------------------------- -# Figure out what CEC-chips are out there & create a list -#---------------------------------------------------------- -#$proc_chip[0]=0; $f=0; foreach $g in (get-object-list -all cec-chip) {$proc_chip[$f] = $g; $f = $f + 1} - -#---------------------------------------------------------- -# ChipId/NodeId Lists for OCC Alone Model -#---------------------------------------------------------- -$occChipId_murano = [] -$occChipId_murano[0] = 0x0000000000000000; # NodeID=0, ChipID=0 -$occChipId_murano[1] = 0x0000000000040000; # NodeID=0, ChipID=1 -$occChipId_murano[2] = 0x0000000000200000; # NodeID=1, ChipID=0 -$occChipId_murano[3] = 0x0000000000240000; # NodeID=1, ChipID=1 -$occChipId_murano[4] = 0x0000000000400000; # NodeID=2, ChipID=0 -$occChipId_murano[5] = 0x0000000000440000; # NodeID=2, ChipID=1 -$occChipId_murano[6] = 0x0000000000600000; # NodeID=3, ChipID=0 -$occChipId_murano[7] = 0x0000000000640000; # NodeID=3, ChipID=1 - -$occChipId_venice = [] -$occChipId_venice[0] = 0x0000000000000000; # NodeID=0, ChipID=0 -$occChipId_venice[1] = 0x0000000000040000; # NodeID=0, ChipID=1 -$occChipId_venice[2] = 0x0000000000080000; # NodeID=0, ChipID=2 -$occChipId_venice[3] = 0x00000000000C0000; # NodeID=0, ChipID=3 -$occChipId_venice[4] = 0x0000000000100000; # NodeID=0, ChipID=4 -$occChipId_venice[5] = 0x0000000000140000; # NodeID=0, ChipID=5 -$occChipId_venice[6] = 0x0000000000180000; # NodeID=0, ChipID=6 -$occChipId_venice[7] = 0x00000000001C0000; # NodeID=0, ChipID=7 - - -#---------------------------------------------------------- -# Set up path to OCC image -#---------------------------------------------------------- -$occ_image = "../obj/ppc/occc/405/image.bin" -if not (lookup-file $occ_image ){ - echo "Using GNUmake image" - $occ_image = "../src/occc/405/image.bin" -}else{ - echo "Using ODEmake image" -} - - -#---------------------------------------------------------- -# Create symbol table for occ application using sandbox or backing build -#---------------------------------------------------------- -@occoutfile = "/../obj/ppc/occc/405/occ/occ.out" -@occsb = os.getenv("sb") -@cli.run_command("$occsb = " + occsb + occoutfile) -@occbb = os.getenv("bb") -@cli.run_command("$occbb = " + occbb + "/src" + occoutfile) - -# Create symbol table - first look in $sb, then $bb, then gnumake location -if not (lookup-file $occsb ){ - echo "Cannot find OCC Symbols file in Sandbox" - - if not (lookup-file $occbb) { - echo "Cannot find OCC Symbols file in Backing Build" - - @cli.run_command("$occsb = " + occsb + "/occc/405/occ/occ.out") - if not (lookup-file $occsb) { - echo "Cannot find OCC Symbols file in src/ tree" - }else{ - echo "Loaded symbol file from src/occ/occ.out" - new-symtable occst $occsb - } - }else{ - echo "Loaded symbol table from $bb/obj/ppc/occc/405/occ/occ.out" - new-symtable occst $occbb - } -}else{ - echo "Loaded symbol table from $sb/obj/ppc/occc/405/occ/occ.out" - new-symtable occst $occsb -} - - -#---------------------------------------------------------- -# Create symbol table for occ Bootloader using sandbox or backing build -#---------------------------------------------------------- -@btoutfile = "/../obj/ppc/occc/405/occBootLoader/bootloader.out" -@cli.run_command("$occsb = " + occsb + btoutfile) -@cli.run_command("$occbb = " + occbb + "/src" + btoutfile) - -# Create symbol table - first look in $sb, then $bb, then gnumake location -if not (lookup-file $occsb ){ - echo "Cannot find Bootloader Symbols file in Sandbox" - if not (lookup-file $occbb) { - echo "Cannot find Bootloader Symbols file in Backing Build" - - @cli.run_command("$occsb = " + occsb + "/occc/405/occBootLoader/bootloader.out") - if not (lookup-file $occsb) { - echo "Cannot find Bootloader Symbols file src/ tree" - }else{ - echo "Loaded symbol file from src/occBootLoader/bootloader.out" - occst.load-symbols $occsb - } - }else{ - echo "Loaded symbol table from $bb/obj/ppc/occc/405/occBootLoader/bootloader.out" - occst.load-symbols $occbb - } -}else{ - echo "Loaded symbol table from $sb/obj/ppc/occc/405/occBootLoader/bootloader.out" - occst.load-symbols $occsb -} - - -#---------------------------------------------------------- -# Loop through all present OCCs, setting them all to the -# same initial settings -#---------------------------------------------------------- -while $b { - $b -= 1 - - echo " " - echo "-------------------------------------------------------- " - echo "Loading & configuring: " - echo $occc[$b] - echo "-------------------------------------------------------- " - - # Set up symbol table for each OCC - @occ_path = cli.quiet_run_command("echo $occc[$b]") - @cli.run_command("@conf." + occ_path[1].rstrip('\n') + ".cpu.current_context.symtable = conf.occst") - - # Load OCC image - # $occc[$b].pob_space.load-file ../src/image.bin - - # Load OCC image - $alone = p8Proc0.OccComplexSlot->isStandalone - if $alone == 0 { - echo "Loading OCC image into phys_mem" - proc_venicechip_cmp0.phys_mem.load-file $occ_image 0x400000 - $occc[$b].pba->pba_slvctl0 = 0x87001E0000000000 # OCC HOMER Image - $occc[$b].pba->pba_barmsk0 = 0x0000000000300000 # OCC HOMER Image - $occc[$b].pba->pba_bar0 = 0x0000000000400000 # OCC HOMER Image - } else { - echo "Alone: Loading into fake phys_mem" - backplane0.phys_mem.load-file $occ_image 0x400000 - $occc[$b].pba->pba_slvctl0 = 0x87001E0000000000 # OCC HOMER Image - $occc[$b].pba->pba_barmsk0 = 0x0000000000300000 # OCC HOMER Image - $occc[$b].pba->pba_bar0 = 0x0000000000400000 # OCC HOMER Image - } - - # Set PBA BAR register - simics 04/04/2012 and newer - $occc[$b].pba->pba_mode = 0x00E03A9000000000 - $occc[$b].pba->pba_slvctl3 = 0xD7005E4000000000 # OCC Common - $occc[$b].pba->pba_slvctl2 = 0xC7005E4000000000 # PORE-SLW - $occc[$b].pba->pba_slvctl1 = 0xE6005E4000000000 # Centaur - $occc[$b].pba->pba_bar1 = 0x0003e00000000000 # Centaur - $occc[$b].pba->pba_barmsk1 = 0x1fffff00000 # Centaur - $occc[$b].pba->pba_bar3 = 0x0000000008000000 # OCC Common Image - $occc[$b].pba->pba_barmsk3 = 0x00000700000 # OCC Common Image - - # Set OCB registers until we are always talking via TMGT/HWSV - $occc[$b].ocb->ocb_ocbar0 = 0xffff600000000000 - $occc[$b].ocb->ocb_ocbcsr0 = 0x0800000000000000 - $occc[$b].ocb->ocb_ocbcsr1 = 0x0c00000000000000 - $occc[$b].ocb->ocb_ocbar1 = 0xffff600000000000 - - # Set CPI to be more accurate. Simics defaults to a CPI = 1, but it - # is more likely with our workload that we will have a CPI ~= 3. Simics - # only allows certain step rates, so we will end up with a CPI of 2.9767 - # Step Rate = IPC = 1/CPI - $occc[$b].cpu.set-step-rate "43/128" - - # Set branch to address 64(0x40) and place this branch at 0xFFFFFFFC. - $occc[$b].oci_space.set 0xfffffffc 0x48000042 - - # --------------------------------------------------------- - # Temporary Workarounds - # --------------------------------------------------------- - echo " " - echo "-------------------------------------------------------- " - echo "Applying Workarounds to Enable OCC" - echo "-------------------------------------------------------- " - - # In the beginning Scott Prather created the simics model and the occ. - # Now the occ was formless and empty, [and didn't have all the inits - # that would happen on a real system.] - # And Scott said, "Let there be clocks": and there was clocks. - # Scott saw that clocks were good, and Scott divided clocks from [simics - # init into this seperate initialization.] - $proc_chip[$b].regwrite LOGIC 0xFF000001 FFFFFFFF_FFFFFFFF 64 - $proc_chip[$b].regwrite LOGIC 0xFFC50000 FFFFFFFF_FFFFFFFF 64 - $proc_chip[$b].regwrite LOGIC 0xFFC50001 FFFFFFFF_FFFFFFFF 64 - $proc_chip[$b].regwrite LOGIC 0xFFC50002 FFFFFFFF_FFFFFFFF 64 - $proc_chip[$b].regwrite LOGIC 0xFFC50003 FFFFFFFF_FFFFFFFF 64 - $proc_chip[$b].regwrite LOGIC 0xFFC50004 FFFFFFFF_FFFFFFFF 64 - $proc_chip[$b].regwrite LOGIC 0xFFC50005 FFFFFFFF_FFFFFFFF 64 - $proc_chip[$b].regwrite LOGIC 0xFFC50006 FFFFFFFF_FFFFFFFF 64 - $proc_chip[$b].regwrite LOGIC 0xFFC50007 FFFFFFFF_FFFFFFFF 64 - $proc_chip[$b].regwrite LOGIC 0xFFC50008 FFFFFFFF_FFFFFFFF 64 - $proc_chip[$b].regwrite LOGIC 0xFFC50009 FFFFFFFF_FFFFFFFF 64 - $proc_chip[$b].regwrite LOGIC 0xFFC50010 FFFFFFFF_FFFFFFFF 64 - $proc_chip[$b].regwrite LOGIC 0xFFC50011 FFFFFFFF_FFFFFFFF 64 - $proc_chip[$b].regwrite LOGIC 0xFFC50012 FFFFFFFF_FFFFFFFF 64 - $proc_chip[$b].regwrite LOGIC 0xFFC50013 FFFFFFFF_FFFFFFFF 64 - $proc_chip[$b].regwrite LOGIC 0xFFC50014 FFFFFFFF_FFFFFFFF 64 - $proc_chip[$b].regwrite LOGIC 0xFFC50015 FFFFFFFF_FFFFFFFF 64 - $proc_chip[$b].regwrite LOGIC 0xFFC50016 FFFFFFFF_FFFFFFFF 64 - $proc_chip[$b].regwrite LOGIC 0xFFC50019 FFFFFFFF_FFFFFFFF 64 - $proc_chip[$b].regwrite LOGIC 0xFFC5001A FFFFFFFF_FFFFFFFF 64 - $proc_chip[$b].regwrite LOGIC 0xFFC5001B FFFFFFFF_FFFFFFFF 64 - $proc_chip[$b].regwrite LOGIC 0xFFC5001C FFFFFFFF_FFFFFFFF 64 - $proc_chip[$b].regwrite LOGIC 0xFFC5001D FFFFFFFF_FFFFFFFF 64 - $proc_chip[$b].regwrite LOGIC 0xFFC5001E FFFFFFFF_FFFFFFFF 64 - - # FW588165 : PHYP scom to OCC targeting invalid address 0x40020 - $occc[$b].pcb_space.add-map $occc[$b].ocb:pib 0x00040020 0x1 - - # Simics Crash when hitting PBAX operations - #@cli.run_command("@conf." + occ_path[1].rstrip('\n') + ".pba.pbax_connector=conf.p8Proc0.OccComplexSlot.pbax_router") - - if $alone == 0 { - echo "" - } else { - echo "OCC Alone Workaround: Set ChipId & NodeId (Murano)" - $occc[$b].pib_master->address = 0x01000000 - $occc[$b].pib_master->data = $occChipId_murano[$b] - } -} - -# --------------------------------------------------------- -# APSS settings -# --------------------------------------------------------- -$apss[0]->adc_channel_val = [ 0x2da, # [0]: Memory 1 -- 90.000 W - 0x302, # [1]: Memory 2 -- 95.000 W - 0x3cd, # [2]: Proc1 Vdd -- 120.000 W - 0x3bd, # [3]: Proc2 Vdd -- 118.000 W - 0x659, # [4]: Proc 1 Vcs/Vio/Vpcie -- 100.000 W - 0x6aa, # [5]: Proc 2 Vcs/Vio/Vpcie -- 105.000 W - 0x592, # [6]: Storage/Media 1 -- 80.000 W - 0x5eb, # [7]: Storage/Media 2 -- 85.000 W - 0x000, # [8]: Remote GND -- 0.000 V - 0xecb, # [9]: 12V Voltage Sense -- 12.300 V - 0x1bd, # [a]: IO 1 -- 25.000 W - 0x1cf, # [b]: IO 2 -- 26.000 W - 0x1e1, # [c]: IO 3 -- 27.000 W - 0x10b, # [d]: Fans 1 -- 15.000 W - 0x0d5, # [e]: Fans 2 -- 12.000 W - 0x001] # [f]: Unused -- 0.000 -# ---------- -# Total -- 898.000 W - - -# --------------------------------------------------------- -# Vpm - Uncomment lines below to run Vpm -# --------------------------------------------------------- -#@occoutfile = "/../simics/vpm/vpxP7" -#@occsb = os.getenv("sb") -#@cli.run_command("!" + occsb + occoutfile) - -@poolsys = os.getenv("DISPLAY") -#@cli.run_command("Vpm.run-spec spec = square vpxServer = " + poolsys.split( ':',1)[0]) -#Vpm.enable-vpm - - -# --------------------------------------------------------- -# Misc Simics settings -# --------------------------------------------------------- -output-radix 16 # output in hex - -# --------------------------------------------------------- -# Run python script(s) to enable some OCC Simics Commands -# --------------------------------------------------------- -echo " " -echo "-------------------------------------------------------- " -echo "Load OCC Developer Debug Scripts" -echo "-------------------------------------------------------- " -if not (lookup-file ../src/occc/405/occ/tools/occ_simics_debug.py ){ - echo "Load Scripts from GSA" - run-python-file /gsa/ausgsa/projects/o/occfw/public/simics/scripts/occ_simics_debug.py # hsym, h64sym, h64attr - run-python-file /gsa/ausgsa/projects/o/occfw/public/simics/scripts/occ_amec_sensors.py # amec commands - run-python-file /gsa/ausgsa/projects/o/occfw/public/simics/scripts/occ_fsp_fakeout.py # tmgt commands - run-python-file /gsa/ausgsa/projects/o/occfw/public/simics/scripts/occ_gdb.py # gdb/ddd commands -}else{ - echo "Load Scripts from Sandbox" - run-python-file ../src/occc/405/occ/tools/occ_simics_debug.py # hsym, h64sym, h64attr - run-python-file ../src/occc/405/occ/tools/occ_amec_sensors.py # amec commands - run-python-file ../src/occc/405/occ/tools/occ_fsp_fakeout.py # tmgt commands - run-python-file ../src/occc/405/occ/tools/occ_gdb.py # gdb/ddd commands -} - -# --------------------------------------------------------- -# Set up Centaur/MCS so OCC can access Centaur -# --------------------------------------------------------- -echo " " -echo "-------------------------------------------------------- " -echo "Set up Centaur/MCS so OCC can access Centaur" -echo "-------------------------------------------------------- " -#putscom 0x2011802 0x83e0000000000000 # Centaur 0 -- Venice Only -#putscom 0x2011882 0x83e0200000000000 # Centaur 1 -- Venice Only -#putscom 0x2011902 0x83e0400000000000 # Centaur 2 -- Venice Only -#putscom 0x2011982 0x83e0600000000000 # Centaur 3 -- Venice Only -##putscom 0x2011c02 0x83e0800000000000 # Centaur 4 -##putscom 0x2011c82 0x83e0a00000000000 # Centaur 5 -##putscom 0x2011d02 0x83e0c00000000000 # Centaur 6 -##putscom 0x2011d82 0x83e0e00000000000 # Centaur 7 - - -# --------------------------------------------------------- -# Enabling Magic Breakpoint to help with development debug -# --------------------------------------------------------- -echo " " -echo "-------------------------------------------------------- " -echo "Enabling Simics Magic Breakpoint for OCC developer debug " -echo " To Disable: disable-magic-breakpoint" -echo " To Start GDB: occ-gdb-start <occnum>" -echo "-------------------------------------------------------- " -echo " " -enable-magic-breakpoint - diff --git a/src/occ/tools/occ_simics_debug.py b/src/occ/tools/occ_simics_debug.py deleted file mode 100755 index 63cee85..0000000 --- a/src/occ/tools/occ_simics_debug.py +++ /dev/null @@ -1,174 +0,0 @@ -# @file - occ_simics_debug.py -# @brief Create Simics Generic Commands -# -# Flag Def/Fea Userid Date Description -# ------- ---------- -------- ---------- ---------------------------------- -# thallet 03/28/2012 Created - - -from time import sleep -from random import randint -import sys -import re - -G_occ_list = [] - -############################################################################## -########################################################### -# Functions -########################################################### -############################################################################## -def print_sym_as_hex( str ): - tick = cli.quiet_run_command(G_occ_list[0] + ".cpu.psym " + '\"' + str + '\"') - splitter = re.compile(r' (\d+)') - p_sym = tick[1].rstrip('\n') - r_sym = splitter.split(p_sym) - out_str = '' - for item in r_sym: - if item.isdigit(): - if (int(item) > 0xffffffff): - out_str += "0x%016x" % int(item) - else: - out_str += "0x%08x" % int(item) - else: - out_str += `item` - - print out_str - return - -def print_sym_as_hex64( str ): - tick = cli.quiet_run_command(G_occ_list[0] + ".cpu.psym " + '\"' + str + '\"') - splitter = re.compile(r' (\d+)') - p_sym = tick[1].rstrip('\n') - r_sym = splitter.split(p_sym) - out_str = '' - for item in r_sym: - if item.isdigit(): - out_str += "0x%016x" % int(item) - else: - out_str += `item` - - print out_str - return - - -def print_simics_attr_as_hex64( str ): - tick = cli.quiet_run_command(str) - splitter = re.compile(r'(\d+)') - p_sym = tick[0] - print "0x%016x" % p_sym - return - - -def getscom( int ): - tick = cli.quiet_run_command(G_occ_list[0] + ".pib_master->address = " + str(int)) - tick = cli.quiet_run_command(G_occ_list[0] + ".pib_master->data") - p_sym = tick[0] - print "0x%016x" % p_sym - return - -def putscom( addr, data ): - tick = cli.quiet_run_command(G_occ_list[0] + ".pib_master->address = " + str(addr)) - tick = cli.quiet_run_command(G_occ_list[0] + ".pib_master->data = " + str(data)) - getscom(addr) - return - -def generate_occlist(): - tick = cli.quiet_run_command("$occc[0]=0; $b=0; foreach $c in (get-object-list -all occ_simple) {$occc[$b] = $c; $b = $b + 1}") - num = cli.quiet_run_command("print -d $b") - for idx in range(int(num[1].rstrip('\n'))): - tick = cli.quiet_run_command("echo $occc[" + str(idx) + "]") - G_occ_list.insert(idx,tick[1].rstrip('\n')) - G_occ_list.sort() - for idx in range(int(num[1].rstrip('\n'))): - print str(idx) + ": " + G_occ_list[idx] - - return - - -generate_occlist() - -############################################################################## -########################################################### -# Register some New Simics Commands -########################################################### -############################################################################## - - -#---------------------------------------------------------- -# -# -new_command("hsym", print_sym_as_hex, - args = [arg(str_t, "symbol-name")], - alias = "hsym", - type = "occ-fw-module-commands", - short = "Print a symbol as hex (uint64 or uint32) for all structure members", - doc_items = [("NOTE", "This command is best")], - see_also = ["h64sym"], - doc = """ - <b>hsym</b> is best. - This is its documentation. <i>arg</i> - is the first argument...""") - -#---------------------------------------------------------- -# -# -new_command("h64sym", print_sym_as_hex64, - args = [arg(str_t, "symbol-name")], - alias = "hsym64", - type = "occ-fw-module-commands", - short = "Print a symbol as hex (uint64) for all structure members", - doc_items = [("NOTE", "This command is best")], - see_also = ["hsym"], - doc = """ - <b>h64sym</b> is best. - This is its documentation. <i>arg</i> - is the first argument...""") - - -#---------------------------------------------------------- -# -# -new_command("h64attr", print_simics_attr_as_hex64, - args = [arg(str_t, "simics-attribute")], - alias = "hattr", - type = "occ-fw-module-commands", - short = "Print a simics attribute as hex (uint64) for all structure members", - doc_items = [("NOTE", "This command is best")], - see_also = ["hsym","h64sym"], - doc = """ - <b>h64attr</b> is best. - This is its documentation. <i>arg</i> - is the first argument...""") - -#---------------------------------------------------------- -# -# -new_command("getscom", getscom, - args = [arg(int_t, "scomAddress")], - alias = "gs", - type = "occ-fw-module-commands", - short = "Do a getscom", - doc_items = [("NOTE", "This command is best")], - see_also = ["hsym","h64sym"], - doc = """ - <b>h64attr</b> is best. - This is its documentation. <i>arg</i> - is the first argument...""") - - -#---------------------------------------------------------- -# -# -new_command("putscom", putscom, - args = [arg(int_t, "scomAddress"),arg(int_t, "data")], - alias = "ps", - type = "occ-fw-module-commands", - short = "Do a getscom", - doc_items = [("NOTE", "This command is best")], - see_also = ["hsym","h64sym"], - doc = """ - <b>h64attr</b> is best. - This is its documentation. <i>arg</i> - is the first argument...""") - diff --git a/src/occ/tools/occ_simics_gen_lists.py b/src/occ/tools/occ_simics_gen_lists.py deleted file mode 100644 index 92768e7..0000000 --- a/src/occ/tools/occ_simics_gen_lists.py +++ /dev/null @@ -1,53 +0,0 @@ -# @file - occ_simics_debug.py -# @brief Create Simics Generic Commands -# -# Flag Def/Fea Userid Date Description -# ------- ---------- -------- ---------- ---------------------------------- -# thallet 03/28/2012 Created - - -from time import sleep -from random import randint -import sys -import re - -G_occ_list = [] -G_proc_list = [] - -############################################################################## -########################################################### -# Functions -########################################################### -############################################################################## - -def generate_occlist(): - occsimicslist = cli.quiet_run_command("$occc[0]=0; $b=0; foreach $c in (get-object-list -all occ_simple) {$occc[$b] = $c; $b = $b + 1}") - num = cli.quiet_run_command("print -d $b") - for idx in range(int(num[1].rstrip('\n'))): - occsimicslist = cli.quiet_run_command("echo $occc[" + str(idx) + "]") - G_occ_list.insert(idx,occsimicslist[1].rstrip('\n')) - G_occ_list.sort() - for idx in range(int(num[1].rstrip('\n'))): - cli.quiet_run_command("$occc[" + str(idx) + "]= " + G_occ_list[idx] + "") - print str(idx) + ": " + G_occ_list[idx] - - return - -def generate_proclist(): - procsimicslist = cli.quiet_run_command("$proc_chip[0]=0; $f=0; foreach $g in (get-object-list -all cec-chip) {$proc_chip[$f] = $g; $f = $f + 1}") - num = cli.quiet_run_command("print -d $f") - for idx in range(int(num[1].rstrip('\n'))): - procsimicslist = cli.quiet_run_command("echo $proc_chip[" + str(idx) + "]") - G_proc_list.insert(idx,procsimicslist[1].rstrip('\n')) - G_proc_list.sort() - for idx in range(int(num[1].rstrip('\n'))): - cli.quiet_run_command("$proc_chip[" + str(idx) + "]= " + G_proc_list[idx] + "") - print str(idx) + ": " + G_proc_list[idx] - - return - - - -generate_occlist() -generate_proclist() - diff --git a/src/occ/tools/occ_trace.simics b/src/occ/tools/occ_trace.simics deleted file mode 100755 index 53175fb..0000000 --- a/src/occ/tools/occ_trace.simics +++ /dev/null @@ -1,3 +0,0 @@ -# Simics script to pull trace data. To run: -# run-command-file trace.simics -pipe "oci_space.x (sym g_trac_main) (sym \"sizeof(g_trac_main_buffer)\")" fsp_trace_parse.pl diff --git a/src/occ/tools/occgenlid.pl b/src/occ/tools/occgenlid.pl deleted file mode 100755 index d373fed..0000000 --- a/src/occ/tools/occgenlid.pl +++ /dev/null @@ -1,123 +0,0 @@ -#!/usr/bin/perl - -################################################################################ -# change log: -# n/a andrewg 09/07/06 Created -# eggler 2009/04/06 added option file parm -# thallet 2012/08/09 Modified to use with OCC -################################################################################ - -################################################################################ -# -# The purpose of this script is to take as input a occ binary file and convert -# it to a lid which can then be checked into cmvc. -# -################################################################################ - -use strict; -use warnings; - -# ---- MODULES ---- # -use Getopt::Long; -use File::Path; -use File::Basename; - -# ---- CONSTANTS ---- # - -# ---- GLOBALS ---- # -my $g_debug = 0; - -################################################################################ -# -# Main program -# -################################################################################ - -exit(main()); - -################################################################################ -# -# Main -# -################################################################################ - -sub main -{ - my $l_help = ''; - my $l_input_bin; - my $l_lid_name; - my $l_update_bin; - my $optionsfile; - - - if (!GetOptions('h|help' => \$l_help, - 'd|debug' => \$g_debug, - 'i|input_binary=s'=> \$l_input_bin, - 'l|lid_name=s' => \$l_lid_name, - 'o|optionsfile=s' => \$optionsfile)) - { - return -1; - } - - #-- Handle the usage statement immediately. - if ($l_help) - { - usageInfo(); - return 0; - } - - if((!defined($l_input_bin)) || (!defined($l_lid_name))) - { - print "Must provide both --input_binary and --lid_name!\n"; - return -1; - } - - if(! -e $l_input_bin) - { - print "Input binary file, $l_input_bin, does not exist!\n"; - return -1; - - } - - - # We should now have some file called update_bin_* - lets rename it - system ("cp $l_input_bin occ_update.bin"); - - # Make sure that the extucode dir exists - if( !(-d $ENV{'sb'}."/extucode") ) - { - print "Directory ".$ENV{'sb'}."/extucode not found....Creating\n"; - system("mkdir " .$ENV{'sb'}."/extucode"); - } - - # Now lets run the build scripts - system ("apyfipshdr -r ". $ENV{'bb'} . "/src/lidhdr/$l_lid_name.lidhdr -l ./occ_update.bin -o " . $ENV{'sb'} . "/extucode/$l_lid_name.fips"); - - system("apyruhhdr -r " . $ENV{'bb'} . "/src/lidhdr/$l_lid_name.lidhdr -l " . $ENV{'sb'} . "/extucode/$l_lid_name.fips"); - - return(0); -} - - - -################################################################################ -# -# usageInfo -# -################################################################################ - -sub usageInfo -{ -print<<EOF; -Usage: - tpmdgenlid.pl -i <absolute bin file> -l <lid name> - -OPERATIONS: - -h, -H, --help : Print this summary of options and exit. - -d, --debug : Displays additional output - -i --input_binary : Input binary file - -l --lid_name : Lid name to output to w/o lid suffix (i.e. -l 81e00430) - - -EOF -} diff --git a/src/occ/tools/scanforsrcs.pl b/src/occ/tools/scanforsrcs.pl deleted file mode 100755 index f3b0a8f..0000000 --- a/src/occ/tools/scanforsrcs.pl +++ /dev/null @@ -1,1121 +0,0 @@ -#!/usr/bin/perl - -# This is a utility to generate occSrcParse.C automatically. -# It will searching backing build if file is not present in the sandbox. - -use strict; -use File::Find (); -use Time::localtime; - -#use re 'debug'; -my $VERSION = 1.5; - - -sub usage() { - print "Usage: $0 < -b base > <-d> < -o output dir > < -w Word N > \"location of fips_comp_id.H\"\n"; - print "\n"; - print "-b: base directory ( default is pwd )\n"; - print "-d: Allow duplicates - default is to ignore\n"; - print "-o: Used as the output directory where plugins are dropped\n"; - print " Default is PWD\n"; - print "-w: Use word N in generating unique SRCs ( N is between 1 and 4 )\n"; - print "-e: Word N is errno\n"; - print "-n: Don't display tag lines equal to NA or N/A\n"; - print "-V Display version.\n"; - print "-h Display version.\n"; - print "\n\n"; - exit 1; -} - -# Locals -my $base = $ENV{PWD}; -my $baseBB = $ENV{PWD}; -my $output = $base; -my $arg; -my %Comps; -my $ignore = 1; -my $fips_comp_id = "$ENV{bs}/fstp/fsp/fips_comp_id.H"; -#occ/incl/comp_ids.h -my $wordn = "userdata"; -my $wordnd = 0; -my $Errno = 0; -my $NA = 1; - -while ($ARGV = shift) { - if ( $ARGV =~ m/-b/ ) { - $base = shift; - } - elsif ( $ARGV =~ m/-d/i ) { - $ignore = 0; - } - elsif ( $ARGV =~ m/-o/i ) { - $output = shift; - } - elsif ( $ARGV =~ m/-w/i ) { - $wordnd = shift; - $wordn .= $wordnd; - } - elsif ( $ARGV =~ m/-e/i ) { - $Errno = shift; - } - elsif ( $ARGV =~ m/-n/i ) { - $NA = 0; - } - elsif ( $ARGV =~ m/-h/i ) { - usage(); - } - elsif ( $ARGV =~ m/-V/ ) { - print "$0 version = $VERSION\n\n"; - exit 0; - } - else { - $fips_comp_id = $ARGV . "/$fips_comp_id"; - } -} - -# Hardcode just the values that occ needs -$base="$ENV{SANDBOXBASE}/src/occc/405/"; -#$baseBB="$ENV{bb}/src/occc/405/"; -#$baseBB="/afs/austin.ibm.com/projects/esw/occ810/Builds/occ810_130926a/src/occc/405/"; -$baseBB="$ENV{BACKED_SANDBOXDIR}"; -my @values = split(':', $baseBB); -foreach my $val (@values) -{ - if ( $val =~ m/occ810/) - { - $baseBB=$val; - } - } - -#we should not input -d option, let $ignore = 1; #so compile won't fail if there are dups -$output=$base; # put output file in base directory -$wordnd = 4; #look at userdata4 -$wordn .= $wordnd; -#$NA = 0; -my $IgnoreDir = "ssx"; - - -FindFiles(); - -my $cntr; - -foreach my $key ( sort keys %Comps ) -{ - DumpPlugin( $key, \@{$Comps{$key}} ); -} - - -#DumpMakefile(); - -print " +++ $0 is DONE. \n"; - -exit; - -sub FindFiles -{ - # Array which will have the final set of files to scan - my @FilteredArray; - - # Array holding Base Sandbox files - my $BaseFiles=`find $base -name $IgnoreDir -prune -type f -name \'*.h\' -or -name \'*.c\'`; - my @BaseFileArray= split("\n", $BaseFiles); - #foreach my $val (@BaseFileArray) - #{ - # print "SandboxFiles:: $val \n"; - #} - # Array holding the Backing Build files - my $BBFiles=`find $baseBB -name $IgnoreDir -prune -type f -name \'*.h\' -or -name \'*.c\'`; - my @BBFileArray= split("\n", $BBFiles); - #foreach my $val (@BBFileArray) - #{ - # print "BackingBuildFiles:: $val \n"; - #} - - # find all build files from makefile and remove unnecessary files from src scan list - my @BuildList = FindBuildList(); - #foreach my $val (@BuildList) - #{ - # print "BuildList:: $val \n"; - #} - - - CheckBuildList(\@BBFileArray, @BuildList); - CheckBuildList(\@BaseFileArray, @BuildList); - - # Start with Sandbox Files - @FilteredArray=@BaseFileArray; - - # Cycle through all Backing Build Files - for my $BBFileArrayCntr(@BBFileArray) - { - # found flag - my $found = 0; - - # Cycle through all Sandbox Files - for my $BaseFileArrayCntr(@BaseFileArray) - { - - # strip off everything an get current Backing Build File - my $tmp1 = rindex($BBFileArrayCntr, "/") + 1; - my $BBFileName = substr($BBFileArrayCntr, $tmp1); - - # strip off everyting and get current Sandbox File - my $tmp2 = rindex($BaseFileArrayCntr, "/") + 1; - my $FileName = substr($BaseFileArrayCntr, $tmp2); - - # if Backing Build File name is same is SandBox file name - # then we are done checking this Backing Build file, exit! - if ( "$BBFileName" eq "$FileName" ) - { - $found = 1; - last; - } - } - - # if we didnt find any matches then it means that the - # backing build file name should be used - if ( $found eq 0 ) - { - # add to final array - @FilteredArray=(@FilteredArray,$BBFileArrayCntr); - } - } - - # sort final arry based on ascii of strings - @FilteredArray = sort( @FilteredArray ); - - # now called wanted to extract SRCs - foreach my $FilteredArrayCntr(@FilteredArray) - { - # extract srcs from this file - &wanted( $FilteredArrayCntr ); - } -} - -# Find build lists from makefile -sub FindBuildList -{ - # Array holding all makefiles - my @MakefileArray; - - # Array holding makefiles in Base Sandbox - my $BaseMakefile = `find $base -type f -name *.mk -or -name "Makefile*"`; - my @BaseMakefileArray = split("\n", $BaseMakefile); - - # Array holding makefiles in Backing Build - my $BBMakefile = `find $baseBB -type f -name *.mk -or -name "Makefile*"`; - my @BBMakefileArray = split("\n", $BBMakefile); - - # Use makefiles in sandbox as the base - @MakefileArray = @BaseMakefileArray; - - # Cycle through all Backing Build Files - for my $BBMakefileArrayCntr(@BBMakefileArray) - { - # found flag - my $found = 0; - - # Cycle through all Sandbox Files - for my $BaseMakefileArrayCntr(@BaseMakefileArray) - { - # strip off everything and get current Backing Build File - my $tmp1 = rindex($BBMakefileArrayCntr, "/src/occc/405") + 1; - my $BBMakefileName = substr($BBMakefileArrayCntr, $tmp1); - - # strip off everyting and get current Sandbox File - my $tmp2 = rindex($BaseMakefileArrayCntr, "/src/occc/405") + 1; - my $FileName = substr($BaseMakefileArrayCntr, $tmp2); - - # To check if the makefiles is only found in Backing Build - if ("$BBMakefileName" eq "$FileName") - { - $found = 1; - last; - } - } - - # if we didnt find any matches, use makefile from backing build - if ($found == 0) - { # add to final array - @MakefileArray = (@MakefileArray,$BBMakefileArrayCntr); - } - } - - # sort final array based on ascii of strings - @MakefileArray = sort( @MakefileArray ); - - # loop for all makefiles to collect build files - my @TempArray; - foreach my $makefileCnt (@MakefileArray) - { - #will display which makefile we cross reference against - #print "Using $makefileCnt\n"; - my $var; - { - local $/; - open my $fh, '<', $makefileCnt or die "can't open $makefileCnt: $!"; - $var = <$fh>; - close $fh; - } - $var =~ s/#.*//g; # remove comments -# print "$var \n"; - while ($var =~ m/(\w+)\.o/g) - { # Add to build list - @TempArray = (@TempArray,$1); - } - - while ($var =~ m/(\w+)\.c/g) - { # Add to build list - @TempArray = (@TempArray,$1); - } - } - - # remove duplicate elements - my %hash = map { $_, 1 } @TempArray; - my @BuildArray = keys %hash; - # sort final arry based on ascii of strings - @BuildArray = sort(@BuildArray); - - # foreach my $val (@BuildArray) - # { - # print "$val \n"; - # } - - return @BuildArray -} - -# Remove files which are not in the build list -sub CheckBuildList -{ - my ($FileArray, @BuildList) = @_; - - my @tempArray; # since we cannot delete elements in array in loop - - foreach my $ArrayCnt(@$FileArray) - { # strip off everything and get filename - my $pos = rindex($ArrayCnt, "/") + 1; - my $File = substr($ArrayCnt, $pos, -2); - - if ( $ArrayCnt =~ /\/lib\// ) - { - #print "LIB file found! $ArrayCnt \n"; - next; - } - - if ( $ArrayCnt =~ /\/ssx\// ) - { - #print "SSX file found! $ArrayCnt \n"; - next; - } - - #print "Found $File.c\n"; - - my $found = 0; - foreach my $Buildfile(@BuildList) - { - if ($Buildfile =~ /$File/) - { - # found filename in makefile, add to scan SRC - - # will give you the full path of file we - # adding to our scan list - # print "Adding $ArrayCnt to src scan list. \n"; - - push @tempArray, $ArrayCnt; - $found = 1; - last; - } - } - - if ($found == 0) - { # not found, ignore this file - print "Ignoring $ArrayCnt. \n"; - } - } - - @$FileArray = @tempArray; -} - -sub FileFind -{ - # Set the variable $File::Find::dont_use_nlink if you're using AFS, - # since AFS cheats. - - # for the convenience of &wanted calls, including -eval statements: - use vars qw/*name *dir *prune/; - *name = *File::Find::name; - *dir = *File::Find::dir; - *prune = *File::Find::prune; - - # Traverse desired filesystems - File::Find::find({wanted => \&wanted}, $base); - -} - - -sub wanted { - #my ($dev,$ino,$mode,$nlink,$uid,$gid); - my $data; - my $file = "@_"; - - print "Processing: $file\n"; - - open FH, $file or die "Cannot open: $file"; - read FH, $data, -s FH or die "Error reading $file: $!"; - close FH; - - # extract filename from full path - my $pos = rindex($file, "/") + 1; - my $fileName = substr($file, $pos); - - # extract component -# $fileName =~ /^(\w{4})/; -# my $comp = $1; - # No matter filename has prefix "hwsv"(applet) or "tmgt"(all other tmgt code), put all function in one file which is "occSrcParse.C", - my $comp = 'occc'; - - while ( $data =~ /\@errortype(?:.*?)\n((.+?\n)+?).+?\*\//mgo ) - { - my $text = $1; - my $found = 0; - my %hash = $text =~ /\@(\w+)(?:\s+|\.+)\b(.+?)$/gm; - my $tmp; - - foreach my $key (sort keys %hash) - { - # Extract multi-line string - $text =~ /\@$key(?:\s+|\.+)(.+?)(?:\@|$).*/s; - $tmp = $1; - - # take off comment starting with "//" - $tmp =~ s/\s*\/\/.*//gm; - - # replace "\*" with "\n" - $tmp =~ s/\s*\*\s*/ \n/gm; - - chomp($tmp); - $hash{$key} = $tmp; - } - - #add on file info - $hash{file} = $file; - -# print "------------------------>\n"; -# print "$text\n\n"; -# foreach my $key (sort keys %hash) -# { -# print "\t$key => $hash{$key}\n"; -# } -# print "<------------------------\n"; - - # Remove trailing words - $hash{moduleid} =~ s/^(\w+).*$/$1/; - $hash{reasoncode} =~ s/^(\w+).*$/$1/; - - if ( $ignore ) - { - my $res; - my @RedundantComps; - - # Find duplicates - foreach my $href ( @{ $Comps{$comp} } ) - { - $res = hasheq( 3, $href, \%hash); - $found |= $res; - - # showing up duplicated files - if ($res) - { - push @RedundantComps, $href; - } - } - - if ($found) { - foreach my $href ( @RedundantComps ) - { - print "!!!! Also found the same combination in file => $href->{file}\n"; - } - - die "ERROR: $hash{moduleid}/$hash{reasoncode}/$hash{$wordn} combination used more than once in file $fileName!\n"; - } - } - - if ( ! $found ) - { - push @{ $Comps{$comp} }, \%hash; - } - } -} - - -sub hasheq -{ - my ($cmpnum, $ha1, $ha2) = @_; - my $h1w2 = ""; - my $h2w2 = ""; - - $h1w2 = $1 if $ha1->{$wordn} =~ /^(\w+)/; - $h2w2 = $1 if $ha2->{$wordn} =~ /^(\w+)/; - - if ( $ha1->{moduleid} eq $ha2->{moduleid} && - $ha1->{reasoncode} eq $ha2->{reasoncode} ) - { - if ($cmpnum eq 2) - { - return 1; - } - # compare one more parm (userdataX) - elsif ($cmpnum eq 3 && - $h1w2 eq $h2w2 ) - { - return 1; - } - else - { - return 0; - } - } - else - { - return 0; - } -} - -sub TakeOffRedundantFunc -{ - my ( $aref ) = @_; - - my @nonRedundantComps; - my $sameflag = 0; - my $i; - my $j; - - #take off redundent componets - for($j = 0; $j < @$aref; $j++) - { - for($i = ($j + 1); $i < @$aref; $i++) - { - if ( hasheq( 2, @$aref[$j], @$aref[$i]) ) - { - $sameflag = 1; - last; - } - } - - if ($sameflag == 0) - { - push @nonRedundantComps, @$aref[$j]; - } - $sameflag = 0; - } - - return @nonRedundantComps; -} - - -sub DumpPlugin -{ - my ( $compName, $aref ) = @_; - my $filename = "$output/$compName" . "SrcParse.C"; - my $filename2 = "$output/$compName" . "SrcParse.H"; - - my $fh; - my $fh2; - - #if the plugins subdir doesn't exist, create it - if (!-e $output) - { - print "Creating directory $output\n"; - `mkdir -p $output`; - } - - `rm -f $filename`; - `rm -f $filename2`; - - open $fh, ">$filename" or die "Cannot open $filename: $!\n"; - open $fh2, ">$filename2" or die "Cannot open $filename2: $!\n"; - - DumpHeader( $compName, $fh, $fh2 ); - - DumpPrototypes( $fh, $aref ); - - DumpTable( $fh, $compName, $aref ); - - DumpBody( $fh ); - - DumpParsers( $fh, $aref ); - - close $fh or die "Cannot close $filename: $!\n"; - close $fh2 or die "Cannot close $filename: $!\n"; -} - - - - -sub DumpHeader -{ - my ( $compName, $fh, $fh2 ) = @_; - my $schdr = $compName . "SrcParse.H"; - my $struct = $compName . "SrcParser"; - my $timestamp = ctime(); - - #lets look for the header includes we will need! - my $compIdFiles=`find $base -type f -name \"comp_ids.h\"`; - my @compIdFilesArray= split("\n", $compIdFiles); - - - my $headerString = "// includes from occ code base \n// $base \n"; - foreach my $val (@compIdFilesArray) - { - #print "IncludeFiles:: $val \n"; - - open ( my $l_fh, $val ) or die "Could not open $val"; - - my $filedata = ""; - my $start=0; - while (my $row = <$l_fh>) - { - chomp $row; - if ( $row =~ /#ifndef/) - { - $start = 1; - } - - if ($start == 1) - { - if ( $row =~ /#include/) - { - #ignore the line - } - else - { - $filedata .= "$row \n"; - } - } - - if ( $row =~ /#endif/) - { - $start = 0; - } - - } - - #print "$filedata \n"; - close ($l_fh); - - # strip off everyting and get current Sandbox File - #my $tmp2 = rindex($val, "/") + 1; - #my $FileName = substr($val, $tmp2); - - #$headerString .= "#include <$FileName> \n"; - $headerString .= "$filedata \n"; - } - - - #lets look for the header includes we will need! - my $IncludeFiles=`find $base -type f -name \"*_service_codes.h\"`; - my @IncludeFilesArray= split("\n", $IncludeFiles); - - foreach my $val (@IncludeFilesArray) - { - #print "IncludeFiles:: $val \n"; - - open ( my $l_fh, $val ) or die "Could not open $val"; - - my $filedata = ""; - my $start=0; - while (my $row = <$l_fh>) - { - chomp $row; - if ( $row =~ /#ifndef/) - { - $start = 1; - } - - if ($start == 1) - { - if ( $row =~ /#include/) - { - #ignore the line - } - else - { - $filedata .= "$row \n"; - } - } - - if ( $row =~ /#endif/) - { - $start = 0; - } - - } - - #print "$filedata \n"; - close ($l_fh); - - # strip off everyting and get current Sandbox File - #my $tmp2 = rindex($val, "/") + 1; - #my $FileName = substr($val, $tmp2); - - #$headerString .= "#include <$FileName> \n"; - $headerString .= "$filedata \n"; - } - - - #print "$headerString "; - - my $filehdr = " - -/* - * Automatically generated by $0 - * - * TimeStamp: $timestamp - * -*/ - -/*****************************************************************************/ -// I n c l u d e s -/*****************************************************************************/ -#include <cstring> -#include <errno.h> - -#include <errlplugins.H> -#include <errlusrparser.H> -#include <srcisrc.H> - -#include <$schdr> - -typedef void (*parser_t) ( ErrlUsrParser & i_parser, const SrciSrc & i_src ); - - -// Returns specified userdata word (1-4) for supplied SRC -uint32_t get_usrword(const SrciSrc & i_src, const uint8_t i_userdata_num) -{ - const uint32_t *l_wordarray = NULL; - uint32_t l_wordcount = 0; - uint32_t l_word = 0; - uint16_t l_index = i_userdata_num + 3; // userdata1 is at array index 4, ... - - // Access user words 2-9 and get count - l_wordarray = i_src.getHexData(l_wordcount); - if ( l_index < l_wordcount) - { - l_word = l_wordarray[l_index]; - } - - return l_word; -} - - -/*****************************************************************************/ -// Forward -/*****************************************************************************/ -static bool SrcDataParse( - ErrlUsrParser & i_parser, - const SrciSrc & i_src -); - - -/*****************************************************************************/ -// User types -/*****************************************************************************/ -struct $struct -{ - uint32_t iv_uid; - parser_t iv_parser; -}; - - -/*****************************************************************************/ -// Prototypes -/*****************************************************************************/ -"; - - print $fh $filehdr; - print $fh2 $headerString; -} - - -sub DumpPrototypes -{ - my ( $fh, $aref ) = @_; - my $forward; - - # get nonRedundant functions to avoid declare same prototype for miltiple times. - my @nonRedundant = TakeOffRedundantFunc($aref); - - foreach my $href ( @nonRedundant ) - { - $forward = "void Parse_$href->{moduleid}_$href->{reasoncode}( ErrlUsrParser & i_parser, const SrciSrc & i_src );\n"; - print $fh $forward; - } - - print $fh "\n\n"; - -} - - -sub DumpTable -{ - my ( $fh, $compName, $aref ) = @_; - my $structname = $compName . "SrcParser"; - my $compId = ( uc $compName ) . "_COMP_ID"; - my $header = " -/*****************************************************************************/ -// Globals -/*****************************************************************************/ -static errl::SrcPlugin g_SrcPlugin( $compId, SrcDataParse ); - -static $structname g_ParserList[] = -{ -"; - - my $footer = -" { 0, 0 } -};"; - - my $forward; - - print $fh $header; - - # get nonRedundant functions to avoid declare same function for miltiple times. - my @nonRedundant= TakeOffRedundantFunc($aref); - - foreach my $href ( @nonRedundant ) - { - $forward = " { ( ( $href->{moduleid} << 16 ) | ( OCCC_COMP_ID | $href->{reasoncode}) ), Parse_$href->{moduleid}_$href->{reasoncode} },\n"; - print $fh $forward; - } - - print $fh "$footer\n\n"; - -} - -sub DumpBody -{ - my ( $fh ) = @_; - print $fh " -/*****************************************************************************/ -// Main Parser -/*****************************************************************************/ -bool SrcDataParse( - ErrlUsrParser & i_parser, - const SrciSrc & i_src -) -{ - // Locals - int l_cntr = 0; - uint32_t l_uid = 0; - bool l_rc = false;"; - - - if ( $Errno > 0 ) # || $wordnd > 0 - { - print $fh " - const uint32_t *l_wa = 0; - uint32_t l_wc = 0; - - // Access user words - l_wa = i_src.getHexData(l_wc);"; - - } - - print $fh " - - // Form Unique Id - uint8_t l_w4 = (uint8_t) ( ( get_usrword(i_src,4) & 0xFF000000) >> 24); //extract the component id from word 4 - l_uid = (l_w4 << 24) | ( i_src.moduleId() << 16 ) | i_src.reasonCode(); - - //i_parser.PrintNumber( \"original l_uid: \", \"0x%08X\", l_uid ); - - //i_parser.PrintNumber( \"new gList value\", \"0x%08X\", ( (AMEC_MST_CHECK_UNDER_PCAP & 0x00FF) << 16 ) | (OCCC_COMP_ID|INTERNAL_FAILURE) ); - - - "; - - - if ( $Errno > 0 ) - { - print $fh " - - // Set errno - errno = l_wa[$Errno+3];"; - - } - - print $fh " - - // Find unique parser and transfer control - while ( g_ParserList[l_cntr].iv_uid ) - { - if ( g_ParserList[l_cntr].iv_uid == l_uid ) - { - g_ParserList[l_cntr].iv_parser( i_parser, i_src ); - l_rc = true; - break; - } - l_cntr++; - } - - return l_rc; -} - - -"; - - -} - - -sub DumpParsers -{ - - my ( $fh, $aref ) = @_; - my $FuncName; - - foreach my $href ( @$aref ) - { - my $mid = $href->{moduleid}; - my $erc = $href->{reasoncode}; - - $FuncName = "Parse_$mid\_$erc"; - - my $header = " -/*****************************************************************************/ -// $mid, $erc -/*****************************************************************************/ -void $FuncName( ErrlUsrParser & i_parser, const SrciSrc & i_src ) -{ -"; - print $fh $header; - - my @sameComps; - my @othersComps; - my $other; - #check if we have the same modid and reason code, but different data4. - while (@$aref != "") - { - $other = pop (@$aref); - if ( ($href != $other) && - hasheq( 2, $href, $other) ) - { - push @sameComps, $other; - } - else - { - push @othersComps, $other; - } - } - @sameComps = reverse(@sameComps); - @othersComps = reverse(@othersComps); - @$aref = @othersComps; - -# print "I am $href, othersComps = @othersComps\n"; -# print "Current Array: @$aref\n"; -# printf "--------------------\n"; - - #add itself into array - push @sameComps, $href; - - my %hashtemp; - #if more than one errl has same moduleID/reason, sort errl by userdata4. - if (@sameComps > 1) - { - my @tempComps; - my @Result; - my $temp; - my $wdnString; - - while (@sameComps) - { - $temp = pop (@sameComps); - %hashtemp = %{ $temp }; - - # if userdata4 filed is not null, put it to the front of result array. - if ($hashtemp{$wordn} ne "") - { - # check if userdata4 still has string - $wdnString = $hashtemp{$wordn} =~ /[:alpha:]/; - if ($wdnString) - { - print "WARNING: userdata4 can only be number!!! Current value =\"$hashtemp{$wordn}\", file : $hashtemp{file}\n"; - } - - push @Result, $temp; - } - else - { - push @tempComps, $temp; - } - } - - # push remain elements(userdata4 == null) into end of result array - while (@tempComps) - { - $temp = pop (@tempComps); - push @Result, $temp; - } - # write Result back - @sameComps = @Result; - } - - my $i; - my $errl; - # create code for Errl combination - for($i = 0; $i < scalar(@sameComps); $i++) - { - $errl = @sameComps[$i]; - %hashtemp = %{ $errl }; - - #print if/esle case - if (scalar(@sameComps) > 1) - { - if ( $i eq 0 ) - { - print $fh " - uint32_t l_word = (get_usrword(i_src,4) & 0x00FFFFFF)\; - if (l_word == $hashtemp{$wordn}) - {\n"; - } - elsif ($i eq (@sameComps - 1)) - { - print $fh " - else - {\n"; - } - else - { - print $fh " - else if (l_word == $hashtemp{$wordn}) - {\n"; - } - } - - #print code line by line for errl detail. - foreach my $tag ( sort keys %$errl ) - { - $errl->{$tag} =~ s/\"/\\\"/g; - - # Do not print out file information which is not require by LOG - if ( $tag =~ /file/ ) - { - next; - } - - my @lines = split /^/, $errl->{$tag}; - - # if we have if/else cases, shift 4 space for coding standard. - if (scalar(@sameComps) > 1) - { - print $fh " "; - } - - if ( scalar(@lines) > 1 ) - { - print $fh " i_parser.PrintString(\"$tag\",\n"; - foreach my $line ( @lines ) - { - $line =~ s/\n//g; - print $fh " \"$line\"\n"; - } - print $fh " );\n"; - } - else - { - my $line = $errl->{$tag}; - $line =~ s/\n//g; - - if ( $tag =~ /$Errno/ ) - { - print $fh " i_parser.PrintString(\"errno\", strerror(errno));\n"; - } - elsif ( $NA == 1 || ! ( $line =~ /^N\/??A/ ) ) - { - print $fh " i_parser.PrintString(\"$tag\", \"$line\");\n"; - } - } - - } - - if ( scalar(@sameComps) > 1) - { - print $fh " }" - } - } - print $fh "\n}\n\n\n"; - } - -} - -sub DumpMakefile -{ - my $filename = "$output/makefile"; - my $fh; - my $fcid; # Fips Component Ids - my %comphash; - - if ( ! open $fcid, "<$fips_comp_id" ) - { - print "Cannot open $fips_comp_id: $! - makefile will NOT be created\n"; - return; - } - else - { - my $data; - read $fcid, $data, -s $fcid or die "Error reading $fips_comp_id: $!"; - close $fcid; - %comphash = $data =~ /(\w{4})_COMP_ID.*?=.*?0x(\w{4})/mg; - #foreach my $key ( sort keys %comphash ) - #{ - # print "MAP: $key->$comphash{$key}\n"; - #} - } - if ( ! open $fh, ">$filename" ) - { - print "Cannot open $filename: $! - makefile will NOT be created\n"; - return; - } - - my @keys = keys %Comps; - my %libnames; - - print $fh "\n"; - foreach my $key ( @keys ) - { - my $uKey = $key; - $uKey =~ tr/a-z/A-Z/; - $libnames{$key} = "libE-" . $comphash{$uKey} . ".so"; - my $srcfile = $key . "SrcParse.o\n"; - print $fh "$libnames{$key}_OFILES = $srcfile"; - #$libnames{$key} = $libnames{$key} . ".so"; - } - print $fh "\n"; - - print $fh "INCFLAGS\t+= "; - foreach my $key ( @keys ) - { - print $fh "-I../$key/fsp "; - } - print $fh "\n\n"; - - print $fh "SHARED_LIBRARIES\t=\t\t\\\n"; - foreach my $key ( @keys ) - { - print $fh "\t$libnames{$key} \t\\\n"; - } - print $fh "\n\n"; - - print $fh ".if ( \$(CONTEXT) != \"x86\" )\n"; - foreach my $key ( @keys ) - { - print $fh "$libnames{$key}_IDIR = /fs/nfs.fips/lib/\n"; - } - print $fh ".endif\n\n"; - - print $fh "SHIPLIST = \$\{ILIST\}\n\n"; - - print $fh ".include<\$\{RULES_MK\}>\n\n"; - - close $fh or die "Cannot close $filename: $!\n"; -} diff --git a/src/occ/tools/start_occ_simics.pl b/src/occ/tools/start_occ_simics.pl deleted file mode 100755 index 15c8890..0000000 --- a/src/occ/tools/start_occ_simics.pl +++ /dev/null @@ -1,251 +0,0 @@ -#!/usr/bin/perl -w - -#---------------------------------------------------------------------------- -use strict; -use Cwd; - -#use Getopt::Long; -#use File::Basename; -#use Time::Local; -#use POSIX qw(strftime); -#use Carp; -#use FindBin; # std -#use Cwd 'abs_path'; - -#use Time::Local; - -use lib "$ENV{'sb'}/simu/fsp/perl/CPAN"; -use lib "$ENV{'bb'}/src/simu/fsp/perl/CPAN"; - -# Setup/declare some of our initial variables -my $configuration_file = "$ENV{'HOME'}/.occ_simics_config"; -my $cur_dir = getcwd(); -my $use_gdb = 0; # Default to not allowing GDB in simics -my $verbose = 0; # Default to non-verbose output -my $commands = ""; - -my $target = "occ-simple-common.simics"; -my $binary_file = "validation/apps/ocb_irq/ocb_irq.out"; -my $simics_workspace = ""; -my @search_paths; - -# Read in the configuration file -read_configuration_file(); - -#start by handling the command line arguments -process_command_line(); - -# Add $simics_workspace and $cur_dir to @search_paths -push @search_paths, $simics_workspace; -push @search_paths, $cur_dir; - -# Now put all our read in options together... -$target = find_full_path($target); -$binary_file = find_full_path($binary_file); - - -# And setup our command line arguments -my $binary_cmd = "oci_space.load-binary $binary_file"; -my $symtable_cmd = "new-symtable st $binary_file"; -my $gdb_cmd = "new-gdb-remote"; - -my $full_command = "\"" . $binary_cmd . ";" . $symtable_cmd . ";" . $commands; -if($use_gdb) -{ - $full_command .= $gdb_cmd . ";"; -} -$full_command .= "\""; - -# Create the simics command -if($verbose) -{ - print "Target: $target\n"; - print "Binary: $binary_file\n"; -} -my $simics_command = "ulimit -c unlimited; $simics_workspace/simics -verbose $target -e $full_command"; - - -# Run the simics command -if($verbose) -{ - print "\nRunning $simics_command\n"; -} - -system("$simics_command"); - -exit 0; - - - - -############################################################################### -# Helper Functions # -############################################################################### - - -################################################################################ -# -# Processes any command line arguments. -# -################################################################################ -sub process_command_line -{ - my $n = 0; - - while ( $n < @ARGV ) - { - $_ = $ARGV[$n]; - chomp($_); - - if (/^-h$/i || /^--h$/i || /^-help$/i || /^--help$/i) - { - print "start_occ_simics.pl [options] [binary .out file]\n\n"; - print "Based on your \$HOME/.occ_simics_config and passed in arguments, it will start\n"; - print "a simics session. The parameters in the EXAMPLE_.occ_simics_config file:\n"; - print "\tSIMICS_WORKSPACE: Path to simics workspace\n"; - print "\tDEFAULT_TARGET: Target you wish you to use in the target directory under simics-workspace\n"; - print "\tDEFAULT_BINARY: Binary value to use like occ.out\n"; - print "\tPATH: Paths to check when looking for target/binary files. Checked recursively\n"; - print "\tCOMMAND: Comands to run immediately when starting simics. Can add directories, set output-radix, etc\n"; - print "\n"; - print "Arguments to start_occ_simics.pl\n"; - print "-t Modifies the target\n"; - print "-g Automatically enables GDB\n"; - print "-v Verbose option\n"; - print "\n"; - exit 0; - } - elsif(/^-t$/i || /^--target$/i) - { - $target = $ARGV[$n + 1] or die "Bad command line variable: expecting a target\n"; - $n++; - } - elsif(/\.out/) - { - $binary_file = $ARGV[$n]; - } - elsif(/^-g$/i) - { - $use_gdb = 1; - } - elsif(/^-v/) - { - $verbose = 1; - } - else - { - print ("Unrecognized command: $_ \n"); - print ("To view all the options and help text run \'start_simics -h\' \n"); - exit 1; - } - - $n++; - } -} - -################################################################################ -# -# Parses the configuration file located at $configuration_file -# -################################################################################ -sub read_configuration_file -{ - - open(CONFIG_FILE, "$configuration_file") || warn "Could not read $configuration_file\n"; - - - while(<CONFIG_FILE>) - { - #print $_; - if(/^SIMICS_WORKSPACE\s*=\s*(\/.*)/) - { - $simics_workspace = $1; - chomp $simics_workspace; - - my $last_char = substr $simics_workspace,-1,1; - if($last_char ne '/') - { - $simics_workspace .= "/"; - } - } - elsif(/^PATH\s*=\s*(\/.*)/) - { - my $path = $1; - chomp $path; - - my $last_char = substr $path,-1,1; - if($last_char ne '/') - { - $path .= "/"; - } - - push @search_paths, $path; - } - elsif(/^DEFAULT_TARGET\s*=\s*(\/.*)/) - { - $target = $1; - chomp $target; - } - elsif(/^DEFAULT_BINARY\s*=\s*(\/.*)/) - { - $binary_file = $1; - chomp $binary_file; - } - elsif(/^COMMAND\s*=\s*(.*)/) - { - my $tmp_cmd = $1; - chomp $tmp_cmd; - #print "Saw $tmp_cmd\n"; - $commands .= $1 . ";"; - } - } - - close(CONFIG_FILE); -} - - - -################################################################################ -# -# Finds the full path for a passed in file using @search_paths -# -################################################################################ -sub find_full_path -{ - my $arg = shift; - - # If $arg starts with "/" assume we were given the full path - if($arg =~ /^\//) - { - # Do nothing - } - else - { - my $entry_found = 0; - - foreach my $path (@search_paths) - { - # Need to find the file based off either our $cur_dir or $simics_workspace - my @output = `find $path 2>&1 | grep $arg `; - foreach my $entry (@output) - { - chomp $entry; - if($entry =~ /$arg$/) - { - $arg = $entry; # $arg now has the full path - $entry_found = 1; - last; - } - } - - if($entry_found) - { - last; - } - } - - $entry_found or die "Could not find $arg"; - } - - return $arg; -} diff --git a/src/occ/tools/trexStringFile b/src/occ/tools/trexStringFile deleted file mode 100755 index 9cbf2db..0000000 --- a/src/occ/tools/trexStringFile +++ /dev/null @@ -1,12 +0,0 @@ -#FSP_TRACE_v2|||6/17/2010|||BUILD:OCC 1 -761415651||Trace buffers initialized|| -959803951||timer_routine loop %d|| -2017357799||PRCD Thread|| -3219055108||Main Thread|| -1049182497||timer: New maximum time of %d ticks (10 ticks = 6 ns?)|| -459971656||Procedure Number: %d completed|| -4171193265||First Critical Timer Tick|| -2775191224||>>PRCD_update_procedures|| -26695188||Exit: PRCD_update_procedures|| -481443942||PRCD Submit %d|| - diff --git a/src/occApplet/productApplet/Makefile b/src/occApplet/productApplet/Makefile index e87e37d..f95f41f 100755 --- a/src/occApplet/productApplet/Makefile +++ b/src/occApplet/productApplet/Makefile @@ -1,39 +1,8 @@ -# $Id$ -# @file Makefile -# -# @brief OCC Product Applet Makefile -# -# @page ChangeLogs Change Logs -# @section Makefile -# @verbatim -# -# -# Change Log ****************************************************************** -# Flag Defect/Feature User Date Description -# ------ -------------- ---------- ------------ ----------- -# @pb001 pbavari 07/18/2011 Created -# @ani01 abagepa 08/08/2011 Creating to "test" applets -# as placeholders for real applets -# Update to include for easier compiling -# @pb006 pbavari 09/16/2011 Display size support -# @pb004 pbavari 09/20/2011 Initialization Section support -# @pb00A pbavari 11/14/2011 Moved sensor_init from applet to init section -# @th005 thallet 11/23/2011 Sensor querySensorList support -# @pb00C pbavari 01/20/2012 Added debug_trace.mk -# @rc003 rickylie 02/03/2012 Verify & Clean Up OCC Headers & Comments -# @at009 859308 alvinwan 10/15/2012 Added tracepp support -# @th029 thallet 01/23/2013 MD5sum in applet version & include aplt headers -# -# @endverbatim -# - -# >> gitprep ifndef ROOTPATH ROOTPATH = $(shell pwd)/../../ export OCCROOT = $(ROOTPATH) endif -# << gitprep #******************************************************************************* # mk variable Declaration @@ -44,71 +13,44 @@ SSX = ../../ssx PRODUCTAPPLET = . LIB = ../../lib -# New product applet source file must to listed as part of the SOURCES variable -# to create product applet image. Prodcut applet images will be added to the -# mainstore single image in the order source files are listed in SOURCES -# variable. -# @ani01c -# Note: New applets must be updated in the applet enum list -# see occ/aplt/appletManager.h +# New product applet source files must to listed in productappletfiles.mk +# Note: New applets must be given an ID in src/occ/aplt/incl/appletId. -# >> gitprep -# Add missing flags for GNU build LDFLAGS = -L $(SSX)/ssx -L $(SSX)/ppc32 -L $(SSX)/ppc405 -L $(SSX)/pgp \ - -L $(OCC) -L $(LIB) -lssx -lppc32 --oformat=elf32-powerpc -melf32ppc +-L $(OCC) -L $(LIB) -lssx -lppc32 --oformat=elf32-powerpc -melf32ppc + buildImage = $(LD) -R $(OCC)/occ.out $(obj) -Tlinkscript $(LDFLAGS) \ - -Map $(basename $(obj)).map -Bstatic -o $(basename $(obj)).out;\ - $(OBJCOPY) -I elf32-powerpc -O binary $(basename $(obj)).out $(basename $(obj)).bin; \ - $(OBJDUMP) -d $(basename $(obj)).out > $(basename $(obj)).dis; \ - $(BOOTLOADER)/imageHdrScript $(basename $(obj)).bin `md5sum $(OCC)/occ.out | cut -c 1-4`; -# << gitprep +-Map $(basename $(obj)).map -Bstatic -o $(basename $(obj)).out; \ +$(OBJCOPY) -I elf32-powerpc -O binary $(basename $(obj)).out $(basename $(obj)).bin; \ +$(OBJDUMP) -d $(basename $(obj)).out > $(basename $(obj)).dis; \ +$(BOOTLOADER)/imageHdrScript $(basename $(obj)).bin `md5sum $(OCC)/occ.out | cut -c 1-4`; -image = $(BOOTLOADER)/imageHdrScript $(basename $(obj)).bin combineImage;\ - $(BOOTLOADER)/imageHdrScript $(basename $(obj)).out displaySize; +image = $(BOOTLOADER)/imageHdrScript $(basename $(obj)).bin combineImage; \ +$(BOOTLOADER)/imageHdrScript $(basename $(obj)).out displaySize; #******************************************************************************* # Includes #******************************************************************************* include $(SSX)/pgp/ssx.mk -#$pb00Ca - Added for debug traces -include $(OCC)/debug_trace.mk include productappletfiles.mk -# >> gitprep -# Add needed includes for GNU build INCLUDES = -I. -I$(OCC)/incl -I$(OCC)/errl -I$(OCC)/trac -I$(LIB) -I$(SSX)/ssx \ - -I$(OCC)/sensor -I$(OCC) -I$(OCC)/rtls -I$(OCC)/cmdh -I$(OCC)/pss -I$(OCC)/gpe \ - -I$(OCC)/aplt/incl -I$(OCC)/aplt -I$(OCC)/cent -I$(OCC)/proc -I$(OCC)/thread \ - -I$(SSX)/ppc405 -I$(SSX)/pgp -I$(SSX)/ppc32 -I$(SSX)/pgp/registers -# << gitprep +-I$(OCC)/sensor -I$(OCC) -I$(OCC)/rtls -I$(OCC)/cmdh -I$(OCC)/pss -I$(OCC)/gpe \ +-I$(OCC)/aplt/incl -I$(OCC)/aplt -I$(OCC)/cent -I$(OCC)/proc -I$(OCC)/thread \ +-I$(SSX)/ppc405 -I$(SSX)/pgp -I$(SSX)/ppc32 -I$(SSX)/pgp/registers #******************************************************************************* -# Flags +# Defs #******************************************************************************* -#D = -DSIMICS_MAGIC_PANIC=1 \ - -DINITIALIZE_SIMICS_IO=1 - DEFS += $(D) DEFS += -DAPPLET_BUILD=1 -# >> gitprep -# Very important we build applets with custom cfg header DEFS += -DUSE_SSX_APP_CFG_H=1 -# << gitprep -# If this makefile is called as "make NO_TRAC_STRINGS=1" then trace strings -# won't be built into the image. This will be used for metrics regarded to the -# realistic OCC Code Size. Note that "make clean" must be run before this define -# will be picked up by the compiler, otherwise previously compiled objects will -# be used. You can also see the space used by strings by running: -# strings occ.bin | \grep "ERR\|INF\|IMP" | sed 's/^...: %s: //g' | wc -m -ifdef NO_TRAC_STRINGS -D += -DNO_TRAC_STRINGS=1 -endif - -# Do not use SDA sections for product applet +# Note: Do not use SDA sections for product applet GCC-CFLAGS = -c -g -Wall -fsigned-char -msoft-float -pipe \ - -Wa,-m405 -m32 -mcpu=405 -mmultiple -mstring -meabi \ - -ffreestanding -Os -mno-sdata +-Wa,-m405 -m32 -mcpu=405 -mmultiple -mstring -meabi \ +-ffreestanding -Os -mno-sdata + #******************************************************************************* # Compilation #******************************************************************************* @@ -128,3 +70,4 @@ combineImage: #******************************************************************************* clean: rm -f *.o *.out *.bin *.dis *.map *.hash linkscript + diff --git a/src/occApplet/testApplet/Makefile b/src/occApplet/testApplet/Makefile index 9a5ea0b..dba7068 100755 --- a/src/occApplet/testApplet/Makefile +++ b/src/occApplet/testApplet/Makefile @@ -1,92 +1,46 @@ -# @file Makefile -# -# @brief OCC Test Applet Makefile -# -# @page ChangeLogs Change Logs -# @section Makefile -# @verbatim -# -# -# Change Log ****************************************************************** -# Flag Defect/Feature User Date Description -# ------ -------------- ---------- ------------ ----------- -# @pb001 pbavari 07/18/2011 Created -# @pb002 pbavari 08/17/2011 Added sensorTest.c -# @cc000 cjcain 08/30/2011 Added apssTest.c -# @pb004 pbavari 09/15/2011 Added support for calling -# product aplt from test aplt -# @02 tapiar 10/03/2011 Adding new dir includes -# @dw000 dwodham 12/13/2011 Add include for appletId -# @rc001 rickylie 01/16/2012 Include debug_trace.mk -# @rc003 rickylie 02/03/2012 Verify & Clean Up OCC Headers & Comments -# @at002 alvinwan 02/10/2012 Added errlTest.c -# @at009 859308 alvinwan 10/15/2012 Added tracepp support -# @th029 thallet 01/23/2013 Added md5sum in version -# -# @endverbatim -# - -# >> gitprep ifndef ROOTPATH ROOTPATH = $(shell pwd)/../../ export OCCROOT = $(ROOTPATH) endif -# << gitprep #******************************************************************************* -# mk variable Declaration +# make variables #******************************************************************************* OCC = ../../occ BOOTLOADER = ../../occBootLoader SSX = ../../ssx TESTAPPLET = . LIB = ../../lib - -# >> gitprep -# Add missing link flags fir GNU build LDFLAGS += --oformat=elf32-powerpc -melf32ppc buildImage = $(LD) -R $(OCC)/occ.out $(obj) -Tlinkscript $(LDFLAGS) \ - -Map $(basename $(obj)).map -Bstatic -o $(basename $(obj)).out;\ - $(OBJCOPY) -I elf32-powerpc -O binary $(basename $(obj)).out $(basename $(obj)).bin; \ - $(OBJDUMP) -d $(basename $(obj)).out > $(basename $(obj)).dis; \ - $(BOOTLOADER)/imageHdrScript $(basename $(obj)).bin `md5sum $(OCC)/occ.out | cut -c 1-4`; \ -# << gitprep +-Map $(basename $(obj)).map -Bstatic -o $(basename $(obj)).out; \ +$(OBJCOPY) -I elf32-powerpc -O binary $(basename $(obj)).out $(basename $(obj)).bin; \ +$(OBJDUMP) -d $(basename $(obj)).out > $(basename $(obj)).dis; \ +$(BOOTLOADER)/imageHdrScript $(basename $(obj)).bin `md5sum $(OCC)/occ.out | cut -c 1-4`; \ #******************************************************************************* # Includes #******************************************************************************* include $(SSX)/pgp/ssx.mk -#@rc001a -include $(OCC)/debug_trace.mk include testappletfiles.mk INCLUDES = -I. -I$(OCC)/rtls -I$(OCC)/incl -I$(OCC)/errl -I$(OCC)/trac -I$(LIB) -I$(SSX)/ssx INCLUDES += -I$(SSX)/ppc405 -I$(SSX)/pgp -I$(SSX)/ppc32 -I$(SSX)/pgp/registers INCLUDES += -I$(OCC)/sensor -I$(OCC)/pss -I$(OCC)/gpe -I$(OCC) -I$(OCC)/aplt -I$(OCC)/dcom -# >> gitprep -# Add missing include paths INCLUDES += -I$(OCC)/aplt/incl -I$(OCC)/cmdh -# << gitprep #******************************************************************************* -# Flags +# Defs #******************************************************************************* -#D = -DSIMICS_MAGIC_PANIC=1 \ - -DINITIALIZE_SIMICS_IO=1 - DEFS += $(D) -DEFS += -DOCC=1 \ - -DUSE_SSX_APP_CFG_H=1 +DEFS += -DOCC=1 -DUSE_SSX_APP_CFG_H=1 # Do not use SDA sections for product applet -# >> gitprep -# Add missing compile flags for GNU build GCC-CFLAGS = -c -g -Wall -fsigned-char -msoft-float -pipe \ - -m32 -Wa,-m405 -mcpu=405 -mmultiple -mstring -meabi \ - -ffreestanding -Os -mno-sdata -# << gitprep +-m32 -Wa,-m405 -mcpu=405 -mmultiple -mstring -meabi \ +-ffreestanding -Os -mno-sdata #******************************************************************************* # Compilation @@ -105,3 +59,4 @@ combineImage: #******************************************************************************* clean: rm -f *.o *.out *.bin *.dis *.map *.hash linkscript + |