diff options
author | Adam Muhle <armuhle@us.ibm.com> | 2011-08-10 16:21:12 -0500 |
---|---|---|
committer | ADAM R. MUHLE <armuhle@us.ibm.com> | 2011-08-15 08:53:32 -0500 |
commit | c7b83cbaf5b18e72846e24e26f990babc5b02708 (patch) | |
tree | fc9a5e5771c9f08ed89e688d265434a5f0fcdcc9 /src/build | |
parent | 65f04fd6c74f04a3d7b0f11c3f21e634a2b0a9e8 (diff) | |
download | talos-hostboot-c7b83cbaf5b18e72846e24e26f990babc5b02708.tar.gz talos-hostboot-c7b83cbaf5b18e72846e24e26f990babc5b02708.zip |
Move fakePNOR to 5MB, copy fakeext image to sandbox, load fakeext/TOC into phys_mem
Change-Id: Ie9243f22f7afbfd2d3112fa17fe74999467d2dd6
Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/251
Tested-by: Jenkins Server
Reviewed-by: Douglas R. Gilbert <dgilbert@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Diffstat (limited to 'src/build')
-rw-r--r-- | src/build/makefile | 2 | ||||
-rwxr-xr-x | src/build/simics/post_model_hook.simics | 38 | ||||
-rw-r--r-- | src/build/tocgen/makefile | 20 | ||||
-rwxr-xr-x | src/build/tocgen/mkpnortoc.pl | 323 | ||||
-rw-r--r-- | src/build/tocgen/pnortoc.xml | 134 | ||||
-rwxr-xr-x | src/build/tools/cpfiles.pl | 8 |
6 files changed, 522 insertions, 3 deletions
diff --git a/src/build/makefile b/src/build/makefile index 8d4c7d750..d9ef1d792 100644 --- a/src/build/makefile +++ b/src/build/makefile @@ -1,5 +1,5 @@ ROOTPATH = ../.. -SUBDIRS = linker.d +SUBDIRS = linker.d tocgen.d include ${ROOTPATH}/config.mk diff --git a/src/build/simics/post_model_hook.simics b/src/build/simics/post_model_hook.simics new file mode 100755 index 000000000..d87f999bc --- /dev/null +++ b/src/build/simics/post_model_hook.simics @@ -0,0 +1,38 @@ +################################################################################ +# IBM_PROLOG_BEGIN_TAG +# This is an automatically generated prolog. +# +# $Source: firmsim firmsim_vob/firmsim_comp/simics/post_model_hook.simics 1$ +# +# IBM CONFIDENTIAL +# +# OBJECT CODE ONLY SOURCE MATERIALS +# +# COPYRIGHT International Business Machines Corp. 2011,2011 +# All Rights Reserved +# +# The source code for this program is not published or otherwise +# divested of its trade secrets, irrespective of what has been +# deposited with the U.S. Copyright Office. +# +# IBM_PROLOG_END_TAG +# post_model_hook.simics +# This file is used to run a set of commands on the simics console after +# modules have loaded. +################################################################################ +# Example for Hostboot group: +#@os.environ["HOSTBOOT_SYMS"]="./hbicore.syms" +#@os.environ["HOSTBOOT_OFILE"]="./hbotStringFile" +#add-directory path="/esw/fips740/Builds/built/hostboot" +#run-python-file traceHB.py +#@del os.environ["HOSTBOOT_SYMS"] +################################################################################ + + +#setup traces +run-python-file traceHB.py + +#Load extended image and pnor.toc into phys_mem +#This will be merged into once the proper tools are written. +phys_mem.load-file ../img/hbicore_extended.bin 0x500690 +phys_mem.load-file ../img/pnor.toc 0x500000 diff --git a/src/build/tocgen/makefile b/src/build/tocgen/makefile new file mode 100644 index 000000000..cb872f1f1 --- /dev/null +++ b/src/build/tocgen/makefile @@ -0,0 +1,20 @@ + +#Temporary implementation to get a PNOR TOC created. This will all change once the PNOR +#layout is finalized and we put together some real build tools. +#TODO: restructure to fit the usual makefile structure +ROOTPATH = ../../.. + +pnortoc: + ${ROOTPATH}/src/build/tocgen/mkpnortoc.pl -i ${ROOTPATH}/src/build/tocgen/pnortoc.xml \ + -o ${ROOTPATH}/img/pnor.toc + +all: gen_pass + +code_pass: + +gen_pass: pnortoc + +clean: + +beam: + diff --git a/src/build/tocgen/mkpnortoc.pl b/src/build/tocgen/mkpnortoc.pl new file mode 100755 index 000000000..5a3d95d15 --- /dev/null +++ b/src/build/tocgen/mkpnortoc.pl @@ -0,0 +1,323 @@ +#!/usr/bin/perl +# File mkPnorTOC.pl created by ADAM R. MUHLE at 14:39:27 on Mon Aug 1 2011. + +#Limitations to address later +# number fields must be 4 or 8 bytes +# numbers cannot be over 32 bits + +#@TODO - enable "use strict" +#@TODO - standardize variable names, i_blah for input, etc. + +use XML::LibXML; +#use Data::Dumper; +use File::Basename; + +my $programName = File::Basename::basename $0; +my $g_trace = 0; # 1 -> enable traces +$tocDataFile = ""; +$tocOutFile = ""; + +if ($#ARGV < 0) { + usage(); + exit; +} + + +#Parse the commandline args +for ($i=0; $i < $#ARGV + 1; $i++) +{ + if ($ARGV[$i] =~ /-h/) { + usage(); + exit 0; + } + elsif($ARGV[$i] =~ /-v/) { + $verbose = 1; + } + elsif($ARGV[$i] =~ /-i/) { + $tocDataFile = $ARGV[++$i]; + trace(1, "Input Data File=$tocDataFile"); + } + elsif($ARGV[$i] =~ /-o/) { + $tocOutFile = $ARGV[++$i]; + trace(1, "Output Binary File=$tocOutFile"); + } + else { + #Error!! + } +} + + +#open output file +open( BIN_TOC_FILE, ">:raw", $tocOutFile) or die "Can't open $tocOutFile file for writing"; + +#parse the input XML file +$parser = XML::LibXML->new(); +$doc = $parser->parse_file($tocDataFile); + +#add the SBE field to the TOC +$sbeNodes = $doc->getElementsByTagName("sbeLoc"); +$onlySbeNode = $sbeNodes->pop(); +writeElementToBinFile(BIN_TOC_FILE, $onlySbeNode); + +#Add TOC version field to TOC +$tocVerNodes = $doc->getElementsByTagName("tocVersion"); +$onlytocVerNode = $tocVerNodes->pop(); +writeElementToBinFile(BIN_TOC_FILE, $onlytocVerNode); + + +#Add the individual TOC entries +$root = $doc->firstChild; +$curSibling = $root->firstChild; + +do { + #just in case the first childe is bad + if(!$curSibling) + { + last; + } + elsif($curSibling->nodeName eq "tocEntry") + { + parseTocEntry(BIN_TOC_FILE, $curSibling); + } + elsif(($curSibling->nodeName eq "sbeLoc") || + ($curSibling->nodeName eq "tocVersion")) + { + #skip these, already inserted above + } + +}while($curSibling = $curSibling->nextSibling); + + +close(BIN_TOC_FILE); +exit; + +################################################# +# Get Length of a field +# Searches XML element for sub-element called +# length +################################################# +sub getLength +{ + $element = @_[0]; + + $lenElements = $element->getElementsByLocalName("length"); + $lenEl = $lenElements->pop(); + + $len = $lenEl->firstChild->data; + chomp $len; + return $len; + +} + +################################################# +# Get format of a field +# Searches XML element for sub-element called +# format +################################################# +sub getFormat +{ + $element = @_[0]; + + $formatElements = $element->getElementsByLocalName("format"); + $formatEl = $formatElements->pop(); + + $format = $formatEl->firstChild->data; + chomp $format; + return $format; + +} + + +################################################# +# Get data value from provided XML element +# +################################################# +sub getValue +{ + $i_element = @_[0]; + + $value = $i_element->firstChild->data; + + $value =~s/\s+$//; + chomp $value; + + return $value; +} + +################################################# +# parse <tocEntry> node, write bin data to file +# +################################################# +sub parseTocEntry +{ + ($i_FILEHANDLE, $i_element) = @_; + $entryLength = 0; + $sumFieldLen = 0; + local $curSibling; + + + $curSibling = $i_element->firstChild; + do { + #just in case the first childe is bad + if(!$curSibling) + { + last; + } + elsif($curSibling->nodeName eq "text") + { + #print "skipping ".$curSibling->nodeName."\n"; + } + elsif($curSibling->nodeName eq "length") + { + $entryLength = $curSibling->firstChild->data; + + } + else + { + $fieldLen = writeElementToBinFile($i_FILEHANDLE, $curSibling); + $sumFieldLen = $sumFieldLen + $fieldLen; + + } +# ($nextSibling = $curSibling->nextSibling) + + }while($curSibling = $curSibling->nextSibling); + + if($sumFieldLen > $entryLength) + { + trace(0, "Fields in TOC Entry consumed more space (".$sumFieldLen.") then they were supposed to (".$entryLength.")\n Aborting"); + exit 1; + } + elsif($sumFieldLen < $entryLength) + { + trace(1, "Need to insert padding to fill up TOC entry space"); + $padBytes = $entryLength - $sumFieldLen; + insertPadBytes($i_FILEHANDLE, $padBytes); + } + + +} +################################################# +# write provided element to binary file +# +################################################# +sub writeElementToBinFile +{ + ($i_FILEHANDLE, $i_element) = @_; + + $elValue = getValue($i_element); + $len = getLength($i_element); + $format = getFormat($i_element); + + trace(1, "Value=".$elValue." Length=".$len." Format=".$format); + + + if($format =~ "string") + { + #print in ascii + #pad on right side + @charArray = unpack("C*", $elValue); + foreach $char (@charArray) + { + print $i_FILEHANDLE pack('C', $char); + } + + $zeroPad = $len-length($elValue); + insertPadBytes($i_FILEHANDLE, $zeroPad); + } + elsif ($format =~ "number") + { + if(($len != 4) && + ($len != 8)) + { + trace(0, "field <length>=".$len.". Currently only lengths of 4 or 8 are supported. \n Aborting program"); + exit 1; + } + + if($len == 8) + { + print $i_FILEHANDLE pack('N', 0); + } + + #check if we have a hex number + if($elValue =~ "0x") + { + $num = oct($elValue); + } + else + { + $num = $elValue; + } + + #verify number consumes less than 32 bits + if($num > 0xFFFFFFFF) + { + trace(0, "number=".$num.". This is greater than 32 bits in hex and not currently supported!. \n Aborting program"); + exit 1; + } + + print $i_FILEHANDLE pack('N', $num); + + } + else + { + print "ERROR: Unrecognized <format> type: ".$format." Exiting!\n"; + exit 1; + } + + return $len + +} + +################################################# +# Insert specifed number of pad bytes into file +# +################################################# +sub insertPadBytes +{ + ($i_FILEHANDLE, $i_padBytes) = @_; + for($i=0; $i<$i_padBytes; $i++) + { + print $i_FILEHANDLE pack('C', 0); + } +} + + + + +################################################################################ +# trace +################################################################################ +sub trace +{ + ($i_traceLevel, $i_string) = @_; + + #traceLevel 0 is for errors + if($i_traceLevel == 0) + { + print "ERROR: ".$i_string."\n"; + } + elsif ($g_trace >= $i_traceLevel) + { + print "TRACE: ".$i_string."\n"; + } +} + +################################################################################ +# print usage instructions +################################################################################ +sub usage +{ +print <<"ENDUSAGE"; + $programName = Creates the PNOR Table of Contents (TOC) based on input XML file. + + Usage: + $programName -i <XML File> -o <binary Output File> + + Current Limitations: + --Hex/number fields must be 4 or 8 bytes in length + --Numbers cannot be over 32 bits (in hex) + The script will print and error and exit with a non-zero return code if these + conditions are encountered. + +ENDUSAGE +} diff --git a/src/build/tocgen/pnortoc.xml b/src/build/tocgen/pnortoc.xml new file mode 100644 index 000000000..2f530bdb6 --- /dev/null +++ b/src/build/tocgen/pnortoc.xml @@ -0,0 +1,134 @@ +<pnorToc> + <sbeLoc>0x180 + <length>8</length> + <format>number</format> + </sbeLoc> + <tocVersion>0xFFFF + <length>8</length> + <format>number</format> + </tocVersion> + <tocEntry> + <length>56</length> + <field type="eyeCatch">TOC + <length>8</length> + <format>string</format> + </field> + <field type="logical_offset">0 + <length>8</length> + <format>number</format> + </field> + <field type="physical_offset">0 + <length>8</length> + <format>number</format> + </field> + <field type="logical_size">0x690 + <length>8</length> + <format>number</format> + </field> + <field type="physical_size">0x690 + <length>8</length> + <format>number</format> + </field> + <field type="Act_logical_size">0 + <length>8</length> + <format>number</format> + </field> + <field type="Act_physical_size">0 + <length>8</length> + <format>number</format> + </field> + </tocEntry> + <tocEntry> + <length>56</length> + <field type="eyeCatch">HBI + <length>8</length> + <format>string</format> + </field> + <field type="logical_offset">0x690 + <length>8</length> + <format>number</format> + </field> + <field type="physical_offset">0x690 + <length>8</length> + <format>number</format> + </field> + <field type="logical_size">0x7D000 + <length>8</length> + <format>number</format> + </field> + <field type="physical_size">0x7D000 + <length>8</length> + <format>number</format> + </field> + <field type="Act_logical_size">0 + <length>8</length> + <format>number</format> + </field> + <field type="Act_physical_size">0 + <length>8</length> + <format>number</format> + </field> + </tocEntry> + <tocEntry> + <length>56</length> + <field type="eyeCatch">GLOBAL + <length>8</length> + <format>string</format> + </field> + <field type="logical_offset">0x7D690 + <length>8</length> + <format>number</format> + </field> + <field type="physical_offset">0x7D690 + <length>8</length> + <format>number</format> + </field> + <field type="logical_size">4096 + <length>8</length> + <format>number</format> + </field> + <field type="physical_size">4096 + <length>8</length> + <format>number</format> + </field> + <field type="Act_logical_size">0 + <length>8</length> + <format>number</format> + </field> + <field type="Act_physical_size">0 + <length>8</length> + <format>number</format> + </field> + </tocEntry> + <tocEntry> + <length>56</length> + <field type="eyeCatch">HBD + <length>8</length> + <format>string</format> + </field> + <field type="logical_offset">0x7E690 + <length>8</length> + <format>number</format> + </field> + <field type="physical_offset">0x7E690 + <length>8</length> + <format>number</format> + </field> + <field type="logical_size">8192 + <length>8</length> + <format>number</format> + </field> + <field type="physical_size">8192 + <length>8</length> + <format>number</format> + </field> + <field type="Act_logical_size">0 + <length>8</length> + <format>number</format> + </field> + <field type="Act_physical_size">0 + <length>8</length> + <format>number</format> + </field> + </tocEntry> +</pnorToc> diff --git a/src/build/tools/cpfiles.pl b/src/build/tools/cpfiles.pl index dc066d859..b17764e0f 100755 --- a/src/build/tools/cpfiles.pl +++ b/src/build/tools/cpfiles.pl @@ -34,6 +34,7 @@ sub printUsage; #List of files to copy. Path is relative to git repository. my @files = ("src/build/tools/exthbdump.pl", + "src/build/simics/post_model_hook.simics", "src/build/trace/traceHB.py", "img/hbotStringFile", "img/hbicore.syms", @@ -41,7 +42,9 @@ my @files = ("src/build/tools/exthbdump.pl", "img/hbicore.bin", "img/hbicore_test.bin", "img/hbicore.list", - "img/hbicore_test.list"); + "img/hbicore_test.list", + "img/hbicore_extended.bin", + "img/pnor.toc"); #Directories in base git repository my @gitRepoDirs = ("img", @@ -182,7 +185,8 @@ foreach (@files) #print "$filename, $directories, $suffix\n"; #Copy .bin to the img dir - if ($suffix eq ".bin") + if (($suffix eq ".bin") || + ($suffix eq ".toc")) { $copyDir = $imgDir; } |