diff options
Diffstat (limited to 'src/build/debug/Hostboot/HwpfAttrOverride.pm')
-rwxr-xr-x | src/build/debug/Hostboot/HwpfAttrOverride.pm | 809 |
1 files changed, 508 insertions, 301 deletions
diff --git a/src/build/debug/Hostboot/HwpfAttrOverride.pm b/src/build/debug/Hostboot/HwpfAttrOverride.pm index ef595bcee..daff19f5b 100755 --- a/src/build/debug/Hostboot/HwpfAttrOverride.pm +++ b/src/build/debug/Hostboot/HwpfAttrOverride.pm @@ -1,26 +1,26 @@ #!/usr/bin/perl -# IBM_PROLOG_BEGIN_TAG -# This is an automatically generated prolog. +# IBM_PROLOG_BEGIN_TAG +# This is an automatically generated prolog. # -# $Source: src/build/debug/Hostboot/HwpfAttrOverride.pm $ +# $Source: src/build/debug/Hostboot/HwpfAttrOverride.pm $ # -# IBM CONFIDENTIAL +# IBM CONFIDENTIAL # -# COPYRIGHT International Business Machines Corp. 2012 +# COPYRIGHT International Business Machines Corp. 2012,2013 # -# p1 +# p1 # -# Object Code Only (OCO) source materials -# Licensed Internal Code Source Materials -# IBM HostBoot Licensed Internal Code +# Object Code Only (OCO) source materials +# Licensed Internal Code Source Materials +# IBM HostBoot Licensed Internal Code # -# The source code for this program is not published or other- -# wise divested of its trade secrets, irrespective of what has -# been deposited with the U.S. Copyright Office. +# 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. # -# Origin: 30 +# Origin: 30 # -# IBM_PROLOG_END_TAG +# IBM_PROLOG_END_TAG # # This perl module will be used in a standalone Hostboot environment @@ -52,18 +52,21 @@ use constant TARGET_TYPE_MCS_CHIPLET => 0x00000040; use constant TARGET_TYPE_XBUS_ENDPOINT => 0x00000080; use constant TARGET_TYPE_ABUS_ENDPOINT => 0x00000100; -# From fapiAttributeTank.H +# From attributeTank.H use constant ATTR_POS_NA => 0xffff; use constant ATTR_UNIT_POS_NA => 0xff; -use constant ATTR_ARRAYD_NA => 0xff; use constant ATTR_FLAG_CONST => 1; -# From fapiPlatAttrOverrideDirect.C +# From fapiPlatAttrOverrideSync.C +use constant MAX_DIRECT_OVERRIDE_ATTR_SIZE_BYTES => 64; +my $overrideHeaderSymbol = 'fapi::g_attrOverrideHeader'; my $overrideSymbol = 'fapi::g_attrOverride'; +my $overrideFapiTankSymbol = 'fapi::g_attrOverrideFapiTank'; # Expected filenames -my $attributeIdsFileName = 'fapiAttributeIds.txt'; -my $attributeEnumsFileName = 'fapiAttributeEnums.txt'; +my $fapiAttrInfoFileName = 'fapiAttrInfo.csv'; +my $fapiAttrEnumInfoFileName = 'fapiAttrEnumInfo.csv'; +my $targAttrInfoFileName = 'targAttrInfo.csv'; my $overrideFileName = 'OverrideAttrs.txt'; sub main @@ -76,389 +79,591 @@ sub main } #-------------------------------------------------------------------------- - # Check if the Attribute IDs/Enums and Attribute Overrides files exist + # Get the address of the Hostboot Attribute Override variables #-------------------------------------------------------------------------- - my $attributeIdsFile = ::getImgPath(); - $attributeIdsFile = $attributeIdsFile."$attributeIdsFileName"; - unless (-e $attributeIdsFile) + my $overrideHeaderSymAddr = (::findSymbolAddress("$overrideHeaderSymbol"))[0]; + + if (not defined $overrideHeaderSymAddr) + { + ::userDisplay "Cannot find Hostboot symbol '$overrideHeaderSymbol'\n"; + die; + } + + my $overrideHeaderAddr = Hostboot::_DebugFrameworkVMM::getPhysicalAddr( + $overrideHeaderSymAddr, $debug, 0); + + if ($overrideHeaderAddr eq Hostboot::_DebugFrameworkVMM::NotFound) { - die "Cannot find file $attributeIdsFile"; + ::userDisplay "Cannot translate '$overrideHeaderSymbol' to a phys addr\n"; + die; } - my $attributeEnumsFile = ::getImgPath(); - $attributeEnumsFile = $attributeEnumsFile."$attributeEnumsFileName"; - unless (-e $attributeEnumsFile) + #-------------------------------------------------------------------------- + my $overrideSymAddr = (::findSymbolAddress("$overrideSymbol"))[0]; + + if (not defined $overrideSymAddr) { - die "Cannot find file $attributeEnumsFile"; + ::userDisplay "Cannot find Hostboot symbol '$overrideSymbol'\n"; + die; + } + + my $overrideAddr = Hostboot::_DebugFrameworkVMM::getPhysicalAddr( + $overrideSymAddr, $debug, 0); + + if ($overrideAddr eq Hostboot::_DebugFrameworkVMM::NotFound) + { + ::userDisplay "Cannot translate '$overrideSymbol' to a phys addr\n"; + die; + } + + #-------------------------------------------------------------------------- + my $overrideFapiTankSymAddr = (::findSymbolAddress("$overrideFapiTankSymbol"))[0]; + + if (not defined $overrideFapiTankSymAddr) + { + ::userDisplay "Cannot find Hostboot symbol '$overrideFapiTankSymbol'\n"; + die; + } + + my $overrideFapiTankAddr = Hostboot::_DebugFrameworkVMM::getPhysicalAddr( + $overrideFapiTankSymAddr, $debug, 0); + + if ($overrideFapiTankAddr eq Hostboot::_DebugFrameworkVMM::NotFound) + { + ::userDisplay "Cannot translate '$overrideFapiTankSymbol' to a phys addr\n"; + die; + } + + #-------------------------------------------------------------------------- + # Check if the Attribute info and Override files exist + #-------------------------------------------------------------------------- + my $fapiAttrInfoFile = ::getImgPath(); + $fapiAttrInfoFile .= "$fapiAttrInfoFileName"; + unless (-e $fapiAttrInfoFile) + { + die "Cannot find file '$fapiAttrInfoFile'"; + } + + my $fapiAttrEnumInfoFile = ::getImgPath(); + $fapiAttrEnumInfoFile .= "$fapiAttrEnumInfoFileName"; + unless (-e $fapiAttrEnumInfoFile) + { + die "Cannot find file '$fapiAttrEnumInfoFile'"; + } + + my $targAttrInfoFile = ::getImgPath(); + $targAttrInfoFile .= "$targAttrInfoFileName"; + unless (-e $targAttrInfoFile) + { + die "Cannot find file '$targAttrInfoFile'"; } my $overrideFile = ::getImgPath(); $overrideFile = $overrideFile."$overrideFileName"; unless (-e $overrideFile) { - die "Cannot find file $overrideFile"; + die "Cannot find file '$overrideFile'"; + } + + #-------------------------------------------------------------------------- + # Process the FAPI Attribute Info file. Record the ATTR-ID-VAL and + # ATTR-TYPE in a hash indexed by ATTR-ID-STR. Note that for FAPI Attributes + # FAPI-ATTR-ID-STR and LAYER-ATTR-ID-STR will be identical + # + # Format: <FAPI-ATTR-ID-STR>,<LAYER-ATTR-ID-STR>,<ATTR-ID-VAL>,<ATTR-TYPE> + #-------------------------------------------------------------------------- + my %fapiAttrInfo; + + open(FAPIATTFILE, "< $fapiAttrInfoFile") or die + "Cannot open file '$fapiAttrInfoFile'"; + while (my $line = <FAPIATTFILE>) + { + chomp($line); + + # Skip comment lines + if (!($line =~ /^#/)) + { + if ($line =~ /(ATTR_\S+),ATTR_\S+,0x(\S+),(\S+)/) + { + $fapiAttrInfo{$1}->{idVal} = hex $2; + $fapiAttrInfo{$1}->{typeStr} = $3; + } + } } + close(FAPIATTFILE); #-------------------------------------------------------------------------- - # Process the Attribute ID file. Record the values of the Attribute IDs in - # a hash + # Process the TARG Attribute Info file. Record the ATTR-ID-VAL and + # ATTR-TYPE in a hash indexed by ATTR-ID-STR. Note that for TARG Attributes + # FAPI-ATTR-ID-STR and LAYER-ATTR-ID-STR may be different and if the + # TARG attribute does not map to a FAPI attribute then FAPI-ATTR-ID-STR + # will be NO-FAPI-ID + # + # Format: <FAPI-ATTR-ID-STR>,<LAYER-ATTR-ID-STR>,<ATTR-ID-VAL>,<ATTR-TYPE> #-------------------------------------------------------------------------- - my %attributeIdVals; + my %targAttrInfo; - open(IDFILE, "< $attributeIdsFile") or die "Cannot open file $attributeIdsFile"; - while (my $line = <IDFILE>) + open(TARGATTFILE, "< $targAttrInfoFile") or die + "Cannot open file '$targAttrInfoFile'"; + while (my $line = <TARGATTFILE>) { chomp($line); - if ($line =~ /(ATTR_\S+) 0x(\S+)/) + # Skip comment lines + if (!($line =~ /^#/)) { - # Found an attribute ID - $attributeIdVals{$1} = hex $2 + if ($line =~ /(\S+),(ATTR_\S+),(\S+),(\S+)/) + { + if ($1 ne "NO-FAPI-ID") + { + $targAttrInfo{$1}->{idVal} = $3; + $targAttrInfo{$1}->{typeStr} = $4; + } + + $targAttrInfo{$2}->{idVal} = $3; + $targAttrInfo{$2}->{typeStr} = $4; + } } } - close(IDFILE); + close(TARGATTFILE); #-------------------------------------------------------------------------- - # Process the Attribute ENUM file. Record the values of the Attribute ENUMs - # in a hash + # Process the FAPI Attribute Enum Info file. Record the values of the + # Attribute ENUMs in a hash #-------------------------------------------------------------------------- - my %attributeEnumVals; + my %fapiAttrEnumVals; - open(ENUMFILE, "< $attributeEnumsFile") or die "Cannot open file $attributeEnumsFile"; + open(ENUMFILE, "< $fapiAttrEnumInfoFile") or die + "Cannot open file '$fapiAttrEnumInfoFile'"; while (my $line = <ENUMFILE>) { # Note that enumerated values can end with 'ULL' if ($line =~ /(ATTR_\S+) = 0x([a-fA-F0-9]+)/) { # Found a hex attribute value enumeration - $attributeEnumVals{$1} = hex $2; + $fapiAttrEnumVals{$1} = hex $2; } elsif ($line =~ /(ATTR_\S+) = ([0-9]+)/) { # Found a decimal attribute value enumeration - $attributeEnumVals{$1} = $2; + $fapiAttrEnumVals{$1} = $2; } } close(ENUMFILE); - # Debug output - if ($debug) - { - foreach my $key (keys %attributeIdVals) - { - ::userDisplay "AttrIdVal: $key => $attributeIdVals{$key}\n"; - } - foreach my $key (keys %attributeEnumVals) - { - ::userDisplay "AttrEnumVal: $key => $attributeEnumVals{$key}\n"; - } - } - #-------------------------------------------------------------------------- - # Process the Attribute Overrides file. Record the information for each - # override in arrays + # Process the Attribute Overrides file #-------------------------------------------------------------------------- - my @attrIdString; - my @val; - my @attrId; - my @targetType; - my @pos; - my @unitPos; - my @flags; - my @arrayD1; - my @arrayD2; - my @arrayD3; - my @arrayD4; - + my $targLine = ""; my $numOverrides = 0; - my $curTargetType = TARGET_TYPE_SYSTEM; - my $curPos = ATTR_POS_NA; - my $curUnitPos = ATTR_UNIT_POS_NA; - - open(OVFILE, "< $overrideFile") or die "Cannot open file $overrideFile"; - - while (my $line = <OVFILE>) + my $attrString = ""; + my @attrLines; + + #-------------------------------------------------------------------------- + # Iterate over all lines in the Attribute Overrides file + #-------------------------------------------------------------------------- + open(OVFILE, "< $overrideFile") or die "Cannot open file '$overrideFile'"; + my $line = <OVFILE>; + while ($line ne "") { - chomp($line); - - if ($line =~ /^target = /) + #---------------------------------------------------------------------- + # Find all lines making up a single attribute override. There are + # multiple lines for a multi-dimensional attribute + #---------------------------------------------------------------------- + $attrString = ""; + @attrLines = (); + + while ($line ne "") { - # Found a target - my $p8pres = 0; + chomp($line); - # Figure out the target type - if ($line =~ /p8.ex/) + if ($line =~ /^target = /) { - $p8pres = 1; - $curTargetType = TARGET_TYPE_EX_CHIPLET; - } - elsif ($line =~ /centaur.mba/) - { - $curTargetType = TARGET_TYPE_MBA_CHIPLET; - } - elsif ($line =~ /p8.mcs/) - { - $p8pres = 1; - $curTargetType = TARGET_TYPE_MCS_CHIPLET; - } - elsif ($line =~ /p8.xbus/) - { - $p8pres = 1; - $curTargetType = TARGET_TYPE_XBUS_ENDPOINT; - } - elsif ($line =~ /p8.abus/) - { - $p8pres = 1; - $curTargetType = TARGET_TYPE_ABUS_ENDPOINT; - } - elsif ($line =~ /centaur/) - { - $curTargetType = TARGET_TYPE_MEMBUF_CHIP; - } - elsif ($line =~ /p8/) - { - $p8pres = 1; - $curTargetType = TARGET_TYPE_PROC_CHIP; + if ($attrString eq "") + { + # Not currently processing attribute lines, save the target + # line, it is for following attribute lines + $targLine = $line; + $line = <OVFILE>; + last; + } + else + { + # Currently processing attribute lines. Break out of the + # loop to process the current set and look at this target + # line in the next iteration + last; + } } - elsif ($line =~ /dimm/) + elsif ($line =~ /^(ATTR_\w+)/) { - $curTargetType = TARGET_TYPE_DIMM; + # Found an attribute override line + if ($attrString eq "") + { + # First override line for an attribute + $attrString = $1; + } + elsif ($attrString ne $1) + { + # Override line for a different attribute. Break out of the + # loop to process the current attribute override and look + # at this line in the next main loop + last; + } + + # Add the attribute override line to the set of lines to + # process for a single override and get the next line + push(@attrLines, $line); + $line = <OVFILE>; } else { - $curTargetType = TARGET_TYPE_SYSTEM; + # Not a target or attribute line, get the next line + $line = <OVFILE>; } + } # end of finding all lines making up a single attr override - # Figure out the position - if ($p8pres == 1) + if (scalar(@attrLines) > 0) + { + #------------------------------------------------------------------ + # Process the set of lines making up a single attribute override + #------------------------------------------------------------------ + my $attrIdStr = ""; + my $attrIdVal = 0; + my $fapiTank = 0; + my $elemSize = 0; + my $d1 = 1; # First dimension of the attribute + my $d2 = 1; + my $d3 = 1; + my $d4 = 1; + my $valSize = 0; + my $flags = 0; + + foreach my $attrLine(@attrLines) { - # Do not confuse 'p8' for position 8 - if ($line =~ /p8\S*:p(\d+)/) + my $td1 = 0; # First dimension of this line's element + my $td2 = 0; + my $td3 = 0; + my $td4 = 0; + my $val = 0; + + if ($attrIdStr eq "") { - $curPos = $1; + # This is the first line, figure out the attrIdStr + if ($attrLine =~ /^(ATTR_\w+)/) + { + $attrIdStr = $1; + } + else + { + ::userDisplay "Cannot find attr id str in '$attrLine'\n"; + die; + } + + # Use the data gathered from the AttrInfo files to figure out + # the attrIdVal, typeStr and tank Info + my $typeStr = ""; + + if (exists $targAttrInfo{$attrIdStr}) + { + $attrIdVal = $targAttrInfo{$attrIdStr}->{idVal}; + $typeStr = $targAttrInfo{$attrIdStr}->{typeStr}; + $fapiTank = 0; + } + elsif (exists $fapiAttrInfo{$attrIdStr}) + { + $attrIdVal = $fapiAttrInfo{$attrIdStr}->{idVal}; + $typeStr = $fapiAttrInfo{$attrIdStr}->{typeStr}; + $fapiTank = 1; + } + else + { + ::userDisplay "Cannot find '$attrIdStr' in attribute info files\n"; + die; + } + + # Figure out the attribute element size + if ($typeStr =~ /^u8/) + { + $elemSize = 1; + } + elsif ($typeStr =~ /^u16/) + { + $elemSize = 2; + } + elsif ($typeStr =~ /^u32/) + { + $elemSize = 4; + } + elsif ($typeStr =~ /^u64/) + { + $elemSize = 8; + } + else + { + ::userDisplay "Bad type string '$typeStr' in attribute info file\n"; + die; + } + + # Remove the attribute element type from typeStr + $typeStr =~ s/u\w+//; + + # Figure out the attribute array dimensions + if ($typeStr =~ /^\[(\d+)\]/) + { + $d1 = $1; + } + if ($typeStr =~ /^\[\d+\]\[(\d+)\]/) + { + $d2 = $1; + } + if ($typeStr =~ /^\[\d+\]\[\d+\]\[(\d+)\]/) + { + $d3 = $1; + } + if ($typeStr =~ /^\[\d+\]\[\d+\]\[\d+\]\[(\d+)\]/) + { + $d4 = $1; + } + + # Calculate the attribute value size + $valSize = $elemSize * $d1 * $d2 * $d3 * $d4; + + if ($valSize > MAX_DIRECT_OVERRIDE_ATTR_SIZE_BYTES) + { + ::userDisplay "Attribute size too big ($valSize bytes) to directly override\n"; + die; + } } - else + + # Figure out this element's dimensions + if ($attrLine =~ /^ATTR_\w+\[(\d+)\]/) { - $curPos = ATTR_POS_NA; + $td1 = $1; } - } - else - { - if ($line =~ /:p(\d+)/) + if ($attrLine =~ /^ATTR_\w+\[\d+\]\[(\d+)\]/) + { + $td2 = $1; + } + if ($attrLine =~ /^ATTR_\w+\[\d+\]\[\d+\]\[(\d+)\]/) + { + $td3 = $1; + } + if ($attrLine =~ /^ATTR_\w+\[\d+\]\[\d+\]\[\d+\]\[(\d+)\]/) { - $curPos = $1; + $td4 = $1; + } + + # Check for overflow + if (($td1 >= $d1) || ($td2 >= $d2) || ($td3 >= $d3) || + ($td4 >= $d4)) + { + ::userDisplay "Attribute '$attrLine' overflows its array\n"; + ::userDisplay "$td1:$d1:$td2:$d2:$td3:$d3:$td4:$d4\n"; + die; + } + + # Remove the Attribute ID and any dimensions from the line + $attrLine =~ s/^ATTR_\S+\s+//; + + # If the line includes a type field then remove it + $attrLine =~ s/^u8\S*\s+//; + $attrLine =~ s/^u16\S*\s+//; + $attrLine =~ s/^u32\S*\s+//; + $attrLine =~ s/^u64\S*\s+//; + + # Figure out the override value + if ($attrLine =~ /^([A-Za-z]+\S*)/) + { + # enumerator + my $enum = "$attrIdStr"."_$1"; + if (exists $fapiAttrEnumVals{$enum}) + { + $val = $fapiAttrEnumVals{$enum}; + } + else + { + ::userDisplay "Cannot find enum '$enum' in '$fapiAttrEnumInfoFile'\n"; + die; + } + } + elsif ($attrLine =~ /^0x([0-9A-Za-z]+)/) + { + # Hex value + $val = hex $1; + } + elsif ($attrLine =~ /^(\d+)/) + { + # Decimal Value + $val = $1; } else { - $curPos = ATTR_POS_NA; + ::userDisplay "Cannot find override value for '$attrIdStr'\n"; + die; } - } - # Figure out the unit position - if ($line =~ /:c(\d+)/) - { - $curUnitPos = $1; - } - else + # Figure out if it is a const override + if ($attrLine =~ /CONST\s*/) + { + $flags = ATTR_FLAG_CONST; + } + + # Write element to Hostboot memory + my $addr = $overrideAddr; + + my $elemNum = $td4 + ($td3*$d4) + ($td2*$d3*$d4) + + ($td1*$d2*$d3*$d4); + $addr += $elemNum * $elemSize; + + if ($elemSize == 1) + { + ::write8($addr, $val); + } + elsif ($elemSize == 2) + { + ::write16($addr, $val); + } + elsif ($elemSize == 4) + { + ::write32($addr, $val); + } + elsif ($elemSize == 8) + { + ::write64($addr, $val); + } + + } # end of processing all lines making up a single attr override + + #------------------------------------------------------------------ + # Figure out the Target type/pos/unitpos + #------------------------------------------------------------------ + my $targType = TARGET_TYPE_SYSTEM; + my $targPos = ATTR_POS_NA; + my $targUnitPos = ATTR_UNIT_POS_NA; + + # Figure out the target type + my $targ = $targLine; + + if ($targ =~ /p8.ex/) { - $curUnitPos = ATTR_UNIT_POS_NA; + $targType = TARGET_TYPE_EX_CHIPLET; + $targ =~ s/^.*p8.ex//; } - } - elsif ($line =~ /^(ATTR_\w+)/) - { - # Found an override - $attrIdString[$numOverrides] = $1; - $targetType[$numOverrides] = $curTargetType; - $pos[$numOverrides] = $curPos; - $unitPos[$numOverrides] = $curUnitPos; - - # Figure out the attribute ID - if (exists $attributeIdVals{$1}) + elsif ($targ =~ /centaur.mba/) { - $attrId[$numOverrides] = $attributeIdVals{$1}; + $targType = TARGET_TYPE_MBA_CHIPLET; + $targ =~ s/^.*centaur.mba//; } - else + elsif ($targ =~ /p8.mcs/) { - ::userDisplay "Cannot find ID $1 in $attributeIdsFile\n"; - die; + $targType = TARGET_TYPE_MCS_CHIPLET; + $targ =~ s/^.*p8.mcs//; } - - # Figure out the attribute array dimensions - if ($line =~ /^ATTR_\w+\[(\d)\]\[(\d)\]\[(\d)\]\[(\d)\] /) + elsif ($targ =~ /p8.xbus/) { - # 4D array override - $arrayD1[$numOverrides] = $1; - $arrayD2[$numOverrides] = $2; - $arrayD3[$numOverrides] = $3; - $arrayD4[$numOverrides] = $4; + $targType = TARGET_TYPE_XBUS_ENDPOINT; + $targ =~ s/^.*p8.xbus//; } - elsif ($line =~ /^ATTR_\w+\[(\d)\]\[(\d)\]\[(\d)\] /) + elsif ($targ =~ /p8.abus/) { - # 3D array override - $arrayD1[$numOverrides] = $1; - $arrayD2[$numOverrides] = $2; - $arrayD3[$numOverrides] = $3; - $arrayD4[$numOverrides] = ATTR_ARRAYD_NA; + $targType = TARGET_TYPE_ABUS_ENDPOINT; + $targ =~ s/^.*p8.abus//; } - elsif ($line =~ /^ATTR_\w+\[(\d)\]\[(\d)\] /) + elsif ($targ =~ /centaur/) { - # 2D array override - $arrayD1[$numOverrides] = $1; - $arrayD2[$numOverrides] = $2; - $arrayD3[$numOverrides] = ATTR_ARRAYD_NA; - $arrayD4[$numOverrides] = ATTR_ARRAYD_NA; + $targType = TARGET_TYPE_MEMBUF_CHIP; + $targ =~ s/^.*centaur//; } - elsif ($line =~ /^ATTR_\w+\[(\d)\] /) + elsif ($targ =~ /dimm/) { - # 1D array override - $arrayD1[$numOverrides] = $1; - $arrayD2[$numOverrides] = ATTR_ARRAYD_NA; - $arrayD3[$numOverrides] = ATTR_ARRAYD_NA; - $arrayD4[$numOverrides] = ATTR_ARRAYD_NA; + $targType = TARGET_TYPE_DIMM; + $targ =~ s/^.*dimm//; } - else + elsif ($targ =~ /p8/) { - # Non-array attribute - $arrayD1[$numOverrides] = ATTR_ARRAYD_NA; - $arrayD2[$numOverrides] = ATTR_ARRAYD_NA; - $arrayD3[$numOverrides] = ATTR_ARRAYD_NA; - $arrayD4[$numOverrides] = ATTR_ARRAYD_NA; + $targType = TARGET_TYPE_PROC_CHIP; + $targ =~ s/^.*p8//; } - # Figure out the override value - if ($line =~ /^ATTR_\S+\s+([A-Za-z]+\S*)/) - { - # enumerator - my $enum = "$attrIdString[$numOverrides]"."_$1"; - if (exists $attributeEnumVals{$enum}) - { - $val[$numOverrides] = $attributeEnumVals{$enum}; - } - else - { - ::userDisplay "Cannot find enum $enum in $attributeEnumsFile\n"; - die; - } - } - elsif ($line =~ /^ATTR_\S+\s+0x([0-9A-Za-z]+)/) - { - # Hex value - $val[$numOverrides] = hex $1; - } - elsif ($line =~ /^ATTR_\S+\s+(\d+)/) + # Figure out the position + if ($targ =~ /:p(\d+)/) { - # Decimal Value - $val[$numOverrides] = $1; + $targPos = $1; } else { - ::userDisplay "Cannot find override value for $attrIdString[$numOverrides]\n"; - die; + $targPos = ATTR_POS_NA; } - # Figure out if it is a const override - if ($line =~ /CONST\s*/) + # Figure out the unit position + if ($targ =~ /:c(\d+)/) { - $flags[$numOverrides] = ATTR_FLAG_CONST; + $targUnitPos = $1; } else { - $flags[$numOverrides] = 0; + $targUnitPos = ATTR_UNIT_POS_NA; } # Debug output if ($debug) { - ::userDisplay "OVERRIDE. Val: $val[$numOverrides]. "; - ::userDisplay "ID: $attrId[$numOverrides]. "; - ::userDisplay "TargType: $targetType[$numOverrides]. "; - ::userDisplay "Pos: $pos[$numOverrides].$unitPos[$numOverrides].\n"; - ::userDisplay " OFlags: $flags[$numOverrides]. "; - ::userDisplay "Dims: $arrayD1[$numOverrides]."; - ::userDisplay "$arrayD2[$numOverrides]."; - ::userDisplay "$arrayD3[$numOverrides]."; - ::userDisplay "$arrayD4[$numOverrides]\n"; + ::userDisplay "OVERRIDE. ID: $attrIdVal. "; + ::userDisplay "Targ: $targType.$targPos.$targUnitPos. "; + ::userDisplay "Flags: $flags\n"; } - $numOverrides++; - } - } - close(OVFILE); + #------------------------------------------------------------------ + # Write the overide to Hostboot memory + #------------------------------------------------------------------ + # From attributeTank.H + # struct AttributeHeader + # { + # uint32_t iv_attrId; // Attribute ID + # uint32_t iv_targetType; // Target Type attribute is for + # uint16_t iv_pos; // For chips/dimms the position + # // For chiplets the parent chip position + # uint8_t iv_unitPos; // For chiplets the position + # uint8_t iv_flags; // AttributeFlags enum value(s) + # uint32_t iv_valSize; // Size of the attribute value in bytes + # }; + my $addr = $overrideHeaderAddr; + ::write32($addr, $attrIdVal); + $addr += 4; + ::write32($addr, $targType); + $addr += 4; + ::write16($addr, $targPos); + $addr += 2; + ::write8($addr, $targUnitPos); + $addr += 1; + ::write8($addr, $flags); + $addr += 1; + ::write32($addr, $valSize); + + $addr = $overrideFapiTankAddr; + ::write8($addr, $fapiTank); + + #------------------------------------------------------------------ + # Tell Hostboot to apply the override + #------------------------------------------------------------------ + my $callFuncForce = 0; + my @callFuncParms; + Hostboot::CallFunc::execFunc("fapi::directOverride()", + $debug, $callFuncForce, \@callFuncParms); - #-------------------------------------------------------------------------- - # Get the address of the Hostboot Attribute Override variable - #-------------------------------------------------------------------------- - my $overrideSymAddr = (::findSymbolAddress("$overrideSymbol"))[0]; - - if (not defined $overrideSymAddr) - { - ::userDisplay "Cannot find Hostboot symbol $overrideSymbol\n"; - die; - } + if ($debug) + { + ::userDisplay "$attrIdStr sent\n"; + } - my $overrideAddr = - Hostboot::_DebugFrameworkVMM::getPhysicalAddr($overrideSymAddr, $debug, 0); + $numOverrides++; - if ($overrideAddr eq Hostboot::_DebugFrameworkVMM::NotFound) - { - ::userDisplay "Cannot translate $overrideSymbol to a physical address\n"; - die; - } + } # end of if there is an atribute override to process - # From fapiAttributeOverride.H - # struct AttributeOverride - # { - # uint64_t iv_val; // Large enough to hold the biggest attribute size - # uint32_t iv_attrId; // fapi::AttributeId enum value - # uint32_t iv_targetType; // fapi::TargetType enum value - # uint16_t iv_pos; // For chips/dimms the position - # // For chiplets the parent chip position - # uint8_t iv_unitPos; // For chiplets the position - # uint8_t iv_flags; // fapi::AttributeFlags enum value - # uint8_t iv_arrayD1; // Applies to element D1 in 1D or more array atts - # uint8_t iv_arrayD2; // Applies to element D2 in 2D or more array atts - # uint8_t iv_arrayD3; // Applies to element D3 in 3D or more array atts - # uint8_t iv_arrayD4; // Applies to element D4 in 4D array atts - # }; + } # end of iterating over all lines in an attr override file - #-------------------------------------------------------------------------- - # Send the overrides to Hostboot - #-------------------------------------------------------------------------- - for (my $i = 0; $i < $numOverrides; $i++) - { - # Write override to Hostboot - my $addr = $overrideAddr; - ::write64($addr, $val[$i]); - $addr += 8; - ::write32($addr, $attrId[$i]); - $addr += 4; - ::write32($addr, $targetType[$i]); - $addr += 4; - ::write16($addr, $pos[$i]); - $addr += 2; - ::write8($addr, $unitPos[$i]); - $addr++; - ::write8($addr, $flags[$i]); - $addr++; - ::write8($addr, $arrayD1[$i]); - $addr++; - ::write8($addr, $arrayD2[$i]); - $addr++; - ::write8($addr, $arrayD3[$i]); - $addr++; - ::write8($addr, $arrayD4[$i]); - - # Tell Hostboot to process the override - my $callFuncForce = 0; - my @callFuncParms; - Hostboot::CallFunc::execFunc("fapi::attrOverrideSync::directOverride()", - $debug, $callFuncForce, \@callFuncParms); - - if ($debug) - { - ::userDisplay "$attrIdString[$i] sent\n"; - } - } + close(OVFILE); ::userDisplay "All $numOverrides override(s) successfully sent to Hostboot\n"; } @@ -471,9 +676,11 @@ sub helpInfo options => { "debug" => ["More debug output."], }, - notes => ["Looks for three files in the image directory", - "$attributeIdsFileName: Contains attribute id values", - "$attributeEnumsFileName: Contains attribute enum values", + notes => ["Looks for four files in the image directory", + "$fapiAttrInfoFileName: Contains FAPI attribute info", + "$fapiAttrEnumInfoFileName: Contains FAPI attribute enum info", + "$targAttrInfoFileName: Contains TARG attribute info", "$overrideFileName: Contains the attribute overrides"] ); } + |